2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <asm/bootinfo.h>
12 #include <linux/platform_device.h>
13 #include <bcm63xx_cs.h>
14 #include <bcm63xx_cpu.h>
15 #include <bcm63xx_dev_pcmcia.h>
16 #include <bcm63xx_io.h>
17 #include <bcm63xx_regs.h>
19 static struct resource pcmcia_resources
[] = {
20 /* pcmcia registers */
22 /* start & end filled at runtime */
23 .flags
= IORESOURCE_MEM
,
26 /* pcmcia memory zone resources */
28 .start
= BCM_PCMCIA_COMMON_BASE_PA
,
29 .end
= BCM_PCMCIA_COMMON_END_PA
,
30 .flags
= IORESOURCE_MEM
,
33 .start
= BCM_PCMCIA_ATTR_BASE_PA
,
34 .end
= BCM_PCMCIA_ATTR_END_PA
,
35 .flags
= IORESOURCE_MEM
,
38 .start
= BCM_PCMCIA_IO_BASE_PA
,
39 .end
= BCM_PCMCIA_IO_END_PA
,
40 .flags
= IORESOURCE_MEM
,
45 /* start filled at runtime */
46 .flags
= IORESOURCE_IRQ
,
49 /* declare PCMCIA IO resource also */
51 .start
= BCM_PCMCIA_IO_BASE_PA
,
52 .end
= BCM_PCMCIA_IO_END_PA
,
53 .flags
= IORESOURCE_IO
,
57 static struct bcm63xx_pcmcia_platform_data pd
;
59 static struct platform_device bcm63xx_pcmcia_device
= {
60 .name
= "bcm63xx_pcmcia",
62 .num_resources
= ARRAY_SIZE(pcmcia_resources
),
63 .resource
= pcmcia_resources
,
69 static int __init
config_pcmcia_cs(unsigned int cs
,
70 u32 base
, unsigned int size
)
74 ret
= bcm63xx_set_cs_status(cs
, 0);
76 ret
= bcm63xx_set_cs_base(cs
, base
, size
);
78 ret
= bcm63xx_set_cs_status(cs
, 1);
82 static const __initdata
struct {
88 .cs
= MPI_CS_PCMCIA_COMMON
,
89 .base
= BCM_PCMCIA_COMMON_BASE_PA
,
90 .size
= BCM_PCMCIA_COMMON_SIZE
93 .cs
= MPI_CS_PCMCIA_ATTR
,
94 .base
= BCM_PCMCIA_ATTR_BASE_PA
,
95 .size
= BCM_PCMCIA_ATTR_SIZE
98 .cs
= MPI_CS_PCMCIA_IO
,
99 .base
= BCM_PCMCIA_IO_BASE_PA
,
100 .size
= BCM_PCMCIA_IO_SIZE
104 int __init
bcm63xx_pcmcia_register(void)
108 if (!BCMCPU_IS_6348() && !BCMCPU_IS_6358())
111 /* use correct pcmcia ready gpio depending on processor */
112 switch (bcm63xx_get_cpu_id()) {
125 pcmcia_resources
[0].start
= bcm63xx_regset_address(RSET_PCMCIA
);
126 pcmcia_resources
[0].end
= pcmcia_resources
[0].start
+
127 RSET_PCMCIA_SIZE
- 1;
128 pcmcia_resources
[4].start
= bcm63xx_get_irq_number(IRQ_PCMCIA
);
130 /* configure pcmcia chip selects */
131 for (i
= 0; i
< 3; i
++) {
132 ret
= config_pcmcia_cs(pcmcia_cs
[i
].cs
,
139 return platform_device_register(&bcm63xx_pcmcia_device
);
142 printk(KERN_ERR
"unable to set pcmcia chip select\n");