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
= -1, /* filled at runtime */
23 .end
= -1, /* filled at runtime */
24 .flags
= IORESOURCE_MEM
,
27 /* pcmcia memory zone resources */
29 .start
= BCM_PCMCIA_COMMON_BASE_PA
,
30 .end
= BCM_PCMCIA_COMMON_END_PA
,
31 .flags
= IORESOURCE_MEM
,
34 .start
= BCM_PCMCIA_ATTR_BASE_PA
,
35 .end
= BCM_PCMCIA_ATTR_END_PA
,
36 .flags
= IORESOURCE_MEM
,
39 .start
= BCM_PCMCIA_IO_BASE_PA
,
40 .end
= BCM_PCMCIA_IO_END_PA
,
41 .flags
= IORESOURCE_MEM
,
46 .start
= -1, /* filled at runtime */
47 .flags
= IORESOURCE_IRQ
,
50 /* declare PCMCIA IO resource also */
52 .start
= BCM_PCMCIA_IO_BASE_PA
,
53 .end
= BCM_PCMCIA_IO_END_PA
,
54 .flags
= IORESOURCE_IO
,
58 static struct bcm63xx_pcmcia_platform_data pd
;
60 static struct platform_device bcm63xx_pcmcia_device
= {
61 .name
= "bcm63xx_pcmcia",
63 .num_resources
= ARRAY_SIZE(pcmcia_resources
),
64 .resource
= pcmcia_resources
,
70 static int __init
config_pcmcia_cs(unsigned int cs
,
71 u32 base
, unsigned int size
)
75 ret
= bcm63xx_set_cs_status(cs
, 0);
77 ret
= bcm63xx_set_cs_base(cs
, base
, size
);
79 ret
= bcm63xx_set_cs_status(cs
, 1);
83 static const __initdata
unsigned int pcmcia_cs
[3][3] = {
84 /* cs, base address, size */
85 { MPI_CS_PCMCIA_COMMON
, BCM_PCMCIA_COMMON_BASE_PA
,
86 BCM_PCMCIA_COMMON_SIZE
},
88 { MPI_CS_PCMCIA_ATTR
, BCM_PCMCIA_ATTR_BASE_PA
,
89 BCM_PCMCIA_ATTR_SIZE
},
91 { MPI_CS_PCMCIA_IO
, BCM_PCMCIA_IO_BASE_PA
,
95 int __init
bcm63xx_pcmcia_register(void)
99 if (!BCMCPU_IS_6348() && !BCMCPU_IS_6358())
102 /* use correct pcmcia ready gpio depending on processor */
103 switch (bcm63xx_get_cpu_id()) {
116 pcmcia_resources
[0].start
= bcm63xx_regset_address(RSET_PCMCIA
);
117 pcmcia_resources
[0].end
= pcmcia_resources
[0].start
;
118 pcmcia_resources
[0].end
+= RSET_PCMCIA_SIZE
- 1;
119 pcmcia_resources
[4].start
= bcm63xx_get_irq_number(IRQ_PCMCIA
);
121 /* configure pcmcia chip selects */
122 for (i
= 0; i
< 3; i
++) {
123 ret
= config_pcmcia_cs(pcmcia_cs
[i
][0],
130 return platform_device_register(&bcm63xx_pcmcia_device
);
133 printk(KERN_ERR
"unable to set pcmcia chip select");