Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Frederik Kriewitz | c35d7cf | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 2 | /* |
| 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 Kriewitz | c35d7cf | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 17 | */ |
| 18 | #include <common.h> |
Anthoine Bourgeois | a91ef4a | 2015-01-02 00:35:43 +0100 | [diff] [blame] | 19 | #include <dm.h> |
Simon Glass | 9fb625c | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 20 | #include <env.h> |
Simon Glass | 691d719 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 21 | #include <init.h> |
Simon Glass | 336d461 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 22 | #include <malloc.h> |
Anthoine Bourgeois | a91ef4a | 2015-01-02 00:35:43 +0100 | [diff] [blame] | 23 | #include <ns16550.h> |
Frederik Kriewitz | c35d7cf | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 24 | #include <twl4030.h> |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 25 | #include <asm/global_data.h> |
Frederik Kriewitz | c35d7cf | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 26 | #include <asm/io.h> |
Tom Rini | f408501 | 2011-09-03 21:52:45 -0400 | [diff] [blame] | 27 | #include <asm/arch/mmc_host_def.h> |
Frederik Kriewitz | c35d7cf | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 28 | #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 Schwarz | 2d52a9a | 2012-03-15 04:01:40 +0000 | [diff] [blame] | 33 | #include <asm/gpio.h> |
Frederik Kriewitz | c35d7cf | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 34 | #ifdef CONFIG_DRIVER_DM9000 |
| 35 | #include <net.h> |
| 36 | #include <netdev.h> |
| 37 | #endif |
| 38 | |
| 39 | DECLARE_GLOBAL_DATA_PTR; |
| 40 | |
Thomas Weber | 13b178e | 2011-12-13 05:54:17 +0000 | [diff] [blame] | 41 | static 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 Glass | 8a8d24b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 51 | static const struct ns16550_plat devkit8000_serial = { |
Adam Ford | 2f6ed3b | 2016-03-07 21:08:49 -0600 | [diff] [blame] | 52 | .base = OMAP34XX_UART3, |
| 53 | .reg_shift = 2, |
Heiko Schocher | 17fa032 | 2017-01-18 08:05:49 +0100 | [diff] [blame] | 54 | .clock = V_NS16550_CLK, |
| 55 | .fcr = UART_FCR_DEFVAL, |
Anthoine Bourgeois | a91ef4a | 2015-01-02 00:35:43 +0100 | [diff] [blame] | 56 | }; |
| 57 | |
Simon Glass | 20e442a | 2020-12-28 20:34:54 -0700 | [diff] [blame] | 58 | U_BOOT_DRVINFO(devkit8000_uart) = { |
Thomas Chou | c7b9686 | 2015-11-19 21:48:12 +0800 | [diff] [blame] | 59 | "ns16550_serial", |
Anthoine Bourgeois | a91ef4a | 2015-01-02 00:35:43 +0100 | [diff] [blame] | 60 | &devkit8000_serial |
| 61 | }; |
| 62 | |
Frederik Kriewitz | c35d7cf | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 63 | /* |
| 64 | * Routine: board_init |
| 65 | * Description: Early hardware init. |
| 66 | */ |
| 67 | int 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 Schwarz | 9e70c08 | 2012-03-15 04:01:37 +0000 | [diff] [blame] | 78 | /* Configure GPMC registers for DM9000 */ |
| 79 | static 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 Kriewitz | c35d7cf | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 85 | /* |
| 86 | * Routine: misc_init_r |
| 87 | * Description: Configure board specific parts |
| 88 | */ |
| 89 | int 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 Ignotas | ead39d7 | 2009-12-10 17:10:21 +0200 | [diff] [blame] | 99 | twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON); |
Frederik Kriewitz | c35d7cf | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 100 | #endif |
| 101 | |
| 102 | #ifdef CONFIG_DRIVER_DM9000 |
| 103 | /* Configure GPMC registers for DM9000 */ |
Thomas Weber | 13b178e | 2011-12-13 05:54:17 +0000 | [diff] [blame] | 104 | enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[6], |
| 105 | CONFIG_DM9000_BASE, GPMC_SIZE_16M); |
Frederik Kriewitz | c35d7cf | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 106 | |
| 107 | /* Use OMAP DIE_ID as MAC address */ |
Simon Glass | 35affd7 | 2017-08-03 12:22:14 -0600 | [diff] [blame] | 108 | if (!eth_env_get_enetaddr("ethaddr", enetaddr)) { |
Frederik Kriewitz | c35d7cf | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 109 | 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 Glass | fd1e959 | 2017-08-03 12:22:11 -0600 | [diff] [blame] | 117 | eth_env_set_enetaddr("ethaddr", enetaddr); |
Frederik Kriewitz | c35d7cf | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 118 | } |
| 119 | #endif |
| 120 | |
Paul Kocialkowski | 679f82c | 2015-08-27 19:37:13 +0200 | [diff] [blame] | 121 | omap_die_id_display(); |
Frederik Kriewitz | c35d7cf | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 122 | |
| 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 | */ |
| 132 | void set_muxconf_regs(void) |
| 133 | { |
| 134 | MUX_DEVKIT8000(); |
| 135 | } |
| 136 | |
Masahiro Yamada | 4aa2ba3 | 2017-05-09 20:31:39 +0900 | [diff] [blame] | 137 | #if defined(CONFIG_MMC) |
Masahiro Yamada | b75d8dc | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 138 | int board_mmc_init(struct bd_info *bis) |
Tom Rini | f408501 | 2011-09-03 21:52:45 -0400 | [diff] [blame] | 139 | { |
Nikita Kiryanov | e3913f5 | 2012-12-03 02:19:47 +0000 | [diff] [blame] | 140 | return omap_mmc_init(0, 0, 0, -1, -1); |
Tom Rini | f408501 | 2011-09-03 21:52:45 -0400 | [diff] [blame] | 141 | } |
| 142 | #endif |
| 143 | |
Masahiro Yamada | 4aa2ba3 | 2017-05-09 20:31:39 +0900 | [diff] [blame] | 144 | #if defined(CONFIG_MMC) |
Paul Kocialkowski | aac5450 | 2014-11-08 20:55:47 +0100 | [diff] [blame] | 145 | void board_mmc_power_init(void) |
| 146 | { |
| 147 | twl4030_power_mmc_init(0); |
| 148 | } |
| 149 | #endif |
| 150 | |
Simon Schwarz | 3f6a492 | 2011-09-14 15:32:17 -0400 | [diff] [blame] | 151 | #if defined(CONFIG_DRIVER_DM9000) & !defined(CONFIG_SPL_BUILD) |
Frederik Kriewitz | c35d7cf | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 152 | /* |
| 153 | * Routine: board_eth_init |
| 154 | * Description: Setting up the Ethernet hardware. |
| 155 | */ |
Masahiro Yamada | b75d8dc | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 156 | int board_eth_init(struct bd_info *bis) |
Frederik Kriewitz | c35d7cf | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 157 | { |
| 158 | return dm9000_initialize(bis); |
| 159 | } |
| 160 | #endif |
Tom Rini | 9ae0d55 | 2011-11-18 12:48:06 +0000 | [diff] [blame] | 161 | |
Simon Schwarz | 9e70c08 | 2012-03-15 04:01:37 +0000 | [diff] [blame] | 162 | #ifdef CONFIG_SPL_OS_BOOT |
| 163 | /* |
Robert P. J. Day | fc0b594 | 2016-09-07 14:27:59 -0400 | [diff] [blame] | 164 | * Do board specific preparation before SPL |
Simon Schwarz | 9e70c08 | 2012-03-15 04:01:37 +0000 | [diff] [blame] | 165 | * Linux boot |
| 166 | */ |
| 167 | void spl_board_prepare_for_linux(void) |
| 168 | { |
| 169 | gpmc_dm9000_config(); |
| 170 | } |
| 171 | |
Simon Schwarz | 2d52a9a | 2012-03-15 04:01:40 +0000 | [diff] [blame] | 172 | /* |
| 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 | */ |
| 179 | int spl_start_uboot(void) |
| 180 | { |
| 181 | int val = 0; |
Stefano Babic | 3037296 | 2013-02-23 00:53:26 +0000 | [diff] [blame] | 182 | 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 Schwarz | 2d52a9a | 2012-03-15 04:01:40 +0000 | [diff] [blame] | 186 | } |
| 187 | return !val; |
| 188 | } |
Simon Schwarz | 9e70c08 | 2012-03-15 04:01:37 +0000 | [diff] [blame] | 189 | #endif |
| 190 | |
Tom Rini | 9ae0d55 | 2011-11-18 12:48:06 +0000 | [diff] [blame] | 191 | /* |
| 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 Barada | 8c4445d | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 198 | void get_board_mem_timings(struct board_sdrc_timings *timings) |
Tom Rini | 9ae0d55 | 2011-11-18 12:48:06 +0000 | [diff] [blame] | 199 | { |
| 200 | /* General SDRC config */ |
Peter Barada | 8c4445d | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 201 | timings->mcfg = MICRON_V_MCFG_165(128 << 20); |
| 202 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
Tom Rini | 9ae0d55 | 2011-11-18 12:48:06 +0000 | [diff] [blame] | 203 | |
| 204 | /* AC timings */ |
Peter Barada | 8c4445d | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 205 | timings->ctrla = MICRON_V_ACTIMA_165; |
| 206 | timings->ctrlb = MICRON_V_ACTIMB_165; |
Tom Rini | 9ae0d55 | 2011-11-18 12:48:06 +0000 | [diff] [blame] | 207 | |
Peter Barada | 8c4445d | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 208 | timings->mr = MICRON_V_MR_165; |
Tom Rini | 9ae0d55 | 2011-11-18 12:48:06 +0000 | [diff] [blame] | 209 | } |