aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2008-07-13 07:05:49 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-07-13 07:05:49 -0400
commit044e5f45e4ad890d03bd1e8bb44c634397cac24d (patch)
treea6063f77bd719d933823915d2273eaadb6331611 /drivers/pcmcia
parentf0006314d37639714da9658cf4ff3f1f9f420764 (diff)
parentfaf64ed4968e354624f330c6da6c1ce8b05a0713 (diff)
Merge branch 'pxa' into devel
Conflicts: arch/arm/configs/em_x270_defconfig arch/arm/configs/xm_x270_defconfig
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r--drivers/pcmcia/Kconfig3
-rw-r--r--drivers/pcmcia/Makefile1
-rw-r--r--drivers/pcmcia/pxa2xx_cm_x270.c108
-rw-r--r--drivers/pcmcia/pxa2xx_mainstone.c13
-rw-r--r--drivers/pcmcia/pxa2xx_palmtx.c118
-rw-r--r--drivers/pcmcia/pxa2xx_sharpsl.c12
6 files changed, 175 insertions, 80 deletions
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index 1b0eb5aaf650..86dd324c8ce0 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -219,7 +219,8 @@ config PCMCIA_SA1111
219config PCMCIA_PXA2XX 219config 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 || MACH_ARMCORE 222 depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \
223 || MACH_ARMCORE || ARCH_PXA_PALM)
223 help 224 help
224 Say Y here to include support for the PXA2xx PCMCIA controller 225 Say Y here to include support for the PXA2xx PCMCIA controller
225 226
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index 6f6478ba7174..8e6dd22e9300 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -71,4 +71,5 @@ pxa2xx_cs-$(CONFIG_ARCH_LUBBOCK) += pxa2xx_lubbock.o sa1111_generic.o
71pxa2xx_cs-$(CONFIG_MACH_MAINSTONE) += pxa2xx_mainstone.o 71pxa2xx_cs-$(CONFIG_MACH_MAINSTONE) += pxa2xx_mainstone.o
72pxa2xx_cs-$(CONFIG_PXA_SHARPSL) += pxa2xx_sharpsl.o 72pxa2xx_cs-$(CONFIG_PXA_SHARPSL) += pxa2xx_sharpsl.o
73pxa2xx_cs-$(CONFIG_MACH_ARMCORE) += pxa2xx_cm_x270.o 73pxa2xx_cs-$(CONFIG_MACH_ARMCORE) += pxa2xx_cm_x270.o
74pxa2xx_cs-$(CONFIG_MACH_PALMTX) += pxa2xx_palmtx.o
74 75
diff --git a/drivers/pcmcia/pxa2xx_cm_x270.c b/drivers/pcmcia/pxa2xx_cm_x270.c
index e7ab060ff118..bb95db7d2b76 100644
--- a/drivers/pcmcia/pxa2xx_cm_x270.c
+++ b/drivers/pcmcia/pxa2xx_cm_x270.c
@@ -5,82 +5,60 @@
5 * it under the terms of the GNU General Public License version 2 as 5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation. 6 * published by the Free Software Foundation.
7 * 7 *
8 * Compulab Ltd., 2003, 2007 8 * Compulab Ltd., 2003, 2007, 2008
9 * Mike Rapoport <mike@compulab.co.il> 9 * Mike Rapoport <mike@compulab.co.il>
10 * 10 *
11 */ 11 */
12 12
13#include <linux/kernel.h>
14#include <linux/sched.h>
15#include <linux/platform_device.h> 13#include <linux/platform_device.h>
16#include <linux/irq.h> 14#include <linux/irq.h>
17#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/gpio.h>
18 17
19#include <pcmcia/ss.h> 18#include <asm/mach-types.h>
20#include <asm/hardware.h>
21
22#include <asm/arch/pxa-regs.h> 19#include <asm/arch/pxa-regs.h>
23#include <asm/arch/pxa2xx-gpio.h>
24#include <asm/arch/cm-x270.h>
25 20
26#include "soc_common.h" 21#include "soc_common.h"
27 22
23#define GPIO_PCMCIA_S0_CD_VALID (84)
24#define GPIO_PCMCIA_S0_RDYINT (82)
25#define GPIO_PCMCIA_RESET (53)
26
27#define PCMCIA_S0_CD_VALID IRQ_GPIO(GPIO_PCMCIA_S0_CD_VALID)
28#define PCMCIA_S0_RDYINT IRQ_GPIO(GPIO_PCMCIA_S0_RDYINT)
29
30
28static struct pcmcia_irqs irqs[] = { 31static struct pcmcia_irqs irqs[] = {
29 { 0, PCMCIA_S0_CD_VALID, "PCMCIA0 CD" }, 32 { 0, PCMCIA_S0_CD_VALID, "PCMCIA0 CD" },
30 { 1, PCMCIA_S1_CD_VALID, "PCMCIA1 CD" },
31}; 33};
32 34
33static int cmx270_pcmcia_hw_init(struct soc_pcmcia_socket *skt) 35static int cmx270_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
34{ 36{
35 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) | 37 int ret = gpio_request(GPIO_PCMCIA_RESET, "PCCard reset");
36 GPIO_bit(GPIO49_nPWE) | 38 if (ret)
37 GPIO_bit(GPIO50_nPIOR) | 39 return ret;
38 GPIO_bit(GPIO51_nPIOW) | 40 gpio_direction_output(GPIO_PCMCIA_RESET, 0);
39 GPIO_bit(GPIO85_nPCE_1) | 41
40 GPIO_bit(GPIO54_nPCE_2); 42 skt->irq = PCMCIA_S0_RDYINT;
41 43 ret = soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
42 pxa_gpio_mode(GPIO48_nPOE_MD); 44 if (!ret)
43 pxa_gpio_mode(GPIO49_nPWE_MD); 45 gpio_free(GPIO_PCMCIA_RESET);
44 pxa_gpio_mode(GPIO50_nPIOR_MD); 46
45 pxa_gpio_mode(GPIO51_nPIOW_MD); 47 return ret;
46 pxa_gpio_mode(GPIO85_nPCE_1_MD);
47 pxa_gpio_mode(GPIO54_nPCE_2_MD);
48 pxa_gpio_mode(GPIO55_nPREG_MD);
49 pxa_gpio_mode(GPIO56_nPWAIT_MD);
50 pxa_gpio_mode(GPIO57_nIOIS16_MD);
51
52 /* Reset signal */
53 pxa_gpio_mode(GPIO53_nPCE_2 | GPIO_OUT);
54 GPCR(GPIO53_nPCE_2) = GPIO_bit(GPIO53_nPCE_2);
55
56 set_irq_type(PCMCIA_S0_CD_VALID, IRQ_TYPE_EDGE_BOTH);
57 set_irq_type(PCMCIA_S1_CD_VALID, IRQ_TYPE_EDGE_BOTH);
58
59 /* irq's for slots: */
60 set_irq_type(PCMCIA_S0_RDYINT, IRQ_TYPE_EDGE_FALLING);
61 set_irq_type(PCMCIA_S1_RDYINT, IRQ_TYPE_EDGE_FALLING);
62
63 skt->irq = (skt->nr == 0) ? PCMCIA_S0_RDYINT : PCMCIA_S1_RDYINT;
64 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
65} 48}
66 49
67static void cmx270_pcmcia_shutdown(struct soc_pcmcia_socket *skt) 50static void cmx270_pcmcia_shutdown(struct soc_pcmcia_socket *skt)
68{ 51{
69 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs)); 52 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
70 53 gpio_free(GPIO_PCMCIA_RESET);
71 set_irq_type(IRQ_TO_GPIO(PCMCIA_S0_CD_VALID), IRQ_TYPE_NONE);
72 set_irq_type(IRQ_TO_GPIO(PCMCIA_S1_CD_VALID), IRQ_TYPE_NONE);
73
74 set_irq_type(IRQ_TO_GPIO(PCMCIA_S0_RDYINT), IRQ_TYPE_NONE);
75 set_irq_type(IRQ_TO_GPIO(PCMCIA_S1_RDYINT), IRQ_TYPE_NONE);
76} 54}
77 55
78 56
79static void cmx270_pcmcia_socket_state(struct soc_pcmcia_socket *skt, 57static void cmx270_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
80 struct pcmcia_state *state) 58 struct pcmcia_state *state)
81{ 59{
82 state->detect = (PCC_DETECT(skt->nr) == 0) ? 1 : 0; 60 state->detect = (gpio_get_value(GPIO_PCMCIA_S0_CD_VALID) == 0) ? 1 : 0;
83 state->ready = (PCC_READY(skt->nr) == 0) ? 0 : 1; 61 state->ready = (gpio_get_value(GPIO_PCMCIA_S0_RDYINT) == 0) ? 0 : 1;
84 state->bvd1 = 1; 62 state->bvd1 = 1;
85 state->bvd2 = 1; 63 state->bvd2 = 1;
86 state->vs_3v = 0; 64 state->vs_3v = 0;
@@ -92,32 +70,16 @@ static void cmx270_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
92static int cmx270_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, 70static int cmx270_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
93 const socket_state_t *state) 71 const socket_state_t *state)
94{ 72{
95 GPSR(GPIO49_nPWE) = GPIO_bit(GPIO49_nPWE);
96 pxa_gpio_mode(GPIO49_nPWE | GPIO_OUT);
97
98 switch (skt->nr) { 73 switch (skt->nr) {
99 case 0: 74 case 0:
100 if (state->flags & SS_RESET) { 75 if (state->flags & SS_RESET) {
101 GPCR(GPIO49_nPWE) = GPIO_bit(GPIO49_nPWE); 76 gpio_set_value(GPIO_PCMCIA_RESET, 1);
102 GPSR(GPIO53_nPCE_2) = GPIO_bit(GPIO53_nPCE_2);
103 udelay(10); 77 udelay(10);
104 GPCR(GPIO53_nPCE_2) = GPIO_bit(GPIO53_nPCE_2); 78 gpio_set_value(GPIO_PCMCIA_RESET, 0);
105 GPSR(GPIO49_nPWE) = GPIO_bit(GPIO49_nPWE);
106 }
107 break;
108 case 1:
109 if (state->flags & SS_RESET) {
110 GPCR(GPIO49_nPWE) = GPIO_bit(GPIO49_nPWE);
111 GPSR(GPIO53_nPCE_2) = GPIO_bit(GPIO53_nPCE_2);
112 udelay(10);
113 GPCR(GPIO53_nPCE_2) = GPIO_bit(GPIO53_nPCE_2);
114 GPSR(GPIO49_nPWE) = GPIO_bit(GPIO49_nPWE);
115 } 79 }
116 break; 80 break;
117 } 81 }
118 82
119 pxa_gpio_mode(GPIO49_nPWE_MD);
120
121 return 0; 83 return 0;
122} 84}
123 85
@@ -130,7 +92,7 @@ static void cmx270_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
130} 92}
131 93
132 94
133static struct pcmcia_low_level cmx270_pcmcia_ops = { 95static struct pcmcia_low_level cmx270_pcmcia_ops __initdata = {
134 .owner = THIS_MODULE, 96 .owner = THIS_MODULE,
135 .hw_init = cmx270_pcmcia_hw_init, 97 .hw_init = cmx270_pcmcia_hw_init,
136 .hw_shutdown = cmx270_pcmcia_shutdown, 98 .hw_shutdown = cmx270_pcmcia_shutdown,
@@ -138,7 +100,7 @@ static struct pcmcia_low_level cmx270_pcmcia_ops = {
138 .configure_socket = cmx270_pcmcia_configure_socket, 100 .configure_socket = cmx270_pcmcia_configure_socket,
139 .socket_init = cmx270_pcmcia_socket_init, 101 .socket_init = cmx270_pcmcia_socket_init,
140 .socket_suspend = cmx270_pcmcia_socket_suspend, 102 .socket_suspend = cmx270_pcmcia_socket_suspend,
141 .nr = 2, 103 .nr = 1,
142}; 104};
143 105
144static struct platform_device *cmx270_pcmcia_device; 106static struct platform_device *cmx270_pcmcia_device;
@@ -147,15 +109,21 @@ static int __init cmx270_pcmcia_init(void)
147{ 109{
148 int ret; 110 int ret;
149 111
112 if (!machine_is_armcore())
113 return -ENODEV;
114
150 cmx270_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); 115 cmx270_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
151 116
152 if (!cmx270_pcmcia_device) 117 if (!cmx270_pcmcia_device)
153 return -ENOMEM; 118 return -ENOMEM;
154 119
155 cmx270_pcmcia_device->dev.platform_data = &cmx270_pcmcia_ops; 120 ret = platform_device_add_data(cmx270_pcmcia_device, &cmx270_pcmcia_ops,
121 sizeof(cmx270_pcmcia_ops));
156 122
157 printk(KERN_INFO "Registering cm-x270 PCMCIA interface.\n"); 123 if (ret == 0) {
158 ret = platform_device_add(cmx270_pcmcia_device); 124 printk(KERN_INFO "Registering cm-x270 PCMCIA interface.\n");
125 ret = platform_device_add(cmx270_pcmcia_device);
126 }
159 127
160 if (ret) 128 if (ret)
161 platform_device_put(cmx270_pcmcia_device); 129 platform_device_put(cmx270_pcmcia_device);
diff --git a/drivers/pcmcia/pxa2xx_mainstone.c b/drivers/pcmcia/pxa2xx_mainstone.c
index 145b85e0f02c..92d1cc33808c 100644
--- a/drivers/pcmcia/pxa2xx_mainstone.c
+++ b/drivers/pcmcia/pxa2xx_mainstone.c
@@ -22,6 +22,7 @@
22#include <pcmcia/ss.h> 22#include <pcmcia/ss.h>
23 23
24#include <asm/hardware.h> 24#include <asm/hardware.h>
25#include <asm/mach-types.h>
25#include <asm/irq.h> 26#include <asm/irq.h>
26 27
27#include <asm/arch/pxa-regs.h> 28#include <asm/arch/pxa-regs.h>
@@ -136,7 +137,7 @@ static void mst_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
136{ 137{
137} 138}
138 139
139static struct pcmcia_low_level mst_pcmcia_ops = { 140static struct pcmcia_low_level mst_pcmcia_ops __initdata = {
140 .owner = THIS_MODULE, 141 .owner = THIS_MODULE,
141 .hw_init = mst_pcmcia_hw_init, 142 .hw_init = mst_pcmcia_hw_init,
142 .hw_shutdown = mst_pcmcia_hw_shutdown, 143 .hw_shutdown = mst_pcmcia_hw_shutdown,
@@ -153,13 +154,17 @@ static int __init mst_pcmcia_init(void)
153{ 154{
154 int ret; 155 int ret;
155 156
157 if (!machine_is_mainstone())
158 return -ENODEV;
159
156 mst_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); 160 mst_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
157 if (!mst_pcmcia_device) 161 if (!mst_pcmcia_device)
158 return -ENOMEM; 162 return -ENOMEM;
159 163
160 mst_pcmcia_device->dev.platform_data = &mst_pcmcia_ops; 164 ret = platform_device_add_data(mst_pcmcia_device, &mst_pcmcia_ops,
161 165 sizeof(mst_pcmcia_ops));
162 ret = platform_device_add(mst_pcmcia_device); 166 if (ret == 0)
167 ret = platform_device_add(mst_pcmcia_device);
163 168
164 if (ret) 169 if (ret)
165 platform_device_put(mst_pcmcia_device); 170 platform_device_put(mst_pcmcia_device);
diff --git a/drivers/pcmcia/pxa2xx_palmtx.c b/drivers/pcmcia/pxa2xx_palmtx.c
new file mode 100644
index 000000000000..4abde190c1f5
--- /dev/null
+++ b/drivers/pcmcia/pxa2xx_palmtx.c
@@ -0,0 +1,118 @@
1/*
2 * linux/drivers/pcmcia/pxa2xx_palmtx.c
3 *
4 * Driver for Palm T|X PCMCIA
5 *
6 * Copyright (C) 2007-2008 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
17#include <asm/mach-types.h>
18
19#include <asm/arch/gpio.h>
20#include <asm/arch/palmtx.h>
21
22#include "soc_common.h"
23
24static int palmtx_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
25{
26 skt->irq = IRQ_GPIO(GPIO_NR_PALMTX_PCMCIA_READY);
27 return 0;
28}
29
30static void palmtx_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
31{
32}
33
34static void palmtx_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
35 struct pcmcia_state *state)
36{
37 state->detect = 1; /* always inserted */
38 state->ready = !!gpio_get_value(GPIO_NR_PALMTX_PCMCIA_READY);
39 state->bvd1 = 1;
40 state->bvd2 = 1;
41 state->wrprot = 0;
42 state->vs_3v = 1;
43 state->vs_Xv = 0;
44}
45
46static int
47palmtx_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
48 const socket_state_t *state)
49{
50 gpio_set_value(GPIO_NR_PALMTX_PCMCIA_POWER1, 1);
51 gpio_set_value(GPIO_NR_PALMTX_PCMCIA_POWER2, 1);
52 gpio_set_value(GPIO_NR_PALMTX_PCMCIA_RESET,
53 !!(state->flags & SS_RESET));
54
55 return 0;
56}
57
58static void palmtx_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
59{
60}
61
62static void palmtx_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
63{
64}
65
66static struct pcmcia_low_level palmtx_pcmcia_ops = {
67 .owner = THIS_MODULE,
68
69 .first = 0,
70 .nr = 1,
71
72 .hw_init = palmtx_pcmcia_hw_init,
73 .hw_shutdown = palmtx_pcmcia_hw_shutdown,
74
75 .socket_state = palmtx_pcmcia_socket_state,
76 .configure_socket = palmtx_pcmcia_configure_socket,
77
78 .socket_init = palmtx_pcmcia_socket_init,
79 .socket_suspend = palmtx_pcmcia_socket_suspend,
80};
81
82static struct platform_device *palmtx_pcmcia_device;
83
84static int __init palmtx_pcmcia_init(void)
85{
86 int ret;
87
88 if (!machine_is_palmtx())
89 return -ENODEV;
90
91 palmtx_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
92 if (!palmtx_pcmcia_device)
93 return -ENOMEM;
94
95 ret = platform_device_add_data(palmtx_pcmcia_device, &palmtx_pcmcia_ops,
96 sizeof(palmtx_pcmcia_ops));
97
98 if (!ret)
99 ret = platform_device_add(palmtx_pcmcia_device);
100
101 if (ret)
102 platform_device_put(palmtx_pcmcia_device);
103
104 return ret;
105}
106
107static void __exit palmtx_pcmcia_exit(void)
108{
109 platform_device_unregister(palmtx_pcmcia_device);
110}
111
112fs_initcall(palmtx_pcmcia_init);
113module_exit(palmtx_pcmcia_exit);
114
115MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
116MODULE_DESCRIPTION("PCMCIA support for Palm T|X");
117MODULE_ALIAS("platform:pxa2xx-pcmcia");
118MODULE_LICENSE("GPL");
diff --git a/drivers/pcmcia/pxa2xx_sharpsl.c b/drivers/pcmcia/pxa2xx_sharpsl.c
index d5c33bd78d68..d71f93d45833 100644
--- a/drivers/pcmcia/pxa2xx_sharpsl.c
+++ b/drivers/pcmcia/pxa2xx_sharpsl.c
@@ -222,7 +222,7 @@ static void sharpsl_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
222 sharpsl_pcmcia_init_reset(skt); 222 sharpsl_pcmcia_init_reset(skt);
223} 223}
224 224
225static struct pcmcia_low_level sharpsl_pcmcia_ops = { 225static struct pcmcia_low_level sharpsl_pcmcia_ops __initdata = {
226 .owner = THIS_MODULE, 226 .owner = THIS_MODULE,
227 .hw_init = sharpsl_pcmcia_hw_init, 227 .hw_init = sharpsl_pcmcia_hw_init,
228 .hw_shutdown = sharpsl_pcmcia_hw_shutdown, 228 .hw_shutdown = sharpsl_pcmcia_hw_shutdown,
@@ -261,10 +261,12 @@ static int __init sharpsl_pcmcia_init(void)
261 if (!sharpsl_pcmcia_device) 261 if (!sharpsl_pcmcia_device)
262 return -ENOMEM; 262 return -ENOMEM;
263 263
264 sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops; 264 ret = platform_device_add_data(sharpsl_pcmcia_device,
265 sharpsl_pcmcia_device->dev.parent = platform_scoop_config->devs[0].dev; 265 &sharpsl_pcmcia_ops, sizeof(sharpsl_pcmcia_ops));
266 266 if (ret == 0) {
267 ret = platform_device_add(sharpsl_pcmcia_device); 267 sharpsl_pcmcia_device->dev.parent = platform_scoop_config->devs[0].dev;
268 ret = platform_device_add(sharpsl_pcmcia_device);
269 }
268 270
269 if (ret) 271 if (ret)
270 platform_device_put(sharpsl_pcmcia_device); 272 platform_device_put(sharpsl_pcmcia_device);