OMAP3: PM: Fixed VDD2 control to work from both sysfs and SRF API
[linux-ginger.git] / drivers / pcmcia / sa1100_shannon.c
blob46d8c1977c2a44592652fc4abfb9ce1aeb1ca3fa
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/device.h>
10 #include <linux/init.h>
12 #include <mach/hardware.h>
13 #include <asm/mach-types.h>
14 #include <mach/shannon.h>
15 #include <asm/irq.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->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));
41 static void
42 shannon_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
43 struct pcmcia_state *state)
45 unsigned long levels = GPLR;
47 switch (skt->nr) {
48 case 0:
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. */
52 state->bvd1 = 1;
53 state->bvd2 = 1;
54 state->vs_3v = 1; /* FIXME Can only apply 3.3V on Shannon. */
55 state->vs_Xv = 0;
56 break;
58 case 1:
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. */
62 state->bvd1 = 1;
63 state->bvd2 = 1;
64 state->vs_3v = 1; /* FIXME Can only apply 3.3V on Shannon. */
65 state->vs_Xv = 0;
66 break;
70 static int
71 shannon_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
72 const socket_state_t *state)
74 switch (state->Vcc) {
75 case 0: /* power off */
76 printk(KERN_WARNING "%s(): CS asked for 0V, still applying 3.3V..\n", __func__);
77 break;
78 case 50:
79 printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V..\n", __func__);
80 case 33:
81 break;
82 default:
83 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
84 __func__, state->Vcc);
85 return -1;
88 printk(KERN_WARNING "%s(): Warning, Can't perform reset\n", __func__);
90 /* Silently ignore Vpp, output enable, speaker enable. */
92 return 0;
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 __init pcmcia_shannon_init(struct device *dev)
118 int ret = -ENODEV;
120 if (machine_is_shannon())
121 ret = sa11xx_drv_pcmcia_probe(dev, &shannon_pcmcia_ops, 0, 2);
123 return ret;