blob: 875383625d45ed3387c09890a3cd0f222864eea7 [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 Glass97589732020-05-10 11:40:02 -060021#include <init.h>
Simon Glass9bc15642020-02-03 07:36:16 -070022#include <malloc.h>
Anthoine Bourgeoiscf84a822015-01-02 00:35:43 +010023#include <ns16550.h>
Frederik Kriewitz99396502009-08-23 12:56:42 +020024#include <twl4030.h>
25#include <asm/io.h>
Tom Rinibde8eea2011-09-03 21:52:45 -040026#include <asm/arch/mmc_host_def.h>
Frederik Kriewitz99396502009-08-23 12:56:42 +020027#include <asm/arch/mux.h>
28#include <asm/arch/sys_proto.h>
29#include <asm/arch/mem.h>
30#include <asm/mach-types.h>
31#include "devkit8000.h"
Simon Schwarzbbb57cb2012-03-15 04:01:40 +000032#include <asm/gpio.h>
Frederik Kriewitz99396502009-08-23 12:56:42 +020033#ifdef CONFIG_DRIVER_DM9000
34#include <net.h>
35#include <netdev.h>
36#endif
37
38DECLARE_GLOBAL_DATA_PTR;
39
Thomas Weber30e219a2011-12-13 05:54:17 +000040static u32 gpmc_net_config[GPMC_MAX_REG] = {
41 NET_GPMC_CONFIG1,
42 NET_GPMC_CONFIG2,
43 NET_GPMC_CONFIG3,
44 NET_GPMC_CONFIG4,
45 NET_GPMC_CONFIG5,
46 NET_GPMC_CONFIG6,
47 0
48};
49
Simon Glassb75b15b2020-12-03 16:55:23 -070050static const struct ns16550_plat devkit8000_serial = {
Adam Fordd1e22fa2016-03-07 21:08:49 -060051 .base = OMAP34XX_UART3,
52 .reg_shift = 2,
Heiko Schocher06f108e2017-01-18 08:05:49 +010053 .clock = V_NS16550_CLK,
54 .fcr = UART_FCR_DEFVAL,
Anthoine Bourgeoiscf84a822015-01-02 00:35:43 +010055};
56
57U_BOOT_DEVICE(devkit8000_uart) = {
Thomas Chou52ac4432015-11-19 21:48:12 +080058 "ns16550_serial",
Anthoine Bourgeoiscf84a822015-01-02 00:35:43 +010059 &devkit8000_serial
60};
61
Frederik Kriewitz99396502009-08-23 12:56:42 +020062/*
63 * Routine: board_init
64 * Description: Early hardware init.
65 */
66int board_init(void)
67{
68 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
69 /* board id for Linux */
70 gd->bd->bi_arch_number = MACH_TYPE_DEVKIT8000;
71 /* boot param addr */
72 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
73
74 return 0;
75}
76
Simon Schwarz23cced12012-03-15 04:01:37 +000077/* Configure GPMC registers for DM9000 */
78static void gpmc_dm9000_config(void)
79{
80 enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[6],
81 CONFIG_DM9000_BASE, GPMC_SIZE_16M);
82}
83
Frederik Kriewitz99396502009-08-23 12:56:42 +020084/*
85 * Routine: misc_init_r
86 * Description: Configure board specific parts
87 */
88int misc_init_r(void)
89{
90 struct ctrl_id *id_base = (struct ctrl_id *)OMAP34XX_ID_L4_IO_BASE;
91#ifdef CONFIG_DRIVER_DM9000
92 uchar enetaddr[6];
93 u32 die_id_0;
94#endif
95
96 twl4030_power_init();
97#ifdef CONFIG_TWL4030_LED
Grazvydas Ignotas17887bf2009-12-10 17:10:21 +020098 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
Frederik Kriewitz99396502009-08-23 12:56:42 +020099#endif
100
101#ifdef CONFIG_DRIVER_DM9000
102 /* Configure GPMC registers for DM9000 */
Thomas Weber30e219a2011-12-13 05:54:17 +0000103 enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[6],
104 CONFIG_DM9000_BASE, GPMC_SIZE_16M);
Frederik Kriewitz99396502009-08-23 12:56:42 +0200105
106 /* Use OMAP DIE_ID as MAC address */
Simon Glass399a9ce2017-08-03 12:22:14 -0600107 if (!eth_env_get_enetaddr("ethaddr", enetaddr)) {
Frederik Kriewitz99396502009-08-23 12:56:42 +0200108 printf("ethaddr not set, using Die ID\n");
109 die_id_0 = readl(&id_base->die_id_0);
110 enetaddr[0] = 0x02; /* locally administered */
111 enetaddr[1] = readl(&id_base->die_id_1) & 0xff;
112 enetaddr[2] = (die_id_0 & 0xff000000) >> 24;
113 enetaddr[3] = (die_id_0 & 0x00ff0000) >> 16;
114 enetaddr[4] = (die_id_0 & 0x0000ff00) >> 8;
115 enetaddr[5] = (die_id_0 & 0x000000ff);
Simon Glass8551d552017-08-03 12:22:11 -0600116 eth_env_set_enetaddr("ethaddr", enetaddr);
Frederik Kriewitz99396502009-08-23 12:56:42 +0200117 }
118#endif
119
Paul Kocialkowski6bc318e2015-08-27 19:37:13 +0200120 omap_die_id_display();
Frederik Kriewitz99396502009-08-23 12:56:42 +0200121
122 return 0;
123}
124
125/*
126 * Routine: set_muxconf_regs
127 * Description: Setting up the configuration Mux registers specific to the
128 * hardware. Many pins need to be moved from protect to primary
129 * mode.
130 */
131void set_muxconf_regs(void)
132{
133 MUX_DEVKIT8000();
134}
135
Masahiro Yamada0a780172017-05-09 20:31:39 +0900136#if defined(CONFIG_MMC)
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900137int board_mmc_init(struct bd_info *bis)
Tom Rinibde8eea2011-09-03 21:52:45 -0400138{
Nikita Kiryanov4be9dbc2012-12-03 02:19:47 +0000139 return omap_mmc_init(0, 0, 0, -1, -1);
Tom Rinibde8eea2011-09-03 21:52:45 -0400140}
141#endif
142
Masahiro Yamada0a780172017-05-09 20:31:39 +0900143#if defined(CONFIG_MMC)
Paul Kocialkowski69559892014-11-08 20:55:47 +0100144void board_mmc_power_init(void)
145{
146 twl4030_power_mmc_init(0);
147}
148#endif
149
Simon Schwarz7ae359c2011-09-14 15:32:17 -0400150#if defined(CONFIG_DRIVER_DM9000) & !defined(CONFIG_SPL_BUILD)
Frederik Kriewitz99396502009-08-23 12:56:42 +0200151/*
152 * Routine: board_eth_init
153 * Description: Setting up the Ethernet hardware.
154 */
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900155int board_eth_init(struct bd_info *bis)
Frederik Kriewitz99396502009-08-23 12:56:42 +0200156{
157 return dm9000_initialize(bis);
158}
159#endif
Tom Rini05800b92011-11-18 12:48:06 +0000160
Simon Schwarz23cced12012-03-15 04:01:37 +0000161#ifdef CONFIG_SPL_OS_BOOT
162/*
Robert P. J. Dayc5b1e5d2016-09-07 14:27:59 -0400163 * Do board specific preparation before SPL
Simon Schwarz23cced12012-03-15 04:01:37 +0000164 * Linux boot
165 */
166void spl_board_prepare_for_linux(void)
167{
168 gpmc_dm9000_config();
169}
170
Simon Schwarzbbb57cb2012-03-15 04:01:40 +0000171/*
172 * devkit8000 specific implementation of spl_start_uboot()
173 *
174 * RETURN
175 * 0 if the button is not pressed
176 * 1 if the button is pressed
177 */
178int spl_start_uboot(void)
179{
180 int val = 0;
Stefano Babicf51b4c72013-02-23 00:53:26 +0000181 if (!gpio_request(SPL_OS_BOOT_KEY, "U-Boot key")) {
182 gpio_direction_input(SPL_OS_BOOT_KEY);
183 val = gpio_get_value(SPL_OS_BOOT_KEY);
184 gpio_free(SPL_OS_BOOT_KEY);
Simon Schwarzbbb57cb2012-03-15 04:01:40 +0000185 }
186 return !val;
187}
Simon Schwarz23cced12012-03-15 04:01:37 +0000188#endif
189
Tom Rini05800b92011-11-18 12:48:06 +0000190/*
191 * Routine: get_board_mem_timings
192 * Description: If we use SPL then there is no x-loader nor config header
193 * so we have to setup the DDR timings ourself on the first bank. This
194 * provides the timing values back to the function that configures
195 * the memory. We have either one or two banks of 128MB DDR.
196 */
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000197void get_board_mem_timings(struct board_sdrc_timings *timings)
Tom Rini05800b92011-11-18 12:48:06 +0000198{
199 /* General SDRC config */
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000200 timings->mcfg = MICRON_V_MCFG_165(128 << 20);
201 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
Tom Rini05800b92011-11-18 12:48:06 +0000202
203 /* AC timings */
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000204 timings->ctrla = MICRON_V_ACTIMA_165;
205 timings->ctrlb = MICRON_V_ACTIMB_165;
Tom Rini05800b92011-11-18 12:48:06 +0000206
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000207 timings->mr = MICRON_V_MR_165;
Tom Rini05800b92011-11-18 12:48:06 +0000208}