Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 2 | /* |
Egli, Samuel | 097951b | 2014-05-05 16:50:43 +0200 | [diff] [blame] | 3 | * Board functions for TI AM335X based draco board |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 4 | * (C) Copyright 2013 Siemens Schweiz AG |
| 5 | * (C) Heiko Schocher, DENX Software Engineering, hs@denx.de. |
| 6 | * |
| 7 | * Based on: |
| 8 | * |
| 9 | * Board functions for TI AM335X based boards |
| 10 | * u-boot:/board/ti/am335x/board.c |
| 11 | * |
Nishanth Menon | eaa39c6 | 2023-11-01 15:56:03 -0500 | [diff] [blame] | 12 | * Copyright (C) 2011, Texas Instruments, Incorporated - https://www.ti.com/ |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #include <common.h> |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 16 | #include <command.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 17 | #include <env.h> |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 18 | #include <errno.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 19 | #include <init.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 20 | #include <net.h> |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 21 | #include <spl.h> |
| 22 | #include <asm/arch/cpu.h> |
| 23 | #include <asm/arch/hardware.h> |
| 24 | #include <asm/arch/omap.h> |
| 25 | #include <asm/arch/ddr_defs.h> |
| 26 | #include <asm/arch/clock.h> |
| 27 | #include <asm/arch/gpio.h> |
| 28 | #include <asm/arch/mmc_host_def.h> |
| 29 | #include <asm/arch/sys_proto.h> |
Heiko Schocher | cbec11a | 2016-06-07 08:55:45 +0200 | [diff] [blame] | 30 | #include <asm/arch/mem.h> |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 31 | #include <asm/io.h> |
| 32 | #include <asm/emif.h> |
| 33 | #include <asm/gpio.h> |
| 34 | #include <i2c.h> |
| 35 | #include <miiphy.h> |
| 36 | #include <cpsw.h> |
| 37 | #include <watchdog.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 38 | #include <linux/delay.h> |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 39 | #include "board.h" |
| 40 | #include "../common/factoryset.h" |
Heiko Schocher | cbec11a | 2016-06-07 08:55:45 +0200 | [diff] [blame] | 41 | #include <nand.h> |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 42 | |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 43 | #ifdef CONFIG_SPL_BUILD |
Marek BehĂșn | 4bebdd3 | 2021-05-20 13:23:52 +0200 | [diff] [blame] | 44 | static struct draco_baseboard_id __section(".data") settings; |
Egli, Samuel | bc38fa4 | 2014-04-24 17:57:53 +0200 | [diff] [blame] | 45 | |
| 46 | #if DDR_PLL_FREQ == 303 |
Heiko Schocher | cbec11a | 2016-06-07 08:55:45 +0200 | [diff] [blame] | 47 | #if !defined(CONFIG_TARGET_ETAMIN) |
Egli, Samuel | bc38fa4 | 2014-04-24 17:57:53 +0200 | [diff] [blame] | 48 | /* Default@303MHz-i0 */ |
| 49 | const struct ddr3_data ddr3_default = { |
| 50 | 0x33524444, 0x56312e35, 0x0080, 0x0000, 0x003A, 0x003F, 0x009F, |
Heiko Schocher | d17c3fc | 2015-06-16 14:59:34 +0200 | [diff] [blame] | 51 | 0x0079, 0x0888A39B, 0x26517FDA, 0x501F84EF, 0x00100206, 0x61A44A32, |
Egli, Samuel | bc38fa4 | 2014-04-24 17:57:53 +0200 | [diff] [blame] | 52 | 0x0000093B, 0x0000014A, |
| 53 | "default name @303MHz \0", |
| 54 | "default marking \0", |
| 55 | }; |
Heiko Schocher | cbec11a | 2016-06-07 08:55:45 +0200 | [diff] [blame] | 56 | #else |
| 57 | /* etamin board */ |
| 58 | const struct ddr3_data ddr3_default = { |
| 59 | 0x33524444, 0x56312e36, 0x0080, 0x0000, 0x003A, 0x0010, 0x009F, |
| 60 | 0x0050, 0x0888A39B, 0x266D7FDA, 0x501F86AF, 0x00100206, 0x61A44BB2, |
| 61 | 0x0000093B, 0x0000018A, |
| 62 | "test-etamin \0", |
| 63 | "generic-8Gbit \0", |
| 64 | }; |
| 65 | #endif |
Egli, Samuel | bc38fa4 | 2014-04-24 17:57:53 +0200 | [diff] [blame] | 66 | #elif DDR_PLL_FREQ == 400 |
| 67 | /* Default@400MHz-i0 */ |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 68 | const struct ddr3_data ddr3_default = { |
Egli, Samuel | bc38fa4 | 2014-04-24 17:57:53 +0200 | [diff] [blame] | 69 | 0x33524444, 0x56312e35, 0x0080, 0x0000, 0x0039, 0x0046, 0x00ab, |
| 70 | 0x0080, 0x0AAAA4DB, 0x26307FDA, 0x501F821F, 0x00100207, 0x61A45232, |
Samuel Egli | 8069bfe | 2013-11-04 14:05:03 +0100 | [diff] [blame] | 71 | 0x00000618, 0x0000014A, |
Egli, Samuel | bc38fa4 | 2014-04-24 17:57:53 +0200 | [diff] [blame] | 72 | "default name @400MHz \0", |
| 73 | "default marking \0", |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 74 | }; |
Egli, Samuel | bc38fa4 | 2014-04-24 17:57:53 +0200 | [diff] [blame] | 75 | #endif |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 76 | |
| 77 | static void set_default_ddr3_timings(void) |
| 78 | { |
| 79 | printf("Set default DDR3 settings\n"); |
| 80 | settings.ddr3 = ddr3_default; |
| 81 | } |
| 82 | |
| 83 | static void print_ddr3_timings(void) |
| 84 | { |
Egli, Samuel | bc38fa4 | 2014-04-24 17:57:53 +0200 | [diff] [blame] | 85 | printf("\nDDR3\n"); |
| 86 | printf("clock:\t\t%d MHz\n", DDR_PLL_FREQ); |
| 87 | printf("device:\t\t%s\n", settings.ddr3.manu_name); |
| 88 | printf("marking:\t%s\n", settings.ddr3.manu_marking); |
Heiko Schocher | d17c3fc | 2015-06-16 14:59:34 +0200 | [diff] [blame] | 89 | printf("%-20s, %-8s, %-8s, %-4s\n", "timing parameters", "eeprom", |
| 90 | "default", "diff"); |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 91 | PRINTARGS(magic); |
| 92 | PRINTARGS(version); |
| 93 | PRINTARGS(ddr3_sratio); |
| 94 | PRINTARGS(iclkout); |
| 95 | |
| 96 | PRINTARGS(dt0rdsratio0); |
| 97 | PRINTARGS(dt0wdsratio0); |
| 98 | PRINTARGS(dt0fwsratio0); |
| 99 | PRINTARGS(dt0wrsratio0); |
| 100 | |
| 101 | PRINTARGS(sdram_tim1); |
| 102 | PRINTARGS(sdram_tim2); |
| 103 | PRINTARGS(sdram_tim3); |
| 104 | |
| 105 | PRINTARGS(emif_ddr_phy_ctlr_1); |
| 106 | |
| 107 | PRINTARGS(sdram_config); |
| 108 | PRINTARGS(ref_ctrl); |
Samuel Egli | 8069bfe | 2013-11-04 14:05:03 +0100 | [diff] [blame] | 109 | PRINTARGS(ioctr_val); |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | static void print_chip_data(void) |
| 113 | { |
Heiko Schocher | d17c3fc | 2015-06-16 14:59:34 +0200 | [diff] [blame] | 114 | struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; |
| 115 | dpll_mpu_opp100.m = am335x_get_efuse_mpu_max_freq(cdev); |
Egli, Samuel | bc38fa4 | 2014-04-24 17:57:53 +0200 | [diff] [blame] | 116 | printf("\nCPU BOARD\n"); |
| 117 | printf("device: \t'%s'\n", settings.chip.sdevname); |
| 118 | printf("hw version: \t'%s'\n", settings.chip.shwver); |
Heiko Schocher | d17c3fc | 2015-06-16 14:59:34 +0200 | [diff] [blame] | 119 | printf("max freq: \t%d MHz\n", dpll_mpu_opp100.m); |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 120 | } |
| 121 | #endif /* CONFIG_SPL_BUILD */ |
| 122 | |
Heiko Schocher | 4453d7a | 2016-06-07 08:55:43 +0200 | [diff] [blame] | 123 | #define AM335X_NAND_ECC_MASK 0x0f |
| 124 | #define AM335X_NAND_ECC_TYPE_16 0x02 |
| 125 | |
| 126 | static int ecc_type; |
| 127 | |
| 128 | struct am335x_nand_geometry { |
| 129 | u32 magic; |
| 130 | u8 nand_geo_addr; |
| 131 | u8 nand_geo_page; |
| 132 | u8 nand_bus; |
| 133 | }; |
| 134 | |
Tom Rini | 1cfc127 | 2021-08-17 17:59:40 -0400 | [diff] [blame] | 135 | #define EEPROM_ADDR 0x50 |
| 136 | #define EEPROM_ADDR_DDR3 0x90 |
| 137 | #define EEPROM_ADDR_CHIP 0x120 |
| 138 | |
Heiko Schocher | 4453d7a | 2016-06-07 08:55:43 +0200 | [diff] [blame] | 139 | static int draco_read_nand_geometry(void) |
| 140 | { |
| 141 | struct am335x_nand_geometry geo; |
| 142 | |
| 143 | /* Read NAND geometry */ |
Tom Rini | 1cfc127 | 2021-08-17 17:59:40 -0400 | [diff] [blame] | 144 | if (i2c_read(EEPROM_ADDR, 0x80, 2, |
Heiko Schocher | 4453d7a | 2016-06-07 08:55:43 +0200 | [diff] [blame] | 145 | (uchar *)&geo, sizeof(struct am335x_nand_geometry))) { |
| 146 | printf("Could not read the NAND geomtery; something fundamentally wrong on the I2C bus.\n"); |
| 147 | return -EIO; |
| 148 | } |
| 149 | if (geo.magic != 0xa657b310) { |
| 150 | printf("%s: bad magic: %x\n", __func__, geo.magic); |
| 151 | return -EFAULT; |
| 152 | } |
| 153 | if ((geo.nand_bus & AM335X_NAND_ECC_MASK) == AM335X_NAND_ECC_TYPE_16) |
| 154 | ecc_type = 16; |
| 155 | else |
| 156 | ecc_type = 8; |
| 157 | |
| 158 | return 0; |
| 159 | } |
| 160 | |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 161 | /* |
| 162 | * Read header information from EEPROM into global structure. |
| 163 | */ |
| 164 | static int read_eeprom(void) |
| 165 | { |
| 166 | /* Check if baseboard eeprom is available */ |
Tom Rini | 1cfc127 | 2021-08-17 17:59:40 -0400 | [diff] [blame] | 167 | if (i2c_probe(EEPROM_ADDR)) { |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 168 | printf("Could not probe the EEPROM; something fundamentally wrong on the I2C bus.\n"); |
| 169 | return 1; |
| 170 | } |
| 171 | |
| 172 | #ifdef CONFIG_SPL_BUILD |
| 173 | /* Read Siemens eeprom data (DDR3) */ |
Tom Rini | 1cfc127 | 2021-08-17 17:59:40 -0400 | [diff] [blame] | 174 | if (i2c_read(EEPROM_ADDR, EEPROM_ADDR_DDR3, 2, |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 175 | (uchar *)&settings.ddr3, sizeof(struct ddr3_data))) { |
| 176 | printf("Could not read the EEPROM; something fundamentally wrong on the I2C bus.\nUse default DDR3 timings\n"); |
| 177 | set_default_ddr3_timings(); |
| 178 | } |
| 179 | /* Read Siemens eeprom data (CHIP) */ |
Tom Rini | 1cfc127 | 2021-08-17 17:59:40 -0400 | [diff] [blame] | 180 | if (i2c_read(EEPROM_ADDR, EEPROM_ADDR_CHIP, 2, |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 181 | (uchar *)&settings.chip, sizeof(settings.chip))) |
| 182 | printf("Could not read chip settings\n"); |
| 183 | |
| 184 | if (ddr3_default.magic == settings.ddr3.magic && |
| 185 | ddr3_default.version == settings.ddr3.version) { |
| 186 | printf("Using DDR3 settings from EEPROM\n"); |
| 187 | } else { |
| 188 | if (ddr3_default.magic != settings.ddr3.magic) |
Egli, Samuel | bc38fa4 | 2014-04-24 17:57:53 +0200 | [diff] [blame] | 189 | printf("Warning: No valid DDR3 data in eeprom.\n"); |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 190 | if (ddr3_default.version != settings.ddr3.version) |
Egli, Samuel | bc38fa4 | 2014-04-24 17:57:53 +0200 | [diff] [blame] | 191 | printf("Warning: DDR3 data version does not match.\n"); |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 192 | |
| 193 | printf("Using default settings\n"); |
| 194 | set_default_ddr3_timings(); |
| 195 | } |
| 196 | |
Egli, Samuel | 097951b | 2014-05-05 16:50:43 +0200 | [diff] [blame] | 197 | if (MAGIC_CHIP == settings.chip.magic) |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 198 | print_chip_data(); |
Egli, Samuel | 097951b | 2014-05-05 16:50:43 +0200 | [diff] [blame] | 199 | else |
Egli, Samuel | bc38fa4 | 2014-04-24 17:57:53 +0200 | [diff] [blame] | 200 | printf("Warning: No chip data in eeprom\n"); |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 201 | |
| 202 | print_ddr3_timings(); |
Heiko Schocher | 4453d7a | 2016-06-07 08:55:43 +0200 | [diff] [blame] | 203 | |
| 204 | return draco_read_nand_geometry(); |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 205 | #endif |
| 206 | return 0; |
| 207 | } |
| 208 | |
| 209 | #ifdef CONFIG_SPL_BUILD |
| 210 | static void board_init_ddr(void) |
| 211 | { |
Egli, Samuel | 097951b | 2014-05-05 16:50:43 +0200 | [diff] [blame] | 212 | struct emif_regs draco_ddr3_emif_reg_data = { |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 213 | .zq_config = 0x50074BE4, |
| 214 | }; |
| 215 | |
Egli, Samuel | 097951b | 2014-05-05 16:50:43 +0200 | [diff] [blame] | 216 | struct ddr_data draco_ddr3_data = { |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 217 | }; |
| 218 | |
Egli, Samuel | 097951b | 2014-05-05 16:50:43 +0200 | [diff] [blame] | 219 | struct cmd_control draco_ddr3_cmd_ctrl_data = { |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 220 | }; |
Lokesh Vutla | 303b267 | 2013-12-10 15:02:21 +0530 | [diff] [blame] | 221 | |
Egli, Samuel | 097951b | 2014-05-05 16:50:43 +0200 | [diff] [blame] | 222 | struct ctrl_ioregs draco_ddr3_ioregs = { |
Lokesh Vutla | 303b267 | 2013-12-10 15:02:21 +0530 | [diff] [blame] | 223 | }; |
| 224 | |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 225 | /* pass values from eeprom */ |
Egli, Samuel | 097951b | 2014-05-05 16:50:43 +0200 | [diff] [blame] | 226 | draco_ddr3_emif_reg_data.sdram_tim1 = settings.ddr3.sdram_tim1; |
| 227 | draco_ddr3_emif_reg_data.sdram_tim2 = settings.ddr3.sdram_tim2; |
| 228 | draco_ddr3_emif_reg_data.sdram_tim3 = settings.ddr3.sdram_tim3; |
| 229 | draco_ddr3_emif_reg_data.emif_ddr_phy_ctlr_1 = |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 230 | settings.ddr3.emif_ddr_phy_ctlr_1; |
Egli, Samuel | 097951b | 2014-05-05 16:50:43 +0200 | [diff] [blame] | 231 | draco_ddr3_emif_reg_data.sdram_config = settings.ddr3.sdram_config; |
Heiko Schocher | cbec11a | 2016-06-07 08:55:45 +0200 | [diff] [blame] | 232 | draco_ddr3_emif_reg_data.sdram_config2 = 0x08000000; |
Egli, Samuel | 097951b | 2014-05-05 16:50:43 +0200 | [diff] [blame] | 233 | draco_ddr3_emif_reg_data.ref_ctrl = settings.ddr3.ref_ctrl; |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 234 | |
Egli, Samuel | 097951b | 2014-05-05 16:50:43 +0200 | [diff] [blame] | 235 | draco_ddr3_data.datardsratio0 = settings.ddr3.dt0rdsratio0; |
| 236 | draco_ddr3_data.datawdsratio0 = settings.ddr3.dt0wdsratio0; |
| 237 | draco_ddr3_data.datafwsratio0 = settings.ddr3.dt0fwsratio0; |
| 238 | draco_ddr3_data.datawrsratio0 = settings.ddr3.dt0wrsratio0; |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 239 | |
Egli, Samuel | 097951b | 2014-05-05 16:50:43 +0200 | [diff] [blame] | 240 | draco_ddr3_cmd_ctrl_data.cmd0csratio = settings.ddr3.ddr3_sratio; |
| 241 | draco_ddr3_cmd_ctrl_data.cmd0iclkout = settings.ddr3.iclkout; |
| 242 | draco_ddr3_cmd_ctrl_data.cmd1csratio = settings.ddr3.ddr3_sratio; |
| 243 | draco_ddr3_cmd_ctrl_data.cmd1iclkout = settings.ddr3.iclkout; |
| 244 | draco_ddr3_cmd_ctrl_data.cmd2csratio = settings.ddr3.ddr3_sratio; |
| 245 | draco_ddr3_cmd_ctrl_data.cmd2iclkout = settings.ddr3.iclkout; |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 246 | |
Egli, Samuel | 097951b | 2014-05-05 16:50:43 +0200 | [diff] [blame] | 247 | draco_ddr3_ioregs.cm0ioctl = settings.ddr3.ioctr_val, |
| 248 | draco_ddr3_ioregs.cm1ioctl = settings.ddr3.ioctr_val, |
| 249 | draco_ddr3_ioregs.cm2ioctl = settings.ddr3.ioctr_val, |
| 250 | draco_ddr3_ioregs.dt0ioctl = settings.ddr3.ioctr_val, |
| 251 | draco_ddr3_ioregs.dt1ioctl = settings.ddr3.ioctr_val, |
Lokesh Vutla | 303b267 | 2013-12-10 15:02:21 +0530 | [diff] [blame] | 252 | |
Egli, Samuel | 097951b | 2014-05-05 16:50:43 +0200 | [diff] [blame] | 253 | config_ddr(DDR_PLL_FREQ, &draco_ddr3_ioregs, &draco_ddr3_data, |
| 254 | &draco_ddr3_cmd_ctrl_data, &draco_ddr3_emif_reg_data, 0); |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | static void spl_siemens_board_init(void) |
| 258 | { |
| 259 | return; |
| 260 | } |
| 261 | #endif /* if def CONFIG_SPL_BUILD */ |
| 262 | |
Heiko Schocher | d17c3fc | 2015-06-16 14:59:34 +0200 | [diff] [blame] | 263 | #ifdef CONFIG_BOARD_LATE_INIT |
| 264 | int board_late_init(void) |
| 265 | { |
Heiko Schocher | 4453d7a | 2016-06-07 08:55:43 +0200 | [diff] [blame] | 266 | int ret; |
| 267 | |
| 268 | ret = draco_read_nand_geometry(); |
| 269 | if (ret != 0) |
| 270 | return ret; |
| 271 | |
| 272 | nand_curr_device = 0; |
| 273 | omap_nand_switch_ecc(1, ecc_type); |
Heiko Schocher | cbec11a | 2016-06-07 08:55:45 +0200 | [diff] [blame] | 274 | #ifdef CONFIG_TARGET_ETAMIN |
| 275 | nand_curr_device = 1; |
| 276 | omap_nand_switch_ecc(1, ecc_type); |
| 277 | #endif |
Heiko Schocher | d17c3fc | 2015-06-16 14:59:34 +0200 | [diff] [blame] | 278 | #ifdef CONFIG_FACTORYSET |
| 279 | /* Set ASN in environment*/ |
| 280 | if (factory_dat.asn[0] != 0) { |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 281 | env_set("dtb_name", (char *)factory_dat.asn); |
Heiko Schocher | d17c3fc | 2015-06-16 14:59:34 +0200 | [diff] [blame] | 282 | } else { |
| 283 | /* dtb suffix gets added in load script */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 284 | env_set("dtb_name", "am335x-draco"); |
Heiko Schocher | d17c3fc | 2015-06-16 14:59:34 +0200 | [diff] [blame] | 285 | } |
| 286 | #else |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 287 | env_set("dtb_name", "am335x-draco"); |
Heiko Schocher | d17c3fc | 2015-06-16 14:59:34 +0200 | [diff] [blame] | 288 | #endif |
| 289 | |
| 290 | return 0; |
| 291 | } |
| 292 | #endif |
| 293 | |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 294 | #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \ |
Simon Glass | e5cd9a4 | 2021-07-10 21:14:26 -0600 | [diff] [blame] | 295 | (defined(CONFIG_SPL_ETH) && defined(CONFIG_SPL_BUILD)) |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 296 | static void cpsw_control(int enabled) |
| 297 | { |
| 298 | /* VTP can be added here */ |
| 299 | |
| 300 | return; |
| 301 | } |
| 302 | |
| 303 | static struct cpsw_slave_data cpsw_slaves[] = { |
| 304 | { |
| 305 | .slave_reg_ofs = 0x208, |
| 306 | .sliver_reg_ofs = 0xd80, |
Mugunthan V N | 4944f37 | 2014-02-18 07:31:52 -0500 | [diff] [blame] | 307 | .phy_addr = 0, |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 308 | .phy_if = PHY_INTERFACE_MODE_MII, |
| 309 | }, |
| 310 | }; |
| 311 | |
| 312 | static struct cpsw_platform_data cpsw_data = { |
| 313 | .mdio_base = CPSW_MDIO_BASE, |
| 314 | .cpsw_base = CPSW_BASE, |
| 315 | .mdio_div = 0xff, |
| 316 | .channels = 4, |
| 317 | .cpdma_reg_ofs = 0x800, |
| 318 | .slaves = 1, |
| 319 | .slave_data = cpsw_slaves, |
| 320 | .ale_reg_ofs = 0xd00, |
| 321 | .ale_entries = 1024, |
| 322 | .host_port_reg_ofs = 0x108, |
| 323 | .hw_stats_reg_ofs = 0x900, |
| 324 | .bd_ram_ofs = 0x2000, |
| 325 | .mac_control = (1 << 5), |
| 326 | .control = cpsw_control, |
| 327 | .host_port_num = 0, |
| 328 | .version = CPSW_CTRL_VERSION_2, |
| 329 | }; |
| 330 | |
| 331 | #if defined(CONFIG_DRIVER_TI_CPSW) || \ |
Paul Kocialkowski | f34dfcb | 2015-08-04 17:04:06 +0200 | [diff] [blame] | 332 | (defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET)) |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 333 | int board_eth_init(struct bd_info *bis) |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 334 | { |
| 335 | struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; |
| 336 | int n = 0; |
| 337 | int rv; |
| 338 | |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 339 | factoryset_env_set(); |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 340 | |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 341 | /* Set rgmii mode and enable rmii clock to be sourced from chip */ |
| 342 | writel((RMII_MODE_ENABLE | RMII_CHIPCKL_ENABLE), &cdev->miisel); |
| 343 | |
| 344 | rv = cpsw_register(&cpsw_data); |
| 345 | if (rv < 0) |
| 346 | printf("Error %d registering CPSW switch\n", rv); |
| 347 | else |
| 348 | n += rv; |
| 349 | return n; |
| 350 | } |
Stefan Roese | 9aee57f | 2014-03-12 10:45:41 +0100 | [diff] [blame] | 351 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 352 | static int do_switch_reset(struct cmd_tbl *cmdtp, int flag, int argc, |
| 353 | char *const argv[]) |
Stefan Roese | 9aee57f | 2014-03-12 10:45:41 +0100 | [diff] [blame] | 354 | { |
| 355 | /* Reset SMSC LAN9303 switch for default configuration */ |
| 356 | gpio_request(GPIO_LAN9303_NRST, "nRST"); |
| 357 | gpio_direction_output(GPIO_LAN9303_NRST, 0); |
| 358 | /* assert active low reset for 200us */ |
| 359 | udelay(200); |
| 360 | gpio_set_value(GPIO_LAN9303_NRST, 1); |
| 361 | |
| 362 | return 0; |
| 363 | }; |
| 364 | |
| 365 | U_BOOT_CMD( |
| 366 | switch_rst, CONFIG_SYS_MAXARGS, 1, do_switch_reset, |
| 367 | "Reset LAN9303 switch via its reset pin", |
| 368 | "" |
| 369 | ); |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 370 | #endif /* #if defined(CONFIG_DRIVER_TI_CPSW) */ |
| 371 | #endif /* #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) */ |
| 372 | |
Tom Rini | 4044a7a | 2022-12-02 16:42:38 -0500 | [diff] [blame] | 373 | #if CONFIG_IS_ENABLED(NAND_CS_INIT) |
| 374 | #define ETAMIN_NAND_GPMC_CONFIG1 0x00000800 |
| 375 | #define ETAMIN_NAND_GPMC_CONFIG2 0x001e1e00 |
| 376 | #define ETAMIN_NAND_GPMC_CONFIG3 0x001e1e00 |
| 377 | #define ETAMIN_NAND_GPMC_CONFIG4 0x16051807 |
| 378 | #define ETAMIN_NAND_GPMC_CONFIG5 0x00151e1e |
| 379 | #define ETAMIN_NAND_GPMC_CONFIG6 0x16000f80 |
| 380 | |
Heiko Schocher | cbec11a | 2016-06-07 08:55:45 +0200 | [diff] [blame] | 381 | /* GPMC definitions for second nand cs1 */ |
| 382 | static const u32 gpmc_nand_config[] = { |
| 383 | ETAMIN_NAND_GPMC_CONFIG1, |
| 384 | ETAMIN_NAND_GPMC_CONFIG2, |
| 385 | ETAMIN_NAND_GPMC_CONFIG3, |
| 386 | ETAMIN_NAND_GPMC_CONFIG4, |
| 387 | ETAMIN_NAND_GPMC_CONFIG5, |
| 388 | ETAMIN_NAND_GPMC_CONFIG6, |
| 389 | /*CONFIG7- computed as params */ |
| 390 | }; |
| 391 | |
| 392 | static void board_nand_cs_init(void) |
| 393 | { |
| 394 | enable_gpmc_cs_config(gpmc_nand_config, &gpmc_cfg->cs[1], |
| 395 | 0x18000000, GPMC_SIZE_16M); |
| 396 | } |
| 397 | #endif |
| 398 | |
Heiko Schocher | 499c498 | 2013-08-19 16:39:01 +0200 | [diff] [blame] | 399 | #include "../common/board.c" |