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/gpio.h>
21 #include <linux/platform_device.h>
22 #include <linux/mtd/mtd.h>
23 #include <linux/mtd/nand.h>
24 #include <linux/mtd/partitions.h>
25 #include <linux/mtd/physmap.h>
26 #include <linux/regulator/machine.h>
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
31 #include <mach/cp_intc.h>
32 #include <mach/da8xx.h>
33 #include <mach/nand.h>
36 #define DA850_EVM_PHY_MASK 0x1
37 #define DA850_EVM_MDIO_FREQUENCY 2200000 /* PHY bus frequency */
39 #define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8)
40 #define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
42 #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
43 #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
45 #define DA850_MII_MDIO_CLKEN_PIN GPIO_TO_PIN(2, 6)
47 static struct mtd_partition da850_evm_norflash_partition[] = {
49 .name = "NOR filesystem",
51 .size = MTDPART_SIZ_FULL,
56 static struct physmap_flash_data da850_evm_norflash_data = {
58 .parts = da850_evm_norflash_partition,
59 .nr_parts = ARRAY_SIZE(da850_evm_norflash_partition),
62 static struct resource da850_evm_norflash_resource[] = {
64 .start = DA8XX_AEMIF_CS2_BASE,
65 .end = DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
66 .flags = IORESOURCE_MEM,
70 static struct platform_device da850_evm_norflash_device = {
71 .name = "physmap-flash",
74 .platform_data = &da850_evm_norflash_data,
77 .resource = da850_evm_norflash_resource,
80 /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
81 * (128K blocks). It may be used instead of the (default) SPI flash
82 * to boot, using TI's tools to install the secondary boot loader
85 struct mtd_partition da850_evm_nandflash_partition[] = {
90 .mask_flags = MTD_WRITEABLE,
94 .offset = MTDPART_OFS_APPEND,
96 .mask_flags = MTD_WRITEABLE,
100 .offset = MTDPART_OFS_APPEND,
102 .mask_flags = MTD_WRITEABLE,
111 .name = "filesystem",
112 .offset = MTDPART_OFS_APPEND,
113 .size = MTDPART_SIZ_FULL,
118 static struct davinci_nand_pdata da850_evm_nandflash_data = {
119 .parts = da850_evm_nandflash_partition,
120 .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition),
121 .ecc_mode = NAND_ECC_HW,
122 .options = NAND_USE_FLASH_BBT,
125 static struct resource da850_evm_nandflash_resource[] = {
127 .start = DA8XX_AEMIF_CS3_BASE,
128 .end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
129 .flags = IORESOURCE_MEM,
132 .start = DA8XX_AEMIF_CTL_BASE,
133 .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
134 .flags = IORESOURCE_MEM,
138 static struct platform_device da850_evm_nandflash_device = {
139 .name = "davinci_nand",
142 .platform_data = &da850_evm_nandflash_data,
144 .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
145 .resource = da850_evm_nandflash_resource,
148 static struct platform_device *da850_evm_devices[] __initdata = {
149 &da850_evm_nandflash_device,
150 &da850_evm_norflash_device,
153 #define DA8XX_AEMIF_CE2CFG_OFFSET 0x10
154 #define DA8XX_AEMIF_ASIZE_16BIT 0x1
156 static void __init da850_evm_init_nor(void)
158 void __iomem *aemif_addr;
160 aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
162 /* Configure data bus width of CS2 to 16 bit */
163 writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
164 DA8XX_AEMIF_ASIZE_16BIT,
165 aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
170 static u32 ui_card_detected;
172 #if defined(CONFIG_MMC_DAVINCI) || \
173 defined(CONFIG_MMC_DAVINCI_MODULE)
179 static __init void da850_evm_setup_nor_nand(void)
183 if (ui_card_detected & !HAS_MMC) {
184 ret = da8xx_pinmux_setup(da850_nand_pins);
186 pr_warning("da850_evm_init: nand mux setup failed: "
189 ret = da8xx_pinmux_setup(da850_nor_pins);
191 pr_warning("da850_evm_init: nor mux setup failed: %d\n",
194 da850_evm_init_nor();
196 platform_add_devices(da850_evm_devices,
197 ARRAY_SIZE(da850_evm_devices));
201 #ifdef CONFIG_DA850_UI_RMII
202 static inline void da850_evm_setup_emac_rmii(int rmii_sel)
204 struct davinci_soc_info *soc_info = &davinci_soc_info;
206 soc_info->emac_pdata->rmii_en = 1;
207 gpio_set_value(rmii_sel, 0);
210 static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
213 static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
214 unsigned ngpio, void *c)
216 int sel_a, sel_b, sel_c, ret;
222 ret = gpio_request(sel_a, "sel_a");
224 pr_warning("Cannot open UI expander pin %d\n", sel_a);
225 goto exp_setup_sela_fail;
228 ret = gpio_request(sel_b, "sel_b");
230 pr_warning("Cannot open UI expander pin %d\n", sel_b);
231 goto exp_setup_selb_fail;
234 ret = gpio_request(sel_c, "sel_c");
236 pr_warning("Cannot open UI expander pin %d\n", sel_c);
237 goto exp_setup_selc_fail;
240 /* deselect all functionalities */
241 gpio_direction_output(sel_a, 1);
242 gpio_direction_output(sel_b, 1);
243 gpio_direction_output(sel_c, 1);
245 ui_card_detected = 1;
246 pr_info("DA850/OMAP-L138 EVM UI card detected\n");
248 da850_evm_setup_nor_nand();
250 da850_evm_setup_emac_rmii(sel_a);
262 static int da850_evm_ui_expander_teardown(struct i2c_client *client,
263 unsigned gpio, unsigned ngpio, void *c)
265 /* deselect all functionalities */
266 gpio_set_value(gpio + 5, 1);
267 gpio_set_value(gpio + 6, 1);
268 gpio_set_value(gpio + 7, 1);
277 static struct pca953x_platform_data da850_evm_ui_expander_info = {
278 .gpio_base = DAVINCI_N_GPIO,
279 .setup = da850_evm_ui_expander_setup,
280 .teardown = da850_evm_ui_expander_teardown,
283 static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
285 I2C_BOARD_INFO("tlv320aic3x", 0x18),
288 I2C_BOARD_INFO("tca6416", 0x20),
289 .platform_data = &da850_evm_ui_expander_info,
293 static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
294 .bus_freq = 100, /* kHz */
295 .bus_delay = 0, /* usec */
298 static struct davinci_uart_config da850_evm_uart_config __initdata = {
299 .enabled_uarts = 0x7,
302 /* davinci da850 evm audio machine driver */
303 static u8 da850_iis_serializer_direction[] = {
304 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
305 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
306 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
307 RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
310 static struct snd_platform_data da850_evm_snd_data = {
311 .tx_dma_offset = 0x2000,
312 .rx_dma_offset = 0x2000,
313 .op_mode = DAVINCI_MCASP_IIS_MODE,
314 .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
316 .serial_dir = da850_iis_serializer_direction,
317 .eventq_no = EVENTQ_1,
318 .version = MCASP_VERSION_2,
323 static int da850_evm_mmc_get_ro(int index)
325 return gpio_get_value(DA850_MMCSD_WP_PIN);
328 static int da850_evm_mmc_get_cd(int index)
330 return !gpio_get_value(DA850_MMCSD_CD_PIN);
333 static struct davinci_mmc_config da850_mmc_config = {
334 .get_ro = da850_evm_mmc_get_ro,
335 .get_cd = da850_evm_mmc_get_cd,
337 .max_freq = 50000000,
338 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
339 .version = MMC_CTLR_VERSION_2,
342 static void da850_panel_power_ctrl(int val)
345 gpio_set_value(DA850_LCD_BL_PIN, val);
348 gpio_set_value(DA850_LCD_PWR_PIN, val);
351 static int da850_lcd_hw_init(void)
355 status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
359 status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
361 gpio_free(DA850_LCD_BL_PIN);
365 gpio_direction_output(DA850_LCD_BL_PIN, 0);
366 gpio_direction_output(DA850_LCD_PWR_PIN, 0);
368 /* Switch off panel power and backlight */
369 da850_panel_power_ctrl(0);
371 /* Switch on panel power and backlight */
372 da850_panel_power_ctrl(1);
377 /* TPS65070 voltage regulator support */
380 struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
382 .supply = "usb0_vdda33",
385 .supply = "usb1_vdda33",
390 struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
392 .supply = "dvdd3318_a",
395 .supply = "dvdd3318_b",
398 .supply = "dvdd3318_c",
403 struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
410 struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
412 .supply = "sata_vddr",
415 .supply = "usb0_vdda18",
418 .supply = "usb1_vdda18",
421 .supply = "ddr_dvdd18",
426 struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
428 .supply = "sata_vdd",
431 .supply = "pll0_vdda",
434 .supply = "pll1_vdda",
437 .supply = "usbs_cvdd",
440 .supply = "vddarnwa1",
444 struct regulator_init_data tps65070_regulator_data[] = {
450 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
451 REGULATOR_CHANGE_STATUS),
454 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
455 .consumer_supplies = tps65070_dcdc1_consumers,
463 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
464 REGULATOR_CHANGE_STATUS),
467 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
468 .consumer_supplies = tps65070_dcdc2_consumers,
476 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
477 REGULATOR_CHANGE_STATUS),
480 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
481 .consumer_supplies = tps65070_dcdc3_consumers,
489 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
490 REGULATOR_CHANGE_STATUS),
493 .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
494 .consumer_supplies = tps65070_ldo1_consumers,
502 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
503 REGULATOR_CHANGE_STATUS),
506 .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
507 .consumer_supplies = tps65070_ldo2_consumers,
511 static struct i2c_board_info __initdata da850evm_tps65070_info[] = {
513 I2C_BOARD_INFO("tps6507x", 0x48),
514 .platform_data = &tps65070_regulator_data[0],
518 static int __init pmic_tps65070_init(void)
520 return i2c_register_board_info(1, da850evm_tps65070_info,
521 ARRAY_SIZE(da850evm_tps65070_info));
524 static const short da850_evm_lcdc_pins[] = {
525 DA850_GPIO2_8, DA850_GPIO2_15,
529 static int __init da850_evm_config_emac(void)
531 void __iomem *cfg_chip3_base;
534 struct davinci_soc_info *soc_info = &davinci_soc_info;
535 u8 rmii_en = soc_info->emac_pdata->rmii_en;
537 if (!machine_is_davinci_da850_evm())
540 cfg_chip3_base = DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP3_REG);
542 val = __raw_readl(cfg_chip3_base);
546 ret = da8xx_pinmux_setup(da850_rmii_pins);
547 pr_info("EMAC: RMII PHY configured, MII PHY will not be"
551 ret = da8xx_pinmux_setup(da850_cpgmac_pins);
552 pr_info("EMAC: MII PHY configured, RMII PHY will not be"
557 pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
560 /* configure the CFGCHIP3 register for RMII or MII */
561 __raw_writel(val, cfg_chip3_base);
563 ret = davinci_cfg_reg(DA850_GPIO2_6);
565 pr_warning("da850_evm_init:GPIO(2,6) mux setup "
568 ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
570 pr_warning("Cannot open GPIO %d\n",
571 DA850_MII_MDIO_CLKEN_PIN);
575 /* Enable/Disable MII MDIO clock */
576 gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
578 soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
579 soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
581 ret = da8xx_register_emac();
583 pr_warning("da850_evm_init: emac registration failed: %d\n",
588 device_initcall(da850_evm_config_emac);
590 static __init void da850_evm_init(void)
594 ret = pmic_tps65070_init();
596 pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
599 ret = da8xx_register_edma();
601 pr_warning("da850_evm_init: edma registration failed: %d\n",
604 ret = da8xx_pinmux_setup(da850_i2c0_pins);
606 pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
609 ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
611 pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
615 ret = da8xx_register_watchdog();
617 pr_warning("da830_evm_init: watchdog registration failed: %d\n",
621 ret = da8xx_pinmux_setup(da850_mmcsd0_pins);
623 pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
626 ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
628 pr_warning("da850_evm_init: can not open GPIO %d\n",
630 gpio_direction_input(DA850_MMCSD_CD_PIN);
632 ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
634 pr_warning("da850_evm_init: can not open GPIO %d\n",
636 gpio_direction_input(DA850_MMCSD_WP_PIN);
638 ret = da8xx_register_mmcsd0(&da850_mmc_config);
640 pr_warning("da850_evm_init: mmcsd0 registration failed:"
644 davinci_serial_init(&da850_evm_uart_config);
646 i2c_register_board_info(1, da850_evm_i2c_devices,
647 ARRAY_SIZE(da850_evm_i2c_devices));
650 * shut down uart 0 and 1; they are not used on the board and
651 * accessing them causes endless "too much work in irq53" messages
654 __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
655 __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
657 ret = da8xx_pinmux_setup(da850_mcasp_pins);
659 pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
662 da8xx_register_mcasp(0, &da850_evm_snd_data);
664 ret = da8xx_pinmux_setup(da850_lcdcntl_pins);
666 pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
669 /* Handle board specific muxing for LCD here */
670 ret = da8xx_pinmux_setup(da850_evm_lcdc_pins);
672 pr_warning("da850_evm_init: evm specific lcd mux setup "
673 "failed: %d\n", ret);
675 ret = da850_lcd_hw_init();
677 pr_warning("da850_evm_init: lcd initialization failed: %d\n",
680 sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
681 ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
683 pr_warning("da850_evm_init: lcdc registration failed: %d\n",
686 ret = da8xx_register_rtc();
688 pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
690 ret = da850_register_cpufreq();
692 pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
695 ret = da8xx_register_cpuidle();
697 pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
701 #ifdef CONFIG_SERIAL_8250_CONSOLE
702 static int __init da850_evm_console_init(void)
704 return add_preferred_console("ttyS", 2, "115200");
706 console_initcall(da850_evm_console_init);
709 static __init void da850_evm_irq_init(void)
711 struct davinci_soc_info *soc_info = &davinci_soc_info;
713 cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA850_N_CP_INTC_IRQ,
714 soc_info->intc_irq_prios);
717 static void __init da850_evm_map_io(void)
722 MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138 EVM")
724 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
725 .boot_params = (DA8XX_DDR_BASE + 0x100),
726 .map_io = da850_evm_map_io,
727 .init_irq = da850_evm_irq_init,
728 .timer = &davinci_timer,
729 .init_machine = da850_evm_init,