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/mtd/mtd.h>
18 #include <linux/mtd/partitions.h>
19 #include <linux/mtd/physmap.h>
20 #include <linux/mtd/onenand.h>
21 #include <linux/dm9000.h>
22 #include <linux/ucb1400.h>
23 #include <linux/ata_platform.h>
24 #include <linux/regulator/machine.h>
25 #include <linux/regulator/max1586.h>
26 #include <linux/platform_data/i2c-pxa.h>
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
32 #include <mach/audio.h>
33 #include <mach/vpac270.h>
34 #include <linux/platform_data/mmc-pxamci.h>
35 #include <linux/platform_data/video-pxafb.h>
36 #include <linux/platform_data/usb-ohci-pxa27x.h>
37 #include "pxa27x-udc.h"
39 #include <linux/platform_data/ata-pxa.h>
44 /******************************************************************************
46 ******************************************************************************/
47 static unsigned long vpac270_pin_config
[] __initdata
= {
55 GPIO53_GPIO
, /* SD detect */
56 GPIO52_GPIO
, /* SD r/o switch */
59 GPIO1_GPIO
, /* USER BTN */
62 GPIO15_GPIO
, /* orange led */
109 GPIO84_GPIO
, /* PCMCIA CD */
110 GPIO35_GPIO
, /* PCMCIA RDY */
111 GPIO107_GPIO
, /* PCMCIA PPEN */
112 GPIO11_GPIO
, /* PCMCIA RESET */
113 GPIO17_GPIO
, /* CF CD */
114 GPIO12_GPIO
, /* CF RDY */
115 GPIO16_GPIO
, /* CF RESET */
127 GPIO114_GPIO
, /* IRQ */
131 GPIO29_AC97_SDATA_IN_0
,
132 GPIO30_AC97_SDATA_OUT
,
136 GPIO113_GPIO
, /* TS IRQ */
143 GPIO36_GPIO
, /* IDE IRQ */
147 /******************************************************************************
149 ******************************************************************************/
150 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
151 static struct mtd_partition vpac270_nor_partitions
[] = {
154 .offset
= 0x00000000,
155 .size
= MTDPART_SIZ_FULL
,
159 static struct physmap_flash_data vpac270_flash_data
[] = {
161 .width
= 2, /* bankwidth in bytes */
162 .parts
= vpac270_nor_partitions
,
163 .nr_parts
= ARRAY_SIZE(vpac270_nor_partitions
)
167 static struct resource vpac270_flash_resource
= {
168 .start
= PXA_CS0_PHYS
,
169 .end
= PXA_CS0_PHYS
+ SZ_64M
- 1,
170 .flags
= IORESOURCE_MEM
,
173 static struct platform_device vpac270_flash
= {
174 .name
= "physmap-flash",
176 .resource
= &vpac270_flash_resource
,
179 .platform_data
= vpac270_flash_data
,
182 static void __init
vpac270_nor_init(void)
184 platform_device_register(&vpac270_flash
);
187 static inline void vpac270_nor_init(void) {}
190 /******************************************************************************
192 ******************************************************************************/
193 #if defined(CONFIG_MTD_ONENAND) || defined(CONFIG_MTD_ONENAND_MODULE)
194 static struct mtd_partition vpac270_onenand_partitions
[] = {
197 .offset
= 0x00000000,
198 .size
= MTDPART_SIZ_FULL
,
202 static struct onenand_platform_data vpac270_onenand_info
= {
203 .parts
= vpac270_onenand_partitions
,
204 .nr_parts
= ARRAY_SIZE(vpac270_onenand_partitions
),
207 static struct resource vpac270_onenand_resources
[] = {
209 .start
= PXA_CS0_PHYS
,
210 .end
= PXA_CS0_PHYS
+ SZ_1M
,
211 .flags
= IORESOURCE_MEM
,
215 static struct platform_device vpac270_onenand
= {
216 .name
= "onenand-flash",
218 .resource
= vpac270_onenand_resources
,
219 .num_resources
= ARRAY_SIZE(vpac270_onenand_resources
),
221 .platform_data
= &vpac270_onenand_info
,
225 static void __init
vpac270_onenand_init(void)
227 platform_device_register(&vpac270_onenand
);
230 static void __init
vpac270_onenand_init(void) {}
233 /******************************************************************************
234 * SD/MMC card controller
235 ******************************************************************************/
236 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
237 static struct pxamci_platform_data vpac270_mci_platform_data
= {
238 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
239 .detect_delay_ms
= 200,
242 static struct gpiod_lookup_table vpac270_mci_gpio_table
= {
243 .dev_id
= "pxa2xx-mci.0",
245 GPIO_LOOKUP("gpio-pxa", GPIO53_VPAC270_SD_DETECT_N
,
246 "cd", GPIO_ACTIVE_LOW
),
247 GPIO_LOOKUP("gpio-pxa", GPIO52_VPAC270_SD_READONLY
,
248 "wp", GPIO_ACTIVE_LOW
),
253 static void __init
vpac270_mmc_init(void)
255 gpiod_add_lookup_table(&vpac270_mci_gpio_table
);
256 pxa_set_mci_info(&vpac270_mci_platform_data
);
259 static inline void vpac270_mmc_init(void) {}
262 /******************************************************************************
264 ******************************************************************************/
265 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
266 static struct gpio_keys_button vpac270_pxa_buttons
[] = {
267 {KEY_POWER
, GPIO1_VPAC270_USER_BTN
, 0, "USER BTN"},
270 static struct gpio_keys_platform_data vpac270_pxa_keys_data
= {
271 .buttons
= vpac270_pxa_buttons
,
272 .nbuttons
= ARRAY_SIZE(vpac270_pxa_buttons
),
275 static struct platform_device vpac270_pxa_keys
= {
279 .platform_data
= &vpac270_pxa_keys_data
,
283 static void __init
vpac270_keys_init(void)
285 platform_device_register(&vpac270_pxa_keys
);
288 static inline void vpac270_keys_init(void) {}
291 /******************************************************************************
293 ******************************************************************************/
294 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
295 struct gpio_led vpac270_gpio_leds
[] = {
297 .name
= "vpac270:orange:user",
298 .default_trigger
= "none",
299 .gpio
= GPIO15_VPAC270_LED_ORANGE
,
304 static struct gpio_led_platform_data vpac270_gpio_led_info
= {
305 .leds
= vpac270_gpio_leds
,
306 .num_leds
= ARRAY_SIZE(vpac270_gpio_leds
),
309 static struct platform_device vpac270_leds
= {
313 .platform_data
= &vpac270_gpio_led_info
,
317 static void __init
vpac270_leds_init(void)
319 platform_device_register(&vpac270_leds
);
322 static inline void vpac270_leds_init(void) {}
325 /******************************************************************************
327 ******************************************************************************/
328 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
329 static int vpac270_ohci_init(struct device
*dev
)
331 UP2OCR
= UP2OCR_HXS
| UP2OCR_HXOE
| UP2OCR_DPPDE
| UP2OCR_DMPDE
;
335 static struct pxaohci_platform_data vpac270_ohci_info
= {
336 .port_mode
= PMM_PERPORT_MODE
,
337 .flags
= ENABLE_PORT1
| ENABLE_PORT2
|
338 POWER_CONTROL_LOW
| POWER_SENSE_LOW
,
339 .init
= vpac270_ohci_init
,
342 static void __init
vpac270_uhc_init(void)
344 pxa_set_ohci_info(&vpac270_ohci_info
);
347 static inline void vpac270_uhc_init(void) {}
350 /******************************************************************************
352 ******************************************************************************/
353 #if defined(CONFIG_USB_PXA27X)||defined(CONFIG_USB_PXA27X_MODULE)
354 static struct gpiod_lookup_table vpac270_gpio_vbus_gpiod_table
= {
355 .dev_id
= "gpio-vbus",
357 GPIO_LOOKUP("gpio-pxa", GPIO41_VPAC270_UDC_DETECT
,
358 "vbus", GPIO_ACTIVE_HIGH
),
363 static struct platform_device vpac270_gpio_vbus
= {
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 gpiod_add_lookup_table(&vpac270_gpio_vbus_gpiod_table
);
385 platform_device_register(&vpac270_gpio_vbus
);
388 static inline void vpac270_udc_init(void) {}
391 /******************************************************************************
393 ******************************************************************************/
394 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
395 static struct resource vpac270_dm9000_resources
[] = {
397 .start
= PXA_CS2_PHYS
+ 0x300,
398 .end
= PXA_CS2_PHYS
+ 0x303,
399 .flags
= IORESOURCE_MEM
,
402 .start
= PXA_CS2_PHYS
+ 0x304,
403 .end
= PXA_CS2_PHYS
+ 0x343,
404 .flags
= IORESOURCE_MEM
,
407 .start
= PXA_GPIO_TO_IRQ(GPIO114_VPAC270_ETH_IRQ
),
408 .end
= PXA_GPIO_TO_IRQ(GPIO114_VPAC270_ETH_IRQ
),
409 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
413 static struct dm9000_plat_data vpac270_dm9000_platdata
= {
414 .flags
= DM9000_PLATF_32BITONLY
,
417 static struct platform_device vpac270_dm9000_device
= {
420 .num_resources
= ARRAY_SIZE(vpac270_dm9000_resources
),
421 .resource
= vpac270_dm9000_resources
,
423 .platform_data
= &vpac270_dm9000_platdata
,
427 static void __init
vpac270_eth_init(void)
429 platform_device_register(&vpac270_dm9000_device
);
432 static inline void vpac270_eth_init(void) {}
435 /******************************************************************************
436 * Audio and Touchscreen
437 ******************************************************************************/
438 #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
439 defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
440 static pxa2xx_audio_ops_t vpac270_ac97_pdata
= {
444 static struct ucb1400_pdata vpac270_ucb1400_pdata
= {
445 .irq
= PXA_GPIO_TO_IRQ(GPIO113_VPAC270_TS_IRQ
),
448 static struct platform_device vpac270_ucb1400_device
= {
449 .name
= "ucb1400_core",
452 .platform_data
= &vpac270_ucb1400_pdata
,
456 static void __init
vpac270_ts_init(void)
458 pxa_set_ac97_info(&vpac270_ac97_pdata
);
459 platform_device_register(&vpac270_ucb1400_device
);
462 static inline void vpac270_ts_init(void) {}
465 /******************************************************************************
467 ******************************************************************************/
468 #if defined(CONFIG_RTC_DRV_DS1307) || defined(CONFIG_RTC_DRV_DS1307_MODULE)
469 static struct i2c_board_info __initdata vpac270_i2c_devs
[] = {
471 I2C_BOARD_INFO("ds1339", 0x68),
475 static void __init
vpac270_rtc_init(void)
477 i2c_register_board_info(0, ARRAY_AND_SIZE(vpac270_i2c_devs
));
480 static inline void vpac270_rtc_init(void) {}
483 /******************************************************************************
485 ******************************************************************************/
486 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
487 static struct pxafb_mode_info vpac270_lcd_modes
[] = {
503 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
504 }, { /* CRT 640x480 */
519 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
520 }, { /* CRT 800x600 H=30kHz V=48HZ */
535 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
536 }, { /* CRT 1024x768 H=40kHz V=50Hz */
551 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
555 static struct pxafb_mach_info vpac270_lcd_screen
= {
556 .modes
= vpac270_lcd_modes
,
557 .num_modes
= ARRAY_SIZE(vpac270_lcd_modes
),
558 .lcd_conn
= LCD_COLOR_TFT_18BPP
,
561 static void vpac270_lcd_power(int on
, struct fb_var_screeninfo
*info
)
563 gpio_set_value(GPIO81_VPAC270_BKL_ON
, on
);
566 static void __init
vpac270_lcd_init(void)
570 ret
= gpio_request(GPIO81_VPAC270_BKL_ON
, "BKL-ON");
572 pr_err("Requesting BKL-ON GPIO failed!\n");
576 ret
= gpio_direction_output(GPIO81_VPAC270_BKL_ON
, 1);
578 pr_err("Setting BKL-ON GPIO direction failed!\n");
582 vpac270_lcd_screen
.pxafb_lcd_power
= vpac270_lcd_power
;
583 pxa_set_fb_info(NULL
, &vpac270_lcd_screen
);
587 gpio_free(GPIO81_VPAC270_BKL_ON
);
592 static inline void vpac270_lcd_init(void) {}
595 /******************************************************************************
597 ******************************************************************************/
598 #if defined(CONFIG_PATA_PXA) || defined(CONFIG_PATA_PXA_MODULE)
599 static struct pata_pxa_pdata vpac270_pata_pdata
= {
602 .irq_flags
= IRQF_TRIGGER_RISING
,
605 static struct resource vpac270_ide_resources
[] = {
606 [0] = { /* I/O Base address */
607 .start
= PXA_CS3_PHYS
+ 0x120,
608 .end
= PXA_CS3_PHYS
+ 0x13f,
609 .flags
= IORESOURCE_MEM
611 [1] = { /* CTL Base address */
612 .start
= PXA_CS3_PHYS
+ 0x15c,
613 .end
= PXA_CS3_PHYS
+ 0x15f,
614 .flags
= IORESOURCE_MEM
616 [2] = { /* DMA Base address */
617 .start
= PXA_CS3_PHYS
+ 0x20,
618 .end
= PXA_CS3_PHYS
+ 0x2f,
619 .flags
= IORESOURCE_DMA
621 [3] = { /* IDE IRQ pin */
622 .start
= PXA_GPIO_TO_IRQ(GPIO36_VPAC270_IDE_IRQ
),
623 .end
= PXA_GPIO_TO_IRQ(GPIO36_VPAC270_IDE_IRQ
),
624 .flags
= IORESOURCE_IRQ
628 static struct platform_device vpac270_ide_device
= {
630 .num_resources
= ARRAY_SIZE(vpac270_ide_resources
),
631 .resource
= vpac270_ide_resources
,
633 .platform_data
= &vpac270_pata_pdata
,
634 .coherent_dma_mask
= 0xffffffff,
638 static void __init
vpac270_ide_init(void)
640 platform_device_register(&vpac270_ide_device
);
643 static inline void vpac270_ide_init(void) {}
646 /******************************************************************************
647 * Core power regulator
648 ******************************************************************************/
649 #if defined(CONFIG_REGULATOR_MAX1586) || \
650 defined(CONFIG_REGULATOR_MAX1586_MODULE)
651 static struct regulator_consumer_supply vpac270_max1587a_consumers
[] = {
652 REGULATOR_SUPPLY("vcc_core", NULL
),
655 static struct regulator_init_data vpac270_max1587a_v3_info
= {
657 .name
= "vcc_core range",
661 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
,
663 .consumer_supplies
= vpac270_max1587a_consumers
,
664 .num_consumer_supplies
= ARRAY_SIZE(vpac270_max1587a_consumers
),
667 static struct max1586_subdev_data vpac270_max1587a_subdevs
[] = {
671 .platform_data
= &vpac270_max1587a_v3_info
,
675 static struct max1586_platform_data vpac270_max1587a_info
= {
676 .subdevs
= vpac270_max1587a_subdevs
,
677 .num_subdevs
= ARRAY_SIZE(vpac270_max1587a_subdevs
),
678 .v3_gain
= MAX1586_GAIN_R24_3k32
, /* 730..1550 mV */
681 static struct i2c_board_info __initdata vpac270_pi2c_board_info
[] = {
683 I2C_BOARD_INFO("max1586", 0x14),
684 .platform_data
= &vpac270_max1587a_info
,
688 static void __init
vpac270_pmic_init(void)
690 i2c_register_board_info(1, ARRAY_AND_SIZE(vpac270_pi2c_board_info
));
693 static inline void vpac270_pmic_init(void) {}
697 /******************************************************************************
699 ******************************************************************************/
700 static void __init
vpac270_init(void)
702 pxa2xx_mfp_config(ARRAY_AND_SIZE(vpac270_pin_config
));
704 pxa_set_ffuart_info(NULL
);
705 pxa_set_btuart_info(NULL
);
706 pxa_set_stuart_info(NULL
);
707 pxa_set_i2c_info(NULL
);
708 pxa27x_set_i2c_power_info(NULL
);
714 vpac270_onenand_init();
724 regulator_has_full_constraints();
727 MACHINE_START(VPAC270
, "Voipac PXA270")
728 .atag_offset
= 0x100,
729 .map_io
= pxa27x_map_io
,
730 .nr_irqs
= PXA_NR_IRQS
,
731 .init_irq
= pxa27x_init_irq
,
732 .handle_irq
= pxa27x_handle_irq
,
733 .init_time
= pxa_timer_init
,
734 .init_machine
= vpac270_init
,
735 .restart
= pxa_restart
,