ea20.c 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. /*
  2. * (C) Copyright 2010
  3. * Stefano Babic, DENX Software Engineering, sbabic@denx.de
  4. *
  5. * Based on da850evm.c, original Copyrights follow:
  6. *
  7. * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
  8. *
  9. * Based on da830evm.c. Original Copyrights follow:
  10. *
  11. * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd. <nick.thompson@gefanuc.com>
  12. * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
  13. *
  14. * SPDX-License-Identifier: GPL-2.0+
  15. */
  16. #include <common.h>
  17. #include <i2c.h>
  18. #include <net.h>
  19. #include <netdev.h>
  20. #include <asm/arch/hardware.h>
  21. #include <asm/ti-common/davinci_nand.h>
  22. #include <asm/arch/emac_defs.h>
  23. #include <asm/io.h>
  24. #include <asm/arch/davinci_misc.h>
  25. #include <asm/gpio.h>
  26. #include "../../../drivers/video/da8xx-fb.h"
  27. DECLARE_GLOBAL_DATA_PTR;
  28. static const struct da8xx_panel lcd_panel = {
  29. /* Casio COM57H531x */
  30. .name = "Casio_COM57H531x",
  31. .width = 640,
  32. .height = 480,
  33. .hfp = 12,
  34. .hbp = 144,
  35. .hsw = 30,
  36. .vfp = 10,
  37. .vbp = 35,
  38. .vsw = 3,
  39. .pxl_clk = 25000000,
  40. .invert_pxl_clk = 0,
  41. };
  42. static const struct display_panel disp_panel = {
  43. QVGA,
  44. 16,
  45. 16,
  46. COLOR_ACTIVE,
  47. };
  48. static const struct lcd_ctrl_config lcd_cfg = {
  49. &disp_panel,
  50. .ac_bias = 255,
  51. .ac_bias_intrpt = 0,
  52. .dma_burst_sz = 16,
  53. .bpp = 16,
  54. .fdd = 255,
  55. .tft_alt_mode = 0,
  56. .stn_565_mode = 0,
  57. .mono_8bit_mode = 0,
  58. .invert_line_clock = 1,
  59. .invert_frm_clock = 1,
  60. .sync_edge = 0,
  61. .sync_ctrl = 1,
  62. .raster_order = 0,
  63. };
  64. /* SPI0 pin muxer settings */
  65. static const struct pinmux_config spi1_pins[] = {
  66. { pinmux(5), 1, 1 },
  67. { pinmux(5), 1, 2 },
  68. { pinmux(5), 1, 4 },
  69. { pinmux(5), 1, 5 }
  70. };
  71. /* I2C pin muxer settings */
  72. static const struct pinmux_config i2c_pins[] = {
  73. { pinmux(4), 2, 2 },
  74. { pinmux(4), 2, 3 }
  75. };
  76. /* UART0 pin muxer settings */
  77. static const struct pinmux_config uart_pins[] = {
  78. { pinmux(3), 2, 7 },
  79. { pinmux(3), 2, 6 },
  80. { pinmux(3), 2, 4 },
  81. { pinmux(3), 2, 5 }
  82. };
  83. #ifdef CONFIG_DRIVER_TI_EMAC
  84. #define HAS_RMII 1
  85. static const struct pinmux_config emac_pins[] = {
  86. { pinmux(14), 8, 2 },
  87. { pinmux(14), 8, 3 },
  88. { pinmux(14), 8, 4 },
  89. { pinmux(14), 8, 5 },
  90. { pinmux(14), 8, 6 },
  91. { pinmux(14), 8, 7 },
  92. { pinmux(15), 8, 1 },
  93. { pinmux(4), 8, 0 },
  94. { pinmux(4), 8, 1 }
  95. };
  96. #endif
  97. #ifdef CONFIG_NAND_DAVINCI
  98. const struct pinmux_config nand_pins[] = {
  99. { pinmux(7), 1, 0}, /* CS2 */
  100. { pinmux(7), 0, 1}, /* CS3 in three state*/
  101. { pinmux(7), 1, 4 }, /* EMA_WE */
  102. { pinmux(7), 1, 5 }, /* EMA_OE */
  103. { pinmux(9), 1, 0 }, /* EMA_D[7] */
  104. { pinmux(9), 1, 1 }, /* EMA_D[6] */
  105. { pinmux(9), 1, 2 }, /* EMA_D[5] */
  106. { pinmux(9), 1, 3 }, /* EMA_D[4] */
  107. { pinmux(9), 1, 4 }, /* EMA_D[3] */
  108. { pinmux(9), 1, 5 }, /* EMA_D[2] */
  109. { pinmux(9), 1, 6 }, /* EMA_D[1] */
  110. { pinmux(9), 1, 7 }, /* EMA_D[0] */
  111. { pinmux(12), 1, 5 }, /* EMA_A[2] */
  112. { pinmux(12), 1, 6 }, /* EMA_A[1] */
  113. { pinmux(6), 1, 0 } /* EMA_CLK */
  114. };
  115. #endif
  116. const struct pinmux_config gpio_pins[] = {
  117. { pinmux(13), 8, 0 }, /* GPIO6[15] RESETOUTn on SOM*/
  118. { pinmux(13), 8, 5 }, /* GPIO6[10] U0_SW0 on EA20-00101_2*/
  119. { pinmux(13), 8, 3 }, /* GPIO6[12] U0_SW1 on EA20-00101_2*/
  120. { pinmux(19), 8, 5 }, /* GPIO6[1] DISP_ON */
  121. { pinmux(14), 8, 1 } /* GPIO6[6] LCD_B_PWR*/
  122. };
  123. const struct pinmux_config lcd_pins[] = {
  124. { pinmux(17), 2, 1 }, /* LCD_D_0 */
  125. { pinmux(17), 2, 0 }, /* LCD_D_1 */
  126. { pinmux(16), 2, 7 }, /* LCD_D_2 */
  127. { pinmux(16), 2, 6 }, /* LCD_D_3 */
  128. { pinmux(16), 2, 5 }, /* LCD_D_4 */
  129. { pinmux(16), 2, 4 }, /* LCD_D_5 */
  130. { pinmux(16), 2, 3 }, /* LCD_D_6 */
  131. { pinmux(16), 2, 2 }, /* LCD_D_7 */
  132. { pinmux(18), 2, 1 }, /* LCD_D_8 */
  133. { pinmux(18), 2, 0 }, /* LCD_D_9 */
  134. { pinmux(17), 2, 7 }, /* LCD_D_10 */
  135. { pinmux(17), 2, 6 }, /* LCD_D_11 */
  136. { pinmux(17), 2, 5 }, /* LCD_D_12 */
  137. { pinmux(17), 2, 4 }, /* LCD_D_13 */
  138. { pinmux(17), 2, 3 }, /* LCD_D_14 */
  139. { pinmux(17), 2, 2 }, /* LCD_D_15 */
  140. { pinmux(18), 2, 6 }, /* LCD_PCLK */
  141. { pinmux(19), 2, 0 }, /* LCD_HSYNC */
  142. { pinmux(19), 2, 1 }, /* LCD_VSYNC */
  143. { pinmux(19), 2, 6 }, /* DA850_NLCD_AC_ENB_CS */
  144. };
  145. const struct pinmux_config halten_pin[] = {
  146. { pinmux(3), 4, 2 } /* GPIO8[6] HALTEN */
  147. };
  148. static const struct pinmux_resource pinmuxes[] = {
  149. #ifdef CONFIG_SPI_FLASH
  150. PINMUX_ITEM(spi1_pins),
  151. #endif
  152. PINMUX_ITEM(uart_pins),
  153. PINMUX_ITEM(i2c_pins),
  154. #ifdef CONFIG_NAND_DAVINCI
  155. PINMUX_ITEM(nand_pins),
  156. #endif
  157. #ifdef CONFIG_VIDEO
  158. PINMUX_ITEM(lcd_pins),
  159. #endif
  160. };
  161. static const struct lpsc_resource lpsc[] = {
  162. { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */
  163. { DAVINCI_LPSC_SPI1 }, /* Serial Flash */
  164. { DAVINCI_LPSC_EMAC }, /* image download */
  165. { DAVINCI_LPSC_UART0 }, /* console */
  166. { DAVINCI_LPSC_GPIO },
  167. { DAVINCI_LPSC_LCDC }, /* LCD */
  168. };
  169. int board_early_init_f(void)
  170. {
  171. /* PinMux for GPIO */
  172. if (davinci_configure_pin_mux(gpio_pins, ARRAY_SIZE(gpio_pins)) != 0)
  173. return 1;
  174. /* Set DISP_ON high to enable LCD output*/
  175. gpio_direction_output(97, 1);
  176. /* Set the RESETOUTn low */
  177. gpio_direction_output(111, 0);
  178. /* Set U0_SW0 low for UART0 as console*/
  179. gpio_direction_output(106, 0);
  180. /* Set U0_SW1 low for UART0 as console*/
  181. gpio_direction_output(108, 0);
  182. /* Set LCD_B_PWR low to power down LCD Backlight*/
  183. gpio_direction_output(102, 0);
  184. #ifndef CONFIG_USE_IRQ
  185. irq_init();
  186. #endif
  187. /*
  188. * NAND CS setup - cycle counts based on da850evm NAND timings in the
  189. * Linux kernel @ 25MHz EMIFA
  190. */
  191. #ifdef CONFIG_NAND_DAVINCI
  192. writel((DAVINCI_ABCR_WSETUP(0) |
  193. DAVINCI_ABCR_WSTROBE(1) |
  194. DAVINCI_ABCR_WHOLD(0) |
  195. DAVINCI_ABCR_RSETUP(0) |
  196. DAVINCI_ABCR_RSTROBE(1) |
  197. DAVINCI_ABCR_RHOLD(0) |
  198. DAVINCI_ABCR_TA(0) |
  199. DAVINCI_ABCR_ASIZE_8BIT),
  200. &davinci_emif_regs->ab1cr); /* CS2 */
  201. #endif
  202. /*
  203. * Power on required peripherals
  204. * ARM does not have access by default to PSC0 and PSC1
  205. * assuming here that the DSP bootloader has set the IOPU
  206. * such that PSC access is available to ARM
  207. */
  208. if (da8xx_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc)))
  209. return 1;
  210. /* setup the SUSPSRC for ARM to control emulation suspend */
  211. writel(readl(&davinci_syscfg_regs->suspsrc) &
  212. ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C |
  213. DAVINCI_SYSCFG_SUSPSRC_SPI1 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 |
  214. DAVINCI_SYSCFG_SUSPSRC_UART0),
  215. &davinci_syscfg_regs->suspsrc);
  216. /* configure pinmux settings */
  217. if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes)))
  218. return 1;
  219. #ifdef CONFIG_DRIVER_TI_EMAC
  220. if (davinci_configure_pin_mux(emac_pins, ARRAY_SIZE(emac_pins)) != 0)
  221. return 1;
  222. davinci_emac_mii_mode_sel(HAS_RMII);
  223. #endif /* CONFIG_DRIVER_TI_EMAC */
  224. /* enable the console UART */
  225. writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST |
  226. DAVINCI_UART_PWREMU_MGMT_UTRST),
  227. &davinci_uart0_ctrl_regs->pwremu_mgmt);
  228. /*
  229. * Reconfigure the LCDC priority to the highest to ensure that
  230. * the throughput/latency requirements for the LCDC are met.
  231. */
  232. writel(readl(&davinci_syscfg_regs->mstpri[2]) & 0x0fffffff,
  233. &davinci_syscfg_regs->mstpri[2]);
  234. return 0;
  235. }
  236. /*
  237. * Do not overwrite the console
  238. * Use always serial for U-Boot console
  239. */
  240. int overwrite_console(void)
  241. {
  242. return 1;
  243. }
  244. int board_init(void)
  245. {
  246. /* arch number of the board */
  247. gd->bd->bi_arch_number = MACH_TYPE_EA20;
  248. /* address of boot parameters */
  249. gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
  250. da8xx_video_init(&lcd_panel, &lcd_cfg, 16);
  251. return 0;
  252. }
  253. #ifdef CONFIG_BOARD_LATE_INIT
  254. int board_late_init(void)
  255. {
  256. unsigned char buf[2];
  257. int ret;
  258. /* PinMux for HALTEN */
  259. if (davinci_configure_pin_mux(halten_pin, ARRAY_SIZE(halten_pin)) != 0)
  260. return 1;
  261. /* Set HALTEN to high */
  262. gpio_direction_output(134, 1);
  263. /* Set fixed contrast settings for LCD via I2C potentiometer */
  264. buf[0] = 0x00;
  265. buf[1] = 0xd7;
  266. ret = i2c_write(0x2e, 6, 1, buf, 2);
  267. if (ret)
  268. puts("\nContrast Settings FAILED\n");
  269. /* Set LCD_B_PWR high to power up LCD Backlight*/
  270. gpio_set_value(102, 1);
  271. return 0;
  272. }
  273. #endif /* CONFIG_BOARD_LATE_INIT */
  274. #ifdef CONFIG_DRIVER_TI_EMAC
  275. /*
  276. * Initializes on-board ethernet controllers.
  277. */
  278. int board_eth_init(bd_t *bis)
  279. {
  280. if (!davinci_emac_initialize()) {
  281. printf("Error: Ethernet init failed!\n");
  282. return -1;
  283. }
  284. /*
  285. * This board has a RMII PHY. However, the MDC line on the SOM
  286. * must not be disabled (there is no MII PHY on the
  287. * baseboard) via the GPIO2[6], because this pin
  288. * disables at the same time the SPI flash.
  289. */
  290. return 0;
  291. }
  292. #endif /* CONFIG_DRIVER_TI_EMAC */