aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-10-11 13:09:45 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-11 13:09:45 -0400
commit7cc4e87f912bbefa440a51856b8d076e5d1f554a (patch)
tree1b8df8683f3de37d2e8211ffa8d151f60d59af62 /drivers/pcmcia
parent5ba2f67afb02c5302b2898949ed6fc3b3d37dcf1 (diff)
parent69fc7eed5f56bce15b239e5110de2575a6970df4 (diff)
Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm
* 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm: (236 commits) [ARM] 5300/1: fixup spitz reset during boot [ARM] 5295/1: make ZONE_DMA optional [ARM] 5239/1: Palm Zire 72 power management support [ARM] 5298/1: Drop desc_handle_irq() [ARM] 5297/1: [KS8695] Fix two compile-time warnings [ARM] 5296/1: [KS8695] Replace macro's with trailing underscores. [ARM] pxa: allow multi-machine PCMCIA builds [ARM] pxa: add preliminary CPUFREQ support for PXA3xx [ARM] pxa: add missing ACCR bit definitions to pxa3xx-regs.h [ARM] pxa: rename cpu-pxa.c to cpufreq-pxa2xx.c [ARM] pxa/zylonite: add support for USB OHCI [ARM] ohci-pxa27x: use ioremap() and offset for register access [ARM] ohci-pxa27x: introduce pxa27x_clear_otgph() [ARM] ohci-pxa27x: use platform_get_{irq,resource} for the resource [ARM] ohci-pxa27x: move OHCI controller specific registers into the driver [ARM] ohci-pxa27x: introduce flags to avoid direct access to OHCI registers [ARM] pxa: move I2S register and bit definitions into pxa2xx-i2s.c [ARM] pxa: simplify DMA register definitions [ARM] pxa: make additional DCSR bits valid for PXA3xx [ARM] pxa: move i2c register and bit definitions into i2c-pxa.c ... Fixed up conflicts in arch/arm/mach-versatile/core.c sound/soc/pxa/pxa2xx-ac97.c sound/soc/pxa/pxa2xx-i2s.c manually.
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r--drivers/pcmcia/Kconfig3
-rw-r--r--drivers/pcmcia/Makefile16
-rw-r--r--drivers/pcmcia/pxa2xx_base.c44
-rw-r--r--drivers/pcmcia/pxa2xx_cm_x255.c154
-rw-r--r--drivers/pcmcia/pxa2xx_cm_x270.c14
-rw-r--r--drivers/pcmcia/pxa2xx_cm_x2xx.c49
-rw-r--r--drivers/pcmcia/pxa2xx_palmld.c151
-rw-r--r--drivers/pcmcia/pxa2xx_trizeps4.c256
-rw-r--r--drivers/pcmcia/pxa2xx_viper.c179
9 files changed, 825 insertions, 41 deletions
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index e0f884034c9f..f57eeae3830a 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -220,7 +220,8 @@ config PCMCIA_PXA2XX
220 tristate "PXA2xx support" 220 tristate "PXA2xx support"
221 depends on ARM && ARCH_PXA && PCMCIA 221 depends on ARM && ARCH_PXA && PCMCIA
222 depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \ 222 depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \
223 || MACH_ARMCORE || ARCH_PXA_PALM) 223 || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \
224 || ARCH_VIPER)
224 help 225 help
225 Say Y here to include support for the PXA2xx PCMCIA controller 226 Say Y here to include support for the PXA2xx PCMCIA controller
226 227
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index 269a9e913ba2..a87902de8d3b 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -29,7 +29,6 @@ obj-$(CONFIG_PCMCIA_M8XX) += m8xx_pcmcia.o
29obj-$(CONFIG_HD64465_PCMCIA) += hd64465_ss.o 29obj-$(CONFIG_HD64465_PCMCIA) += hd64465_ss.o
30obj-$(CONFIG_PCMCIA_SA1100) += sa11xx_core.o sa1100_cs.o 30obj-$(CONFIG_PCMCIA_SA1100) += sa11xx_core.o sa1100_cs.o
31obj-$(CONFIG_PCMCIA_SA1111) += sa11xx_core.o sa1111_cs.o 31obj-$(CONFIG_PCMCIA_SA1111) += sa11xx_core.o sa1111_cs.o
32obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_core.o pxa2xx_cs.o
33obj-$(CONFIG_M32R_PCC) += m32r_pcc.o 32obj-$(CONFIG_M32R_PCC) += m32r_pcc.o
34obj-$(CONFIG_M32R_CFC) += m32r_cfc.o 33obj-$(CONFIG_M32R_CFC) += m32r_cfc.o
35obj-$(CONFIG_PCMCIA_AU1X00) += au1x00_ss.o 34obj-$(CONFIG_PCMCIA_AU1X00) += au1x00_ss.o
@@ -68,9 +67,14 @@ sa1100_cs-$(CONFIG_SA1100_H3600) += sa1100_h3600.o
68sa1100_cs-$(CONFIG_SA1100_SHANNON) += sa1100_shannon.o 67sa1100_cs-$(CONFIG_SA1100_SHANNON) += sa1100_shannon.o
69sa1100_cs-$(CONFIG_SA1100_SIMPAD) += sa1100_simpad.o 68sa1100_cs-$(CONFIG_SA1100_SIMPAD) += sa1100_simpad.o
70 69
71pxa2xx_cs-$(CONFIG_ARCH_LUBBOCK) += pxa2xx_lubbock.o sa1111_generic.o 70pxa2xx_lubbock_cs-y += pxa2xx_lubbock.o sa1111_generic.o
72pxa2xx_cs-$(CONFIG_MACH_MAINSTONE) += pxa2xx_mainstone.o 71pxa2xx-obj-$(CONFIG_ARCH_LUBBOCK) += pxa2xx_lubbock_cs.o
73pxa2xx_cs-$(CONFIG_PXA_SHARPSL) += pxa2xx_sharpsl.o 72pxa2xx-obj-$(CONFIG_MACH_MAINSTONE) += pxa2xx_mainstone.o
74pxa2xx_cs-$(CONFIG_MACH_ARMCORE) += pxa2xx_cm_x270.o 73pxa2xx-obj-$(CONFIG_PXA_SHARPSL) += pxa2xx_sharpsl.o
75pxa2xx_cs-$(CONFIG_MACH_PALMTX) += pxa2xx_palmtx.o 74pxa2xx-obj-$(CONFIG_MACH_ARMCORE) += pxa2xx_cm_x2xx.o pxa2xx_cm_x255.o pxa2xx_cm_x270.o
75pxa2xx-obj-$(CONFIG_ARCH_VIPER) += pxa2xx_viper.o
76pxa2xx-obj-$(CONFIG_TRIZEPS_PCMCIA) += pxa2xx_trizeps.o
77pxa2xx-obj-$(CONFIG_MACH_PALMTX) += pxa2xx_palmtx.o
78pxa2xx-obj-$(CONFIG_MACH_PALMLD) += pxa2xx_palmld.o
76 79
80obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_core.o $(pxa2xx-obj-y)
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index 1b07af5a2ed3..13f1e0fd3f31 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -30,6 +30,7 @@
30#include <asm/system.h> 30#include <asm/system.h>
31#include <mach/pxa-regs.h> 31#include <mach/pxa-regs.h>
32#include <mach/pxa2xx-regs.h> 32#include <mach/pxa2xx-regs.h>
33#include <asm/mach-types.h>
33 34
34#include <pcmcia/cs_types.h> 35#include <pcmcia/cs_types.h>
35#include <pcmcia/ss.h> 36#include <pcmcia/ss.h>
@@ -166,18 +167,32 @@ pxa2xx_pcmcia_frequency_change(struct soc_pcmcia_socket *skt,
166} 167}
167#endif 168#endif
168 169
170static void pxa2xx_configure_sockets(struct device *dev)
171{
172 struct pcmcia_low_level *ops = dev->platform_data;
173
174 /*
175 * We have at least one socket, so set MECR:CIT
176 * (Card Is There)
177 */
178 MECR |= MECR_CIT;
179
180 /* Set MECR:NOS (Number Of Sockets) */
181 if (ops->nr > 1 || machine_is_viper())
182 MECR |= MECR_NOS;
183 else
184 MECR &= ~MECR_NOS;
185}
186
169int __pxa2xx_drv_pcmcia_probe(struct device *dev) 187int __pxa2xx_drv_pcmcia_probe(struct device *dev)
170{ 188{
171 int ret; 189 int ret;
172 struct pcmcia_low_level *ops; 190 struct pcmcia_low_level *ops;
173 int first, nr;
174 191
175 if (!dev || !dev->platform_data) 192 if (!dev || !dev->platform_data)
176 return -ENODEV; 193 return -ENODEV;
177 194
178 ops = (struct pcmcia_low_level *)dev->platform_data; 195 ops = (struct pcmcia_low_level *)dev->platform_data;
179 first = ops->first;
180 nr = ops->nr;
181 196
182 /* Provide our PXA2xx specific timing routines. */ 197 /* Provide our PXA2xx specific timing routines. */
183 ops->set_timing = pxa2xx_pcmcia_set_timing; 198 ops->set_timing = pxa2xx_pcmcia_set_timing;
@@ -185,21 +200,10 @@ int __pxa2xx_drv_pcmcia_probe(struct device *dev)
185 ops->frequency_change = pxa2xx_pcmcia_frequency_change; 200 ops->frequency_change = pxa2xx_pcmcia_frequency_change;
186#endif 201#endif
187 202
188 ret = soc_common_drv_pcmcia_probe(dev, ops, first, nr); 203 ret = soc_common_drv_pcmcia_probe(dev, ops, ops->first, ops->nr);
189 204
190 if (ret == 0) { 205 if (!ret)
191 /* 206 pxa2xx_configure_sockets(dev);
192 * We have at least one socket, so set MECR:CIT
193 * (Card Is There)
194 */
195 MECR |= MECR_CIT;
196
197 /* Set MECR:NOS (Number Of Sockets) */
198 if (nr > 1)
199 MECR |= MECR_NOS;
200 else
201 MECR &= ~MECR_NOS;
202 }
203 207
204 return ret; 208 return ret;
205} 209}
@@ -223,11 +227,7 @@ static int pxa2xx_drv_pcmcia_suspend(struct platform_device *dev, pm_message_t s
223 227
224static int pxa2xx_drv_pcmcia_resume(struct platform_device *dev) 228static int pxa2xx_drv_pcmcia_resume(struct platform_device *dev)
225{ 229{
226 struct pcmcia_low_level *ops = dev->dev.platform_data; 230 pxa2xx_configure_sockets(&dev->dev);
227 int nr = ops ? ops->nr : 0;
228
229 MECR = nr > 1 ? MECR_CIT | MECR_NOS : (nr > 0 ? MECR_CIT : 0);
230
231 return pcmcia_socket_dev_resume(&dev->dev); 231 return pcmcia_socket_dev_resume(&dev->dev);
232} 232}
233 233
diff --git a/drivers/pcmcia/pxa2xx_cm_x255.c b/drivers/pcmcia/pxa2xx_cm_x255.c
new file mode 100644
index 000000000000..7c8bcb476622
--- /dev/null
+++ b/drivers/pcmcia/pxa2xx_cm_x255.c
@@ -0,0 +1,154 @@
1/*
2 * linux/drivers/pcmcia/pxa/pxa_cm_x255.c
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * Compulab Ltd., 2003, 2007, 2008
9 * Mike Rapoport <mike@compulab.co.il>
10 *
11 */
12
13#include <linux/platform_device.h>
14#include <linux/irq.h>
15#include <linux/delay.h>
16#include <linux/gpio.h>
17
18#include <asm/mach-types.h>
19#include <mach/pxa-regs.h>
20
21#include "soc_common.h"
22
23#define GPIO_PCMCIA_SKTSEL (54)
24#define GPIO_PCMCIA_S0_CD_VALID (16)
25#define GPIO_PCMCIA_S1_CD_VALID (17)
26#define GPIO_PCMCIA_S0_RDYINT (6)
27#define GPIO_PCMCIA_S1_RDYINT (8)
28#define GPIO_PCMCIA_RESET (9)
29
30#define PCMCIA_S0_CD_VALID IRQ_GPIO(GPIO_PCMCIA_S0_CD_VALID)
31#define PCMCIA_S1_CD_VALID IRQ_GPIO(GPIO_PCMCIA_S1_CD_VALID)
32#define PCMCIA_S0_RDYINT IRQ_GPIO(GPIO_PCMCIA_S0_RDYINT)
33#define PCMCIA_S1_RDYINT IRQ_GPIO(GPIO_PCMCIA_S1_RDYINT)
34
35
36static struct pcmcia_irqs irqs[] = {
37 { 0, PCMCIA_S0_CD_VALID, "PCMCIA0 CD" },
38 { 1, PCMCIA_S1_CD_VALID, "PCMCIA1 CD" },
39};
40
41static int cmx255_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
42{
43 int ret = gpio_request(GPIO_PCMCIA_RESET, "PCCard reset");
44 if (ret)
45 return ret;
46 gpio_direction_output(GPIO_PCMCIA_RESET, 0);
47
48 skt->irq = skt->nr == 0 ? PCMCIA_S0_RDYINT : PCMCIA_S1_RDYINT;
49 ret = soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
50 if (!ret)
51 gpio_free(GPIO_PCMCIA_RESET);
52
53 return ret;
54}
55
56static void cmx255_pcmcia_shutdown(struct soc_pcmcia_socket *skt)
57{
58 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
59 gpio_free(GPIO_PCMCIA_RESET);
60}
61
62
63static void cmx255_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
64 struct pcmcia_state *state)
65{
66 int cd = skt->nr ? GPIO_PCMCIA_S1_CD_VALID : GPIO_PCMCIA_S0_CD_VALID;
67 int rdy = skt->nr ? GPIO_PCMCIA_S0_RDYINT : GPIO_PCMCIA_S1_RDYINT;
68
69 state->detect = !gpio_get_value(cd);
70 state->ready = !!gpio_get_value(rdy);
71 state->bvd1 = 1;
72 state->bvd2 = 1;
73 state->vs_3v = 0;
74 state->vs_Xv = 0;
75 state->wrprot = 0; /* not available */
76}
77
78
79static int cmx255_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
80 const socket_state_t *state)
81{
82 switch (skt->nr) {
83 case 0:
84 if (state->flags & SS_RESET) {
85 gpio_set_value(GPIO_PCMCIA_SKTSEL, 0);
86 udelay(1);
87 gpio_set_value(GPIO_PCMCIA_RESET, 1);
88 udelay(10);
89 gpio_set_value(GPIO_PCMCIA_RESET, 0);
90 }
91 break;
92 case 1:
93 if (state->flags & SS_RESET) {
94 gpio_set_value(GPIO_PCMCIA_SKTSEL, 1);
95 udelay(1);
96 gpio_set_value(GPIO_PCMCIA_RESET, 1);
97 udelay(10);
98 gpio_set_value(GPIO_PCMCIA_RESET, 0);
99 }
100 break;
101 }
102
103 return 0;
104}
105
106static void cmx255_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
107{
108}
109
110static void cmx255_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
111{
112}
113
114
115static struct pcmcia_low_level cmx255_pcmcia_ops __initdata = {
116 .owner = THIS_MODULE,
117 .hw_init = cmx255_pcmcia_hw_init,
118 .hw_shutdown = cmx255_pcmcia_shutdown,
119 .socket_state = cmx255_pcmcia_socket_state,
120 .configure_socket = cmx255_pcmcia_configure_socket,
121 .socket_init = cmx255_pcmcia_socket_init,
122 .socket_suspend = cmx255_pcmcia_socket_suspend,
123 .nr = 1,
124};
125
126static struct platform_device *cmx255_pcmcia_device;
127
128int __init cmx255_pcmcia_init(void)
129{
130 int ret;
131
132 cmx255_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
133
134 if (!cmx255_pcmcia_device)
135 return -ENOMEM;
136
137 ret = platform_device_add_data(cmx255_pcmcia_device, &cmx255_pcmcia_ops,
138 sizeof(cmx255_pcmcia_ops));
139
140 if (ret == 0) {
141 printk(KERN_INFO "Registering cm-x255 PCMCIA interface.\n");
142 ret = platform_device_add(cmx255_pcmcia_device);
143 }
144
145 if (ret)
146 platform_device_put(cmx255_pcmcia_device);
147
148 return ret;
149}
150
151void __exit cmx255_pcmcia_exit(void)
152{
153 platform_device_unregister(cmx255_pcmcia_device);
154}
diff --git a/drivers/pcmcia/pxa2xx_cm_x270.c b/drivers/pcmcia/pxa2xx_cm_x270.c
index bcff5cfed051..6c3aac377126 100644
--- a/drivers/pcmcia/pxa2xx_cm_x270.c
+++ b/drivers/pcmcia/pxa2xx_cm_x270.c
@@ -105,13 +105,10 @@ static struct pcmcia_low_level cmx270_pcmcia_ops __initdata = {
105 105
106static struct platform_device *cmx270_pcmcia_device; 106static struct platform_device *cmx270_pcmcia_device;
107 107
108static int __init cmx270_pcmcia_init(void) 108int __init cmx270_pcmcia_init(void)
109{ 109{
110 int ret; 110 int ret;
111 111
112 if (!machine_is_armcore())
113 return -ENODEV;
114
115 cmx270_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); 112 cmx270_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
116 113
117 if (!cmx270_pcmcia_device) 114 if (!cmx270_pcmcia_device)
@@ -131,14 +128,7 @@ static int __init cmx270_pcmcia_init(void)
131 return ret; 128 return ret;
132} 129}
133 130
134static void __exit cmx270_pcmcia_exit(void) 131void __exit cmx270_pcmcia_exit(void)
135{ 132{
136 platform_device_unregister(cmx270_pcmcia_device); 133 platform_device_unregister(cmx270_pcmcia_device);
137} 134}
138
139module_init(cmx270_pcmcia_init);
140module_exit(cmx270_pcmcia_exit);
141
142MODULE_LICENSE("GPL");
143MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>");
144MODULE_DESCRIPTION("CM-x270 PCMCIA driver");
diff --git a/drivers/pcmcia/pxa2xx_cm_x2xx.c b/drivers/pcmcia/pxa2xx_cm_x2xx.c
new file mode 100644
index 000000000000..4f09506ad8d4
--- /dev/null
+++ b/drivers/pcmcia/pxa2xx_cm_x2xx.c
@@ -0,0 +1,49 @@
1/*
2 * linux/drivers/pcmcia/pxa/pxa_cm_x2xx.c
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * Compulab Ltd., 2003, 2007, 2008
9 * Mike Rapoport <mike@compulab.co.il>
10 *
11 */
12
13#include <linux/module.h>
14
15#include <asm/system.h>
16#include <asm/mach-types.h>
17#include <mach/system.h>
18
19int cmx255_pcmcia_init(void);
20int cmx270_pcmcia_init(void);
21void cmx255_pcmcia_exit(void);
22void cmx270_pcmcia_exit(void);
23
24static int __init cmx2xx_pcmcia_init(void)
25{
26 int ret = -ENODEV;
27
28 if (machine_is_armcore() && cpu_is_pxa25x())
29 ret = cmx255_pcmcia_init();
30 else if (machine_is_armcore() && cpu_is_pxa27x())
31 ret = cmx270_pcmcia_init();
32
33 return ret;
34}
35
36static void __exit cmx2xx_pcmcia_exit(void)
37{
38 if (machine_is_armcore() && cpu_is_pxa25x())
39 cmx255_pcmcia_exit();
40 else if (machine_is_armcore() && cpu_is_pxa27x())
41 cmx270_pcmcia_exit();
42}
43
44module_init(cmx2xx_pcmcia_init);
45module_exit(cmx2xx_pcmcia_exit);
46
47MODULE_LICENSE("GPL");
48MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>");
49MODULE_DESCRIPTION("CM-x2xx PCMCIA driver");
diff --git a/drivers/pcmcia/pxa2xx_palmld.c b/drivers/pcmcia/pxa2xx_palmld.c
new file mode 100644
index 000000000000..1736c67e547e
--- /dev/null
+++ b/drivers/pcmcia/pxa2xx_palmld.c
@@ -0,0 +1,151 @@
1/*
2 * linux/drivers/pcmcia/pxa2xx_palmld.c
3 *
4 * Driver for Palm LifeDrive PCMCIA
5 *
6 * Copyright (C) 2006 Alex Osborne <ato@meshy.org>
7 * Copyright (C) 2007-2008 Marek Vasut <marek.vasut@gmail.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 */
14
15#include <linux/module.h>
16#include <linux/platform_device.h>
17#include <linux/gpio.h>
18
19#include <asm/mach-types.h>
20#include <mach/palmld.h>
21#include "soc_common.h"
22
23static int palmld_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
24{
25 int ret;
26
27 ret = gpio_request(GPIO_NR_PALMLD_PCMCIA_POWER, "PCMCIA PWR");
28 if (ret)
29 goto err1;
30 ret = gpio_direction_output(GPIO_NR_PALMLD_PCMCIA_POWER, 0);
31 if (ret)
32 goto err2;
33
34 ret = gpio_request(GPIO_NR_PALMLD_PCMCIA_RESET, "PCMCIA RST");
35 if (ret)
36 goto err2;
37 ret = gpio_direction_output(GPIO_NR_PALMLD_PCMCIA_RESET, 1);
38 if (ret)
39 goto err3;
40
41 ret = gpio_request(GPIO_NR_PALMLD_PCMCIA_READY, "PCMCIA RDY");
42 if (ret)
43 goto err3;
44 ret = gpio_direction_input(GPIO_NR_PALMLD_PCMCIA_READY);
45 if (ret)
46 goto err4;
47
48 skt->irq = IRQ_GPIO(GPIO_NR_PALMLD_PCMCIA_READY);
49 return 0;
50
51err4:
52 gpio_free(GPIO_NR_PALMLD_PCMCIA_READY);
53err3:
54 gpio_free(GPIO_NR_PALMLD_PCMCIA_RESET);
55err2:
56 gpio_free(GPIO_NR_PALMLD_PCMCIA_POWER);
57err1:
58 return ret;
59}
60
61static void palmld_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
62{
63 gpio_free(GPIO_NR_PALMLD_PCMCIA_READY);
64 gpio_free(GPIO_NR_PALMLD_PCMCIA_RESET);
65 gpio_free(GPIO_NR_PALMLD_PCMCIA_POWER);
66}
67
68static void palmld_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
69 struct pcmcia_state *state)
70{
71 state->detect = 1; /* always inserted */
72 state->ready = !!gpio_get_value(GPIO_NR_PALMLD_PCMCIA_READY);
73 state->bvd1 = 1;
74 state->bvd2 = 1;
75 state->wrprot = 0;
76 state->vs_3v = 1;
77 state->vs_Xv = 0;
78}
79
80static int palmld_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
81 const socket_state_t *state)
82{
83 gpio_set_value(GPIO_NR_PALMLD_PCMCIA_POWER, 1);
84 gpio_set_value(GPIO_NR_PALMLD_PCMCIA_RESET,
85 !!(state->flags & SS_RESET));
86
87 return 0;
88}
89
90static void palmld_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
91{
92}
93
94static void palmld_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
95{
96}
97
98static struct pcmcia_low_level palmld_pcmcia_ops = {
99 .owner = THIS_MODULE,
100
101 .first = 0,
102 .nr = 2,
103
104 .hw_init = palmld_pcmcia_hw_init,
105 .hw_shutdown = palmld_pcmcia_hw_shutdown,
106
107 .socket_state = palmld_pcmcia_socket_state,
108 .configure_socket = palmld_pcmcia_configure_socket,
109
110 .socket_init = palmld_pcmcia_socket_init,
111 .socket_suspend = palmld_pcmcia_socket_suspend,
112};
113
114static struct platform_device *palmld_pcmcia_device;
115
116static int __init palmld_pcmcia_init(void)
117{
118 int ret;
119
120 if (!machine_is_palmld())
121 return -ENODEV;
122
123 palmld_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
124 if (!palmld_pcmcia_device)
125 return -ENOMEM;
126
127 ret = platform_device_add_data(palmld_pcmcia_device, &palmld_pcmcia_ops,
128 sizeof(palmld_pcmcia_ops));
129
130 if (!ret)
131 ret = platform_device_add(palmld_pcmcia_device);
132
133 if (ret)
134 platform_device_put(palmld_pcmcia_device);
135
136 return ret;
137}
138
139static void __exit palmld_pcmcia_exit(void)
140{
141 platform_device_unregister(palmld_pcmcia_device);
142}
143
144module_init(palmld_pcmcia_init);
145module_exit(palmld_pcmcia_exit);
146
147MODULE_AUTHOR("Alex Osborne <ato@meshy.org>,"
148 " Marek Vasut <marek.vasut@gmail.com>");
149MODULE_DESCRIPTION("PCMCIA support for Palm LifeDrive");
150MODULE_ALIAS("platform:pxa2xx-pcmcia");
151MODULE_LICENSE("GPL");
diff --git a/drivers/pcmcia/pxa2xx_trizeps4.c b/drivers/pcmcia/pxa2xx_trizeps4.c
new file mode 100644
index 000000000000..36c7a0b324d2
--- /dev/null
+++ b/drivers/pcmcia/pxa2xx_trizeps4.c
@@ -0,0 +1,256 @@
1/*
2 * linux/drivers/pcmcia/pxa2xx_trizeps4.c
3 *
4 * TRIZEPS PCMCIA specific routines.
5 *
6 * Author: Jürgen Schindele
7 * Created: 20 02, 2006
8 * Copyright: Jürgen Schindele
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <linux/module.h>
16#include <linux/init.h>
17#include <linux/kernel.h>
18#include <linux/gpio.h>
19#include <linux/interrupt.h>
20#include <linux/platform_device.h>
21
22#include <asm/mach-types.h>
23#include <asm/irq.h>
24
25#include <mach/hardware.h>
26#include <mach/pxa-regs.h>
27#include <mach/trizeps4.h>
28
29#include "soc_common.h"
30
31extern void board_pcmcia_power(int power);
32
33static struct pcmcia_irqs irqs[] = {
34 { 0, IRQ_GPIO(GPIO_PCD), "cs0_cd" }
35 /* on other baseboards we can have more inputs */
36};
37
38static int trizeps_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
39{
40 int ret, i;
41 /* we dont have voltage/card/ready detection
42 * so we dont need interrupts for it
43 */
44 switch (skt->nr) {
45 case 0:
46 if (gpio_request(GPIO_PRDY, "cf_irq") < 0) {
47 pr_err("%s: sock %d unable to request gpio %d\n", __func__,
48 skt->nr, GPIO_PRDY);
49 return -EBUSY;
50 }
51 if (gpio_direction_input(GPIO_PRDY) < 0) {
52 pr_err("%s: sock %d unable to set input gpio %d\n", __func__,
53 skt->nr, GPIO_PRDY);
54 gpio_free(GPIO_PRDY);
55 return -EINVAL;
56 }
57 skt->irq = IRQ_GPIO(GPIO_PRDY);
58 break;
59
60#ifndef CONFIG_MACH_TRIZEPS_CONXS
61 case 1:
62#endif
63 default:
64 break;
65 }
66 /* release the reset of this card */
67 pr_debug("%s: sock %d irq %d\n", __func__, skt->nr, skt->irq);
68
69 /* supplementory irqs for the socket */
70 for (i = 0; i < ARRAY_SIZE(irqs); i++) {
71 if (irqs[i].sock != skt->nr)
72 continue;
73 if (gpio_request(IRQ_TO_GPIO(irqs[i].irq), irqs[i].str) < 0) {
74 pr_err("%s: sock %d unable to request gpio %d\n",
75 __func__, skt->nr, IRQ_TO_GPIO(irqs[i].irq));
76 ret = -EBUSY;
77 goto error;
78 }
79 if (gpio_direction_input(IRQ_TO_GPIO(irqs[i].irq)) < 0) {
80 pr_err("%s: sock %d unable to set input gpio %d\n",
81 __func__, skt->nr, IRQ_TO_GPIO(irqs[i].irq));
82 ret = -EINVAL;
83 goto error;
84 }
85 }
86 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
87
88error:
89 for (; i >= 0; i--) {
90 gpio_free(IRQ_TO_GPIO(irqs[i].irq));
91 }
92 return (ret);
93}
94
95static void trizeps_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
96{
97 int i;
98 /* free allocated gpio's */
99 gpio_free(GPIO_PRDY);
100 for (i = 0; i < ARRAY_SIZE(irqs); i++)
101 gpio_free(IRQ_TO_GPIO(irqs[i].irq));
102}
103
104static unsigned long trizeps_pcmcia_status[2];
105
106static void trizeps_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
107 struct pcmcia_state *state)
108{
109 unsigned short status = 0, change;
110 status = CFSR_readw();
111 change = (status ^ trizeps_pcmcia_status[skt->nr]) &
112 ConXS_CFSR_BVD_MASK;
113 if (change) {
114 trizeps_pcmcia_status[skt->nr] = status;
115 if (status & ConXS_CFSR_BVD1) {
116 /* enable_irq empty */
117 } else {
118 /* disable_irq empty */
119 }
120 }
121
122 switch (skt->nr) {
123 case 0:
124 /* just fill in fix states */
125 state->detect = gpio_get_value(GPIO_PCD) ? 0 : 1;
126 state->ready = gpio_get_value(GPIO_PRDY) ? 1 : 0;
127 state->bvd1 = (status & ConXS_CFSR_BVD1) ? 1 : 0;
128 state->bvd2 = (status & ConXS_CFSR_BVD2) ? 1 : 0;
129 state->vs_3v = (status & ConXS_CFSR_VS1) ? 0 : 1;
130 state->vs_Xv = (status & ConXS_CFSR_VS2) ? 0 : 1;
131 state->wrprot = 0; /* not available */
132 break;
133
134#ifndef CONFIG_MACH_TRIZEPS_CONXS
135 /* on ConXS we only have one slot. Second is inactive */
136 case 1:
137 state->detect = 0;
138 state->ready = 0;
139 state->bvd1 = 0;
140 state->bvd2 = 0;
141 state->vs_3v = 0;
142 state->vs_Xv = 0;
143 state->wrprot = 0;
144 break;
145
146#endif
147 }
148}
149
150static int trizeps_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
151 const socket_state_t *state)
152{
153 int ret = 0;
154 unsigned short power = 0;
155
156 /* we do nothing here just check a bit */
157 switch (state->Vcc) {
158 case 0: power &= 0xfc; break;
159 case 33: power |= ConXS_BCR_S0_VCC_3V3; break;
160 case 50:
161 pr_err("%s(): Vcc 5V not supported in socket\n", __func__);
162 break;
163 default:
164 pr_err("%s(): bad Vcc %u\n", __func__, state->Vcc);
165 ret = -1;
166 }
167
168 switch (state->Vpp) {
169 case 0: power &= 0xf3; break;
170 case 33: power |= ConXS_BCR_S0_VPP_3V3; break;
171 case 120:
172 pr_err("%s(): Vpp 12V not supported in socket\n", __func__);
173 break;
174 default:
175 if (state->Vpp != state->Vcc) {
176 pr_err("%s(): bad Vpp %u\n", __func__, state->Vpp);
177 ret = -1;
178 }
179 }
180
181 switch (skt->nr) {
182 case 0: /* we only have 3.3V */
183 board_pcmcia_power(power);
184 break;
185
186#ifndef CONFIG_MACH_TRIZEPS_CONXS
187 /* on ConXS we only have one slot. Second is inactive */
188 case 1:
189#endif
190 default:
191 break;
192 }
193
194 return ret;
195}
196
197static void trizeps_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
198{
199 /* default is on */
200 board_pcmcia_power(0x9);
201}
202
203static void trizeps_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
204{
205 board_pcmcia_power(0x0);
206}
207
208static struct pcmcia_low_level trizeps_pcmcia_ops = {
209 .owner = THIS_MODULE,
210 .hw_init = trizeps_pcmcia_hw_init,
211 .hw_shutdown = trizeps_pcmcia_hw_shutdown,
212 .socket_state = trizeps_pcmcia_socket_state,
213 .configure_socket = trizeps_pcmcia_configure_socket,
214 .socket_init = trizeps_pcmcia_socket_init,
215 .socket_suspend = trizeps_pcmcia_socket_suspend,
216#ifdef CONFIG_MACH_TRIZEPS_CONXS
217 .nr = 1,
218#else
219 .nr = 2,
220#endif
221 .first = 0,
222};
223
224static struct platform_device *trizeps_pcmcia_device;
225
226static int __init trizeps_pcmcia_init(void)
227{
228 int ret;
229
230 trizeps_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
231 if (!trizeps_pcmcia_device)
232 return -ENOMEM;
233
234 ret = platform_device_add_data(trizeps_pcmcia_device,
235 &trizeps_pcmcia_ops, sizeof(trizeps_pcmcia_ops));
236
237 if (ret == 0)
238 ret = platform_device_add(trizeps_pcmcia_device);
239
240 if (ret)
241 platform_device_put(trizeps_pcmcia_device);
242
243 return ret;
244}
245
246static void __exit trizeps_pcmcia_exit(void)
247{
248 platform_device_unregister(trizeps_pcmcia_device);
249}
250
251fs_initcall(trizeps_pcmcia_init);
252module_exit(trizeps_pcmcia_exit);
253
254MODULE_LICENSE("GPL");
255MODULE_AUTHOR("Juergen Schindele");
256MODULE_ALIAS("platform:pxa2xx-pcmcia");
diff --git a/drivers/pcmcia/pxa2xx_viper.c b/drivers/pcmcia/pxa2xx_viper.c
new file mode 100644
index 000000000000..dd10481be7bf
--- /dev/null
+++ b/drivers/pcmcia/pxa2xx_viper.c
@@ -0,0 +1,179 @@
1/*
2 * VIPER PCMCIA support
3 * Copyright 2004 Arcom Control Systems
4 *
5 * Maintained by Marc Zyngier <maz@misterjones.org>
6 * <marc.zyngier@altran.com>
7 *
8 * Based on:
9 * iPAQ h2200 PCMCIA support
10 * Copyright 2004 Koen Kooi <koen@vestingbar.nl>
11 *
12 * This file is subject to the terms and conditions of the GNU General Public
13 * License. See the file COPYING in the main directory of this archive for
14 * more details.
15 */
16
17#include <linux/module.h>
18#include <linux/init.h>
19#include <linux/kernel.h>
20#include <linux/errno.h>
21#include <linux/interrupt.h>
22#include <linux/platform_device.h>
23#include <linux/gpio.h>
24
25#include <pcmcia/ss.h>
26
27#include <asm/irq.h>
28
29#include <mach/pxa-regs.h>
30#include <mach/viper.h>
31#include <asm/mach-types.h>
32
33#include "soc_common.h"
34#include "pxa2xx_base.h"
35
36static struct pcmcia_irqs irqs[] = {
37 { 0, gpio_to_irq(VIPER_CF_CD_GPIO), "PCMCIA_CD" }
38};
39
40static int viper_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
41{
42 unsigned long flags;
43
44 skt->irq = gpio_to_irq(VIPER_CF_RDY_GPIO);
45
46 if (gpio_request(VIPER_CF_CD_GPIO, "CF detect"))
47 goto err_request_cd;
48
49 if (gpio_request(VIPER_CF_RDY_GPIO, "CF ready"))
50 goto err_request_rdy;
51
52 if (gpio_request(VIPER_CF_POWER_GPIO, "CF power"))
53 goto err_request_pwr;
54
55 local_irq_save(flags);
56
57 /* GPIO 82 is the CF power enable line. initially off */
58 if (gpio_direction_output(VIPER_CF_POWER_GPIO, 0) ||
59 gpio_direction_input(VIPER_CF_CD_GPIO) ||
60 gpio_direction_input(VIPER_CF_RDY_GPIO)) {
61 local_irq_restore(flags);
62 goto err_dir;
63 }
64
65 local_irq_restore(flags);
66
67 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
68
69err_dir:
70 gpio_free(VIPER_CF_POWER_GPIO);
71err_request_pwr:
72 gpio_free(VIPER_CF_RDY_GPIO);
73err_request_rdy:
74 gpio_free(VIPER_CF_CD_GPIO);
75err_request_cd:
76 printk(KERN_ERR "viper: Failed to setup PCMCIA GPIOs\n");
77 return -1;
78}
79
80/*
81 * Release all resources.
82 */
83static void viper_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
84{
85 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
86 gpio_free(VIPER_CF_POWER_GPIO);
87 gpio_free(VIPER_CF_RDY_GPIO);
88 gpio_free(VIPER_CF_CD_GPIO);
89}
90
91static void viper_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
92 struct pcmcia_state *state)
93{
94 state->detect = gpio_get_value(VIPER_CF_CD_GPIO) ? 0 : 1;
95 state->ready = gpio_get_value(VIPER_CF_RDY_GPIO) ? 1 : 0;
96 state->bvd1 = 1;
97 state->bvd2 = 1;
98 state->wrprot = 0;
99 state->vs_3v = 1; /* Can only apply 3.3V */
100 state->vs_Xv = 0;
101}
102
103static int viper_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
104 const socket_state_t *state)
105{
106 /* Silently ignore Vpp, output enable, speaker enable. */
107 viper_cf_rst(state->flags & SS_RESET);
108
109 /* Apply socket voltage */
110 switch (state->Vcc) {
111 case 0:
112 gpio_set_value(VIPER_CF_POWER_GPIO, 0);
113 break;
114 case 33:
115 gpio_set_value(VIPER_CF_POWER_GPIO, 1);
116 break;
117 default:
118 printk(KERN_ERR "%s: Unsupported Vcc:%d\n",
119 __func__, state->Vcc);
120 return -1;
121 }
122
123 return 0;
124}
125
126static void viper_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
127{
128}
129
130static void viper_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
131{
132}
133
134static struct pcmcia_low_level viper_pcmcia_ops __initdata = {
135 .owner = THIS_MODULE,
136 .hw_init = viper_pcmcia_hw_init,
137 .hw_shutdown = viper_pcmcia_hw_shutdown,
138 .socket_state = viper_pcmcia_socket_state,
139 .configure_socket = viper_pcmcia_configure_socket,
140 .socket_init = viper_pcmcia_socket_init,
141 .socket_suspend = viper_pcmcia_socket_suspend,
142 .nr = 1,
143};
144
145static struct platform_device *viper_pcmcia_device;
146
147static int __init viper_pcmcia_init(void)
148{
149 int ret;
150
151 if (!machine_is_viper())
152 return -ENODEV;
153
154 viper_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
155 if (!viper_pcmcia_device)
156 return -ENOMEM;
157
158 ret = platform_device_add_data(viper_pcmcia_device,
159 &viper_pcmcia_ops,
160 sizeof(viper_pcmcia_ops));
161
162 if (!ret)
163 ret = platform_device_add(viper_pcmcia_device);
164
165 if (ret)
166 platform_device_put(viper_pcmcia_device);
167
168 return ret;
169}
170
171static void __exit viper_pcmcia_exit(void)
172{
173 platform_device_unregister(viper_pcmcia_device);
174}
175
176module_init(viper_pcmcia_init);
177module_exit(viper_pcmcia_exit);
178
179MODULE_LICENSE("GPL");