MIPS: Yosemite, Emma: Fix off-by-two in arcs_cmdline buffer size check
[linux-2.6/linux-mips.git] / arch / arm / mach-pxa / vpac270.c
bloba7539a6ed1ff2a5d1ce4a460183a17fe28900e45
1 /*
2 * Hardware definitions for Voipac PXA270
4 * Copyright (C) 2010
5 * Marek Vasut <marek.vasut@gmail.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
13 #include <linux/platform_device.h>
14 #include <linux/delay.h>
15 #include <linux/irq.h>
16 #include <linux/gpio_keys.h>
17 #include <linux/input.h>
18 #include <linux/gpio.h>
19 #include <linux/usb/gpio_vbus.h>
20 #include <linux/mtd/mtd.h>
21 #include <linux/mtd/partitions.h>
22 #include <linux/mtd/physmap.h>
23 #include <linux/mtd/onenand.h>
24 #include <linux/dm9000.h>
25 #include <linux/ucb1400.h>
26 #include <linux/ata_platform.h>
27 #include <linux/regulator/max1586.h>
28 #include <linux/i2c/pxa-i2c.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
33 #include <mach/pxa27x.h>
34 #include <mach/audio.h>
35 #include <mach/vpac270.h>
36 #include <mach/mmc.h>
37 #include <mach/pxafb.h>
38 #include <mach/ohci.h>
39 #include <mach/pxa27x-udc.h>
40 #include <mach/udc.h>
41 #include <mach/pata_pxa.h>
43 #include "generic.h"
44 #include "devices.h"
46 /******************************************************************************
47 * Pin configuration
48 ******************************************************************************/
49 static unsigned long vpac270_pin_config[] __initdata = {
50 /* MMC */
51 GPIO32_MMC_CLK,
52 GPIO92_MMC_DAT_0,
53 GPIO109_MMC_DAT_1,
54 GPIO110_MMC_DAT_2,
55 GPIO111_MMC_DAT_3,
56 GPIO112_MMC_CMD,
57 GPIO53_GPIO, /* SD detect */
58 GPIO52_GPIO, /* SD r/o switch */
60 /* GPIO KEYS */
61 GPIO1_GPIO, /* USER BTN */
63 /* LEDs */
64 GPIO15_GPIO, /* orange led */
66 /* FFUART */
67 GPIO34_FFUART_RXD,
68 GPIO39_FFUART_TXD,
69 GPIO27_FFUART_RTS,
70 GPIO100_FFUART_CTS,
71 GPIO33_FFUART_DSR,
72 GPIO40_FFUART_DTR,
73 GPIO10_FFUART_DCD,
74 GPIO38_FFUART_RI,
76 /* LCD */
77 GPIO58_LCD_LDD_0,
78 GPIO59_LCD_LDD_1,
79 GPIO60_LCD_LDD_2,
80 GPIO61_LCD_LDD_3,
81 GPIO62_LCD_LDD_4,
82 GPIO63_LCD_LDD_5,
83 GPIO64_LCD_LDD_6,
84 GPIO65_LCD_LDD_7,
85 GPIO66_LCD_LDD_8,
86 GPIO67_LCD_LDD_9,
87 GPIO68_LCD_LDD_10,
88 GPIO69_LCD_LDD_11,
89 GPIO70_LCD_LDD_12,
90 GPIO71_LCD_LDD_13,
91 GPIO72_LCD_LDD_14,
92 GPIO73_LCD_LDD_15,
93 GPIO86_LCD_LDD_16,
94 GPIO87_LCD_LDD_17,
95 GPIO74_LCD_FCLK,
96 GPIO75_LCD_LCLK,
97 GPIO76_LCD_PCLK,
98 GPIO77_LCD_BIAS,
100 /* PCMCIA */
101 GPIO48_nPOE,
102 GPIO49_nPWE,
103 GPIO50_nPIOR,
104 GPIO51_nPIOW,
105 GPIO85_nPCE_1,
106 GPIO54_nPCE_2,
107 GPIO55_nPREG,
108 GPIO57_nIOIS16,
109 GPIO56_nPWAIT,
110 GPIO104_PSKTSEL,
111 GPIO84_GPIO, /* PCMCIA CD */
112 GPIO35_GPIO, /* PCMCIA RDY */
113 GPIO107_GPIO, /* PCMCIA PPEN */
114 GPIO11_GPIO, /* PCMCIA RESET */
115 GPIO17_GPIO, /* CF CD */
116 GPIO12_GPIO, /* CF RDY */
117 GPIO16_GPIO, /* CF RESET */
119 /* UHC */
120 GPIO88_USBH1_PWR,
121 GPIO89_USBH1_PEN,
122 GPIO119_USBH2_PWR,
123 GPIO120_USBH2_PEN,
125 /* UDC */
126 GPIO41_GPIO,
128 /* Ethernet */
129 GPIO114_GPIO, /* IRQ */
131 /* AC97 */
132 GPIO28_AC97_BITCLK,
133 GPIO29_AC97_SDATA_IN_0,
134 GPIO30_AC97_SDATA_OUT,
135 GPIO31_AC97_SYNC,
136 GPIO95_AC97_nRESET,
137 GPIO98_AC97_SYSCLK,
138 GPIO113_GPIO, /* TS IRQ */
140 /* I2C */
141 GPIO117_I2C_SCL,
142 GPIO118_I2C_SDA,
144 /* IDE */
145 GPIO36_GPIO, /* IDE IRQ */
146 GPIO80_DREQ_1,
149 /******************************************************************************
150 * NOR Flash
151 ******************************************************************************/
152 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
153 static struct mtd_partition vpac270_nor_partitions[] = {
155 .name = "Flash",
156 .offset = 0x00000000,
157 .size = MTDPART_SIZ_FULL,
161 static struct physmap_flash_data vpac270_flash_data[] = {
163 .width = 2, /* bankwidth in bytes */
164 .parts = vpac270_nor_partitions,
165 .nr_parts = ARRAY_SIZE(vpac270_nor_partitions)
169 static struct resource vpac270_flash_resource = {
170 .start = PXA_CS0_PHYS,
171 .end = PXA_CS0_PHYS + SZ_64M - 1,
172 .flags = IORESOURCE_MEM,
175 static struct platform_device vpac270_flash = {
176 .name = "physmap-flash",
177 .id = 0,
178 .resource = &vpac270_flash_resource,
179 .num_resources = 1,
180 .dev = {
181 .platform_data = vpac270_flash_data,
184 static void __init vpac270_nor_init(void)
186 platform_device_register(&vpac270_flash);
188 #else
189 static inline void vpac270_nor_init(void) {}
190 #endif
192 /******************************************************************************
193 * OneNAND Flash
194 ******************************************************************************/
195 #if defined(CONFIG_MTD_ONENAND) || defined(CONFIG_MTD_ONENAND_MODULE)
196 static struct mtd_partition vpac270_onenand_partitions[] = {
198 .name = "Flash",
199 .offset = 0x00000000,
200 .size = MTDPART_SIZ_FULL,
204 static struct onenand_platform_data vpac270_onenand_info = {
205 .parts = vpac270_onenand_partitions,
206 .nr_parts = ARRAY_SIZE(vpac270_onenand_partitions),
209 static struct resource vpac270_onenand_resources[] = {
210 [0] = {
211 .start = PXA_CS0_PHYS,
212 .end = PXA_CS0_PHYS + SZ_1M,
213 .flags = IORESOURCE_MEM,
217 static struct platform_device vpac270_onenand = {
218 .name = "onenand-flash",
219 .id = -1,
220 .resource = vpac270_onenand_resources,
221 .num_resources = ARRAY_SIZE(vpac270_onenand_resources),
222 .dev = {
223 .platform_data = &vpac270_onenand_info,
227 static void __init vpac270_onenand_init(void)
229 platform_device_register(&vpac270_onenand);
231 #else
232 static void __init vpac270_onenand_init(void) {}
233 #endif
235 /******************************************************************************
236 * SD/MMC card controller
237 ******************************************************************************/
238 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
239 static struct pxamci_platform_data vpac270_mci_platform_data = {
240 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
241 .gpio_power = -1,
242 .gpio_card_detect = GPIO53_VPAC270_SD_DETECT_N,
243 .gpio_card_ro = GPIO52_VPAC270_SD_READONLY,
244 .detect_delay_ms = 200,
247 static void __init vpac270_mmc_init(void)
249 pxa_set_mci_info(&vpac270_mci_platform_data);
251 #else
252 static inline void vpac270_mmc_init(void) {}
253 #endif
255 /******************************************************************************
256 * GPIO keys
257 ******************************************************************************/
258 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
259 static struct gpio_keys_button vpac270_pxa_buttons[] = {
260 {KEY_POWER, GPIO1_VPAC270_USER_BTN, 0, "USER BTN"},
263 static struct gpio_keys_platform_data vpac270_pxa_keys_data = {
264 .buttons = vpac270_pxa_buttons,
265 .nbuttons = ARRAY_SIZE(vpac270_pxa_buttons),
268 static struct platform_device vpac270_pxa_keys = {
269 .name = "gpio-keys",
270 .id = -1,
271 .dev = {
272 .platform_data = &vpac270_pxa_keys_data,
276 static void __init vpac270_keys_init(void)
278 platform_device_register(&vpac270_pxa_keys);
280 #else
281 static inline void vpac270_keys_init(void) {}
282 #endif
284 /******************************************************************************
285 * LED
286 ******************************************************************************/
287 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
288 struct gpio_led vpac270_gpio_leds[] = {
290 .name = "vpac270:orange:user",
291 .default_trigger = "none",
292 .gpio = GPIO15_VPAC270_LED_ORANGE,
293 .active_low = 1,
297 static struct gpio_led_platform_data vpac270_gpio_led_info = {
298 .leds = vpac270_gpio_leds,
299 .num_leds = ARRAY_SIZE(vpac270_gpio_leds),
302 static struct platform_device vpac270_leds = {
303 .name = "leds-gpio",
304 .id = -1,
305 .dev = {
306 .platform_data = &vpac270_gpio_led_info,
310 static void __init vpac270_leds_init(void)
312 platform_device_register(&vpac270_leds);
314 #else
315 static inline void vpac270_leds_init(void) {}
316 #endif
318 /******************************************************************************
319 * USB Host
320 ******************************************************************************/
321 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
322 static int vpac270_ohci_init(struct device *dev)
324 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
325 return 0;
328 static struct pxaohci_platform_data vpac270_ohci_info = {
329 .port_mode = PMM_PERPORT_MODE,
330 .flags = ENABLE_PORT1 | ENABLE_PORT2 |
331 POWER_CONTROL_LOW | POWER_SENSE_LOW,
332 .init = vpac270_ohci_init,
335 static void __init vpac270_uhc_init(void)
337 pxa_set_ohci_info(&vpac270_ohci_info);
339 #else
340 static inline void vpac270_uhc_init(void) {}
341 #endif
343 /******************************************************************************
344 * USB Gadget
345 ******************************************************************************/
346 #if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE)
347 static struct gpio_vbus_mach_info vpac270_gpio_vbus_info = {
348 .gpio_vbus = GPIO41_VPAC270_UDC_DETECT,
349 .gpio_pullup = -1,
352 static struct platform_device vpac270_gpio_vbus = {
353 .name = "gpio-vbus",
354 .id = -1,
355 .dev = {
356 .platform_data = &vpac270_gpio_vbus_info,
360 static void vpac270_udc_command(int cmd)
362 if (cmd == PXA2XX_UDC_CMD_CONNECT)
363 UP2OCR = UP2OCR_HXOE | UP2OCR_DPPUE;
364 else if (cmd == PXA2XX_UDC_CMD_DISCONNECT)
365 UP2OCR = UP2OCR_HXOE;
368 static struct pxa2xx_udc_mach_info vpac270_udc_info __initdata = {
369 .udc_command = vpac270_udc_command,
370 .gpio_pullup = -1,
373 static void __init vpac270_udc_init(void)
375 pxa_set_udc_info(&vpac270_udc_info);
376 platform_device_register(&vpac270_gpio_vbus);
378 #else
379 static inline void vpac270_udc_init(void) {}
380 #endif
382 /******************************************************************************
383 * Ethernet
384 ******************************************************************************/
385 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
386 static struct resource vpac270_dm9000_resources[] = {
387 [0] = {
388 .start = PXA_CS2_PHYS + 0x300,
389 .end = PXA_CS2_PHYS + 0x303,
390 .flags = IORESOURCE_MEM,
392 [1] = {
393 .start = PXA_CS2_PHYS + 0x304,
394 .end = PXA_CS2_PHYS + 0x343,
395 .flags = IORESOURCE_MEM,
397 [2] = {
398 .start = IRQ_GPIO(GPIO114_VPAC270_ETH_IRQ),
399 .end = IRQ_GPIO(GPIO114_VPAC270_ETH_IRQ),
400 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
404 static struct dm9000_plat_data vpac270_dm9000_platdata = {
405 .flags = DM9000_PLATF_32BITONLY,
408 static struct platform_device vpac270_dm9000_device = {
409 .name = "dm9000",
410 .id = -1,
411 .num_resources = ARRAY_SIZE(vpac270_dm9000_resources),
412 .resource = vpac270_dm9000_resources,
413 .dev = {
414 .platform_data = &vpac270_dm9000_platdata,
418 static void __init vpac270_eth_init(void)
420 platform_device_register(&vpac270_dm9000_device);
422 #else
423 static inline void vpac270_eth_init(void) {}
424 #endif
426 /******************************************************************************
427 * Audio and Touchscreen
428 ******************************************************************************/
429 #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
430 defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
431 static pxa2xx_audio_ops_t vpac270_ac97_pdata = {
432 .reset_gpio = 95,
435 static struct ucb1400_pdata vpac270_ucb1400_pdata = {
436 .irq = IRQ_GPIO(GPIO113_VPAC270_TS_IRQ),
439 static struct platform_device vpac270_ucb1400_device = {
440 .name = "ucb1400_core",
441 .id = -1,
442 .dev = {
443 .platform_data = &vpac270_ucb1400_pdata,
447 static void __init vpac270_ts_init(void)
449 pxa_set_ac97_info(&vpac270_ac97_pdata);
450 platform_device_register(&vpac270_ucb1400_device);
452 #else
453 static inline void vpac270_ts_init(void) {}
454 #endif
456 /******************************************************************************
457 * RTC
458 ******************************************************************************/
459 #if defined(CONFIG_RTC_DRV_DS1307) || defined(CONFIG_RTC_DRV_DS1307_MODULE)
460 static struct i2c_board_info __initdata vpac270_i2c_devs[] = {
462 I2C_BOARD_INFO("ds1339", 0x68),
466 static void __init vpac270_rtc_init(void)
468 i2c_register_board_info(0, ARRAY_AND_SIZE(vpac270_i2c_devs));
470 #else
471 static inline void vpac270_rtc_init(void) {}
472 #endif
474 /******************************************************************************
475 * Framebuffer
476 ******************************************************************************/
477 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
478 static struct pxafb_mode_info vpac270_lcd_modes[] = {
480 .pixclock = 57692,
481 .xres = 640,
482 .yres = 480,
483 .bpp = 32,
484 .depth = 18,
486 .left_margin = 144,
487 .right_margin = 32,
488 .upper_margin = 13,
489 .lower_margin = 30,
491 .hsync_len = 32,
492 .vsync_len = 2,
494 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
495 }, { /* CRT 640x480 */
496 .pixclock = 35000,
497 .xres = 640,
498 .yres = 480,
499 .bpp = 16,
500 .depth = 16,
502 .left_margin = 96,
503 .right_margin = 48,
504 .upper_margin = 33,
505 .lower_margin = 10,
507 .hsync_len = 48,
508 .vsync_len = 1,
510 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
511 }, { /* CRT 800x600 H=30kHz V=48HZ */
512 .pixclock = 25000,
513 .xres = 800,
514 .yres = 600,
515 .bpp = 16,
516 .depth = 16,
518 .left_margin = 50,
519 .right_margin = 1,
520 .upper_margin = 21,
521 .lower_margin = 12,
523 .hsync_len = 8,
524 .vsync_len = 1,
526 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
527 }, { /* CRT 1024x768 H=40kHz V=50Hz */
528 .pixclock = 15000,
529 .xres = 1024,
530 .yres = 768,
531 .bpp = 16,
532 .depth = 16,
534 .left_margin = 220,
535 .right_margin = 8,
536 .upper_margin = 33,
537 .lower_margin = 2,
539 .hsync_len = 48,
540 .vsync_len = 1,
542 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
546 static struct pxafb_mach_info vpac270_lcd_screen = {
547 .modes = vpac270_lcd_modes,
548 .num_modes = ARRAY_SIZE(vpac270_lcd_modes),
549 .lcd_conn = LCD_COLOR_TFT_18BPP,
552 static void vpac270_lcd_power(int on, struct fb_var_screeninfo *info)
554 gpio_set_value(GPIO81_VPAC270_BKL_ON, on);
557 static void __init vpac270_lcd_init(void)
559 int ret;
561 ret = gpio_request(GPIO81_VPAC270_BKL_ON, "BKL-ON");
562 if (ret) {
563 pr_err("Requesting BKL-ON GPIO failed!\n");
564 goto err;
567 ret = gpio_direction_output(GPIO81_VPAC270_BKL_ON, 1);
568 if (ret) {
569 pr_err("Setting BKL-ON GPIO direction failed!\n");
570 goto err2;
573 vpac270_lcd_screen.pxafb_lcd_power = vpac270_lcd_power;
574 pxa_set_fb_info(NULL, &vpac270_lcd_screen);
575 return;
577 err2:
578 gpio_free(GPIO81_VPAC270_BKL_ON);
579 err:
580 return;
582 #else
583 static inline void vpac270_lcd_init(void) {}
584 #endif
586 /******************************************************************************
587 * PATA IDE
588 ******************************************************************************/
589 #if defined(CONFIG_PATA_PXA) || defined(CONFIG_PATA_PXA_MODULE)
590 static struct pata_pxa_pdata vpac270_pata_pdata = {
591 .reg_shift = 1,
592 .dma_dreq = 1,
593 .irq_flags = IRQF_TRIGGER_RISING,
596 static struct resource vpac270_ide_resources[] = {
597 [0] = { /* I/O Base address */
598 .start = PXA_CS3_PHYS + 0x120,
599 .end = PXA_CS3_PHYS + 0x13f,
600 .flags = IORESOURCE_MEM
602 [1] = { /* CTL Base address */
603 .start = PXA_CS3_PHYS + 0x15c,
604 .end = PXA_CS3_PHYS + 0x15f,
605 .flags = IORESOURCE_MEM
607 [2] = { /* DMA Base address */
608 .start = PXA_CS3_PHYS + 0x20,
609 .end = PXA_CS3_PHYS + 0x2f,
610 .flags = IORESOURCE_DMA
612 [3] = { /* IDE IRQ pin */
613 .start = gpio_to_irq(GPIO36_VPAC270_IDE_IRQ),
614 .end = gpio_to_irq(GPIO36_VPAC270_IDE_IRQ),
615 .flags = IORESOURCE_IRQ
619 static struct platform_device vpac270_ide_device = {
620 .name = "pata_pxa",
621 .num_resources = ARRAY_SIZE(vpac270_ide_resources),
622 .resource = vpac270_ide_resources,
623 .dev = {
624 .platform_data = &vpac270_pata_pdata,
625 .coherent_dma_mask = 0xffffffff,
629 static void __init vpac270_ide_init(void)
631 platform_device_register(&vpac270_ide_device);
633 #else
634 static inline void vpac270_ide_init(void) {}
635 #endif
637 /******************************************************************************
638 * Core power regulator
639 ******************************************************************************/
640 #if defined(CONFIG_REGULATOR_MAX1586) || \
641 defined(CONFIG_REGULATOR_MAX1586_MODULE)
642 static struct regulator_consumer_supply vpac270_max1587a_consumers[] = {
644 .supply = "vcc_core",
648 static struct regulator_init_data vpac270_max1587a_v3_info = {
649 .constraints = {
650 .name = "vcc_core range",
651 .min_uV = 900000,
652 .max_uV = 1705000,
653 .always_on = 1,
654 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
656 .consumer_supplies = vpac270_max1587a_consumers,
657 .num_consumer_supplies = ARRAY_SIZE(vpac270_max1587a_consumers),
660 static struct max1586_subdev_data vpac270_max1587a_subdevs[] = {
662 .name = "vcc_core",
663 .id = MAX1586_V3,
664 .platform_data = &vpac270_max1587a_v3_info,
668 static struct max1586_platform_data vpac270_max1587a_info = {
669 .subdevs = vpac270_max1587a_subdevs,
670 .num_subdevs = ARRAY_SIZE(vpac270_max1587a_subdevs),
671 .v3_gain = MAX1586_GAIN_R24_3k32, /* 730..1550 mV */
674 static struct i2c_board_info __initdata vpac270_pi2c_board_info[] = {
676 I2C_BOARD_INFO("max1586", 0x14),
677 .platform_data = &vpac270_max1587a_info,
681 static void __init vpac270_pmic_init(void)
683 i2c_register_board_info(1, ARRAY_AND_SIZE(vpac270_pi2c_board_info));
685 #else
686 static inline void vpac270_pmic_init(void) {}
687 #endif
690 /******************************************************************************
691 * Machine init
692 ******************************************************************************/
693 static void __init vpac270_init(void)
695 pxa2xx_mfp_config(ARRAY_AND_SIZE(vpac270_pin_config));
697 pxa_set_ffuart_info(NULL);
698 pxa_set_btuart_info(NULL);
699 pxa_set_stuart_info(NULL);
700 pxa_set_i2c_info(NULL);
701 pxa27x_set_i2c_power_info(NULL);
703 vpac270_pmic_init();
704 vpac270_lcd_init();
705 vpac270_mmc_init();
706 vpac270_nor_init();
707 vpac270_onenand_init();
708 vpac270_leds_init();
709 vpac270_keys_init();
710 vpac270_uhc_init();
711 vpac270_udc_init();
712 vpac270_eth_init();
713 vpac270_ts_init();
714 vpac270_rtc_init();
715 vpac270_ide_init();
718 MACHINE_START(VPAC270, "Voipac PXA270")
719 .atag_offset = 0x100,
720 .map_io = pxa27x_map_io,
721 .init_irq = pxa27x_init_irq,
722 .handle_irq = pxa27x_handle_irq,
723 .timer = &pxa_timer,
724 .init_machine = vpac270_init
725 MACHINE_END