blob: 0808ca1a54c09548e3cc34b83146122cb6419eb3 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Frederik Kriewitzc35d7cf2009-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 Kriewitzc35d7cf2009-08-23 12:56:42 +020017 */
18#include <common.h>
Anthoine Bourgeoisa91ef4a2015-01-02 00:35:43 +010019#include <dm.h>
Simon Glass9fb625c2019-08-01 09:46:51 -060020#include <env.h>
Simon Glass691d7192020-05-10 11:40:02 -060021#include <init.h>
Simon Glass336d4612020-02-03 07:36:16 -070022#include <malloc.h>
Anthoine Bourgeoisa91ef4a2015-01-02 00:35:43 +010023#include <ns16550.h>
Frederik Kriewitzc35d7cf2009-08-23 12:56:42 +020024#include <twl4030.h>
Simon Glass401d1c42020-10-30 21:38:53 -060025#include <asm/global_data.h>
Frederik Kriewitzc35d7cf2009-08-23 12:56:42 +020026#include <asm/io.h>
Tom Rinif4085012011-09-03 21:52:45 -040027#include <asm/arch/mmc_host_def.h>
Frederik Kriewitzc35d7cf2009-08-23 12:56:42 +020028#include <asm/arch/mux.h>
29#include <asm/arch/sys_proto.h>
30#include <asm/arch/mem.h>
31#include <asm/mach-types.h>
32#include "devkit8000.h"
Simon Schwarz2d52a9a2012-03-15 04:01:40 +000033#include <asm/gpio.h>
Frederik Kriewitzc35d7cf2009-08-23 12:56:42 +020034#ifdef CONFIG_DRIVER_DM9000
35#include <net.h>
36#include <netdev.h>
37#endif
38
39DECLARE_GLOBAL_DATA_PTR;
40
Thomas Weber13b178e2011-12-13 05:54:17 +000041static u32 gpmc_net_config[GPMC_MAX_REG] = {
42 NET_GPMC_CONFIG1,
43 NET_GPMC_CONFIG2,
44 NET_GPMC_CONFIG3,
45 NET_GPMC_CONFIG4,
46 NET_GPMC_CONFIG5,
47 NET_GPMC_CONFIG6,
48 0
49};
50
Simon Glass8a8d24b2020-12-03 16:55:23 -070051static const struct ns16550_plat devkit8000_serial = {
Adam Ford2f6ed3b2016-03-07 21:08:49 -060052 .base = OMAP34XX_UART3,
53 .reg_shift = 2,
Heiko Schocher17fa0322017-01-18 08:05:49 +010054 .clock = V_NS16550_CLK,
55 .fcr = UART_FCR_DEFVAL,
Anthoine Bourgeoisa91ef4a2015-01-02 00:35:43 +010056};
57
Simon Glass20e442a2020-12-28 20:34:54 -070058U_BOOT_DRVINFO(devkit8000_uart) = {
Thomas Chouc7b96862015-11-19 21:48:12 +080059 "ns16550_serial",
Anthoine Bourgeoisa91ef4a2015-01-02 00:35:43 +010060 &devkit8000_serial
61};
62
Frederik Kriewitzc35d7cf2009-08-23 12:56:42 +020063/*
64 * Routine: board_init
65 * Description: Early hardware init.
66 */
67int board_init(void)
68{
69 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
70 /* board id for Linux */
71 gd->bd->bi_arch_number = MACH_TYPE_DEVKIT8000;
72 /* boot param addr */
73 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
74
75 return 0;
76}
77
Simon Schwarz9e70c082012-03-15 04:01:37 +000078/* Configure GPMC registers for DM9000 */
79static void gpmc_dm9000_config(void)
80{
81 enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[6],
82 CONFIG_DM9000_BASE, GPMC_SIZE_16M);
83}
84
Frederik Kriewitzc35d7cf2009-08-23 12:56:42 +020085/*
86 * Routine: misc_init_r
87 * Description: Configure board specific parts
88 */
89int misc_init_r(void)
90{
91 struct ctrl_id *id_base = (struct ctrl_id *)OMAP34XX_ID_L4_IO_BASE;
92#ifdef CONFIG_DRIVER_DM9000
93 uchar enetaddr[6];
94 u32 die_id_0;
95#endif
96
97 twl4030_power_init();
98#ifdef CONFIG_TWL4030_LED
Grazvydas Ignotasead39d72009-12-10 17:10:21 +020099 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
Frederik Kriewitzc35d7cf2009-08-23 12:56:42 +0200100#endif
101
102#ifdef CONFIG_DRIVER_DM9000
103 /* Configure GPMC registers for DM9000 */
Thomas Weber13b178e2011-12-13 05:54:17 +0000104 enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[6],
105 CONFIG_DM9000_BASE, GPMC_SIZE_16M);
Frederik Kriewitzc35d7cf2009-08-23 12:56:42 +0200106
107 /* Use OMAP DIE_ID as MAC address */
Simon Glass35affd72017-08-03 12:22:14 -0600108 if (!eth_env_get_enetaddr("ethaddr", enetaddr)) {
Frederik Kriewitzc35d7cf2009-08-23 12:56:42 +0200109 printf("ethaddr not set, using Die ID\n");
110 die_id_0 = readl(&id_base->die_id_0);
111 enetaddr[0] = 0x02; /* locally administered */
112 enetaddr[1] = readl(&id_base->die_id_1) & 0xff;
113 enetaddr[2] = (die_id_0 & 0xff000000) >> 24;
114 enetaddr[3] = (die_id_0 & 0x00ff0000) >> 16;
115 enetaddr[4] = (die_id_0 & 0x0000ff00) >> 8;
116 enetaddr[5] = (die_id_0 & 0x000000ff);
Simon Glassfd1e9592017-08-03 12:22:11 -0600117 eth_env_set_enetaddr("ethaddr", enetaddr);
Frederik Kriewitzc35d7cf2009-08-23 12:56:42 +0200118 }
119#endif
120
Paul Kocialkowski679f82c2015-08-27 19:37:13 +0200121 omap_die_id_display();
Frederik Kriewitzc35d7cf2009-08-23 12:56:42 +0200122
123 return 0;
124}
125
126/*
127 * Routine: set_muxconf_regs
128 * Description: Setting up the configuration Mux registers specific to the
129 * hardware. Many pins need to be moved from protect to primary
130 * mode.
131 */
132void set_muxconf_regs(void)
133{
134 MUX_DEVKIT8000();
135}
136
Masahiro Yamada4aa2ba32017-05-09 20:31:39 +0900137#if defined(CONFIG_MMC)
Masahiro Yamadab75d8dc2020-06-26 15:13:33 +0900138int board_mmc_init(struct bd_info *bis)
Tom Rinif4085012011-09-03 21:52:45 -0400139{
Nikita Kiryanove3913f52012-12-03 02:19:47 +0000140 return omap_mmc_init(0, 0, 0, -1, -1);
Tom Rinif4085012011-09-03 21:52:45 -0400141}
142#endif
143
Masahiro Yamada4aa2ba32017-05-09 20:31:39 +0900144#if defined(CONFIG_MMC)
Paul Kocialkowskiaac54502014-11-08 20:55:47 +0100145void board_mmc_power_init(void)
146{
147 twl4030_power_mmc_init(0);
148}
149#endif
150
Simon Schwarz3f6a4922011-09-14 15:32:17 -0400151#if defined(CONFIG_DRIVER_DM9000) & !defined(CONFIG_SPL_BUILD)
Frederik Kriewitzc35d7cf2009-08-23 12:56:42 +0200152/*
153 * Routine: board_eth_init
154 * Description: Setting up the Ethernet hardware.
155 */
Masahiro Yamadab75d8dc2020-06-26 15:13:33 +0900156int board_eth_init(struct bd_info *bis)
Frederik Kriewitzc35d7cf2009-08-23 12:56:42 +0200157{
158 return dm9000_initialize(bis);
159}
160#endif
Tom Rini9ae0d552011-11-18 12:48:06 +0000161
Simon Schwarz9e70c082012-03-15 04:01:37 +0000162#ifdef CONFIG_SPL_OS_BOOT
163/*
Robert P. J. Dayfc0b5942016-09-07 14:27:59 -0400164 * Do board specific preparation before SPL
Simon Schwarz9e70c082012-03-15 04:01:37 +0000165 * Linux boot
166 */
167void spl_board_prepare_for_linux(void)
168{
169 gpmc_dm9000_config();
170}
171
Simon Schwarz2d52a9a2012-03-15 04:01:40 +0000172/*
173 * devkit8000 specific implementation of spl_start_uboot()
174 *
175 * RETURN
176 * 0 if the button is not pressed
177 * 1 if the button is pressed
178 */
179int spl_start_uboot(void)
180{
181 int val = 0;
Stefano Babic30372962013-02-23 00:53:26 +0000182 if (!gpio_request(SPL_OS_BOOT_KEY, "U-Boot key")) {
183 gpio_direction_input(SPL_OS_BOOT_KEY);
184 val = gpio_get_value(SPL_OS_BOOT_KEY);
185 gpio_free(SPL_OS_BOOT_KEY);
Simon Schwarz2d52a9a2012-03-15 04:01:40 +0000186 }
187 return !val;
188}
Simon Schwarz9e70c082012-03-15 04:01:37 +0000189#endif
190
Tom Rini9ae0d552011-11-18 12:48:06 +0000191/*
192 * Routine: get_board_mem_timings
193 * Description: If we use SPL then there is no x-loader nor config header
194 * so we have to setup the DDR timings ourself on the first bank. This
195 * provides the timing values back to the function that configures
196 * the memory. We have either one or two banks of 128MB DDR.
197 */
Peter Barada8c4445d2012-11-13 07:40:28 +0000198void get_board_mem_timings(struct board_sdrc_timings *timings)
Tom Rini9ae0d552011-11-18 12:48:06 +0000199{
200 /* General SDRC config */
Peter Barada8c4445d2012-11-13 07:40:28 +0000201 timings->mcfg = MICRON_V_MCFG_165(128 << 20);
202 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
Tom Rini9ae0d552011-11-18 12:48:06 +0000203
204 /* AC timings */
Peter Barada8c4445d2012-11-13 07:40:28 +0000205 timings->ctrla = MICRON_V_ACTIMA_165;
206 timings->ctrlb = MICRON_V_ACTIMB_165;
Tom Rini9ae0d552011-11-18 12:48:06 +0000207
Peter Barada8c4445d2012-11-13 07:40:28 +0000208 timings->mr = MICRON_V_MR_165;
Tom Rini9ae0d552011-11-18 12:48:06 +0000209}