aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMarc Zyngier <maz@misterjones.org>2009-11-14 07:39:13 -0500
committerEric Miao <eric.y.miao@gmail.com>2009-12-13 08:42:58 -0500
commitc2de1c382933fd9ef0a3db13b6747115e1e32c56 (patch)
treed9e0fa251d376fb7d5f9906952bf02f2f31570e0 /drivers
parente491a11c77a4ed93ec14cc052b1f048bddc9e99a (diff)
[ARM] pxa/zeus: make Viper pcmcia support more generic to support Zeus
The Arcom Zeus CF slot requires the same kind of support as the Viper. To avoid code duplication, introduce a platform device that abstracts the differences. This also allows for the removal of the ugly export of viper_cf_rst(). Signed-off-by: Marc Zyngier <maz@misterjones.org> Signed-off-by: Eric Miao <eric.y.miao@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pcmcia/Kconfig2
-rw-r--r--drivers/pcmcia/Makefile2
-rw-r--r--drivers/pcmcia/pxa2xx_base.c3
-rw-r--r--drivers/pcmcia/pxa2xx_viper.c119
4 files changed, 90 insertions, 36 deletions
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index cd5082d3ca19..58bee55a3dd3 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -208,7 +208,7 @@ config PCMCIA_PXA2XX
208 depends on ARM && ARCH_PXA && PCMCIA 208 depends on ARM && ARCH_PXA && PCMCIA
209 depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \ 209 depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \
210 || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \ 210 || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \
211 || ARCH_VIPER || ARCH_PXA_ESERIES || MACH_STARGATE2) 211 || ARCOM_PCMCIA || ARCH_PXA_ESERIES || MACH_STARGATE2)
212 select PCMCIA_SOC_COMMON 212 select PCMCIA_SOC_COMMON
213 help 213 help
214 Say Y here to include support for the PXA2xx PCMCIA controller 214 Say Y here to include support for the PXA2xx PCMCIA controller
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index 382938313991..83ff802de544 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -67,7 +67,7 @@ pxa2xx-obj-$(CONFIG_ARCH_LUBBOCK) += pxa2xx_lubbock_cs.o
67pxa2xx-obj-$(CONFIG_MACH_MAINSTONE) += pxa2xx_mainstone.o 67pxa2xx-obj-$(CONFIG_MACH_MAINSTONE) += pxa2xx_mainstone.o
68pxa2xx-obj-$(CONFIG_PXA_SHARPSL) += pxa2xx_sharpsl.o 68pxa2xx-obj-$(CONFIG_PXA_SHARPSL) += pxa2xx_sharpsl.o
69pxa2xx-obj-$(CONFIG_MACH_ARMCORE) += pxa2xx_cm_x2xx_cs.o 69pxa2xx-obj-$(CONFIG_MACH_ARMCORE) += pxa2xx_cm_x2xx_cs.o
70pxa2xx-obj-$(CONFIG_ARCH_VIPER) += pxa2xx_viper.o 70pxa2xx-obj-$(CONFIG_ARCOM_PCMCIA) += pxa2xx_viper.o
71pxa2xx-obj-$(CONFIG_TRIZEPS_PCMCIA) += pxa2xx_trizeps4.o 71pxa2xx-obj-$(CONFIG_TRIZEPS_PCMCIA) += pxa2xx_trizeps4.o
72pxa2xx-obj-$(CONFIG_MACH_PALMTX) += pxa2xx_palmtx.o 72pxa2xx-obj-$(CONFIG_MACH_PALMTX) += pxa2xx_palmtx.o
73pxa2xx-obj-$(CONFIG_MACH_PALMTC) += pxa2xx_palmtc.o 73pxa2xx-obj-$(CONFIG_MACH_PALMTC) += pxa2xx_palmtc.o
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index 84dde7768ad5..87481ce60dfb 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -214,7 +214,8 @@ static void pxa2xx_configure_sockets(struct device *dev)
214 MECR |= MECR_CIT; 214 MECR |= MECR_CIT;
215 215
216 /* Set MECR:NOS (Number Of Sockets) */ 216 /* Set MECR:NOS (Number Of Sockets) */
217 if ((ops->first + ops->nr) > 1 || machine_is_viper()) 217 if ((ops->first + ops->nr) > 1 ||
218 machine_is_viper() || machine_is_arcom_zeus())
218 MECR |= MECR_NOS; 219 MECR |= MECR_NOS;
219 else 220 else
220 MECR &= ~MECR_NOS; 221 MECR &= ~MECR_NOS;
diff --git a/drivers/pcmcia/pxa2xx_viper.c b/drivers/pcmcia/pxa2xx_viper.c
index 27be2e154df2..a51f2077644a 100644
--- a/drivers/pcmcia/pxa2xx_viper.c
+++ b/drivers/pcmcia/pxa2xx_viper.c
@@ -1,9 +1,8 @@
1/* 1/*
2 * VIPER PCMCIA support 2 * Viper/Zeus PCMCIA support
3 * Copyright 2004 Arcom Control Systems 3 * Copyright 2004 Arcom Control Systems
4 * 4 *
5 * Maintained by Marc Zyngier <maz@misterjones.org> 5 * Maintained by Marc Zyngier <maz@misterjones.org>
6 * <marc.zyngier@altran.com>
7 * 6 *
8 * Based on: 7 * Based on:
9 * iPAQ h2200 PCMCIA support 8 * iPAQ h2200 PCMCIA support
@@ -26,37 +25,47 @@
26 25
27#include <asm/irq.h> 26#include <asm/irq.h>
28 27
29#include <mach/viper.h> 28#include <mach/arcom-pcmcia.h>
30#include <asm/mach-types.h>
31 29
32#include "soc_common.h" 30#include "soc_common.h"
33#include "pxa2xx_base.h" 31#include "pxa2xx_base.h"
34 32
33static struct platform_device *arcom_pcmcia_dev;
34
35static struct pcmcia_irqs irqs[] = { 35static struct pcmcia_irqs irqs[] = {
36 { 0, gpio_to_irq(VIPER_CF_CD_GPIO), "PCMCIA_CD" } 36 {
37 .sock = 0,
38 .str = "PCMCIA_CD",
39 },
37}; 40};
38 41
42static inline struct arcom_pcmcia_pdata *viper_get_pdata(void)
43{
44 return arcom_pcmcia_dev->dev.platform_data;
45}
46
39static int viper_pcmcia_hw_init(struct soc_pcmcia_socket *skt) 47static int viper_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
40{ 48{
49 struct arcom_pcmcia_pdata *pdata = viper_get_pdata();
41 unsigned long flags; 50 unsigned long flags;
42 51
43 skt->socket.pci_irq = gpio_to_irq(VIPER_CF_RDY_GPIO); 52 skt->socket.pci_irq = gpio_to_irq(pdata->rdy_gpio);
53 irqs[0].irq = gpio_to_irq(pdata->cd_gpio);
44 54
45 if (gpio_request(VIPER_CF_CD_GPIO, "CF detect")) 55 if (gpio_request(pdata->cd_gpio, "CF detect"))
46 goto err_request_cd; 56 goto err_request_cd;
47 57
48 if (gpio_request(VIPER_CF_RDY_GPIO, "CF ready")) 58 if (gpio_request(pdata->rdy_gpio, "CF ready"))
49 goto err_request_rdy; 59 goto err_request_rdy;
50 60
51 if (gpio_request(VIPER_CF_POWER_GPIO, "CF power")) 61 if (gpio_request(pdata->pwr_gpio, "CF power"))
52 goto err_request_pwr; 62 goto err_request_pwr;
53 63
54 local_irq_save(flags); 64 local_irq_save(flags);
55 65
56 /* GPIO 82 is the CF power enable line. initially off */ 66 if (gpio_direction_output(pdata->pwr_gpio, 0) ||
57 if (gpio_direction_output(VIPER_CF_POWER_GPIO, 0) || 67 gpio_direction_input(pdata->cd_gpio) ||
58 gpio_direction_input(VIPER_CF_CD_GPIO) || 68 gpio_direction_input(pdata->rdy_gpio)) {
59 gpio_direction_input(VIPER_CF_RDY_GPIO)) {
60 local_irq_restore(flags); 69 local_irq_restore(flags);
61 goto err_dir; 70 goto err_dir;
62 } 71 }
@@ -66,13 +75,13 @@ static int viper_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
66 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); 75 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
67 76
68err_dir: 77err_dir:
69 gpio_free(VIPER_CF_POWER_GPIO); 78 gpio_free(pdata->pwr_gpio);
70err_request_pwr: 79err_request_pwr:
71 gpio_free(VIPER_CF_RDY_GPIO); 80 gpio_free(pdata->rdy_gpio);
72err_request_rdy: 81err_request_rdy:
73 gpio_free(VIPER_CF_CD_GPIO); 82 gpio_free(pdata->cd_gpio);
74err_request_cd: 83err_request_cd:
75 printk(KERN_ERR "viper: Failed to setup PCMCIA GPIOs\n"); 84 dev_err(&arcom_pcmcia_dev->dev, "Failed to setup PCMCIA GPIOs\n");
76 return -1; 85 return -1;
77} 86}
78 87
@@ -81,17 +90,21 @@ err_request_cd:
81 */ 90 */
82static void viper_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) 91static void viper_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
83{ 92{
93 struct arcom_pcmcia_pdata *pdata = viper_get_pdata();
94
84 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs)); 95 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
85 gpio_free(VIPER_CF_POWER_GPIO); 96 gpio_free(pdata->pwr_gpio);
86 gpio_free(VIPER_CF_RDY_GPIO); 97 gpio_free(pdata->rdy_gpio);
87 gpio_free(VIPER_CF_CD_GPIO); 98 gpio_free(pdata->cd_gpio);
88} 99}
89 100
90static void viper_pcmcia_socket_state(struct soc_pcmcia_socket *skt, 101static void viper_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
91 struct pcmcia_state *state) 102 struct pcmcia_state *state)
92{ 103{
93 state->detect = gpio_get_value(VIPER_CF_CD_GPIO) ? 0 : 1; 104 struct arcom_pcmcia_pdata *pdata = viper_get_pdata();
94 state->ready = gpio_get_value(VIPER_CF_RDY_GPIO) ? 1 : 0; 105
106 state->detect = !gpio_get_value(pdata->cd_gpio);
107 state->ready = !!gpio_get_value(pdata->rdy_gpio);
95 state->bvd1 = 1; 108 state->bvd1 = 1;
96 state->bvd2 = 1; 109 state->bvd2 = 1;
97 state->wrprot = 0; 110 state->wrprot = 0;
@@ -102,20 +115,21 @@ static void viper_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
102static int viper_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, 115static int viper_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
103 const socket_state_t *state) 116 const socket_state_t *state)
104{ 117{
118 struct arcom_pcmcia_pdata *pdata = viper_get_pdata();
119
105 /* Silently ignore Vpp, output enable, speaker enable. */ 120 /* Silently ignore Vpp, output enable, speaker enable. */
106 viper_cf_rst(state->flags & SS_RESET); 121 pdata->reset(state->flags & SS_RESET);
107 122
108 /* Apply socket voltage */ 123 /* Apply socket voltage */
109 switch (state->Vcc) { 124 switch (state->Vcc) {
110 case 0: 125 case 0:
111 gpio_set_value(VIPER_CF_POWER_GPIO, 0); 126 gpio_set_value(pdata->pwr_gpio, 0);
112 break; 127 break;
113 case 33: 128 case 33:
114 gpio_set_value(VIPER_CF_POWER_GPIO, 1); 129 gpio_set_value(pdata->pwr_gpio, 1);
115 break; 130 break;
116 default: 131 default:
117 printk(KERN_ERR "%s: Unsupported Vcc:%d\n", 132 dev_err(&arcom_pcmcia_dev->dev, "Unsupported Vcc:%d\n", state->Vcc);
118 __func__, state->Vcc);
119 return -1; 133 return -1;
120 } 134 }
121 135
@@ -130,7 +144,7 @@ static void viper_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
130{ 144{
131} 145}
132 146
133static struct pcmcia_low_level viper_pcmcia_ops __initdata = { 147static struct pcmcia_low_level viper_pcmcia_ops = {
134 .owner = THIS_MODULE, 148 .owner = THIS_MODULE,
135 .hw_init = viper_pcmcia_hw_init, 149 .hw_init = viper_pcmcia_hw_init,
136 .hw_shutdown = viper_pcmcia_hw_shutdown, 150 .hw_shutdown = viper_pcmcia_hw_shutdown,
@@ -143,17 +157,25 @@ static struct pcmcia_low_level viper_pcmcia_ops __initdata = {
143 157
144static struct platform_device *viper_pcmcia_device; 158static struct platform_device *viper_pcmcia_device;
145 159
146static int __init viper_pcmcia_init(void) 160static int viper_pcmcia_probe(struct platform_device *pdev)
147{ 161{
148 int ret; 162 int ret;
149 163
150 if (!machine_is_viper()) 164 /* I can't imagine more than one device, but you never know... */
151 return -ENODEV; 165 if (arcom_pcmcia_dev)
166 return -EEXIST;
167
168 if (!pdev->dev.platform_data)
169 return -EINVAL;
152 170
153 viper_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); 171 viper_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
154 if (!viper_pcmcia_device) 172 if (!viper_pcmcia_device)
155 return -ENOMEM; 173 return -ENOMEM;
156 174
175 arcom_pcmcia_dev = pdev;
176
177 viper_pcmcia_device->dev.parent = &pdev->dev;
178
157 ret = platform_device_add_data(viper_pcmcia_device, 179 ret = platform_device_add_data(viper_pcmcia_device,
158 &viper_pcmcia_ops, 180 &viper_pcmcia_ops,
159 sizeof(viper_pcmcia_ops)); 181 sizeof(viper_pcmcia_ops));
@@ -161,18 +183,49 @@ static int __init viper_pcmcia_init(void)
161 if (!ret) 183 if (!ret)
162 ret = platform_device_add(viper_pcmcia_device); 184 ret = platform_device_add(viper_pcmcia_device);
163 185
164 if (ret) 186 if (ret) {
165 platform_device_put(viper_pcmcia_device); 187 platform_device_put(viper_pcmcia_device);
188 arcom_pcmcia_dev = NULL;
189 }
166 190
167 return ret; 191 return ret;
168} 192}
169 193
170static void __exit viper_pcmcia_exit(void) 194static int viper_pcmcia_remove(struct platform_device *pdev)
171{ 195{
172 platform_device_unregister(viper_pcmcia_device); 196 platform_device_unregister(viper_pcmcia_device);
197 arcom_pcmcia_dev = NULL;
198 return 0;
199}
200
201static struct platform_device_id viper_pcmcia_id_table[] = {
202 { .name = "viper-pcmcia", },
203 { .name = "zeus-pcmcia", },
204 { },
205};
206
207static struct platform_driver viper_pcmcia_driver = {
208 .probe = viper_pcmcia_probe,
209 .remove = viper_pcmcia_remove,
210 .driver = {
211 .name = "arcom-pcmcia",
212 .owner = THIS_MODULE,
213 },
214 .id_table = viper_pcmcia_id_table,
215};
216
217static int __init viper_pcmcia_init(void)
218{
219 return platform_driver_register(&viper_pcmcia_driver);
220}
221
222static void __exit viper_pcmcia_exit(void)
223{
224 return platform_driver_unregister(&viper_pcmcia_driver);
173} 225}
174 226
175module_init(viper_pcmcia_init); 227module_init(viper_pcmcia_init);
176module_exit(viper_pcmcia_exit); 228module_exit(viper_pcmcia_exit);
177 229
230MODULE_DEVICE_TABLE(platform, viper_pcmcia_id_table);
178MODULE_LICENSE("GPL"); 231MODULE_LICENSE("GPL");