2 * drivers/pcmcia/sa1100_shannon.c
4 * PCMCIA implementation routines for Shannon
7 #include <linux/module.h>
8 #include <linux/kernel.h>
9 #include <linux/device.h>
10 #include <linux/init.h>
12 #include <mach/hardware.h>
13 #include <asm/mach-types.h>
14 #include <mach/shannon.h>
16 #include "sa1100_generic.h"
18 static struct pcmcia_irqs irqs
[] = {
19 { 0, SHANNON_IRQ_GPIO_EJECT_0
, "PCMCIA_CD_0" },
20 { 1, SHANNON_IRQ_GPIO_EJECT_1
, "PCMCIA_CD_1" },
23 static int shannon_pcmcia_hw_init(struct soc_pcmcia_socket
*skt
)
25 /* All those are inputs */
26 GPDR
&= ~(SHANNON_GPIO_EJECT_0
| SHANNON_GPIO_EJECT_1
|
27 SHANNON_GPIO_RDY_0
| SHANNON_GPIO_RDY_1
);
28 GAFR
&= ~(SHANNON_GPIO_EJECT_0
| SHANNON_GPIO_EJECT_1
|
29 SHANNON_GPIO_RDY_0
| SHANNON_GPIO_RDY_1
);
31 skt
->socket
.pci_irq
= skt
->nr
? SHANNON_IRQ_GPIO_RDY_1
: SHANNON_IRQ_GPIO_RDY_0
;
33 return soc_pcmcia_request_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
36 static void shannon_pcmcia_hw_shutdown(struct soc_pcmcia_socket
*skt
)
38 soc_pcmcia_free_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
42 shannon_pcmcia_socket_state(struct soc_pcmcia_socket
*skt
,
43 struct pcmcia_state
*state
)
45 unsigned long levels
= GPLR
;
49 state
->detect
= (levels
& SHANNON_GPIO_EJECT_0
) ? 0 : 1;
50 state
->ready
= (levels
& SHANNON_GPIO_RDY_0
) ? 1 : 0;
51 state
->wrprot
= 0; /* Not available on Shannon. */
54 state
->vs_3v
= 1; /* FIXME Can only apply 3.3V on Shannon. */
59 state
->detect
= (levels
& SHANNON_GPIO_EJECT_1
) ? 0 : 1;
60 state
->ready
= (levels
& SHANNON_GPIO_RDY_1
) ? 1 : 0;
61 state
->wrprot
= 0; /* Not available on Shannon. */
64 state
->vs_3v
= 1; /* FIXME Can only apply 3.3V on Shannon. */
71 shannon_pcmcia_configure_socket(struct soc_pcmcia_socket
*skt
,
72 const socket_state_t
*state
)
75 case 0: /* power off */
76 printk(KERN_WARNING
"%s(): CS asked for 0V, still applying 3.3V..\n", __func__
);
79 printk(KERN_WARNING
"%s(): CS asked for 5V, applying 3.3V..\n", __func__
);
83 printk(KERN_ERR
"%s(): unrecognized Vcc %u\n",
84 __func__
, state
->Vcc
);
88 printk(KERN_WARNING
"%s(): Warning, Can't perform reset\n", __func__
);
90 /* Silently ignore Vpp, output enable, speaker enable. */
95 static void shannon_pcmcia_socket_init(struct soc_pcmcia_socket
*skt
)
97 soc_pcmcia_enable_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
100 static void shannon_pcmcia_socket_suspend(struct soc_pcmcia_socket
*skt
)
102 soc_pcmcia_disable_irqs(skt
, irqs
, ARRAY_SIZE(irqs
));
105 static struct pcmcia_low_level shannon_pcmcia_ops
= {
106 .owner
= THIS_MODULE
,
107 .hw_init
= shannon_pcmcia_hw_init
,
108 .hw_shutdown
= shannon_pcmcia_hw_shutdown
,
109 .socket_state
= shannon_pcmcia_socket_state
,
110 .configure_socket
= shannon_pcmcia_configure_socket
,
112 .socket_init
= shannon_pcmcia_socket_init
,
113 .socket_suspend
= shannon_pcmcia_socket_suspend
,
116 int __devinit
pcmcia_shannon_init(struct device
*dev
)
120 if (machine_is_shannon())
121 ret
= sa11xx_drv_pcmcia_probe(dev
, &shannon_pcmcia_ops
, 0, 2);