Linux 4.1.16
[linux/fpc-iii.git] / drivers / pcmcia / pxa2xx_e740.c
blob8751a323b448e1069227a2d4d2399facea4949af
1 /*
2 * Toshiba e740 PCMCIA specific routines.
4 * (c) 2004 Ian Molton <spyro@f2s.com>
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.
9 */
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>
21 #include <asm/irq.h>
22 #include <asm/mach-types.h>
24 #include "soc_common.h"
26 static int e740_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
28 if (skt->nr == 0) {
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";
33 } else {
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";
40 return 0;
43 static void e740_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
44 struct pcmcia_state *state)
46 state->vs_3v = 1;
47 state->vs_Xv = 0;
50 static int e740_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
51 const socket_state_t *state)
53 if (state->flags & SS_RESET) {
54 if (skt->nr == 0)
55 gpio_set_value(GPIO_E740_PCMCIA_RST0, 1);
56 else
57 gpio_set_value(GPIO_E740_PCMCIA_RST1, 1);
58 } else {
59 if (skt->nr == 0)
60 gpio_set_value(GPIO_E740_PCMCIA_RST0, 0);
61 else
62 gpio_set_value(GPIO_E740_PCMCIA_RST1, 0);
65 switch (state->Vcc) {
66 case 0: /* Socket off */
67 if (skt->nr == 0)
68 gpio_set_value(GPIO_E740_PCMCIA_PWR0, 0);
69 else
70 gpio_set_value(GPIO_E740_PCMCIA_PWR1, 1);
71 break;
72 case 50:
73 case 33: /* socket on */
74 if (skt->nr == 0)
75 gpio_set_value(GPIO_E740_PCMCIA_PWR0, 1);
76 else
77 gpio_set_value(GPIO_E740_PCMCIA_PWR1, 0);
78 break;
79 default:
80 printk(KERN_ERR "e740_cs: Unsupported Vcc: %d\n", state->Vcc);
83 return 0;
86 static struct pcmcia_low_level e740_pcmcia_ops = {
87 .owner = THIS_MODULE,
88 .hw_init = e740_pcmcia_hw_init,
89 .socket_state = e740_pcmcia_socket_state,
90 .configure_socket = e740_pcmcia_configure_socket,
91 .nr = 2,
94 static struct platform_device *e740_pcmcia_device;
96 static int __init e740_pcmcia_init(void)
98 int ret;
100 if (!machine_is_e740())
101 return -ENODEV;
103 e740_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
104 if (!e740_pcmcia_device)
105 return -ENOMEM;
107 ret = platform_device_add_data(e740_pcmcia_device, &e740_pcmcia_ops,
108 sizeof(e740_pcmcia_ops));
110 if (!ret)
111 ret = platform_device_add(e740_pcmcia_device);
113 if (ret)
114 platform_device_put(e740_pcmcia_device);
116 return ret;
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");
128 MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
129 MODULE_ALIAS("platform:pxa2xx-pcmcia");
130 MODULE_DESCRIPTION("e740 PCMCIA platform support");