2 * TI DA850/OMAP-L138 EVM board
4 * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
6 * Derived from: arch/arm/mach-davinci/board-da830-evm.c
7 * Original Copyrights follow:
9 * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
10 * the terms of the GNU General Public License version 2. This program
11 * is licensed "as is" without any warranty of any kind, whether express
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/console.h>
17 #include <linux/i2c.h>
18 #include <linux/i2c/at24.h>
19 #include <linux/i2c/pca953x.h>
20 #include <linux/mfd/tps6507x.h>
21 #include <linux/gpio.h>
22 #include <linux/platform_device.h>
23 #include <linux/mtd/mtd.h>
24 #include <linux/mtd/nand.h>
25 #include <linux/mtd/partitions.h>
26 #include <linux/mtd/physmap.h>
27 #include <linux/regulator/machine.h>
28 #include <linux/regulator/tps6507x.h>
29 #include <linux/mfd/tps6507x.h>
30 #include <linux/input/tps6507x-ts.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
35 #include <mach/cp_intc.h>
36 #include <mach/da8xx.h>
37 #include <mach/nand.h>
40 #define DA850_EVM_PHY_MASK 0x1
41 #define DA850_EVM_MDIO_FREQUENCY 2200000 /* PHY bus frequency */
43 #define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8)
44 #define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
46 #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
47 #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
49 #define DA850_MII_MDIO_CLKEN_PIN GPIO_TO_PIN(2, 6)
51 static struct mtd_partition da850_evm_norflash_partition
[] = {
53 .name
= "bootloaders + env",
56 .mask_flags
= MTD_WRITEABLE
,
60 .offset
= MTDPART_OFS_APPEND
,
66 .offset
= MTDPART_OFS_APPEND
,
67 .size
= MTDPART_SIZ_FULL
,
72 static struct physmap_flash_data da850_evm_norflash_data
= {
74 .parts
= da850_evm_norflash_partition
,
75 .nr_parts
= ARRAY_SIZE(da850_evm_norflash_partition
),
78 static struct resource da850_evm_norflash_resource
[] = {
80 .start
= DA8XX_AEMIF_CS2_BASE
,
81 .end
= DA8XX_AEMIF_CS2_BASE
+ SZ_32M
- 1,
82 .flags
= IORESOURCE_MEM
,
86 static struct platform_device da850_evm_norflash_device
= {
87 .name
= "physmap-flash",
90 .platform_data
= &da850_evm_norflash_data
,
93 .resource
= da850_evm_norflash_resource
,
96 static struct davinci_pm_config da850_pm_pdata
= {
100 static struct platform_device da850_pm_device
= {
101 .name
= "pm-davinci",
103 .platform_data
= &da850_pm_pdata
,
108 /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
109 * (128K blocks). It may be used instead of the (default) SPI flash
110 * to boot, using TI's tools to install the secondary boot loader
113 static struct mtd_partition da850_evm_nandflash_partition
[] = {
115 .name
= "u-boot env",
118 .mask_flags
= MTD_WRITEABLE
,
122 .offset
= MTDPART_OFS_APPEND
,
124 .mask_flags
= MTD_WRITEABLE
,
128 .offset
= MTDPART_OFS_APPEND
,
130 .mask_flags
= MTD_WRITEABLE
,
139 .name
= "filesystem",
140 .offset
= MTDPART_OFS_APPEND
,
141 .size
= MTDPART_SIZ_FULL
,
146 static struct davinci_nand_pdata da850_evm_nandflash_data
= {
147 .parts
= da850_evm_nandflash_partition
,
148 .nr_parts
= ARRAY_SIZE(da850_evm_nandflash_partition
),
149 .ecc_mode
= NAND_ECC_HW
,
151 .options
= NAND_USE_FLASH_BBT
,
154 static struct resource da850_evm_nandflash_resource
[] = {
156 .start
= DA8XX_AEMIF_CS3_BASE
,
157 .end
= DA8XX_AEMIF_CS3_BASE
+ SZ_512K
+ 2 * SZ_1K
- 1,
158 .flags
= IORESOURCE_MEM
,
161 .start
= DA8XX_AEMIF_CTL_BASE
,
162 .end
= DA8XX_AEMIF_CTL_BASE
+ SZ_32K
- 1,
163 .flags
= IORESOURCE_MEM
,
167 static struct platform_device da850_evm_nandflash_device
= {
168 .name
= "davinci_nand",
171 .platform_data
= &da850_evm_nandflash_data
,
173 .num_resources
= ARRAY_SIZE(da850_evm_nandflash_resource
),
174 .resource
= da850_evm_nandflash_resource
,
177 static struct platform_device
*da850_evm_devices
[] __initdata
= {
178 &da850_evm_nandflash_device
,
179 &da850_evm_norflash_device
,
182 #define DA8XX_AEMIF_CE2CFG_OFFSET 0x10
183 #define DA8XX_AEMIF_ASIZE_16BIT 0x1
185 static void __init
da850_evm_init_nor(void)
187 void __iomem
*aemif_addr
;
189 aemif_addr
= ioremap(DA8XX_AEMIF_CTL_BASE
, SZ_32K
);
191 /* Configure data bus width of CS2 to 16 bit */
192 writel(readl(aemif_addr
+ DA8XX_AEMIF_CE2CFG_OFFSET
) |
193 DA8XX_AEMIF_ASIZE_16BIT
,
194 aemif_addr
+ DA8XX_AEMIF_CE2CFG_OFFSET
);
199 static u32 ui_card_detected
;
201 #if defined(CONFIG_MMC_DAVINCI) || \
202 defined(CONFIG_MMC_DAVINCI_MODULE)
208 static __init
void da850_evm_setup_nor_nand(void)
212 if (ui_card_detected
& !HAS_MMC
) {
213 ret
= davinci_cfg_reg_list(da850_nand_pins
);
215 pr_warning("da850_evm_init: nand mux setup failed: "
218 ret
= davinci_cfg_reg_list(da850_nor_pins
);
220 pr_warning("da850_evm_init: nor mux setup failed: %d\n",
223 da850_evm_init_nor();
225 platform_add_devices(da850_evm_devices
,
226 ARRAY_SIZE(da850_evm_devices
));
230 #ifdef CONFIG_DA850_UI_RMII
231 static inline void da850_evm_setup_emac_rmii(int rmii_sel
)
233 struct davinci_soc_info
*soc_info
= &davinci_soc_info
;
235 soc_info
->emac_pdata
->rmii_en
= 1;
236 gpio_set_value(rmii_sel
, 0);
239 static inline void da850_evm_setup_emac_rmii(int rmii_sel
) { }
242 static int da850_evm_ui_expander_setup(struct i2c_client
*client
, unsigned gpio
,
243 unsigned ngpio
, void *c
)
245 int sel_a
, sel_b
, sel_c
, ret
;
251 ret
= gpio_request(sel_a
, "sel_a");
253 pr_warning("Cannot open UI expander pin %d\n", sel_a
);
254 goto exp_setup_sela_fail
;
257 ret
= gpio_request(sel_b
, "sel_b");
259 pr_warning("Cannot open UI expander pin %d\n", sel_b
);
260 goto exp_setup_selb_fail
;
263 ret
= gpio_request(sel_c
, "sel_c");
265 pr_warning("Cannot open UI expander pin %d\n", sel_c
);
266 goto exp_setup_selc_fail
;
269 /* deselect all functionalities */
270 gpio_direction_output(sel_a
, 1);
271 gpio_direction_output(sel_b
, 1);
272 gpio_direction_output(sel_c
, 1);
274 ui_card_detected
= 1;
275 pr_info("DA850/OMAP-L138 EVM UI card detected\n");
277 da850_evm_setup_nor_nand();
279 da850_evm_setup_emac_rmii(sel_a
);
291 static int da850_evm_ui_expander_teardown(struct i2c_client
*client
,
292 unsigned gpio
, unsigned ngpio
, void *c
)
294 /* deselect all functionalities */
295 gpio_set_value(gpio
+ 5, 1);
296 gpio_set_value(gpio
+ 6, 1);
297 gpio_set_value(gpio
+ 7, 1);
306 static struct pca953x_platform_data da850_evm_ui_expander_info
= {
307 .gpio_base
= DAVINCI_N_GPIO
,
308 .setup
= da850_evm_ui_expander_setup
,
309 .teardown
= da850_evm_ui_expander_teardown
,
312 static struct i2c_board_info __initdata da850_evm_i2c_devices
[] = {
314 I2C_BOARD_INFO("tlv320aic3x", 0x18),
317 I2C_BOARD_INFO("tca6416", 0x20),
318 .platform_data
= &da850_evm_ui_expander_info
,
322 static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata
= {
323 .bus_freq
= 100, /* kHz */
324 .bus_delay
= 0, /* usec */
327 static struct davinci_uart_config da850_evm_uart_config __initdata
= {
328 .enabled_uarts
= 0x7,
331 /* davinci da850 evm audio machine driver */
332 static u8 da850_iis_serializer_direction
[] = {
333 INACTIVE_MODE
, INACTIVE_MODE
, INACTIVE_MODE
, INACTIVE_MODE
,
334 INACTIVE_MODE
, INACTIVE_MODE
, INACTIVE_MODE
, INACTIVE_MODE
,
335 INACTIVE_MODE
, INACTIVE_MODE
, INACTIVE_MODE
, TX_MODE
,
336 RX_MODE
, INACTIVE_MODE
, INACTIVE_MODE
, INACTIVE_MODE
,
339 static struct snd_platform_data da850_evm_snd_data
= {
340 .tx_dma_offset
= 0x2000,
341 .rx_dma_offset
= 0x2000,
342 .op_mode
= DAVINCI_MCASP_IIS_MODE
,
343 .num_serializer
= ARRAY_SIZE(da850_iis_serializer_direction
),
345 .serial_dir
= da850_iis_serializer_direction
,
346 .asp_chan_q
= EVENTQ_1
,
347 .version
= MCASP_VERSION_2
,
352 static int da850_evm_mmc_get_ro(int index
)
354 return gpio_get_value(DA850_MMCSD_WP_PIN
);
357 static int da850_evm_mmc_get_cd(int index
)
359 return !gpio_get_value(DA850_MMCSD_CD_PIN
);
362 static struct davinci_mmc_config da850_mmc_config
= {
363 .get_ro
= da850_evm_mmc_get_ro
,
364 .get_cd
= da850_evm_mmc_get_cd
,
366 .max_freq
= 50000000,
367 .caps
= MMC_CAP_MMC_HIGHSPEED
| MMC_CAP_SD_HIGHSPEED
,
368 .version
= MMC_CTLR_VERSION_2
,
371 static void da850_panel_power_ctrl(int val
)
374 gpio_set_value(DA850_LCD_BL_PIN
, val
);
377 gpio_set_value(DA850_LCD_PWR_PIN
, val
);
380 static int da850_lcd_hw_init(void)
384 status
= gpio_request(DA850_LCD_BL_PIN
, "lcd bl\n");
388 status
= gpio_request(DA850_LCD_PWR_PIN
, "lcd pwr\n");
390 gpio_free(DA850_LCD_BL_PIN
);
394 gpio_direction_output(DA850_LCD_BL_PIN
, 0);
395 gpio_direction_output(DA850_LCD_PWR_PIN
, 0);
397 /* Switch off panel power and backlight */
398 da850_panel_power_ctrl(0);
400 /* Switch on panel power and backlight */
401 da850_panel_power_ctrl(1);
406 /* TPS65070 voltage regulator support */
409 static struct regulator_consumer_supply tps65070_dcdc1_consumers
[] = {
411 .supply
= "usb0_vdda33",
414 .supply
= "usb1_vdda33",
419 static struct regulator_consumer_supply tps65070_dcdc2_consumers
[] = {
421 .supply
= "dvdd3318_a",
424 .supply
= "dvdd3318_b",
427 .supply
= "dvdd3318_c",
432 static struct regulator_consumer_supply tps65070_dcdc3_consumers
[] = {
439 static struct regulator_consumer_supply tps65070_ldo1_consumers
[] = {
441 .supply
= "sata_vddr",
444 .supply
= "usb0_vdda18",
447 .supply
= "usb1_vdda18",
450 .supply
= "ddr_dvdd18",
455 static struct regulator_consumer_supply tps65070_ldo2_consumers
[] = {
457 .supply
= "sata_vdd",
460 .supply
= "pll0_vdda",
463 .supply
= "pll1_vdda",
466 .supply
= "usbs_cvdd",
469 .supply
= "vddarnwa1",
473 /* We take advantage of the fact that both defdcdc{2,3} are tied high */
474 static struct tps6507x_reg_platform_data tps6507x_platform_data
= {
475 .defdcdc_default
= true,
478 static struct regulator_init_data tps65070_regulator_data
[] = {
484 .valid_ops_mask
= (REGULATOR_CHANGE_VOLTAGE
|
485 REGULATOR_CHANGE_STATUS
),
488 .num_consumer_supplies
= ARRAY_SIZE(tps65070_dcdc1_consumers
),
489 .consumer_supplies
= tps65070_dcdc1_consumers
,
497 .valid_ops_mask
= (REGULATOR_CHANGE_VOLTAGE
|
498 REGULATOR_CHANGE_STATUS
),
501 .num_consumer_supplies
= ARRAY_SIZE(tps65070_dcdc2_consumers
),
502 .consumer_supplies
= tps65070_dcdc2_consumers
,
503 .driver_data
= &tps6507x_platform_data
,
511 .valid_ops_mask
= (REGULATOR_CHANGE_VOLTAGE
|
512 REGULATOR_CHANGE_STATUS
),
515 .num_consumer_supplies
= ARRAY_SIZE(tps65070_dcdc3_consumers
),
516 .consumer_supplies
= tps65070_dcdc3_consumers
,
517 .driver_data
= &tps6507x_platform_data
,
525 .valid_ops_mask
= (REGULATOR_CHANGE_VOLTAGE
|
526 REGULATOR_CHANGE_STATUS
),
529 .num_consumer_supplies
= ARRAY_SIZE(tps65070_ldo1_consumers
),
530 .consumer_supplies
= tps65070_ldo1_consumers
,
538 .valid_ops_mask
= (REGULATOR_CHANGE_VOLTAGE
|
539 REGULATOR_CHANGE_STATUS
),
542 .num_consumer_supplies
= ARRAY_SIZE(tps65070_ldo2_consumers
),
543 .consumer_supplies
= tps65070_ldo2_consumers
,
547 static struct touchscreen_init_data tps6507x_touchscreen_data
= {
548 .poll_period
= 30, /* ms between touch samples */
549 .min_pressure
= 0x30, /* minimum pressure to trigger touch */
550 .vref
= 0, /* turn off vref when not using A/D */
551 .vendor
= 0, /* /sys/class/input/input?/id/vendor */
552 .product
= 65070, /* /sys/class/input/input?/id/product */
553 .version
= 0x100, /* /sys/class/input/input?/id/version */
556 static struct tps6507x_board tps_board
= {
557 .tps6507x_pmic_init_data
= &tps65070_regulator_data
[0],
558 .tps6507x_ts_init_data
= &tps6507x_touchscreen_data
,
561 static struct i2c_board_info __initdata da850evm_tps65070_info
[] = {
563 I2C_BOARD_INFO("tps6507x", 0x48),
564 .platform_data
= &tps_board
,
568 static int __init
pmic_tps65070_init(void)
570 return i2c_register_board_info(1, da850evm_tps65070_info
,
571 ARRAY_SIZE(da850evm_tps65070_info
));
574 static const short da850_evm_lcdc_pins
[] = {
575 DA850_GPIO2_8
, DA850_GPIO2_15
,
579 static int __init
da850_evm_config_emac(void)
581 void __iomem
*cfg_chip3_base
;
584 struct davinci_soc_info
*soc_info
= &davinci_soc_info
;
585 u8 rmii_en
= soc_info
->emac_pdata
->rmii_en
;
587 if (!machine_is_davinci_da850_evm())
590 cfg_chip3_base
= DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG
);
592 val
= __raw_readl(cfg_chip3_base
);
596 ret
= davinci_cfg_reg_list(da850_rmii_pins
);
597 pr_info("EMAC: RMII PHY configured, MII PHY will not be"
601 ret
= davinci_cfg_reg_list(da850_cpgmac_pins
);
602 pr_info("EMAC: MII PHY configured, RMII PHY will not be"
607 pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
610 /* configure the CFGCHIP3 register for RMII or MII */
611 __raw_writel(val
, cfg_chip3_base
);
613 ret
= davinci_cfg_reg(DA850_GPIO2_6
);
615 pr_warning("da850_evm_init:GPIO(2,6) mux setup "
618 ret
= gpio_request(DA850_MII_MDIO_CLKEN_PIN
, "mdio_clk_en");
620 pr_warning("Cannot open GPIO %d\n",
621 DA850_MII_MDIO_CLKEN_PIN
);
625 /* Enable/Disable MII MDIO clock */
626 gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN
, rmii_en
);
628 soc_info
->emac_pdata
->phy_mask
= DA850_EVM_PHY_MASK
;
629 soc_info
->emac_pdata
->mdio_max_freq
= DA850_EVM_MDIO_FREQUENCY
;
631 ret
= da8xx_register_emac();
633 pr_warning("da850_evm_init: emac registration failed: %d\n",
638 device_initcall(da850_evm_config_emac
);
641 * The following EDMA channels/slots are not being used by drivers (for
642 * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
643 * they are being reserved for codecs on the DSP side.
645 static const s16 da850_dma0_rsv_chans
[][2] = {
646 /* (offset, number) */
653 static const s16 da850_dma0_rsv_slots
[][2] = {
654 /* (offset, number) */
661 static const s16 da850_dma1_rsv_chans
[][2] = {
662 /* (offset, number) */
668 static const s16 da850_dma1_rsv_slots
[][2] = {
669 /* (offset, number) */
675 static struct edma_rsv_info da850_edma_cc0_rsv
= {
676 .rsv_chans
= da850_dma0_rsv_chans
,
677 .rsv_slots
= da850_dma0_rsv_slots
,
680 static struct edma_rsv_info da850_edma_cc1_rsv
= {
681 .rsv_chans
= da850_dma1_rsv_chans
,
682 .rsv_slots
= da850_dma1_rsv_slots
,
685 static struct edma_rsv_info
*da850_edma_rsv
[2] = {
690 static __init
void da850_evm_init(void)
694 ret
= pmic_tps65070_init();
696 pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
699 ret
= da850_register_edma(da850_edma_rsv
);
701 pr_warning("da850_evm_init: edma registration failed: %d\n",
704 ret
= davinci_cfg_reg_list(da850_i2c0_pins
);
706 pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
709 ret
= da8xx_register_i2c(0, &da850_evm_i2c_0_pdata
);
711 pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
715 ret
= da8xx_register_watchdog();
717 pr_warning("da830_evm_init: watchdog registration failed: %d\n",
721 ret
= davinci_cfg_reg_list(da850_mmcsd0_pins
);
723 pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
726 ret
= gpio_request(DA850_MMCSD_CD_PIN
, "MMC CD\n");
728 pr_warning("da850_evm_init: can not open GPIO %d\n",
730 gpio_direction_input(DA850_MMCSD_CD_PIN
);
732 ret
= gpio_request(DA850_MMCSD_WP_PIN
, "MMC WP\n");
734 pr_warning("da850_evm_init: can not open GPIO %d\n",
736 gpio_direction_input(DA850_MMCSD_WP_PIN
);
738 ret
= da8xx_register_mmcsd0(&da850_mmc_config
);
740 pr_warning("da850_evm_init: mmcsd0 registration failed:"
744 davinci_serial_init(&da850_evm_uart_config
);
746 i2c_register_board_info(1, da850_evm_i2c_devices
,
747 ARRAY_SIZE(da850_evm_i2c_devices
));
750 * shut down uart 0 and 1; they are not used on the board and
751 * accessing them causes endless "too much work in irq53" messages
754 __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE
) + 0x30);
755 __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE
) + 0x30);
757 ret
= davinci_cfg_reg_list(da850_mcasp_pins
);
759 pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
762 da8xx_register_mcasp(0, &da850_evm_snd_data
);
764 ret
= davinci_cfg_reg_list(da850_lcdcntl_pins
);
766 pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
769 /* Handle board specific muxing for LCD here */
770 ret
= davinci_cfg_reg_list(da850_evm_lcdc_pins
);
772 pr_warning("da850_evm_init: evm specific lcd mux setup "
773 "failed: %d\n", ret
);
775 ret
= da850_lcd_hw_init();
777 pr_warning("da850_evm_init: lcd initialization failed: %d\n",
780 sharp_lk043t1dg01_pdata
.panel_power_ctrl
= da850_panel_power_ctrl
,
781 ret
= da8xx_register_lcdc(&sharp_lk043t1dg01_pdata
);
783 pr_warning("da850_evm_init: lcdc registration failed: %d\n",
786 ret
= da8xx_register_rtc();
788 pr_warning("da850_evm_init: rtc setup failed: %d\n", ret
);
790 ret
= da850_register_cpufreq();
792 pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
795 ret
= da8xx_register_cpuidle();
797 pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
800 ret
= da850_register_pm(&da850_pm_device
);
802 pr_warning("da850_evm_init: suspend registration failed: %d\n",
806 #ifdef CONFIG_SERIAL_8250_CONSOLE
807 static int __init
da850_evm_console_init(void)
809 return add_preferred_console("ttyS", 2, "115200");
811 console_initcall(da850_evm_console_init
);
814 static void __init
da850_evm_map_io(void)
819 MACHINE_START(DAVINCI_DA850_EVM
, "DaVinci DA850/OMAP-L138/AM18x EVM")
821 .io_pg_offst
= (__IO_ADDRESS(IO_PHYS
) >> 18) & 0xfffc,
822 .boot_params
= (DA8XX_DDR_BASE
+ 0x100),
823 .map_io
= da850_evm_map_io
,
824 .init_irq
= cp_intc_init
,
825 .timer
= &davinci_timer
,
826 .init_machine
= da850_evm_init
,