[package] base-files: add "mtu" option for route sections, allows setting per-route...
[openwrt.git] / target / linux / pxa / patches / 005-verdex_pcmcia_support.patch
1 From 76a102bd5c9d792db19c6c72eafdecea0311a0c9 Mon Sep 17 00:00:00 2001
2 From: Craig Hughes <craig@gumstix.com>
3 Date: Fri, 30 Oct 2009 14:16:27 -0400
4 Subject: [PATCH] [ARM] pxa: Gumstix Verdex PCMCIA support
5
6 Needed for the Libertas CS wireless device.
7
8 Signed-off-by: Bobby Powers <bobbypowers@gmail.com>
9 ---
10 drivers/pcmcia/Kconfig | 3 +-
11 drivers/pcmcia/Makefile | 3 +
12 drivers/pcmcia/pxa2xx_gumstix.c | 194 +++++++++++++++++++++++++++++++++++++++
13 3 files changed, 199 insertions(+), 1 deletions(-)
14 create mode 100644 drivers/pcmcia/pxa2xx_gumstix.c
15
16 --- a/drivers/pcmcia/Kconfig
17 +++ b/drivers/pcmcia/Kconfig
18 @@ -221,7 +221,8 @@ config PCMCIA_PXA2XX
19 depends on ARM && ARCH_PXA && PCMCIA
20 depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \
21 || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \
22 - || ARCH_VIPER || ARCH_PXA_ESERIES || MACH_STARGATE2)
23 + || ARCH_VIPER || ARCH_PXA_ESERIES || MACH_STARGATE2 \
24 + || ARCH_GUMSTIX)
25 help
26 Say Y here to include support for the PXA2xx PCMCIA controller
27
28 --- a/drivers/pcmcia/Makefile
29 +++ b/drivers/pcmcia/Makefile
30 @@ -77,4 +77,7 @@ pxa2xx-obj-$(CONFIG_MACH_PALMLD) += pxa
31 pxa2xx-obj-$(CONFIG_MACH_E740) += pxa2xx_e740.o
32 pxa2xx-obj-$(CONFIG_MACH_STARGATE2) += pxa2xx_stargate2.o
33
34 +pxa2xx-obj-$(CONFIG_MACH_GUMSTIX_VERDEX) += pxa2xx_cs.o
35 +pxa2xx_cs-objs := pxa2xx_gumstix.o
36 +
37 obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_core.o $(pxa2xx-obj-y)
38 --- /dev/null
39 +++ b/drivers/pcmcia/pxa2xx_gumstix.c
40 @@ -0,0 +1,194 @@
41 +/*
42 + * linux/drivers/pcmcia/pxa2xx_gumstix.c
43 + *
44 + * Gumstix PCMCIA specific routines. Based on Mainstone
45 + *
46 + * Copyright 2004, Craig Hughes <craig@gumstix.com>
47 + *
48 + * This program is free software; you can redistribute it and/or modify
49 + * it under the terms of the GNU General Public License version 2 as
50 + * published by the Free Software Foundation.
51 + */
52 +
53 +#include <linux/module.h>
54 +#include <linux/init.h>
55 +#include <linux/kernel.h>
56 +#include <linux/errno.h>
57 +#include <linux/interrupt.h>
58 +#include <linux/irq.h>
59 +#include <linux/gpio.h>
60 +
61 +#include <linux/delay.h>
62 +#include <linux/platform_device.h>
63 +
64 +#include <pcmcia/ss.h>
65 +
66 +#include <mach/hardware.h>
67 +#include <asm/mach-types.h>
68 +
69 +#ifdef CONFIG_MACH_GUMSTIX_VERDEX
70 +#include <mach/pxa27x.h>
71 +#else
72 +#include <mach/pxa27x.h>
73 +#endif
74 +
75 +#include <asm/io.h>
76 +#include <mach/gpio.h>
77 +#include <mach/gumstix.h>
78 +#include "soc_common.h"
79 +
80 +#define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x)
81 +
82 +static struct pcmcia_irqs gumstix_pcmcia_irqs0[] = {
83 + { 0, GUMSTIX_S0_nCD_IRQ, "CF0 nCD" },
84 + { 0, GUMSTIX_S0_nSTSCHG_IRQ, "CF0 nSTSCHG" },
85 +};
86 +
87 +static struct pcmcia_irqs gumstix_pcmcia_irqs1[] = {
88 + { 1, GUMSTIX_S1_nCD_IRQ, "CF1 nCD" },
89 + { 1, GUMSTIX_S1_nSTSCHG_IRQ, "CF1 nSTSCHG" },
90 +};
91 +
92 +
93 +static int net_cf_vx_mode = 0;
94 +
95 +static int gumstix_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
96 +{
97 +/* Note: The verdex_pcmcia_pin_config is moved to gumstix_verdex.c in order to use mfp_pxa2xx_config
98 + for board-specific pin configuration instead of the old deprecated pxa_gpio_mode function. Thus,
99 + only the IRQ init is still needed to be done here. */
100 + skt->irq = (skt->nr == 0) ? ((net_cf_vx_mode == 0) ? GUMSTIX_S0_PRDY_nBSY_IRQ : GUMSTIX_S0_PRDY_nBSY_OLD_IRQ) : GUMSTIX_S1_PRDY_nBSY_IRQ;
101 +
102 + return (skt->nr == 0) ? soc_pcmcia_request_irqs(skt, gumstix_pcmcia_irqs0, ARRAY_SIZE(gumstix_pcmcia_irqs0)) :
103 + soc_pcmcia_request_irqs(skt, gumstix_pcmcia_irqs1, ARRAY_SIZE(gumstix_pcmcia_irqs1));
104 +}
105 +
106 +static void gumstix_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
107 +{
108 + if(skt->nr == 0)
109 + {
110 + soc_pcmcia_free_irqs(skt, gumstix_pcmcia_irqs0, ARRAY_SIZE(gumstix_pcmcia_irqs0));
111 + } else {
112 + soc_pcmcia_free_irqs(skt, gumstix_pcmcia_irqs1, ARRAY_SIZE(gumstix_pcmcia_irqs1));
113 + }
114 +
115 + if (net_cf_vx_mode) {
116 + gpio_free(GPIO_GUMSTIX_CF_OLD_RESET);
117 + } else {
118 + gpio_free(GPIO_GUMSTIX_CF_RESET);
119 + }
120 +
121 +}
122 +
123 +static void gumstix_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
124 + struct pcmcia_state *state)
125 +{
126 + unsigned int cd, prdy_nbsy, nbvd1;
127 + if(skt->nr == 0)
128 + {
129 + cd = GPIO_GUMSTIX_nCD_0;
130 + if(net_cf_vx_mode)
131 + prdy_nbsy = GPIO_GUMSTIX_PRDY_nBSY_0_OLD;
132 + else
133 + prdy_nbsy = GPIO_GUMSTIX_PRDY_nBSY_0;
134 + nbvd1 = GPIO_GUMSTIX_nBVD1_0;
135 + } else {
136 + cd = GPIO_GUMSTIX_nCD_1;
137 + prdy_nbsy = GPIO_GUMSTIX_PRDY_nBSY_1;
138 + nbvd1 = GPIO_GUMSTIX_nBVD1_1;
139 + }
140 + state->detect = !(GPLR(cd) & GPIO_bit(cd));
141 + state->ready = !!(GPLR(prdy_nbsy) & GPIO_bit(prdy_nbsy));
142 + state->bvd1 = !!(GPLR(nbvd1) & GPIO_bit(nbvd1));
143 + state->bvd2 = 1;
144 + state->vs_3v = 0;
145 + state->vs_Xv = 0;
146 + state->wrprot = 0;
147 +}
148 +
149 +static int gumstix_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
150 + const socket_state_t *state)
151 +{
152 + return 0;
153 +}
154 +
155 +static void gumstix_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
156 +{
157 + if(skt->nr) {
158 + soc_pcmcia_enable_irqs(skt, gumstix_pcmcia_irqs0, ARRAY_SIZE(gumstix_pcmcia_irqs0));
159 + } else {
160 + soc_pcmcia_enable_irqs(skt, gumstix_pcmcia_irqs1, ARRAY_SIZE(gumstix_pcmcia_irqs1));
161 + }
162 +}
163 +
164 +static void gumstix_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
165 +{
166 + if(skt->nr) {
167 + soc_pcmcia_disable_irqs(skt, gumstix_pcmcia_irqs0, ARRAY_SIZE(gumstix_pcmcia_irqs0));
168 + } else {
169 + soc_pcmcia_disable_irqs(skt, gumstix_pcmcia_irqs1, ARRAY_SIZE(gumstix_pcmcia_irqs1));
170 + }
171 +}
172 +
173 +static struct pcmcia_low_level gumstix_pcmcia_ops = {
174 + .owner = THIS_MODULE,
175 + .hw_init = gumstix_pcmcia_hw_init,
176 + .hw_shutdown = gumstix_pcmcia_hw_shutdown,
177 + .socket_state = gumstix_pcmcia_socket_state,
178 + .configure_socket = gumstix_pcmcia_configure_socket,
179 + .socket_init = gumstix_pcmcia_socket_init,
180 + .socket_suspend = gumstix_pcmcia_socket_suspend,
181 + .nr = 2,
182 +};
183 +
184 +static struct platform_device *gumstix_pcmcia_device;
185 +
186 +extern int __init gumstix_get_cf_cards(void);
187 +
188 +#ifdef CONFIG_MACH_GUMSTIX_VERDEX
189 +extern int __init gumstix_check_if_netCF_vx(void);
190 +#endif
191 +
192 +static int __init gumstix_pcmcia_init(void)
193 +{
194 + int ret;
195 +
196 +#ifdef CONFIG_MACH_GUMSTIX_VERDEX
197 + net_cf_vx_mode = gumstix_check_if_netCF_vx();
198 +#endif
199 +
200 + gumstix_pcmcia_ops.nr = gumstix_get_cf_cards();
201 +
202 + gumstix_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
203 + if (!gumstix_pcmcia_device)
204 + return -ENOMEM;
205 +
206 + ret = platform_device_add_data(gumstix_pcmcia_device, &gumstix_pcmcia_ops,
207 + sizeof(gumstix_pcmcia_ops));
208 +
209 + if (ret == 0) {
210 + printk(KERN_INFO "Registering gumstix PCMCIA interface.\n");
211 + ret = platform_device_add(gumstix_pcmcia_device);
212 + }
213 +
214 + if (ret)
215 + platform_device_put(gumstix_pcmcia_device);
216 +
217 + return ret;
218 +}
219 +
220 +static void __exit gumstix_pcmcia_exit(void)
221 +{
222 + /*
223 + * This call is supposed to free our gumstix_pcmcia_device.
224 + * Unfortunately platform_device don't have a free method, and
225 + * we can't assume it's free of any reference at this point so we
226 + * can't free it either.
227 + */
228 + platform_device_unregister(gumstix_pcmcia_device);
229 +}
230 +
231 +fs_initcall(gumstix_pcmcia_init);
232 +module_exit(gumstix_pcmcia_exit);
233 +
234 +MODULE_LICENSE("GPL");
This page took 0.051908 seconds and 5 git commands to generate.