pxa: add support for 3.3
[openwrt/openwrt.git] / target / linux / pxa / patches-3.3 / 001-gumstix_verdex_pro_arch_support.patch
1 From 4f4bb58cba3a6c44e9f9f113609287d9d50be9c4 Mon Sep 17 00:00:00 2001
2 From: Joseph Kortje <jpktech@rogers.com>
3 Date: Wed, 28 Oct 2009 21:11:28 -0400
4 Subject: [PATCH] [ARM] Gumstix Verdex Pro arch support
5
6 add an option for Verdex Pro when ARCH_GUMSTIX is selected, and
7 factor earlier Gumstix support into a seperate option
8
9 Signed-off-by: Bobby Powers <bobbypowers@gmail.com>
10 ---
11 arch/arm/mach-pxa/Kconfig | 29 +-
12 arch/arm/mach-pxa/Makefile | 3 +-
13 arch/arm/mach-pxa/gumstix-verdex.c | 749 +++++++++++++++++++++++++++
14 arch/arm/mach-pxa/include/mach/mfp-pxa27x.h | 1 +
15 4 files changed, 772 insertions(+), 10 deletions(-)
16 create mode 100644 arch/arm/mach-pxa/gumstix-verdex.c
17
18 --- a/arch/arm/mach-pxa/Kconfig
19 +++ b/arch/arm/mach-pxa/Kconfig
20 @@ -134,23 +134,34 @@ config MACH_CAPC7117
21 select PXA3xx
22
23 config ARCH_GUMSTIX
24 - bool "Gumstix XScale 255 boards"
25 - select PXA25x
26 + bool "Gumstix boards"
27 help
28 - Say Y here if you intend to run this kernel on
29 - Basix, Connex, ws-200ax, ws-400ax systems
30 + Say Y here if you intend to run this kernel on a
31 + gumstix computer.
32
33 -choice
34 - prompt "Gumstix Carrier/Expansion Board"
35 depends on ARCH_GUMSTIX
36
37 -config GUMSTIX_AM200EPD
38 +config MACH_GUMSTIX_F
39 + bool "Gumstix Basix/Connex ..."
40 + depends on ARCH_GUMSTIX
41 + select PXA25x
42 +
43 + choice
44 + prompt "Gumstix Carrier/Expansion Board"
45 + depends on MACH_GUMSTIX_F
46 +
47 + config GUMSTIX_AM200EPD
48 bool "Enable AM200EPD board support"
49
50 -config GUMSTIX_AM300EPD
51 + config GUMSTIX_AM300EPD
52 bool "Enable AM300EPD board support"
53
54 -endchoice
55 + endchoice
56 +
57 +config MACH_GUMSTIX_VERDEX
58 + bool "Gumstix VERDEX ..."
59 + depends on ARCH_GUMSTIX
60 + select PXA27x
61
62 config MACH_INTELMOTE2
63 bool "Intel Mote 2 Platform"
64 --- a/arch/arm/mach-pxa/Makefile
65 +++ b/arch/arm/mach-pxa/Makefile
66 @@ -51,7 +51,8 @@ endif
67 obj-$(CONFIG_MACH_EM_X270) += em-x270.o
68 obj-$(CONFIG_MACH_CM_X300) += cm-x300.o
69 obj-$(CONFIG_MACH_CAPC7117) += capc7117.o mxm8x10.o
70 -obj-$(CONFIG_ARCH_GUMSTIX) += gumstix.o
71 +obj-$(CONFIG_MACH_GUMSTIX_F) += gumstix.o
72 +obj-$(CONFIG_MACH_GUMSTIX_VERDEX) += gumstix-verdex.o
73 obj-$(CONFIG_GUMSTIX_AM200EPD) += am200epd.o
74 obj-$(CONFIG_GUMSTIX_AM300EPD) += am300epd.o
75 obj-$(CONFIG_MACH_INTELMOTE2) += stargate2.o
76 --- /dev/null
77 +++ b/arch/arm/mach-pxa/gumstix-verdex.c
78 @@ -0,0 +1,793 @@
79 +/*
80 + * linux/arch/arm/mach-pxa/gumstix-verdex.c
81 + *
82 + * Support for the Gumstix verdex motherboard.
83 + *
84 + * Original Author: Craig Hughes
85 + * Created: Feb 14, 2008
86 + * Copyright: Craig Hughes
87 + *
88 + * This program is free software; you can redistribute it and/or modify
89 + * it under the terms of the GNU General Public License version 2 as
90 + * published by the Free Software Foundation.
91 + *
92 + * Implemented based on lubbock.c by Nicolas Pitre and code from Craig
93 + * Hughes
94 + */
95 +
96 +#include <linux/module.h>
97 +#include <linux/kernel.h>
98 +#include <linux/init.h>
99 +#include <linux/platform_device.h>
100 +#include <linux/interrupt.h>
101 +#include <linux/mtd/mtd.h>
102 +#include <linux/mtd/partitions.h>
103 +#include <linux/i2c/tsc2007.h>
104 +#include <linux/i2c/pxa-i2c.h>
105 +#include <linux/gpio.h>
106 +
107 +#include <asm/setup.h>
108 +#include <asm/memory.h>
109 +#include <asm/mach-types.h>
110 +#include <asm/irq.h>
111 +#include <asm/sizes.h>
112 +#include <asm/io.h>
113 +
114 +#include <asm/mach/arch.h>
115 +#include <asm/mach/map.h>
116 +#include <asm/mach/irq.h>
117 +#include <asm/mach/flash.h>
118 +
119 +#include <mach/mmc.h>
120 +#include <mach/udc.h>
121 +#include <mach/pxafb.h>
122 +#include <mach/ohci.h>
123 +#include <mach/pxa27x.h>
124 +#include <mach/pxa27x-udc.h>
125 +#include <mach/gpio.h>
126 +
127 +#include <mach/gumstix.h>
128 +
129 +#include "generic.h"
130 +
131 +#include <linux/delay.h>
132 +
133 +static struct resource flash_resource = {
134 + .start = 0x00000000,
135 + .end = SZ_64M - 1,
136 + .flags = IORESOURCE_MEM,
137 +};
138 +
139 +static struct mtd_partition gumstix_partitions[] = {
140 + {
141 + .name = "u-boot",
142 + .size = 0x00040000,
143 + .offset = 0,
144 + .mask_flags = MTD_WRITEABLE /* force read-only */
145 + } , {
146 + .name = "rootfs",
147 + .size = 0x01ec0000,
148 + .offset = 0x00040000
149 + } , {
150 + .name = "kernel",
151 + .size = 0x00100000,
152 + .offset = 0x01f00000
153 + }
154 +};
155 +
156 +static struct flash_platform_data gumstix_flash_data = {
157 + .map_name = "cfi_probe",
158 + .parts = gumstix_partitions,
159 + .nr_parts = ARRAY_SIZE(gumstix_partitions),
160 + .width = 2,
161 +};
162 +
163 +static struct platform_device gumstix_flash_device = {
164 + .name = "pxa2xx-flash",
165 + .id = 0,
166 + .dev = {
167 + .platform_data = &gumstix_flash_data,
168 + },
169 + .resource = &flash_resource,
170 + .num_resources = 1,
171 +};
172 +
173 +#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) \
174 + || defined(CONFIG_PCMCIA_PXA2XX) || defined(CONFIG_PCMCIA_PXA2XX_MODULE)
175 +
176 +#include <linux/smsc911x.h>
177 +
178 +static struct resource verdex_smsc911x_resources[] = {
179 + [0] = {
180 + .name = "smsc911x-memory",
181 + .start = PXA_CS1_PHYS,
182 + .end = PXA_CS1_PHYS + 0x000fffff,
183 + .flags = IORESOURCE_MEM,
184 + },
185 + [1] = {
186 + .start = PXA_GPIO_TO_IRQ(GPIO_GUMSTIX_ETH0),
187 + .end = PXA_GPIO_TO_IRQ(GPIO_GUMSTIX_ETH0),
188 + .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
189 + },
190 +};
191 +
192 +static struct smsc911x_platform_config verdex_smsc911x_config = {
193 + .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
194 + .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
195 + .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
196 + .phy_interface = PHY_INTERFACE_MODE_MII,
197 +};
198 +
199 +static struct platform_device verdex_smsc911x_device = {
200 + .name = "smsc911x",
201 + .id = -1,
202 + .num_resources = ARRAY_SIZE(verdex_smsc911x_resources),
203 + .resource = verdex_smsc911x_resources,
204 + .dev = {
205 + .platform_data = &verdex_smsc911x_config,
206 + },
207 +};
208 +#endif
209 +
210 +#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
211 +static void __init verdex_init_smsc911x(void)
212 +{
213 +
214 + printk(KERN_INFO "Initializing Gumstix verdex smsc911x\n");
215 +
216 + if (gpio_request(GPIO_GUMSTIX_ETH0_RST, "SMSC911x_ETH0_RST") != 0) {
217 + printk(KERN_ERR "could not obtain gpio for SMSC911x_ETH0_RST\n");
218 + goto err_request_gpio_eth0_rst;
219 + }
220 +
221 + if (gpio_request(GPIO_GUMSTIX_ETH0, "SMSC911x_ETH0_IRQ") != 0) {
222 + printk(KERN_ERR "could not obtain gpio for SMSC911x_ETH0_IRQ\n");
223 + goto err_request_gpio_eth0_irq;
224 + }
225 +
226 + if (gpio_direction_output(GPIO_GUMSTIX_ETH0_RST, 0) != 0) {
227 + printk(KERN_ERR "could not set SMSC911x_ETH0_RST pin to output\n");
228 + goto err_dir;
229 + }
230 +
231 + gpio_set_value(GPIO_GUMSTIX_ETH0_RST, 0);
232 +
233 + msleep(500); // Hold RESET for at least 200ms
234 +
235 + gpio_set_value(GPIO_GUMSTIX_ETH0_RST, 1);
236 +
237 + msleep(50);
238 +
239 + if (gpio_direction_input(GPIO_GUMSTIX_ETH0) != 0) {
240 + printk(KERN_ERR "could not set SMSC911x_ETH0_IRQ pin to input\n");
241 + goto err_dir;
242 + }
243 +
244 + gpio_export(GPIO_GUMSTIX_ETH0, 0);
245 + platform_device_register(&verdex_smsc911x_device);
246 + return;
247 +
248 +err_dir:
249 + gpio_free(GPIO_GUMSTIX_ETH0_RST);
250 +
251 +err_request_gpio_eth0_irq:
252 + gpio_free(GPIO_GUMSTIX_ETH0);
253 +
254 +err_request_gpio_eth0_rst:
255 + return;
256 +}
257 +
258 +#else
259 +static void __init verdex_init_smsc911x(void) { return; }
260 +#endif
261 +
262 +static unsigned long verdex_pin_config[] = {
263 + /* MMC */
264 + GPIO32_MMC_CLK,
265 + GPIO112_MMC_CMD,
266 + GPIO92_MMC_DAT_0,
267 + GPIO109_MMC_DAT_1,
268 + GPIO110_MMC_DAT_2,
269 + GPIO111_MMC_DAT_3,
270 +
271 + /* BTUART */
272 + GPIO42_BTUART_RXD,
273 + GPIO43_BTUART_TXD,
274 + GPIO44_BTUART_CTS,
275 + GPIO45_BTUART_RTS,
276 +
277 + /* STUART */
278 + GPIO46_STUART_RXD,
279 + GPIO47_STUART_TXD,
280 +
281 + /* FFUART */
282 + GPIO34_FFUART_RXD,
283 + GPIO39_FFUART_TXD,
284 +
285 + /* SSP 2 */
286 + GPIO19_SSP2_SCLK,
287 + GPIO14_SSP2_SFRM,
288 + GPIO13_SSP2_TXD,
289 + GPIO11_SSP2_RXD,
290 +
291 + /* SDRAM and local bus */
292 + GPIO49_nPWE,
293 + GPIO15_nCS_1,
294 +
295 + /* I2C */
296 + GPIO117_I2C_SCL,
297 + GPIO118_I2C_SDA,
298 +
299 + /* PWM 0 */
300 + GPIO16_PWM0_OUT,
301 +
302 + /* BRIGHTNESS */
303 + GPIO17_PWM1_OUT,
304 +
305 + /* LCD */
306 + GPIO58_LCD_LDD_0,
307 + GPIO59_LCD_LDD_1,
308 + GPIO60_LCD_LDD_2,
309 + GPIO61_LCD_LDD_3,
310 + GPIO62_LCD_LDD_4,
311 + GPIO63_LCD_LDD_5,
312 + GPIO64_LCD_LDD_6,
313 + GPIO65_LCD_LDD_7,
314 + GPIO66_LCD_LDD_8,
315 + GPIO67_LCD_LDD_9,
316 + GPIO68_LCD_LDD_10,
317 + GPIO69_LCD_LDD_11,
318 + GPIO70_LCD_LDD_12,
319 + GPIO71_LCD_LDD_13,
320 + GPIO72_LCD_LDD_14,
321 + GPIO73_LCD_LDD_15,
322 + GPIO74_LCD_FCLK,
323 + GPIO75_LCD_LCLK,
324 + GPIO76_LCD_PCLK,
325 +#ifdef CONFIG_FB_PXA_SHARP_LQ043_PSP
326 + /* DISP must be always high while screen is on */
327 + /* Done below in verdex_init */
328 +#else
329 + GPIO77_LCD_BIAS,
330 +#endif
331 +};
332 +
333 +#if defined(CONFIG_PCMCIA_PXA2XX) || defined(CONFIG_PCMCIA_PXA2XX_MODULE)
334 +
335 +static unsigned long gpio_ntschg_0[] = {
336 + GPIO104_GPIO, // pxa_gpio_mode(GPIO_GUMSTIX_nCD_0_MD);
337 +};
338 +
339 +static unsigned long gpio_ntschg_1[] = {
340 + GPIO18_GPIO, // pxa_gpio_mode(GPIO_GUMSTIX_nSTSCHG_1_MD);
341 + GPIO36_GPIO, // pxa_gpio_mode(GPIO_GUMSTIX_nCD_1_MD);
342 + GPIO27_GPIO, // pxa_gpio_mode(GPIO_GUMSTIX_PRDY_nBSY_1_MD);
343 +};
344 +
345 +static unsigned long gpio_prdy_nbsy_old[] = {
346 + GPIO111_GPIO, // pxa_gpio_mode(GPIO_GUMSTIX_nSTSCHG_0_MD);
347 + GPIO109_GPIO, // pxa_gpio_mode(GPIO_GUMSTIX_PRDY_nBSY_0_OLD_MD);
348 +};
349 +
350 +static unsigned long gpio_prdy_nbsy[] = {
351 + GPIO96_GPIO, // pxa_gpio_mode(GPIO_GUMSTIX_PRDY_nBSY_0_MD);
352 +};
353 +
354 +static unsigned long gpio_nhw_init[] = {
355 + GPIO48_nPOE, // pxa_gpio_mode(GPIO_GUMSTIX_nPOE_MD);
356 + GPIO102_nPCE_1, // pxa_gpio_mode(GPIO_GUMSTIX_nPCE_1_MD);
357 + GPIO105_nPCE_2, // pxa_gpio_mode(GPIO_GUMSTIX_nPCE_2_MD);
358 + GPIO104_GPIO, // pxa_gpio_mode(GPIO_GUMSTIX_nCD_0_MD);
359 +
360 + GPIO49_nPWE, // pxa_gpio_mode(GPIO_GUMSTIX_nPWE_MD);
361 + GPIO50_nPIOR, // pxa_gpio_mode(GPIO_GUMSTIX_nPIOR_MD);
362 + GPIO51_nPIOW, // pxa_gpio_mode(GPIO_GUMSTIX_nPIOW_MD);
363 + GPIO79_PSKTSEL, // pxa_gpio_mode(GPIO_GUMSTIX_pSKTSEL_MD);
364 + GPIO55_nPREG, // pxa_gpio_mode(GPIO_GUMSTIX_nPREG_MD);
365 + GPIO56_nPWAIT, // pxa_gpio_mode(GPIO_GUMSTIX_nPWAIT_MD);
366 + GPIO57_nIOIS16, // pxa_gpio_mode(GPIO_GUMSTIX_nIOIS16_MD);
367 +};
368 +
369 +static int net_cf_vx_mode = 0;
370 +static int pcmcia_cf_nr = 2;
371 +
372 +inline void __init gumstix_pcmcia_cpld_clk(void)
373 +{
374 + GPCR(GPIO_GUMSTIX_nPOE) = GPIO_bit(GPIO_GUMSTIX_nPOE);
375 + GPSR(GPIO_GUMSTIX_nPOE) = GPIO_bit(GPIO_GUMSTIX_nPOE);
376 +}
377 +
378 +inline unsigned char __init gumstix_pcmcia_cpld_read_bits(int bits)
379 +{
380 + unsigned char result = 0;
381 + unsigned int shift = 0;
382 + while(bits--)
383 + {
384 + result |= !!(GPLR(GPIO_GUMSTIX_nCD_0) & GPIO_bit(GPIO_GUMSTIX_nCD_0)) << shift;
385 + shift ++;
386 + gumstix_pcmcia_cpld_clk();
387 + }
388 + printk("CPLD responded with: %02x\n",result);
389 + return result;
390 +}
391 +
392 +/* We use the CPLD on the CF-CF card to read a value from a shift register. If we can read that
393 + * magic sequence, then we have 2 CF cards; otherwise we assume just one
394 + * The CPLD will send the value of the shift register on GPIO11 (the CD line for slot 0)
395 + * when RESET is held in reset. We use GPIO48 (nPOE) as a clock signal,
396 + * GPIO52/53 (card enable for both cards) to control read/write to the shift register
397 + */
398 +static void __init gumstix_count_cards(void)
399 +{
400 + if ((gpio_request(GPIO_GUMSTIX_nPOE, "GPIO_GUMSTIX_nPOE") == 0) &&
401 + (gpio_direction_output(GPIO_GUMSTIX_nPOE, 1) == 0))
402 + gpio_export(GPIO_GUMSTIX_nPOE, 0);
403 + else
404 + printk(KERN_ERR "could not obtain gpio for GPIO_GUMSTIX_nPOE\n");
405 +
406 + if ((gpio_request(GPIO_GUMSTIX_nPCE_1, "GPIO_GUMSTIX_nPCE_1") == 0) &&
407 + (gpio_direction_output(GPIO_GUMSTIX_nPCE_1, 1) == 0))
408 + gpio_export(GPIO_GUMSTIX_nPCE_1, 0);
409 + else
410 + printk(KERN_ERR "could not obtain gpio for GPIO_GUMSTIX_nPCE_1\n");
411 +
412 + if ((gpio_request(GPIO_GUMSTIX_nPCE_2, "GPIO_GUMSTIX_nPCE_2") == 0) &&
413 + (gpio_direction_output(GPIO_GUMSTIX_nPCE_2, 1) == 0))
414 + gpio_export(GPIO_GUMSTIX_nPCE_2, 0);
415 + else
416 + printk(KERN_ERR "could not obtain gpio for GPIO_GUMSTIX_nPCE_2\n");
417 +
418 + if ((gpio_request(GPIO_GUMSTIX_nCD_0, "GPIO_GUMSTIX_nCD_0") == 0) &&
419 + (gpio_direction_input(GPIO_GUMSTIX_nCD_0) == 0))
420 + gpio_export(GPIO_GUMSTIX_nCD_0, 0);
421 + else
422 + printk(KERN_ERR "could not obtain gpio for GPIO_GUMSTIX_nCD_0\n");
423 +
424 + if (net_cf_vx_mode) {
425 + if ((gpio_request(GPIO_GUMSTIX_CF_OLD_RESET, "GPIO_GUMSTIX_CF_OLD_RESET") == 0) &&
426 + (gpio_direction_output(GPIO_GUMSTIX_CF_OLD_RESET, 1) == 0)) {
427 + gpio_export(GPIO_GUMSTIX_CF_OLD_RESET, 0);
428 + } else {
429 + printk(KERN_ERR "could not obtain gpio for GPIO_GUMSTIX_CF_OLD_RESET\n");
430 + }
431 + } else {
432 + if ((gpio_request(GPIO_GUMSTIX_CF_RESET, "GPIO_GUMSTIX_CF_RESET") == 0) &&
433 + (gpio_direction_output(GPIO_GUMSTIX_CF_RESET, 1) == 0)) {
434 + gpio_export(GPIO_GUMSTIX_CF_RESET, 0);
435 + } else {
436 + printk(KERN_ERR "could not obtain gpio for GPIO_GUMSTIX_CF_RESET\n");
437 + }
438 + }
439 +
440 + // Setup the shift register
441 + GPSR(GPIO_GUMSTIX_nPCE_1) = GPIO_bit(GPIO_GUMSTIX_nPCE_1);
442 + GPCR(GPIO_GUMSTIX_nPCE_2) = GPIO_bit(GPIO_GUMSTIX_nPCE_2);
443 +
444 + // Tick the clock to program the shift register
445 + gumstix_pcmcia_cpld_clk();
446 +
447 + // Now set shift register into read mode
448 + GPCR(GPIO_GUMSTIX_nPCE_1) = GPIO_bit(GPIO_GUMSTIX_nPCE_1);
449 + GPSR(GPIO_GUMSTIX_nPCE_2) = GPIO_bit(GPIO_GUMSTIX_nPCE_2);
450 +
451 + // We can read the bits now -- 0xC2 means "Dual compact flash"
452 + if(gumstix_pcmcia_cpld_read_bits(8) != 0xC2)
453 + {
454 + // We do not have 2 CF slots
455 + pcmcia_cf_nr = 1;
456 + }
457 +
458 + udelay(50);
459 +
460 + if (net_cf_vx_mode) {
461 + gpio_set_value(GPIO_GUMSTIX_CF_OLD_RESET, 0);
462 + gpio_free(GPIO_GUMSTIX_CF_OLD_RESET);
463 + } else {
464 + gpio_set_value(GPIO_GUMSTIX_CF_RESET, 0);
465 + gpio_free(GPIO_GUMSTIX_CF_RESET);
466 + }
467 +
468 + printk(KERN_INFO "found %d CF slots\n", pcmcia_cf_nr);
469 +
470 + gpio_free(GPIO_GUMSTIX_nPCE_2);
471 + gpio_free(GPIO_GUMSTIX_nPCE_1);
472 + gpio_free(GPIO_GUMSTIX_nPOE);
473 + return;
474 +}
475 +
476 +#define SMC_IO_EXTENT 16
477 +#define BANK_SELECT 14
478 +
479 +static void __init verdex_pcmcia_pin_config(void)
480 +{
481 + struct resource *res;
482 + void *network_controller_memory;
483 + struct platform_device *pdev = &verdex_smsc911x_device;
484 +
485 + printk(KERN_INFO "Initializing Gumstix verdex pcmcia\n");
486 +
487 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
488 + if (res == NULL) {
489 + printk(KERN_ERR "no memory resource defined\n");
490 + goto err_done;
491 + }
492 +
493 + res = request_mem_region(res->start, SMC_IO_EXTENT, "smc91x probe");
494 + if (res == NULL) {
495 + printk(KERN_ERR "failed to request memory resource\n");
496 + goto err_done;
497 + }
498 +
499 + // We check for the possibility of SMSC91c111 (reg base offset 0x300 from CS1 base)
500 + network_controller_memory = ioremap(res->start + 0x300, SMC_IO_EXTENT);
501 + if (network_controller_memory == NULL) {
502 + printk(KERN_ERR "failed to ioremap() registers\n");
503 + goto err_free_mem;
504 + }
505 +
506 + // Look for the special 91c111 value in the bank select register
507 + if((0xff00 & readw(network_controller_memory+BANK_SELECT)) == 0x3300) {
508 + printk(KERN_INFO "Detected netCF-vx board: pcmcia using older GPIO configuration\n");
509 + net_cf_vx_mode = 1;
510 + } else {
511 + printk(KERN_INFO "Not netCF-vx board: pcmcia using newer GPIO configuration\n");
512 + net_cf_vx_mode = 0;
513 + }
514 +
515 + iounmap(network_controller_memory);
516 +err_free_mem:
517 + release_mem_region(res->start, SMC_IO_EXTENT);
518 +err_done:
519 +
520 + gumstix_count_cards(); // this can update pcmcia_cf_nr
521 +
522 + // If pcmcia_cf_nr is 1 then we do not have 2 CF slots
523 + // Note: logic sequence was altered from previous kernel revs
524 + // so that this works as intended now.
525 + if (pcmcia_cf_nr != 0)
526 + {
527 + pxa2xx_mfp_config(ARRAY_AND_SIZE(gpio_ntschg_0));
528 +
529 + if(net_cf_vx_mode)
530 + pxa2xx_mfp_config(gpio_prdy_nbsy_old, 1);
531 + else
532 + pxa2xx_mfp_config(gpio_prdy_nbsy, 1);
533 +
534 + } else {
535 + // Note: this reconfigures pin GPIO18 to be GPIO-IN so make
536 + // sure that this only gets done for the old dual slot board
537 + // since that pin is an active AF1 out-mode signal (RDY) on
538 + // newer boards and changing the pin mode on the newer boards
539 + // would result in memory corruption for the NIC (and hang during
540 + // PHY test).
541 + pxa2xx_mfp_config(ARRAY_AND_SIZE(gpio_ntschg_1));
542 + }
543 +
544 + pxa2xx_mfp_config(ARRAY_AND_SIZE(gpio_nhw_init));
545 + return;
546 +}
547 +
548 +int __init gumstix_get_cf_cards(void)
549 +{
550 + return pcmcia_cf_nr;
551 +}
552 +EXPORT_SYMBOL(gumstix_get_cf_cards);
553 +
554 +#ifdef CONFIG_MACH_GUMSTIX_VERDEX
555 +int __init gumstix_check_if_netCF_vx(void)
556 +{
557 + return net_cf_vx_mode;
558 +}
559 +EXPORT_SYMBOL(gumstix_check_if_netCF_vx);
560 +#endif
561 +
562 +#endif
563 +
564 +#if defined(CONFIG_FB_PXA_SHARP_LQ043_PSP) || defined(CONFIG_FB_PXA_SAMSUNG_LTE430WQ_F0C)
565 +static void gumstix_lcd_backlight(int on_or_off)
566 +{
567 + int err;
568 + err = gpio_request(17, "LCD BACKLIGHT");
569 + if (err) {
570 + //pr_warning("Gumstix Verdex: Failed to request LCD Backlight gpio\n");
571 + return;
572 + }
573 +
574 + if(on_or_off) {
575 + gpio_direction_input(17);
576 + } else {
577 + GPCR(17) = GPIO_bit(17);
578 + gpio_direction_output(17, 0);
579 + GPCR(17) = GPIO_bit(17);
580 + }
581 +
582 + return;
583 +}
584 +#endif
585 +
586 +#ifdef CONFIG_FB_PXA_ALPS_CDOLLAR
587 +static struct pxafb_mode_info gumstix_fb_mode = {
588 + .pixclock = 300000,
589 + .xres = 240,
590 + .yres = 320,
591 + .bpp = 16,
592 + .hsync_len = 2,
593 + .left_margin = 1,
594 + .right_margin = 1,
595 + .vsync_len = 3,
596 + .upper_margin = 0,
597 + .lower_margin = 0,
598 + .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
599 +};
600 +
601 +static struct pxafb_mach_info gumstix_fb_info = {
602 + .modes = &gumstix_fb_mode,
603 + .num_modes = 1,
604 + .lccr0 = LCCR0_Pas | LCCR0_Sngl | LCCR0_Color,
605 + .lccr3 = LCCR3_PixFlEdg,
606 +};
607 +#elif defined(CONFIG_FB_PXA_SHARP_LQ043_PSP)
608 +static struct pxafb_mode_info gumstix_fb_mode = {
609 + .pixclock = 110000,
610 + .xres = 480,
611 + .yres = 272,
612 + .bpp = 16,
613 + .hsync_len = 41,
614 + .left_margin = 2,
615 + .right_margin = 2,
616 + .vsync_len = 10,
617 + .upper_margin = 2,
618 + .lower_margin = 2,
619 + .sync = 0, // Hsync and Vsync both active low
620 +};
621 +
622 +static struct pxafb_mach_info gumstix_fb_info = {
623 + .modes = &gumstix_fb_mode,
624 + .num_modes = 1,
625 + .lccr0 = LCCR0_Act | LCCR0_Sngl | LCCR0_Color,
626 + .lccr3 = LCCR3_OutEnH | LCCR3_PixFlEdg | (0 << 30),
627 + .pxafb_backlight_power = &gumstix_lcd_backlight,
628 +};
629 +#elif defined(CONFIG_FB_PXA_SAMSUNG_LTE430WQ_F0C)
630 +static struct pxafb_mode_info gumstix_fb_mode = {
631 + .pixclock = 108696, // 9.2MHz typical DOTCLK from datasheet
632 + .xres = 480,
633 + .hsync_len = 41, // HLW from datasheet: 41 typ
634 + .left_margin = 4, // HBP - HLW from datasheet: 45 - 41 = 4
635 + .right_margin = 8, // HFP from datasheet: 8 typ
636 + .yres = 272,
637 + .vsync_len = 10, // VLW from datasheet: 10 typ
638 + .upper_margin = 2, // VBP - VLW from datasheet: 12 - 10 = 2
639 + .lower_margin = 4, // VFP from datasheet: 4 typ
640 + .bpp = 16,
641 + .sync = 0, // Hsync and Vsync both active low
642 +};
643 +
644 +static struct pxafb_mach_info gumstix_fb_info = {
645 + .modes = &gumstix_fb_mode,
646 + .num_modes = 1,
647 + .lccr0 = LCCR0_Act | LCCR0_Sngl | LCCR0_Color,
648 + .lccr3 = LCCR3_OutEnH | LCCR3_PixFlEdg | (0 << 30),
649 + .pxafb_backlight_power = &gumstix_lcd_backlight,
650 +};
651 +#endif
652 +
653 +static struct platform_device verdex_audio_device = {
654 + .name = "pxa2xx-ac97",
655 + .id = -1,
656 +};
657 +
658 +static struct platform_device *devices[] __initdata = {
659 + &gumstix_flash_device,
660 + &verdex_audio_device,
661 +};
662 +
663 +/* PXA27x OHCI controller setup */
664 +#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
665 +static int ohci_verdex_init(struct device *dev)
666 +{
667 + // Turn on port 2 in host mode
668 + UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
669 +
670 + /* See drivers/usb/host/ohci-pxa27x.c for further details but
671 + ENABLE_PORT_ALL flag is equivalent to using this old sequence:
672 + UHCHR = (UHCHR) &
673 + ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
674 + */
675 + return 0;
676 +}
677 +
678 +static struct pxaohci_platform_data verdex_ohci_platform_data = {
679 + .port_mode = PMM_PERPORT_MODE,
680 + .flags = ENABLE_PORT_ALL,
681 + .init = ohci_verdex_init,
682 +};
683 +
684 +static void __init verdex_ohci_init(void)
685 +{
686 + pxa_set_ohci_info(&verdex_ohci_platform_data);
687 +}
688 +#else
689 +static void __init verdex_ohci_init(void) {
690 + printk(KERN_INFO "Gumstix verdex host usb ohci is disabled\n");
691 +}
692 +#endif
693 +
694 +
695 +#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
696 +static struct pxamci_platform_data verdex_mci_platform_data;
697 +
698 +static int verdex_mci_init(struct device *dev, irq_handler_t detect_int,
699 + void *data)
700 +{
701 + /* GPIO setup for MMC on the 120-pin connector is done in verdex_init.
702 + * There is no card detect on a uSD connector so no interrupt to
703 + * register. There is no WP detect GPIO line either.
704 + */
705 +
706 + return 0;
707 +}
708 +
709 +static struct pxamci_platform_data verdex_mci_platform_data = {
710 + .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
711 + .init = verdex_mci_init,
712 + .gpio_card_detect = -1,
713 + .gpio_card_ro = -1,
714 + .gpio_power = -1,
715 +};
716 +
717 +static void __init verdex_mmc_init(void)
718 +{
719 + pxa_set_mci_info(&verdex_mci_platform_data);
720 +}
721 +#else
722 +static void __init verdex_mmc_init(void)
723 +{
724 + printk(KERN_INFO "Gumstix verdex mmc disabled\n");
725 +}
726 +#endif
727 +
728 +#if defined(CONFIG_USB_GADGET_PXA2XX) || defined(CONFIG_USB_GADGET_PXA2XX_MODULE)
729 +static struct pxa2xx_udc_mach_info verdex_udc_info __initdata = {
730 + .gpio_vbus = GPIO35,
731 + .gpio_pullup = GPIO41,
732 +};
733 +
734 +static void __init verdex_udc_init(void)
735 +{
736 + pxa_set_udc_info(&verdex_udc_info);
737 +}
738 +#else
739 +static void __init verdex_udc_init(void)
740 +{
741 + printk(KERN_INFO "Gumstix verdex udc is disabled\n");
742 +}
743 +#endif
744 +
745 +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
746 +
747 +#if defined(CONFIG_TOUCHSCREEN_TSC2003) || defined(CONFIG_TOUCHSCREEN_TSC2003_MODULE)
748 +
749 +#define VERDEX_GPIO_PENDOWN 16
750 +
751 +static int tsc2003_init_platform_hw(void)
752 +{
753 + return 0;
754 +}
755 +
756 +static void tsc2003_exit_platform_hw(void)
757 +{
758 + return;
759 +}
760 +
761 +static void tsc2003_clear_penirq(void)
762 +{
763 + return;
764 +}
765 +
766 +static int tsc2003_get_pendown_state(void)
767 +{
768 + return !gpio_get_value(VERDEX_GPIO_PENDOWN);
769 +}
770 +
771 +static struct tsc2007_platform_data tsc2003_config = {
772 + .model = 2003,
773 + .x_plate_ohms = 100,
774 + .get_pendown_state = tsc2003_get_pendown_state,
775 + .clear_penirq = tsc2003_clear_penirq,
776 + .init_platform_hw = tsc2003_init_platform_hw,
777 + .exit_platform_hw = tsc2003_exit_platform_hw,
778 +};
779 +#endif
780 +
781 +static struct i2c_board_info __initdata verdex_i2c_board_info[] = {
782 +#if defined(CONFIG_RTC_DRV_DS1307) || defined(CONFIG_RTC_DRV_DS1307_MODULE)
783 + {
784 + I2C_BOARD_INFO("rtc-ds1307", 0x68),
785 + },
786 +#endif
787 +#if defined(CONFIG_TOUCHSCREEN_TSC2003) || defined(CONFIG_TOUCHSCREEN_TSC2003_MODULE)
788 + {
789 + I2C_BOARD_INFO("tsc2003", 0x48),
790 + .platform_data = &tsc2003_config,
791 + .irq = IRQ_GPIO(VERDEX_GPIO_PENDOWN),
792 + },
793 +#endif
794 +};
795 +
796 +static struct i2c_pxa_platform_data verdex_i2c_pwr_info = {
797 + .fast_mode = 1,
798 +};
799 +
800 +static struct i2c_pxa_platform_data verdex_i2c_info = {
801 + .fast_mode = 1,
802 +};
803 +
804 +static void __init verdex_i2c_init(void)
805 +{
806 + printk(KERN_INFO "Initializing Gumstix verdex i2c\n");
807 +
808 +#if defined(CONFIG_TOUCHSCREEN_TSC2003) || defined(CONFIG_TOUCHSCREEN_TSC2003_MODULE)
809 + if ((gpio_request(VERDEX_GPIO_PENDOWN, "TSC2003_PENDOWN") == 0) &&
810 + (gpio_direction_input(VERDEX_GPIO_PENDOWN) == 0)) {
811 + gpio_export(VERDEX_GPIO_PENDOWN, 0);
812 + } else {
813 + printk(KERN_ERR "could not obtain gpio for TSC2003_PENDOWN\n");
814 + return;
815 + }
816 +#endif
817 +
818 + i2c_register_board_info(0, verdex_i2c_board_info,
819 + ARRAY_SIZE(verdex_i2c_board_info));
820 + pxa_set_i2c_info(&verdex_i2c_info);
821 + pxa27x_set_i2c_power_info(&verdex_i2c_pwr_info);
822 +}
823 +#else
824 +static inline void verdex_i2c_init(void) {}
825 +#endif
826 +
827 +#if defined(CONFIG_PCMCIA_PXA2XX) || defined(CONFIG_PCMCIA_PXA2XX_MODULE)
828 +static void __init verdex_pcmcia_init(void)
829 +{
830 + verdex_pcmcia_pin_config();
831 +}
832 +#else
833 +static void __init verdex_pcmcia_init(void) {
834 + printk(KERN_INFO "Gumstix verdex pcmcia is disabled\n");
835 +}
836 +#endif
837 +
838 +
839 +static void __init verdex_init(void)
840 +{
841 + pxa2xx_mfp_config(ARRAY_AND_SIZE(verdex_pin_config));
842 +
843 +#ifdef CONFIG_FB_PXA_SHARP_LQ043_PSP
844 + /* DISP must be always high while screen is on */
845 + gpio_direction_output(GPIO77, 0);
846 + GPSR(GPIO77) = GPIO_bit(GPIO77);
847 +#endif
848 + verdex_udc_init();
849 + verdex_mmc_init();
850 + verdex_ohci_init();
851 + verdex_i2c_init();
852 + verdex_init_smsc911x();
853 + verdex_pcmcia_init();
854 +
855 +#if defined(CONFIG_FB_PXA_ALPS_CDOLLAR) || defined(CONFIG_FB_PXA_SHARP_LQ043_PSP) || defined(CONFIG_FB_PXA_SAMSUNG_LTE430WQ_F0C)
856 + printk(KERN_INFO "Initializing Gumstix verdex FB info\n");
857 + set_pxa_fb_info(&gumstix_fb_info);
858 +#endif
859 + printk(KERN_INFO "Initializing Gumstix platform_add_devices\n");
860 + (void) platform_add_devices(devices, ARRAY_SIZE(devices));
861 +}
862 +
863 +MACHINE_START(GUMSTIX, "Gumstix verdex")
864 + .atag_offset = 0x100, /* match u-boot bi_boot_params */
865 + .map_io = pxa27x_map_io,
866 + .init_irq = pxa27x_init_irq,
867 + .handle_irq = pxa27x_handle_irq,
868 + .timer = &pxa_timer,
869 + .init_machine = verdex_init,
870 + .restart = pxa_restart,
871 +MACHINE_END
872 --- a/arch/arm/mach-pxa/include/mach/mfp-pxa27x.h
873 +++ b/arch/arm/mach-pxa/include/mach/mfp-pxa27x.h
874 @@ -109,6 +109,7 @@
875 #define GPIO54_nPCE_2 MFP_CFG_OUT(GPIO54, AF2, DRIVE_HIGH)
876 #define GPIO78_nPCE_2 MFP_CFG_OUT(GPIO78, AF1, DRIVE_HIGH)
877 #define GPIO87_nPCE_2 MFP_CFG_IN(GPIO87, AF1)
878 +#define GPIO105_nPCE_2 MFP_CFG_OUT(GPIO105, AF1, DRIVE_HIGH)
879 #define GPIO55_nPREG MFP_CFG_OUT(GPIO55, AF2, DRIVE_HIGH)
880 #define GPIO50_nPIOR MFP_CFG_OUT(GPIO50, AF2, DRIVE_HIGH)
881 #define GPIO51_nPIOW MFP_CFG_OUT(GPIO51, AF2, DRIVE_HIGH)