blob: 89ee079ea60ff0f836c7caabbe89a60947740dfe [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>
22#include <asm/arch/emif_defs.h>
23#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
Stefano Babic649a33e2010-11-30 11:46:56 -050046/* SPI0 pin muxer settings */
47static const struct pinmux_config spi1_pins[] = {
48 { pinmux(5), 1, 1 },
49 { pinmux(5), 1, 2 },
50 { pinmux(5), 1, 4 },
51 { pinmux(5), 1, 5 }
52};
53
Stefano Babic42059872011-10-04 23:43:38 +000054/* I2C pin muxer settings */
55static const struct pinmux_config i2c_pins[] = {
56 { pinmux(4), 2, 2 },
57 { pinmux(4), 2, 3 }
58};
59
Bastian Ruppertf9fc2372011-10-04 23:43:28 +000060/* UART0 pin muxer settings */
Stefano Babic649a33e2010-11-30 11:46:56 -050061static const struct pinmux_config uart_pins[] = {
Bastian Ruppertf9fc2372011-10-04 23:43:28 +000062 { pinmux(3), 2, 7 },
63 { pinmux(3), 2, 6 },
64 { pinmux(3), 2, 4 },
65 { pinmux(3), 2, 5 }
Stefano Babic649a33e2010-11-30 11:46:56 -050066};
67
68#ifdef CONFIG_DRIVER_TI_EMAC
69#define HAS_RMII 1
70static const struct pinmux_config emac_pins[] = {
71 { pinmux(14), 8, 2 },
72 { pinmux(14), 8, 3 },
73 { pinmux(14), 8, 4 },
74 { pinmux(14), 8, 5 },
75 { pinmux(14), 8, 6 },
76 { pinmux(14), 8, 7 },
77 { pinmux(15), 8, 1 },
78 { pinmux(4), 8, 0 },
79 { pinmux(4), 8, 1 }
80};
81#endif
82
83#ifdef CONFIG_NAND_DAVINCI
84const struct pinmux_config nand_pins[] = {
Stefano Babic17a89042011-10-04 23:43:30 +000085 { pinmux(7), 1, 0}, /* CS2 */
86 { pinmux(7), 0, 1}, /* CS3 in three state*/
87 { pinmux(7), 1, 4 }, /* EMA_WE */
88 { pinmux(7), 1, 5 }, /* EMA_OE */
89 { pinmux(9), 1, 0 }, /* EMA_D[7] */
90 { pinmux(9), 1, 1 }, /* EMA_D[6] */
91 { pinmux(9), 1, 2 }, /* EMA_D[5] */
92 { pinmux(9), 1, 3 }, /* EMA_D[4] */
93 { pinmux(9), 1, 4 }, /* EMA_D[3] */
94 { pinmux(9), 1, 5 }, /* EMA_D[2] */
95 { pinmux(9), 1, 6 }, /* EMA_D[1] */
96 { pinmux(9), 1, 7 }, /* EMA_D[0] */
97 { pinmux(12), 1, 5 }, /* EMA_A[2] */
98 { pinmux(12), 1, 6 }, /* EMA_A[1] */
99 { pinmux(6), 1, 0 } /* EMA_CLK */
Stefano Babic649a33e2010-11-30 11:46:56 -0500100};
101#endif
102
Bastian Ruppertca1646b2011-10-04 23:43:29 +0000103const struct pinmux_config gpio_pins[] = {
104 { pinmux(13), 8, 0 }, /* GPIO6[15] RESETOUTn on SOM*/
105 { pinmux(13), 8, 5 }, /* GPIO6[10] U0_SW0 on EA20-00101_2*/
Bastian Ruppert8540b162011-10-04 23:43:34 +0000106 { pinmux(13), 8, 3 }, /* GPIO6[12] U0_SW1 on EA20-00101_2*/
107 { pinmux(19), 8, 5 }, /* GPIO6[1] DISP_ON */
108 { pinmux(14), 8, 1 } /* GPIO6[6] LCD_B_PWR*/
Bastian Ruppertca1646b2011-10-04 23:43:29 +0000109};
110
Stefano Babic3c891012011-10-04 23:43:37 +0000111const struct pinmux_config lcd_pins[] = {
112 { pinmux(17), 2, 1 }, /* LCD_D_0 */
113 { pinmux(17), 2, 0 }, /* LCD_D_1 */
114 { pinmux(16), 2, 7 }, /* LCD_D_2 */
115 { pinmux(16), 2, 6 }, /* LCD_D_3 */
116 { pinmux(16), 2, 5 }, /* LCD_D_4 */
117 { pinmux(16), 2, 4 }, /* LCD_D_5 */
118 { pinmux(16), 2, 3 }, /* LCD_D_6 */
119 { pinmux(16), 2, 2 }, /* LCD_D_7 */
120 { pinmux(18), 2, 1 }, /* LCD_D_8 */
121 { pinmux(18), 2, 0 }, /* LCD_D_9 */
122 { pinmux(17), 2, 7 }, /* LCD_D_10 */
123 { pinmux(17), 2, 6 }, /* LCD_D_11 */
124 { pinmux(17), 2, 5 }, /* LCD_D_12 */
125 { pinmux(17), 2, 4 }, /* LCD_D_13 */
126 { pinmux(17), 2, 3 }, /* LCD_D_14 */
127 { pinmux(17), 2, 2 }, /* LCD_D_15 */
128 { pinmux(18), 2, 6 }, /* LCD_PCLK */
129 { pinmux(19), 2, 0 }, /* LCD_HSYNC */
130 { pinmux(19), 2, 1 }, /* LCD_VSYNC */
131 { pinmux(19), 2, 6 }, /* DA850_NLCD_AC_ENB_CS */
132};
133
Bastian Rupperte5ee9122011-10-04 23:43:33 +0000134const struct pinmux_config halten_pin[] = {
135 { pinmux(3), 4, 2 } /* GPIO8[6] HALTEN */
136};
137
Stefano Babic649a33e2010-11-30 11:46:56 -0500138static const struct pinmux_resource pinmuxes[] = {
139#ifdef CONFIG_SPI_FLASH
140 PINMUX_ITEM(spi1_pins),
141#endif
142 PINMUX_ITEM(uart_pins),
Stefano Babic42059872011-10-04 23:43:38 +0000143 PINMUX_ITEM(i2c_pins),
Stefano Babic649a33e2010-11-30 11:46:56 -0500144#ifdef CONFIG_NAND_DAVINCI
145 PINMUX_ITEM(nand_pins),
146#endif
Stefano Babic3c891012011-10-04 23:43:37 +0000147#ifdef CONFIG_VIDEO
148 PINMUX_ITEM(lcd_pins),
149#endif
Stefano Babic649a33e2010-11-30 11:46:56 -0500150};
151
152static const struct lpsc_resource lpsc[] = {
153 { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */
154 { DAVINCI_LPSC_SPI1 }, /* Serial Flash */
155 { DAVINCI_LPSC_EMAC }, /* image download */
Bastian Ruppertf9fc2372011-10-04 23:43:28 +0000156 { DAVINCI_LPSC_UART0 }, /* console */
Stefano Babic649a33e2010-11-30 11:46:56 -0500157 { DAVINCI_LPSC_GPIO },
Stefano Babic3c891012011-10-04 23:43:37 +0000158 { DAVINCI_LPSC_LCDC }, /* LCD */
Stefano Babic649a33e2010-11-30 11:46:56 -0500159};
160
Stefano Babic1c6ec6d2011-10-04 23:43:31 +0000161int board_early_init_f(void)
Stefano Babic649a33e2010-11-30 11:46:56 -0500162{
Bastian Ruppertca1646b2011-10-04 23:43:29 +0000163 /* PinMux for GPIO */
164 if (davinci_configure_pin_mux(gpio_pins, ARRAY_SIZE(gpio_pins)) != 0)
165 return 1;
166
Bastian Ruppertbdb04ab2012-09-13 22:28:59 +0000167 /* Set DISP_ON high to enable LCD output*/
168 gpio_direction_output(97, 1);
169
Bastian Ruppertca1646b2011-10-04 23:43:29 +0000170 /* Set the RESETOUTn low */
Stefano Babic1441aa62011-10-05 03:08:24 +0000171 gpio_direction_output(111, 0);
Bastian Ruppertca1646b2011-10-04 23:43:29 +0000172
173 /* Set U0_SW0 low for UART0 as console*/
Stefano Babic1441aa62011-10-05 03:08:24 +0000174 gpio_direction_output(106, 0);
Bastian Ruppertca1646b2011-10-04 23:43:29 +0000175
176 /* Set U0_SW1 low for UART0 as console*/
Stefano Babic1441aa62011-10-05 03:08:24 +0000177 gpio_direction_output(108, 0);
Bastian Ruppertca1646b2011-10-04 23:43:29 +0000178
Bastian Ruppert8540b162011-10-04 23:43:34 +0000179 /* Set LCD_B_PWR low to power down LCD Backlight*/
Stefano Babic1441aa62011-10-05 03:08:24 +0000180 gpio_direction_output(102, 0);
Bastian Ruppert8540b162011-10-04 23:43:34 +0000181
Stefano Babic649a33e2010-11-30 11:46:56 -0500182#ifndef CONFIG_USE_IRQ
183 irq_init();
184#endif
185
Stefano Babic649a33e2010-11-30 11:46:56 -0500186 /*
187 * NAND CS setup - cycle counts based on da850evm NAND timings in the
188 * Linux kernel @ 25MHz EMIFA
189 */
Stefano Babic17a89042011-10-04 23:43:30 +0000190#ifdef CONFIG_NAND_DAVINCI
Stefano Babic649a33e2010-11-30 11:46:56 -0500191 writel((DAVINCI_ABCR_WSETUP(0) |
Stefano Babic17a89042011-10-04 23:43:30 +0000192 DAVINCI_ABCR_WSTROBE(1) |
Stefano Babic649a33e2010-11-30 11:46:56 -0500193 DAVINCI_ABCR_WHOLD(0) |
194 DAVINCI_ABCR_RSETUP(0) |
195 DAVINCI_ABCR_RSTROBE(1) |
196 DAVINCI_ABCR_RHOLD(0) |
197 DAVINCI_ABCR_TA(0) |
198 DAVINCI_ABCR_ASIZE_8BIT),
Stefano Babic17a89042011-10-04 23:43:30 +0000199 &davinci_emif_regs->ab1cr); /* CS2 */
Stefano Babic649a33e2010-11-30 11:46:56 -0500200#endif
201
Stefano Babic649a33e2010-11-30 11:46:56 -0500202 /*
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
211 /* setup the SUSPSRC for ARM to control emulation suspend */
212 writel(readl(&davinci_syscfg_regs->suspsrc) &
213 ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C |
214 DAVINCI_SYSCFG_SUSPSRC_SPI1 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 |
Bastian Ruppertf9fc2372011-10-04 23:43:28 +0000215 DAVINCI_SYSCFG_SUSPSRC_UART0),
Stefano Babic649a33e2010-11-30 11:46:56 -0500216 &davinci_syscfg_regs->suspsrc);
217
218 /* configure pinmux settings */
219 if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes)))
220 return 1;
221
222#ifdef CONFIG_DRIVER_TI_EMAC
223 if (davinci_configure_pin_mux(emac_pins, ARRAY_SIZE(emac_pins)) != 0)
224 return 1;
225
226 davinci_emac_mii_mode_sel(HAS_RMII);
227#endif /* CONFIG_DRIVER_TI_EMAC */
228
229 /* enable the console UART */
230 writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST |
231 DAVINCI_UART_PWREMU_MGMT_UTRST),
Bastian Ruppertf9fc2372011-10-04 23:43:28 +0000232 &davinci_uart0_ctrl_regs->pwremu_mgmt);
Stefano Babic649a33e2010-11-30 11:46:56 -0500233
Stefano Babic3c891012011-10-04 23:43:37 +0000234 /*
235 * Reconfigure the LCDC priority to the highest to ensure that
236 * the throughput/latency requirements for the LCDC are met.
237 */
238 writel(readl(&davinci_syscfg_regs->mstpri[2]) & 0x0fffffff,
239 &davinci_syscfg_regs->mstpri[2]);
240
Stefano Babic3c891012011-10-04 23:43:37 +0000241
Stefano Babic649a33e2010-11-30 11:46:56 -0500242 return 0;
243}
244
Bastian Ruppert39e133d2012-09-13 22:29:00 +0000245/*
246 * Do not overwrite the console
247 * Use always serial for U-Boot console
248 */
249int overwrite_console(void)
250{
251 return 1;
252}
253
Stefano Babic1c6ec6d2011-10-04 23:43:31 +0000254int board_init(void)
255{
256 /* arch number of the board */
257 gd->bd->bi_arch_number = MACH_TYPE_EA20;
258
259 /* address of boot parameters */
260 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
261
Stefano Babic3c891012011-10-04 23:43:37 +0000262 da8xx_video_init(&lcd_panel, 16);
263
Stefano Babic1c6ec6d2011-10-04 23:43:31 +0000264 return 0;
265}
Bastian Rupperte5ee9122011-10-04 23:43:33 +0000266
Nobuhiro Iwamatsu2d594fd2012-04-17 16:41:54 +0000267#ifdef CONFIG_BOARD_LATE_INIT
Bastian Rupperte5ee9122011-10-04 23:43:33 +0000268
269int board_late_init(void)
270{
Bastian Ruppertbdb04ab2012-09-13 22:28:59 +0000271 unsigned char buf[2];
272 int ret;
273
Bastian Rupperte5ee9122011-10-04 23:43:33 +0000274 /* PinMux for HALTEN */
275 if (davinci_configure_pin_mux(halten_pin, ARRAY_SIZE(halten_pin)) != 0)
276 return 1;
277
278 /* Set HALTEN to high */
Stefano Babic1441aa62011-10-05 03:08:24 +0000279 gpio_direction_output(134, 1);
Bastian Rupperte5ee9122011-10-04 23:43:33 +0000280
Bastian Ruppertbdb04ab2012-09-13 22:28:59 +0000281 /* Set fixed contrast settings for LCD via I2C potentiometer */
282 buf[0] = 0x00;
283 buf[1] = 0xd7;
284 ret = i2c_write(0x2e, 6, 1, buf, 2);
285 if (ret)
286 puts("\nContrast Settings FAILED\n");
287
288 /* Set LCD_B_PWR high to power up LCD Backlight*/
289 gpio_set_value(102, 1);
Bastian Rupperte5ee9122011-10-04 23:43:33 +0000290 return 0;
291}
Nobuhiro Iwamatsu2d594fd2012-04-17 16:41:54 +0000292#endif /* CONFIG_BOARD_LATE_INIT */
Bastian Rupperte5ee9122011-10-04 23:43:33 +0000293
Stefano Babic649a33e2010-11-30 11:46:56 -0500294#ifdef CONFIG_DRIVER_TI_EMAC
295
296/*
297 * Initializes on-board ethernet controllers.
298 */
299int board_eth_init(bd_t *bis)
300{
301 if (!davinci_emac_initialize()) {
302 printf("Error: Ethernet init failed!\n");
303 return -1;
304 }
305
306 /*
307 * This board has a RMII PHY. However, the MDC line on the SOM
308 * must not be disabled (there is no MII PHY on the
309 * baseboard) via the GPIO2[6], because this pin
310 * disables at the same time the SPI flash.
311 */
312
313 return 0;
314}
315#endif /* CONFIG_DRIVER_TI_EMAC */