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