diff options
Diffstat (limited to 'drivers/pcmcia/sa1100_shannon.c')
-rw-r--r-- | drivers/pcmcia/sa1100_shannon.c | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/drivers/pcmcia/sa1100_shannon.c b/drivers/pcmcia/sa1100_shannon.c new file mode 100644 index 000000000000..7bc9e59c761f --- /dev/null +++ b/drivers/pcmcia/sa1100_shannon.c | |||
@@ -0,0 +1,125 @@ | |||
1 | /* | ||
2 | * drivers/pcmcia/sa1100_shannon.c | ||
3 | * | ||
4 | * PCMCIA implementation routines for Shannon | ||
5 | * | ||
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> | ||
12 | |||
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" | ||
18 | |||
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" }, | ||
22 | }; | ||
23 | |||
24 | static int shannon_pcmcia_hw_init(struct soc_pcmcia_socket *skt) | ||
25 | { | ||
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); | ||
31 | |||
32 | skt->irq = skt->nr ? SHANNON_IRQ_GPIO_RDY_1 : SHANNON_IRQ_GPIO_RDY_0; | ||
33 | |||
34 | return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); | ||
35 | } | ||
36 | |||
37 | static void shannon_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) | ||
38 | { | ||
39 | soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs)); | ||
40 | } | ||
41 | |||
42 | static void | ||
43 | shannon_pcmcia_socket_state(struct soc_pcmcia_socket *skt, | ||
44 | struct pcmcia_state *state) | ||
45 | { | ||
46 | unsigned long levels = GPLR; | ||
47 | |||
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; | ||
58 | |||
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; | ||
68 | } | ||
69 | } | ||
70 | |||
71 | static int | ||
72 | shannon_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | ||
73 | const socket_state_t *state) | ||
74 | { | ||
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; | ||
87 | } | ||
88 | |||
89 | printk(KERN_WARNING "%s(): Warning, Can't perform reset\n", __FUNCTION__); | ||
90 | |||
91 | /* Silently ignore Vpp, output enable, speaker enable. */ | ||
92 | |||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | static void shannon_pcmcia_socket_init(struct soc_pcmcia_socket *skt) | ||
97 | { | ||
98 | soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs)); | ||
99 | } | ||
100 | |||
101 | static void shannon_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) | ||
102 | { | ||
103 | soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs)); | ||
104 | } | ||
105 | |||
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, | ||
112 | |||
113 | .socket_init = shannon_pcmcia_socket_init, | ||
114 | .socket_suspend = shannon_pcmcia_socket_suspend, | ||
115 | }; | ||
116 | |||
117 | int __init pcmcia_shannon_init(struct device *dev) | ||
118 | { | ||
119 | int ret = -ENODEV; | ||
120 | |||
121 | if (machine_is_shannon()) | ||
122 | ret = sa11xx_drv_pcmcia_probe(dev, &shannon_pcmcia_ops, 0, 2); | ||
123 | |||
124 | return ret; | ||
125 | } | ||