1 From b17597be763621ba63534fda6e1ea0a802be2087 Mon Sep 17 00:00:00 2001
2 From: Maxime Bizon <mbizon@freebox.fr>
3 Date: Fri, 18 Jul 2008 21:18:51 +0200
4 Subject: [PATCH] [MIPS] BCM63XX: Add PCMCIA & Cardbus support.
6 Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
8 arch/mips/bcm63xx/Makefile | 1 +
9 arch/mips/bcm63xx/dev-pcmcia.c | 135 +++++
10 drivers/pcmcia/Kconfig | 4 +
11 drivers/pcmcia/Makefile | 1 +
12 drivers/pcmcia/bcm63xx_pcmcia.c | 521 ++++++++++++++++++++
13 drivers/pcmcia/bcm63xx_pcmcia.h | 65 +++
14 include/asm-mips/mach-bcm63xx/bcm63xx_dev_pcmcia.h | 13 +
15 7 files changed, 740 insertions(+), 0 deletions(-)
16 create mode 100644 arch/mips/bcm63xx/dev-pcmcia.c
17 create mode 100644 drivers/pcmcia/bcm63xx_pcmcia.c
18 create mode 100644 drivers/pcmcia/bcm63xx_pcmcia.h
19 create mode 100644 include/asm-mips/mach-bcm63xx/bcm63xx_dev_pcmcia.h
21 diff --git a/arch/mips/bcm63xx/Makefile b/arch/mips/bcm63xx/Makefile
22 index 8f3299e..456e915 100644
23 --- a/arch/mips/bcm63xx/Makefile
24 +++ b/arch/mips/bcm63xx/Makefile
26 obj-y += clk.o cpu.o cs.o gpio.o irq.o prom.o setup.o timer.o
28 +obj-y += dev-pcmcia.o
29 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
30 diff --git a/arch/mips/bcm63xx/dev-pcmcia.c b/arch/mips/bcm63xx/dev-pcmcia.c
32 index 0000000..40ec4bc
34 +++ b/arch/mips/bcm63xx/dev-pcmcia.c
37 + * This file is subject to the terms and conditions of the GNU General Public
38 + * License. See the file "COPYING" in the main directory of this archive
41 + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
44 +#include <linux/init.h>
45 +#include <linux/kernel.h>
46 +#include <asm/bootinfo.h>
47 +#include <linux/platform_device.h>
48 +#include <bcm63xx_cs.h>
49 +#include <bcm63xx_cpu.h>
50 +#include <bcm63xx_dev_pcmcia.h>
51 +#include <bcm63xx_io.h>
52 +#include <bcm63xx_regs.h>
54 +static struct resource pcmcia_resources[] = {
55 + /* pcmcia registers */
57 + .start = -1, /* filled at runtime */
58 + .end = -1, /* filled at runtime */
59 + .flags = IORESOURCE_MEM,
62 + /* pcmcia memory zone resources */
64 + .start = BCM_PCMCIA_COMMON_BASE_PA,
65 + .end = BCM_PCMCIA_COMMON_END_PA,
66 + .flags = IORESOURCE_MEM,
69 + .start = BCM_PCMCIA_ATTR_BASE_PA,
70 + .end = BCM_PCMCIA_ATTR_END_PA,
71 + .flags = IORESOURCE_MEM,
74 + .start = BCM_PCMCIA_IO_BASE_PA,
75 + .end = BCM_PCMCIA_IO_END_PA,
76 + .flags = IORESOURCE_MEM,
81 + .start = -1, /* filled at runtime */
82 + .flags = IORESOURCE_IRQ,
85 + /* declare PCMCIA IO resource also */
87 + .start = BCM_PCMCIA_IO_BASE_PA,
88 + .end = BCM_PCMCIA_IO_END_PA,
89 + .flags = IORESOURCE_IO,
93 +static struct bcm63xx_pcmcia_platform_data pd;
95 +static struct platform_device bcm63xx_pcmcia_device = {
96 + .name = "bcm63xx_pcmcia",
98 + .num_resources = ARRAY_SIZE(pcmcia_resources),
99 + .resource = pcmcia_resources,
101 + .platform_data = &pd,
105 +static int __init config_pcmcia_cs(unsigned int cs,
106 + u32 base, unsigned int size)
110 + ret = bcm63xx_set_cs_status(cs, 0);
112 + ret = bcm63xx_set_cs_base(cs, base, size);
114 + ret = bcm63xx_set_cs_status(cs, 1);
118 +static const __initdata unsigned int pcmcia_cs[3][3] = {
119 + /* cs, base address, size */
120 + { MPI_CS_PCMCIA_COMMON, BCM_PCMCIA_COMMON_BASE_PA,
121 + BCM_PCMCIA_COMMON_SIZE },
123 + { MPI_CS_PCMCIA_ATTR, BCM_PCMCIA_ATTR_BASE_PA,
124 + BCM_PCMCIA_ATTR_SIZE },
126 + { MPI_CS_PCMCIA_IO, BCM_PCMCIA_IO_BASE_PA,
127 + BCM_PCMCIA_IO_SIZE },
130 +int __init bcm63xx_pcmcia_register(void)
134 + if (!BCMCPU_IS_6348() && !BCMCPU_IS_6358())
137 + /* use correct pcmcia ready gpio depending on processor */
138 + switch (bcm63xx_get_cpu_id()) {
139 + case BCM6348_CPU_ID:
140 + pd.ready_gpio = 22;
143 + case BCM6358_CPU_ID:
144 + pd.ready_gpio = 22;
151 + pcmcia_resources[0].start = bcm63xx_regset_address(RSET_PCMCIA);
152 + pcmcia_resources[0].end = pcmcia_resources[0].start;
153 + pcmcia_resources[0].end += RSET_PCMCIA_SIZE - 1;
154 + pcmcia_resources[4].start = bcm63xx_get_irq_number(IRQ_PCMCIA);
156 + /* configure pcmcia chip selects */
157 + for (i = 0; i < 3; i++) {
158 + ret = config_pcmcia_cs(pcmcia_cs[i][0],
165 + return platform_device_register(&bcm63xx_pcmcia_device);
168 + printk(KERN_ERR "unable to set pcmcia chip select");
171 diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
172 index e0f8840..5c640ca 100644
173 --- a/drivers/pcmcia/Kconfig
174 +++ b/drivers/pcmcia/Kconfig
175 @@ -196,6 +196,10 @@ config PCMCIA_AU1X00
176 tristate "Au1x00 pcmcia support"
177 depends on SOC_AU1X00 && PCMCIA
179 +config PCMCIA_BCM63XX
180 + tristate "bcm63xx pcmcia support"
181 + depends on BCM63XX && PCMCIA
184 tristate "SA1100 support"
185 depends on ARM && ARCH_SA1100 && PCMCIA
186 diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
187 index 269a9e9..32b19b5 100644
188 --- a/drivers/pcmcia/Makefile
189 +++ b/drivers/pcmcia/Makefile
190 @@ -33,6 +33,7 @@ obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_core.o pxa2xx_cs.o
191 obj-$(CONFIG_M32R_PCC) += m32r_pcc.o
192 obj-$(CONFIG_M32R_CFC) += m32r_cfc.o
193 obj-$(CONFIG_PCMCIA_AU1X00) += au1x00_ss.o
194 +obj-$(CONFIG_PCMCIA_BCM63XX) += bcm63xx_pcmcia.o
195 obj-$(CONFIG_PCMCIA_VRC4171) += vrc4171_card.o
196 obj-$(CONFIG_PCMCIA_VRC4173) += vrc4173_cardu.o
197 obj-$(CONFIG_OMAP_CF) += omap_cf.o
198 diff --git a/drivers/pcmcia/bcm63xx_pcmcia.c b/drivers/pcmcia/bcm63xx_pcmcia.c
200 index 0000000..3a0b7fc
202 +++ b/drivers/pcmcia/bcm63xx_pcmcia.c
205 + * This file is subject to the terms and conditions of the GNU General Public
206 + * License. See the file "COPYING" in the main directory of this archive
207 + * for more details.
209 + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
212 +#include <linux/kernel.h>
213 +#include <linux/module.h>
214 +#include <linux/ioport.h>
215 +#include <linux/timer.h>
216 +#include <linux/platform_device.h>
217 +#include <linux/delay.h>
218 +#include <linux/pci.h>
219 +#include <linux/gpio.h>
221 +#include <bcm63xx_regs.h>
222 +#include <bcm63xx_io.h>
223 +#include "bcm63xx_pcmcia.h"
225 +#define PFX "bcm63xx_pcmcia: "
227 +#ifdef CONFIG_CARDBUS
228 +/* if cardbus is used, platform device needs reference to actual pci
230 +static struct pci_dev *bcm63xx_cb_dev;
234 + * read/write helper for pcmcia regs
236 +static inline u32 pcmcia_readl(struct bcm63xx_pcmcia_socket *skt, u32 off)
238 + return bcm_readl(skt->base + off);
241 +static inline void pcmcia_writel(struct bcm63xx_pcmcia_socket *skt,
244 + bcm_writel(val, skt->base + off);
248 + * (Re-)Initialise the socket, turning on status interrupts and PCMCIA
249 + * bus. This must wait for power to stabilise so that the card status
250 + * signals report correctly.
252 +static int bcm63xx_pcmcia_sock_init(struct pcmcia_socket *sock)
254 + struct bcm63xx_pcmcia_socket *skt;
255 + skt = sock->driver_data;
260 + * Remove power on the socket, disable IRQs from the card.
261 + * Turn off status interrupts, and disable the PCMCIA bus.
263 +static int bcm63xx_pcmcia_suspend(struct pcmcia_socket *sock)
265 + struct bcm63xx_pcmcia_socket *skt;
266 + skt = sock->driver_data;
271 + * Implements the set_socket() operation for the in-kernel PCMCIA
272 + * service (formerly SS_SetSocket in Card Services). We more or
273 + * less punt all of this work and let the kernel handle the details
274 + * of power configuration, reset, &c. We also record the value of
275 + * `state' in order to regurgitate it to the PCMCIA core later.
277 +static int bcm63xx_pcmcia_set_socket(struct pcmcia_socket *sock,
278 + socket_state_t *state)
280 + struct bcm63xx_pcmcia_socket *skt;
281 + unsigned long flags;
284 + skt = sock->driver_data;
286 + spin_lock_irqsave(&skt->lock, flags);
288 + /* apply requested socket power */
289 + /* FIXME: hardware can't do this */
291 + /* apply socket reset */
292 + val = pcmcia_readl(skt, PCMCIA_C1_REG);
293 + if (state->flags & SS_RESET)
294 + val |= PCMCIA_C1_RESET_MASK;
296 + val &= ~PCMCIA_C1_RESET_MASK;
298 + /* reverse reset logic for cardbus card */
299 + if (skt->card_detected && (skt->card_type & CARD_CARDBUS))
300 + val ^= PCMCIA_C1_RESET_MASK;
302 + pcmcia_writel(skt, val, PCMCIA_C1_REG);
304 + /* keep requested state for event reporting */
305 + skt->requested_state = *state;
307 + spin_unlock_irqrestore(&skt->lock, flags);
313 + * identity cardtype from VS[12] input, CD[12] input while only VS2 is
314 + * floating, and CD[12] input while only VS1 is floating
319 + IN_CD1_VS2H = (1 << 2),
320 + IN_CD2_VS2H = (1 << 3),
321 + IN_CD1_VS1H = (1 << 4),
322 + IN_CD2_VS1H = (1 << 5),
325 +static const u8 vscd_to_cardtype[] = {
327 + /* VS1 float, VS2 float */
328 + [IN_VS1 | IN_VS2] = (CARD_PCCARD | CARD_5V),
330 + /* VS1 grounded, VS2 float */
331 + [IN_VS2] = (CARD_PCCARD | CARD_5V | CARD_3V),
333 + /* VS1 grounded, VS2 grounded */
334 + [0] = (CARD_PCCARD | CARD_5V | CARD_3V | CARD_XV),
336 + /* VS1 tied to CD1, VS2 float */
337 + [IN_VS1 | IN_VS2 | IN_CD1_VS1H] = (CARD_CARDBUS | CARD_3V),
339 + /* VS1 grounded, VS2 tied to CD2 */
340 + [IN_VS2 | IN_CD2_VS2H] = (CARD_CARDBUS | CARD_3V | CARD_XV),
342 + /* VS1 tied to CD2, VS2 grounded */
343 + [IN_VS1 | IN_CD2_VS1H] = (CARD_CARDBUS | CARD_3V | CARD_XV | CARD_YV),
345 + /* VS1 float, VS2 grounded */
346 + [IN_VS1] = (CARD_PCCARD | CARD_XV),
348 + /* VS1 float, VS2 tied to CD2 */
349 + [IN_VS1 | IN_VS2 | IN_CD2_VS2H] = (CARD_CARDBUS | CARD_3V),
351 + /* VS1 float, VS2 tied to CD1 */
352 + [IN_VS1 | IN_VS2 | IN_CD1_VS2H] = (CARD_CARDBUS | CARD_XV | CARD_YV),
354 + /* VS1 tied to CD2, VS2 float */
355 + [IN_VS1 | IN_VS2 | IN_CD2_VS1H] = (CARD_CARDBUS | CARD_YV),
357 + /* VS2 grounded, VS1 is tied to CD1, CD2 is grounded */
358 + [IN_VS1 | IN_CD1_VS1H] = 0, /* ignore cardbay */
362 + * poll hardware to check card insertion status
364 +static unsigned int __get_socket_status(struct bcm63xx_pcmcia_socket *skt)
371 + /* check CD for card presence */
372 + val = pcmcia_readl(skt, PCMCIA_C1_REG);
374 + if (!(val & PCMCIA_C1_CD1_MASK) && !(val & PCMCIA_C1_CD2_MASK))
377 + /* if new insertion, detect cardtype */
378 + if ((stat & SS_DETECT) && !skt->card_detected) {
379 + unsigned int stat = 0;
381 + /* float VS1, float VS2 */
382 + val |= PCMCIA_C1_VS1OE_MASK;
383 + val |= PCMCIA_C1_VS2OE_MASK;
384 + pcmcia_writel(skt, val, PCMCIA_C1_REG);
386 + /* wait for output to stabilize and read VS[12] */
388 + val = pcmcia_readl(skt, PCMCIA_C1_REG);
389 + stat |= (val & PCMCIA_C1_VS1_MASK) ? IN_VS1 : 0;
390 + stat |= (val & PCMCIA_C1_VS2_MASK) ? IN_VS2 : 0;
392 + /* drive VS1 low, float VS2 */
393 + val &= ~PCMCIA_C1_VS1OE_MASK;
394 + val |= PCMCIA_C1_VS2OE_MASK;
395 + pcmcia_writel(skt, val, PCMCIA_C1_REG);
397 + /* wait for output to stabilize and read CD[12] */
399 + val = pcmcia_readl(skt, PCMCIA_C1_REG);
400 + stat |= (val & PCMCIA_C1_CD1_MASK) ? IN_CD1_VS2H : 0;
401 + stat |= (val & PCMCIA_C1_CD2_MASK) ? IN_CD2_VS2H : 0;
403 + /* float VS1, drive VS2 low */
404 + val |= PCMCIA_C1_VS1OE_MASK;
405 + val &= ~PCMCIA_C1_VS2OE_MASK;
406 + pcmcia_writel(skt, val, PCMCIA_C1_REG);
408 + /* wait for output to stabilize and read CD[12] */
410 + val = pcmcia_readl(skt, PCMCIA_C1_REG);
411 + stat |= (val & PCMCIA_C1_CD1_MASK) ? IN_CD1_VS1H : 0;
412 + stat |= (val & PCMCIA_C1_CD2_MASK) ? IN_CD2_VS1H : 0;
414 + /* guess cardtype from all this */
415 + skt->card_type = vscd_to_cardtype[stat];
416 + if (!skt->card_type)
417 + printk(KERN_ERR PFX "unsupported card type\n");
419 + /* drive both VS pin to 0 again */
420 + val &= ~(PCMCIA_C1_VS1OE_MASK | PCMCIA_C1_VS2OE_MASK);
422 + /* enable correct logic */
423 + val &= ~(PCMCIA_C1_EN_PCMCIA_MASK | PCMCIA_C1_EN_CARDBUS_MASK);
424 + if (skt->card_type & CARD_PCCARD)
425 + val |= PCMCIA_C1_EN_PCMCIA_MASK;
427 + val |= PCMCIA_C1_EN_CARDBUS_MASK;
429 + pcmcia_writel(skt, val, PCMCIA_C1_REG);
431 + skt->card_detected = (stat & SS_DETECT) ? 1 : 0;
433 + /* report card type/voltage */
434 + if (skt->card_type & CARD_CARDBUS)
435 + stat |= SS_CARDBUS;
436 + if (skt->card_type & CARD_3V)
438 + if (skt->card_type & CARD_XV)
440 + stat |= SS_POWERON;
442 + if (gpio_get_value(skt->pd->ready_gpio))
449 + * core request to get current socket status
451 +static int bcm63xx_pcmcia_get_status(struct pcmcia_socket *sock,
452 + unsigned int *status)
454 + struct bcm63xx_pcmcia_socket *skt;
456 + skt = sock->driver_data;
458 + spin_lock_bh(&skt->lock);
459 + *status = __get_socket_status(skt);
460 + spin_unlock_bh(&skt->lock);
466 + * socket polling timer callback
468 +static void bcm63xx_pcmcia_poll(unsigned long data)
470 + struct bcm63xx_pcmcia_socket *skt;
471 + unsigned int stat, events;
473 + skt = (struct bcm63xx_pcmcia_socket *)data;
475 + spin_lock_bh(&skt->lock);
477 + stat = __get_socket_status(skt);
479 + /* keep only changed bits, and mask with required one from the
481 + events = (stat ^ skt->old_status) & skt->requested_state.csc_mask;
482 + skt->old_status = stat;
483 + spin_unlock_bh(&skt->lock);
486 + pcmcia_parse_events(&skt->socket, events);
488 + mod_timer(&skt->timer,
489 + jiffies + msecs_to_jiffies(BCM63XX_PCMCIA_POLL_RATE));
492 +static int bcm63xx_pcmcia_set_io_map(struct pcmcia_socket *sock,
493 + struct pccard_io_map *map)
495 + /* this doesn't seem to be called by pcmcia layer if static
496 + * mapping is used */
500 +static int bcm63xx_pcmcia_set_mem_map(struct pcmcia_socket *sock,
501 + struct pccard_mem_map *map)
503 + struct bcm63xx_pcmcia_socket *skt;
504 + struct resource *res;
506 + skt = sock->driver_data;
507 + if (map->flags & MAP_ATTRIB)
508 + res = skt->attr_res;
510 + res = skt->common_res;
512 + map->static_start = res->start + map->card_start;
516 +static struct pccard_operations bcm63xx_pcmcia_operations = {
517 + .init = bcm63xx_pcmcia_sock_init,
518 + .suspend = bcm63xx_pcmcia_suspend,
519 + .get_status = bcm63xx_pcmcia_get_status,
520 + .set_socket = bcm63xx_pcmcia_set_socket,
521 + .set_io_map = bcm63xx_pcmcia_set_io_map,
522 + .set_mem_map = bcm63xx_pcmcia_set_mem_map,
526 + * register pcmcia socket to core
528 +static int bcm63xx_drv_pcmcia_probe(struct platform_device *pdev)
530 + struct bcm63xx_pcmcia_socket *skt;
531 + struct pcmcia_socket *sock;
532 + struct resource *res, *irq_res;
533 + unsigned int regmem_size = 0, iomem_size = 0;
537 + skt = kzalloc(sizeof(*skt), GFP_KERNEL);
540 + spin_lock_init(&skt->lock);
541 + sock = &skt->socket;
542 + sock->driver_data = skt;
544 + /* make sure we have all resources we need */
545 + skt->common_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
546 + skt->attr_res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
547 + irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
548 + skt->pd = pdev->dev.platform_data;
549 + if (!skt->common_res || !skt->attr_res || !irq_res || !skt->pd) {
554 + /* remap pcmcia registers */
555 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
556 + regmem_size = res->end - res->start + 1;
557 + if (!request_mem_region(res->start, regmem_size, "bcm63xx_pcmcia")) {
561 + skt->reg_res = res;
563 + skt->base = ioremap(res->start, regmem_size);
569 + /* remap io registers */
570 + res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
571 + iomem_size = res->end - res->start + 1;
572 + skt->io_base = ioremap(res->start, iomem_size);
573 + if (!skt->io_base) {
578 + /* resources are static */
579 + sock->resource_ops = &pccard_static_ops;
580 + sock->ops = &bcm63xx_pcmcia_operations;
581 + sock->owner = THIS_MODULE;
582 + sock->dev.parent = &pdev->dev;
583 + sock->features = SS_CAP_STATIC_MAP | SS_CAP_PCCARD;
584 + sock->io_offset = (unsigned long)skt->io_base;
585 + sock->pci_irq = irq_res->start;
587 +#ifdef CONFIG_CARDBUS
588 + sock->cb_dev = bcm63xx_cb_dev;
589 + if (bcm63xx_cb_dev)
590 + sock->features |= SS_CAP_CARDBUS;
593 + /* assume common & attribute memory have the same size */
594 + sock->map_size = skt->common_res->end - skt->common_res->start + 1;
596 + /* initialize polling timer */
597 + setup_timer(&skt->timer, bcm63xx_pcmcia_poll, (unsigned long)skt);
599 + /* initialize pcmcia control register, drive VS[12] to 0,
600 + * leave CB IDSEL to the old value since it is set by the PCI
602 + val = pcmcia_readl(skt, PCMCIA_C1_REG);
603 + val &= PCMCIA_C1_CBIDSEL_MASK;
604 + val |= PCMCIA_C1_EN_PCMCIA_GPIO_MASK;
605 + pcmcia_writel(skt, val, PCMCIA_C1_REG);
607 + /* FIXME set correct pcmcia timings */
608 + val = PCMCIA_C2_DATA16_MASK;
609 + val |= 10 << PCMCIA_C2_RWCOUNT_SHIFT;
610 + val |= 6 << PCMCIA_C2_INACTIVE_SHIFT;
611 + val |= 3 << PCMCIA_C2_SETUP_SHIFT;
612 + val |= 3 << PCMCIA_C2_HOLD_SHIFT;
613 + pcmcia_writel(skt, val, PCMCIA_C2_REG);
615 + ret = pcmcia_register_socket(sock);
619 + /* start polling socket */
620 + mod_timer(&skt->timer,
621 + jiffies + msecs_to_jiffies(BCM63XX_PCMCIA_POLL_RATE));
623 + platform_set_drvdata(pdev, skt);
628 + iounmap(skt->io_base);
630 + iounmap(skt->base);
632 + release_mem_region(skt->reg_res->start, regmem_size);
637 +static int bcm63xx_drv_pcmcia_remove(struct platform_device *pdev)
639 + struct bcm63xx_pcmcia_socket *skt;
640 + struct resource *res;
642 + skt = platform_get_drvdata(pdev);
643 + del_timer_sync(&skt->timer);
644 + iounmap(skt->base);
645 + iounmap(skt->io_base);
646 + res = skt->reg_res;
647 + release_mem_region(res->start, res->end - res->start + 1);
652 +struct platform_driver bcm63xx_pcmcia_driver = {
653 + .probe = bcm63xx_drv_pcmcia_probe,
654 + .remove = __devexit_p(bcm63xx_drv_pcmcia_remove),
656 + .name = "bcm63xx_pcmcia",
657 + .owner = THIS_MODULE,
661 +#ifdef CONFIG_CARDBUS
662 +static int __devinit bcm63xx_cb_probe(struct pci_dev *dev,
663 + const struct pci_device_id *id)
665 + /* keep pci device */
666 + bcm63xx_cb_dev = dev;
667 + return platform_driver_register(&bcm63xx_pcmcia_driver);
670 +static void __devexit bcm63xx_cb_exit(struct pci_dev *dev)
672 + platform_driver_unregister(&bcm63xx_pcmcia_driver);
673 + bcm63xx_cb_dev = NULL;
676 +static struct pci_device_id bcm63xx_cb_table[] = {
678 + .vendor = PCI_VENDOR_ID_BROADCOM,
679 + .device = PCI_ANY_ID,
680 + .subvendor = PCI_VENDOR_ID_BROADCOM,
681 + .subdevice = PCI_ANY_ID,
682 + .class = PCI_CLASS_BRIDGE_CARDBUS << 8,
687 +MODULE_DEVICE_TABLE(pci, bcm63xx_cb_table);
689 +static struct pci_driver bcm63xx_cardbus_driver = {
690 + .name = "yenta_cardbus",
691 + .id_table = bcm63xx_cb_table,
692 + .probe = bcm63xx_cb_probe,
693 + .remove = __devexit_p(bcm63xx_cb_exit),
698 + * if cardbus support is enabled, register our platform device after
699 + * our fake cardbus bridge has been registered
701 +static int __init bcm63xx_pcmcia_init(void)
703 +#ifdef CONFIG_CARDBUS
704 + return pci_register_driver(&bcm63xx_cardbus_driver);
706 + return platform_driver_register(&bcm63xx_pcmcia_driver);
710 +static void __exit bcm63xx_pcmcia_exit(void)
712 +#ifdef CONFIG_CARDBUS
713 + return pci_unregister_driver(&bcm63xx_cardbus_driver);
715 + platform_driver_unregister(&bcm63xx_pcmcia_driver);
719 +module_init(bcm63xx_pcmcia_init);
720 +module_exit(bcm63xx_pcmcia_exit);
722 +MODULE_LICENSE("GPL");
723 +MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
724 +MODULE_DESCRIPTION("Linux PCMCIA Card Services: bcm63xx Socket Controller");
725 diff --git a/drivers/pcmcia/bcm63xx_pcmcia.h b/drivers/pcmcia/bcm63xx_pcmcia.h
727 index 0000000..85de866
729 +++ b/drivers/pcmcia/bcm63xx_pcmcia.h
731 +#ifndef BCM63XX_PCMCIA_H_
732 +#define BCM63XX_PCMCIA_H_
734 +#include <linux/types.h>
735 +#include <linux/timer.h>
736 +#include <pcmcia/ss.h>
737 +#include <bcm63xx_dev_pcmcia.h>
739 +/* socket polling rate in ms */
740 +#define BCM63XX_PCMCIA_POLL_RATE 500
743 + CARD_CARDBUS = (1 << 0),
745 + CARD_PCCARD = (1 << 1),
747 + CARD_5V = (1 << 2),
749 + CARD_3V = (1 << 3),
751 + CARD_XV = (1 << 4),
753 + CARD_YV = (1 << 5),
756 +struct bcm63xx_pcmcia_socket {
757 + struct pcmcia_socket socket;
759 + /* platform specific data */
760 + struct bcm63xx_pcmcia_platform_data *pd;
762 + /* all regs access are protected by this spinlock */
765 + /* pcmcia registers resource */
766 + struct resource *reg_res;
768 + /* base remapped address of registers */
769 + void __iomem *base;
771 + /* whether a card is detected at the moment */
774 + /* type of detected card (mask of above enum) */
777 + /* keep last socket status to implement event reporting */
778 + unsigned int old_status;
780 + /* backup of requested socket state */
781 + socket_state_t requested_state;
783 + /* timer used for socket status polling */
784 + struct timer_list timer;
786 + /* attribute/common memory resources */
787 + struct resource *attr_res;
788 + struct resource *common_res;
789 + struct resource *io_res;
791 + /* base address of io memory */
792 + void __iomem *io_base;
795 +#endif /* BCM63XX_PCMCIA_H_ */
796 diff --git a/include/asm-mips/mach-bcm63xx/bcm63xx_dev_pcmcia.h b/include/asm-mips/mach-bcm63xx/bcm63xx_dev_pcmcia.h
798 index 0000000..2beb396
800 +++ b/include/asm-mips/mach-bcm63xx/bcm63xx_dev_pcmcia.h
802 +#ifndef BCM63XX_DEV_PCMCIA_H_
803 +#define BCM63XX_DEV_PCMCIA_H_
806 + * PCMCIA driver platform data
808 +struct bcm63xx_pcmcia_platform_data {
809 + unsigned int ready_gpio;
812 +int bcm63xx_pcmcia_register(void);
814 +#endif /* BCM63XX_DEV_PCMCIA_H_ */