Linux 2.6.17.7
[linux/fpc-iii.git] / drivers / pcmcia / sa1100_shannon.c
blob7bc9e59c761f732c5b2fa737a996db4fc031460a
1 /*
2 * drivers/pcmcia/sa1100_shannon.c
4 * PCMCIA implementation routines for Shannon
6 */
7 #include <linux/module.h>
8 #include <linux/kernel.h>
9 #include <linux/sched.h>
10 #include <linux/device.h>
11 #include <linux/init.h>
13 #include <asm/hardware.h>
14 #include <asm/mach-types.h>
15 #include <asm/arch/shannon.h>
16 #include <asm/irq.h>
17 #include "sa1100_generic.h"
19 static struct pcmcia_irqs irqs[] = {
20 { 0, SHANNON_IRQ_GPIO_EJECT_0, "PCMCIA_CD_0" },
21 { 1, SHANNON_IRQ_GPIO_EJECT_1, "PCMCIA_CD_1" },
24 static int shannon_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
26 /* All those are inputs */
27 GPDR &= ~(SHANNON_GPIO_EJECT_0 | SHANNON_GPIO_EJECT_1 |
28 SHANNON_GPIO_RDY_0 | SHANNON_GPIO_RDY_1);
29 GAFR &= ~(SHANNON_GPIO_EJECT_0 | SHANNON_GPIO_EJECT_1 |
30 SHANNON_GPIO_RDY_0 | SHANNON_GPIO_RDY_1);
32 skt->irq = skt->nr ? SHANNON_IRQ_GPIO_RDY_1 : SHANNON_IRQ_GPIO_RDY_0;
34 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
37 static void shannon_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
39 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
42 static void
43 shannon_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
44 struct pcmcia_state *state)
46 unsigned long levels = GPLR;
48 switch (skt->nr) {
49 case 0:
50 state->detect = (levels & SHANNON_GPIO_EJECT_0) ? 0 : 1;
51 state->ready = (levels & SHANNON_GPIO_RDY_0) ? 1 : 0;
52 state->wrprot = 0; /* Not available on Shannon. */
53 state->bvd1 = 1;
54 state->bvd2 = 1;
55 state->vs_3v = 1; /* FIXME Can only apply 3.3V on Shannon. */
56 state->vs_Xv = 0;
57 break;
59 case 1:
60 state->detect = (levels & SHANNON_GPIO_EJECT_1) ? 0 : 1;
61 state->ready = (levels & SHANNON_GPIO_RDY_1) ? 1 : 0;
62 state->wrprot = 0; /* Not available on Shannon. */
63 state->bvd1 = 1;
64 state->bvd2 = 1;
65 state->vs_3v = 1; /* FIXME Can only apply 3.3V on Shannon. */
66 state->vs_Xv = 0;
67 break;
71 static int
72 shannon_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
73 const socket_state_t *state)
75 switch (state->Vcc) {
76 case 0: /* power off */
77 printk(KERN_WARNING "%s(): CS asked for 0V, still applying 3.3V..\n", __FUNCTION__);
78 break;
79 case 50:
80 printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V..\n", __FUNCTION__);
81 case 33:
82 break;
83 default:
84 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
85 __FUNCTION__, state->Vcc);
86 return -1;
89 printk(KERN_WARNING "%s(): Warning, Can't perform reset\n", __FUNCTION__);
91 /* Silently ignore Vpp, output enable, speaker enable. */
93 return 0;
96 static void shannon_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
98 soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
101 static void shannon_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
103 soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
106 static struct pcmcia_low_level shannon_pcmcia_ops = {
107 .owner = THIS_MODULE,
108 .hw_init = shannon_pcmcia_hw_init,
109 .hw_shutdown = shannon_pcmcia_hw_shutdown,
110 .socket_state = shannon_pcmcia_socket_state,
111 .configure_socket = shannon_pcmcia_configure_socket,
113 .socket_init = shannon_pcmcia_socket_init,
114 .socket_suspend = shannon_pcmcia_socket_suspend,
117 int __init pcmcia_shannon_init(struct device *dev)
119 int ret = -ENODEV;
121 if (machine_is_shannon())
122 ret = sa11xx_drv_pcmcia_probe(dev, &shannon_pcmcia_ops, 0, 2);
124 return ret;