blob: 66804d75bd045d9a01a01f400cabbdc9abc7be5a [file] [log] [blame]
Stefano Babic649a33e2010-11-30 11:46:56 -05001/*
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 *
Wolfgang Denk1a459662013-07-08 09:37:19 +020014 * SPDX-License-Identifier: GPL-2.0+
Stefano Babic649a33e2010-11-30 11:46:56 -050015 */
16
17#include <common.h>
18#include <i2c.h>
19#include <net.h>
20#include <netdev.h>
21#include <asm/arch/hardware.h>
Khoronzhuk, Ivan3e01ed02014-06-07 04:22:52 +030022#include <asm/ti-common/davinci_nand.h>
Stefano Babic649a33e2010-11-30 11:46:56 -050023#include <asm/arch/emac_defs.h>
24#include <asm/io.h>
25#include <asm/arch/davinci_misc.h>
Stefano Babic1441aa62011-10-05 03:08:24 +000026#include <asm/gpio.h>
Heiko Schocher0017f9e2013-08-03 07:22:48 +020027#include "../../../drivers/video/da8xx-fb.h"
Stefano Babic649a33e2010-11-30 11:46:56 -050028
29DECLARE_GLOBAL_DATA_PTR;
30
Stefano Babic3c891012011-10-04 23:43:37 +000031static const struct da8xx_panel lcd_panel = {
32 /* Casio COM57H531x */
33 .name = "Casio_COM57H531x",
34 .width = 640,
35 .height = 480,
36 .hfp = 12,
37 .hbp = 144,
38 .hsw = 30,
39 .vfp = 10,
40 .vbp = 35,
41 .vsw = 3,
42 .pxl_clk = 25000000,
43 .invert_pxl_clk = 0,
44};
45
Heiko Schocher765f2f02013-08-03 07:22:50 +020046static const struct display_panel disp_panel = {
47 QVGA,
48 16,
49 16,
50 COLOR_ACTIVE,
51};
52
53static const struct lcd_ctrl_config lcd_cfg = {
54 &disp_panel,
55 .ac_bias = 255,
56 .ac_bias_intrpt = 0,
57 .dma_burst_sz = 16,
58 .bpp = 16,
59 .fdd = 255,
60 .tft_alt_mode = 0,
61 .stn_565_mode = 0,
62 .mono_8bit_mode = 0,
63 .invert_line_clock = 1,
64 .invert_frm_clock = 1,
65 .sync_edge = 0,
66 .sync_ctrl = 1,
67 .raster_order = 0,
68};
69
Stefano Babic649a33e2010-11-30 11:46:56 -050070/* SPI0 pin muxer settings */
71static const struct pinmux_config spi1_pins[] = {
72 { pinmux(5), 1, 1 },
73 { pinmux(5), 1, 2 },
74 { pinmux(5), 1, 4 },
75 { pinmux(5), 1, 5 }
76};
77
Stefano Babic42059872011-10-04 23:43:38 +000078/* I2C pin muxer settings */
79static const struct pinmux_config i2c_pins[] = {
80 { pinmux(4), 2, 2 },
81 { pinmux(4), 2, 3 }
82};
83
Bastian Ruppertf9fc2372011-10-04 23:43:28 +000084/* UART0 pin muxer settings */
Stefano Babic649a33e2010-11-30 11:46:56 -050085static const struct pinmux_config uart_pins[] = {
Bastian Ruppertf9fc2372011-10-04 23:43:28 +000086 { pinmux(3), 2, 7 },
87 { pinmux(3), 2, 6 },
88 { pinmux(3), 2, 4 },
89 { pinmux(3), 2, 5 }
Stefano Babic649a33e2010-11-30 11:46:56 -050090};
91
92#ifdef CONFIG_DRIVER_TI_EMAC
93#define HAS_RMII 1
94static const struct pinmux_config emac_pins[] = {
95 { pinmux(14), 8, 2 },
96 { pinmux(14), 8, 3 },
97 { pinmux(14), 8, 4 },
98 { pinmux(14), 8, 5 },
99 { pinmux(14), 8, 6 },
100 { pinmux(14), 8, 7 },
101 { pinmux(15), 8, 1 },
102 { pinmux(4), 8, 0 },
103 { pinmux(4), 8, 1 }
104};
105#endif
106
107#ifdef CONFIG_NAND_DAVINCI
108const struct pinmux_config nand_pins[] = {
Stefano Babic17a89042011-10-04 23:43:30 +0000109 { pinmux(7), 1, 0}, /* CS2 */
110 { pinmux(7), 0, 1}, /* CS3 in three state*/
111 { pinmux(7), 1, 4 }, /* EMA_WE */
112 { pinmux(7), 1, 5 }, /* EMA_OE */
113 { pinmux(9), 1, 0 }, /* EMA_D[7] */
114 { pinmux(9), 1, 1 }, /* EMA_D[6] */
115 { pinmux(9), 1, 2 }, /* EMA_D[5] */
116 { pinmux(9), 1, 3 }, /* EMA_D[4] */
117 { pinmux(9), 1, 4 }, /* EMA_D[3] */
118 { pinmux(9), 1, 5 }, /* EMA_D[2] */
119 { pinmux(9), 1, 6 }, /* EMA_D[1] */
120 { pinmux(9), 1, 7 }, /* EMA_D[0] */
121 { pinmux(12), 1, 5 }, /* EMA_A[2] */
122 { pinmux(12), 1, 6 }, /* EMA_A[1] */
123 { pinmux(6), 1, 0 } /* EMA_CLK */
Stefano Babic649a33e2010-11-30 11:46:56 -0500124};
125#endif
126
Bastian Ruppertca1646b2011-10-04 23:43:29 +0000127const struct pinmux_config gpio_pins[] = {
128 { pinmux(13), 8, 0 }, /* GPIO6[15] RESETOUTn on SOM*/
129 { pinmux(13), 8, 5 }, /* GPIO6[10] U0_SW0 on EA20-00101_2*/
Bastian Ruppert8540b162011-10-04 23:43:34 +0000130 { pinmux(13), 8, 3 }, /* GPIO6[12] U0_SW1 on EA20-00101_2*/
131 { pinmux(19), 8, 5 }, /* GPIO6[1] DISP_ON */
132 { pinmux(14), 8, 1 } /* GPIO6[6] LCD_B_PWR*/
Bastian Ruppertca1646b2011-10-04 23:43:29 +0000133};
134
Stefano Babic3c891012011-10-04 23:43:37 +0000135const struct pinmux_config lcd_pins[] = {
136 { pinmux(17), 2, 1 }, /* LCD_D_0 */
137 { pinmux(17), 2, 0 }, /* LCD_D_1 */
138 { pinmux(16), 2, 7 }, /* LCD_D_2 */
139 { pinmux(16), 2, 6 }, /* LCD_D_3 */
140 { pinmux(16), 2, 5 }, /* LCD_D_4 */
141 { pinmux(16), 2, 4 }, /* LCD_D_5 */
142 { pinmux(16), 2, 3 }, /* LCD_D_6 */
143 { pinmux(16), 2, 2 }, /* LCD_D_7 */
144 { pinmux(18), 2, 1 }, /* LCD_D_8 */
145 { pinmux(18), 2, 0 }, /* LCD_D_9 */
146 { pinmux(17), 2, 7 }, /* LCD_D_10 */
147 { pinmux(17), 2, 6 }, /* LCD_D_11 */
148 { pinmux(17), 2, 5 }, /* LCD_D_12 */
149 { pinmux(17), 2, 4 }, /* LCD_D_13 */
150 { pinmux(17), 2, 3 }, /* LCD_D_14 */
151 { pinmux(17), 2, 2 }, /* LCD_D_15 */
152 { pinmux(18), 2, 6 }, /* LCD_PCLK */
153 { pinmux(19), 2, 0 }, /* LCD_HSYNC */
154 { pinmux(19), 2, 1 }, /* LCD_VSYNC */
155 { pinmux(19), 2, 6 }, /* DA850_NLCD_AC_ENB_CS */
156};
157
Bastian Rupperte5ee9122011-10-04 23:43:33 +0000158const struct pinmux_config halten_pin[] = {
159 { pinmux(3), 4, 2 } /* GPIO8[6] HALTEN */
160};
161
Stefano Babic649a33e2010-11-30 11:46:56 -0500162static const struct pinmux_resource pinmuxes[] = {
163#ifdef CONFIG_SPI_FLASH
164 PINMUX_ITEM(spi1_pins),
165#endif
166 PINMUX_ITEM(uart_pins),
Stefano Babic42059872011-10-04 23:43:38 +0000167 PINMUX_ITEM(i2c_pins),
Stefano Babic649a33e2010-11-30 11:46:56 -0500168#ifdef CONFIG_NAND_DAVINCI
169 PINMUX_ITEM(nand_pins),
170#endif
Stefano Babic3c891012011-10-04 23:43:37 +0000171#ifdef CONFIG_VIDEO
172 PINMUX_ITEM(lcd_pins),
173#endif
Stefano Babic649a33e2010-11-30 11:46:56 -0500174};
175
176static const struct lpsc_resource lpsc[] = {
177 { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */
178 { DAVINCI_LPSC_SPI1 }, /* Serial Flash */
179 { DAVINCI_LPSC_EMAC }, /* image download */
Bastian Ruppertf9fc2372011-10-04 23:43:28 +0000180 { DAVINCI_LPSC_UART0 }, /* console */
Stefano Babic649a33e2010-11-30 11:46:56 -0500181 { DAVINCI_LPSC_GPIO },
Stefano Babic3c891012011-10-04 23:43:37 +0000182 { DAVINCI_LPSC_LCDC }, /* LCD */
Stefano Babic649a33e2010-11-30 11:46:56 -0500183};
184
Stefano Babic1c6ec6d2011-10-04 23:43:31 +0000185int board_early_init_f(void)
Stefano Babic649a33e2010-11-30 11:46:56 -0500186{
Bastian Ruppertca1646b2011-10-04 23:43:29 +0000187 /* PinMux for GPIO */
188 if (davinci_configure_pin_mux(gpio_pins, ARRAY_SIZE(gpio_pins)) != 0)
189 return 1;
190
Bastian Ruppertbdb04ab2012-09-13 22:28:59 +0000191 /* Set DISP_ON high to enable LCD output*/
192 gpio_direction_output(97, 1);
193
Bastian Ruppertca1646b2011-10-04 23:43:29 +0000194 /* Set the RESETOUTn low */
Stefano Babic1441aa62011-10-05 03:08:24 +0000195 gpio_direction_output(111, 0);
Bastian Ruppertca1646b2011-10-04 23:43:29 +0000196
197 /* Set U0_SW0 low for UART0 as console*/
Stefano Babic1441aa62011-10-05 03:08:24 +0000198 gpio_direction_output(106, 0);
Bastian Ruppertca1646b2011-10-04 23:43:29 +0000199
200 /* Set U0_SW1 low for UART0 as console*/
Stefano Babic1441aa62011-10-05 03:08:24 +0000201 gpio_direction_output(108, 0);
Bastian Ruppertca1646b2011-10-04 23:43:29 +0000202
Bastian Ruppert8540b162011-10-04 23:43:34 +0000203 /* Set LCD_B_PWR low to power down LCD Backlight*/
Stefano Babic1441aa62011-10-05 03:08:24 +0000204 gpio_direction_output(102, 0);
Bastian Ruppert8540b162011-10-04 23:43:34 +0000205
Stefano Babic649a33e2010-11-30 11:46:56 -0500206#ifndef CONFIG_USE_IRQ
207 irq_init();
208#endif
209
Stefano Babic649a33e2010-11-30 11:46:56 -0500210 /*
211 * NAND CS setup - cycle counts based on da850evm NAND timings in the
212 * Linux kernel @ 25MHz EMIFA
213 */
Stefano Babic17a89042011-10-04 23:43:30 +0000214#ifdef CONFIG_NAND_DAVINCI
Stefano Babic649a33e2010-11-30 11:46:56 -0500215 writel((DAVINCI_ABCR_WSETUP(0) |
Stefano Babic17a89042011-10-04 23:43:30 +0000216 DAVINCI_ABCR_WSTROBE(1) |
Stefano Babic649a33e2010-11-30 11:46:56 -0500217 DAVINCI_ABCR_WHOLD(0) |
218 DAVINCI_ABCR_RSETUP(0) |
219 DAVINCI_ABCR_RSTROBE(1) |
220 DAVINCI_ABCR_RHOLD(0) |
221 DAVINCI_ABCR_TA(0) |
222 DAVINCI_ABCR_ASIZE_8BIT),
Stefano Babic17a89042011-10-04 23:43:30 +0000223 &davinci_emif_regs->ab1cr); /* CS2 */
Stefano Babic649a33e2010-11-30 11:46:56 -0500224#endif
225
Stefano Babic649a33e2010-11-30 11:46:56 -0500226 /*
227 * Power on required peripherals
228 * ARM does not have access by default to PSC0 and PSC1
229 * assuming here that the DSP bootloader has set the IOPU
230 * such that PSC access is available to ARM
231 */
232 if (da8xx_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc)))
233 return 1;
234
235 /* setup the SUSPSRC for ARM to control emulation suspend */
236 writel(readl(&davinci_syscfg_regs->suspsrc) &
237 ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C |
238 DAVINCI_SYSCFG_SUSPSRC_SPI1 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 |
Bastian Ruppertf9fc2372011-10-04 23:43:28 +0000239 DAVINCI_SYSCFG_SUSPSRC_UART0),
Stefano Babic649a33e2010-11-30 11:46:56 -0500240 &davinci_syscfg_regs->suspsrc);
241
242 /* configure pinmux settings */
243 if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes)))
244 return 1;
245
246#ifdef CONFIG_DRIVER_TI_EMAC
247 if (davinci_configure_pin_mux(emac_pins, ARRAY_SIZE(emac_pins)) != 0)
248 return 1;
249
250 davinci_emac_mii_mode_sel(HAS_RMII);
251#endif /* CONFIG_DRIVER_TI_EMAC */
252
253 /* enable the console UART */
254 writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST |
255 DAVINCI_UART_PWREMU_MGMT_UTRST),
Bastian Ruppertf9fc2372011-10-04 23:43:28 +0000256 &davinci_uart0_ctrl_regs->pwremu_mgmt);
Stefano Babic649a33e2010-11-30 11:46:56 -0500257
Stefano Babic3c891012011-10-04 23:43:37 +0000258 /*
259 * Reconfigure the LCDC priority to the highest to ensure that
260 * the throughput/latency requirements for the LCDC are met.
261 */
262 writel(readl(&davinci_syscfg_regs->mstpri[2]) & 0x0fffffff,
263 &davinci_syscfg_regs->mstpri[2]);
264
Stefano Babic3c891012011-10-04 23:43:37 +0000265
Stefano Babic649a33e2010-11-30 11:46:56 -0500266 return 0;
267}
268
Bastian Ruppert39e133d2012-09-13 22:29:00 +0000269/*
270 * Do not overwrite the console
271 * Use always serial for U-Boot console
272 */
273int overwrite_console(void)
274{
275 return 1;
276}
277
Stefano Babic1c6ec6d2011-10-04 23:43:31 +0000278int board_init(void)
279{
280 /* arch number of the board */
281 gd->bd->bi_arch_number = MACH_TYPE_EA20;
282
283 /* address of boot parameters */
284 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
285
Heiko Schocher765f2f02013-08-03 07:22:50 +0200286 da8xx_video_init(&lcd_panel, &lcd_cfg, 16);
Stefano Babic3c891012011-10-04 23:43:37 +0000287
Stefano Babic1c6ec6d2011-10-04 23:43:31 +0000288 return 0;
289}
Bastian Rupperte5ee9122011-10-04 23:43:33 +0000290
Nobuhiro Iwamatsu2d594fd2012-04-17 16:41:54 +0000291#ifdef CONFIG_BOARD_LATE_INIT
Bastian Rupperte5ee9122011-10-04 23:43:33 +0000292
293int board_late_init(void)
294{
Bastian Ruppertbdb04ab2012-09-13 22:28:59 +0000295 unsigned char buf[2];
296 int ret;
297
Bastian Rupperte5ee9122011-10-04 23:43:33 +0000298 /* PinMux for HALTEN */
299 if (davinci_configure_pin_mux(halten_pin, ARRAY_SIZE(halten_pin)) != 0)
300 return 1;
301
302 /* Set HALTEN to high */
Stefano Babic1441aa62011-10-05 03:08:24 +0000303 gpio_direction_output(134, 1);
Bastian Rupperte5ee9122011-10-04 23:43:33 +0000304
Bastian Ruppertbdb04ab2012-09-13 22:28:59 +0000305 /* Set fixed contrast settings for LCD via I2C potentiometer */
306 buf[0] = 0x00;
307 buf[1] = 0xd7;
308 ret = i2c_write(0x2e, 6, 1, buf, 2);
309 if (ret)
310 puts("\nContrast Settings FAILED\n");
311
312 /* Set LCD_B_PWR high to power up LCD Backlight*/
313 gpio_set_value(102, 1);
Bastian Rupperte5ee9122011-10-04 23:43:33 +0000314 return 0;
315}
Nobuhiro Iwamatsu2d594fd2012-04-17 16:41:54 +0000316#endif /* CONFIG_BOARD_LATE_INIT */
Bastian Rupperte5ee9122011-10-04 23:43:33 +0000317
Stefano Babic649a33e2010-11-30 11:46:56 -0500318#ifdef CONFIG_DRIVER_TI_EMAC
319
320/*
321 * Initializes on-board ethernet controllers.
322 */
323int board_eth_init(bd_t *bis)
324{
325 if (!davinci_emac_initialize()) {
326 printf("Error: Ethernet init failed!\n");
327 return -1;
328 }
329
330 /*
331 * This board has a RMII PHY. However, the MDC line on the SOM
332 * must not be disabled (there is no MII PHY on the
333 * baseboard) via the GPIO2[6], because this pin
334 * disables at the same time the SPI flash.
335 */
336
337 return 0;
338}
339#endif /* CONFIG_DRIVER_TI_EMAC */