aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2012-01-13 18:05:12 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-02-04 09:32:24 -0500
commit7cf779cb8ddeef797a3a265889c7f088d42a12f7 (patch)
tree6533ca24db08d6bdfb42a257787ffb54c1ca41aa /drivers/pcmcia
parentbbb58a1210c6fdc68b09f7b9e12096c2a1886aa1 (diff)
PCMCIA: sa11x0: nanoengine: convert to use new irq/gpio management
Convert Nanoengine socket driver to use the new irq/gpio management. This is slightly more involved because we have to touch the private platform header file to modify the GPIO bitmasks to be GPIO numbers. Acked-by: Dominik Brodowski <linux@dominikbrodowski.net> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r--drivers/pcmcia/sa1100_nanoengine.c101
1 files changed, 11 insertions, 90 deletions
diff --git a/drivers/pcmcia/sa1100_nanoengine.c b/drivers/pcmcia/sa1100_nanoengine.c
index 93b9c9ba57c3..b19b8161395b 100644
--- a/drivers/pcmcia/sa1100_nanoengine.c
+++ b/drivers/pcmcia/sa1100_nanoengine.c
@@ -34,43 +34,24 @@
34 34
35#include "sa1100_generic.h" 35#include "sa1100_generic.h"
36 36
37static struct pcmcia_irqs irqs_skt0[] = {
38 /* socket, IRQ, name */
39 { 0, NANOENGINE_IRQ_GPIO_PC_CD0, "PC CD0" },
40};
41
42static struct pcmcia_irqs irqs_skt1[] = {
43 /* socket, IRQ, name */
44 { 1, NANOENGINE_IRQ_GPIO_PC_CD1, "PC CD1" },
45};
46
47struct nanoengine_pins { 37struct nanoengine_pins {
48 unsigned input_pins;
49 unsigned output_pins; 38 unsigned output_pins;
50 unsigned clear_outputs; 39 unsigned clear_outputs;
51 unsigned transition_pins; 40 int gpio_cd;
52 unsigned pci_irq; 41 int gpio_rdy;
53 struct pcmcia_irqs *pcmcia_irqs;
54 unsigned pcmcia_irqs_size;
55}; 42};
56 43
57static struct nanoengine_pins nano_skts[] = { 44static struct nanoengine_pins nano_skts[] = {
58 { 45 {
59 .input_pins = GPIO_PC_READY0 | GPIO_PC_CD0,
60 .output_pins = GPIO_PC_RESET0, 46 .output_pins = GPIO_PC_RESET0,
61 .clear_outputs = GPIO_PC_RESET0, 47 .clear_outputs = GPIO_PC_RESET0,
62 .transition_pins = NANOENGINE_IRQ_GPIO_PC_CD0, 48 .gpio_cd = GPIO_PC_CD0,
63 .pci_irq = NANOENGINE_IRQ_GPIO_PC_READY0, 49 .gpio_rdy = GPIO_PC_READY0,
64 .pcmcia_irqs = irqs_skt0,
65 .pcmcia_irqs_size = ARRAY_SIZE(irqs_skt0)
66 }, { 50 }, {
67 .input_pins = GPIO_PC_READY1 | GPIO_PC_CD1,
68 .output_pins = GPIO_PC_RESET1, 51 .output_pins = GPIO_PC_RESET1,
69 .clear_outputs = GPIO_PC_RESET1, 52 .clear_outputs = GPIO_PC_RESET1,
70 .transition_pins = NANOENGINE_IRQ_GPIO_PC_CD1, 53 .gpio_cd = GPIO_PC_CD1,
71 .pci_irq = NANOENGINE_IRQ_GPIO_PC_READY1, 54 .gpio_rdy = GPIO_PC_READY1,
72 .pcmcia_irqs = irqs_skt1,
73 .pcmcia_irqs_size = ARRAY_SIZE(irqs_skt1)
74 } 55 }
75}; 56};
76 57
@@ -83,28 +64,15 @@ static int nanoengine_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
83 if (i >= num_nano_pcmcia_sockets) 64 if (i >= num_nano_pcmcia_sockets)
84 return -ENXIO; 65 return -ENXIO;
85 66
86 GPDR &= ~nano_skts[i].input_pins;
87 GPDR |= nano_skts[i].output_pins; 67 GPDR |= nano_skts[i].output_pins;
88 GPCR = nano_skts[i].clear_outputs; 68 GPCR = nano_skts[i].clear_outputs;
89 irq_set_irq_type(nano_skts[i].transition_pins, IRQ_TYPE_EDGE_BOTH);
90 skt->socket.pci_irq = nano_skts[i].pci_irq;
91 69
92 return soc_pcmcia_request_irqs(skt, 70 skt->stat[SOC_STAT_CD].gpio = nano_skts[i].gpio_cd;
93 nano_skts[i].pcmcia_irqs, nano_skts[i].pcmcia_irqs_size); 71 skt->stat[SOC_STAT_CD].name = i ? "PC CD1" : "PC CD0";
94} 72 skt->stat[SOC_STAT_RDY].gpio = nano_skts[i].gpio_rdy;
73 skt->stat[SOC_STAT_RDY].name = i ? "PC RDY1" : "PC RDY0";
95 74
96/* 75 return 0;
97 * Release all resources.
98 */
99static void nanoengine_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
100{
101 unsigned i = skt->nr;
102
103 if (i >= num_nano_pcmcia_sockets)
104 return;
105
106 soc_pcmcia_free_irqs(skt,
107 nano_skts[i].pcmcia_irqs, nano_skts[i].pcmcia_irqs_size);
108} 76}
109 77
110static int nanoengine_pcmcia_configure_socket( 78static int nanoengine_pcmcia_configure_socket(
@@ -138,25 +106,11 @@ static int nanoengine_pcmcia_configure_socket(
138static void nanoengine_pcmcia_socket_state( 106static void nanoengine_pcmcia_socket_state(
139 struct soc_pcmcia_socket *skt, struct pcmcia_state *state) 107 struct soc_pcmcia_socket *skt, struct pcmcia_state *state)
140{ 108{
141 unsigned long levels = GPLR;
142 unsigned i = skt->nr; 109 unsigned i = skt->nr;
143 110
144 if (i >= num_nano_pcmcia_sockets) 111 if (i >= num_nano_pcmcia_sockets)
145 return; 112 return;
146 113
147 memset(state, 0, sizeof(struct pcmcia_state));
148 switch (i) {
149 case 0:
150 state->ready = (levels & GPIO_PC_READY0) ? 1 : 0;
151 state->detect = !(levels & GPIO_PC_CD0) ? 1 : 0;
152 break;
153 case 1:
154 state->ready = (levels & GPIO_PC_READY1) ? 1 : 0;
155 state->detect = !(levels & GPIO_PC_CD1) ? 1 : 0;
156 break;
157 default:
158 return;
159 }
160 state->bvd1 = 1; 114 state->bvd1 = 1;
161 state->bvd2 = 1; 115 state->bvd2 = 1;
162 state->wrprot = 0; /* Not available */ 116 state->wrprot = 0; /* Not available */
@@ -164,46 +118,13 @@ static void nanoengine_pcmcia_socket_state(
164 state->vs_Xv = 0; 118 state->vs_Xv = 0;
165} 119}
166 120
167/*
168 * Enable card status IRQs on (re-)initialisation. This can
169 * be called at initialisation, power management event, or
170 * pcmcia event.
171 */
172static void nanoengine_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
173{
174 unsigned i = skt->nr;
175
176 if (i >= num_nano_pcmcia_sockets)
177 return;
178
179 soc_pcmcia_enable_irqs(skt,
180 nano_skts[i].pcmcia_irqs, nano_skts[i].pcmcia_irqs_size);
181}
182
183/*
184 * Disable card status IRQs on suspend.
185 */
186static void nanoengine_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
187{
188 unsigned i = skt->nr;
189
190 if (i >= num_nano_pcmcia_sockets)
191 return;
192
193 soc_pcmcia_disable_irqs(skt,
194 nano_skts[i].pcmcia_irqs, nano_skts[i].pcmcia_irqs_size);
195}
196
197static struct pcmcia_low_level nanoengine_pcmcia_ops = { 121static struct pcmcia_low_level nanoengine_pcmcia_ops = {
198 .owner = THIS_MODULE, 122 .owner = THIS_MODULE,
199 123
200 .hw_init = nanoengine_pcmcia_hw_init, 124 .hw_init = nanoengine_pcmcia_hw_init,
201 .hw_shutdown = nanoengine_pcmcia_hw_shutdown,
202 125
203 .configure_socket = nanoengine_pcmcia_configure_socket, 126 .configure_socket = nanoengine_pcmcia_configure_socket,
204 .socket_state = nanoengine_pcmcia_socket_state, 127 .socket_state = nanoengine_pcmcia_socket_state,
205 .socket_init = nanoengine_pcmcia_socket_init,
206 .socket_suspend = nanoengine_pcmcia_socket_suspend,
207}; 128};
208 129
209int pcmcia_nanoengine_init(struct device *dev) 130int pcmcia_nanoengine_init(struct device *dev)