Warning: That file was not part of the compilation database. It may have many parsing errors.

1/*
2 * Toshiba e740 PCMCIA specific routines.
3 *
4 * (c) 2004 Ian Molton <spyro@f2s.com>
5 *
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 */
10
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>
18
19#include <mach/eseries-gpio.h>
20
21#include <asm/irq.h>
22#include <asm/mach-types.h>
23
24#include "soc_common.h"
25
26static int e740_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
27{
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";
38 }
39
40 return 0;
41}
42
43static void e740_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
44 struct pcmcia_state *state)
45{
46 state->vs_3v = 1;
47 state->vs_Xv = 0;
48}
49
50static int e740_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
51 const socket_state_t *state)
52{
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);
63 }
64
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);
81 }
82
83 return 0;
84}
85
86static 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,
92};
93
94static struct platform_device *e740_pcmcia_device;
95
96static int __init e740_pcmcia_init(void)
97{
98 int ret;
99
100 if (!machine_is_e740())
101 return -ENODEV;
102
103 e740_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
104 if (!e740_pcmcia_device)
105 return -ENOMEM;
106
107 ret = platform_device_add_data(e740_pcmcia_device, &e740_pcmcia_ops,
108 sizeof(e740_pcmcia_ops));
109
110 if (!ret)
111 ret = platform_device_add(e740_pcmcia_device);
112
113 if (ret)
114 platform_device_put(e740_pcmcia_device);
115
116 return ret;
117}
118
119static void __exit e740_pcmcia_exit(void)
120{
121 platform_device_unregister(e740_pcmcia_device);
122}
123
124module_init(e740_pcmcia_init);
125module_exit(e740_pcmcia_exit);
126
127MODULE_LICENSE("GPL v2");
128MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
129MODULE_ALIAS("platform:pxa2xx-pcmcia");
130MODULE_DESCRIPTION("e740 PCMCIA platform support");
131

Warning: That file was not part of the compilation database. It may have many parsing errors.