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