Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Frederik Kriewitz | 9939650 | 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 | 9939650 | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 17 | */ |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame] | 18 | #include <config.h> |
Anthoine Bourgeois | cf84a82 | 2015-01-02 00:35:43 +0100 | [diff] [blame] | 19 | #include <dm.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 20 | #include <env.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 21 | #include <init.h> |
Simon Glass | 9bc1564 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 22 | #include <malloc.h> |
Anthoine Bourgeois | cf84a82 | 2015-01-02 00:35:43 +0100 | [diff] [blame] | 23 | #include <ns16550.h> |
Frederik Kriewitz | 9939650 | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 24 | #include <twl4030.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 25 | #include <asm/global_data.h> |
Frederik Kriewitz | 9939650 | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 26 | #include <asm/io.h> |
Tom Rini | bde8eea | 2011-09-03 21:52:45 -0400 | [diff] [blame] | 27 | #include <asm/arch/mmc_host_def.h> |
Frederik Kriewitz | 9939650 | 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 | bbb57cb | 2012-03-15 04:01:40 +0000 | [diff] [blame] | 33 | #include <asm/gpio.h> |
Frederik Kriewitz | 9939650 | 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 | 30e219a | 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 | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 51 | static const struct ns16550_plat devkit8000_serial = { |
Adam Ford | d1e22fa | 2016-03-07 21:08:49 -0600 | [diff] [blame] | 52 | .base = OMAP34XX_UART3, |
| 53 | .reg_shift = 2, |
Heiko Schocher | 06f108e | 2017-01-18 08:05:49 +0100 | [diff] [blame] | 54 | .clock = V_NS16550_CLK, |
| 55 | .fcr = UART_FCR_DEFVAL, |
Anthoine Bourgeois | cf84a82 | 2015-01-02 00:35:43 +0100 | [diff] [blame] | 56 | }; |
| 57 | |
Simon Glass | 1d8364a | 2020-12-28 20:34:54 -0700 | [diff] [blame] | 58 | U_BOOT_DRVINFO(devkit8000_uart) = { |
Thomas Chou | 52ac443 | 2015-11-19 21:48:12 +0800 | [diff] [blame] | 59 | "ns16550_serial", |
Anthoine Bourgeois | cf84a82 | 2015-01-02 00:35:43 +0100 | [diff] [blame] | 60 | &devkit8000_serial |
| 61 | }; |
| 62 | |
Frederik Kriewitz | 9939650 | 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 | 23cced1 | 2012-03-15 04:01:37 +0000 | [diff] [blame] | 78 | /* Configure GPMC registers for DM9000 */ |
Tom Rini | 599b11b | 2022-12-02 16:42:18 -0500 | [diff] [blame] | 79 | #define DM9000_BASE 0x2c000000 |
Simon Schwarz | 23cced1 | 2012-03-15 04:01:37 +0000 | [diff] [blame] | 80 | static void gpmc_dm9000_config(void) |
| 81 | { |
| 82 | enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[6], |
Tom Rini | 599b11b | 2022-12-02 16:42:18 -0500 | [diff] [blame] | 83 | DM9000_BASE, GPMC_SIZE_16M); |
Simon Schwarz | 23cced1 | 2012-03-15 04:01:37 +0000 | [diff] [blame] | 84 | } |
| 85 | |
Frederik Kriewitz | 9939650 | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 86 | /* |
| 87 | * Routine: misc_init_r |
| 88 | * Description: Configure board specific parts |
| 89 | */ |
| 90 | int misc_init_r(void) |
| 91 | { |
| 92 | struct ctrl_id *id_base = (struct ctrl_id *)OMAP34XX_ID_L4_IO_BASE; |
| 93 | #ifdef CONFIG_DRIVER_DM9000 |
| 94 | uchar enetaddr[6]; |
| 95 | u32 die_id_0; |
| 96 | #endif |
| 97 | |
| 98 | twl4030_power_init(); |
| 99 | #ifdef CONFIG_TWL4030_LED |
Grazvydas Ignotas | 17887bf | 2009-12-10 17:10:21 +0200 | [diff] [blame] | 100 | twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON); |
Frederik Kriewitz | 9939650 | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 101 | #endif |
| 102 | |
| 103 | #ifdef CONFIG_DRIVER_DM9000 |
Tom Rini | 599b11b | 2022-12-02 16:42:18 -0500 | [diff] [blame] | 104 | gpmc_dm9000_config(); |
Frederik Kriewitz | 9939650 | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 105 | |
| 106 | /* Use OMAP DIE_ID as MAC address */ |
Simon Glass | 399a9ce | 2017-08-03 12:22:14 -0600 | [diff] [blame] | 107 | if (!eth_env_get_enetaddr("ethaddr", enetaddr)) { |
Frederik Kriewitz | 9939650 | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 108 | 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 Glass | 8551d55 | 2017-08-03 12:22:11 -0600 | [diff] [blame] | 116 | eth_env_set_enetaddr("ethaddr", enetaddr); |
Frederik Kriewitz | 9939650 | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 117 | } |
| 118 | #endif |
| 119 | |
Paul Kocialkowski | 6bc318e | 2015-08-27 19:37:13 +0200 | [diff] [blame] | 120 | omap_die_id_display(); |
Frederik Kriewitz | 9939650 | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 121 | |
| 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 | */ |
| 131 | void set_muxconf_regs(void) |
| 132 | { |
| 133 | MUX_DEVKIT8000(); |
| 134 | } |
| 135 | |
Masahiro Yamada | 0a78017 | 2017-05-09 20:31:39 +0900 | [diff] [blame] | 136 | #if defined(CONFIG_MMC) |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 137 | int board_mmc_init(struct bd_info *bis) |
Tom Rini | bde8eea | 2011-09-03 21:52:45 -0400 | [diff] [blame] | 138 | { |
Nikita Kiryanov | 4be9dbc | 2012-12-03 02:19:47 +0000 | [diff] [blame] | 139 | return omap_mmc_init(0, 0, 0, -1, -1); |
Tom Rini | bde8eea | 2011-09-03 21:52:45 -0400 | [diff] [blame] | 140 | } |
| 141 | #endif |
| 142 | |
Masahiro Yamada | 0a78017 | 2017-05-09 20:31:39 +0900 | [diff] [blame] | 143 | #if defined(CONFIG_MMC) |
Paul Kocialkowski | 6955989 | 2014-11-08 20:55:47 +0100 | [diff] [blame] | 144 | void board_mmc_power_init(void) |
| 145 | { |
| 146 | twl4030_power_mmc_init(0); |
| 147 | } |
| 148 | #endif |
| 149 | |
Simon Schwarz | 7ae359c | 2011-09-14 15:32:17 -0400 | [diff] [blame] | 150 | #if defined(CONFIG_DRIVER_DM9000) & !defined(CONFIG_SPL_BUILD) |
Frederik Kriewitz | 9939650 | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 151 | /* |
| 152 | * Routine: board_eth_init |
| 153 | * Description: Setting up the Ethernet hardware. |
| 154 | */ |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 155 | int board_eth_init(struct bd_info *bis) |
Frederik Kriewitz | 9939650 | 2009-08-23 12:56:42 +0200 | [diff] [blame] | 156 | { |
| 157 | return dm9000_initialize(bis); |
| 158 | } |
| 159 | #endif |
Tom Rini | 05800b9 | 2011-11-18 12:48:06 +0000 | [diff] [blame] | 160 | |
Simon Schwarz | 23cced1 | 2012-03-15 04:01:37 +0000 | [diff] [blame] | 161 | #ifdef CONFIG_SPL_OS_BOOT |
| 162 | /* |
Robert P. J. Day | c5b1e5d | 2016-09-07 14:27:59 -0400 | [diff] [blame] | 163 | * Do board specific preparation before SPL |
Simon Schwarz | 23cced1 | 2012-03-15 04:01:37 +0000 | [diff] [blame] | 164 | * Linux boot |
| 165 | */ |
| 166 | void spl_board_prepare_for_linux(void) |
| 167 | { |
| 168 | gpmc_dm9000_config(); |
| 169 | } |
| 170 | |
Simon Schwarz | bbb57cb | 2012-03-15 04:01:40 +0000 | [diff] [blame] | 171 | /* |
| 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 | */ |
| 178 | int spl_start_uboot(void) |
| 179 | { |
| 180 | int val = 0; |
Stefano Babic | f51b4c7 | 2013-02-23 00:53:26 +0000 | [diff] [blame] | 181 | 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 Schwarz | bbb57cb | 2012-03-15 04:01:40 +0000 | [diff] [blame] | 185 | } |
| 186 | return !val; |
| 187 | } |
Simon Schwarz | 23cced1 | 2012-03-15 04:01:37 +0000 | [diff] [blame] | 188 | #endif |
| 189 | |
Tom Rini | 05800b9 | 2011-11-18 12:48:06 +0000 | [diff] [blame] | 190 | /* |
| 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 Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 197 | void get_board_mem_timings(struct board_sdrc_timings *timings) |
Tom Rini | 05800b9 | 2011-11-18 12:48:06 +0000 | [diff] [blame] | 198 | { |
| 199 | /* General SDRC config */ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 200 | timings->mcfg = MICRON_V_MCFG_165(128 << 20); |
| 201 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
Tom Rini | 05800b9 | 2011-11-18 12:48:06 +0000 | [diff] [blame] | 202 | |
| 203 | /* AC timings */ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 204 | timings->ctrla = MICRON_V_ACTIMA_165; |
| 205 | timings->ctrlb = MICRON_V_ACTIMB_165; |
Tom Rini | 05800b9 | 2011-11-18 12:48:06 +0000 | [diff] [blame] | 206 | |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 207 | timings->mr = MICRON_V_MR_165; |
Tom Rini | 05800b9 | 2011-11-18 12:48:06 +0000 | [diff] [blame] | 208 | } |