2 * Toshiba e740 PCMCIA specific routines.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <linux/init.h>
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/errno.h>
15 #include <linux/gpio.h>
16 #include <linux/interrupt.h>
17 #include <linux/platform_device.h>
19 #include <mach/eseries-gpio.h>
22 #include <asm/mach-types.h>
24 #include "soc_common.h"
26 static int e740_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
29 skt->stat[SOC_STAT_CD].gpio = GPIO_E740_PCMCIA_CD0;
30 skt->stat[SOC_STAT_CD].name = "CF card detect";
31 skt->stat[SOC_STAT_RDY].gpio = GPIO_E740_PCMCIA_RDY0;
32 skt->stat[SOC_STAT_RDY].name = "CF ready";
34 skt->stat[SOC_STAT_CD].gpio = GPIO_E740_PCMCIA_CD1;
35 skt->stat[SOC_STAT_CD].name = "Wifi switch";
36 skt->stat[SOC_STAT_RDY].gpio = GPIO_E740_PCMCIA_RDY1;
37 skt->stat[SOC_STAT_RDY].name = "Wifi ready";
43 static void e740_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
44 struct pcmcia_state *state)
50 static int e740_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
51 const socket_state_t *state)
53 if (state->flags & SS_RESET) {
55 gpio_set_value(GPIO_E740_PCMCIA_RST0, 1);
57 gpio_set_value(GPIO_E740_PCMCIA_RST1, 1);
60 gpio_set_value(GPIO_E740_PCMCIA_RST0, 0);
62 gpio_set_value(GPIO_E740_PCMCIA_RST1, 0);
66 case 0: /* Socket off */
68 gpio_set_value(GPIO_E740_PCMCIA_PWR0, 0);
70 gpio_set_value(GPIO_E740_PCMCIA_PWR1, 1);
73 case 33: /* socket on */
75 gpio_set_value(GPIO_E740_PCMCIA_PWR0, 1);
77 gpio_set_value(GPIO_E740_PCMCIA_PWR1, 0);
80 printk(KERN_ERR "e740_cs: Unsupported Vcc: %d\n", state->Vcc);
86 static struct pcmcia_low_level e740_pcmcia_ops = {
88 .hw_init = e740_pcmcia_hw_init,
89 .socket_state = e740_pcmcia_socket_state,
90 .configure_socket = e740_pcmcia_configure_socket,
94 static struct platform_device *e740_pcmcia_device;
96 static int __init e740_pcmcia_init(void)
100 if (!machine_is_e740())
103 e740_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
104 if (!e740_pcmcia_device)
107 ret = platform_device_add_data(e740_pcmcia_device, &e740_pcmcia_ops,
108 sizeof(e740_pcmcia_ops));
111 ret = platform_device_add(e740_pcmcia_device);
114 platform_device_put(e740_pcmcia_device);
119 static void __exit e740_pcmcia_exit(void)
121 platform_device_unregister(e740_pcmcia_device);
124 module_init(e740_pcmcia_init);
125 module_exit(e740_pcmcia_exit);
127 MODULE_LICENSE("GPL v2");
129 MODULE_ALIAS("platform:pxa2xx-pcmcia");
130 MODULE_DESCRIPTION("e740 PCMCIA platform support");