Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 2 | /* |
| 3 | * board.c |
| 4 | * |
| 5 | * Board functions for TI AM335X based boards |
| 6 | * |
| 7 | * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/ |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <common.h> |
Lokesh Vutla | 4548bc8 | 2017-04-26 13:37:08 +0530 | [diff] [blame] | 11 | #include <dm.h> |
Simon Glass | 4bfd1f5 | 2019-08-01 09:46:43 -0600 | [diff] [blame] | 12 | #include <env.h> |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 13 | #include <errno.h> |
Simon Glass | 4d72caa | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 14 | #include <image.h> |
Simon Glass | 5255932 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 15 | #include <init.h> |
Simon Glass | 336d461 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 16 | #include <malloc.h> |
Simon Glass | 90526e9 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 17 | #include <net.h> |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 18 | #include <spl.h> |
Lokesh Vutla | 3d16389 | 2016-05-16 11:47:29 +0530 | [diff] [blame] | 19 | #include <serial.h> |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 20 | #include <asm/arch/cpu.h> |
| 21 | #include <asm/arch/hardware.h> |
| 22 | #include <asm/arch/omap.h> |
| 23 | #include <asm/arch/ddr_defs.h> |
| 24 | #include <asm/arch/clock.h> |
Lokesh Vutla | 97f3a17 | 2016-05-16 11:47:26 +0530 | [diff] [blame] | 25 | #include <asm/arch/clk_synthesizer.h> |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 26 | #include <asm/arch/gpio.h> |
| 27 | #include <asm/arch/mmc_host_def.h> |
| 28 | #include <asm/arch/sys_proto.h> |
Steve Kipisz | cd8845d | 2013-07-18 15:13:03 -0400 | [diff] [blame] | 29 | #include <asm/arch/mem.h> |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 30 | #include <asm/global_data.h> |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 31 | #include <asm/io.h> |
| 32 | #include <asm/emif.h> |
| 33 | #include <asm/gpio.h> |
Semen Protsenko | 00bbe96 | 2017-06-02 18:00:00 +0300 | [diff] [blame] | 34 | #include <asm/omap_common.h> |
Andrew F. Davis | b0a4eea | 2016-08-30 14:06:24 -0500 | [diff] [blame] | 35 | #include <asm/omap_sec_common.h> |
Lokesh Vutla | 4548bc8 | 2017-04-26 13:37:08 +0530 | [diff] [blame] | 36 | #include <asm/omap_mmc.h> |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 37 | #include <i2c.h> |
| 38 | #include <miiphy.h> |
| 39 | #include <cpsw.h> |
Simon Glass | cd93d62 | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 40 | #include <linux/bitops.h> |
Simon Glass | c05ed00 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 41 | #include <linux/delay.h> |
Tom Rini | 9721027 | 2013-08-30 16:28:46 -0400 | [diff] [blame] | 42 | #include <power/tps65217.h> |
| 43 | #include <power/tps65910.h> |
Simon Glass | f3998fd | 2019-08-02 09:44:25 -0600 | [diff] [blame] | 44 | #include <env_internal.h> |
Tom Rini | 6843918 | 2013-10-01 12:32:04 -0400 | [diff] [blame] | 45 | #include <watchdog.h> |
Nishanth Menon | 770e68c | 2016-02-24 12:30:55 -0600 | [diff] [blame] | 46 | #include "../common/board_detect.h" |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 47 | #include "board.h" |
| 48 | |
| 49 | DECLARE_GLOBAL_DATA_PTR; |
| 50 | |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 51 | /* GPIO that controls power to DDR on EVM-SK */ |
Lokesh Vutla | 97f3a17 | 2016-05-16 11:47:26 +0530 | [diff] [blame] | 52 | #define GPIO_TO_PIN(bank, gpio) (32 * (bank) + (gpio)) |
| 53 | #define GPIO_DDR_VTT_EN GPIO_TO_PIN(0, 7) |
| 54 | #define ICE_GPIO_DDR_VTT_EN GPIO_TO_PIN(0, 18) |
| 55 | #define GPIO_PR1_MII_CTRL GPIO_TO_PIN(3, 4) |
| 56 | #define GPIO_MUX_MII_CTRL GPIO_TO_PIN(3, 10) |
| 57 | #define GPIO_FET_SWITCH_CTRL GPIO_TO_PIN(0, 7) |
| 58 | #define GPIO_PHY_RESET GPIO_TO_PIN(2, 5) |
Roger Quadros | e607ec9 | 2016-08-24 15:35:50 +0300 | [diff] [blame] | 59 | #define GPIO_ETH0_MODE GPIO_TO_PIN(0, 11) |
| 60 | #define GPIO_ETH1_MODE GPIO_TO_PIN(1, 26) |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 61 | |
| 62 | static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; |
| 63 | |
Roger Quadros | e607ec9 | 2016-08-24 15:35:50 +0300 | [diff] [blame] | 64 | #define GPIO0_RISINGDETECT (AM33XX_GPIO0_BASE + OMAP_GPIO_RISINGDETECT) |
| 65 | #define GPIO1_RISINGDETECT (AM33XX_GPIO1_BASE + OMAP_GPIO_RISINGDETECT) |
| 66 | |
| 67 | #define GPIO0_IRQSTATUS1 (AM33XX_GPIO0_BASE + OMAP_GPIO_IRQSTATUS1) |
| 68 | #define GPIO1_IRQSTATUS1 (AM33XX_GPIO1_BASE + OMAP_GPIO_IRQSTATUS1) |
| 69 | |
| 70 | #define GPIO0_IRQSTATUSRAW (AM33XX_GPIO0_BASE + 0x024) |
| 71 | #define GPIO1_IRQSTATUSRAW (AM33XX_GPIO1_BASE + 0x024) |
| 72 | |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 73 | /* |
| 74 | * Read header information from EEPROM into global structure. |
| 75 | */ |
Lokesh Vutla | 140d76a | 2016-10-14 10:35:25 +0530 | [diff] [blame] | 76 | #ifdef CONFIG_TI_I2C_BOARD_DETECT |
| 77 | void do_board_detect(void) |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 78 | { |
Lokesh Vutla | 140d76a | 2016-10-14 10:35:25 +0530 | [diff] [blame] | 79 | enable_i2c0_pin_mux(); |
Igor Opaniuk | 2147a16 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 80 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Lokesh Vutla | 140d76a | 2016-10-14 10:35:25 +0530 | [diff] [blame] | 81 | i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE); |
Jean-Jacques Hiblot | 1514244 | 2018-12-07 14:50:49 +0100 | [diff] [blame] | 82 | #endif |
Simon Glass | 64a144d | 2017-05-12 21:09:55 -0600 | [diff] [blame] | 83 | if (ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS, |
| 84 | CONFIG_EEPROM_CHIP_ADDRESS)) |
Lokesh Vutla | 140d76a | 2016-10-14 10:35:25 +0530 | [diff] [blame] | 85 | printf("ti_i2c_eeprom_init failed\n"); |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 86 | } |
Lokesh Vutla | 140d76a | 2016-10-14 10:35:25 +0530 | [diff] [blame] | 87 | #endif |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 88 | |
Lokesh Vutla | 3d16389 | 2016-05-16 11:47:29 +0530 | [diff] [blame] | 89 | #ifndef CONFIG_DM_SERIAL |
| 90 | struct serial_device *default_serial_console(void) |
| 91 | { |
| 92 | if (board_is_icev2()) |
| 93 | return &eserial4_device; |
| 94 | else |
| 95 | return &eserial1_device; |
| 96 | } |
| 97 | #endif |
| 98 | |
Tom Rini | d0e6d34 | 2014-04-09 08:25:57 -0400 | [diff] [blame] | 99 | #ifndef CONFIG_SKIP_LOWLEVEL_INIT |
Peter Korsgaard | c00f69d | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 100 | static const struct ddr_data ddr2_data = { |
Tom Rini | c4f80f5 | 2014-07-07 21:40:16 -0400 | [diff] [blame] | 101 | .datardsratio0 = MT47H128M16RT25E_RD_DQS, |
| 102 | .datafwsratio0 = MT47H128M16RT25E_PHY_FIFO_WE, |
| 103 | .datawrsratio0 = MT47H128M16RT25E_PHY_WR_DATA, |
Peter Korsgaard | c00f69d | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | static const struct cmd_control ddr2_cmd_ctrl_data = { |
Peter Korsgaard | c7d35be | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 107 | .cmd0csratio = MT47H128M16RT25E_RATIO, |
Peter Korsgaard | c00f69d | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 108 | |
Peter Korsgaard | c7d35be | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 109 | .cmd1csratio = MT47H128M16RT25E_RATIO, |
Peter Korsgaard | c00f69d | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 110 | |
Peter Korsgaard | c7d35be | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 111 | .cmd2csratio = MT47H128M16RT25E_RATIO, |
Peter Korsgaard | c00f69d | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | static const struct emif_regs ddr2_emif_reg_data = { |
Peter Korsgaard | c7d35be | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 115 | .sdram_config = MT47H128M16RT25E_EMIF_SDCFG, |
| 116 | .ref_ctrl = MT47H128M16RT25E_EMIF_SDREF, |
| 117 | .sdram_tim1 = MT47H128M16RT25E_EMIF_TIM1, |
| 118 | .sdram_tim2 = MT47H128M16RT25E_EMIF_TIM2, |
| 119 | .sdram_tim3 = MT47H128M16RT25E_EMIF_TIM3, |
| 120 | .emif_ddr_phy_ctlr_1 = MT47H128M16RT25E_EMIF_READ_LATENCY, |
Peter Korsgaard | c00f69d | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 121 | }; |
| 122 | |
Jyri Sarha | 8c17cbd | 2016-12-09 12:29:13 +0200 | [diff] [blame] | 123 | static const struct emif_regs ddr2_evm_emif_reg_data = { |
| 124 | .sdram_config = MT47H128M16RT25E_EMIF_SDCFG, |
| 125 | .ref_ctrl = MT47H128M16RT25E_EMIF_SDREF, |
| 126 | .sdram_tim1 = MT47H128M16RT25E_EMIF_TIM1, |
| 127 | .sdram_tim2 = MT47H128M16RT25E_EMIF_TIM2, |
| 128 | .sdram_tim3 = MT47H128M16RT25E_EMIF_TIM3, |
| 129 | .ocp_config = EMIF_OCP_CONFIG_AM335X_EVM, |
| 130 | .emif_ddr_phy_ctlr_1 = MT47H128M16RT25E_EMIF_READ_LATENCY, |
| 131 | }; |
| 132 | |
Peter Korsgaard | c00f69d | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 133 | static const struct ddr_data ddr3_data = { |
Peter Korsgaard | c7d35be | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 134 | .datardsratio0 = MT41J128MJT125_RD_DQS, |
| 135 | .datawdsratio0 = MT41J128MJT125_WR_DQS, |
| 136 | .datafwsratio0 = MT41J128MJT125_PHY_FIFO_WE, |
| 137 | .datawrsratio0 = MT41J128MJT125_PHY_WR_DATA, |
Peter Korsgaard | c00f69d | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 138 | }; |
| 139 | |
Tom Rini | c7ba18a | 2013-03-21 04:30:02 +0000 | [diff] [blame] | 140 | static const struct ddr_data ddr3_beagleblack_data = { |
| 141 | .datardsratio0 = MT41K256M16HA125E_RD_DQS, |
| 142 | .datawdsratio0 = MT41K256M16HA125E_WR_DQS, |
| 143 | .datafwsratio0 = MT41K256M16HA125E_PHY_FIFO_WE, |
| 144 | .datawrsratio0 = MT41K256M16HA125E_PHY_WR_DATA, |
Tom Rini | c7ba18a | 2013-03-21 04:30:02 +0000 | [diff] [blame] | 145 | }; |
| 146 | |
Jeff Lance | 13526f7 | 2013-01-14 05:32:20 +0000 | [diff] [blame] | 147 | static const struct ddr_data ddr3_evm_data = { |
| 148 | .datardsratio0 = MT41J512M8RH125_RD_DQS, |
| 149 | .datawdsratio0 = MT41J512M8RH125_WR_DQS, |
| 150 | .datafwsratio0 = MT41J512M8RH125_PHY_FIFO_WE, |
| 151 | .datawrsratio0 = MT41J512M8RH125_PHY_WR_DATA, |
Jeff Lance | 13526f7 | 2013-01-14 05:32:20 +0000 | [diff] [blame] | 152 | }; |
| 153 | |
Lokesh Vutla | d8ff4fd | 2016-05-16 11:47:24 +0530 | [diff] [blame] | 154 | static const struct ddr_data ddr3_icev2_data = { |
| 155 | .datardsratio0 = MT41J128MJT125_RD_DQS_400MHz, |
| 156 | .datawdsratio0 = MT41J128MJT125_WR_DQS_400MHz, |
| 157 | .datafwsratio0 = MT41J128MJT125_PHY_FIFO_WE_400MHz, |
| 158 | .datawrsratio0 = MT41J128MJT125_PHY_WR_DATA_400MHz, |
| 159 | }; |
| 160 | |
Peter Korsgaard | c00f69d | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 161 | static const struct cmd_control ddr3_cmd_ctrl_data = { |
Peter Korsgaard | c7d35be | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 162 | .cmd0csratio = MT41J128MJT125_RATIO, |
Peter Korsgaard | c7d35be | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 163 | .cmd0iclkout = MT41J128MJT125_INVERT_CLKOUT, |
Peter Korsgaard | c00f69d | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 164 | |
Peter Korsgaard | c7d35be | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 165 | .cmd1csratio = MT41J128MJT125_RATIO, |
Peter Korsgaard | c7d35be | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 166 | .cmd1iclkout = MT41J128MJT125_INVERT_CLKOUT, |
Peter Korsgaard | c00f69d | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 167 | |
Peter Korsgaard | c7d35be | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 168 | .cmd2csratio = MT41J128MJT125_RATIO, |
Peter Korsgaard | c7d35be | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 169 | .cmd2iclkout = MT41J128MJT125_INVERT_CLKOUT, |
Peter Korsgaard | c00f69d | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 170 | }; |
| 171 | |
Tom Rini | c7ba18a | 2013-03-21 04:30:02 +0000 | [diff] [blame] | 172 | static const struct cmd_control ddr3_beagleblack_cmd_ctrl_data = { |
| 173 | .cmd0csratio = MT41K256M16HA125E_RATIO, |
Tom Rini | c7ba18a | 2013-03-21 04:30:02 +0000 | [diff] [blame] | 174 | .cmd0iclkout = MT41K256M16HA125E_INVERT_CLKOUT, |
| 175 | |
| 176 | .cmd1csratio = MT41K256M16HA125E_RATIO, |
Tom Rini | c7ba18a | 2013-03-21 04:30:02 +0000 | [diff] [blame] | 177 | .cmd1iclkout = MT41K256M16HA125E_INVERT_CLKOUT, |
| 178 | |
| 179 | .cmd2csratio = MT41K256M16HA125E_RATIO, |
Tom Rini | c7ba18a | 2013-03-21 04:30:02 +0000 | [diff] [blame] | 180 | .cmd2iclkout = MT41K256M16HA125E_INVERT_CLKOUT, |
| 181 | }; |
| 182 | |
Jeff Lance | 13526f7 | 2013-01-14 05:32:20 +0000 | [diff] [blame] | 183 | static const struct cmd_control ddr3_evm_cmd_ctrl_data = { |
| 184 | .cmd0csratio = MT41J512M8RH125_RATIO, |
Jeff Lance | 13526f7 | 2013-01-14 05:32:20 +0000 | [diff] [blame] | 185 | .cmd0iclkout = MT41J512M8RH125_INVERT_CLKOUT, |
| 186 | |
| 187 | .cmd1csratio = MT41J512M8RH125_RATIO, |
Jeff Lance | 13526f7 | 2013-01-14 05:32:20 +0000 | [diff] [blame] | 188 | .cmd1iclkout = MT41J512M8RH125_INVERT_CLKOUT, |
| 189 | |
| 190 | .cmd2csratio = MT41J512M8RH125_RATIO, |
Jeff Lance | 13526f7 | 2013-01-14 05:32:20 +0000 | [diff] [blame] | 191 | .cmd2iclkout = MT41J512M8RH125_INVERT_CLKOUT, |
| 192 | }; |
| 193 | |
Lokesh Vutla | d8ff4fd | 2016-05-16 11:47:24 +0530 | [diff] [blame] | 194 | static const struct cmd_control ddr3_icev2_cmd_ctrl_data = { |
| 195 | .cmd0csratio = MT41J128MJT125_RATIO_400MHz, |
| 196 | .cmd0iclkout = MT41J128MJT125_INVERT_CLKOUT_400MHz, |
| 197 | |
| 198 | .cmd1csratio = MT41J128MJT125_RATIO_400MHz, |
| 199 | .cmd1iclkout = MT41J128MJT125_INVERT_CLKOUT_400MHz, |
| 200 | |
| 201 | .cmd2csratio = MT41J128MJT125_RATIO_400MHz, |
| 202 | .cmd2iclkout = MT41J128MJT125_INVERT_CLKOUT_400MHz, |
| 203 | }; |
| 204 | |
Peter Korsgaard | c00f69d | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 205 | static struct emif_regs ddr3_emif_reg_data = { |
Peter Korsgaard | c7d35be | 2012-10-18 01:21:13 +0000 | [diff] [blame] | 206 | .sdram_config = MT41J128MJT125_EMIF_SDCFG, |
| 207 | .ref_ctrl = MT41J128MJT125_EMIF_SDREF, |
| 208 | .sdram_tim1 = MT41J128MJT125_EMIF_TIM1, |
| 209 | .sdram_tim2 = MT41J128MJT125_EMIF_TIM2, |
| 210 | .sdram_tim3 = MT41J128MJT125_EMIF_TIM3, |
| 211 | .zq_config = MT41J128MJT125_ZQ_CFG, |
Vaibhav Hiremath | 59dcf97 | 2013-03-14 21:11:16 +0000 | [diff] [blame] | 212 | .emif_ddr_phy_ctlr_1 = MT41J128MJT125_EMIF_READ_LATENCY | |
| 213 | PHY_EN_DYN_PWRDN, |
Peter Korsgaard | c00f69d | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 214 | }; |
Jeff Lance | 13526f7 | 2013-01-14 05:32:20 +0000 | [diff] [blame] | 215 | |
Tom Rini | c7ba18a | 2013-03-21 04:30:02 +0000 | [diff] [blame] | 216 | static struct emif_regs ddr3_beagleblack_emif_reg_data = { |
| 217 | .sdram_config = MT41K256M16HA125E_EMIF_SDCFG, |
| 218 | .ref_ctrl = MT41K256M16HA125E_EMIF_SDREF, |
| 219 | .sdram_tim1 = MT41K256M16HA125E_EMIF_TIM1, |
| 220 | .sdram_tim2 = MT41K256M16HA125E_EMIF_TIM2, |
| 221 | .sdram_tim3 = MT41K256M16HA125E_EMIF_TIM3, |
Jyri Sarha | 8c17cbd | 2016-12-09 12:29:13 +0200 | [diff] [blame] | 222 | .ocp_config = EMIF_OCP_CONFIG_BEAGLEBONE_BLACK, |
Tom Rini | c7ba18a | 2013-03-21 04:30:02 +0000 | [diff] [blame] | 223 | .zq_config = MT41K256M16HA125E_ZQ_CFG, |
| 224 | .emif_ddr_phy_ctlr_1 = MT41K256M16HA125E_EMIF_READ_LATENCY, |
| 225 | }; |
| 226 | |
Jeff Lance | 13526f7 | 2013-01-14 05:32:20 +0000 | [diff] [blame] | 227 | static struct emif_regs ddr3_evm_emif_reg_data = { |
| 228 | .sdram_config = MT41J512M8RH125_EMIF_SDCFG, |
| 229 | .ref_ctrl = MT41J512M8RH125_EMIF_SDREF, |
| 230 | .sdram_tim1 = MT41J512M8RH125_EMIF_TIM1, |
| 231 | .sdram_tim2 = MT41J512M8RH125_EMIF_TIM2, |
| 232 | .sdram_tim3 = MT41J512M8RH125_EMIF_TIM3, |
Jyri Sarha | 8c17cbd | 2016-12-09 12:29:13 +0200 | [diff] [blame] | 233 | .ocp_config = EMIF_OCP_CONFIG_AM335X_EVM, |
Jeff Lance | 13526f7 | 2013-01-14 05:32:20 +0000 | [diff] [blame] | 234 | .zq_config = MT41J512M8RH125_ZQ_CFG, |
Vaibhav Hiremath | 59dcf97 | 2013-03-14 21:11:16 +0000 | [diff] [blame] | 235 | .emif_ddr_phy_ctlr_1 = MT41J512M8RH125_EMIF_READ_LATENCY | |
| 236 | PHY_EN_DYN_PWRDN, |
Jeff Lance | 13526f7 | 2013-01-14 05:32:20 +0000 | [diff] [blame] | 237 | }; |
Peter Korsgaard | 12d7a47 | 2013-05-13 08:36:30 +0000 | [diff] [blame] | 238 | |
Lokesh Vutla | d8ff4fd | 2016-05-16 11:47:24 +0530 | [diff] [blame] | 239 | static struct emif_regs ddr3_icev2_emif_reg_data = { |
| 240 | .sdram_config = MT41J128MJT125_EMIF_SDCFG_400MHz, |
| 241 | .ref_ctrl = MT41J128MJT125_EMIF_SDREF_400MHz, |
| 242 | .sdram_tim1 = MT41J128MJT125_EMIF_TIM1_400MHz, |
| 243 | .sdram_tim2 = MT41J128MJT125_EMIF_TIM2_400MHz, |
| 244 | .sdram_tim3 = MT41J128MJT125_EMIF_TIM3_400MHz, |
| 245 | .zq_config = MT41J128MJT125_ZQ_CFG_400MHz, |
| 246 | .emif_ddr_phy_ctlr_1 = MT41J128MJT125_EMIF_READ_LATENCY_400MHz | |
| 247 | PHY_EN_DYN_PWRDN, |
| 248 | }; |
| 249 | |
Peter Korsgaard | 12d7a47 | 2013-05-13 08:36:30 +0000 | [diff] [blame] | 250 | #ifdef CONFIG_SPL_OS_BOOT |
| 251 | int spl_start_uboot(void) |
| 252 | { |
Alex Kiernan | d4bb3b3 | 2018-04-19 04:32:53 +0000 | [diff] [blame] | 253 | #ifdef CONFIG_SPL_SERIAL_SUPPORT |
Peter Korsgaard | 12d7a47 | 2013-05-13 08:36:30 +0000 | [diff] [blame] | 254 | /* break into full u-boot on 'c' */ |
Tom Rini | ba9a670 | 2014-03-28 12:03:38 -0400 | [diff] [blame] | 255 | if (serial_tstc() && serial_getc() == 'c') |
| 256 | return 1; |
Alex Kiernan | d4bb3b3 | 2018-04-19 04:32:53 +0000 | [diff] [blame] | 257 | #endif |
Tom Rini | ba9a670 | 2014-03-28 12:03:38 -0400 | [diff] [blame] | 258 | |
| 259 | #ifdef CONFIG_SPL_ENV_SUPPORT |
| 260 | env_init(); |
Simon Glass | 310fb14 | 2017-08-03 12:22:07 -0600 | [diff] [blame] | 261 | env_load(); |
Simon Glass | bfebc8c | 2017-08-03 12:22:13 -0600 | [diff] [blame] | 262 | if (env_get_yesno("boot_os") != 1) |
Tom Rini | ba9a670 | 2014-03-28 12:03:38 -0400 | [diff] [blame] | 263 | return 1; |
| 264 | #endif |
| 265 | |
| 266 | return 0; |
Peter Korsgaard | 12d7a47 | 2013-05-13 08:36:30 +0000 | [diff] [blame] | 267 | } |
| 268 | #endif |
| 269 | |
Lokesh Vutla | 94d77fb | 2013-07-30 10:48:52 +0530 | [diff] [blame] | 270 | const struct dpll_params *get_dpll_ddr_params(void) |
| 271 | { |
Lokesh Vutla | fbd6295 | 2017-05-05 12:59:10 +0530 | [diff] [blame] | 272 | int ind = get_sys_clk_index(); |
| 273 | |
Nishanth Menon | 770e68c | 2016-02-24 12:30:55 -0600 | [diff] [blame] | 274 | if (board_is_evm_sk()) |
Lokesh Vutla | fbd6295 | 2017-05-05 12:59:10 +0530 | [diff] [blame] | 275 | return &dpll_ddr3_303MHz[ind]; |
Jason Kridner | eff0c97 | 2018-03-07 05:40:41 -0500 | [diff] [blame] | 276 | else if (board_is_pb() || board_is_bone_lt() || board_is_icev2()) |
Lokesh Vutla | fbd6295 | 2017-05-05 12:59:10 +0530 | [diff] [blame] | 277 | return &dpll_ddr3_400MHz[ind]; |
Nishanth Menon | 770e68c | 2016-02-24 12:30:55 -0600 | [diff] [blame] | 278 | else if (board_is_evm_15_or_later()) |
Lokesh Vutla | fbd6295 | 2017-05-05 12:59:10 +0530 | [diff] [blame] | 279 | return &dpll_ddr3_303MHz[ind]; |
Lokesh Vutla | 94d77fb | 2013-07-30 10:48:52 +0530 | [diff] [blame] | 280 | else |
Lokesh Vutla | fbd6295 | 2017-05-05 12:59:10 +0530 | [diff] [blame] | 281 | return &dpll_ddr2_266MHz[ind]; |
| 282 | } |
| 283 | |
| 284 | static u8 bone_not_connected_to_ac_power(void) |
| 285 | { |
| 286 | if (board_is_bone()) { |
| 287 | uchar pmic_status_reg; |
| 288 | if (tps65217_reg_read(TPS65217_STATUS, |
| 289 | &pmic_status_reg)) |
| 290 | return 1; |
| 291 | if (!(pmic_status_reg & TPS65217_PWR_SRC_AC_BITMASK)) { |
| 292 | puts("No AC power, switching to default OPP\n"); |
| 293 | return 1; |
| 294 | } |
| 295 | } |
| 296 | return 0; |
| 297 | } |
| 298 | |
| 299 | const struct dpll_params *get_dpll_mpu_params(void) |
| 300 | { |
| 301 | int ind = get_sys_clk_index(); |
| 302 | int freq = am335x_get_efuse_mpu_max_freq(cdev); |
| 303 | |
| 304 | if (bone_not_connected_to_ac_power()) |
| 305 | freq = MPUPLL_M_600; |
| 306 | |
Jason Kridner | eff0c97 | 2018-03-07 05:40:41 -0500 | [diff] [blame] | 307 | if (board_is_pb() || board_is_bone_lt()) |
Lokesh Vutla | fbd6295 | 2017-05-05 12:59:10 +0530 | [diff] [blame] | 308 | freq = MPUPLL_M_1000; |
| 309 | |
| 310 | switch (freq) { |
| 311 | case MPUPLL_M_1000: |
| 312 | return &dpll_mpu_opp[ind][5]; |
| 313 | case MPUPLL_M_800: |
| 314 | return &dpll_mpu_opp[ind][4]; |
| 315 | case MPUPLL_M_720: |
| 316 | return &dpll_mpu_opp[ind][3]; |
| 317 | case MPUPLL_M_600: |
| 318 | return &dpll_mpu_opp[ind][2]; |
| 319 | case MPUPLL_M_500: |
| 320 | return &dpll_mpu_opp100; |
| 321 | case MPUPLL_M_300: |
| 322 | return &dpll_mpu_opp[ind][0]; |
| 323 | } |
| 324 | |
| 325 | return &dpll_mpu_opp[ind][0]; |
Lokesh Vutla | 94d77fb | 2013-07-30 10:48:52 +0530 | [diff] [blame] | 326 | } |
| 327 | |
Lokesh Vutla | 0650798 | 2017-05-05 12:59:09 +0530 | [diff] [blame] | 328 | static void scale_vcores_bone(int freq) |
| 329 | { |
| 330 | int usb_cur_lim, mpu_vdd; |
| 331 | |
| 332 | /* |
| 333 | * Only perform PMIC configurations if board rev > A1 |
| 334 | * on Beaglebone White |
| 335 | */ |
| 336 | if (board_is_bone() && !strncmp(board_ti_get_rev(), "00A1", 4)) |
| 337 | return; |
| 338 | |
Igor Opaniuk | 2147a16 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 339 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Lokesh Vutla | 0650798 | 2017-05-05 12:59:09 +0530 | [diff] [blame] | 340 | if (i2c_probe(TPS65217_CHIP_PM)) |
| 341 | return; |
Jean-Jacques Hiblot | 1514244 | 2018-12-07 14:50:49 +0100 | [diff] [blame] | 342 | #else |
| 343 | if (power_tps65217_init(0)) |
| 344 | return; |
| 345 | #endif |
| 346 | |
Lokesh Vutla | 0650798 | 2017-05-05 12:59:09 +0530 | [diff] [blame] | 347 | |
| 348 | /* |
| 349 | * On Beaglebone White we need to ensure we have AC power |
| 350 | * before increasing the frequency. |
| 351 | */ |
Lokesh Vutla | fbd6295 | 2017-05-05 12:59:10 +0530 | [diff] [blame] | 352 | if (bone_not_connected_to_ac_power()) |
| 353 | freq = MPUPLL_M_600; |
Lokesh Vutla | 0650798 | 2017-05-05 12:59:09 +0530 | [diff] [blame] | 354 | |
| 355 | /* |
| 356 | * Override what we have detected since we know if we have |
| 357 | * a Beaglebone Black it supports 1GHz. |
| 358 | */ |
Jason Kridner | eff0c97 | 2018-03-07 05:40:41 -0500 | [diff] [blame] | 359 | if (board_is_pb() || board_is_bone_lt()) |
Lokesh Vutla | 0650798 | 2017-05-05 12:59:09 +0530 | [diff] [blame] | 360 | freq = MPUPLL_M_1000; |
| 361 | |
Lokesh Vutla | 0650798 | 2017-05-05 12:59:09 +0530 | [diff] [blame] | 362 | switch (freq) { |
| 363 | case MPUPLL_M_1000: |
| 364 | mpu_vdd = TPS65217_DCDC_VOLT_SEL_1325MV; |
| 365 | usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1800MA; |
| 366 | break; |
| 367 | case MPUPLL_M_800: |
| 368 | mpu_vdd = TPS65217_DCDC_VOLT_SEL_1275MV; |
Lokesh Vutla | 9f7923c | 2017-06-10 13:22:56 +0530 | [diff] [blame] | 369 | usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1300MA; |
Lokesh Vutla | 0650798 | 2017-05-05 12:59:09 +0530 | [diff] [blame] | 370 | break; |
| 371 | case MPUPLL_M_720: |
| 372 | mpu_vdd = TPS65217_DCDC_VOLT_SEL_1200MV; |
Lokesh Vutla | 9f7923c | 2017-06-10 13:22:56 +0530 | [diff] [blame] | 373 | usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1300MA; |
Lokesh Vutla | 0650798 | 2017-05-05 12:59:09 +0530 | [diff] [blame] | 374 | break; |
| 375 | case MPUPLL_M_600: |
| 376 | case MPUPLL_M_500: |
| 377 | case MPUPLL_M_300: |
Lokesh Vutla | 9f7923c | 2017-06-10 13:22:56 +0530 | [diff] [blame] | 378 | default: |
Lokesh Vutla | 0650798 | 2017-05-05 12:59:09 +0530 | [diff] [blame] | 379 | mpu_vdd = TPS65217_DCDC_VOLT_SEL_1100MV; |
| 380 | usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1300MA; |
| 381 | break; |
| 382 | } |
| 383 | |
| 384 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_NONE, |
| 385 | TPS65217_POWER_PATH, |
| 386 | usb_cur_lim, |
| 387 | TPS65217_USB_INPUT_CUR_LIMIT_MASK)) |
| 388 | puts("tps65217_reg_write failure\n"); |
| 389 | |
| 390 | /* Set DCDC3 (CORE) voltage to 1.10V */ |
| 391 | if (tps65217_voltage_update(TPS65217_DEFDCDC3, |
| 392 | TPS65217_DCDC_VOLT_SEL_1100MV)) { |
| 393 | puts("tps65217_voltage_update failure\n"); |
| 394 | return; |
| 395 | } |
| 396 | |
| 397 | /* Set DCDC2 (MPU) voltage */ |
| 398 | if (tps65217_voltage_update(TPS65217_DEFDCDC2, mpu_vdd)) { |
| 399 | puts("tps65217_voltage_update failure\n"); |
| 400 | return; |
| 401 | } |
| 402 | |
| 403 | /* |
| 404 | * Set LDO3, LDO4 output voltage to 3.3V for Beaglebone. |
| 405 | * Set LDO3 to 1.8V and LDO4 to 3.3V for Beaglebone Black. |
| 406 | */ |
| 407 | if (board_is_bone()) { |
| 408 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, |
| 409 | TPS65217_DEFLS1, |
| 410 | TPS65217_LDO_VOLTAGE_OUT_3_3, |
| 411 | TPS65217_LDO_MASK)) |
| 412 | puts("tps65217_reg_write failure\n"); |
| 413 | } else { |
| 414 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, |
| 415 | TPS65217_DEFLS1, |
| 416 | TPS65217_LDO_VOLTAGE_OUT_1_8, |
| 417 | TPS65217_LDO_MASK)) |
| 418 | puts("tps65217_reg_write failure\n"); |
| 419 | } |
| 420 | |
| 421 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, |
| 422 | TPS65217_DEFLS2, |
| 423 | TPS65217_LDO_VOLTAGE_OUT_3_3, |
| 424 | TPS65217_LDO_MASK)) |
| 425 | puts("tps65217_reg_write failure\n"); |
| 426 | } |
| 427 | |
| 428 | void scale_vcores_generic(int freq) |
| 429 | { |
| 430 | int sil_rev, mpu_vdd; |
| 431 | |
| 432 | /* |
| 433 | * The GP EVM, IDK and EVM SK use a TPS65910 PMIC. For all |
| 434 | * MPU frequencies we support we use a CORE voltage of |
| 435 | * 1.10V. For MPU voltage we need to switch based on |
| 436 | * the frequency we are running at. |
| 437 | */ |
Igor Opaniuk | 2147a16 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 438 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Lokesh Vutla | 0650798 | 2017-05-05 12:59:09 +0530 | [diff] [blame] | 439 | if (i2c_probe(TPS65910_CTRL_I2C_ADDR)) |
| 440 | return; |
Jean-Jacques Hiblot | 1514244 | 2018-12-07 14:50:49 +0100 | [diff] [blame] | 441 | #else |
| 442 | if (power_tps65910_init(0)) |
| 443 | return; |
| 444 | #endif |
Lokesh Vutla | 0650798 | 2017-05-05 12:59:09 +0530 | [diff] [blame] | 445 | /* |
| 446 | * Depending on MPU clock and PG we will need a different |
| 447 | * VDD to drive at that speed. |
| 448 | */ |
| 449 | sil_rev = readl(&cdev->deviceid) >> 28; |
| 450 | mpu_vdd = am335x_get_tps65910_mpu_vdd(sil_rev, freq); |
| 451 | |
| 452 | /* Tell the TPS65910 to use i2c */ |
| 453 | tps65910_set_i2c_control(); |
| 454 | |
| 455 | /* First update MPU voltage. */ |
| 456 | if (tps65910_voltage_update(MPU, mpu_vdd)) |
| 457 | return; |
| 458 | |
| 459 | /* Second, update the CORE voltage. */ |
| 460 | if (tps65910_voltage_update(CORE, TPS65910_OP_REG_SEL_1_1_0)) |
| 461 | return; |
| 462 | |
| 463 | } |
| 464 | |
| 465 | void gpi2c_init(void) |
| 466 | { |
| 467 | /* When needed to be invoked prior to BSS initialization */ |
| 468 | static bool first_time = true; |
| 469 | |
| 470 | if (first_time) { |
| 471 | enable_i2c0_pin_mux(); |
Igor Opaniuk | 2147a16 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 472 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Lokesh Vutla | 0650798 | 2017-05-05 12:59:09 +0530 | [diff] [blame] | 473 | i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, |
| 474 | CONFIG_SYS_OMAP24_I2C_SLAVE); |
Jean-Jacques Hiblot | 1514244 | 2018-12-07 14:50:49 +0100 | [diff] [blame] | 475 | #endif |
Lokesh Vutla | 0650798 | 2017-05-05 12:59:09 +0530 | [diff] [blame] | 476 | first_time = false; |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | void scale_vcores(void) |
| 481 | { |
| 482 | int freq; |
| 483 | |
| 484 | gpi2c_init(); |
| 485 | freq = am335x_get_efuse_mpu_max_freq(cdev); |
| 486 | |
Lokesh Vutla | 9f7923c | 2017-06-10 13:22:56 +0530 | [diff] [blame] | 487 | if (board_is_beaglebonex()) |
Lokesh Vutla | 0650798 | 2017-05-05 12:59:09 +0530 | [diff] [blame] | 488 | scale_vcores_bone(freq); |
| 489 | else |
| 490 | scale_vcores_generic(freq); |
| 491 | } |
| 492 | |
Heiko Schocher | 0660481 | 2013-07-30 10:48:54 +0530 | [diff] [blame] | 493 | void set_uart_mux_conf(void) |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 494 | { |
Tom Rini | 1286b7f | 2014-08-01 09:53:24 -0400 | [diff] [blame] | 495 | #if CONFIG_CONS_INDEX == 1 |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 496 | enable_uart0_pin_mux(); |
Tom Rini | 1286b7f | 2014-08-01 09:53:24 -0400 | [diff] [blame] | 497 | #elif CONFIG_CONS_INDEX == 2 |
Andrew Bradford | 6422b70 | 2012-10-25 08:21:30 -0400 | [diff] [blame] | 498 | enable_uart1_pin_mux(); |
Tom Rini | 1286b7f | 2014-08-01 09:53:24 -0400 | [diff] [blame] | 499 | #elif CONFIG_CONS_INDEX == 3 |
Andrew Bradford | 6422b70 | 2012-10-25 08:21:30 -0400 | [diff] [blame] | 500 | enable_uart2_pin_mux(); |
Tom Rini | 1286b7f | 2014-08-01 09:53:24 -0400 | [diff] [blame] | 501 | #elif CONFIG_CONS_INDEX == 4 |
Andrew Bradford | 6422b70 | 2012-10-25 08:21:30 -0400 | [diff] [blame] | 502 | enable_uart3_pin_mux(); |
Tom Rini | 1286b7f | 2014-08-01 09:53:24 -0400 | [diff] [blame] | 503 | #elif CONFIG_CONS_INDEX == 5 |
Andrew Bradford | 6422b70 | 2012-10-25 08:21:30 -0400 | [diff] [blame] | 504 | enable_uart4_pin_mux(); |
Tom Rini | 1286b7f | 2014-08-01 09:53:24 -0400 | [diff] [blame] | 505 | #elif CONFIG_CONS_INDEX == 6 |
Andrew Bradford | 6422b70 | 2012-10-25 08:21:30 -0400 | [diff] [blame] | 506 | enable_uart5_pin_mux(); |
Tom Rini | 1286b7f | 2014-08-01 09:53:24 -0400 | [diff] [blame] | 507 | #endif |
Heiko Schocher | 0660481 | 2013-07-30 10:48:54 +0530 | [diff] [blame] | 508 | } |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 509 | |
Heiko Schocher | 0660481 | 2013-07-30 10:48:54 +0530 | [diff] [blame] | 510 | void set_mux_conf_regs(void) |
| 511 | { |
Nishanth Menon | 770e68c | 2016-02-24 12:30:55 -0600 | [diff] [blame] | 512 | enable_board_pin_mux(); |
Heiko Schocher | 0660481 | 2013-07-30 10:48:54 +0530 | [diff] [blame] | 513 | } |
| 514 | |
Lokesh Vutla | 965de8b | 2013-12-10 15:02:21 +0530 | [diff] [blame] | 515 | const struct ctrl_ioregs ioregs_evmsk = { |
| 516 | .cm0ioctl = MT41J128MJT125_IOCTRL_VALUE, |
| 517 | .cm1ioctl = MT41J128MJT125_IOCTRL_VALUE, |
| 518 | .cm2ioctl = MT41J128MJT125_IOCTRL_VALUE, |
| 519 | .dt0ioctl = MT41J128MJT125_IOCTRL_VALUE, |
| 520 | .dt1ioctl = MT41J128MJT125_IOCTRL_VALUE, |
| 521 | }; |
| 522 | |
| 523 | const struct ctrl_ioregs ioregs_bonelt = { |
| 524 | .cm0ioctl = MT41K256M16HA125E_IOCTRL_VALUE, |
| 525 | .cm1ioctl = MT41K256M16HA125E_IOCTRL_VALUE, |
| 526 | .cm2ioctl = MT41K256M16HA125E_IOCTRL_VALUE, |
| 527 | .dt0ioctl = MT41K256M16HA125E_IOCTRL_VALUE, |
| 528 | .dt1ioctl = MT41K256M16HA125E_IOCTRL_VALUE, |
| 529 | }; |
| 530 | |
| 531 | const struct ctrl_ioregs ioregs_evm15 = { |
| 532 | .cm0ioctl = MT41J512M8RH125_IOCTRL_VALUE, |
| 533 | .cm1ioctl = MT41J512M8RH125_IOCTRL_VALUE, |
| 534 | .cm2ioctl = MT41J512M8RH125_IOCTRL_VALUE, |
| 535 | .dt0ioctl = MT41J512M8RH125_IOCTRL_VALUE, |
| 536 | .dt1ioctl = MT41J512M8RH125_IOCTRL_VALUE, |
| 537 | }; |
| 538 | |
| 539 | const struct ctrl_ioregs ioregs = { |
| 540 | .cm0ioctl = MT47H128M16RT25E_IOCTRL_VALUE, |
| 541 | .cm1ioctl = MT47H128M16RT25E_IOCTRL_VALUE, |
| 542 | .cm2ioctl = MT47H128M16RT25E_IOCTRL_VALUE, |
| 543 | .dt0ioctl = MT47H128M16RT25E_IOCTRL_VALUE, |
| 544 | .dt1ioctl = MT47H128M16RT25E_IOCTRL_VALUE, |
| 545 | }; |
| 546 | |
Heiko Schocher | 0660481 | 2013-07-30 10:48:54 +0530 | [diff] [blame] | 547 | void sdram_init(void) |
| 548 | { |
Nishanth Menon | 770e68c | 2016-02-24 12:30:55 -0600 | [diff] [blame] | 549 | if (board_is_evm_sk()) { |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 550 | /* |
| 551 | * EVM SK 1.2A and later use gpio0_7 to enable DDR3. |
| 552 | * This is safe enough to do on older revs. |
| 553 | */ |
| 554 | gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en"); |
| 555 | gpio_direction_output(GPIO_DDR_VTT_EN, 1); |
| 556 | } |
| 557 | |
Lokesh Vutla | d8ff4fd | 2016-05-16 11:47:24 +0530 | [diff] [blame] | 558 | if (board_is_icev2()) { |
| 559 | gpio_request(ICE_GPIO_DDR_VTT_EN, "ddr_vtt_en"); |
| 560 | gpio_direction_output(ICE_GPIO_DDR_VTT_EN, 1); |
| 561 | } |
| 562 | |
Nishanth Menon | 770e68c | 2016-02-24 12:30:55 -0600 | [diff] [blame] | 563 | if (board_is_evm_sk()) |
Lokesh Vutla | 965de8b | 2013-12-10 15:02:21 +0530 | [diff] [blame] | 564 | config_ddr(303, &ioregs_evmsk, &ddr3_data, |
Matt Porter | 3ba65f9 | 2013-03-15 10:07:03 +0000 | [diff] [blame] | 565 | &ddr3_cmd_ctrl_data, &ddr3_emif_reg_data, 0); |
Jason Kridner | eff0c97 | 2018-03-07 05:40:41 -0500 | [diff] [blame] | 566 | else if (board_is_pb() || board_is_bone_lt()) |
Lokesh Vutla | 965de8b | 2013-12-10 15:02:21 +0530 | [diff] [blame] | 567 | config_ddr(400, &ioregs_bonelt, |
Tom Rini | c7ba18a | 2013-03-21 04:30:02 +0000 | [diff] [blame] | 568 | &ddr3_beagleblack_data, |
| 569 | &ddr3_beagleblack_cmd_ctrl_data, |
| 570 | &ddr3_beagleblack_emif_reg_data, 0); |
Nishanth Menon | 770e68c | 2016-02-24 12:30:55 -0600 | [diff] [blame] | 571 | else if (board_is_evm_15_or_later()) |
Lokesh Vutla | 965de8b | 2013-12-10 15:02:21 +0530 | [diff] [blame] | 572 | config_ddr(303, &ioregs_evm15, &ddr3_evm_data, |
Matt Porter | 3ba65f9 | 2013-03-15 10:07:03 +0000 | [diff] [blame] | 573 | &ddr3_evm_cmd_ctrl_data, &ddr3_evm_emif_reg_data, 0); |
Lokesh Vutla | d8ff4fd | 2016-05-16 11:47:24 +0530 | [diff] [blame] | 574 | else if (board_is_icev2()) |
| 575 | config_ddr(400, &ioregs_evmsk, &ddr3_icev2_data, |
| 576 | &ddr3_icev2_cmd_ctrl_data, &ddr3_icev2_emif_reg_data, |
| 577 | 0); |
Jyri Sarha | 8c17cbd | 2016-12-09 12:29:13 +0200 | [diff] [blame] | 578 | else if (board_is_gp_evm()) |
| 579 | config_ddr(266, &ioregs, &ddr2_data, |
| 580 | &ddr2_cmd_ctrl_data, &ddr2_evm_emif_reg_data, 0); |
Peter Korsgaard | c00f69d | 2012-10-18 01:21:12 +0000 | [diff] [blame] | 581 | else |
Lokesh Vutla | 965de8b | 2013-12-10 15:02:21 +0530 | [diff] [blame] | 582 | config_ddr(266, &ioregs, &ddr2_data, |
Matt Porter | 3ba65f9 | 2013-03-15 10:07:03 +0000 | [diff] [blame] | 583 | &ddr2_cmd_ctrl_data, &ddr2_emif_reg_data, 0); |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 584 | } |
Heiko Schocher | 0660481 | 2013-07-30 10:48:54 +0530 | [diff] [blame] | 585 | #endif |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 586 | |
Alex Kiernan | 8cf2f36 | 2018-04-01 09:22:37 +0000 | [diff] [blame] | 587 | #if defined(CONFIG_CLOCK_SYNTHESIZER) && (!defined(CONFIG_SPL_BUILD) || \ |
| 588 | (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))) |
Roger Quadros | e607ec9 | 2016-08-24 15:35:50 +0300 | [diff] [blame] | 589 | static void request_and_set_gpio(int gpio, char *name, int val) |
Lokesh Vutla | 97f3a17 | 2016-05-16 11:47:26 +0530 | [diff] [blame] | 590 | { |
| 591 | int ret; |
| 592 | |
| 593 | ret = gpio_request(gpio, name); |
| 594 | if (ret < 0) { |
| 595 | printf("%s: Unable to request %s\n", __func__, name); |
| 596 | return; |
| 597 | } |
| 598 | |
| 599 | ret = gpio_direction_output(gpio, 0); |
| 600 | if (ret < 0) { |
| 601 | printf("%s: Unable to set %s as output\n", __func__, name); |
| 602 | goto err_free_gpio; |
| 603 | } |
| 604 | |
Roger Quadros | e607ec9 | 2016-08-24 15:35:50 +0300 | [diff] [blame] | 605 | gpio_set_value(gpio, val); |
Lokesh Vutla | 97f3a17 | 2016-05-16 11:47:26 +0530 | [diff] [blame] | 606 | |
| 607 | return; |
| 608 | |
| 609 | err_free_gpio: |
| 610 | gpio_free(gpio); |
| 611 | } |
| 612 | |
Roger Quadros | e607ec9 | 2016-08-24 15:35:50 +0300 | [diff] [blame] | 613 | #define REQUEST_AND_SET_GPIO(N) request_and_set_gpio(N, #N, 1); |
| 614 | #define REQUEST_AND_CLR_GPIO(N) request_and_set_gpio(N, #N, 0); |
Lokesh Vutla | 97f3a17 | 2016-05-16 11:47:26 +0530 | [diff] [blame] | 615 | |
| 616 | /** |
| 617 | * RMII mode on ICEv2 board needs 50MHz clock. Given the clock |
| 618 | * synthesizer With a capacitor of 18pF, and 25MHz input clock cycle |
| 619 | * PLL1 gives an output of 100MHz. So, configuring the div2/3 as 2 to |
| 620 | * give 50MHz output for Eth0 and 1. |
| 621 | */ |
| 622 | static struct clk_synth cdce913_data = { |
| 623 | .id = 0x81, |
| 624 | .capacitor = 0x90, |
| 625 | .mux = 0x6d, |
| 626 | .pdiv2 = 0x2, |
| 627 | .pdiv3 = 0x2, |
| 628 | }; |
| 629 | #endif |
| 630 | |
Sekhar Nori | 20c37fb | 2018-08-23 17:11:30 +0530 | [diff] [blame] | 631 | #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_CONTROL) && \ |
| 632 | defined(CONFIG_DM_ETH) && defined(CONFIG_DRIVER_TI_CPSW) |
| 633 | |
| 634 | #define MAX_CPSW_SLAVES 2 |
| 635 | |
| 636 | /* At the moment, we do not want to stop booting for any failures here */ |
Masahiro Yamada | b75d8dc | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 637 | int ft_board_setup(void *fdt, struct bd_info *bd) |
Sekhar Nori | 20c37fb | 2018-08-23 17:11:30 +0530 | [diff] [blame] | 638 | { |
| 639 | const char *slave_path, *enet_name; |
| 640 | int enetnode, slavenode, phynode; |
| 641 | struct udevice *ethdev; |
| 642 | char alias[16]; |
| 643 | u32 phy_id[2]; |
| 644 | int phy_addr; |
| 645 | int i, ret; |
| 646 | |
| 647 | /* phy address fixup needed only on beagle bone family */ |
| 648 | if (!board_is_beaglebonex()) |
| 649 | goto done; |
| 650 | |
| 651 | for (i = 0; i < MAX_CPSW_SLAVES; i++) { |
| 652 | sprintf(alias, "ethernet%d", i); |
| 653 | |
| 654 | slave_path = fdt_get_alias(fdt, alias); |
| 655 | if (!slave_path) |
| 656 | continue; |
| 657 | |
| 658 | slavenode = fdt_path_offset(fdt, slave_path); |
| 659 | if (slavenode < 0) |
| 660 | continue; |
| 661 | |
| 662 | enetnode = fdt_parent_offset(fdt, slavenode); |
| 663 | enet_name = fdt_get_name(fdt, enetnode, NULL); |
| 664 | |
| 665 | ethdev = eth_get_dev_by_name(enet_name); |
| 666 | if (!ethdev) |
| 667 | continue; |
| 668 | |
| 669 | phy_addr = cpsw_get_slave_phy_addr(ethdev, i); |
| 670 | |
| 671 | /* check for phy_id as well as phy-handle properties */ |
| 672 | ret = fdtdec_get_int_array_count(fdt, slavenode, "phy_id", |
| 673 | phy_id, 2); |
| 674 | if (ret == 2) { |
| 675 | if (phy_id[1] != phy_addr) { |
| 676 | printf("fixing up phy_id for %s, old: %d, new: %d\n", |
| 677 | alias, phy_id[1], phy_addr); |
| 678 | |
| 679 | phy_id[0] = cpu_to_fdt32(phy_id[0]); |
| 680 | phy_id[1] = cpu_to_fdt32(phy_addr); |
| 681 | do_fixup_by_path(fdt, slave_path, "phy_id", |
| 682 | phy_id, sizeof(phy_id), 0); |
| 683 | } |
| 684 | } else { |
| 685 | phynode = fdtdec_lookup_phandle(fdt, slavenode, |
| 686 | "phy-handle"); |
| 687 | if (phynode < 0) |
| 688 | continue; |
| 689 | |
| 690 | ret = fdtdec_get_int(fdt, phynode, "reg", -ENOENT); |
| 691 | if (ret < 0) |
| 692 | continue; |
| 693 | |
| 694 | if (ret != phy_addr) { |
| 695 | printf("fixing up phy-handle for %s, old: %d, new: %d\n", |
| 696 | alias, ret, phy_addr); |
| 697 | |
| 698 | fdt_setprop_u32(fdt, phynode, "reg", |
| 699 | cpu_to_fdt32(phy_addr)); |
| 700 | } |
| 701 | } |
| 702 | } |
| 703 | |
| 704 | done: |
| 705 | return 0; |
| 706 | } |
| 707 | #endif |
| 708 | |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 709 | /* |
| 710 | * Basic board specific setup. Pinmux has been handled already. |
| 711 | */ |
| 712 | int board_init(void) |
| 713 | { |
Tom Rini | 6843918 | 2013-10-01 12:32:04 -0400 | [diff] [blame] | 714 | #if defined(CONFIG_HW_WATCHDOG) |
| 715 | hw_watchdog_init(); |
| 716 | #endif |
| 717 | |
Tom Rini | 73feefd | 2013-08-09 11:22:13 -0400 | [diff] [blame] | 718 | gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; |
Miquel Raynal | 88718be | 2019-10-03 19:50:03 +0200 | [diff] [blame] | 719 | #if defined(CONFIG_NOR) || defined(CONFIG_MTD_RAW_NAND) |
Ilya Yanok | 98b5c26 | 2012-11-06 13:06:31 +0000 | [diff] [blame] | 720 | gpmc_init(); |
Steve Kipisz | cd8845d | 2013-07-18 15:13:03 -0400 | [diff] [blame] | 721 | #endif |
Lokesh Vutla | 97f3a17 | 2016-05-16 11:47:26 +0530 | [diff] [blame] | 722 | |
Alex Kiernan | 8cf2f36 | 2018-04-01 09:22:37 +0000 | [diff] [blame] | 723 | #if defined(CONFIG_CLOCK_SYNTHESIZER) && (!defined(CONFIG_SPL_BUILD) || \ |
| 724 | (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))) |
Lokesh Vutla | 97f3a17 | 2016-05-16 11:47:26 +0530 | [diff] [blame] | 725 | if (board_is_icev2()) { |
Roger Quadros | e607ec9 | 2016-08-24 15:35:50 +0300 | [diff] [blame] | 726 | int rv; |
| 727 | u32 reg; |
| 728 | |
Lokesh Vutla | 97f3a17 | 2016-05-16 11:47:26 +0530 | [diff] [blame] | 729 | REQUEST_AND_SET_GPIO(GPIO_PR1_MII_CTRL); |
Roger Quadros | e607ec9 | 2016-08-24 15:35:50 +0300 | [diff] [blame] | 730 | /* Make J19 status available on GPIO1_26 */ |
| 731 | REQUEST_AND_CLR_GPIO(GPIO_MUX_MII_CTRL); |
| 732 | |
Lokesh Vutla | 97f3a17 | 2016-05-16 11:47:26 +0530 | [diff] [blame] | 733 | REQUEST_AND_SET_GPIO(GPIO_FET_SWITCH_CTRL); |
Roger Quadros | e607ec9 | 2016-08-24 15:35:50 +0300 | [diff] [blame] | 734 | /* |
| 735 | * Both ports can be set as RMII-CPSW or MII-PRU-ETH using |
| 736 | * jumpers near the port. Read the jumper value and set |
| 737 | * the pinmux, external mux and PHY clock accordingly. |
| 738 | * As jumper line is overridden by PHY RX_DV pin immediately |
| 739 | * after bootstrap (power-up/reset), we need to sample |
| 740 | * it during PHY reset using GPIO rising edge detection. |
| 741 | */ |
Lokesh Vutla | 97f3a17 | 2016-05-16 11:47:26 +0530 | [diff] [blame] | 742 | REQUEST_AND_SET_GPIO(GPIO_PHY_RESET); |
Roger Quadros | e607ec9 | 2016-08-24 15:35:50 +0300 | [diff] [blame] | 743 | /* Enable rising edge IRQ on GPIO0_11 and GPIO 1_26 */ |
| 744 | reg = readl(GPIO0_RISINGDETECT) | BIT(11); |
| 745 | writel(reg, GPIO0_RISINGDETECT); |
| 746 | reg = readl(GPIO1_RISINGDETECT) | BIT(26); |
| 747 | writel(reg, GPIO1_RISINGDETECT); |
| 748 | /* Reset PHYs to capture the Jumper setting */ |
| 749 | gpio_set_value(GPIO_PHY_RESET, 0); |
| 750 | udelay(2); /* PHY datasheet states 1uS min. */ |
| 751 | gpio_set_value(GPIO_PHY_RESET, 1); |
| 752 | |
| 753 | reg = readl(GPIO0_IRQSTATUSRAW) & BIT(11); |
| 754 | if (reg) { |
| 755 | writel(reg, GPIO0_IRQSTATUS1); /* clear irq */ |
| 756 | /* RMII mode */ |
| 757 | printf("ETH0, CPSW\n"); |
| 758 | } else { |
| 759 | /* MII mode */ |
| 760 | printf("ETH0, PRU\n"); |
| 761 | cdce913_data.pdiv3 = 4; /* 25MHz PHY clk */ |
| 762 | } |
| 763 | |
| 764 | reg = readl(GPIO1_IRQSTATUSRAW) & BIT(26); |
| 765 | if (reg) { |
| 766 | writel(reg, GPIO1_IRQSTATUS1); /* clear irq */ |
| 767 | /* RMII mode */ |
| 768 | printf("ETH1, CPSW\n"); |
| 769 | gpio_set_value(GPIO_MUX_MII_CTRL, 1); |
| 770 | } else { |
| 771 | /* MII mode */ |
| 772 | printf("ETH1, PRU\n"); |
| 773 | cdce913_data.pdiv2 = 4; /* 25MHz PHY clk */ |
| 774 | } |
| 775 | |
| 776 | /* disable rising edge IRQs */ |
| 777 | reg = readl(GPIO0_RISINGDETECT) & ~BIT(11); |
| 778 | writel(reg, GPIO0_RISINGDETECT); |
| 779 | reg = readl(GPIO1_RISINGDETECT) & ~BIT(26); |
| 780 | writel(reg, GPIO1_RISINGDETECT); |
Lokesh Vutla | 97f3a17 | 2016-05-16 11:47:26 +0530 | [diff] [blame] | 781 | |
| 782 | rv = setup_clock_synthesizer(&cdce913_data); |
| 783 | if (rv) { |
| 784 | printf("Clock synthesizer setup failed %d\n", rv); |
| 785 | return rv; |
| 786 | } |
Roger Quadros | e607ec9 | 2016-08-24 15:35:50 +0300 | [diff] [blame] | 787 | |
| 788 | /* reset PHYs */ |
| 789 | gpio_set_value(GPIO_PHY_RESET, 0); |
| 790 | udelay(2); /* PHY datasheet states 1uS min. */ |
| 791 | gpio_set_value(GPIO_PHY_RESET, 1); |
Lokesh Vutla | 97f3a17 | 2016-05-16 11:47:26 +0530 | [diff] [blame] | 792 | } |
| 793 | #endif |
| 794 | |
Peter Korsgaard | e363426 | 2012-10-18 01:21:09 +0000 | [diff] [blame] | 795 | return 0; |
| 796 | } |
| 797 | |
Tom Rini | 044fc14 | 2012-10-24 07:28:17 +0000 | [diff] [blame] | 798 | #ifdef CONFIG_BOARD_LATE_INIT |
| 799 | int board_late_init(void) |
| 800 | { |
Tero Kristo | 752a45a | 2019-09-27 19:14:29 +0300 | [diff] [blame] | 801 | struct udevice *dev; |
Roger Quadros | f411b5c | 2016-08-24 15:35:51 +0300 | [diff] [blame] | 802 | #if !defined(CONFIG_SPL_BUILD) |
| 803 | uint8_t mac_addr[6]; |
| 804 | uint32_t mac_hi, mac_lo; |
| 805 | #endif |
| 806 | |
Tom Rini | 044fc14 | 2012-10-24 07:28:17 +0000 | [diff] [blame] | 807 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
Nishanth Menon | 770e68c | 2016-02-24 12:30:55 -0600 | [diff] [blame] | 808 | char *name = NULL; |
Tom Rini | ace4275 | 2013-07-18 15:13:01 -0400 | [diff] [blame] | 809 | |
robertcnelson@gmail.com | 4015949 | 2017-03-30 14:29:52 -0500 | [diff] [blame] | 810 | if (board_is_bone_lt()) { |
| 811 | /* BeagleBoard.org BeagleBone Black Wireless: */ |
| 812 | if (!strncmp(board_ti_get_rev(), "BWA", 3)) { |
| 813 | name = "BBBW"; |
| 814 | } |
robertcnelson@gmail.com | 2b79fba | 2017-03-30 14:29:53 -0500 | [diff] [blame] | 815 | /* SeeedStudio BeagleBone Green Wireless */ |
| 816 | if (!strncmp(board_ti_get_rev(), "GW1", 3)) { |
| 817 | name = "BBGW"; |
| 818 | } |
robertcnelson@gmail.com | 52609d7 | 2017-03-30 14:29:54 -0500 | [diff] [blame] | 819 | /* BeagleBoard.org BeagleBone Blue */ |
| 820 | if (!strncmp(board_ti_get_rev(), "BLA", 3)) { |
| 821 | name = "BBBL"; |
| 822 | } |
robertcnelson@gmail.com | 4015949 | 2017-03-30 14:29:52 -0500 | [diff] [blame] | 823 | } |
| 824 | |
Nishanth Menon | 770e68c | 2016-02-24 12:30:55 -0600 | [diff] [blame] | 825 | if (board_is_bbg1()) |
| 826 | name = "BBG1"; |
Koen Kooi | ad6054f | 2018-07-18 10:13:59 +0200 | [diff] [blame] | 827 | if (board_is_bben()) |
| 828 | name = "BBEN"; |
Nishanth Menon | 770e68c | 2016-02-24 12:30:55 -0600 | [diff] [blame] | 829 | set_board_info_env(name); |
Lokesh Vutla | 5d4d436 | 2016-11-29 11:58:03 +0530 | [diff] [blame] | 830 | |
| 831 | /* |
| 832 | * Default FIT boot on HS devices. Non FIT images are not allowed |
| 833 | * on HS devices. |
| 834 | */ |
| 835 | if (get_device_type() == HS_DEVICE) |
Simon Glass | 382bee5 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 836 | env_set("boot_fit", "1"); |
Tom Rini | 044fc14 | 2012-10-24 07:28:17 +0000 | [diff] [blame] | 837 | #endif |
| 838 | |
Roger Quadros | f411b5c | 2016-08-24 15:35:51 +0300 | [diff] [blame] | 839 | #if !defined(CONFIG_SPL_BUILD) |
| 840 | /* try reading mac address from efuse */ |
| 841 | mac_lo = readl(&cdev->macid0l); |
| 842 | mac_hi = readl(&cdev->macid0h); |
| 843 | mac_addr[0] = mac_hi & 0xFF; |
| 844 | mac_addr[1] = (mac_hi & 0xFF00) >> 8; |
| 845 | mac_addr[2] = (mac_hi & 0xFF0000) >> 16; |
| 846 | mac_addr[3] = (mac_hi & 0xFF000000) >> 24; |
| 847 | mac_addr[4] = mac_lo & 0xFF; |
| 848 | mac_addr[5] = (mac_lo & 0xFF00) >> 8; |
| 849 | |
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 850 | if (!env_get("ethaddr")) { |
Roger Quadros | f411b5c | 2016-08-24 15:35:51 +0300 | [diff] [blame] | 851 | printf("<ethaddr> not set. Validating first E-fuse MAC\n"); |
| 852 | |
| 853 | if (is_valid_ethaddr(mac_addr)) |
Simon Glass | fd1e959 | 2017-08-03 12:22:11 -0600 | [diff] [blame] | 854 | eth_env_set_enetaddr("ethaddr", mac_addr); |
Roger Quadros | f411b5c | 2016-08-24 15:35:51 +0300 | [diff] [blame] | 855 | } |
| 856 | |
| 857 | mac_lo = readl(&cdev->macid1l); |
| 858 | mac_hi = readl(&cdev->macid1h); |
| 859 | mac_addr[0] = mac_hi & 0xFF; |
| 860 | mac_addr[1] = (mac_hi & 0xFF00) >> 8; |
| 861 | mac_addr[2] = (mac_hi & 0xFF0000) >> 16; |
| 862 | mac_addr[3] = (mac_hi & 0xFF000000) >> 24; |
| 863 | mac_addr[4] = mac_lo & 0xFF; |
| 864 | mac_addr[5] = (mac_lo & 0xFF00) >> 8; |
| 865 | |
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 866 | if (!env_get("eth1addr")) { |
Roger Quadros | f411b5c | 2016-08-24 15:35:51 +0300 | [diff] [blame] | 867 | if (is_valid_ethaddr(mac_addr)) |
Simon Glass | fd1e959 | 2017-08-03 12:22:11 -0600 | [diff] [blame] | 868 | eth_env_set_enetaddr("eth1addr", mac_addr); |
Roger Quadros | f411b5c | 2016-08-24 15:35:51 +0300 | [diff] [blame] | 869 | } |
| 870 | #endif |
| 871 | |
Sam Protsenko | fc228dc | 2018-02-28 00:26:15 +0200 | [diff] [blame] | 872 | if (!env_get("serial#")) { |
| 873 | char *board_serial = env_get("board_serial"); |
| 874 | char *ethaddr = env_get("ethaddr"); |
| 875 | |
| 876 | if (!board_serial || !strncmp(board_serial, "unknown", 7)) |
| 877 | env_set("serial#", ethaddr); |
| 878 | else |
| 879 | env_set("serial#", board_serial); |
| 880 | } |
| 881 | |
Tero Kristo | 752a45a | 2019-09-27 19:14:29 +0300 | [diff] [blame] | 882 | /* Just probe the potentially supported cdce913 device */ |
Dario Binacchi | ba149a5 | 2020-12-30 00:16:32 +0100 | [diff] [blame] | 883 | uclass_get_device_by_name(UCLASS_CLK, "cdce913@65", &dev); |
Tero Kristo | 752a45a | 2019-09-27 19:14:29 +0300 | [diff] [blame] | 884 | |
Tom Rini | 044fc14 | 2012-10-24 07:28:17 +0000 | [diff] [blame] | 885 | return 0; |
| 886 | } |
| 887 | #endif |
| 888 | |
Simon Glass | caa4daa | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 889 | /* CPSW plat */ |
Faiz Abbas | 0229c93 | 2019-03-18 13:54:37 +0530 | [diff] [blame] | 890 | #if !CONFIG_IS_ENABLED(OF_CONTROL) |
| 891 | struct cpsw_slave_data slave_data[] = { |
| 892 | { |
| 893 | .slave_reg_ofs = CPSW_SLAVE0_OFFSET, |
| 894 | .sliver_reg_ofs = CPSW_SLIVER0_OFFSET, |
| 895 | .phy_addr = 0, |
| 896 | }, |
| 897 | { |
| 898 | .slave_reg_ofs = CPSW_SLAVE1_OFFSET, |
| 899 | .sliver_reg_ofs = CPSW_SLIVER1_OFFSET, |
| 900 | .phy_addr = 1, |
| 901 | }, |
| 902 | }; |
| 903 | |
| 904 | struct cpsw_platform_data am335_eth_data = { |
| 905 | .cpsw_base = CPSW_BASE, |
| 906 | .version = CPSW_CTRL_VERSION_2, |
| 907 | .bd_ram_ofs = CPSW_BD_OFFSET, |
| 908 | .ale_reg_ofs = CPSW_ALE_OFFSET, |
| 909 | .cpdma_reg_ofs = CPSW_CPDMA_OFFSET, |
| 910 | .mdio_div = CPSW_MDIO_DIV, |
| 911 | .host_port_reg_ofs = CPSW_HOST_PORT_OFFSET, |
| 912 | .channels = 8, |
| 913 | .slaves = 2, |
| 914 | .slave_data = slave_data, |
| 915 | .ale_entries = 1024, |
Faiz Abbas | 0229c93 | 2019-03-18 13:54:37 +0530 | [diff] [blame] | 916 | .mac_control = 0x20, |
| 917 | .active_slave = 0, |
| 918 | .mdio_base = 0x4a101000, |
| 919 | .gmii_sel = 0x44e10650, |
| 920 | .phy_sel_compat = "ti,am3352-cpsw-phy-sel", |
| 921 | .syscon_addr = 0x44e10630, |
| 922 | .macid_sel_compat = "cpsw,am33xx", |
| 923 | }; |
| 924 | |
| 925 | struct eth_pdata cpsw_pdata = { |
| 926 | .iobase = 0x4a100000, |
| 927 | .phy_interface = 0, |
| 928 | .priv_pdata = &am335_eth_data, |
| 929 | }; |
| 930 | |
Simon Glass | 20e442a | 2020-12-28 20:34:54 -0700 | [diff] [blame] | 931 | U_BOOT_DRVINFO(am335x_eth) = { |
Faiz Abbas | 0229c93 | 2019-03-18 13:54:37 +0530 | [diff] [blame] | 932 | .name = "eth_cpsw", |
Simon Glass | caa4daa | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 933 | .plat = &cpsw_pdata, |
Faiz Abbas | 0229c93 | 2019-03-18 13:54:37 +0530 | [diff] [blame] | 934 | }; |
| 935 | #endif |
| 936 | |
Lokesh Vutla | 505ea6e | 2016-05-16 11:24:24 +0530 | [diff] [blame] | 937 | #ifdef CONFIG_SPL_LOAD_FIT |
| 938 | int board_fit_config_name_match(const char *name) |
| 939 | { |
| 940 | if (board_is_gp_evm() && !strcmp(name, "am335x-evm")) |
| 941 | return 0; |
| 942 | else if (board_is_bone() && !strcmp(name, "am335x-bone")) |
| 943 | return 0; |
| 944 | else if (board_is_bone_lt() && !strcmp(name, "am335x-boneblack")) |
| 945 | return 0; |
Jason Kridner | eff0c97 | 2018-03-07 05:40:41 -0500 | [diff] [blame] | 946 | else if (board_is_pb() && !strcmp(name, "am335x-pocketbeagle")) |
| 947 | return 0; |
Lokesh Vutla | 3819ea7 | 2016-05-16 11:24:28 +0530 | [diff] [blame] | 948 | else if (board_is_evm_sk() && !strcmp(name, "am335x-evmsk")) |
| 949 | return 0; |
Lokesh Vutla | da9d959 | 2016-05-16 11:24:29 +0530 | [diff] [blame] | 950 | else if (board_is_bbg1() && !strcmp(name, "am335x-bonegreen")) |
| 951 | return 0; |
Lokesh Vutla | 73ec696 | 2016-05-16 11:47:28 +0530 | [diff] [blame] | 952 | else if (board_is_icev2() && !strcmp(name, "am335x-icev2")) |
| 953 | return 0; |
Lokesh Vutla | 505ea6e | 2016-05-16 11:24:24 +0530 | [diff] [blame] | 954 | else |
| 955 | return -1; |
| 956 | } |
| 957 | #endif |
Andrew F. Davis | b0a4eea | 2016-08-30 14:06:24 -0500 | [diff] [blame] | 958 | |
| 959 | #ifdef CONFIG_TI_SECURE_DEVICE |
| 960 | void board_fit_image_post_process(void **p_image, size_t *p_size) |
| 961 | { |
| 962 | secure_boot_verify_image(p_image, p_size); |
| 963 | } |
| 964 | #endif |
Lokesh Vutla | 4548bc8 | 2017-04-26 13:37:08 +0530 | [diff] [blame] | 965 | |
| 966 | #if !CONFIG_IS_ENABLED(OF_CONTROL) |
Simon Glass | 8a8d24b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 967 | static const struct omap_hsmmc_plat am335x_mmc0_plat = { |
Lokesh Vutla | 4548bc8 | 2017-04-26 13:37:08 +0530 | [diff] [blame] | 968 | .base_addr = (struct hsmmc *)OMAP_HSMMC1_BASE, |
| 969 | .cfg.host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS | MMC_MODE_4BIT, |
| 970 | .cfg.f_min = 400000, |
| 971 | .cfg.f_max = 52000000, |
| 972 | .cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195, |
| 973 | .cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT, |
| 974 | }; |
| 975 | |
Simon Glass | 20e442a | 2020-12-28 20:34:54 -0700 | [diff] [blame] | 976 | U_BOOT_DRVINFO(am335x_mmc0) = { |
Lokesh Vutla | 4548bc8 | 2017-04-26 13:37:08 +0530 | [diff] [blame] | 977 | .name = "omap_hsmmc", |
Simon Glass | 8a8d24b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 978 | .plat = &am335x_mmc0_plat, |
Lokesh Vutla | 4548bc8 | 2017-04-26 13:37:08 +0530 | [diff] [blame] | 979 | }; |
| 980 | |
Simon Glass | 8a8d24b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 981 | static const struct omap_hsmmc_plat am335x_mmc1_plat = { |
Lokesh Vutla | 4548bc8 | 2017-04-26 13:37:08 +0530 | [diff] [blame] | 982 | .base_addr = (struct hsmmc *)OMAP_HSMMC2_BASE, |
| 983 | .cfg.host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS | MMC_MODE_8BIT, |
| 984 | .cfg.f_min = 400000, |
| 985 | .cfg.f_max = 52000000, |
| 986 | .cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195, |
| 987 | .cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT, |
| 988 | }; |
| 989 | |
Simon Glass | 20e442a | 2020-12-28 20:34:54 -0700 | [diff] [blame] | 990 | U_BOOT_DRVINFO(am335x_mmc1) = { |
Lokesh Vutla | 4548bc8 | 2017-04-26 13:37:08 +0530 | [diff] [blame] | 991 | .name = "omap_hsmmc", |
Simon Glass | 8a8d24b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 992 | .plat = &am335x_mmc1_plat, |
Lokesh Vutla | 4548bc8 | 2017-04-26 13:37:08 +0530 | [diff] [blame] | 993 | }; |
| 994 | #endif |