diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-06 19:50:35 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-06 19:50:35 -0500 |
commit | 3c0cb7c31c206aaedb967e44b98442bbeb17a6c4 (patch) | |
tree | 3ecba45d7ffae4fba4a5aafaef4af5b0b1105bde /drivers/pcmcia | |
parent | f70f5b9dc74ca7d0a64c4ead3fb28da09dc1b234 (diff) | |
parent | 404a02cbd2ae8bf256a2fa1169bdfe86bb5ebb34 (diff) |
Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm
* 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm: (416 commits)
ARM: DMA: add support for DMA debugging
ARM: PL011: add DMA burst threshold support for ST variants
ARM: PL011: Add support for transmit DMA
ARM: PL011: Ensure IRQs are disabled in UART interrupt handler
ARM: PL011: Separate hardware FIFO size from TTY FIFO size
ARM: PL011: Allow better handling of vendor data
ARM: PL011: Ensure error flags are clear at startup
ARM: PL011: include revision number in boot-time port printk
ARM: vexpress: add sched_clock() for Versatile Express
ARM i.MX53: Make MX53 EVK bootable
ARM i.MX53: Some bug fix about MX53 MSL code
ARM: 6607/1: sa1100: Update platform device registration
ARM: 6606/1: sa1100: Fix platform device registration
ARM i.MX51: rename IPU irqs
ARM i.MX51: Add ipu clock support
ARM: imx/mx27_3ds: Add PMIC support
ARM: DMA: Replace page_to_dma()/dma_to_page() with pfn_to_dma()/dma_to_pfn()
mx51: fix usb clock support
MX51: Add support for usb host 2
arch/arm/plat-mxc/ehci.c: fix errors/typos
...
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r-- | drivers/pcmcia/Kconfig | 3 | ||||
-rw-r--r-- | drivers/pcmcia/Makefile | 5 | ||||
-rw-r--r-- | drivers/pcmcia/pxa2xx_balloon3.c | 11 | ||||
-rw-r--r-- | drivers/pcmcia/pxa2xx_base.c | 64 | ||||
-rw-r--r-- | drivers/pcmcia/pxa2xx_colibri.c | 229 | ||||
-rw-r--r-- | drivers/pcmcia/sa1100_generic.c | 3 | ||||
-rw-r--r-- | drivers/pcmcia/sa1100_generic.h | 1 | ||||
-rw-r--r-- | drivers/pcmcia/sa1100_nanoengine.c | 219 | ||||
-rw-r--r-- | drivers/pcmcia/soc_common.c | 128 | ||||
-rw-r--r-- | drivers/pcmcia/soc_common.h | 3 |
10 files changed, 585 insertions, 81 deletions
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index c80a7a6e7698..de886f3dfd39 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig | |||
@@ -215,7 +215,8 @@ config PCMCIA_PXA2XX | |||
215 | depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \ | 215 | depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \ |
216 | || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \ | 216 | || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \ |
217 | || ARCOM_PCMCIA || ARCH_PXA_ESERIES || MACH_STARGATE2 \ | 217 | || ARCOM_PCMCIA || ARCH_PXA_ESERIES || MACH_STARGATE2 \ |
218 | || MACH_VPAC270 || MACH_BALLOON3) | 218 | || MACH_VPAC270 || MACH_BALLOON3 || MACH_COLIBRI \ |
219 | || MACH_COLIBRI320) | ||
219 | select PCMCIA_SOC_COMMON | 220 | select PCMCIA_SOC_COMMON |
220 | help | 221 | help |
221 | Say Y here to include support for the PXA2xx PCMCIA controller | 222 | Say Y here to include support for the PXA2xx PCMCIA controller |
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index 8d9386a22eb3..29935ea921df 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile | |||
@@ -50,8 +50,9 @@ sa1111_cs-$(CONFIG_SA1100_JORNADA720) += sa1100_jornada720.o | |||
50 | sa1100_cs-y += sa1100_generic.o | 50 | sa1100_cs-y += sa1100_generic.o |
51 | sa1100_cs-$(CONFIG_SA1100_ASSABET) += sa1100_assabet.o | 51 | sa1100_cs-$(CONFIG_SA1100_ASSABET) += sa1100_assabet.o |
52 | sa1100_cs-$(CONFIG_SA1100_CERF) += sa1100_cerf.o | 52 | sa1100_cs-$(CONFIG_SA1100_CERF) += sa1100_cerf.o |
53 | sa1100_cs-$(CONFIG_SA1100_COLLIE) += pxa2xx_sharpsl.o | 53 | sa1100_cs-$(CONFIG_SA1100_COLLIE) += pxa2xx_sharpsl.o |
54 | sa1100_cs-$(CONFIG_SA1100_H3600) += sa1100_h3600.o | 54 | sa1100_cs-$(CONFIG_SA1100_H3600) += sa1100_h3600.o |
55 | sa1100_cs-$(CONFIG_SA1100_NANOENGINE) += sa1100_nanoengine.o | ||
55 | sa1100_cs-$(CONFIG_SA1100_SHANNON) += sa1100_shannon.o | 56 | sa1100_cs-$(CONFIG_SA1100_SHANNON) += sa1100_shannon.o |
56 | sa1100_cs-$(CONFIG_SA1100_SIMPAD) += sa1100_simpad.o | 57 | sa1100_cs-$(CONFIG_SA1100_SIMPAD) += sa1100_simpad.o |
57 | 58 | ||
@@ -70,6 +71,8 @@ pxa2xx-obj-$(CONFIG_MACH_E740) += pxa2xx_e740.o | |||
70 | pxa2xx-obj-$(CONFIG_MACH_STARGATE2) += pxa2xx_stargate2.o | 71 | pxa2xx-obj-$(CONFIG_MACH_STARGATE2) += pxa2xx_stargate2.o |
71 | pxa2xx-obj-$(CONFIG_MACH_VPAC270) += pxa2xx_vpac270.o | 72 | pxa2xx-obj-$(CONFIG_MACH_VPAC270) += pxa2xx_vpac270.o |
72 | pxa2xx-obj-$(CONFIG_MACH_BALLOON3) += pxa2xx_balloon3.o | 73 | pxa2xx-obj-$(CONFIG_MACH_BALLOON3) += pxa2xx_balloon3.o |
74 | pxa2xx-obj-$(CONFIG_MACH_COLIBRI) += pxa2xx_colibri.o | ||
75 | pxa2xx-obj-$(CONFIG_MACH_COLIBRI320) += pxa2xx_colibri.o | ||
73 | 76 | ||
74 | obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_base.o $(pxa2xx-obj-y) | 77 | obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_base.o $(pxa2xx-obj-y) |
75 | 78 | ||
diff --git a/drivers/pcmcia/pxa2xx_balloon3.c b/drivers/pcmcia/pxa2xx_balloon3.c index dbbdd0063202..453c54c97612 100644 --- a/drivers/pcmcia/pxa2xx_balloon3.c +++ b/drivers/pcmcia/pxa2xx_balloon3.c | |||
@@ -39,12 +39,10 @@ static struct pcmcia_irqs irqs[] = { | |||
39 | static int balloon3_pcmcia_hw_init(struct soc_pcmcia_socket *skt) | 39 | static int balloon3_pcmcia_hw_init(struct soc_pcmcia_socket *skt) |
40 | { | 40 | { |
41 | uint16_t ver; | 41 | uint16_t ver; |
42 | int ret; | ||
43 | static void __iomem *fpga_ver; | ||
44 | 42 | ||
45 | ver = __raw_readw(BALLOON3_FPGA_VER); | 43 | ver = __raw_readw(BALLOON3_FPGA_VER); |
46 | if (ver > 0x0201) | 44 | if (ver < 0x4f08) |
47 | pr_warn("The FPGA code, version 0x%04x, is newer than rel-0.3. " | 45 | pr_warn("The FPGA code, version 0x%04x, is too old. " |
48 | "PCMCIA/CF support might be broken in this version!", | 46 | "PCMCIA/CF support might be broken in this version!", |
49 | ver); | 47 | ver); |
50 | 48 | ||
@@ -97,8 +95,9 @@ static void balloon3_pcmcia_socket_state(struct soc_pcmcia_socket *skt, | |||
97 | static int balloon3_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | 95 | static int balloon3_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, |
98 | const socket_state_t *state) | 96 | const socket_state_t *state) |
99 | { | 97 | { |
100 | __raw_writew((state->flags & SS_RESET) ? BALLOON3_CF_RESET : 0, | 98 | __raw_writew(BALLOON3_CF_RESET, BALLOON3_CF_CONTROL_REG | |
101 | BALLOON3_CF_CONTROL_REG); | 99 | ((state->flags & SS_RESET) ? |
100 | BALLOON3_FPGA_SETnCLR : 0)); | ||
102 | return 0; | 101 | return 0; |
103 | } | 102 | } |
104 | 103 | ||
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c index ae07b4db8a6e..3755e7c8c715 100644 --- a/drivers/pcmcia/pxa2xx_base.c +++ b/drivers/pcmcia/pxa2xx_base.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
27 | 27 | ||
28 | #include <mach/hardware.h> | 28 | #include <mach/hardware.h> |
29 | #include <mach/smemc.h> | ||
29 | #include <asm/io.h> | 30 | #include <asm/io.h> |
30 | #include <asm/irq.h> | 31 | #include <asm/irq.h> |
31 | #include <asm/system.h> | 32 | #include <asm/system.h> |
@@ -116,37 +117,49 @@ static inline u_int pxa2xx_pcmcia_cmd_time(u_int mem_clk_10khz, | |||
116 | 117 | ||
117 | static int pxa2xx_pcmcia_set_mcmem( int sock, int speed, int clock ) | 118 | static int pxa2xx_pcmcia_set_mcmem( int sock, int speed, int clock ) |
118 | { | 119 | { |
119 | MCMEM(sock) = ((pxa2xx_mcxx_setup(speed, clock) | 120 | uint32_t val; |
121 | |||
122 | val = ((pxa2xx_mcxx_setup(speed, clock) | ||
120 | & MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT) | 123 | & MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT) |
121 | | ((pxa2xx_mcxx_asst(speed, clock) | 124 | | ((pxa2xx_mcxx_asst(speed, clock) |
122 | & MCXX_ASST_MASK) << MCXX_ASST_SHIFT) | 125 | & MCXX_ASST_MASK) << MCXX_ASST_SHIFT) |
123 | | ((pxa2xx_mcxx_hold(speed, clock) | 126 | | ((pxa2xx_mcxx_hold(speed, clock) |
124 | & MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT); | 127 | & MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT); |
125 | 128 | ||
129 | __raw_writel(val, MCMEM(sock)); | ||
130 | |||
126 | return 0; | 131 | return 0; |
127 | } | 132 | } |
128 | 133 | ||
129 | static int pxa2xx_pcmcia_set_mcio( int sock, int speed, int clock ) | 134 | static int pxa2xx_pcmcia_set_mcio( int sock, int speed, int clock ) |
130 | { | 135 | { |
131 | MCIO(sock) = ((pxa2xx_mcxx_setup(speed, clock) | 136 | uint32_t val; |
137 | |||
138 | val = ((pxa2xx_mcxx_setup(speed, clock) | ||
132 | & MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT) | 139 | & MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT) |
133 | | ((pxa2xx_mcxx_asst(speed, clock) | 140 | | ((pxa2xx_mcxx_asst(speed, clock) |
134 | & MCXX_ASST_MASK) << MCXX_ASST_SHIFT) | 141 | & MCXX_ASST_MASK) << MCXX_ASST_SHIFT) |
135 | | ((pxa2xx_mcxx_hold(speed, clock) | 142 | | ((pxa2xx_mcxx_hold(speed, clock) |
136 | & MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT); | 143 | & MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT); |
137 | 144 | ||
145 | __raw_writel(val, MCIO(sock)); | ||
146 | |||
138 | return 0; | 147 | return 0; |
139 | } | 148 | } |
140 | 149 | ||
141 | static int pxa2xx_pcmcia_set_mcatt( int sock, int speed, int clock ) | 150 | static int pxa2xx_pcmcia_set_mcatt( int sock, int speed, int clock ) |
142 | { | 151 | { |
143 | MCATT(sock) = ((pxa2xx_mcxx_setup(speed, clock) | 152 | uint32_t val; |
153 | |||
154 | val = ((pxa2xx_mcxx_setup(speed, clock) | ||
144 | & MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT) | 155 | & MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT) |
145 | | ((pxa2xx_mcxx_asst(speed, clock) | 156 | | ((pxa2xx_mcxx_asst(speed, clock) |
146 | & MCXX_ASST_MASK) << MCXX_ASST_SHIFT) | 157 | & MCXX_ASST_MASK) << MCXX_ASST_SHIFT) |
147 | | ((pxa2xx_mcxx_hold(speed, clock) | 158 | | ((pxa2xx_mcxx_hold(speed, clock) |
148 | & MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT); | 159 | & MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT); |
149 | 160 | ||
161 | __raw_writel(val, MCATT(sock)); | ||
162 | |||
150 | return 0; | 163 | return 0; |
151 | } | 164 | } |
152 | 165 | ||
@@ -166,8 +179,8 @@ static int pxa2xx_pcmcia_set_mcxx(struct soc_pcmcia_socket *skt, unsigned int cl | |||
166 | 179 | ||
167 | static int pxa2xx_pcmcia_set_timing(struct soc_pcmcia_socket *skt) | 180 | static int pxa2xx_pcmcia_set_timing(struct soc_pcmcia_socket *skt) |
168 | { | 181 | { |
169 | unsigned int clk = get_memclk_frequency_10khz(); | 182 | unsigned long clk = clk_get_rate(skt->clk); |
170 | return pxa2xx_pcmcia_set_mcxx(skt, clk); | 183 | return pxa2xx_pcmcia_set_mcxx(skt, clk / 10000); |
171 | } | 184 | } |
172 | 185 | ||
173 | #ifdef CONFIG_CPU_FREQ | 186 | #ifdef CONFIG_CPU_FREQ |
@@ -205,19 +218,18 @@ pxa2xx_pcmcia_frequency_change(struct soc_pcmcia_socket *skt, | |||
205 | static void pxa2xx_configure_sockets(struct device *dev) | 218 | static void pxa2xx_configure_sockets(struct device *dev) |
206 | { | 219 | { |
207 | struct pcmcia_low_level *ops = dev->platform_data; | 220 | struct pcmcia_low_level *ops = dev->platform_data; |
208 | |||
209 | /* | 221 | /* |
210 | * We have at least one socket, so set MECR:CIT | 222 | * We have at least one socket, so set MECR:CIT |
211 | * (Card Is There) | 223 | * (Card Is There) |
212 | */ | 224 | */ |
213 | MECR |= MECR_CIT; | 225 | uint32_t mecr = MECR_CIT; |
214 | 226 | ||
215 | /* Set MECR:NOS (Number Of Sockets) */ | 227 | /* Set MECR:NOS (Number Of Sockets) */ |
216 | if ((ops->first + ops->nr) > 1 || | 228 | if ((ops->first + ops->nr) > 1 || |
217 | machine_is_viper() || machine_is_arcom_zeus()) | 229 | machine_is_viper() || machine_is_arcom_zeus()) |
218 | MECR |= MECR_NOS; | 230 | mecr |= MECR_NOS; |
219 | else | 231 | |
220 | MECR &= ~MECR_NOS; | 232 | __raw_writel(mecr, MECR); |
221 | } | 233 | } |
222 | 234 | ||
223 | static const char *skt_names[] = { | 235 | static const char *skt_names[] = { |
@@ -270,24 +282,41 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev) | |||
270 | struct pcmcia_low_level *ops; | 282 | struct pcmcia_low_level *ops; |
271 | struct skt_dev_info *sinfo; | 283 | struct skt_dev_info *sinfo; |
272 | struct soc_pcmcia_socket *skt; | 284 | struct soc_pcmcia_socket *skt; |
285 | struct clk *clk; | ||
273 | 286 | ||
274 | ops = (struct pcmcia_low_level *)dev->dev.platform_data; | 287 | ops = (struct pcmcia_low_level *)dev->dev.platform_data; |
275 | if (!ops) | 288 | if (!ops) { |
289 | ret = -ENODEV; | ||
290 | goto err0; | ||
291 | } | ||
292 | |||
293 | if (cpu_is_pxa320() && ops->nr > 1) { | ||
294 | dev_err(&dev->dev, "pxa320 supports only one pcmcia slot"); | ||
295 | ret = -EINVAL; | ||
296 | goto err0; | ||
297 | } | ||
298 | |||
299 | clk = clk_get(&dev->dev, NULL); | ||
300 | if (!clk) | ||
276 | return -ENODEV; | 301 | return -ENODEV; |
277 | 302 | ||
278 | pxa2xx_drv_pcmcia_ops(ops); | 303 | pxa2xx_drv_pcmcia_ops(ops); |
279 | 304 | ||
280 | sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops->nr), GFP_KERNEL); | 305 | sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops->nr), GFP_KERNEL); |
281 | if (!sinfo) | 306 | if (!sinfo) { |
307 | clk_put(clk); | ||
282 | return -ENOMEM; | 308 | return -ENOMEM; |
309 | } | ||
283 | 310 | ||
284 | sinfo->nskt = ops->nr; | 311 | sinfo->nskt = ops->nr; |
312 | sinfo->clk = clk; | ||
285 | 313 | ||
286 | /* Initialize processor specific parameters */ | 314 | /* Initialize processor specific parameters */ |
287 | for (i = 0; i < ops->nr; i++) { | 315 | for (i = 0; i < ops->nr; i++) { |
288 | skt = &sinfo->skt[i]; | 316 | skt = &sinfo->skt[i]; |
289 | 317 | ||
290 | skt->nr = ops->first + i; | 318 | skt->nr = ops->first + i; |
319 | skt->clk = clk; | ||
291 | skt->ops = ops; | 320 | skt->ops = ops; |
292 | skt->socket.owner = ops->owner; | 321 | skt->socket.owner = ops->owner; |
293 | skt->socket.dev.parent = &dev->dev; | 322 | skt->socket.dev.parent = &dev->dev; |
@@ -295,18 +324,26 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev) | |||
295 | 324 | ||
296 | ret = pxa2xx_drv_pcmcia_add_one(skt); | 325 | ret = pxa2xx_drv_pcmcia_add_one(skt); |
297 | if (ret) | 326 | if (ret) |
298 | break; | 327 | goto err1; |
299 | } | 328 | } |
300 | 329 | ||
301 | if (ret) { | 330 | if (ret) { |
302 | while (--i >= 0) | 331 | while (--i >= 0) |
303 | soc_pcmcia_remove_one(&sinfo->skt[i]); | 332 | soc_pcmcia_remove_one(&sinfo->skt[i]); |
304 | kfree(sinfo); | 333 | kfree(sinfo); |
334 | clk_put(clk); | ||
305 | } else { | 335 | } else { |
306 | pxa2xx_configure_sockets(&dev->dev); | 336 | pxa2xx_configure_sockets(&dev->dev); |
307 | dev_set_drvdata(&dev->dev, sinfo); | 337 | dev_set_drvdata(&dev->dev, sinfo); |
308 | } | 338 | } |
309 | 339 | ||
340 | return 0; | ||
341 | |||
342 | err1: | ||
343 | while (--i >= 0) | ||
344 | soc_pcmcia_remove_one(&sinfo->skt[i]); | ||
345 | kfree(sinfo); | ||
346 | err0: | ||
310 | return ret; | 347 | return ret; |
311 | } | 348 | } |
312 | 349 | ||
@@ -320,6 +357,7 @@ static int pxa2xx_drv_pcmcia_remove(struct platform_device *dev) | |||
320 | for (i = 0; i < sinfo->nskt; i++) | 357 | for (i = 0; i < sinfo->nskt; i++) |
321 | soc_pcmcia_remove_one(&sinfo->skt[i]); | 358 | soc_pcmcia_remove_one(&sinfo->skt[i]); |
322 | 359 | ||
360 | clk_put(sinfo->clk); | ||
323 | kfree(sinfo); | 361 | kfree(sinfo); |
324 | return 0; | 362 | return 0; |
325 | } | 363 | } |
diff --git a/drivers/pcmcia/pxa2xx_colibri.c b/drivers/pcmcia/pxa2xx_colibri.c new file mode 100644 index 000000000000..c3f72192af66 --- /dev/null +++ b/drivers/pcmcia/pxa2xx_colibri.c | |||
@@ -0,0 +1,229 @@ | |||
1 | /* | ||
2 | * linux/drivers/pcmcia/pxa2xx_colibri.c | ||
3 | * | ||
4 | * Driver for Toradex Colibri PXA270 CF socket | ||
5 | * | ||
6 | * Copyright (C) 2010 Marek Vasut <marek.vasut@gmail.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/gpio.h> | ||
18 | |||
19 | #include <asm/mach-types.h> | ||
20 | |||
21 | #include "soc_common.h" | ||
22 | |||
23 | #define COLIBRI270_RESET_GPIO 53 | ||
24 | #define COLIBRI270_PPEN_GPIO 107 | ||
25 | #define COLIBRI270_BVD1_GPIO 83 | ||
26 | #define COLIBRI270_BVD2_GPIO 82 | ||
27 | #define COLIBRI270_DETECT_GPIO 84 | ||
28 | #define COLIBRI270_READY_GPIO 1 | ||
29 | |||
30 | #define COLIBRI320_RESET_GPIO 77 | ||
31 | #define COLIBRI320_PPEN_GPIO 57 | ||
32 | #define COLIBRI320_BVD1_GPIO 53 | ||
33 | #define COLIBRI320_BVD2_GPIO 79 | ||
34 | #define COLIBRI320_DETECT_GPIO 81 | ||
35 | #define COLIBRI320_READY_GPIO 29 | ||
36 | |||
37 | static struct { | ||
38 | int reset_gpio; | ||
39 | int ppen_gpio; | ||
40 | int bvd1_gpio; | ||
41 | int bvd2_gpio; | ||
42 | int detect_gpio; | ||
43 | int ready_gpio; | ||
44 | } colibri_pcmcia_gpio; | ||
45 | |||
46 | static struct pcmcia_irqs colibri_irqs[] = { | ||
47 | { | ||
48 | .sock = 0, | ||
49 | .str = "PCMCIA CD" | ||
50 | }, | ||
51 | }; | ||
52 | |||
53 | static int colibri_pcmcia_hw_init(struct soc_pcmcia_socket *skt) | ||
54 | { | ||
55 | int ret; | ||
56 | |||
57 | ret = gpio_request(colibri_pcmcia_gpio.detect_gpio, "DETECT"); | ||
58 | if (ret) | ||
59 | goto err1; | ||
60 | ret = gpio_direction_input(colibri_pcmcia_gpio.detect_gpio); | ||
61 | if (ret) | ||
62 | goto err2; | ||
63 | |||
64 | ret = gpio_request(colibri_pcmcia_gpio.ready_gpio, "READY"); | ||
65 | if (ret) | ||
66 | goto err2; | ||
67 | ret = gpio_direction_input(colibri_pcmcia_gpio.ready_gpio); | ||
68 | if (ret) | ||
69 | goto err3; | ||
70 | |||
71 | ret = gpio_request(colibri_pcmcia_gpio.bvd1_gpio, "BVD1"); | ||
72 | if (ret) | ||
73 | goto err3; | ||
74 | ret = gpio_direction_input(colibri_pcmcia_gpio.bvd1_gpio); | ||
75 | if (ret) | ||
76 | goto err4; | ||
77 | |||
78 | ret = gpio_request(colibri_pcmcia_gpio.bvd2_gpio, "BVD2"); | ||
79 | if (ret) | ||
80 | goto err4; | ||
81 | ret = gpio_direction_input(colibri_pcmcia_gpio.bvd2_gpio); | ||
82 | if (ret) | ||
83 | goto err5; | ||
84 | |||
85 | ret = gpio_request(colibri_pcmcia_gpio.ppen_gpio, "PPEN"); | ||
86 | if (ret) | ||
87 | goto err5; | ||
88 | ret = gpio_direction_output(colibri_pcmcia_gpio.ppen_gpio, 0); | ||
89 | if (ret) | ||
90 | goto err6; | ||
91 | |||
92 | ret = gpio_request(colibri_pcmcia_gpio.reset_gpio, "RESET"); | ||
93 | if (ret) | ||
94 | goto err6; | ||
95 | ret = gpio_direction_output(colibri_pcmcia_gpio.reset_gpio, 1); | ||
96 | if (ret) | ||
97 | goto err7; | ||
98 | |||
99 | colibri_irqs[0].irq = gpio_to_irq(colibri_pcmcia_gpio.detect_gpio); | ||
100 | skt->socket.pci_irq = gpio_to_irq(colibri_pcmcia_gpio.ready_gpio); | ||
101 | |||
102 | return soc_pcmcia_request_irqs(skt, colibri_irqs, | ||
103 | ARRAY_SIZE(colibri_irqs)); | ||
104 | |||
105 | err7: | ||
106 | gpio_free(colibri_pcmcia_gpio.detect_gpio); | ||
107 | err6: | ||
108 | gpio_free(colibri_pcmcia_gpio.ready_gpio); | ||
109 | err5: | ||
110 | gpio_free(colibri_pcmcia_gpio.bvd1_gpio); | ||
111 | err4: | ||
112 | gpio_free(colibri_pcmcia_gpio.bvd2_gpio); | ||
113 | err3: | ||
114 | gpio_free(colibri_pcmcia_gpio.reset_gpio); | ||
115 | err2: | ||
116 | gpio_free(colibri_pcmcia_gpio.ppen_gpio); | ||
117 | err1: | ||
118 | return ret; | ||
119 | } | ||
120 | |||
121 | static void colibri_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) | ||
122 | { | ||
123 | gpio_free(colibri_pcmcia_gpio.detect_gpio); | ||
124 | gpio_free(colibri_pcmcia_gpio.ready_gpio); | ||
125 | gpio_free(colibri_pcmcia_gpio.bvd1_gpio); | ||
126 | gpio_free(colibri_pcmcia_gpio.bvd2_gpio); | ||
127 | gpio_free(colibri_pcmcia_gpio.reset_gpio); | ||
128 | gpio_free(colibri_pcmcia_gpio.ppen_gpio); | ||
129 | } | ||
130 | |||
131 | static void colibri_pcmcia_socket_state(struct soc_pcmcia_socket *skt, | ||
132 | struct pcmcia_state *state) | ||
133 | { | ||
134 | |||
135 | state->detect = !!gpio_get_value(colibri_pcmcia_gpio.detect_gpio); | ||
136 | state->ready = !!gpio_get_value(colibri_pcmcia_gpio.ready_gpio); | ||
137 | state->bvd1 = !!gpio_get_value(colibri_pcmcia_gpio.bvd1_gpio); | ||
138 | state->bvd2 = !!gpio_get_value(colibri_pcmcia_gpio.bvd2_gpio); | ||
139 | state->wrprot = 0; | ||
140 | state->vs_3v = 1; | ||
141 | state->vs_Xv = 0; | ||
142 | } | ||
143 | |||
144 | static int | ||
145 | colibri_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | ||
146 | const socket_state_t *state) | ||
147 | { | ||
148 | gpio_set_value(colibri_pcmcia_gpio.ppen_gpio, | ||
149 | !(state->Vcc == 33 && state->Vpp < 50)); | ||
150 | gpio_set_value(colibri_pcmcia_gpio.reset_gpio, state->flags & SS_RESET); | ||
151 | return 0; | ||
152 | } | ||
153 | |||
154 | static void colibri_pcmcia_socket_init(struct soc_pcmcia_socket *skt) | ||
155 | { | ||
156 | } | ||
157 | |||
158 | static void colibri_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) | ||
159 | { | ||
160 | } | ||
161 | |||
162 | static struct pcmcia_low_level colibri_pcmcia_ops = { | ||
163 | .owner = THIS_MODULE, | ||
164 | |||
165 | .first = 0, | ||
166 | .nr = 1, | ||
167 | |||
168 | .hw_init = colibri_pcmcia_hw_init, | ||
169 | .hw_shutdown = colibri_pcmcia_hw_shutdown, | ||
170 | |||
171 | .socket_state = colibri_pcmcia_socket_state, | ||
172 | .configure_socket = colibri_pcmcia_configure_socket, | ||
173 | |||
174 | .socket_init = colibri_pcmcia_socket_init, | ||
175 | .socket_suspend = colibri_pcmcia_socket_suspend, | ||
176 | }; | ||
177 | |||
178 | static struct platform_device *colibri_pcmcia_device; | ||
179 | |||
180 | static int __init colibri_pcmcia_init(void) | ||
181 | { | ||
182 | int ret; | ||
183 | |||
184 | colibri_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); | ||
185 | if (!colibri_pcmcia_device) | ||
186 | return -ENOMEM; | ||
187 | |||
188 | /* Colibri PXA270 */ | ||
189 | if (machine_is_colibri()) { | ||
190 | colibri_pcmcia_gpio.reset_gpio = COLIBRI270_RESET_GPIO; | ||
191 | colibri_pcmcia_gpio.ppen_gpio = COLIBRI270_PPEN_GPIO; | ||
192 | colibri_pcmcia_gpio.bvd1_gpio = COLIBRI270_BVD1_GPIO; | ||
193 | colibri_pcmcia_gpio.bvd2_gpio = COLIBRI270_BVD2_GPIO; | ||
194 | colibri_pcmcia_gpio.detect_gpio = COLIBRI270_DETECT_GPIO; | ||
195 | colibri_pcmcia_gpio.ready_gpio = COLIBRI270_READY_GPIO; | ||
196 | /* Colibri PXA320 */ | ||
197 | } else if (machine_is_colibri320()) { | ||
198 | colibri_pcmcia_gpio.reset_gpio = COLIBRI320_RESET_GPIO; | ||
199 | colibri_pcmcia_gpio.ppen_gpio = COLIBRI320_PPEN_GPIO; | ||
200 | colibri_pcmcia_gpio.bvd1_gpio = COLIBRI320_BVD1_GPIO; | ||
201 | colibri_pcmcia_gpio.bvd2_gpio = COLIBRI320_BVD2_GPIO; | ||
202 | colibri_pcmcia_gpio.detect_gpio = COLIBRI320_DETECT_GPIO; | ||
203 | colibri_pcmcia_gpio.ready_gpio = COLIBRI320_READY_GPIO; | ||
204 | } | ||
205 | |||
206 | ret = platform_device_add_data(colibri_pcmcia_device, | ||
207 | &colibri_pcmcia_ops, sizeof(colibri_pcmcia_ops)); | ||
208 | |||
209 | if (!ret) | ||
210 | ret = platform_device_add(colibri_pcmcia_device); | ||
211 | |||
212 | if (ret) | ||
213 | platform_device_put(colibri_pcmcia_device); | ||
214 | |||
215 | return ret; | ||
216 | } | ||
217 | |||
218 | static void __exit colibri_pcmcia_exit(void) | ||
219 | { | ||
220 | platform_device_unregister(colibri_pcmcia_device); | ||
221 | } | ||
222 | |||
223 | module_init(colibri_pcmcia_init); | ||
224 | module_exit(colibri_pcmcia_exit); | ||
225 | |||
226 | MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>"); | ||
227 | MODULE_DESCRIPTION("PCMCIA support for Toradex Colibri PXA270/PXA320"); | ||
228 | MODULE_ALIAS("platform:pxa2xx-pcmcia"); | ||
229 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c index 6b228590b3fd..fb9740d3e9a7 100644 --- a/drivers/pcmcia/sa1100_generic.c +++ b/drivers/pcmcia/sa1100_generic.c | |||
@@ -53,6 +53,9 @@ static int (*sa11x0_pcmcia_hw_init[])(struct device *dev) = { | |||
53 | #if defined(CONFIG_SA1100_H3100) || defined(CONFIG_SA1100_H3600) | 53 | #if defined(CONFIG_SA1100_H3100) || defined(CONFIG_SA1100_H3600) |
54 | pcmcia_h3600_init, | 54 | pcmcia_h3600_init, |
55 | #endif | 55 | #endif |
56 | #ifdef CONFIG_SA1100_NANOENGINE | ||
57 | pcmcia_nanoengine_init, | ||
58 | #endif | ||
56 | #ifdef CONFIG_SA1100_SHANNON | 59 | #ifdef CONFIG_SA1100_SHANNON |
57 | pcmcia_shannon_init, | 60 | pcmcia_shannon_init, |
58 | #endif | 61 | #endif |
diff --git a/drivers/pcmcia/sa1100_generic.h b/drivers/pcmcia/sa1100_generic.h index 794f96a35bba..adb08dbc723f 100644 --- a/drivers/pcmcia/sa1100_generic.h +++ b/drivers/pcmcia/sa1100_generic.h | |||
@@ -13,6 +13,7 @@ extern int pcmcia_freebird_init(struct device *); | |||
13 | extern int pcmcia_gcplus_init(struct device *); | 13 | extern int pcmcia_gcplus_init(struct device *); |
14 | extern int pcmcia_graphicsmaster_init(struct device *); | 14 | extern int pcmcia_graphicsmaster_init(struct device *); |
15 | extern int pcmcia_h3600_init(struct device *); | 15 | extern int pcmcia_h3600_init(struct device *); |
16 | extern int pcmcia_nanoengine_init(struct device *); | ||
16 | extern int pcmcia_pangolin_init(struct device *); | 17 | extern int pcmcia_pangolin_init(struct device *); |
17 | extern int pcmcia_pfs168_init(struct device *); | 18 | extern int pcmcia_pfs168_init(struct device *); |
18 | extern int pcmcia_shannon_init(struct device *); | 19 | extern int pcmcia_shannon_init(struct device *); |
diff --git a/drivers/pcmcia/sa1100_nanoengine.c b/drivers/pcmcia/sa1100_nanoengine.c new file mode 100644 index 000000000000..3d2652e2f5ae --- /dev/null +++ b/drivers/pcmcia/sa1100_nanoengine.c | |||
@@ -0,0 +1,219 @@ | |||
1 | /* | ||
2 | * drivers/pcmcia/sa1100_nanoengine.c | ||
3 | * | ||
4 | * PCMCIA implementation routines for BSI nanoEngine. | ||
5 | * | ||
6 | * In order to have a fully functional pcmcia subsystem in a BSE nanoEngine | ||
7 | * board you should carefully read this: | ||
8 | * http://cambuca.ldhs.cetuc.puc-rio.br/nanoengine/ | ||
9 | * | ||
10 | * Copyright (C) 2010 Marcelo Roberto Jimenez <mroberto@cpti.cetuc.puc-rio.br> | ||
11 | * | ||
12 | * Based on original work for kernel 2.4 by | ||
13 | * Miguel Freitas <miguel@cpti.cetuc.puc-rio.br> | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or modify | ||
16 | * it under the terms of the GNU General Public License version 2 as | ||
17 | * published by the Free Software Foundation. | ||
18 | * | ||
19 | */ | ||
20 | #include <linux/device.h> | ||
21 | #include <linux/errno.h> | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <linux/irq.h> | ||
24 | #include <linux/init.h> | ||
25 | #include <linux/kernel.h> | ||
26 | #include <linux/module.h> | ||
27 | #include <linux/signal.h> | ||
28 | |||
29 | #include <asm/mach-types.h> | ||
30 | #include <asm/irq.h> | ||
31 | |||
32 | #include <mach/hardware.h> | ||
33 | #include <mach/nanoengine.h> | ||
34 | |||
35 | #include "sa1100_generic.h" | ||
36 | |||
37 | static struct pcmcia_irqs irqs_skt0[] = { | ||
38 | /* socket, IRQ, name */ | ||
39 | { 0, NANOENGINE_IRQ_GPIO_PC_CD0, "PC CD0" }, | ||
40 | }; | ||
41 | |||
42 | static struct pcmcia_irqs irqs_skt1[] = { | ||
43 | /* socket, IRQ, name */ | ||
44 | { 1, NANOENGINE_IRQ_GPIO_PC_CD1, "PC CD1" }, | ||
45 | }; | ||
46 | |||
47 | struct nanoengine_pins { | ||
48 | unsigned input_pins; | ||
49 | unsigned output_pins; | ||
50 | unsigned clear_outputs; | ||
51 | unsigned transition_pins; | ||
52 | unsigned pci_irq; | ||
53 | struct pcmcia_irqs *pcmcia_irqs; | ||
54 | unsigned pcmcia_irqs_size; | ||
55 | }; | ||
56 | |||
57 | static struct nanoengine_pins nano_skts[] = { | ||
58 | { | ||
59 | .input_pins = GPIO_PC_READY0 | GPIO_PC_CD0, | ||
60 | .output_pins = GPIO_PC_RESET0, | ||
61 | .clear_outputs = GPIO_PC_RESET0, | ||
62 | .transition_pins = NANOENGINE_IRQ_GPIO_PC_CD0, | ||
63 | .pci_irq = NANOENGINE_IRQ_GPIO_PC_READY0, | ||
64 | .pcmcia_irqs = irqs_skt0, | ||
65 | .pcmcia_irqs_size = ARRAY_SIZE(irqs_skt0) | ||
66 | }, { | ||
67 | .input_pins = GPIO_PC_READY1 | GPIO_PC_CD1, | ||
68 | .output_pins = GPIO_PC_RESET1, | ||
69 | .clear_outputs = GPIO_PC_RESET1, | ||
70 | .transition_pins = NANOENGINE_IRQ_GPIO_PC_CD1, | ||
71 | .pci_irq = NANOENGINE_IRQ_GPIO_PC_READY1, | ||
72 | .pcmcia_irqs = irqs_skt1, | ||
73 | .pcmcia_irqs_size = ARRAY_SIZE(irqs_skt1) | ||
74 | } | ||
75 | }; | ||
76 | |||
77 | unsigned num_nano_pcmcia_sockets = ARRAY_SIZE(nano_skts); | ||
78 | |||
79 | static int nanoengine_pcmcia_hw_init(struct soc_pcmcia_socket *skt) | ||
80 | { | ||
81 | unsigned i = skt->nr; | ||
82 | |||
83 | if (i >= num_nano_pcmcia_sockets) | ||
84 | return -ENXIO; | ||
85 | |||
86 | GPDR &= ~nano_skts[i].input_pins; | ||
87 | GPDR |= nano_skts[i].output_pins; | ||
88 | GPCR = nano_skts[i].clear_outputs; | ||
89 | set_irq_type(nano_skts[i].transition_pins, IRQ_TYPE_EDGE_BOTH); | ||
90 | skt->socket.pci_irq = nano_skts[i].pci_irq; | ||
91 | |||
92 | return soc_pcmcia_request_irqs(skt, | ||
93 | nano_skts[i].pcmcia_irqs, nano_skts[i].pcmcia_irqs_size); | ||
94 | } | ||
95 | |||
96 | /* | ||
97 | * Release all resources. | ||
98 | */ | ||
99 | static void nanoengine_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) | ||
100 | { | ||
101 | unsigned i = skt->nr; | ||
102 | |||
103 | if (i >= num_nano_pcmcia_sockets) | ||
104 | return; | ||
105 | |||
106 | soc_pcmcia_free_irqs(skt, | ||
107 | nano_skts[i].pcmcia_irqs, nano_skts[i].pcmcia_irqs_size); | ||
108 | } | ||
109 | |||
110 | static int nanoengine_pcmcia_configure_socket( | ||
111 | struct soc_pcmcia_socket *skt, const socket_state_t *state) | ||
112 | { | ||
113 | unsigned reset; | ||
114 | unsigned i = skt->nr; | ||
115 | |||
116 | if (i >= num_nano_pcmcia_sockets) | ||
117 | return -ENXIO; | ||
118 | |||
119 | switch (i) { | ||
120 | case 0: | ||
121 | reset = GPIO_PC_RESET0; | ||
122 | break; | ||
123 | case 1: | ||
124 | reset = GPIO_PC_RESET1; | ||
125 | break; | ||
126 | default: | ||
127 | return -ENXIO; | ||
128 | } | ||
129 | |||
130 | if (state->flags & SS_RESET) | ||
131 | GPSR = reset; | ||
132 | else | ||
133 | GPCR = reset; | ||
134 | |||
135 | return 0; | ||
136 | } | ||
137 | |||
138 | static void nanoengine_pcmcia_socket_state( | ||
139 | struct soc_pcmcia_socket *skt, struct pcmcia_state *state) | ||
140 | { | ||
141 | unsigned long levels = GPLR; | ||
142 | unsigned i = skt->nr; | ||
143 | |||
144 | if (i >= num_nano_pcmcia_sockets) | ||
145 | return; | ||
146 | |||
147 | memset(state, 0, sizeof(struct pcmcia_state)); | ||
148 | switch (i) { | ||
149 | case 0: | ||
150 | state->ready = (levels & GPIO_PC_READY0) ? 1 : 0; | ||
151 | state->detect = !(levels & GPIO_PC_CD0) ? 1 : 0; | ||
152 | break; | ||
153 | case 1: | ||
154 | state->ready = (levels & GPIO_PC_READY1) ? 1 : 0; | ||
155 | state->detect = !(levels & GPIO_PC_CD1) ? 1 : 0; | ||
156 | break; | ||
157 | default: | ||
158 | return; | ||
159 | } | ||
160 | state->bvd1 = 1; | ||
161 | state->bvd2 = 1; | ||
162 | state->wrprot = 0; /* Not available */ | ||
163 | state->vs_3v = 1; /* Can only apply 3.3V */ | ||
164 | state->vs_Xv = 0; | ||
165 | } | ||
166 | |||
167 | /* | ||
168 | * Enable card status IRQs on (re-)initialisation. This can | ||
169 | * be called at initialisation, power management event, or | ||
170 | * pcmcia event. | ||
171 | */ | ||
172 | static void nanoengine_pcmcia_socket_init(struct soc_pcmcia_socket *skt) | ||
173 | { | ||
174 | unsigned i = skt->nr; | ||
175 | |||
176 | if (i >= num_nano_pcmcia_sockets) | ||
177 | return; | ||
178 | |||
179 | soc_pcmcia_enable_irqs(skt, | ||
180 | nano_skts[i].pcmcia_irqs, nano_skts[i].pcmcia_irqs_size); | ||
181 | } | ||
182 | |||
183 | /* | ||
184 | * Disable card status IRQs on suspend. | ||
185 | */ | ||
186 | static void nanoengine_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) | ||
187 | { | ||
188 | unsigned i = skt->nr; | ||
189 | |||
190 | if (i >= num_nano_pcmcia_sockets) | ||
191 | return; | ||
192 | |||
193 | soc_pcmcia_disable_irqs(skt, | ||
194 | nano_skts[i].pcmcia_irqs, nano_skts[i].pcmcia_irqs_size); | ||
195 | } | ||
196 | |||
197 | static struct pcmcia_low_level nanoengine_pcmcia_ops = { | ||
198 | .owner = THIS_MODULE, | ||
199 | |||
200 | .hw_init = nanoengine_pcmcia_hw_init, | ||
201 | .hw_shutdown = nanoengine_pcmcia_hw_shutdown, | ||
202 | |||
203 | .configure_socket = nanoengine_pcmcia_configure_socket, | ||
204 | .socket_state = nanoengine_pcmcia_socket_state, | ||
205 | .socket_init = nanoengine_pcmcia_socket_init, | ||
206 | .socket_suspend = nanoengine_pcmcia_socket_suspend, | ||
207 | }; | ||
208 | |||
209 | int pcmcia_nanoengine_init(struct device *dev) | ||
210 | { | ||
211 | int ret = -ENODEV; | ||
212 | |||
213 | if (machine_is_nanoengine()) | ||
214 | ret = sa11xx_drv_pcmcia_probe( | ||
215 | dev, &nanoengine_pcmcia_ops, 0, 2); | ||
216 | |||
217 | return ret; | ||
218 | } | ||
219 | |||
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c index 2fe8cb8e95cd..5a9a392eacdf 100644 --- a/drivers/pcmcia/soc_common.c +++ b/drivers/pcmcia/soc_common.c | |||
@@ -31,20 +31,20 @@ | |||
31 | ======================================================================*/ | 31 | ======================================================================*/ |
32 | 32 | ||
33 | 33 | ||
34 | #include <linux/module.h> | 34 | #include <linux/cpufreq.h> |
35 | #include <linux/moduleparam.h> | ||
36 | #include <linux/init.h> | 35 | #include <linux/init.h> |
36 | #include <linux/interrupt.h> | ||
37 | #include <linux/io.h> | ||
38 | #include <linux/irq.h> | ||
37 | #include <linux/kernel.h> | 39 | #include <linux/kernel.h> |
38 | #include <linux/timer.h> | ||
39 | #include <linux/mm.h> | 40 | #include <linux/mm.h> |
41 | #include <linux/module.h> | ||
42 | #include <linux/moduleparam.h> | ||
40 | #include <linux/mutex.h> | 43 | #include <linux/mutex.h> |
41 | #include <linux/interrupt.h> | ||
42 | #include <linux/irq.h> | ||
43 | #include <linux/spinlock.h> | 44 | #include <linux/spinlock.h> |
44 | #include <linux/cpufreq.h> | 45 | #include <linux/timer.h> |
45 | 46 | ||
46 | #include <mach/hardware.h> | 47 | #include <mach/hardware.h> |
47 | #include <asm/io.h> | ||
48 | #include <asm/system.h> | 48 | #include <asm/system.h> |
49 | 49 | ||
50 | #include "soc_common.h" | 50 | #include "soc_common.h" |
@@ -74,7 +74,8 @@ EXPORT_SYMBOL(soc_pcmcia_debug); | |||
74 | 74 | ||
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | #define to_soc_pcmcia_socket(x) container_of(x, struct soc_pcmcia_socket, socket) | 77 | #define to_soc_pcmcia_socket(x) \ |
78 | container_of(x, struct soc_pcmcia_socket, socket) | ||
78 | 79 | ||
79 | static unsigned short | 80 | static unsigned short |
80 | calc_speed(unsigned short *spds, int num, unsigned short dflt) | 81 | calc_speed(unsigned short *spds, int num, unsigned short dflt) |
@@ -91,11 +92,15 @@ calc_speed(unsigned short *spds, int num, unsigned short dflt) | |||
91 | return speed; | 92 | return speed; |
92 | } | 93 | } |
93 | 94 | ||
94 | void soc_common_pcmcia_get_timing(struct soc_pcmcia_socket *skt, struct soc_pcmcia_timing *timing) | 95 | void soc_common_pcmcia_get_timing(struct soc_pcmcia_socket *skt, |
96 | struct soc_pcmcia_timing *timing) | ||
95 | { | 97 | { |
96 | timing->io = calc_speed(skt->spd_io, MAX_IO_WIN, SOC_PCMCIA_IO_ACCESS); | 98 | timing->io = |
97 | timing->mem = calc_speed(skt->spd_mem, MAX_WIN, SOC_PCMCIA_3V_MEM_ACCESS); | 99 | calc_speed(skt->spd_io, MAX_IO_WIN, SOC_PCMCIA_IO_ACCESS); |
98 | timing->attr = calc_speed(skt->spd_attr, MAX_WIN, SOC_PCMCIA_3V_MEM_ACCESS); | 100 | timing->mem = |
101 | calc_speed(skt->spd_mem, MAX_WIN, SOC_PCMCIA_3V_MEM_ACCESS); | ||
102 | timing->attr = | ||
103 | calc_speed(skt->spd_attr, MAX_WIN, SOC_PCMCIA_3V_MEM_ACCESS); | ||
99 | } | 104 | } |
100 | EXPORT_SYMBOL(soc_common_pcmcia_get_timing); | 105 | EXPORT_SYMBOL(soc_common_pcmcia_get_timing); |
101 | 106 | ||
@@ -137,8 +142,8 @@ static unsigned int soc_common_pcmcia_skt_state(struct soc_pcmcia_socket *skt) | |||
137 | * | 142 | * |
138 | * Convert PCMCIA socket state to our socket configure structure. | 143 | * Convert PCMCIA socket state to our socket configure structure. |
139 | */ | 144 | */ |
140 | static int | 145 | static int soc_common_pcmcia_config_skt( |
141 | soc_common_pcmcia_config_skt(struct soc_pcmcia_socket *skt, socket_state_t *state) | 146 | struct soc_pcmcia_socket *skt, socket_state_t *state) |
142 | { | 147 | { |
143 | int ret; | 148 | int ret; |
144 | 149 | ||
@@ -150,7 +155,8 @@ soc_common_pcmcia_config_skt(struct soc_pcmcia_socket *skt, socket_state_t *stat | |||
150 | */ | 155 | */ |
151 | if (skt->irq_state != 1 && state->io_irq) { | 156 | if (skt->irq_state != 1 && state->io_irq) { |
152 | skt->irq_state = 1; | 157 | skt->irq_state = 1; |
153 | set_irq_type(skt->socket.pci_irq, IRQ_TYPE_EDGE_FALLING); | 158 | set_irq_type(skt->socket.pci_irq, |
159 | IRQ_TYPE_EDGE_FALLING); | ||
154 | } else if (skt->irq_state == 1 && state->io_irq == 0) { | 160 | } else if (skt->irq_state == 1 && state->io_irq == 0) { |
155 | skt->irq_state = 0; | 161 | skt->irq_state = 0; |
156 | set_irq_type(skt->socket.pci_irq, IRQ_TYPE_NONE); | 162 | set_irq_type(skt->socket.pci_irq, IRQ_TYPE_NONE); |
@@ -304,24 +310,24 @@ soc_common_pcmcia_get_status(struct pcmcia_socket *sock, unsigned int *status) | |||
304 | * of power configuration, reset, &c. We also record the value of | 310 | * of power configuration, reset, &c. We also record the value of |
305 | * `state' in order to regurgitate it to the PCMCIA core later. | 311 | * `state' in order to regurgitate it to the PCMCIA core later. |
306 | */ | 312 | */ |
307 | static int | 313 | static int soc_common_pcmcia_set_socket( |
308 | soc_common_pcmcia_set_socket(struct pcmcia_socket *sock, socket_state_t *state) | 314 | struct pcmcia_socket *sock, socket_state_t *state) |
309 | { | 315 | { |
310 | struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock); | 316 | struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock); |
311 | 317 | ||
312 | debug(skt, 2, "mask: %s%s%s%s%s%sflags: %s%s%s%s%s%sVcc %d Vpp %d irq %d\n", | 318 | debug(skt, 2, "mask: %s%s%s%s%s%s flags: %s%s%s%s%s%s Vcc %d Vpp %d irq %d\n", |
313 | (state->csc_mask==0)?"<NONE> ":"", | 319 | (state->csc_mask == 0) ? "<NONE> " : "", |
314 | (state->csc_mask&SS_DETECT)?"DETECT ":"", | 320 | (state->csc_mask & SS_DETECT) ? "DETECT " : "", |
315 | (state->csc_mask&SS_READY)?"READY ":"", | 321 | (state->csc_mask & SS_READY) ? "READY " : "", |
316 | (state->csc_mask&SS_BATDEAD)?"BATDEAD ":"", | 322 | (state->csc_mask & SS_BATDEAD) ? "BATDEAD " : "", |
317 | (state->csc_mask&SS_BATWARN)?"BATWARN ":"", | 323 | (state->csc_mask & SS_BATWARN) ? "BATWARN " : "", |
318 | (state->csc_mask&SS_STSCHG)?"STSCHG ":"", | 324 | (state->csc_mask & SS_STSCHG) ? "STSCHG " : "", |
319 | (state->flags==0)?"<NONE> ":"", | 325 | (state->flags == 0) ? "<NONE> " : "", |
320 | (state->flags&SS_PWR_AUTO)?"PWR_AUTO ":"", | 326 | (state->flags & SS_PWR_AUTO) ? "PWR_AUTO " : "", |
321 | (state->flags&SS_IOCARD)?"IOCARD ":"", | 327 | (state->flags & SS_IOCARD) ? "IOCARD " : "", |
322 | (state->flags&SS_RESET)?"RESET ":"", | 328 | (state->flags & SS_RESET) ? "RESET " : "", |
323 | (state->flags&SS_SPKR_ENA)?"SPKR_ENA ":"", | 329 | (state->flags & SS_SPKR_ENA) ? "SPKR_ENA " : "", |
324 | (state->flags&SS_OUTPUT_ENA)?"OUTPUT_ENA ":"", | 330 | (state->flags & SS_OUTPUT_ENA) ? "OUTPUT_ENA " : "", |
325 | state->Vcc, state->Vpp, state->io_irq); | 331 | state->Vcc, state->Vpp, state->io_irq); |
326 | 332 | ||
327 | return soc_common_pcmcia_config_skt(skt, state); | 333 | return soc_common_pcmcia_config_skt(skt, state); |
@@ -336,8 +342,8 @@ soc_common_pcmcia_set_socket(struct pcmcia_socket *sock, socket_state_t *state) | |||
336 | * | 342 | * |
337 | * Returns: 0 on success, -1 on error | 343 | * Returns: 0 on success, -1 on error |
338 | */ | 344 | */ |
339 | static int | 345 | static int soc_common_pcmcia_set_io_map( |
340 | soc_common_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *map) | 346 | struct pcmcia_socket *sock, struct pccard_io_map *map) |
341 | { | 347 | { |
342 | struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock); | 348 | struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock); |
343 | unsigned short speed = map->speed; | 349 | unsigned short speed = map->speed; |
@@ -346,14 +352,14 @@ soc_common_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *m | |||
346 | map->map, map->speed, (unsigned long long)map->start, | 352 | map->map, map->speed, (unsigned long long)map->start, |
347 | (unsigned long long)map->stop); | 353 | (unsigned long long)map->stop); |
348 | debug(skt, 2, "flags: %s%s%s%s%s%s%s%s\n", | 354 | debug(skt, 2, "flags: %s%s%s%s%s%s%s%s\n", |
349 | (map->flags==0)?"<NONE>":"", | 355 | (map->flags == 0) ? "<NONE>" : "", |
350 | (map->flags&MAP_ACTIVE)?"ACTIVE ":"", | 356 | (map->flags & MAP_ACTIVE) ? "ACTIVE " : "", |
351 | (map->flags&MAP_16BIT)?"16BIT ":"", | 357 | (map->flags & MAP_16BIT) ? "16BIT " : "", |
352 | (map->flags&MAP_AUTOSZ)?"AUTOSZ ":"", | 358 | (map->flags & MAP_AUTOSZ) ? "AUTOSZ " : "", |
353 | (map->flags&MAP_0WS)?"0WS ":"", | 359 | (map->flags & MAP_0WS) ? "0WS " : "", |
354 | (map->flags&MAP_WRPROT)?"WRPROT ":"", | 360 | (map->flags & MAP_WRPROT) ? "WRPROT " : "", |
355 | (map->flags&MAP_USE_WAIT)?"USE_WAIT ":"", | 361 | (map->flags & MAP_USE_WAIT) ? "USE_WAIT " : "", |
356 | (map->flags&MAP_PREFETCH)?"PREFETCH ":""); | 362 | (map->flags & MAP_PREFETCH) ? "PREFETCH " : ""); |
357 | 363 | ||
358 | if (map->map >= MAX_IO_WIN) { | 364 | if (map->map >= MAX_IO_WIN) { |
359 | printk(KERN_ERR "%s(): map (%d) out of range\n", __func__, | 365 | printk(KERN_ERR "%s(): map (%d) out of range\n", __func__, |
@@ -390,8 +396,8 @@ soc_common_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *m | |||
390 | * | 396 | * |
391 | * Returns: 0 on success, -ERRNO on error | 397 | * Returns: 0 on success, -ERRNO on error |
392 | */ | 398 | */ |
393 | static int | 399 | static int soc_common_pcmcia_set_mem_map( |
394 | soc_common_pcmcia_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *map) | 400 | struct pcmcia_socket *sock, struct pccard_mem_map *map) |
395 | { | 401 | { |
396 | struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock); | 402 | struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock); |
397 | struct resource *res; | 403 | struct resource *res; |
@@ -400,14 +406,14 @@ soc_common_pcmcia_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map | |||
400 | debug(skt, 2, "map %u speed %u card_start %08x\n", | 406 | debug(skt, 2, "map %u speed %u card_start %08x\n", |
401 | map->map, map->speed, map->card_start); | 407 | map->map, map->speed, map->card_start); |
402 | debug(skt, 2, "flags: %s%s%s%s%s%s%s%s\n", | 408 | debug(skt, 2, "flags: %s%s%s%s%s%s%s%s\n", |
403 | (map->flags==0)?"<NONE>":"", | 409 | (map->flags == 0) ? "<NONE>" : "", |
404 | (map->flags&MAP_ACTIVE)?"ACTIVE ":"", | 410 | (map->flags & MAP_ACTIVE) ? "ACTIVE " : "", |
405 | (map->flags&MAP_16BIT)?"16BIT ":"", | 411 | (map->flags & MAP_16BIT) ? "16BIT " : "", |
406 | (map->flags&MAP_AUTOSZ)?"AUTOSZ ":"", | 412 | (map->flags & MAP_AUTOSZ) ? "AUTOSZ " : "", |
407 | (map->flags&MAP_0WS)?"0WS ":"", | 413 | (map->flags & MAP_0WS) ? "0WS " : "", |
408 | (map->flags&MAP_WRPROT)?"WRPROT ":"", | 414 | (map->flags & MAP_WRPROT) ? "WRPROT " : "", |
409 | (map->flags&MAP_ATTRIB)?"ATTRIB ":"", | 415 | (map->flags & MAP_ATTRIB) ? "ATTRIB " : "", |
410 | (map->flags&MAP_USE_WAIT)?"USE_WAIT ":""); | 416 | (map->flags & MAP_USE_WAIT) ? "USE_WAIT " : ""); |
411 | 417 | ||
412 | if (map->map >= MAX_WIN) | 418 | if (map->map >= MAX_WIN) |
413 | return -EINVAL; | 419 | return -EINVAL; |
@@ -462,8 +468,8 @@ static struct bittbl conf_bits[] = { | |||
462 | { SS_OUTPUT_ENA, "SS_OUTPUT_ENA" }, | 468 | { SS_OUTPUT_ENA, "SS_OUTPUT_ENA" }, |
463 | }; | 469 | }; |
464 | 470 | ||
465 | static void | 471 | static void dump_bits(char **p, const char *prefix, |
466 | dump_bits(char **p, const char *prefix, unsigned int val, struct bittbl *bits, int sz) | 472 | unsigned int val, struct bittbl *bits, int sz) |
467 | { | 473 | { |
468 | char *b = *p; | 474 | char *b = *p; |
469 | int i; | 475 | int i; |
@@ -481,13 +487,14 @@ dump_bits(char **p, const char *prefix, unsigned int val, struct bittbl *bits, i | |||
481 | * | 487 | * |
482 | * Returns: the number of characters added to the buffer | 488 | * Returns: the number of characters added to the buffer |
483 | */ | 489 | */ |
484 | static ssize_t show_status(struct device *dev, struct device_attribute *attr, char *buf) | 490 | static ssize_t show_status( |
491 | struct device *dev, struct device_attribute *attr, char *buf) | ||
485 | { | 492 | { |
486 | struct soc_pcmcia_socket *skt = | 493 | struct soc_pcmcia_socket *skt = |
487 | container_of(dev, struct soc_pcmcia_socket, socket.dev); | 494 | container_of(dev, struct soc_pcmcia_socket, socket.dev); |
488 | char *p = buf; | 495 | char *p = buf; |
489 | 496 | ||
490 | p+=sprintf(p, "slot : %d\n", skt->nr); | 497 | p += sprintf(p, "slot : %d\n", skt->nr); |
491 | 498 | ||
492 | dump_bits(&p, "status", skt->status, | 499 | dump_bits(&p, "status", skt->status, |
493 | status_bits, ARRAY_SIZE(status_bits)); | 500 | status_bits, ARRAY_SIZE(status_bits)); |
@@ -496,12 +503,12 @@ static ssize_t show_status(struct device *dev, struct device_attribute *attr, ch | |||
496 | dump_bits(&p, "cs_flags", skt->cs_state.flags, | 503 | dump_bits(&p, "cs_flags", skt->cs_state.flags, |
497 | conf_bits, ARRAY_SIZE(conf_bits)); | 504 | conf_bits, ARRAY_SIZE(conf_bits)); |
498 | 505 | ||
499 | p+=sprintf(p, "Vcc : %d\n", skt->cs_state.Vcc); | 506 | p += sprintf(p, "Vcc : %d\n", skt->cs_state.Vcc); |
500 | p+=sprintf(p, "Vpp : %d\n", skt->cs_state.Vpp); | 507 | p += sprintf(p, "Vpp : %d\n", skt->cs_state.Vpp); |
501 | p+=sprintf(p, "IRQ : %d (%d)\n", skt->cs_state.io_irq, | 508 | p += sprintf(p, "IRQ : %d (%d)\n", skt->cs_state.io_irq, |
502 | skt->socket.pci_irq); | 509 | skt->socket.pci_irq); |
503 | if (skt->ops->show_timing) | 510 | if (skt->ops->show_timing) |
504 | p+=skt->ops->show_timing(skt, p); | 511 | p += skt->ops->show_timing(skt, p); |
505 | 512 | ||
506 | return p-buf; | 513 | return p-buf; |
507 | } | 514 | } |
@@ -594,7 +601,7 @@ soc_pcmcia_notifier(struct notifier_block *nb, unsigned long val, void *data) | |||
594 | 601 | ||
595 | mutex_lock(&soc_pcmcia_sockets_lock); | 602 | mutex_lock(&soc_pcmcia_sockets_lock); |
596 | list_for_each_entry(skt, &soc_pcmcia_sockets, node) | 603 | list_for_each_entry(skt, &soc_pcmcia_sockets, node) |
597 | if ( skt->ops->frequency_change ) | 604 | if (skt->ops->frequency_change) |
598 | ret += skt->ops->frequency_change(skt, val, freqs); | 605 | ret += skt->ops->frequency_change(skt, val, freqs); |
599 | mutex_unlock(&soc_pcmcia_sockets_lock); | 606 | mutex_unlock(&soc_pcmcia_sockets_lock); |
600 | 607 | ||
@@ -620,7 +627,8 @@ fs_initcall(soc_pcmcia_cpufreq_register); | |||
620 | 627 | ||
621 | static void soc_pcmcia_cpufreq_unregister(void) | 628 | static void soc_pcmcia_cpufreq_unregister(void) |
622 | { | 629 | { |
623 | cpufreq_unregister_notifier(&soc_pcmcia_notifier_block, CPUFREQ_TRANSITION_NOTIFIER); | 630 | cpufreq_unregister_notifier(&soc_pcmcia_notifier_block, |
631 | CPUFREQ_TRANSITION_NOTIFIER); | ||
624 | } | 632 | } |
625 | module_exit(soc_pcmcia_cpufreq_unregister); | 633 | module_exit(soc_pcmcia_cpufreq_unregister); |
626 | 634 | ||
diff --git a/drivers/pcmcia/soc_common.h b/drivers/pcmcia/soc_common.h index bbcd5385a221..9daa73615c8b 100644 --- a/drivers/pcmcia/soc_common.h +++ b/drivers/pcmcia/soc_common.h | |||
@@ -10,6 +10,7 @@ | |||
10 | #define _ASM_ARCH_PCMCIA | 10 | #define _ASM_ARCH_PCMCIA |
11 | 11 | ||
12 | /* include the world */ | 12 | /* include the world */ |
13 | #include <linux/clk.h> | ||
13 | #include <linux/cpufreq.h> | 14 | #include <linux/cpufreq.h> |
14 | #include <pcmcia/ss.h> | 15 | #include <pcmcia/ss.h> |
15 | #include <pcmcia/cistpl.h> | 16 | #include <pcmcia/cistpl.h> |
@@ -29,6 +30,7 @@ struct soc_pcmcia_socket { | |||
29 | * Info from low level handler | 30 | * Info from low level handler |
30 | */ | 31 | */ |
31 | unsigned int nr; | 32 | unsigned int nr; |
33 | struct clk *clk; | ||
32 | 34 | ||
33 | /* | 35 | /* |
34 | * Core PCMCIA state | 36 | * Core PCMCIA state |
@@ -56,6 +58,7 @@ struct soc_pcmcia_socket { | |||
56 | 58 | ||
57 | struct skt_dev_info { | 59 | struct skt_dev_info { |
58 | int nskt; | 60 | int nskt; |
61 | struct clk *clk; | ||
59 | struct soc_pcmcia_socket skt[0]; | 62 | struct soc_pcmcia_socket skt[0]; |
60 | }; | 63 | }; |
61 | 64 | ||