1 // SPDX-License-Identifier: GPL-2.0-only
3 * Hardware definitions for Voipac PXA270
6 * Marek Vasut <marek.vasut@gmail.com>
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>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.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"
40 #include <linux/platform_data/ata-pxa.h>
45 /******************************************************************************
47 ******************************************************************************/
48 static unsigned long vpac270_pin_config[] __initdata = {
56 GPIO53_GPIO, /* SD detect */
57 GPIO52_GPIO, /* SD r/o switch */
60 GPIO1_GPIO, /* USER BTN */
63 GPIO15_GPIO, /* orange led */
110 GPIO84_GPIO, /* PCMCIA CD */
111 GPIO35_GPIO, /* PCMCIA RDY */
112 GPIO107_GPIO, /* PCMCIA PPEN */
113 GPIO11_GPIO, /* PCMCIA RESET */
114 GPIO17_GPIO, /* CF CD */
115 GPIO12_GPIO, /* CF RDY */
116 GPIO16_GPIO, /* CF RESET */
128 GPIO114_GPIO, /* IRQ */
132 GPIO29_AC97_SDATA_IN_0,
133 GPIO30_AC97_SDATA_OUT,
137 GPIO113_GPIO, /* TS IRQ */
144 GPIO36_GPIO, /* IDE IRQ */
148 /******************************************************************************
150 ******************************************************************************/
151 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
152 static struct mtd_partition vpac270_nor_partitions[] = {
155 .offset = 0x00000000,
156 .size = MTDPART_SIZ_FULL,
160 static struct physmap_flash_data vpac270_flash_data[] = {
162 .width = 2, /* bankwidth in bytes */
163 .parts = vpac270_nor_partitions,
164 .nr_parts = ARRAY_SIZE(vpac270_nor_partitions)
168 static struct resource vpac270_flash_resource = {
169 .start = PXA_CS0_PHYS,
170 .end = PXA_CS0_PHYS + SZ_64M - 1,
171 .flags = IORESOURCE_MEM,
174 static struct platform_device vpac270_flash = {
175 .name = "physmap-flash",
177 .resource = &vpac270_flash_resource,
180 .platform_data = vpac270_flash_data,
183 static void __init vpac270_nor_init(void)
185 platform_device_register(&vpac270_flash);
188 static inline void vpac270_nor_init(void) {}
191 /******************************************************************************
193 ******************************************************************************/
194 #if defined(CONFIG_MTD_ONENAND) || defined(CONFIG_MTD_ONENAND_MODULE)
195 static struct mtd_partition vpac270_onenand_partitions[] = {
198 .offset = 0x00000000,
199 .size = MTDPART_SIZ_FULL,
203 static struct onenand_platform_data vpac270_onenand_info = {
204 .parts = vpac270_onenand_partitions,
205 .nr_parts = ARRAY_SIZE(vpac270_onenand_partitions),
208 static struct resource vpac270_onenand_resources[] = {
210 .start = PXA_CS0_PHYS,
211 .end = PXA_CS0_PHYS + SZ_1M,
212 .flags = IORESOURCE_MEM,
216 static struct platform_device vpac270_onenand = {
217 .name = "onenand-flash",
219 .resource = vpac270_onenand_resources,
220 .num_resources = ARRAY_SIZE(vpac270_onenand_resources),
222 .platform_data = &vpac270_onenand_info,
226 static void __init vpac270_onenand_init(void)
228 platform_device_register(&vpac270_onenand);
231 static void __init vpac270_onenand_init(void) {}
234 /******************************************************************************
235 * SD/MMC card controller
236 ******************************************************************************/
237 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
238 static struct pxamci_platform_data vpac270_mci_platform_data = {
239 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
240 .detect_delay_ms = 200,
243 static struct gpiod_lookup_table vpac270_mci_gpio_table = {
244 .dev_id = "pxa2xx-mci.0",
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),
254 static void __init vpac270_mmc_init(void)
256 gpiod_add_lookup_table(&vpac270_mci_gpio_table);
257 pxa_set_mci_info(&vpac270_mci_platform_data);
260 static inline void vpac270_mmc_init(void) {}
263 /******************************************************************************
265 ******************************************************************************/
266 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
267 static struct gpio_keys_button vpac270_pxa_buttons[] = {
268 {KEY_POWER, GPIO1_VPAC270_USER_BTN, 0, "USER BTN"},
271 static struct gpio_keys_platform_data vpac270_pxa_keys_data = {
272 .buttons = vpac270_pxa_buttons,
273 .nbuttons = ARRAY_SIZE(vpac270_pxa_buttons),
276 static struct platform_device vpac270_pxa_keys = {
280 .platform_data = &vpac270_pxa_keys_data,
284 static void __init vpac270_keys_init(void)
286 platform_device_register(&vpac270_pxa_keys);
289 static inline void vpac270_keys_init(void) {}
292 /******************************************************************************
294 ******************************************************************************/
295 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
296 struct gpio_led vpac270_gpio_leds[] = {
298 .name = "vpac270:orange:user",
299 .default_trigger = "none",
300 .gpio = GPIO15_VPAC270_LED_ORANGE,
305 static struct gpio_led_platform_data vpac270_gpio_led_info = {
306 .leds = vpac270_gpio_leds,
307 .num_leds = ARRAY_SIZE(vpac270_gpio_leds),
310 static struct platform_device vpac270_leds = {
314 .platform_data = &vpac270_gpio_led_info,
318 static void __init vpac270_leds_init(void)
320 platform_device_register(&vpac270_leds);
323 static inline void vpac270_leds_init(void) {}
326 /******************************************************************************
328 ******************************************************************************/
329 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
330 static int vpac270_ohci_init(struct device *dev)
332 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
336 static 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,
343 static void __init vpac270_uhc_init(void)
345 pxa_set_ohci_info(&vpac270_ohci_info);
348 static inline void vpac270_uhc_init(void) {}
351 /******************************************************************************
353 ******************************************************************************/
354 #if defined(CONFIG_USB_PXA27X)||defined(CONFIG_USB_PXA27X_MODULE)
355 static struct gpio_vbus_mach_info vpac270_gpio_vbus_info = {
356 .gpio_vbus = GPIO41_VPAC270_UDC_DETECT,
360 static struct platform_device vpac270_gpio_vbus = {
364 .platform_data = &vpac270_gpio_vbus_info,
368 static void vpac270_udc_command(int cmd)
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;
376 static struct pxa2xx_udc_mach_info vpac270_udc_info __initdata = {
377 .udc_command = vpac270_udc_command,
381 static void __init vpac270_udc_init(void)
383 pxa_set_udc_info(&vpac270_udc_info);
384 platform_device_register(&vpac270_gpio_vbus);
387 static inline void vpac270_udc_init(void) {}
390 /******************************************************************************
392 ******************************************************************************/
393 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
394 static struct resource vpac270_dm9000_resources[] = {
396 .start = PXA_CS2_PHYS + 0x300,
397 .end = PXA_CS2_PHYS + 0x303,
398 .flags = IORESOURCE_MEM,
401 .start = PXA_CS2_PHYS + 0x304,
402 .end = PXA_CS2_PHYS + 0x343,
403 .flags = IORESOURCE_MEM,
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,
412 static struct dm9000_plat_data vpac270_dm9000_platdata = {
413 .flags = DM9000_PLATF_32BITONLY,
416 static struct platform_device vpac270_dm9000_device = {
419 .num_resources = ARRAY_SIZE(vpac270_dm9000_resources),
420 .resource = vpac270_dm9000_resources,
422 .platform_data = &vpac270_dm9000_platdata,
426 static void __init vpac270_eth_init(void)
428 platform_device_register(&vpac270_dm9000_device);
431 static inline void vpac270_eth_init(void) {}
434 /******************************************************************************
435 * Audio and Touchscreen
436 ******************************************************************************/
437 #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
438 defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
439 static pxa2xx_audio_ops_t vpac270_ac97_pdata = {
443 static struct ucb1400_pdata vpac270_ucb1400_pdata = {
444 .irq = PXA_GPIO_TO_IRQ(GPIO113_VPAC270_TS_IRQ),
447 static struct platform_device vpac270_ucb1400_device = {
448 .name = "ucb1400_core",
451 .platform_data = &vpac270_ucb1400_pdata,
455 static void __init vpac270_ts_init(void)
457 pxa_set_ac97_info(&vpac270_ac97_pdata);
458 platform_device_register(&vpac270_ucb1400_device);
461 static inline void vpac270_ts_init(void) {}
464 /******************************************************************************
466 ******************************************************************************/
467 #if defined(CONFIG_RTC_DRV_DS1307) || defined(CONFIG_RTC_DRV_DS1307_MODULE)
468 static struct i2c_board_info __initdata vpac270_i2c_devs[] = {
470 I2C_BOARD_INFO("ds1339", 0x68),
474 static void __init vpac270_rtc_init(void)
476 i2c_register_board_info(0, ARRAY_AND_SIZE(vpac270_i2c_devs));
479 static inline void vpac270_rtc_init(void) {}
482 /******************************************************************************
484 ******************************************************************************/
485 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
486 static struct pxafb_mode_info vpac270_lcd_modes[] = {
502 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
503 }, { /* CRT 640x480 */
518 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
519 }, { /* CRT 800x600 H=30kHz V=48HZ */
534 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
535 }, { /* CRT 1024x768 H=40kHz V=50Hz */
550 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
554 static 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,
560 static void vpac270_lcd_power(int on, struct fb_var_screeninfo *info)
562 gpio_set_value(GPIO81_VPAC270_BKL_ON, on);
565 static void __init vpac270_lcd_init(void)
569 ret = gpio_request(GPIO81_VPAC270_BKL_ON, "BKL-ON");
571 pr_err("Requesting BKL-ON GPIO failed!\n");
575 ret = gpio_direction_output(GPIO81_VPAC270_BKL_ON, 1);
577 pr_err("Setting BKL-ON GPIO direction failed!\n");
581 vpac270_lcd_screen.pxafb_lcd_power = vpac270_lcd_power;
582 pxa_set_fb_info(NULL, &vpac270_lcd_screen);
586 gpio_free(GPIO81_VPAC270_BKL_ON);
591 static inline void vpac270_lcd_init(void) {}
594 /******************************************************************************
596 ******************************************************************************/
597 #if defined(CONFIG_PATA_PXA) || defined(CONFIG_PATA_PXA_MODULE)
598 static struct pata_pxa_pdata vpac270_pata_pdata = {
601 .irq_flags = IRQF_TRIGGER_RISING,
604 static struct resource vpac270_ide_resources[] = {
605 [0] = { /* I/O Base address */
606 .start = PXA_CS3_PHYS + 0x120,
607 .end = PXA_CS3_PHYS + 0x13f,
608 .flags = IORESOURCE_MEM
610 [1] = { /* CTL Base address */
611 .start = PXA_CS3_PHYS + 0x15c,
612 .end = PXA_CS3_PHYS + 0x15f,
613 .flags = IORESOURCE_MEM
615 [2] = { /* DMA Base address */
616 .start = PXA_CS3_PHYS + 0x20,
617 .end = PXA_CS3_PHYS + 0x2f,
618 .flags = IORESOURCE_DMA
620 [3] = { /* IDE IRQ pin */
621 .start = PXA_GPIO_TO_IRQ(GPIO36_VPAC270_IDE_IRQ),
622 .end = PXA_GPIO_TO_IRQ(GPIO36_VPAC270_IDE_IRQ),
623 .flags = IORESOURCE_IRQ
627 static struct platform_device vpac270_ide_device = {
629 .num_resources = ARRAY_SIZE(vpac270_ide_resources),
630 .resource = vpac270_ide_resources,
632 .platform_data = &vpac270_pata_pdata,
633 .coherent_dma_mask = 0xffffffff,
637 static void __init vpac270_ide_init(void)
639 platform_device_register(&vpac270_ide_device);
642 static inline void vpac270_ide_init(void) {}
645 /******************************************************************************
646 * Core power regulator
647 ******************************************************************************/
648 #if defined(CONFIG_REGULATOR_MAX1586) || \
649 defined(CONFIG_REGULATOR_MAX1586_MODULE)
650 static struct regulator_consumer_supply vpac270_max1587a_consumers[] = {
651 REGULATOR_SUPPLY("vcc_core", NULL),
654 static struct regulator_init_data vpac270_max1587a_v3_info = {
656 .name = "vcc_core range",
660 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
662 .consumer_supplies = vpac270_max1587a_consumers,
663 .num_consumer_supplies = ARRAY_SIZE(vpac270_max1587a_consumers),
666 static struct max1586_subdev_data vpac270_max1587a_subdevs[] = {
670 .platform_data = &vpac270_max1587a_v3_info,
674 static 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, /* 730..1550 mV */
680 static struct i2c_board_info __initdata vpac270_pi2c_board_info[] = {
682 I2C_BOARD_INFO("max1586", 0x14),
683 .platform_data = &vpac270_max1587a_info,
687 static void __init vpac270_pmic_init(void)
689 i2c_register_board_info(1, ARRAY_AND_SIZE(vpac270_pi2c_board_info));
692 static inline void vpac270_pmic_init(void) {}
696 /******************************************************************************
698 ******************************************************************************/
699 static void __init vpac270_init(void)
701 pxa2xx_mfp_config(ARRAY_AND_SIZE(vpac270_pin_config));
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);
713 vpac270_onenand_init();
723 regulator_has_full_constraints();
726 MACHINE_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,