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