1 // SPDX-License-Identifier: GPL-2.0-only
3 * Toshiba e740 PCMCIA specific routines.
8 #include <linux/init.h>
9 #include <linux/module.h>
10 #include <linux/kernel.h>
11 #include <linux/errno.h>
12 #include <linux/gpio.h>
13 #include <linux/interrupt.h>
14 #include <linux/platform_device.h>
16 #include <mach/eseries-gpio.h>
19 #include <asm/mach-types.h>
21 #include "soc_common.h"
23 static int e740_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
26 skt->stat[SOC_STAT_CD].gpio = GPIO_E740_PCMCIA_CD0;
27 skt->stat[SOC_STAT_CD].name = "CF card detect";
28 skt->stat[SOC_STAT_RDY].gpio = GPIO_E740_PCMCIA_RDY0;
29 skt->stat[SOC_STAT_RDY].name = "CF ready";
31 skt->stat[SOC_STAT_CD].gpio = GPIO_E740_PCMCIA_CD1;
32 skt->stat[SOC_STAT_CD].name = "Wifi switch";
33 skt->stat[SOC_STAT_RDY].gpio = GPIO_E740_PCMCIA_RDY1;
34 skt->stat[SOC_STAT_RDY].name = "Wifi ready";
40 static void e740_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
41 struct pcmcia_state *state)
47 static int e740_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
48 const socket_state_t *state)
50 if (state->flags & SS_RESET) {
52 gpio_set_value(GPIO_E740_PCMCIA_RST0, 1);
54 gpio_set_value(GPIO_E740_PCMCIA_RST1, 1);
57 gpio_set_value(GPIO_E740_PCMCIA_RST0, 0);
59 gpio_set_value(GPIO_E740_PCMCIA_RST1, 0);
63 case 0: /* Socket off */
65 gpio_set_value(GPIO_E740_PCMCIA_PWR0, 0);
67 gpio_set_value(GPIO_E740_PCMCIA_PWR1, 1);
70 case 33: /* socket on */
72 gpio_set_value(GPIO_E740_PCMCIA_PWR0, 1);
74 gpio_set_value(GPIO_E740_PCMCIA_PWR1, 0);
77 printk(KERN_ERR "e740_cs: Unsupported Vcc: %d\n", state->Vcc);
83 static struct pcmcia_low_level e740_pcmcia_ops = {
85 .hw_init = e740_pcmcia_hw_init,
86 .socket_state = e740_pcmcia_socket_state,
87 .configure_socket = e740_pcmcia_configure_socket,
91 static struct platform_device *e740_pcmcia_device;
93 static int __init e740_pcmcia_init(void)
97 if (!machine_is_e740())
100 e740_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
101 if (!e740_pcmcia_device)
104 ret = platform_device_add_data(e740_pcmcia_device, &e740_pcmcia_ops,
105 sizeof(e740_pcmcia_ops));
108 ret = platform_device_add(e740_pcmcia_device);
111 platform_device_put(e740_pcmcia_device);
116 static void __exit e740_pcmcia_exit(void)
118 platform_device_unregister(e740_pcmcia_device);
121 module_init(e740_pcmcia_init);
122 module_exit(e740_pcmcia_exit);
124 MODULE_LICENSE("GPL v2");
126 MODULE_ALIAS("platform:pxa2xx-pcmcia");
127 MODULE_DESCRIPTION("e740 PCMCIA platform support");