1649a33e4SStefano Babic /* 2649a33e4SStefano Babic * (C) Copyright 2010 3649a33e4SStefano Babic * Stefano Babic, DENX Software Engineering, sbabic@denx.de 4649a33e4SStefano Babic * 5649a33e4SStefano Babic * Based on da850evm.c, original Copyrights follow: 6649a33e4SStefano Babic * 7649a33e4SStefano Babic * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ 8649a33e4SStefano Babic * 9649a33e4SStefano Babic * Based on da830evm.c. Original Copyrights follow: 10649a33e4SStefano Babic * 11649a33e4SStefano Babic * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd. <nick.thompson@gefanuc.com> 12649a33e4SStefano Babic * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net> 13649a33e4SStefano Babic * 141a459660SWolfgang Denk * SPDX-License-Identifier: GPL-2.0+ 15649a33e4SStefano Babic */ 16649a33e4SStefano Babic 17649a33e4SStefano Babic #include <common.h> 18649a33e4SStefano Babic #include <i2c.h> 19649a33e4SStefano Babic #include <net.h> 20649a33e4SStefano Babic #include <netdev.h> 21649a33e4SStefano Babic #include <asm/arch/hardware.h> 22649a33e4SStefano Babic #include <asm/arch/emif_defs.h> 23649a33e4SStefano Babic #include <asm/arch/emac_defs.h> 24649a33e4SStefano Babic #include <asm/io.h> 25649a33e4SStefano Babic #include <asm/arch/davinci_misc.h> 261441aa6aSStefano Babic #include <asm/gpio.h> 270017f9eeSHeiko Schocher #include "../../../drivers/video/da8xx-fb.h" 28649a33e4SStefano Babic 29649a33e4SStefano Babic DECLARE_GLOBAL_DATA_PTR; 30649a33e4SStefano Babic 313c891011SStefano Babic static const struct da8xx_panel lcd_panel = { 323c891011SStefano Babic /* Casio COM57H531x */ 333c891011SStefano Babic .name = "Casio_COM57H531x", 343c891011SStefano Babic .width = 640, 353c891011SStefano Babic .height = 480, 363c891011SStefano Babic .hfp = 12, 373c891011SStefano Babic .hbp = 144, 383c891011SStefano Babic .hsw = 30, 393c891011SStefano Babic .vfp = 10, 403c891011SStefano Babic .vbp = 35, 413c891011SStefano Babic .vsw = 3, 423c891011SStefano Babic .pxl_clk = 25000000, 433c891011SStefano Babic .invert_pxl_clk = 0, 443c891011SStefano Babic }; 453c891011SStefano Babic 46*765f2f08SHeiko Schocher static const struct display_panel disp_panel = { 47*765f2f08SHeiko Schocher QVGA, 48*765f2f08SHeiko Schocher 16, 49*765f2f08SHeiko Schocher 16, 50*765f2f08SHeiko Schocher COLOR_ACTIVE, 51*765f2f08SHeiko Schocher }; 52*765f2f08SHeiko Schocher 53*765f2f08SHeiko Schocher static const struct lcd_ctrl_config lcd_cfg = { 54*765f2f08SHeiko Schocher &disp_panel, 55*765f2f08SHeiko Schocher .ac_bias = 255, 56*765f2f08SHeiko Schocher .ac_bias_intrpt = 0, 57*765f2f08SHeiko Schocher .dma_burst_sz = 16, 58*765f2f08SHeiko Schocher .bpp = 16, 59*765f2f08SHeiko Schocher .fdd = 255, 60*765f2f08SHeiko Schocher .tft_alt_mode = 0, 61*765f2f08SHeiko Schocher .stn_565_mode = 0, 62*765f2f08SHeiko Schocher .mono_8bit_mode = 0, 63*765f2f08SHeiko Schocher .invert_line_clock = 1, 64*765f2f08SHeiko Schocher .invert_frm_clock = 1, 65*765f2f08SHeiko Schocher .sync_edge = 0, 66*765f2f08SHeiko Schocher .sync_ctrl = 1, 67*765f2f08SHeiko Schocher .raster_order = 0, 68*765f2f08SHeiko Schocher }; 69*765f2f08SHeiko Schocher 70649a33e4SStefano Babic /* SPI0 pin muxer settings */ 71649a33e4SStefano Babic static const struct pinmux_config spi1_pins[] = { 72649a33e4SStefano Babic { pinmux(5), 1, 1 }, 73649a33e4SStefano Babic { pinmux(5), 1, 2 }, 74649a33e4SStefano Babic { pinmux(5), 1, 4 }, 75649a33e4SStefano Babic { pinmux(5), 1, 5 } 76649a33e4SStefano Babic }; 77649a33e4SStefano Babic 784205987aSStefano Babic /* I2C pin muxer settings */ 794205987aSStefano Babic static const struct pinmux_config i2c_pins[] = { 804205987aSStefano Babic { pinmux(4), 2, 2 }, 814205987aSStefano Babic { pinmux(4), 2, 3 } 824205987aSStefano Babic }; 834205987aSStefano Babic 84f9fc237fSBastian Ruppert /* UART0 pin muxer settings */ 85649a33e4SStefano Babic static const struct pinmux_config uart_pins[] = { 86f9fc237fSBastian Ruppert { pinmux(3), 2, 7 }, 87f9fc237fSBastian Ruppert { pinmux(3), 2, 6 }, 88f9fc237fSBastian Ruppert { pinmux(3), 2, 4 }, 89f9fc237fSBastian Ruppert { pinmux(3), 2, 5 } 90649a33e4SStefano Babic }; 91649a33e4SStefano Babic 92649a33e4SStefano Babic #ifdef CONFIG_DRIVER_TI_EMAC 93649a33e4SStefano Babic #define HAS_RMII 1 94649a33e4SStefano Babic static const struct pinmux_config emac_pins[] = { 95649a33e4SStefano Babic { pinmux(14), 8, 2 }, 96649a33e4SStefano Babic { pinmux(14), 8, 3 }, 97649a33e4SStefano Babic { pinmux(14), 8, 4 }, 98649a33e4SStefano Babic { pinmux(14), 8, 5 }, 99649a33e4SStefano Babic { pinmux(14), 8, 6 }, 100649a33e4SStefano Babic { pinmux(14), 8, 7 }, 101649a33e4SStefano Babic { pinmux(15), 8, 1 }, 102649a33e4SStefano Babic { pinmux(4), 8, 0 }, 103649a33e4SStefano Babic { pinmux(4), 8, 1 } 104649a33e4SStefano Babic }; 105649a33e4SStefano Babic #endif 106649a33e4SStefano Babic 107649a33e4SStefano Babic #ifdef CONFIG_NAND_DAVINCI 108649a33e4SStefano Babic const struct pinmux_config nand_pins[] = { 10917a8904bSStefano Babic { pinmux(7), 1, 0}, /* CS2 */ 11017a8904bSStefano Babic { pinmux(7), 0, 1}, /* CS3 in three state*/ 11117a8904bSStefano Babic { pinmux(7), 1, 4 }, /* EMA_WE */ 11217a8904bSStefano Babic { pinmux(7), 1, 5 }, /* EMA_OE */ 11317a8904bSStefano Babic { pinmux(9), 1, 0 }, /* EMA_D[7] */ 11417a8904bSStefano Babic { pinmux(9), 1, 1 }, /* EMA_D[6] */ 11517a8904bSStefano Babic { pinmux(9), 1, 2 }, /* EMA_D[5] */ 11617a8904bSStefano Babic { pinmux(9), 1, 3 }, /* EMA_D[4] */ 11717a8904bSStefano Babic { pinmux(9), 1, 4 }, /* EMA_D[3] */ 11817a8904bSStefano Babic { pinmux(9), 1, 5 }, /* EMA_D[2] */ 11917a8904bSStefano Babic { pinmux(9), 1, 6 }, /* EMA_D[1] */ 12017a8904bSStefano Babic { pinmux(9), 1, 7 }, /* EMA_D[0] */ 12117a8904bSStefano Babic { pinmux(12), 1, 5 }, /* EMA_A[2] */ 12217a8904bSStefano Babic { pinmux(12), 1, 6 }, /* EMA_A[1] */ 12317a8904bSStefano Babic { pinmux(6), 1, 0 } /* EMA_CLK */ 124649a33e4SStefano Babic }; 125649a33e4SStefano Babic #endif 126649a33e4SStefano Babic 127ca1646b8SBastian Ruppert const struct pinmux_config gpio_pins[] = { 128ca1646b8SBastian Ruppert { pinmux(13), 8, 0 }, /* GPIO6[15] RESETOUTn on SOM*/ 129ca1646b8SBastian Ruppert { pinmux(13), 8, 5 }, /* GPIO6[10] U0_SW0 on EA20-00101_2*/ 1308540b169SBastian Ruppert { pinmux(13), 8, 3 }, /* GPIO6[12] U0_SW1 on EA20-00101_2*/ 1318540b169SBastian Ruppert { pinmux(19), 8, 5 }, /* GPIO6[1] DISP_ON */ 1328540b169SBastian Ruppert { pinmux(14), 8, 1 } /* GPIO6[6] LCD_B_PWR*/ 133ca1646b8SBastian Ruppert }; 134ca1646b8SBastian Ruppert 1353c891011SStefano Babic const struct pinmux_config lcd_pins[] = { 1363c891011SStefano Babic { pinmux(17), 2, 1 }, /* LCD_D_0 */ 1373c891011SStefano Babic { pinmux(17), 2, 0 }, /* LCD_D_1 */ 1383c891011SStefano Babic { pinmux(16), 2, 7 }, /* LCD_D_2 */ 1393c891011SStefano Babic { pinmux(16), 2, 6 }, /* LCD_D_3 */ 1403c891011SStefano Babic { pinmux(16), 2, 5 }, /* LCD_D_4 */ 1413c891011SStefano Babic { pinmux(16), 2, 4 }, /* LCD_D_5 */ 1423c891011SStefano Babic { pinmux(16), 2, 3 }, /* LCD_D_6 */ 1433c891011SStefano Babic { pinmux(16), 2, 2 }, /* LCD_D_7 */ 1443c891011SStefano Babic { pinmux(18), 2, 1 }, /* LCD_D_8 */ 1453c891011SStefano Babic { pinmux(18), 2, 0 }, /* LCD_D_9 */ 1463c891011SStefano Babic { pinmux(17), 2, 7 }, /* LCD_D_10 */ 1473c891011SStefano Babic { pinmux(17), 2, 6 }, /* LCD_D_11 */ 1483c891011SStefano Babic { pinmux(17), 2, 5 }, /* LCD_D_12 */ 1493c891011SStefano Babic { pinmux(17), 2, 4 }, /* LCD_D_13 */ 1503c891011SStefano Babic { pinmux(17), 2, 3 }, /* LCD_D_14 */ 1513c891011SStefano Babic { pinmux(17), 2, 2 }, /* LCD_D_15 */ 1523c891011SStefano Babic { pinmux(18), 2, 6 }, /* LCD_PCLK */ 1533c891011SStefano Babic { pinmux(19), 2, 0 }, /* LCD_HSYNC */ 1543c891011SStefano Babic { pinmux(19), 2, 1 }, /* LCD_VSYNC */ 1553c891011SStefano Babic { pinmux(19), 2, 6 }, /* DA850_NLCD_AC_ENB_CS */ 1563c891011SStefano Babic }; 1573c891011SStefano Babic 158e5ee9125SBastian Ruppert const struct pinmux_config halten_pin[] = { 159e5ee9125SBastian Ruppert { pinmux(3), 4, 2 } /* GPIO8[6] HALTEN */ 160e5ee9125SBastian Ruppert }; 161e5ee9125SBastian Ruppert 162649a33e4SStefano Babic static const struct pinmux_resource pinmuxes[] = { 163649a33e4SStefano Babic #ifdef CONFIG_SPI_FLASH 164649a33e4SStefano Babic PINMUX_ITEM(spi1_pins), 165649a33e4SStefano Babic #endif 166649a33e4SStefano Babic PINMUX_ITEM(uart_pins), 1674205987aSStefano Babic PINMUX_ITEM(i2c_pins), 168649a33e4SStefano Babic #ifdef CONFIG_NAND_DAVINCI 169649a33e4SStefano Babic PINMUX_ITEM(nand_pins), 170649a33e4SStefano Babic #endif 1713c891011SStefano Babic #ifdef CONFIG_VIDEO 1723c891011SStefano Babic PINMUX_ITEM(lcd_pins), 1733c891011SStefano Babic #endif 174649a33e4SStefano Babic }; 175649a33e4SStefano Babic 176649a33e4SStefano Babic static const struct lpsc_resource lpsc[] = { 177649a33e4SStefano Babic { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */ 178649a33e4SStefano Babic { DAVINCI_LPSC_SPI1 }, /* Serial Flash */ 179649a33e4SStefano Babic { DAVINCI_LPSC_EMAC }, /* image download */ 180f9fc237fSBastian Ruppert { DAVINCI_LPSC_UART0 }, /* console */ 181649a33e4SStefano Babic { DAVINCI_LPSC_GPIO }, 1823c891011SStefano Babic { DAVINCI_LPSC_LCDC }, /* LCD */ 183649a33e4SStefano Babic }; 184649a33e4SStefano Babic 1851c6ec6ddSStefano Babic int board_early_init_f(void) 186649a33e4SStefano Babic { 187ca1646b8SBastian Ruppert /* PinMux for GPIO */ 188ca1646b8SBastian Ruppert if (davinci_configure_pin_mux(gpio_pins, ARRAY_SIZE(gpio_pins)) != 0) 189ca1646b8SBastian Ruppert return 1; 190ca1646b8SBastian Ruppert 191bdb04abeSBastian Ruppert /* Set DISP_ON high to enable LCD output*/ 192bdb04abeSBastian Ruppert gpio_direction_output(97, 1); 193bdb04abeSBastian Ruppert 194ca1646b8SBastian Ruppert /* Set the RESETOUTn low */ 1951441aa6aSStefano Babic gpio_direction_output(111, 0); 196ca1646b8SBastian Ruppert 197ca1646b8SBastian Ruppert /* Set U0_SW0 low for UART0 as console*/ 1981441aa6aSStefano Babic gpio_direction_output(106, 0); 199ca1646b8SBastian Ruppert 200ca1646b8SBastian Ruppert /* Set U0_SW1 low for UART0 as console*/ 2011441aa6aSStefano Babic gpio_direction_output(108, 0); 202ca1646b8SBastian Ruppert 2038540b169SBastian Ruppert /* Set LCD_B_PWR low to power down LCD Backlight*/ 2041441aa6aSStefano Babic gpio_direction_output(102, 0); 2058540b169SBastian Ruppert 206649a33e4SStefano Babic #ifndef CONFIG_USE_IRQ 207649a33e4SStefano Babic irq_init(); 208649a33e4SStefano Babic #endif 209649a33e4SStefano Babic 210649a33e4SStefano Babic /* 211649a33e4SStefano Babic * NAND CS setup - cycle counts based on da850evm NAND timings in the 212649a33e4SStefano Babic * Linux kernel @ 25MHz EMIFA 213649a33e4SStefano Babic */ 21417a8904bSStefano Babic #ifdef CONFIG_NAND_DAVINCI 215649a33e4SStefano Babic writel((DAVINCI_ABCR_WSETUP(0) | 21617a8904bSStefano Babic DAVINCI_ABCR_WSTROBE(1) | 217649a33e4SStefano Babic DAVINCI_ABCR_WHOLD(0) | 218649a33e4SStefano Babic DAVINCI_ABCR_RSETUP(0) | 219649a33e4SStefano Babic DAVINCI_ABCR_RSTROBE(1) | 220649a33e4SStefano Babic DAVINCI_ABCR_RHOLD(0) | 221649a33e4SStefano Babic DAVINCI_ABCR_TA(0) | 222649a33e4SStefano Babic DAVINCI_ABCR_ASIZE_8BIT), 22317a8904bSStefano Babic &davinci_emif_regs->ab1cr); /* CS2 */ 224649a33e4SStefano Babic #endif 225649a33e4SStefano Babic 226649a33e4SStefano Babic /* 227649a33e4SStefano Babic * Power on required peripherals 228649a33e4SStefano Babic * ARM does not have access by default to PSC0 and PSC1 229649a33e4SStefano Babic * assuming here that the DSP bootloader has set the IOPU 230649a33e4SStefano Babic * such that PSC access is available to ARM 231649a33e4SStefano Babic */ 232649a33e4SStefano Babic if (da8xx_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc))) 233649a33e4SStefano Babic return 1; 234649a33e4SStefano Babic 235649a33e4SStefano Babic /* setup the SUSPSRC for ARM to control emulation suspend */ 236649a33e4SStefano Babic writel(readl(&davinci_syscfg_regs->suspsrc) & 237649a33e4SStefano Babic ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C | 238649a33e4SStefano Babic DAVINCI_SYSCFG_SUSPSRC_SPI1 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 | 239f9fc237fSBastian Ruppert DAVINCI_SYSCFG_SUSPSRC_UART0), 240649a33e4SStefano Babic &davinci_syscfg_regs->suspsrc); 241649a33e4SStefano Babic 242649a33e4SStefano Babic /* configure pinmux settings */ 243649a33e4SStefano Babic if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes))) 244649a33e4SStefano Babic return 1; 245649a33e4SStefano Babic 246649a33e4SStefano Babic #ifdef CONFIG_DRIVER_TI_EMAC 247649a33e4SStefano Babic if (davinci_configure_pin_mux(emac_pins, ARRAY_SIZE(emac_pins)) != 0) 248649a33e4SStefano Babic return 1; 249649a33e4SStefano Babic 250649a33e4SStefano Babic davinci_emac_mii_mode_sel(HAS_RMII); 251649a33e4SStefano Babic #endif /* CONFIG_DRIVER_TI_EMAC */ 252649a33e4SStefano Babic 253649a33e4SStefano Babic /* enable the console UART */ 254649a33e4SStefano Babic writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST | 255649a33e4SStefano Babic DAVINCI_UART_PWREMU_MGMT_UTRST), 256f9fc237fSBastian Ruppert &davinci_uart0_ctrl_regs->pwremu_mgmt); 257649a33e4SStefano Babic 2583c891011SStefano Babic /* 2593c891011SStefano Babic * Reconfigure the LCDC priority to the highest to ensure that 2603c891011SStefano Babic * the throughput/latency requirements for the LCDC are met. 2613c891011SStefano Babic */ 2623c891011SStefano Babic writel(readl(&davinci_syscfg_regs->mstpri[2]) & 0x0fffffff, 2633c891011SStefano Babic &davinci_syscfg_regs->mstpri[2]); 2643c891011SStefano Babic 2653c891011SStefano Babic 266649a33e4SStefano Babic return 0; 267649a33e4SStefano Babic } 268649a33e4SStefano Babic 26939e133d1SBastian Ruppert /* 27039e133d1SBastian Ruppert * Do not overwrite the console 27139e133d1SBastian Ruppert * Use always serial for U-Boot console 27239e133d1SBastian Ruppert */ 27339e133d1SBastian Ruppert int overwrite_console(void) 27439e133d1SBastian Ruppert { 27539e133d1SBastian Ruppert return 1; 27639e133d1SBastian Ruppert } 27739e133d1SBastian Ruppert 2781c6ec6ddSStefano Babic int board_init(void) 2791c6ec6ddSStefano Babic { 2801c6ec6ddSStefano Babic /* arch number of the board */ 2811c6ec6ddSStefano Babic gd->bd->bi_arch_number = MACH_TYPE_EA20; 2821c6ec6ddSStefano Babic 2831c6ec6ddSStefano Babic /* address of boot parameters */ 2841c6ec6ddSStefano Babic gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR; 2851c6ec6ddSStefano Babic 286*765f2f08SHeiko Schocher da8xx_video_init(&lcd_panel, &lcd_cfg, 16); 2873c891011SStefano Babic 2881c6ec6ddSStefano Babic return 0; 2891c6ec6ddSStefano Babic } 290e5ee9125SBastian Ruppert 2912d594fd5SNobuhiro Iwamatsu #ifdef CONFIG_BOARD_LATE_INIT 292e5ee9125SBastian Ruppert 293e5ee9125SBastian Ruppert int board_late_init(void) 294e5ee9125SBastian Ruppert { 295bdb04abeSBastian Ruppert unsigned char buf[2]; 296bdb04abeSBastian Ruppert int ret; 297bdb04abeSBastian Ruppert 298e5ee9125SBastian Ruppert /* PinMux for HALTEN */ 299e5ee9125SBastian Ruppert if (davinci_configure_pin_mux(halten_pin, ARRAY_SIZE(halten_pin)) != 0) 300e5ee9125SBastian Ruppert return 1; 301e5ee9125SBastian Ruppert 302e5ee9125SBastian Ruppert /* Set HALTEN to high */ 3031441aa6aSStefano Babic gpio_direction_output(134, 1); 304e5ee9125SBastian Ruppert 305bdb04abeSBastian Ruppert /* Set fixed contrast settings for LCD via I2C potentiometer */ 306bdb04abeSBastian Ruppert buf[0] = 0x00; 307bdb04abeSBastian Ruppert buf[1] = 0xd7; 308bdb04abeSBastian Ruppert ret = i2c_write(0x2e, 6, 1, buf, 2); 309bdb04abeSBastian Ruppert if (ret) 310bdb04abeSBastian Ruppert puts("\nContrast Settings FAILED\n"); 311bdb04abeSBastian Ruppert 312bdb04abeSBastian Ruppert /* Set LCD_B_PWR high to power up LCD Backlight*/ 313bdb04abeSBastian Ruppert gpio_set_value(102, 1); 314e5ee9125SBastian Ruppert return 0; 315e5ee9125SBastian Ruppert } 3162d594fd5SNobuhiro Iwamatsu #endif /* CONFIG_BOARD_LATE_INIT */ 317e5ee9125SBastian Ruppert 318649a33e4SStefano Babic #ifdef CONFIG_DRIVER_TI_EMAC 319649a33e4SStefano Babic 320649a33e4SStefano Babic /* 321649a33e4SStefano Babic * Initializes on-board ethernet controllers. 322649a33e4SStefano Babic */ 323649a33e4SStefano Babic int board_eth_init(bd_t *bis) 324649a33e4SStefano Babic { 325649a33e4SStefano Babic if (!davinci_emac_initialize()) { 326649a33e4SStefano Babic printf("Error: Ethernet init failed!\n"); 327649a33e4SStefano Babic return -1; 328649a33e4SStefano Babic } 329649a33e4SStefano Babic 330649a33e4SStefano Babic /* 331649a33e4SStefano Babic * This board has a RMII PHY. However, the MDC line on the SOM 332649a33e4SStefano Babic * must not be disabled (there is no MII PHY on the 333649a33e4SStefano Babic * baseboard) via the GPIO2[6], because this pin 334649a33e4SStefano Babic * disables at the same time the SPI flash. 335649a33e4SStefano Babic */ 336649a33e4SStefano Babic 337649a33e4SStefano Babic return 0; 338649a33e4SStefano Babic } 339649a33e4SStefano Babic #endif /* CONFIG_DRIVER_TI_EMAC */ 340