2 * linux/drivers/pcmcia/pxa2xx_vpac270.c
4 * Driver for Voipac PXA270 PCMCIA and CF sockets
7 * Marek Vasut <marek.vasut@gmail.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
15 #include <linux/module.h>
16 #include <linux/platform_device.h>
18 #include <asm/mach-types.h>
20 #include <mach/gpio.h>
21 #include <mach/vpac270.h>
23 #include "soc_common.h"
25 static struct pcmcia_irqs cd_irqs
[] = {
28 .irq
= IRQ_GPIO(GPIO84_VPAC270_PCMCIA_CD
),
33 .irq
= IRQ_GPIO(GPIO17_VPAC270_CF_CD
),
38 static int vpac270_pcmcia_hw_init(struct soc_pcmcia_socket
*skt
)
43 ret
= gpio_request(GPIO84_VPAC270_PCMCIA_CD
, "PCMCIA CD");
46 ret
= gpio_direction_input(GPIO84_VPAC270_PCMCIA_CD
);
50 ret
= gpio_request(GPIO35_VPAC270_PCMCIA_RDY
, "PCMCIA RDY");
53 ret
= gpio_direction_input(GPIO35_VPAC270_PCMCIA_RDY
);
57 ret
= gpio_request(GPIO107_VPAC270_PCMCIA_PPEN
, "PCMCIA PPEN");
60 ret
= gpio_direction_output(GPIO107_VPAC270_PCMCIA_PPEN
, 0);
64 ret
= gpio_request(GPIO11_VPAC270_PCMCIA_RESET
, "PCMCIA RESET");
67 ret
= gpio_direction_output(GPIO11_VPAC270_PCMCIA_RESET
, 0);
71 skt
->socket
.pci_irq
= gpio_to_irq(GPIO35_VPAC270_PCMCIA_RDY
);
73 return soc_pcmcia_request_irqs(skt
, &cd_irqs
[0], 1);
76 gpio_free(GPIO11_VPAC270_PCMCIA_RESET
);
78 gpio_free(GPIO107_VPAC270_PCMCIA_PPEN
);
80 gpio_free(GPIO35_VPAC270_PCMCIA_RDY
);
82 gpio_free(GPIO84_VPAC270_PCMCIA_CD
);
87 ret
= gpio_request(GPIO17_VPAC270_CF_CD
, "CF CD");
90 ret
= gpio_direction_input(GPIO17_VPAC270_CF_CD
);
94 ret
= gpio_request(GPIO12_VPAC270_CF_RDY
, "CF RDY");
97 ret
= gpio_direction_input(GPIO12_VPAC270_CF_RDY
);
101 ret
= gpio_request(GPIO16_VPAC270_CF_RESET
, "CF RESET");
104 ret
= gpio_direction_output(GPIO16_VPAC270_CF_RESET
, 0);
108 skt
->socket
.pci_irq
= gpio_to_irq(GPIO12_VPAC270_CF_RDY
);
110 return soc_pcmcia_request_irqs(skt
, &cd_irqs
[1], 1);
113 gpio_free(GPIO16_VPAC270_CF_RESET
);
115 gpio_free(GPIO12_VPAC270_CF_RDY
);
117 gpio_free(GPIO17_VPAC270_CF_CD
);
124 static void vpac270_pcmcia_hw_shutdown(struct soc_pcmcia_socket
*skt
)
126 gpio_free(GPIO11_VPAC270_PCMCIA_RESET
);
127 gpio_free(GPIO107_VPAC270_PCMCIA_PPEN
);
128 gpio_free(GPIO35_VPAC270_PCMCIA_RDY
);
129 gpio_free(GPIO84_VPAC270_PCMCIA_CD
);
130 gpio_free(GPIO16_VPAC270_CF_RESET
);
131 gpio_free(GPIO12_VPAC270_CF_RDY
);
132 gpio_free(GPIO17_VPAC270_CF_CD
);
135 static void vpac270_pcmcia_socket_state(struct soc_pcmcia_socket
*skt
,
136 struct pcmcia_state
*state
)
139 state
->detect
= !gpio_get_value(GPIO84_VPAC270_PCMCIA_CD
);
140 state
->ready
= !!gpio_get_value(GPIO35_VPAC270_PCMCIA_RDY
);
142 state
->detect
= !gpio_get_value(GPIO17_VPAC270_CF_CD
);
143 state
->ready
= !!gpio_get_value(GPIO12_VPAC270_CF_RDY
);
153 vpac270_pcmcia_configure_socket(struct soc_pcmcia_socket
*skt
,
154 const socket_state_t
*state
)
157 gpio_set_value(GPIO11_VPAC270_PCMCIA_RESET
,
158 (state
->flags
& SS_RESET
));
159 gpio_set_value(GPIO107_VPAC270_PCMCIA_PPEN
,
160 !(state
->Vcc
== 33 || state
->Vcc
== 50));
162 gpio_set_value(GPIO16_VPAC270_CF_RESET
,
163 (state
->flags
& SS_RESET
));
169 static void vpac270_pcmcia_socket_init(struct soc_pcmcia_socket
*skt
)
173 static void vpac270_pcmcia_socket_suspend(struct soc_pcmcia_socket
*skt
)
177 static struct pcmcia_low_level vpac270_pcmcia_ops
= {
178 .owner
= THIS_MODULE
,
183 .hw_init
= vpac270_pcmcia_hw_init
,
184 .hw_shutdown
= vpac270_pcmcia_hw_shutdown
,
186 .socket_state
= vpac270_pcmcia_socket_state
,
187 .configure_socket
= vpac270_pcmcia_configure_socket
,
189 .socket_init
= vpac270_pcmcia_socket_init
,
190 .socket_suspend
= vpac270_pcmcia_socket_suspend
,
193 static struct platform_device
*vpac270_pcmcia_device
;
195 static int __init
vpac270_pcmcia_init(void)
199 if (!machine_is_vpac270())
202 vpac270_pcmcia_device
= platform_device_alloc("pxa2xx-pcmcia", -1);
203 if (!vpac270_pcmcia_device
)
206 ret
= platform_device_add_data(vpac270_pcmcia_device
,
207 &vpac270_pcmcia_ops
, sizeof(vpac270_pcmcia_ops
));
210 ret
= platform_device_add(vpac270_pcmcia_device
);
213 platform_device_put(vpac270_pcmcia_device
);
218 static void __exit
vpac270_pcmcia_exit(void)
220 platform_device_unregister(vpac270_pcmcia_device
);
223 module_init(vpac270_pcmcia_init
);
224 module_exit(vpac270_pcmcia_exit
);
226 MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
227 MODULE_DESCRIPTION("PCMCIA support for Voipac PXA270");
228 MODULE_ALIAS("platform:pxa2xx-pcmcia");
229 MODULE_LICENSE("GPL");