blob: b037d725c3af0ed3b8bd4533d6cd36e1cc84517e [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Frederik Kriewitz99396502009-08-23 12:56:42 +02002/*
3 * (C) Copyright 2004-2008
4 * Texas Instruments, <www.ti.com>
5 *
6 * Author :
7 * Sunil Kumar <sunilsaini05@gmail.com>
8 * Shashi Ranjan <shashiranjanmca05@gmail.com>
9 *
10 * (C) Copyright 2009
11 * Frederik Kriewitz <frederik@kriewitz.eu>
12 *
13 * Derived from Beagle Board and 3430 SDP code by
14 * Richard Woodruff <r-woodruff2@ti.com>
15 * Syed Mohammed Khasim <khasim@ti.com>
16 *
Frederik Kriewitz99396502009-08-23 12:56:42 +020017 */
18#include <common.h>
Anthoine Bourgeoiscf84a822015-01-02 00:35:43 +010019#include <dm.h>
Simon Glass5e6201b2019-08-01 09:46:51 -060020#include <env.h>
Simon Glass9bc15642020-02-03 07:36:16 -070021#include <malloc.h>
Anthoine Bourgeoiscf84a822015-01-02 00:35:43 +010022#include <ns16550.h>
Frederik Kriewitz99396502009-08-23 12:56:42 +020023#include <twl4030.h>
24#include <asm/io.h>
Tom Rinibde8eea2011-09-03 21:52:45 -040025#include <asm/arch/mmc_host_def.h>
Frederik Kriewitz99396502009-08-23 12:56:42 +020026#include <asm/arch/mux.h>
27#include <asm/arch/sys_proto.h>
28#include <asm/arch/mem.h>
29#include <asm/mach-types.h>
30#include "devkit8000.h"
Simon Schwarzbbb57cb2012-03-15 04:01:40 +000031#include <asm/gpio.h>
Frederik Kriewitz99396502009-08-23 12:56:42 +020032#ifdef CONFIG_DRIVER_DM9000
33#include <net.h>
34#include <netdev.h>
35#endif
36
37DECLARE_GLOBAL_DATA_PTR;
38
Thomas Weber30e219a2011-12-13 05:54:17 +000039static u32 gpmc_net_config[GPMC_MAX_REG] = {
40 NET_GPMC_CONFIG1,
41 NET_GPMC_CONFIG2,
42 NET_GPMC_CONFIG3,
43 NET_GPMC_CONFIG4,
44 NET_GPMC_CONFIG5,
45 NET_GPMC_CONFIG6,
46 0
47};
48
Anthoine Bourgeoiscf84a822015-01-02 00:35:43 +010049static const struct ns16550_platdata devkit8000_serial = {
Adam Fordd1e22fa2016-03-07 21:08:49 -060050 .base = OMAP34XX_UART3,
51 .reg_shift = 2,
Heiko Schocher06f108e2017-01-18 08:05:49 +010052 .clock = V_NS16550_CLK,
53 .fcr = UART_FCR_DEFVAL,
Anthoine Bourgeoiscf84a822015-01-02 00:35:43 +010054};
55
56U_BOOT_DEVICE(devkit8000_uart) = {
Thomas Chou52ac4432015-11-19 21:48:12 +080057 "ns16550_serial",
Anthoine Bourgeoiscf84a822015-01-02 00:35:43 +010058 &devkit8000_serial
59};
60
Frederik Kriewitz99396502009-08-23 12:56:42 +020061/*
62 * Routine: board_init
63 * Description: Early hardware init.
64 */
65int board_init(void)
66{
67 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
68 /* board id for Linux */
69 gd->bd->bi_arch_number = MACH_TYPE_DEVKIT8000;
70 /* boot param addr */
71 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
72
73 return 0;
74}
75
Simon Schwarz23cced12012-03-15 04:01:37 +000076/* Configure GPMC registers for DM9000 */
77static void gpmc_dm9000_config(void)
78{
79 enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[6],
80 CONFIG_DM9000_BASE, GPMC_SIZE_16M);
81}
82
Frederik Kriewitz99396502009-08-23 12:56:42 +020083/*
84 * Routine: misc_init_r
85 * Description: Configure board specific parts
86 */
87int misc_init_r(void)
88{
89 struct ctrl_id *id_base = (struct ctrl_id *)OMAP34XX_ID_L4_IO_BASE;
90#ifdef CONFIG_DRIVER_DM9000
91 uchar enetaddr[6];
92 u32 die_id_0;
93#endif
94
95 twl4030_power_init();
96#ifdef CONFIG_TWL4030_LED
Grazvydas Ignotas17887bf2009-12-10 17:10:21 +020097 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
Frederik Kriewitz99396502009-08-23 12:56:42 +020098#endif
99
100#ifdef CONFIG_DRIVER_DM9000
101 /* Configure GPMC registers for DM9000 */
Thomas Weber30e219a2011-12-13 05:54:17 +0000102 enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[6],
103 CONFIG_DM9000_BASE, GPMC_SIZE_16M);
Frederik Kriewitz99396502009-08-23 12:56:42 +0200104
105 /* Use OMAP DIE_ID as MAC address */
Simon Glass399a9ce2017-08-03 12:22:14 -0600106 if (!eth_env_get_enetaddr("ethaddr", enetaddr)) {
Frederik Kriewitz99396502009-08-23 12:56:42 +0200107 printf("ethaddr not set, using Die ID\n");
108 die_id_0 = readl(&id_base->die_id_0);
109 enetaddr[0] = 0x02; /* locally administered */
110 enetaddr[1] = readl(&id_base->die_id_1) & 0xff;
111 enetaddr[2] = (die_id_0 & 0xff000000) >> 24;
112 enetaddr[3] = (die_id_0 & 0x00ff0000) >> 16;
113 enetaddr[4] = (die_id_0 & 0x0000ff00) >> 8;
114 enetaddr[5] = (die_id_0 & 0x000000ff);
Simon Glass8551d552017-08-03 12:22:11 -0600115 eth_env_set_enetaddr("ethaddr", enetaddr);
Frederik Kriewitz99396502009-08-23 12:56:42 +0200116 }
117#endif
118
Paul Kocialkowski6bc318e2015-08-27 19:37:13 +0200119 omap_die_id_display();
Frederik Kriewitz99396502009-08-23 12:56:42 +0200120
121 return 0;
122}
123
124/*
125 * Routine: set_muxconf_regs
126 * Description: Setting up the configuration Mux registers specific to the
127 * hardware. Many pins need to be moved from protect to primary
128 * mode.
129 */
130void set_muxconf_regs(void)
131{
132 MUX_DEVKIT8000();
133}
134
Masahiro Yamada0a780172017-05-09 20:31:39 +0900135#if defined(CONFIG_MMC)
Tom Rinibde8eea2011-09-03 21:52:45 -0400136int board_mmc_init(bd_t *bis)
137{
Nikita Kiryanov4be9dbc2012-12-03 02:19:47 +0000138 return omap_mmc_init(0, 0, 0, -1, -1);
Tom Rinibde8eea2011-09-03 21:52:45 -0400139}
140#endif
141
Masahiro Yamada0a780172017-05-09 20:31:39 +0900142#if defined(CONFIG_MMC)
Paul Kocialkowski69559892014-11-08 20:55:47 +0100143void board_mmc_power_init(void)
144{
145 twl4030_power_mmc_init(0);
146}
147#endif
148
Simon Schwarz7ae359c2011-09-14 15:32:17 -0400149#if defined(CONFIG_DRIVER_DM9000) & !defined(CONFIG_SPL_BUILD)
Frederik Kriewitz99396502009-08-23 12:56:42 +0200150/*
151 * Routine: board_eth_init
152 * Description: Setting up the Ethernet hardware.
153 */
154int board_eth_init(bd_t *bis)
155{
156 return dm9000_initialize(bis);
157}
158#endif
Tom Rini05800b92011-11-18 12:48:06 +0000159
Simon Schwarz23cced12012-03-15 04:01:37 +0000160#ifdef CONFIG_SPL_OS_BOOT
161/*
Robert P. J. Dayc5b1e5d2016-09-07 14:27:59 -0400162 * Do board specific preparation before SPL
Simon Schwarz23cced12012-03-15 04:01:37 +0000163 * Linux boot
164 */
165void spl_board_prepare_for_linux(void)
166{
167 gpmc_dm9000_config();
168}
169
Simon Schwarzbbb57cb2012-03-15 04:01:40 +0000170/*
171 * devkit8000 specific implementation of spl_start_uboot()
172 *
173 * RETURN
174 * 0 if the button is not pressed
175 * 1 if the button is pressed
176 */
177int spl_start_uboot(void)
178{
179 int val = 0;
Stefano Babicf51b4c72013-02-23 00:53:26 +0000180 if (!gpio_request(SPL_OS_BOOT_KEY, "U-Boot key")) {
181 gpio_direction_input(SPL_OS_BOOT_KEY);
182 val = gpio_get_value(SPL_OS_BOOT_KEY);
183 gpio_free(SPL_OS_BOOT_KEY);
Simon Schwarzbbb57cb2012-03-15 04:01:40 +0000184 }
185 return !val;
186}
Simon Schwarz23cced12012-03-15 04:01:37 +0000187#endif
188
Tom Rini05800b92011-11-18 12:48:06 +0000189/*
190 * Routine: get_board_mem_timings
191 * Description: If we use SPL then there is no x-loader nor config header
192 * so we have to setup the DDR timings ourself on the first bank. This
193 * provides the timing values back to the function that configures
194 * the memory. We have either one or two banks of 128MB DDR.
195 */
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000196void get_board_mem_timings(struct board_sdrc_timings *timings)
Tom Rini05800b92011-11-18 12:48:06 +0000197{
198 /* General SDRC config */
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000199 timings->mcfg = MICRON_V_MCFG_165(128 << 20);
200 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
Tom Rini05800b92011-11-18 12:48:06 +0000201
202 /* AC timings */
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000203 timings->ctrla = MICRON_V_ACTIMA_165;
204 timings->ctrlb = MICRON_V_ACTIMB_165;
Tom Rini05800b92011-11-18 12:48:06 +0000205
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000206 timings->mr = MICRON_V_MR_165;
Tom Rini05800b92011-11-18 12:48:06 +0000207}