blob: 72caa6d05ab99d5ebaad276d29886f58532e0f4f [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Ian Moltone38a9702008-10-07 22:01:59 +01002/*
3 * Toshiba e740 PCMCIA specific routines.
4 *
5 * (c) 2004 Ian Molton <spyro@f2s.com>
Ian Moltone38a9702008-10-07 22:01:59 +01006 */
7
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>
15
Ian Moltone38a9702008-10-07 22:01:59 +010016#include <mach/eseries-gpio.h>
17
18#include <asm/irq.h>
19#include <asm/mach-types.h>
20
21#include "soc_common.h"
22
Ian Moltone38a9702008-10-07 22:01:59 +010023static int e740_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
24{
Russell Kinga9bb5a42012-01-13 22:56:32 +000025 if (skt->nr == 0) {
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";
30 } else {
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";
35 }
Axel Lin34641de2011-12-05 19:06:06 +080036
Russell Kinga9bb5a42012-01-13 22:56:32 +000037 return 0;
Ian Moltone38a9702008-10-07 22:01:59 +010038}
39
40static void e740_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
41 struct pcmcia_state *state)
42{
Ian Moltone38a9702008-10-07 22:01:59 +010043 state->vs_3v = 1;
Ian Moltone38a9702008-10-07 22:01:59 +010044 state->vs_Xv = 0;
45}
46
47static int e740_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
48 const socket_state_t *state)
49{
50 if (state->flags & SS_RESET) {
51 if (skt->nr == 0)
52 gpio_set_value(GPIO_E740_PCMCIA_RST0, 1);
53 else
54 gpio_set_value(GPIO_E740_PCMCIA_RST1, 1);
55 } else {
56 if (skt->nr == 0)
57 gpio_set_value(GPIO_E740_PCMCIA_RST0, 0);
58 else
59 gpio_set_value(GPIO_E740_PCMCIA_RST1, 0);
60 }
61
62 switch (state->Vcc) {
63 case 0: /* Socket off */
64 if (skt->nr == 0)
65 gpio_set_value(GPIO_E740_PCMCIA_PWR0, 0);
66 else
67 gpio_set_value(GPIO_E740_PCMCIA_PWR1, 1);
68 break;
69 case 50:
70 case 33: /* socket on */
71 if (skt->nr == 0)
72 gpio_set_value(GPIO_E740_PCMCIA_PWR0, 1);
73 else
74 gpio_set_value(GPIO_E740_PCMCIA_PWR1, 0);
75 break;
76 default:
77 printk(KERN_ERR "e740_cs: Unsupported Vcc: %d\n", state->Vcc);
78 }
79
80 return 0;
81}
82
Ian Moltone38a9702008-10-07 22:01:59 +010083static struct pcmcia_low_level e740_pcmcia_ops = {
84 .owner = THIS_MODULE,
85 .hw_init = e740_pcmcia_hw_init,
Ian Moltone38a9702008-10-07 22:01:59 +010086 .socket_state = e740_pcmcia_socket_state,
87 .configure_socket = e740_pcmcia_configure_socket,
Ian Moltone38a9702008-10-07 22:01:59 +010088 .nr = 2,
89};
90
91static struct platform_device *e740_pcmcia_device;
92
93static int __init e740_pcmcia_init(void)
94{
95 int ret;
96
97 if (!machine_is_e740())
98 return -ENODEV;
99
100 e740_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
101 if (!e740_pcmcia_device)
102 return -ENOMEM;
103
104 ret = platform_device_add_data(e740_pcmcia_device, &e740_pcmcia_ops,
105 sizeof(e740_pcmcia_ops));
106
107 if (!ret)
108 ret = platform_device_add(e740_pcmcia_device);
109
110 if (ret)
111 platform_device_put(e740_pcmcia_device);
112
113 return ret;
114}
115
116static void __exit e740_pcmcia_exit(void)
117{
118 platform_device_unregister(e740_pcmcia_device);
119}
120
121module_init(e740_pcmcia_init);
122module_exit(e740_pcmcia_exit);
123
124MODULE_LICENSE("GPL v2");
125MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
126MODULE_ALIAS("platform:pxa2xx-pcmcia");
127MODULE_DESCRIPTION("e740 PCMCIA platform support");