x86: update to linux 4.4
[openwrt/openwrt.git] / target / linux / pxa / patches-3.10 / 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 @@ -217,7 +217,7 @@ config PCMCIA_PXA2XX
19 || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \
20 || ARCOM_PCMCIA || ARCH_PXA_ESERIES || MACH_STARGATE2 \
21 || MACH_VPAC270 || MACH_BALLOON3 || MACH_COLIBRI \
22 - || MACH_COLIBRI320 || MACH_H4700)
23 + || MACH_COLIBRI320 || MACH_H4700 || ARCH_GUMSTIX)
24 select PCMCIA_SA1111 if ARCH_LUBBOCK && SA1111
25 select PCMCIA_SOC_COMMON
26 help
27 --- a/drivers/pcmcia/Makefile
28 +++ b/drivers/pcmcia/Makefile
29 @@ -71,6 +71,9 @@ pxa2xx-obj-$(CONFIG_MACH_COLIBRI) += px
30 pxa2xx-obj-$(CONFIG_MACH_COLIBRI320) += pxa2xx_colibri.o
31 pxa2xx-obj-$(CONFIG_MACH_H4700) += pxa2xx_hx4700.o
32
33 +pxa2xx-obj-$(CONFIG_MACH_GUMSTIX_VERDEX) += pxa2xx_cs.o
34 +pxa2xx_cs-objs := pxa2xx_gumstix.o
35 +
36 obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_base.o $(pxa2xx-obj-y)
37
38 obj-$(CONFIG_PCMCIA_XXS1500) += xxs1500_ss.o
39 --- /dev/null
40 +++ b/drivers/pcmcia/pxa2xx_gumstix.c
41 @@ -0,0 +1,168 @@
42 +/*
43 + * linux/drivers/pcmcia/pxa2xx_gumstix.c
44 + *
45 + * Gumstix PCMCIA specific routines. Based on Mainstone
46 + *
47 + * Copyright 2004, Craig Hughes <craig@gumstix.com>
48 + *
49 + * This program is free software; you can redistribute it and/or modify
50 + * it under the terms of the GNU General Public License version 2 as
51 + * published by the Free Software Foundation.
52 + */
53 +
54 +#include <linux/module.h>
55 +#include <linux/init.h>
56 +#include <linux/kernel.h>
57 +#include <linux/errno.h>
58 +#include <linux/interrupt.h>
59 +#include <linux/irq.h>
60 +#include <linux/gpio.h>
61 +
62 +#include <linux/delay.h>
63 +#include <linux/platform_device.h>
64 +
65 +#include <linux/gpio-pxa.h>
66 +
67 +#include <pcmcia/ss.h>
68 +
69 +#include <mach/hardware.h>
70 +#include <asm/mach-types.h>
71 +
72 +#include <mach/pxa27x.h>
73 +
74 +#include <asm/io.h>
75 +#include <mach/gpio.h>
76 +#include <mach/gumstix.h>
77 +#include "soc_common.h"
78 +
79 +#define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x)
80 +
81 +#define BANK_OFF(n) (((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2))
82 +#define GPLR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5))
83 +
84 +static int net_cf_vx_mode = 0;
85 +
86 +static int gumstix_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
87 +{
88 +/* Note: The verdex_pcmcia_pin_config is moved to gumstix_verdex.c in order to use mfp_pxa2xx_config
89 + for board-specific pin configuration instead of the old deprecated pxa_gpio_mode function. Thus,
90 + only the IRQ init is still needed to be done here. */
91 + if (skt->nr == 0) {
92 + skt->socket.pci_irq = (net_cf_vx_mode == 0) ? GUMSTIX_S0_PRDY_nBSY_IRQ : GUMSTIX_S0_PRDY_nBSY_OLD_IRQ;
93 + skt->stat[SOC_STAT_CD].gpio = GUMSTIX_S0_nCD_IRQ;
94 + skt->stat[SOC_STAT_CD].name = "CF0 nCD";
95 + skt->stat[SOC_STAT_RDY].gpio = GUMSTIX_S0_nSTSCHG_IRQ;
96 + skt->stat[SOC_STAT_RDY].name = "CF0 nSTSCHG";
97 + } else {
98 + skt->socket.pci_irq = GUMSTIX_S1_PRDY_nBSY_IRQ;
99 + skt->stat[SOC_STAT_CD].gpio = GUMSTIX_S1_nCD_IRQ;
100 + skt->stat[SOC_STAT_CD].name = "CF1 nCD";
101 + skt->stat[SOC_STAT_RDY].gpio = GUMSTIX_S1_nSTSCHG_IRQ;
102 + skt->stat[SOC_STAT_RDY].name = "CF1 nSTSCHG";
103 + }
104 +
105 + return 0;
106 +}
107 +
108 +static void gumstix_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
109 +{
110 + if (net_cf_vx_mode) {
111 + gpio_free(GPIO_GUMSTIX_CF_OLD_RESET);
112 + } else {
113 + gpio_free(GPIO_GUMSTIX_CF_RESET);
114 + }
115 +
116 +}
117 +
118 +static void gumstix_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
119 + struct pcmcia_state *state)
120 +{
121 + unsigned int cd, prdy_nbsy, nbvd1;
122 + if(skt->nr == 0)
123 + {
124 + cd = GPIO_GUMSTIX_nCD_0;
125 + if(net_cf_vx_mode)
126 + prdy_nbsy = GPIO_GUMSTIX_PRDY_nBSY_0_OLD;
127 + else
128 + prdy_nbsy = GPIO_GUMSTIX_PRDY_nBSY_0;
129 + nbvd1 = GPIO_GUMSTIX_nBVD1_0;
130 + } else {
131 + cd = GPIO_GUMSTIX_nCD_1;
132 + prdy_nbsy = GPIO_GUMSTIX_PRDY_nBSY_1;
133 + nbvd1 = GPIO_GUMSTIX_nBVD1_1;
134 + }
135 + state->detect = !!gpio_get_value(cd);
136 + state->ready = !!gpio_get_value(prdy_nbsy);
137 + state->bvd1 = !!gpio_get_value(nbvd1);
138 + state->bvd2 = 1;
139 + state->vs_3v = 0;
140 + state->vs_Xv = 0;
141 + state->wrprot = 0;
142 +}
143 +
144 +static int gumstix_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
145 + const socket_state_t *state)
146 +{
147 + return 0;
148 +}
149 +
150 +static struct pcmcia_low_level gumstix_pcmcia_ops = {
151 + .owner = THIS_MODULE,
152 + .hw_init = gumstix_pcmcia_hw_init,
153 + .hw_shutdown = gumstix_pcmcia_hw_shutdown,
154 + .socket_state = gumstix_pcmcia_socket_state,
155 + .configure_socket = gumstix_pcmcia_configure_socket,
156 + .nr = 2,
157 +};
158 +
159 +static struct platform_device *gumstix_pcmcia_device;
160 +
161 +extern int __init gumstix_get_cf_cards(void);
162 +
163 +#ifdef CONFIG_MACH_GUMSTIX_VERDEX
164 +extern int __init gumstix_check_if_netCF_vx(void);
165 +#endif
166 +
167 +static int __init gumstix_pcmcia_init(void)
168 +{
169 + int ret;
170 +
171 +#ifdef CONFIG_MACH_GUMSTIX_VERDEX
172 + net_cf_vx_mode = gumstix_check_if_netCF_vx();
173 +#endif
174 +
175 + gumstix_pcmcia_ops.nr = gumstix_get_cf_cards();
176 +
177 + gumstix_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
178 + if (!gumstix_pcmcia_device)
179 + return -ENOMEM;
180 +
181 + ret = platform_device_add_data(gumstix_pcmcia_device, &gumstix_pcmcia_ops,
182 + sizeof(gumstix_pcmcia_ops));
183 +
184 + if (ret == 0) {
185 + printk(KERN_INFO "Registering gumstix PCMCIA interface.\n");
186 + ret = platform_device_add(gumstix_pcmcia_device);
187 + }
188 +
189 + if (ret)
190 + platform_device_put(gumstix_pcmcia_device);
191 +
192 + return ret;
193 +}
194 +
195 +static void __exit gumstix_pcmcia_exit(void)
196 +{
197 + /*
198 + * This call is supposed to free our gumstix_pcmcia_device.
199 + * Unfortunately platform_device don't have a free method, and
200 + * we can't assume it's free of any reference at this point so we
201 + * can't free it either.
202 + */
203 + platform_device_unregister(gumstix_pcmcia_device);
204 +}
205 +
206 +fs_initcall(gumstix_pcmcia_init);
207 +module_exit(gumstix_pcmcia_exit);
208 +
209 +MODULE_LICENSE("GPL");