]>
Commit | Line | Data |
---|---|---|
e38a9707 IM |
1 | /* |
2 | * Toshiba e740 PCMCIA specific routines. | |
3 | * | |
4 | * (c) 2004 Ian Molton <[email protected]> | |
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 | ||
e38a9707 IM |
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 | ||
e38a9707 IM |
26 | static int e740_pcmcia_hw_init(struct soc_pcmcia_socket *skt) |
27 | { | |
a9bb5a4b RK |
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 | } | |
e38a9707 | 39 | |
a9bb5a4b | 40 | return 0; |
e38a9707 IM |
41 | } |
42 | ||
43 | static void e740_pcmcia_socket_state(struct soc_pcmcia_socket *skt, | |
44 | struct pcmcia_state *state) | |
45 | { | |
e38a9707 | 46 | state->vs_3v = 1; |
e38a9707 IM |
47 | state->vs_Xv = 0; |
48 | } | |
49 | ||
50 | static 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 | ||
e38a9707 IM |
86 | static struct pcmcia_low_level e740_pcmcia_ops = { |
87 | .owner = THIS_MODULE, | |
88 | .hw_init = e740_pcmcia_hw_init, | |
e38a9707 IM |
89 | .socket_state = e740_pcmcia_socket_state, |
90 | .configure_socket = e740_pcmcia_configure_socket, | |
e38a9707 IM |
91 | .nr = 2, |
92 | }; | |
93 | ||
94 | static struct platform_device *e740_pcmcia_device; | |
95 | ||
96 | static 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 | ||
119 | static void __exit e740_pcmcia_exit(void) | |
120 | { | |
121 | platform_device_unregister(e740_pcmcia_device); | |
122 | } | |
123 | ||
124 | module_init(e740_pcmcia_init); | |
125 | module_exit(e740_pcmcia_exit); | |
126 | ||
127 | MODULE_LICENSE("GPL v2"); | |
128 | MODULE_AUTHOR("Ian Molton <[email protected]>"); | |
129 | MODULE_ALIAS("platform:pxa2xx-pcmcia"); | |
130 | MODULE_DESCRIPTION("e740 PCMCIA platform support"); |