1
2
3
4
5
6
7
8
9#include <linux/platform_device.h>
10#include <linux/delay.h>
11#include <linux/irq.h>
12#include <linux/gpio_keys.h>
13#include <linux/input.h>
14#include <linux/leds.h>
15#include <linux/gpio.h>
16#include <linux/gpio/machine.h>
17#include <linux/usb/gpio_vbus.h>
18#include <linux/mtd/mtd.h>
19#include <linux/mtd/partitions.h>
20#include <linux/mtd/physmap.h>
21#include <linux/mtd/onenand.h>
22#include <linux/dm9000.h>
23#include <linux/ucb1400.h>
24#include <linux/ata_platform.h>
25#include <linux/regulator/machine.h>
26#include <linux/regulator/max1586.h>
27#include <linux/platform_data/i2c-pxa.h>
28
29#include <asm/mach-types.h>
30#include <asm/mach/arch.h>
31
32#include "pxa27x.h"
33#include <mach/audio.h>
34#include <mach/vpac270.h>
35#include <linux/platform_data/mmc-pxamci.h>
36#include <linux/platform_data/video-pxafb.h>
37#include <linux/platform_data/usb-ohci-pxa27x.h>
38#include "pxa27x-udc.h"
39#include "udc.h"
40#include <linux/platform_data/ata-pxa.h>
41
42#include "generic.h"
43#include "devices.h"
44
45
46
47
48static unsigned long vpac270_pin_config[] __initdata = {
49
50 GPIO32_MMC_CLK,
51 GPIO92_MMC_DAT_0,
52 GPIO109_MMC_DAT_1,
53 GPIO110_MMC_DAT_2,
54 GPIO111_MMC_DAT_3,
55 GPIO112_MMC_CMD,
56 GPIO53_GPIO,
57 GPIO52_GPIO,
58
59
60 GPIO1_GPIO,
61
62
63 GPIO15_GPIO,
64
65
66 GPIO34_FFUART_RXD,
67 GPIO39_FFUART_TXD,
68 GPIO27_FFUART_RTS,
69 GPIO100_FFUART_CTS,
70 GPIO33_FFUART_DSR,
71 GPIO40_FFUART_DTR,
72 GPIO10_FFUART_DCD,
73 GPIO38_FFUART_RI,
74
75
76 GPIO58_LCD_LDD_0,
77 GPIO59_LCD_LDD_1,
78 GPIO60_LCD_LDD_2,
79 GPIO61_LCD_LDD_3,
80 GPIO62_LCD_LDD_4,
81 GPIO63_LCD_LDD_5,
82 GPIO64_LCD_LDD_6,
83 GPIO65_LCD_LDD_7,
84 GPIO66_LCD_LDD_8,
85 GPIO67_LCD_LDD_9,
86 GPIO68_LCD_LDD_10,
87 GPIO69_LCD_LDD_11,
88 GPIO70_LCD_LDD_12,
89 GPIO71_LCD_LDD_13,
90 GPIO72_LCD_LDD_14,
91 GPIO73_LCD_LDD_15,
92 GPIO86_LCD_LDD_16,
93 GPIO87_LCD_LDD_17,
94 GPIO74_LCD_FCLK,
95 GPIO75_LCD_LCLK,
96 GPIO76_LCD_PCLK,
97 GPIO77_LCD_BIAS,
98
99
100 GPIO48_nPOE,
101 GPIO49_nPWE,
102 GPIO50_nPIOR,
103 GPIO51_nPIOW,
104 GPIO85_nPCE_1,
105 GPIO54_nPCE_2,
106 GPIO55_nPREG,
107 GPIO57_nIOIS16,
108 GPIO56_nPWAIT,
109 GPIO104_PSKTSEL,
110 GPIO84_GPIO,
111 GPIO35_GPIO,
112 GPIO107_GPIO,
113 GPIO11_GPIO,
114 GPIO17_GPIO,
115 GPIO12_GPIO,
116 GPIO16_GPIO,
117
118
119 GPIO88_USBH1_PWR,
120 GPIO89_USBH1_PEN,
121 GPIO119_USBH2_PWR,
122 GPIO120_USBH2_PEN,
123
124
125 GPIO41_GPIO,
126
127
128 GPIO114_GPIO,
129
130
131 GPIO28_AC97_BITCLK,
132 GPIO29_AC97_SDATA_IN_0,
133 GPIO30_AC97_SDATA_OUT,
134 GPIO31_AC97_SYNC,
135 GPIO95_AC97_nRESET,
136 GPIO98_AC97_SYSCLK,
137 GPIO113_GPIO,
138
139
140 GPIO117_I2C_SCL,
141 GPIO118_I2C_SDA,
142
143
144 GPIO36_GPIO,
145 GPIO80_DREQ_1,
146};
147
148
149
150
151#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
152static struct mtd_partition vpac270_nor_partitions[] = {
153 {
154 .name = "Flash",
155 .offset = 0x00000000,
156 .size = MTDPART_SIZ_FULL,
157 }
158};
159
160static struct physmap_flash_data vpac270_flash_data[] = {
161 {
162 .width = 2,
163 .parts = vpac270_nor_partitions,
164 .nr_parts = ARRAY_SIZE(vpac270_nor_partitions)
165 }
166};
167
168static struct resource vpac270_flash_resource = {
169 .start = PXA_CS0_PHYS,
170 .end = PXA_CS0_PHYS + SZ_64M - 1,
171 .flags = IORESOURCE_MEM,
172};
173
174static struct platform_device vpac270_flash = {
175 .name = "physmap-flash",
176 .id = 0,
177 .resource = &vpac270_flash_resource,
178 .num_resources = 1,
179 .dev = {
180 .platform_data = vpac270_flash_data,
181 },
182};
183static void __init vpac270_nor_init(void)
184{
185 platform_device_register(&vpac270_flash);
186}
187#else
188static inline void vpac270_nor_init(void) {}
189#endif
190
191
192
193
194#if defined(CONFIG_MTD_ONENAND) || defined(CONFIG_MTD_ONENAND_MODULE)
195static struct mtd_partition vpac270_onenand_partitions[] = {
196 {
197 .name = "Flash",
198 .offset = 0x00000000,
199 .size = MTDPART_SIZ_FULL,
200 }
201};
202
203static struct onenand_platform_data vpac270_onenand_info = {
204 .parts = vpac270_onenand_partitions,
205 .nr_parts = ARRAY_SIZE(vpac270_onenand_partitions),
206};
207
208static struct resource vpac270_onenand_resources[] = {
209 [0] = {
210 .start = PXA_CS0_PHYS,
211 .end = PXA_CS0_PHYS + SZ_1M,
212 .flags = IORESOURCE_MEM,
213 },
214};
215
216static struct platform_device vpac270_onenand = {
217 .name = "onenand-flash",
218 .id = -1,
219 .resource = vpac270_onenand_resources,
220 .num_resources = ARRAY_SIZE(vpac270_onenand_resources),
221 .dev = {
222 .platform_data = &vpac270_onenand_info,
223 },
224};
225
226static void __init vpac270_onenand_init(void)
227{
228 platform_device_register(&vpac270_onenand);
229}
230#else
231static void __init vpac270_onenand_init(void) {}
232#endif
233
234
235
236
237#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
238static struct pxamci_platform_data vpac270_mci_platform_data = {
239 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
240 .detect_delay_ms = 200,
241};
242
243static struct gpiod_lookup_table vpac270_mci_gpio_table = {
244 .dev_id = "pxa2xx-mci.0",
245 .table = {
246 GPIO_LOOKUP("gpio-pxa", GPIO53_VPAC270_SD_DETECT_N,
247 "cd", GPIO_ACTIVE_LOW),
248 GPIO_LOOKUP("gpio-pxa", GPIO52_VPAC270_SD_READONLY,
249 "wp", GPIO_ACTIVE_LOW),
250 { },
251 },
252};
253
254static void __init vpac270_mmc_init(void)
255{
256 gpiod_add_lookup_table(&vpac270_mci_gpio_table);
257 pxa_set_mci_info(&vpac270_mci_platform_data);
258}
259#else
260static inline void vpac270_mmc_init(void) {}
261#endif
262
263
264
265
266#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
267static struct gpio_keys_button vpac270_pxa_buttons[] = {
268 {KEY_POWER, GPIO1_VPAC270_USER_BTN, 0, "USER BTN"},
269};
270
271static struct gpio_keys_platform_data vpac270_pxa_keys_data = {
272 .buttons = vpac270_pxa_buttons,
273 .nbuttons = ARRAY_SIZE(vpac270_pxa_buttons),
274};
275
276static struct platform_device vpac270_pxa_keys = {
277 .name = "gpio-keys",
278 .id = -1,
279 .dev = {
280 .platform_data = &vpac270_pxa_keys_data,
281 },
282};
283
284static void __init vpac270_keys_init(void)
285{
286 platform_device_register(&vpac270_pxa_keys);
287}
288#else
289static inline void vpac270_keys_init(void) {}
290#endif
291
292
293
294
295#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
296struct gpio_led vpac270_gpio_leds[] = {
297{
298 .name = "vpac270:orange:user",
299 .default_trigger = "none",
300 .gpio = GPIO15_VPAC270_LED_ORANGE,
301 .active_low = 1,
302}
303};
304
305static struct gpio_led_platform_data vpac270_gpio_led_info = {
306 .leds = vpac270_gpio_leds,
307 .num_leds = ARRAY_SIZE(vpac270_gpio_leds),
308};
309
310static struct platform_device vpac270_leds = {
311 .name = "leds-gpio",
312 .id = -1,
313 .dev = {
314 .platform_data = &vpac270_gpio_led_info,
315 }
316};
317
318static void __init vpac270_leds_init(void)
319{
320 platform_device_register(&vpac270_leds);
321}
322#else
323static inline void vpac270_leds_init(void) {}
324#endif
325
326
327
328
329#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
330static int vpac270_ohci_init(struct device *dev)
331{
332 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
333 return 0;
334}
335
336static struct pxaohci_platform_data vpac270_ohci_info = {
337 .port_mode = PMM_PERPORT_MODE,
338 .flags = ENABLE_PORT1 | ENABLE_PORT2 |
339 POWER_CONTROL_LOW | POWER_SENSE_LOW,
340 .init = vpac270_ohci_init,
341};
342
343static void __init vpac270_uhc_init(void)
344{
345 pxa_set_ohci_info(&vpac270_ohci_info);
346}
347#else
348static inline void vpac270_uhc_init(void) {}
349#endif
350
351
352
353
354#if defined(CONFIG_USB_PXA27X)||defined(CONFIG_USB_PXA27X_MODULE)
355static struct gpio_vbus_mach_info vpac270_gpio_vbus_info = {
356 .gpio_vbus = GPIO41_VPAC270_UDC_DETECT,
357 .gpio_pullup = -1,
358};
359
360static struct platform_device vpac270_gpio_vbus = {
361 .name = "gpio-vbus",
362 .id = -1,
363 .dev = {
364 .platform_data = &vpac270_gpio_vbus_info,
365 },
366};
367
368static void vpac270_udc_command(int cmd)
369{
370 if (cmd == PXA2XX_UDC_CMD_CONNECT)
371 UP2OCR = UP2OCR_HXOE | UP2OCR_DPPUE;
372 else if (cmd == PXA2XX_UDC_CMD_DISCONNECT)
373 UP2OCR = UP2OCR_HXOE;
374}
375
376static struct pxa2xx_udc_mach_info vpac270_udc_info __initdata = {
377 .udc_command = vpac270_udc_command,
378 .gpio_pullup = -1,
379};
380
381static void __init vpac270_udc_init(void)
382{
383 pxa_set_udc_info(&vpac270_udc_info);
384 platform_device_register(&vpac270_gpio_vbus);
385}
386#else
387static inline void vpac270_udc_init(void) {}
388#endif
389
390
391
392
393#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
394static struct resource vpac270_dm9000_resources[] = {
395 [0] = {
396 .start = PXA_CS2_PHYS + 0x300,
397 .end = PXA_CS2_PHYS + 0x303,
398 .flags = IORESOURCE_MEM,
399 },
400 [1] = {
401 .start = PXA_CS2_PHYS + 0x304,
402 .end = PXA_CS2_PHYS + 0x343,
403 .flags = IORESOURCE_MEM,
404 },
405 [2] = {
406 .start = PXA_GPIO_TO_IRQ(GPIO114_VPAC270_ETH_IRQ),
407 .end = PXA_GPIO_TO_IRQ(GPIO114_VPAC270_ETH_IRQ),
408 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
409 },
410};
411
412static struct dm9000_plat_data vpac270_dm9000_platdata = {
413 .flags = DM9000_PLATF_32BITONLY,
414};
415
416static struct platform_device vpac270_dm9000_device = {
417 .name = "dm9000",
418 .id = -1,
419 .num_resources = ARRAY_SIZE(vpac270_dm9000_resources),
420 .resource = vpac270_dm9000_resources,
421 .dev = {
422 .platform_data = &vpac270_dm9000_platdata,
423 }
424};
425
426static void __init vpac270_eth_init(void)
427{
428 platform_device_register(&vpac270_dm9000_device);
429}
430#else
431static inline void vpac270_eth_init(void) {}
432#endif
433
434
435
436
437#if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
438 defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
439static pxa2xx_audio_ops_t vpac270_ac97_pdata = {
440 .reset_gpio = 95,
441};
442
443static struct ucb1400_pdata vpac270_ucb1400_pdata = {
444 .irq = PXA_GPIO_TO_IRQ(GPIO113_VPAC270_TS_IRQ),
445};
446
447static struct platform_device vpac270_ucb1400_device = {
448 .name = "ucb1400_core",
449 .id = -1,
450 .dev = {
451 .platform_data = &vpac270_ucb1400_pdata,
452 },
453};
454
455static void __init vpac270_ts_init(void)
456{
457 pxa_set_ac97_info(&vpac270_ac97_pdata);
458 platform_device_register(&vpac270_ucb1400_device);
459}
460#else
461static inline void vpac270_ts_init(void) {}
462#endif
463
464
465
466
467#if defined(CONFIG_RTC_DRV_DS1307) || defined(CONFIG_RTC_DRV_DS1307_MODULE)
468static struct i2c_board_info __initdata vpac270_i2c_devs[] = {
469 {
470 I2C_BOARD_INFO("ds1339", 0x68),
471 },
472};
473
474static void __init vpac270_rtc_init(void)
475{
476 i2c_register_board_info(0, ARRAY_AND_SIZE(vpac270_i2c_devs));
477}
478#else
479static inline void vpac270_rtc_init(void) {}
480#endif
481
482
483
484
485#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
486static struct pxafb_mode_info vpac270_lcd_modes[] = {
487{
488 .pixclock = 57692,
489 .xres = 640,
490 .yres = 480,
491 .bpp = 32,
492 .depth = 18,
493
494 .left_margin = 144,
495 .right_margin = 32,
496 .upper_margin = 13,
497 .lower_margin = 30,
498
499 .hsync_len = 32,
500 .vsync_len = 2,
501
502 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
503}, {
504 .pixclock = 35000,
505 .xres = 640,
506 .yres = 480,
507 .bpp = 16,
508 .depth = 16,
509
510 .left_margin = 96,
511 .right_margin = 48,
512 .upper_margin = 33,
513 .lower_margin = 10,
514
515 .hsync_len = 48,
516 .vsync_len = 1,
517
518 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
519}, {
520 .pixclock = 25000,
521 .xres = 800,
522 .yres = 600,
523 .bpp = 16,
524 .depth = 16,
525
526 .left_margin = 50,
527 .right_margin = 1,
528 .upper_margin = 21,
529 .lower_margin = 12,
530
531 .hsync_len = 8,
532 .vsync_len = 1,
533
534 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
535}, {
536 .pixclock = 15000,
537 .xres = 1024,
538 .yres = 768,
539 .bpp = 16,
540 .depth = 16,
541
542 .left_margin = 220,
543 .right_margin = 8,
544 .upper_margin = 33,
545 .lower_margin = 2,
546
547 .hsync_len = 48,
548 .vsync_len = 1,
549
550 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
551}
552};
553
554static struct pxafb_mach_info vpac270_lcd_screen = {
555 .modes = vpac270_lcd_modes,
556 .num_modes = ARRAY_SIZE(vpac270_lcd_modes),
557 .lcd_conn = LCD_COLOR_TFT_18BPP,
558};
559
560static void vpac270_lcd_power(int on, struct fb_var_screeninfo *info)
561{
562 gpio_set_value(GPIO81_VPAC270_BKL_ON, on);
563}
564
565static void __init vpac270_lcd_init(void)
566{
567 int ret;
568
569 ret = gpio_request(GPIO81_VPAC270_BKL_ON, "BKL-ON");
570 if (ret) {
571 pr_err("Requesting BKL-ON GPIO failed!\n");
572 goto err;
573 }
574
575 ret = gpio_direction_output(GPIO81_VPAC270_BKL_ON, 1);
576 if (ret) {
577 pr_err("Setting BKL-ON GPIO direction failed!\n");
578 goto err2;
579 }
580
581 vpac270_lcd_screen.pxafb_lcd_power = vpac270_lcd_power;
582 pxa_set_fb_info(NULL, &vpac270_lcd_screen);
583 return;
584
585err2:
586 gpio_free(GPIO81_VPAC270_BKL_ON);
587err:
588 return;
589}
590#else
591static inline void vpac270_lcd_init(void) {}
592#endif
593
594
595
596
597#if defined(CONFIG_PATA_PXA) || defined(CONFIG_PATA_PXA_MODULE)
598static struct pata_pxa_pdata vpac270_pata_pdata = {
599 .reg_shift = 1,
600 .dma_dreq = 1,
601 .irq_flags = IRQF_TRIGGER_RISING,
602};
603
604static struct resource vpac270_ide_resources[] = {
605 [0] = {
606 .start = PXA_CS3_PHYS + 0x120,
607 .end = PXA_CS3_PHYS + 0x13f,
608 .flags = IORESOURCE_MEM
609 },
610 [1] = {
611 .start = PXA_CS3_PHYS + 0x15c,
612 .end = PXA_CS3_PHYS + 0x15f,
613 .flags = IORESOURCE_MEM
614 },
615 [2] = {
616 .start = PXA_CS3_PHYS + 0x20,
617 .end = PXA_CS3_PHYS + 0x2f,
618 .flags = IORESOURCE_DMA
619 },
620 [3] = {
621 .start = PXA_GPIO_TO_IRQ(GPIO36_VPAC270_IDE_IRQ),
622 .end = PXA_GPIO_TO_IRQ(GPIO36_VPAC270_IDE_IRQ),
623 .flags = IORESOURCE_IRQ
624 }
625};
626
627static struct platform_device vpac270_ide_device = {
628 .name = "pata_pxa",
629 .num_resources = ARRAY_SIZE(vpac270_ide_resources),
630 .resource = vpac270_ide_resources,
631 .dev = {
632 .platform_data = &vpac270_pata_pdata,
633 .coherent_dma_mask = 0xffffffff,
634 }
635};
636
637static void __init vpac270_ide_init(void)
638{
639 platform_device_register(&vpac270_ide_device);
640}
641#else
642static inline void vpac270_ide_init(void) {}
643#endif
644
645
646
647
648#if defined(CONFIG_REGULATOR_MAX1586) || \
649 defined(CONFIG_REGULATOR_MAX1586_MODULE)
650static struct regulator_consumer_supply vpac270_max1587a_consumers[] = {
651 REGULATOR_SUPPLY("vcc_core", NULL),
652};
653
654static struct regulator_init_data vpac270_max1587a_v3_info = {
655 .constraints = {
656 .name = "vcc_core range",
657 .min_uV = 900000,
658 .max_uV = 1705000,
659 .always_on = 1,
660 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
661 },
662 .consumer_supplies = vpac270_max1587a_consumers,
663 .num_consumer_supplies = ARRAY_SIZE(vpac270_max1587a_consumers),
664};
665
666static struct max1586_subdev_data vpac270_max1587a_subdevs[] = {
667 {
668 .name = "vcc_core",
669 .id = MAX1586_V3,
670 .platform_data = &vpac270_max1587a_v3_info,
671 }
672};
673
674static struct max1586_platform_data vpac270_max1587a_info = {
675 .subdevs = vpac270_max1587a_subdevs,
676 .num_subdevs = ARRAY_SIZE(vpac270_max1587a_subdevs),
677 .v3_gain = MAX1586_GAIN_R24_3k32,
678};
679
680static struct i2c_board_info __initdata vpac270_pi2c_board_info[] = {
681 {
682 I2C_BOARD_INFO("max1586", 0x14),
683 .platform_data = &vpac270_max1587a_info,
684 },
685};
686
687static void __init vpac270_pmic_init(void)
688{
689 i2c_register_board_info(1, ARRAY_AND_SIZE(vpac270_pi2c_board_info));
690}
691#else
692static inline void vpac270_pmic_init(void) {}
693#endif
694
695
696
697
698
699static void __init vpac270_init(void)
700{
701 pxa2xx_mfp_config(ARRAY_AND_SIZE(vpac270_pin_config));
702
703 pxa_set_ffuart_info(NULL);
704 pxa_set_btuart_info(NULL);
705 pxa_set_stuart_info(NULL);
706 pxa_set_i2c_info(NULL);
707 pxa27x_set_i2c_power_info(NULL);
708
709 vpac270_pmic_init();
710 vpac270_lcd_init();
711 vpac270_mmc_init();
712 vpac270_nor_init();
713 vpac270_onenand_init();
714 vpac270_leds_init();
715 vpac270_keys_init();
716 vpac270_uhc_init();
717 vpac270_udc_init();
718 vpac270_eth_init();
719 vpac270_ts_init();
720 vpac270_rtc_init();
721 vpac270_ide_init();
722
723 regulator_has_full_constraints();
724}
725
726MACHINE_START(VPAC270, "Voipac PXA270")
727 .atag_offset = 0x100,
728 .map_io = pxa27x_map_io,
729 .nr_irqs = PXA_NR_IRQS,
730 .init_irq = pxa27x_init_irq,
731 .handle_irq = pxa27x_handle_irq,
732 .init_time = pxa_timer_init,
733 .init_machine = vpac270_init,
734 .restart = pxa_restart,
735MACHINE_END
736