Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com |
| 4 | * |
| 5 | * Author: Felipe Balbi <balbi@ti.com> |
| 6 | * |
| 7 | * Based on board/ti/dra7xx/evm.c |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <common.h> |
Simon Glass | 79fd214 | 2019-08-01 09:46:43 -0600 | [diff] [blame] | 11 | #include <env.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 12 | #include <init.h> |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 13 | #include <palmas.h> |
| 14 | #include <sata.h> |
Simon Glass | 3673618 | 2019-11-14 12:57:24 -0700 | [diff] [blame] | 15 | #include <serial.h> |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 16 | #include <usb.h> |
Caleb Robey | 0dfcc93 | 2020-01-02 08:17:25 -0600 | [diff] [blame^] | 17 | #include <errno.h> |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 18 | #include <asm/omap_common.h> |
Andreas Dannenberg | 5cf344b | 2016-06-27 09:19:22 -0500 | [diff] [blame] | 19 | #include <asm/omap_sec_common.h> |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 20 | #include <asm/emif.h> |
Lokesh Vutla | 9f15067 | 2015-06-16 20:36:05 +0530 | [diff] [blame] | 21 | #include <asm/gpio.h> |
| 22 | #include <asm/arch/gpio.h> |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 23 | #include <asm/arch/clock.h> |
Lokesh Vutla | c3d39f9 | 2015-06-04 16:42:41 +0530 | [diff] [blame] | 24 | #include <asm/arch/dra7xx_iodelay.h> |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 25 | #include <asm/arch/sys_proto.h> |
| 26 | #include <asm/arch/mmc_host_def.h> |
| 27 | #include <asm/arch/sata.h> |
| 28 | #include <asm/arch/gpio.h> |
Kishon Vijay Abraham I | 5f19b2d | 2015-08-19 14:13:19 +0530 | [diff] [blame] | 29 | #include <asm/arch/omap.h> |
Kishon Vijay Abraham I | 5f19b2d | 2015-08-19 14:13:19 +0530 | [diff] [blame] | 30 | #include <usb.h> |
| 31 | #include <linux/usb/gadget.h> |
| 32 | #include <dwc3-uboot.h> |
| 33 | #include <dwc3-omap-uboot.h> |
| 34 | #include <ti-usb-phy-uboot.h> |
Kishon Vijay Abraham I | 110ed01 | 2018-01-30 16:01:52 +0100 | [diff] [blame] | 35 | #include <mmc.h> |
Tero Kristo | dfbc6b8 | 2019-09-27 19:14:27 +0300 | [diff] [blame] | 36 | #include <dm/uclass.h> |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 37 | |
Kipisz, Steven | 161f138 | 2016-02-24 12:30:58 -0600 | [diff] [blame] | 38 | #include "../common/board_detect.h" |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 39 | #include "mux_data.h" |
| 40 | |
Caleb Robey | 0dfcc93 | 2020-01-02 08:17:25 -0600 | [diff] [blame^] | 41 | #ifdef CONFIG_SUPPORT_EMMC_BOOT |
| 42 | static int board_bootmode_has_emmc(void); |
| 43 | #endif |
| 44 | |
Kipisz, Steven | 161f138 | 2016-02-24 12:30:58 -0600 | [diff] [blame] | 45 | #define board_is_x15() board_ti_is("BBRDX15_") |
Lokesh Vutla | 638e1c0 | 2016-11-25 11:14:20 +0530 | [diff] [blame] | 46 | #define board_is_x15_revb1() (board_ti_is("BBRDX15_") && \ |
Lokesh Vutla | ab4f71e | 2017-07-16 19:59:18 +0530 | [diff] [blame] | 47 | !strncmp("B.10", board_ti_get_rev(), 3)) |
Lokesh Vutla | 816178b | 2017-07-16 19:59:19 +0530 | [diff] [blame] | 48 | #define board_is_x15_revc() (board_ti_is("BBRDX15_") && \ |
| 49 | !strncmp("C.00", board_ti_get_rev(), 3)) |
Kipisz, Steven | 161f138 | 2016-02-24 12:30:58 -0600 | [diff] [blame] | 50 | #define board_is_am572x_evm() board_ti_is("AM572PM_") |
Nishanth Menon | a2aea1c | 2016-11-25 11:14:19 +0530 | [diff] [blame] | 51 | #define board_is_am572x_evm_reva3() \ |
| 52 | (board_ti_is("AM572PM_") && \ |
Lokesh Vutla | ab4f71e | 2017-07-16 19:59:18 +0530 | [diff] [blame] | 53 | !strncmp("A.30", board_ti_get_rev(), 3)) |
Lokesh Vutla | 374aea0 | 2017-12-29 11:47:52 +0530 | [diff] [blame] | 54 | #define board_is_am574x_idk() board_ti_is("AM574IDK") |
Steve Kipisz | 0ac8cea | 2016-04-08 17:01:29 -0500 | [diff] [blame] | 55 | #define board_is_am572x_idk() board_ti_is("AM572IDK") |
Steve Kipisz | c95cddd | 2016-11-25 11:14:24 +0530 | [diff] [blame] | 56 | #define board_is_am571x_idk() board_ti_is("AM571IDK") |
Kipisz, Steven | 161f138 | 2016-02-24 12:30:58 -0600 | [diff] [blame] | 57 | |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 58 | #ifdef CONFIG_DRIVER_TI_CPSW |
| 59 | #include <cpsw.h> |
| 60 | #endif |
| 61 | |
| 62 | DECLARE_GLOBAL_DATA_PTR; |
| 63 | |
Roger Quadros | 2613059 | 2017-03-13 15:04:28 +0200 | [diff] [blame] | 64 | #define GPIO_ETH_LCD GPIO_TO_PIN(2, 22) |
Lokesh Vutla | 9f15067 | 2015-06-16 20:36:05 +0530 | [diff] [blame] | 65 | /* GPIO 7_11 */ |
| 66 | #define GPIO_DDR_VTT_EN 203 |
| 67 | |
Nishanth Menon | d0f399c | 2017-03-13 15:04:30 +0200 | [diff] [blame] | 68 | /* Touch screen controller to identify the LCD */ |
| 69 | #define OSD_TS_FT_BUS_ADDRESS 0 |
| 70 | #define OSD_TS_FT_CHIP_ADDRESS 0x38 |
| 71 | #define OSD_TS_FT_REG_ID 0xA3 |
| 72 | /* |
| 73 | * Touchscreen IDs for various OSD panels |
| 74 | * Ref: http://www.osddisplays.com/TI/OSD101T2587-53TS_A.1.pdf |
| 75 | */ |
| 76 | /* Used on newer osd101t2587 Panels */ |
| 77 | #define OSD_TS_FT_ID_5x46 0x54 |
| 78 | /* Used on older osd101t2045 Panels */ |
| 79 | #define OSD_TS_FT_ID_5606 0x08 |
| 80 | |
Kipisz, Steven | 161f138 | 2016-02-24 12:30:58 -0600 | [diff] [blame] | 81 | #define SYSINFO_BOARD_NAME_MAX_LEN 45 |
| 82 | |
Keerthy | ee85ebe | 2016-11-30 15:02:53 +0530 | [diff] [blame] | 83 | #define TPS65903X_PRIMARY_SECONDARY_PAD2 0xFB |
| 84 | #define TPS65903X_PAD2_POWERHOLD_MASK 0x20 |
| 85 | |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 86 | const struct omap_sysinfo sysinfo = { |
Kipisz, Steven | 161f138 | 2016-02-24 12:30:58 -0600 | [diff] [blame] | 87 | "Board: UNKNOWN(BeagleBoard X15?) REV UNKNOWN\n" |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | static const struct dmm_lisa_map_regs beagle_x15_lisa_regs = { |
| 91 | .dmm_lisa_map_3 = 0x80740300, |
| 92 | .is_ma_present = 0x1 |
| 93 | }; |
| 94 | |
Steve Kipisz | c95cddd | 2016-11-25 11:14:24 +0530 | [diff] [blame] | 95 | static const struct dmm_lisa_map_regs am571x_idk_lisa_regs = { |
| 96 | .dmm_lisa_map_3 = 0x80640100, |
| 97 | .is_ma_present = 0x1 |
| 98 | }; |
| 99 | |
Lokesh Vutla | cbd70db | 2017-12-29 11:47:54 +0530 | [diff] [blame] | 100 | static const struct dmm_lisa_map_regs am574x_idk_lisa_regs = { |
| 101 | .dmm_lisa_map_2 = 0xc0600200, |
| 102 | .dmm_lisa_map_3 = 0x80600100, |
| 103 | .is_ma_present = 0x1 |
| 104 | }; |
| 105 | |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 106 | void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs) |
| 107 | { |
Steve Kipisz | c95cddd | 2016-11-25 11:14:24 +0530 | [diff] [blame] | 108 | if (board_is_am571x_idk()) |
| 109 | *dmm_lisa_regs = &am571x_idk_lisa_regs; |
Lokesh Vutla | cbd70db | 2017-12-29 11:47:54 +0530 | [diff] [blame] | 110 | else if (board_is_am574x_idk()) |
| 111 | *dmm_lisa_regs = &am574x_idk_lisa_regs; |
Steve Kipisz | c95cddd | 2016-11-25 11:14:24 +0530 | [diff] [blame] | 112 | else |
| 113 | *dmm_lisa_regs = &beagle_x15_lisa_regs; |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | static const struct emif_regs beagle_x15_emif1_ddr3_532mhz_emif_regs = { |
Keerthy | 66dd806 | 2016-05-24 11:45:07 +0530 | [diff] [blame] | 117 | .sdram_config_init = 0x61851b32, |
| 118 | .sdram_config = 0x61851b32, |
| 119 | .sdram_config2 = 0x08000000, |
| 120 | .ref_ctrl = 0x000040F1, |
| 121 | .ref_ctrl_final = 0x00001035, |
| 122 | .sdram_tim1 = 0xcccf36ab, |
| 123 | .sdram_tim2 = 0x308f7fda, |
| 124 | .sdram_tim3 = 0x409f88a8, |
| 125 | .read_idle_ctrl = 0x00050000, |
| 126 | .zq_config = 0x5007190b, |
| 127 | .temp_alert_config = 0x00000000, |
| 128 | .emif_ddr_phy_ctlr_1_init = 0x0024400b, |
| 129 | .emif_ddr_phy_ctlr_1 = 0x0e24400b, |
| 130 | .emif_ddr_ext_phy_ctrl_1 = 0x10040100, |
| 131 | .emif_ddr_ext_phy_ctrl_2 = 0x00910091, |
| 132 | .emif_ddr_ext_phy_ctrl_3 = 0x00950095, |
| 133 | .emif_ddr_ext_phy_ctrl_4 = 0x009b009b, |
| 134 | .emif_ddr_ext_phy_ctrl_5 = 0x009e009e, |
| 135 | .emif_rd_wr_lvl_rmp_win = 0x00000000, |
| 136 | .emif_rd_wr_lvl_rmp_ctl = 0x80000000, |
| 137 | .emif_rd_wr_lvl_ctl = 0x00000000, |
| 138 | .emif_rd_wr_exec_thresh = 0x00000305 |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 139 | }; |
| 140 | |
Lokesh Vutla | 979d2c3 | 2015-06-03 14:43:21 +0530 | [diff] [blame] | 141 | /* Ext phy ctrl regs 1-35 */ |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 142 | static const u32 beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs[] = { |
Lokesh Vutla | 979d2c3 | 2015-06-03 14:43:21 +0530 | [diff] [blame] | 143 | 0x10040100, |
Lokesh Vutla | 306b597 | 2016-03-08 09:11:35 +0530 | [diff] [blame] | 144 | 0x00910091, |
| 145 | 0x00950095, |
| 146 | 0x009B009B, |
| 147 | 0x009E009E, |
| 148 | 0x00980098, |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 149 | 0x00340034, |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 150 | 0x00350035, |
Lokesh Vutla | 306b597 | 2016-03-08 09:11:35 +0530 | [diff] [blame] | 151 | 0x00340034, |
| 152 | 0x00310031, |
| 153 | 0x00340034, |
| 154 | 0x007F007F, |
| 155 | 0x007F007F, |
| 156 | 0x007F007F, |
| 157 | 0x007F007F, |
| 158 | 0x007F007F, |
| 159 | 0x00480048, |
| 160 | 0x004A004A, |
| 161 | 0x00520052, |
| 162 | 0x00550055, |
| 163 | 0x00500050, |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 164 | 0x00000000, |
| 165 | 0x00600020, |
Lokesh Vutla | 979d2c3 | 2015-06-03 14:43:21 +0530 | [diff] [blame] | 166 | 0x40011080, |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 167 | 0x08102040, |
Lokesh Vutla | 306b597 | 2016-03-08 09:11:35 +0530 | [diff] [blame] | 168 | 0x0, |
| 169 | 0x0, |
| 170 | 0x0, |
| 171 | 0x0, |
Lokesh Vutla | 51a0f1f | 2015-06-03 14:43:22 +0530 | [diff] [blame] | 172 | 0x0, |
| 173 | 0x0, |
| 174 | 0x0, |
| 175 | 0x0, |
Lokesh Vutla | 306b597 | 2016-03-08 09:11:35 +0530 | [diff] [blame] | 176 | 0x0, |
Lokesh Vutla | 51a0f1f | 2015-06-03 14:43:22 +0530 | [diff] [blame] | 177 | 0x0 |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 178 | }; |
| 179 | |
| 180 | static const struct emif_regs beagle_x15_emif2_ddr3_532mhz_emif_regs = { |
Keerthy | 66dd806 | 2016-05-24 11:45:07 +0530 | [diff] [blame] | 181 | .sdram_config_init = 0x61851b32, |
| 182 | .sdram_config = 0x61851b32, |
| 183 | .sdram_config2 = 0x08000000, |
| 184 | .ref_ctrl = 0x000040F1, |
| 185 | .ref_ctrl_final = 0x00001035, |
| 186 | .sdram_tim1 = 0xcccf36b3, |
| 187 | .sdram_tim2 = 0x308f7fda, |
| 188 | .sdram_tim3 = 0x407f88a8, |
| 189 | .read_idle_ctrl = 0x00050000, |
| 190 | .zq_config = 0x5007190b, |
| 191 | .temp_alert_config = 0x00000000, |
| 192 | .emif_ddr_phy_ctlr_1_init = 0x0024400b, |
| 193 | .emif_ddr_phy_ctlr_1 = 0x0e24400b, |
| 194 | .emif_ddr_ext_phy_ctrl_1 = 0x10040100, |
| 195 | .emif_ddr_ext_phy_ctrl_2 = 0x00910091, |
| 196 | .emif_ddr_ext_phy_ctrl_3 = 0x00950095, |
| 197 | .emif_ddr_ext_phy_ctrl_4 = 0x009b009b, |
| 198 | .emif_ddr_ext_phy_ctrl_5 = 0x009e009e, |
| 199 | .emif_rd_wr_lvl_rmp_win = 0x00000000, |
| 200 | .emif_rd_wr_lvl_rmp_ctl = 0x80000000, |
| 201 | .emif_rd_wr_lvl_ctl = 0x00000000, |
| 202 | .emif_rd_wr_exec_thresh = 0x00000305 |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 203 | }; |
| 204 | |
| 205 | static const u32 beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs[] = { |
Lokesh Vutla | 979d2c3 | 2015-06-03 14:43:21 +0530 | [diff] [blame] | 206 | 0x10040100, |
Lokesh Vutla | 306b597 | 2016-03-08 09:11:35 +0530 | [diff] [blame] | 207 | 0x00910091, |
| 208 | 0x00950095, |
| 209 | 0x009B009B, |
| 210 | 0x009E009E, |
| 211 | 0x00980098, |
| 212 | 0x00340034, |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 213 | 0x00350035, |
Lokesh Vutla | 306b597 | 2016-03-08 09:11:35 +0530 | [diff] [blame] | 214 | 0x00340034, |
| 215 | 0x00310031, |
| 216 | 0x00340034, |
| 217 | 0x007F007F, |
| 218 | 0x007F007F, |
| 219 | 0x007F007F, |
| 220 | 0x007F007F, |
| 221 | 0x007F007F, |
| 222 | 0x00480048, |
| 223 | 0x004A004A, |
| 224 | 0x00520052, |
| 225 | 0x00550055, |
| 226 | 0x00500050, |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 227 | 0x00000000, |
| 228 | 0x00600020, |
Lokesh Vutla | 979d2c3 | 2015-06-03 14:43:21 +0530 | [diff] [blame] | 229 | 0x40011080, |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 230 | 0x08102040, |
Lokesh Vutla | 306b597 | 2016-03-08 09:11:35 +0530 | [diff] [blame] | 231 | 0x0, |
| 232 | 0x0, |
| 233 | 0x0, |
| 234 | 0x0, |
| 235 | 0x0, |
Lokesh Vutla | 51a0f1f | 2015-06-03 14:43:22 +0530 | [diff] [blame] | 236 | 0x0, |
| 237 | 0x0, |
| 238 | 0x0, |
| 239 | 0x0, |
| 240 | 0x0 |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 241 | }; |
| 242 | |
Steve Kipisz | 81c4674 | 2017-08-22 13:52:58 +0530 | [diff] [blame] | 243 | static const struct emif_regs am571x_emif1_ddr3_666mhz_emif_regs = { |
| 244 | .sdram_config_init = 0x61863332, |
| 245 | .sdram_config = 0x61863332, |
| 246 | .sdram_config2 = 0x08000000, |
| 247 | .ref_ctrl = 0x0000514d, |
| 248 | .ref_ctrl_final = 0x0000144a, |
| 249 | .sdram_tim1 = 0xd333887c, |
Lokesh Vutla | cbd70db | 2017-12-29 11:47:54 +0530 | [diff] [blame] | 250 | .sdram_tim2 = 0x30b37fe3, |
| 251 | .sdram_tim3 = 0x409f8ad8, |
Steve Kipisz | 81c4674 | 2017-08-22 13:52:58 +0530 | [diff] [blame] | 252 | .read_idle_ctrl = 0x00050000, |
| 253 | .zq_config = 0x5007190b, |
| 254 | .temp_alert_config = 0x00000000, |
| 255 | .emif_ddr_phy_ctlr_1_init = 0x0024400f, |
| 256 | .emif_ddr_phy_ctlr_1 = 0x0e24400f, |
| 257 | .emif_ddr_ext_phy_ctrl_1 = 0x10040100, |
| 258 | .emif_ddr_ext_phy_ctrl_2 = 0x00910091, |
| 259 | .emif_ddr_ext_phy_ctrl_3 = 0x00950095, |
| 260 | .emif_ddr_ext_phy_ctrl_4 = 0x009b009b, |
| 261 | .emif_ddr_ext_phy_ctrl_5 = 0x009e009e, |
| 262 | .emif_rd_wr_lvl_rmp_win = 0x00000000, |
| 263 | .emif_rd_wr_lvl_rmp_ctl = 0x80000000, |
| 264 | .emif_rd_wr_lvl_ctl = 0x00000000, |
| 265 | .emif_rd_wr_exec_thresh = 0x00000305 |
| 266 | }; |
| 267 | |
Lokesh Vutla | cbd70db | 2017-12-29 11:47:54 +0530 | [diff] [blame] | 268 | static const struct emif_regs am574x_emif1_ddr3_666mhz_emif_ecc_regs = { |
| 269 | .sdram_config_init = 0x61863332, |
| 270 | .sdram_config = 0x61863332, |
| 271 | .sdram_config2 = 0x08000000, |
| 272 | .ref_ctrl = 0x0000514d, |
| 273 | .ref_ctrl_final = 0x0000144a, |
| 274 | .sdram_tim1 = 0xd333887c, |
| 275 | .sdram_tim2 = 0x30b37fe3, |
| 276 | .sdram_tim3 = 0x409f8ad8, |
| 277 | .read_idle_ctrl = 0x00050000, |
| 278 | .zq_config = 0x5007190b, |
| 279 | .temp_alert_config = 0x00000000, |
| 280 | .emif_ddr_phy_ctlr_1_init = 0x0024400f, |
| 281 | .emif_ddr_phy_ctlr_1 = 0x0e24400f, |
| 282 | .emif_ddr_ext_phy_ctrl_1 = 0x10040100, |
| 283 | .emif_ddr_ext_phy_ctrl_2 = 0x00910091, |
| 284 | .emif_ddr_ext_phy_ctrl_3 = 0x00950095, |
| 285 | .emif_ddr_ext_phy_ctrl_4 = 0x009b009b, |
| 286 | .emif_ddr_ext_phy_ctrl_5 = 0x009e009e, |
| 287 | .emif_rd_wr_lvl_rmp_win = 0x00000000, |
| 288 | .emif_rd_wr_lvl_rmp_ctl = 0x80000000, |
| 289 | .emif_rd_wr_lvl_ctl = 0x00000000, |
| 290 | .emif_rd_wr_exec_thresh = 0x00000305, |
| 291 | .emif_ecc_ctrl_reg = 0xD0000001, |
| 292 | .emif_ecc_address_range_1 = 0x3FFF0000, |
| 293 | .emif_ecc_address_range_2 = 0x00000000 |
| 294 | }; |
| 295 | |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 296 | void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs) |
| 297 | { |
| 298 | switch (emif_nr) { |
| 299 | case 1: |
Steve Kipisz | 81c4674 | 2017-08-22 13:52:58 +0530 | [diff] [blame] | 300 | if (board_is_am571x_idk()) |
| 301 | *regs = &am571x_emif1_ddr3_666mhz_emif_regs; |
Lokesh Vutla | cbd70db | 2017-12-29 11:47:54 +0530 | [diff] [blame] | 302 | else if (board_is_am574x_idk()) |
| 303 | *regs = &am574x_emif1_ddr3_666mhz_emif_ecc_regs; |
Steve Kipisz | 81c4674 | 2017-08-22 13:52:58 +0530 | [diff] [blame] | 304 | else |
| 305 | *regs = &beagle_x15_emif1_ddr3_532mhz_emif_regs; |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 306 | break; |
| 307 | case 2: |
Lokesh Vutla | cbd70db | 2017-12-29 11:47:54 +0530 | [diff] [blame] | 308 | if (board_is_am574x_idk()) |
| 309 | *regs = &am571x_emif1_ddr3_666mhz_emif_regs; |
| 310 | else |
| 311 | *regs = &beagle_x15_emif2_ddr3_532mhz_emif_regs; |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 312 | break; |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | void emif_get_ext_phy_ctrl_const_regs(u32 emif_nr, const u32 **regs, u32 *size) |
| 317 | { |
| 318 | switch (emif_nr) { |
| 319 | case 1: |
| 320 | *regs = beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs; |
| 321 | *size = ARRAY_SIZE(beagle_x15_emif1_ddr3_ext_phy_ctrl_const_regs); |
| 322 | break; |
| 323 | case 2: |
| 324 | *regs = beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs; |
| 325 | *size = ARRAY_SIZE(beagle_x15_emif2_ddr3_ext_phy_ctrl_const_regs); |
| 326 | break; |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | struct vcores_data beagle_x15_volts = { |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 331 | .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM, |
| 332 | .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM, |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 333 | .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 334 | .mpu.addr = TPS659038_REG_ADDR_SMPS12, |
| 335 | .mpu.pmic = &tps659038, |
Keerthy | 66dd806 | 2016-05-24 11:45:07 +0530 | [diff] [blame] | 336 | .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK, |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 337 | |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 338 | .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM, |
| 339 | .eve.value[OPP_OD] = VDD_EVE_DRA7_OD, |
| 340 | .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH, |
| 341 | .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM, |
| 342 | .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD, |
| 343 | .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH, |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 344 | .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 345 | .eve.addr = TPS659038_REG_ADDR_SMPS45, |
| 346 | .eve.pmic = &tps659038, |
Nishanth Menon | 59b92af | 2016-04-21 14:34:25 -0500 | [diff] [blame] | 347 | .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK, |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 348 | |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 349 | .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM, |
| 350 | .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD, |
| 351 | .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH, |
| 352 | .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM, |
| 353 | .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD, |
| 354 | .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH, |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 355 | .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 356 | .gpu.addr = TPS659038_REG_ADDR_SMPS45, |
| 357 | .gpu.pmic = &tps659038, |
Nishanth Menon | 59b92af | 2016-04-21 14:34:25 -0500 | [diff] [blame] | 358 | .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK, |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 359 | |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 360 | .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM, |
| 361 | .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM, |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 362 | .core.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 363 | .core.addr = TPS659038_REG_ADDR_SMPS6, |
| 364 | .core.pmic = &tps659038, |
| 365 | |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 366 | .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM, |
| 367 | .iva.value[OPP_OD] = VDD_IVA_DRA7_OD, |
| 368 | .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH, |
| 369 | .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM, |
| 370 | .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD, |
| 371 | .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH, |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 372 | .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 373 | .iva.addr = TPS659038_REG_ADDR_SMPS45, |
| 374 | .iva.pmic = &tps659038, |
Nishanth Menon | 59b92af | 2016-04-21 14:34:25 -0500 | [diff] [blame] | 375 | .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK, |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 376 | }; |
| 377 | |
Keerthy | 152e993 | 2016-05-24 11:45:06 +0530 | [diff] [blame] | 378 | struct vcores_data am572x_idk_volts = { |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 379 | .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM, |
| 380 | .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM, |
Keerthy | 152e993 | 2016-05-24 11:45:06 +0530 | [diff] [blame] | 381 | .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 382 | .mpu.addr = TPS659038_REG_ADDR_SMPS12, |
| 383 | .mpu.pmic = &tps659038, |
| 384 | .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK, |
| 385 | |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 386 | .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM, |
| 387 | .eve.value[OPP_OD] = VDD_EVE_DRA7_OD, |
| 388 | .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH, |
| 389 | .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM, |
| 390 | .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD, |
| 391 | .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH, |
Keerthy | 152e993 | 2016-05-24 11:45:06 +0530 | [diff] [blame] | 392 | .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 393 | .eve.addr = TPS659038_REG_ADDR_SMPS45, |
| 394 | .eve.pmic = &tps659038, |
| 395 | .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK, |
| 396 | |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 397 | .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM, |
| 398 | .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD, |
| 399 | .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH, |
| 400 | .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM, |
| 401 | .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD, |
| 402 | .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH, |
Keerthy | 152e993 | 2016-05-24 11:45:06 +0530 | [diff] [blame] | 403 | .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 404 | .gpu.addr = TPS659038_REG_ADDR_SMPS6, |
| 405 | .gpu.pmic = &tps659038, |
| 406 | .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK, |
| 407 | |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 408 | .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM, |
| 409 | .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM, |
Keerthy | 152e993 | 2016-05-24 11:45:06 +0530 | [diff] [blame] | 410 | .core.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 411 | .core.addr = TPS659038_REG_ADDR_SMPS7, |
| 412 | .core.pmic = &tps659038, |
| 413 | |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 414 | .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM, |
| 415 | .iva.value[OPP_OD] = VDD_IVA_DRA7_OD, |
| 416 | .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH, |
| 417 | .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM, |
| 418 | .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD, |
| 419 | .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH, |
Keerthy | 152e993 | 2016-05-24 11:45:06 +0530 | [diff] [blame] | 420 | .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 421 | .iva.addr = TPS659038_REG_ADDR_SMPS8, |
| 422 | .iva.pmic = &tps659038, |
| 423 | .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK, |
| 424 | }; |
| 425 | |
Keerthy | 9cc2aee | 2017-05-25 15:37:34 +0530 | [diff] [blame] | 426 | struct vcores_data am571x_idk_volts = { |
| 427 | .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM, |
| 428 | .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM, |
| 429 | .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 430 | .mpu.addr = TPS659038_REG_ADDR_SMPS12, |
| 431 | .mpu.pmic = &tps659038, |
| 432 | .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK, |
| 433 | |
| 434 | .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM, |
| 435 | .eve.value[OPP_OD] = VDD_EVE_DRA7_OD, |
| 436 | .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH, |
| 437 | .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM, |
| 438 | .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD, |
| 439 | .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH, |
| 440 | .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 441 | .eve.addr = TPS659038_REG_ADDR_SMPS45, |
| 442 | .eve.pmic = &tps659038, |
| 443 | .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK, |
| 444 | |
| 445 | .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM, |
| 446 | .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD, |
| 447 | .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH, |
| 448 | .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM, |
| 449 | .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD, |
| 450 | .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH, |
| 451 | .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 452 | .gpu.addr = TPS659038_REG_ADDR_SMPS6, |
| 453 | .gpu.pmic = &tps659038, |
| 454 | .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK, |
| 455 | |
| 456 | .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM, |
| 457 | .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM, |
| 458 | .core.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 459 | .core.addr = TPS659038_REG_ADDR_SMPS7, |
| 460 | .core.pmic = &tps659038, |
| 461 | |
| 462 | .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM, |
| 463 | .iva.value[OPP_OD] = VDD_IVA_DRA7_OD, |
| 464 | .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH, |
| 465 | .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM, |
| 466 | .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD, |
| 467 | .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH, |
| 468 | .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 469 | .iva.addr = TPS659038_REG_ADDR_SMPS45, |
| 470 | .iva.pmic = &tps659038, |
| 471 | .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK, |
| 472 | }; |
| 473 | |
Lokesh Vutla | 6ede0fd | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 474 | int get_voltrail_opp(int rail_offset) |
| 475 | { |
| 476 | int opp; |
| 477 | |
| 478 | switch (rail_offset) { |
| 479 | case VOLT_MPU: |
| 480 | opp = DRA7_MPU_OPP; |
| 481 | break; |
| 482 | case VOLT_CORE: |
| 483 | opp = DRA7_CORE_OPP; |
| 484 | break; |
| 485 | case VOLT_GPU: |
| 486 | opp = DRA7_GPU_OPP; |
| 487 | break; |
| 488 | case VOLT_EVE: |
| 489 | opp = DRA7_DSPEVE_OPP; |
| 490 | break; |
| 491 | case VOLT_IVA: |
| 492 | opp = DRA7_IVA_OPP; |
| 493 | break; |
| 494 | default: |
| 495 | opp = OPP_NOM; |
| 496 | } |
| 497 | |
| 498 | return opp; |
| 499 | } |
| 500 | |
| 501 | |
Kipisz, Steven | 161f138 | 2016-02-24 12:30:58 -0600 | [diff] [blame] | 502 | #ifdef CONFIG_SPL_BUILD |
| 503 | /* No env to setup for SPL */ |
| 504 | static inline void setup_board_eeprom_env(void) { } |
| 505 | |
| 506 | /* Override function to read eeprom information */ |
| 507 | void do_board_detect(void) |
| 508 | { |
| 509 | int rc; |
| 510 | |
| 511 | rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS, |
| 512 | CONFIG_EEPROM_CHIP_ADDRESS); |
| 513 | if (rc) |
| 514 | printf("ti_i2c_eeprom_init failed %d\n", rc); |
Caleb Robey | 0dfcc93 | 2020-01-02 08:17:25 -0600 | [diff] [blame^] | 515 | |
| 516 | #ifdef CONFIG_SUPPORT_EMMC_BOOT |
| 517 | rc = board_bootmode_has_emmc(); |
| 518 | if (!rc) |
| 519 | rc = ti_emmc_boardid_get(); |
| 520 | if (rc) |
| 521 | printf("ti_emmc_boardid_get failed %d\n", rc); |
| 522 | #endif |
Kipisz, Steven | 161f138 | 2016-02-24 12:30:58 -0600 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | #else /* CONFIG_SPL_BUILD */ |
| 526 | |
| 527 | /* Override function to read eeprom information: actual i2c read done by SPL*/ |
| 528 | void do_board_detect(void) |
| 529 | { |
| 530 | char *bname = NULL; |
| 531 | int rc; |
| 532 | |
| 533 | rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS, |
| 534 | CONFIG_EEPROM_CHIP_ADDRESS); |
| 535 | if (rc) |
| 536 | printf("ti_i2c_eeprom_init failed %d\n", rc); |
| 537 | |
Caleb Robey | 0dfcc93 | 2020-01-02 08:17:25 -0600 | [diff] [blame^] | 538 | #ifdef CONFIG_SUPPORT_EMMC_BOOT |
| 539 | rc = board_bootmode_has_emmc(); |
| 540 | if (!rc) |
| 541 | rc = ti_emmc_boardid_get(); |
| 542 | if (rc) |
| 543 | printf("ti_emmc_boardid_get failed %d\n", rc); |
| 544 | #endif |
| 545 | |
Kipisz, Steven | 161f138 | 2016-02-24 12:30:58 -0600 | [diff] [blame] | 546 | if (board_is_x15()) |
| 547 | bname = "BeagleBoard X15"; |
| 548 | else if (board_is_am572x_evm()) |
| 549 | bname = "AM572x EVM"; |
Lokesh Vutla | 374aea0 | 2017-12-29 11:47:52 +0530 | [diff] [blame] | 550 | else if (board_is_am574x_idk()) |
| 551 | bname = "AM574x IDK"; |
Steve Kipisz | 0ac8cea | 2016-04-08 17:01:29 -0500 | [diff] [blame] | 552 | else if (board_is_am572x_idk()) |
| 553 | bname = "AM572x IDK"; |
Steve Kipisz | c95cddd | 2016-11-25 11:14:24 +0530 | [diff] [blame] | 554 | else if (board_is_am571x_idk()) |
| 555 | bname = "AM571x IDK"; |
Kipisz, Steven | 161f138 | 2016-02-24 12:30:58 -0600 | [diff] [blame] | 556 | |
| 557 | if (bname) |
| 558 | snprintf(sysinfo.board_string, SYSINFO_BOARD_NAME_MAX_LEN, |
| 559 | "Board: %s REV %s\n", bname, board_ti_get_rev()); |
| 560 | } |
| 561 | |
| 562 | static void setup_board_eeprom_env(void) |
| 563 | { |
| 564 | char *name = "beagle_x15"; |
| 565 | int rc; |
| 566 | |
| 567 | rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS, |
| 568 | CONFIG_EEPROM_CHIP_ADDRESS); |
| 569 | if (rc) |
| 570 | goto invalid_eeprom; |
| 571 | |
Nishanth Menon | a2aea1c | 2016-11-25 11:14:19 +0530 | [diff] [blame] | 572 | if (board_is_x15()) { |
Lokesh Vutla | 638e1c0 | 2016-11-25 11:14:20 +0530 | [diff] [blame] | 573 | if (board_is_x15_revb1()) |
| 574 | name = "beagle_x15_revb1"; |
Lokesh Vutla | 816178b | 2017-07-16 19:59:19 +0530 | [diff] [blame] | 575 | else if (board_is_x15_revc()) |
| 576 | name = "beagle_x15_revc"; |
Lokesh Vutla | 638e1c0 | 2016-11-25 11:14:20 +0530 | [diff] [blame] | 577 | else |
| 578 | name = "beagle_x15"; |
Nishanth Menon | a2aea1c | 2016-11-25 11:14:19 +0530 | [diff] [blame] | 579 | } else if (board_is_am572x_evm()) { |
| 580 | if (board_is_am572x_evm_reva3()) |
| 581 | name = "am57xx_evm_reva3"; |
| 582 | else |
| 583 | name = "am57xx_evm"; |
Lokesh Vutla | 374aea0 | 2017-12-29 11:47:52 +0530 | [diff] [blame] | 584 | } else if (board_is_am574x_idk()) { |
| 585 | name = "am574x_idk"; |
Nishanth Menon | a2aea1c | 2016-11-25 11:14:19 +0530 | [diff] [blame] | 586 | } else if (board_is_am572x_idk()) { |
Steve Kipisz | 0ac8cea | 2016-04-08 17:01:29 -0500 | [diff] [blame] | 587 | name = "am572x_idk"; |
Steve Kipisz | c95cddd | 2016-11-25 11:14:24 +0530 | [diff] [blame] | 588 | } else if (board_is_am571x_idk()) { |
| 589 | name = "am571x_idk"; |
Nishanth Menon | a2aea1c | 2016-11-25 11:14:19 +0530 | [diff] [blame] | 590 | } else { |
Kipisz, Steven | 161f138 | 2016-02-24 12:30:58 -0600 | [diff] [blame] | 591 | printf("Unidentified board claims %s in eeprom header\n", |
| 592 | board_ti_get_name()); |
Nishanth Menon | a2aea1c | 2016-11-25 11:14:19 +0530 | [diff] [blame] | 593 | } |
Kipisz, Steven | 161f138 | 2016-02-24 12:30:58 -0600 | [diff] [blame] | 594 | |
| 595 | invalid_eeprom: |
| 596 | set_board_info_env(name); |
| 597 | } |
| 598 | |
| 599 | #endif /* CONFIG_SPL_BUILD */ |
| 600 | |
Keerthy | 152e993 | 2016-05-24 11:45:06 +0530 | [diff] [blame] | 601 | void vcores_init(void) |
| 602 | { |
Lokesh Vutla | 6e9635c | 2017-12-29 11:47:53 +0530 | [diff] [blame] | 603 | if (board_is_am572x_idk() || board_is_am574x_idk()) |
Keerthy | 152e993 | 2016-05-24 11:45:06 +0530 | [diff] [blame] | 604 | *omap_vcores = &am572x_idk_volts; |
Keerthy | 9cc2aee | 2017-05-25 15:37:34 +0530 | [diff] [blame] | 605 | else if (board_is_am571x_idk()) |
| 606 | *omap_vcores = &am571x_idk_volts; |
Keerthy | 152e993 | 2016-05-24 11:45:06 +0530 | [diff] [blame] | 607 | else |
| 608 | *omap_vcores = &beagle_x15_volts; |
| 609 | } |
| 610 | |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 611 | void hw_data_init(void) |
| 612 | { |
| 613 | *prcm = &dra7xx_prcm; |
Steve Kipisz | 81c4674 | 2017-08-22 13:52:58 +0530 | [diff] [blame] | 614 | if (is_dra72x()) |
| 615 | *dplls_data = &dra72x_dplls; |
Lokesh Vutla | 6e9635c | 2017-12-29 11:47:53 +0530 | [diff] [blame] | 616 | else if (is_dra76x()) |
| 617 | *dplls_data = &dra76x_dplls; |
Steve Kipisz | 81c4674 | 2017-08-22 13:52:58 +0530 | [diff] [blame] | 618 | else |
| 619 | *dplls_data = &dra7xx_dplls; |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 620 | *ctrl = &dra7xx_ctrl; |
| 621 | } |
| 622 | |
Roger Quadros | 2613059 | 2017-03-13 15:04:28 +0200 | [diff] [blame] | 623 | bool am571x_idk_needs_lcd(void) |
| 624 | { |
| 625 | bool needs_lcd; |
| 626 | |
| 627 | gpio_request(GPIO_ETH_LCD, "nLCD_Detect"); |
| 628 | if (gpio_get_value(GPIO_ETH_LCD)) |
| 629 | needs_lcd = false; |
| 630 | else |
| 631 | needs_lcd = true; |
| 632 | |
| 633 | gpio_free(GPIO_ETH_LCD); |
| 634 | |
| 635 | return needs_lcd; |
| 636 | } |
| 637 | |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 638 | int board_init(void) |
| 639 | { |
| 640 | gpmc_init(); |
| 641 | gd->bd->bi_boot_params = (CONFIG_SYS_SDRAM_BASE + 0x100); |
| 642 | |
| 643 | return 0; |
| 644 | } |
| 645 | |
Nishanth Menon | d0f399c | 2017-03-13 15:04:30 +0200 | [diff] [blame] | 646 | void am57x_idk_lcd_detect(void) |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 647 | { |
Nishanth Menon | d0f399c | 2017-03-13 15:04:30 +0200 | [diff] [blame] | 648 | int r = -ENODEV; |
| 649 | char *idk_lcd = "no"; |
Jean-Jacques Hiblot | 184ec9a | 2018-12-07 14:50:50 +0100 | [diff] [blame] | 650 | struct udevice *dev; |
Nishanth Menon | d0f399c | 2017-03-13 15:04:30 +0200 | [diff] [blame] | 651 | |
| 652 | /* Only valid for IDKs */ |
| 653 | if (board_is_x15() || board_is_am572x_evm()) |
| 654 | return; |
| 655 | |
| 656 | /* Only AM571x IDK has gpio control detect.. so check that */ |
| 657 | if (board_is_am571x_idk() && !am571x_idk_needs_lcd()) |
| 658 | goto out; |
| 659 | |
Jean-Jacques Hiblot | 52a5151 | 2018-12-07 14:50:49 +0100 | [diff] [blame] | 660 | r = i2c_get_chip_for_busnum(OSD_TS_FT_BUS_ADDRESS, |
| 661 | OSD_TS_FT_CHIP_ADDRESS, 1, &dev); |
Nishanth Menon | d0f399c | 2017-03-13 15:04:30 +0200 | [diff] [blame] | 662 | if (r) { |
Jean-Jacques Hiblot | 52a5151 | 2018-12-07 14:50:49 +0100 | [diff] [blame] | 663 | printf("%s: Failed to get I2C device %d/%d (ret %d)\n", |
| 664 | __func__, OSD_TS_FT_BUS_ADDRESS, OSD_TS_FT_CHIP_ADDRESS, |
| 665 | r); |
Nishanth Menon | d0f399c | 2017-03-13 15:04:30 +0200 | [diff] [blame] | 666 | /* AM572x IDK has no explicit settings for optional LCD kit */ |
Jean-Jacques Hiblot | 52a5151 | 2018-12-07 14:50:49 +0100 | [diff] [blame] | 667 | if (board_is_am571x_idk()) |
Nishanth Menon | d0f399c | 2017-03-13 15:04:30 +0200 | [diff] [blame] | 668 | printf("%s: Touch screen detect failed: %d!\n", |
| 669 | __func__, r); |
Nishanth Menon | d0f399c | 2017-03-13 15:04:30 +0200 | [diff] [blame] | 670 | goto out; |
| 671 | } |
| 672 | |
| 673 | /* Read FT ID */ |
Jean-Jacques Hiblot | 52a5151 | 2018-12-07 14:50:49 +0100 | [diff] [blame] | 674 | r = dm_i2c_reg_read(dev, OSD_TS_FT_REG_ID); |
| 675 | if (r < 0) { |
Nishanth Menon | d0f399c | 2017-03-13 15:04:30 +0200 | [diff] [blame] | 676 | printf("%s: Touch screen ID read %d:0x%02x[0x%02x] failed:%d\n", |
| 677 | __func__, OSD_TS_FT_BUS_ADDRESS, OSD_TS_FT_CHIP_ADDRESS, |
| 678 | OSD_TS_FT_REG_ID, r); |
| 679 | goto out; |
| 680 | } |
| 681 | |
Jean-Jacques Hiblot | 184ec9a | 2018-12-07 14:50:50 +0100 | [diff] [blame] | 682 | switch (r) { |
Nishanth Menon | d0f399c | 2017-03-13 15:04:30 +0200 | [diff] [blame] | 683 | case OSD_TS_FT_ID_5606: |
| 684 | idk_lcd = "osd101t2045"; |
| 685 | break; |
| 686 | case OSD_TS_FT_ID_5x46: |
| 687 | idk_lcd = "osd101t2587"; |
| 688 | break; |
| 689 | default: |
| 690 | printf("%s: Unidentifed Touch screen ID 0x%02x\n", |
Jean-Jacques Hiblot | 184ec9a | 2018-12-07 14:50:50 +0100 | [diff] [blame] | 691 | __func__, r); |
Nishanth Menon | d0f399c | 2017-03-13 15:04:30 +0200 | [diff] [blame] | 692 | /* we will let default be "no lcd" */ |
| 693 | } |
| 694 | out: |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 695 | env_set("idk_lcd", idk_lcd); |
Nishanth Menon | d0f399c | 2017-03-13 15:04:30 +0200 | [diff] [blame] | 696 | return; |
| 697 | } |
Roger Quadros | 2613059 | 2017-03-13 15:04:28 +0200 | [diff] [blame] | 698 | |
Vignesh R | 98c5f63 | 2018-11-29 10:57:42 +0100 | [diff] [blame] | 699 | #if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL) |
| 700 | static int device_okay(const char *path) |
| 701 | { |
| 702 | int node; |
| 703 | |
| 704 | node = fdt_path_offset(gd->fdt_blob, path); |
| 705 | if (node < 0) |
| 706 | return 0; |
| 707 | |
| 708 | return fdtdec_get_is_enabled(gd->fdt_blob, node); |
| 709 | } |
| 710 | #endif |
| 711 | |
Nishanth Menon | d0f399c | 2017-03-13 15:04:30 +0200 | [diff] [blame] | 712 | int board_late_init(void) |
| 713 | { |
Kipisz, Steven | 161f138 | 2016-02-24 12:30:58 -0600 | [diff] [blame] | 714 | setup_board_eeprom_env(); |
Keerthy | ee85ebe | 2016-11-30 15:02:53 +0530 | [diff] [blame] | 715 | u8 val; |
Tero Kristo | dfbc6b8 | 2019-09-27 19:14:27 +0300 | [diff] [blame] | 716 | struct udevice *dev; |
Kipisz, Steven | 161f138 | 2016-02-24 12:30:58 -0600 | [diff] [blame] | 717 | |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 718 | /* |
| 719 | * DEV_CTRL.DEV_ON = 1 please - else palmas switches off in 8 seconds |
| 720 | * This is the POWERHOLD-in-Low behavior. |
| 721 | */ |
| 722 | palmas_i2c_write_u8(TPS65903X_CHIP_P1, 0xA0, 0x1); |
Lokesh Vutla | 2c47e8c | 2016-11-29 11:58:02 +0530 | [diff] [blame] | 723 | |
| 724 | /* |
| 725 | * Default FIT boot on HS devices. Non FIT images are not allowed |
| 726 | * on HS devices. |
| 727 | */ |
| 728 | if (get_device_type() == HS_DEVICE) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 729 | env_set("boot_fit", "1"); |
Lokesh Vutla | 2c47e8c | 2016-11-29 11:58:02 +0530 | [diff] [blame] | 730 | |
Keerthy | ee85ebe | 2016-11-30 15:02:53 +0530 | [diff] [blame] | 731 | /* |
| 732 | * Set the GPIO7 Pad to POWERHOLD. This has higher priority |
| 733 | * over DEV_CTRL.DEV_ON bit. This can be reset in case of |
| 734 | * PMIC Power off. So to be on the safer side set it back |
| 735 | * to POWERHOLD mode irrespective of the current state. |
| 736 | */ |
| 737 | palmas_i2c_read_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2, |
| 738 | &val); |
| 739 | val = val | TPS65903X_PAD2_POWERHOLD_MASK; |
| 740 | palmas_i2c_write_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2, |
| 741 | val); |
| 742 | |
Semen Protsenko | 4b0721f | 2017-02-13 19:09:37 +0200 | [diff] [blame] | 743 | omap_die_id_serial(); |
Semen Protsenko | b72dccd | 2017-05-22 19:16:41 +0300 | [diff] [blame] | 744 | omap_set_fastboot_vars(); |
Semen Protsenko | 4b0721f | 2017-02-13 19:09:37 +0200 | [diff] [blame] | 745 | |
Nishanth Menon | d0f399c | 2017-03-13 15:04:30 +0200 | [diff] [blame] | 746 | am57x_idk_lcd_detect(); |
Roger Quadros | 2613059 | 2017-03-13 15:04:28 +0200 | [diff] [blame] | 747 | |
Tero Kristo | dfbc6b8 | 2019-09-27 19:14:27 +0300 | [diff] [blame] | 748 | /* Just probe the potentially supported cdce913 device */ |
| 749 | uclass_get_device(UCLASS_CLK, 0, &dev); |
| 750 | |
Roger Quadros | 2613059 | 2017-03-13 15:04:28 +0200 | [diff] [blame] | 751 | #if !defined(CONFIG_SPL_BUILD) |
| 752 | board_ti_set_ethaddr(2); |
| 753 | #endif |
| 754 | |
Vignesh R | 98c5f63 | 2018-11-29 10:57:42 +0100 | [diff] [blame] | 755 | #if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL) |
| 756 | if (device_okay("/ocp/omap_dwc3_1@48880000")) |
| 757 | enable_usb_clocks(0); |
| 758 | if (device_okay("/ocp/omap_dwc3_2@488c0000")) |
| 759 | enable_usb_clocks(1); |
| 760 | #endif |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 761 | return 0; |
| 762 | } |
| 763 | |
Paul Kocialkowski | a00b1e5 | 2016-02-27 19:18:56 +0100 | [diff] [blame] | 764 | void set_muxconf_regs(void) |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 765 | { |
| 766 | do_set_mux32((*ctrl)->control_padconf_core_base, |
Lokesh Vutla | c3d39f9 | 2015-06-04 16:42:41 +0530 | [diff] [blame] | 767 | early_padconf, ARRAY_SIZE(early_padconf)); |
Caleb Robey | 0dfcc93 | 2020-01-02 08:17:25 -0600 | [diff] [blame^] | 768 | |
| 769 | #ifdef CONFIG_SUPPORT_EMMC_BOOT |
| 770 | do_set_mux32((*ctrl)->control_padconf_core_base, |
| 771 | emmc_padconf, ARRAY_SIZE(emmc_padconf)); |
| 772 | #endif |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 773 | } |
| 774 | |
Lokesh Vutla | c3d39f9 | 2015-06-04 16:42:41 +0530 | [diff] [blame] | 775 | #ifdef CONFIG_IODELAY_RECALIBRATION |
| 776 | void recalibrate_iodelay(void) |
| 777 | { |
Steve Kipisz | 0ac8cea | 2016-04-08 17:01:29 -0500 | [diff] [blame] | 778 | const struct pad_conf_entry *pconf; |
Lokesh Vutla | 3cb4c62 | 2017-06-05 14:48:16 +0530 | [diff] [blame] | 779 | const struct iodelay_cfg_entry *iod, *delta_iod; |
| 780 | int pconf_sz, iod_sz, delta_iod_sz = 0; |
Nishanth Menon | 8e3212e | 2016-11-25 11:14:22 +0530 | [diff] [blame] | 781 | int ret; |
Steve Kipisz | 0ac8cea | 2016-04-08 17:01:29 -0500 | [diff] [blame] | 782 | |
Lokesh Vutla | 1e3425c | 2017-12-29 11:47:55 +0530 | [diff] [blame] | 783 | if (board_is_am572x_idk()) { |
Steve Kipisz | 0ac8cea | 2016-04-08 17:01:29 -0500 | [diff] [blame] | 784 | pconf = core_padconf_array_essential_am572x_idk; |
| 785 | pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am572x_idk); |
| 786 | iod = iodelay_cfg_array_am572x_idk; |
| 787 | iod_sz = ARRAY_SIZE(iodelay_cfg_array_am572x_idk); |
Lokesh Vutla | 1e3425c | 2017-12-29 11:47:55 +0530 | [diff] [blame] | 788 | } else if (board_is_am574x_idk()) { |
| 789 | pconf = core_padconf_array_essential_am574x_idk; |
| 790 | pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am574x_idk); |
| 791 | iod = iodelay_cfg_array_am574x_idk; |
| 792 | iod_sz = ARRAY_SIZE(iodelay_cfg_array_am574x_idk); |
Steve Kipisz | c95cddd | 2016-11-25 11:14:24 +0530 | [diff] [blame] | 793 | } else if (board_is_am571x_idk()) { |
| 794 | pconf = core_padconf_array_essential_am571x_idk; |
| 795 | pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am571x_idk); |
| 796 | iod = iodelay_cfg_array_am571x_idk; |
| 797 | iod_sz = ARRAY_SIZE(iodelay_cfg_array_am571x_idk); |
Steve Kipisz | 0ac8cea | 2016-04-08 17:01:29 -0500 | [diff] [blame] | 798 | } else { |
| 799 | /* Common for X15/GPEVM */ |
| 800 | pconf = core_padconf_array_essential_x15; |
| 801 | pconf_sz = ARRAY_SIZE(core_padconf_array_essential_x15); |
Nishanth Menon | 8e3212e | 2016-11-25 11:14:22 +0530 | [diff] [blame] | 802 | /* There never was an SR1.0 X15.. So.. */ |
| 803 | if (omap_revision() == DRA752_ES1_1) { |
| 804 | iod = iodelay_cfg_array_x15_sr1_1; |
| 805 | iod_sz = ARRAY_SIZE(iodelay_cfg_array_x15_sr1_1); |
| 806 | } else { |
| 807 | /* Since full production should switch to SR2.0 */ |
| 808 | iod = iodelay_cfg_array_x15_sr2_0; |
| 809 | iod_sz = ARRAY_SIZE(iodelay_cfg_array_x15_sr2_0); |
| 810 | } |
Steve Kipisz | 0ac8cea | 2016-04-08 17:01:29 -0500 | [diff] [blame] | 811 | } |
| 812 | |
Nishanth Menon | 8e3212e | 2016-11-25 11:14:22 +0530 | [diff] [blame] | 813 | /* Setup I/O isolation */ |
| 814 | ret = __recalibrate_iodelay_start(); |
| 815 | if (ret) |
| 816 | goto err; |
| 817 | |
| 818 | /* Do the muxing here */ |
| 819 | do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz); |
| 820 | |
| 821 | /* Now do the weird minor deltas that should be safe */ |
| 822 | if (board_is_x15() || board_is_am572x_evm()) { |
Lokesh Vutla | 816178b | 2017-07-16 19:59:19 +0530 | [diff] [blame] | 823 | if (board_is_x15_revb1() || board_is_am572x_evm_reva3() || |
| 824 | board_is_x15_revc()) { |
Nishanth Menon | 8e3212e | 2016-11-25 11:14:22 +0530 | [diff] [blame] | 825 | pconf = core_padconf_array_delta_x15_sr2_0; |
| 826 | pconf_sz = ARRAY_SIZE(core_padconf_array_delta_x15_sr2_0); |
| 827 | } else { |
| 828 | pconf = core_padconf_array_delta_x15_sr1_1; |
| 829 | pconf_sz = ARRAY_SIZE(core_padconf_array_delta_x15_sr1_1); |
| 830 | } |
| 831 | do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz); |
| 832 | } |
| 833 | |
Roger Quadros | 2613059 | 2017-03-13 15:04:28 +0200 | [diff] [blame] | 834 | if (board_is_am571x_idk()) { |
| 835 | if (am571x_idk_needs_lcd()) { |
| 836 | pconf = core_padconf_array_vout_am571x_idk; |
| 837 | pconf_sz = ARRAY_SIZE(core_padconf_array_vout_am571x_idk); |
Lokesh Vutla | 3cb4c62 | 2017-06-05 14:48:16 +0530 | [diff] [blame] | 838 | delta_iod = iodelay_cfg_array_am571x_idk_4port; |
| 839 | delta_iod_sz = ARRAY_SIZE(iodelay_cfg_array_am571x_idk_4port); |
| 840 | |
Roger Quadros | 2613059 | 2017-03-13 15:04:28 +0200 | [diff] [blame] | 841 | } else { |
| 842 | pconf = core_padconf_array_icss1eth_am571x_idk; |
| 843 | pconf_sz = ARRAY_SIZE(core_padconf_array_icss1eth_am571x_idk); |
| 844 | } |
| 845 | do_set_mux32((*ctrl)->control_padconf_core_base, pconf, pconf_sz); |
| 846 | } |
| 847 | |
Nishanth Menon | 8e3212e | 2016-11-25 11:14:22 +0530 | [diff] [blame] | 848 | /* Setup IOdelay configuration */ |
| 849 | ret = do_set_iodelay((*ctrl)->iodelay_config_base, iod, iod_sz); |
Lokesh Vutla | 3cb4c62 | 2017-06-05 14:48:16 +0530 | [diff] [blame] | 850 | if (delta_iod_sz) |
| 851 | ret = do_set_iodelay((*ctrl)->iodelay_config_base, delta_iod, |
| 852 | delta_iod_sz); |
| 853 | |
Nishanth Menon | 8e3212e | 2016-11-25 11:14:22 +0530 | [diff] [blame] | 854 | err: |
| 855 | /* Closeup.. remove isolation */ |
| 856 | __recalibrate_iodelay_end(ret); |
Lokesh Vutla | c3d39f9 | 2015-06-04 16:42:41 +0530 | [diff] [blame] | 857 | } |
| 858 | #endif |
| 859 | |
Masahiro Yamada | 0a78017 | 2017-05-09 20:31:39 +0900 | [diff] [blame] | 860 | #if defined(CONFIG_MMC) |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 861 | int board_mmc_init(bd_t *bis) |
| 862 | { |
| 863 | omap_mmc_init(0, 0, 0, -1, -1); |
| 864 | omap_mmc_init(1, 0, 0, -1, -1); |
| 865 | return 0; |
| 866 | } |
Kishon Vijay Abraham I | 110ed01 | 2018-01-30 16:01:52 +0100 | [diff] [blame] | 867 | |
| 868 | static const struct mmc_platform_fixups am57x_es1_1_mmc1_fixups = { |
| 869 | .hw_rev = "rev11", |
| 870 | .unsupported_caps = MMC_CAP(MMC_HS_200) | |
| 871 | MMC_CAP(UHS_SDR104), |
| 872 | .max_freq = 96000000, |
| 873 | }; |
| 874 | |
| 875 | static const struct mmc_platform_fixups am57x_es1_1_mmc23_fixups = { |
| 876 | .hw_rev = "rev11", |
| 877 | .unsupported_caps = MMC_CAP(MMC_HS_200) | |
| 878 | MMC_CAP(UHS_SDR104) | |
| 879 | MMC_CAP(UHS_SDR50), |
| 880 | .max_freq = 48000000, |
| 881 | }; |
| 882 | |
| 883 | const struct mmc_platform_fixups *platform_fixups_mmc(uint32_t addr) |
| 884 | { |
| 885 | switch (omap_revision()) { |
| 886 | case DRA752_ES1_0: |
| 887 | case DRA752_ES1_1: |
| 888 | if (addr == OMAP_HSMMC1_BASE) |
| 889 | return &am57x_es1_1_mmc1_fixups; |
| 890 | else |
| 891 | return &am57x_es1_1_mmc23_fixups; |
| 892 | default: |
| 893 | return NULL; |
| 894 | } |
| 895 | } |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 896 | #endif |
| 897 | |
| 898 | #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OS_BOOT) |
| 899 | int spl_start_uboot(void) |
| 900 | { |
| 901 | /* break into full u-boot on 'c' */ |
| 902 | if (serial_tstc() && serial_getc() == 'c') |
| 903 | return 1; |
| 904 | |
| 905 | #ifdef CONFIG_SPL_ENV_SUPPORT |
| 906 | env_init(); |
Simon Glass | 1753957 | 2017-08-03 12:22:07 -0600 | [diff] [blame] | 907 | env_load(); |
Simon Glass | 22c34c2 | 2017-08-03 12:22:13 -0600 | [diff] [blame] | 908 | if (env_get_yesno("boot_os") != 1) |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 909 | return 1; |
| 910 | #endif |
| 911 | |
| 912 | return 0; |
| 913 | } |
| 914 | #endif |
| 915 | |
| 916 | #ifdef CONFIG_DRIVER_TI_CPSW |
| 917 | |
| 918 | /* Delay value to add to calibrated value */ |
| 919 | #define RGMII0_TXCTL_DLY_VAL ((0x3 << 5) + 0x8) |
| 920 | #define RGMII0_TXD0_DLY_VAL ((0x3 << 5) + 0x8) |
| 921 | #define RGMII0_TXD1_DLY_VAL ((0x3 << 5) + 0x2) |
| 922 | #define RGMII0_TXD2_DLY_VAL ((0x4 << 5) + 0x0) |
| 923 | #define RGMII0_TXD3_DLY_VAL ((0x4 << 5) + 0x0) |
| 924 | #define VIN2A_D13_DLY_VAL ((0x3 << 5) + 0x8) |
| 925 | #define VIN2A_D17_DLY_VAL ((0x3 << 5) + 0x8) |
| 926 | #define VIN2A_D16_DLY_VAL ((0x3 << 5) + 0x2) |
| 927 | #define VIN2A_D15_DLY_VAL ((0x4 << 5) + 0x0) |
| 928 | #define VIN2A_D14_DLY_VAL ((0x4 << 5) + 0x0) |
| 929 | |
| 930 | static void cpsw_control(int enabled) |
| 931 | { |
| 932 | /* VTP can be added here */ |
| 933 | } |
| 934 | |
| 935 | static struct cpsw_slave_data cpsw_slaves[] = { |
| 936 | { |
| 937 | .slave_reg_ofs = 0x208, |
| 938 | .sliver_reg_ofs = 0xd80, |
| 939 | .phy_addr = 1, |
| 940 | }, |
| 941 | { |
| 942 | .slave_reg_ofs = 0x308, |
| 943 | .sliver_reg_ofs = 0xdc0, |
| 944 | .phy_addr = 2, |
| 945 | }, |
| 946 | }; |
| 947 | |
| 948 | static struct cpsw_platform_data cpsw_data = { |
| 949 | .mdio_base = CPSW_MDIO_BASE, |
| 950 | .cpsw_base = CPSW_BASE, |
| 951 | .mdio_div = 0xff, |
| 952 | .channels = 8, |
| 953 | .cpdma_reg_ofs = 0x800, |
| 954 | .slaves = 1, |
| 955 | .slave_data = cpsw_slaves, |
| 956 | .ale_reg_ofs = 0xd00, |
| 957 | .ale_entries = 1024, |
| 958 | .host_port_reg_ofs = 0x108, |
| 959 | .hw_stats_reg_ofs = 0x900, |
| 960 | .bd_ram_ofs = 0x2000, |
| 961 | .mac_control = (1 << 5), |
| 962 | .control = cpsw_control, |
| 963 | .host_port_num = 0, |
| 964 | .version = CPSW_CTRL_VERSION_2, |
| 965 | }; |
| 966 | |
Roger Quadros | 64217a2 | 2016-03-18 13:18:12 +0200 | [diff] [blame] | 967 | static u64 mac_to_u64(u8 mac[6]) |
| 968 | { |
| 969 | int i; |
| 970 | u64 addr = 0; |
| 971 | |
| 972 | for (i = 0; i < 6; i++) { |
| 973 | addr <<= 8; |
| 974 | addr |= mac[i]; |
| 975 | } |
| 976 | |
| 977 | return addr; |
| 978 | } |
| 979 | |
| 980 | static void u64_to_mac(u64 addr, u8 mac[6]) |
| 981 | { |
| 982 | mac[5] = addr; |
| 983 | mac[4] = addr >> 8; |
| 984 | mac[3] = addr >> 16; |
| 985 | mac[2] = addr >> 24; |
| 986 | mac[1] = addr >> 32; |
| 987 | mac[0] = addr >> 40; |
| 988 | } |
| 989 | |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 990 | int board_eth_init(bd_t *bis) |
| 991 | { |
| 992 | int ret; |
| 993 | uint8_t mac_addr[6]; |
| 994 | uint32_t mac_hi, mac_lo; |
| 995 | uint32_t ctrl_val; |
Roger Quadros | 64217a2 | 2016-03-18 13:18:12 +0200 | [diff] [blame] | 996 | int i; |
| 997 | u64 mac1, mac2; |
| 998 | u8 mac_addr1[6], mac_addr2[6]; |
| 999 | int num_macs; |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 1000 | |
| 1001 | /* try reading mac address from efuse */ |
| 1002 | mac_lo = readl((*ctrl)->control_core_mac_id_0_lo); |
| 1003 | mac_hi = readl((*ctrl)->control_core_mac_id_0_hi); |
| 1004 | mac_addr[0] = (mac_hi & 0xFF0000) >> 16; |
| 1005 | mac_addr[1] = (mac_hi & 0xFF00) >> 8; |
| 1006 | mac_addr[2] = mac_hi & 0xFF; |
| 1007 | mac_addr[3] = (mac_lo & 0xFF0000) >> 16; |
| 1008 | mac_addr[4] = (mac_lo & 0xFF00) >> 8; |
| 1009 | mac_addr[5] = mac_lo & 0xFF; |
| 1010 | |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 1011 | if (!env_get("ethaddr")) { |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 1012 | printf("<ethaddr> not set. Validating first E-fuse MAC\n"); |
| 1013 | |
Joe Hershberger | 8ecdbed | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 1014 | if (is_valid_ethaddr(mac_addr)) |
Simon Glass | 8551d55 | 2017-08-03 12:22:11 -0600 | [diff] [blame] | 1015 | eth_env_set_enetaddr("ethaddr", mac_addr); |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 1016 | } |
| 1017 | |
| 1018 | mac_lo = readl((*ctrl)->control_core_mac_id_1_lo); |
| 1019 | mac_hi = readl((*ctrl)->control_core_mac_id_1_hi); |
| 1020 | mac_addr[0] = (mac_hi & 0xFF0000) >> 16; |
| 1021 | mac_addr[1] = (mac_hi & 0xFF00) >> 8; |
| 1022 | mac_addr[2] = mac_hi & 0xFF; |
| 1023 | mac_addr[3] = (mac_lo & 0xFF0000) >> 16; |
| 1024 | mac_addr[4] = (mac_lo & 0xFF00) >> 8; |
| 1025 | mac_addr[5] = mac_lo & 0xFF; |
| 1026 | |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 1027 | if (!env_get("eth1addr")) { |
Joe Hershberger | 8ecdbed | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 1028 | if (is_valid_ethaddr(mac_addr)) |
Simon Glass | 8551d55 | 2017-08-03 12:22:11 -0600 | [diff] [blame] | 1029 | eth_env_set_enetaddr("eth1addr", mac_addr); |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 1030 | } |
| 1031 | |
| 1032 | ctrl_val = readl((*ctrl)->control_core_control_io1) & (~0x33); |
| 1033 | ctrl_val |= 0x22; |
| 1034 | writel(ctrl_val, (*ctrl)->control_core_control_io1); |
| 1035 | |
Steve Kipisz | c95cddd | 2016-11-25 11:14:24 +0530 | [diff] [blame] | 1036 | /* The phy address for the AM57xx IDK are different than x15 */ |
Lokesh Vutla | 6e9635c | 2017-12-29 11:47:53 +0530 | [diff] [blame] | 1037 | if (board_is_am572x_idk() || board_is_am571x_idk() || |
| 1038 | board_is_am574x_idk()) { |
Steve Kipisz | 0ac8cea | 2016-04-08 17:01:29 -0500 | [diff] [blame] | 1039 | cpsw_data.slave_data[0].phy_addr = 0; |
| 1040 | cpsw_data.slave_data[1].phy_addr = 1; |
| 1041 | } |
| 1042 | |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 1043 | ret = cpsw_register(&cpsw_data); |
| 1044 | if (ret < 0) |
| 1045 | printf("Error %d registering CPSW switch\n", ret); |
| 1046 | |
Roger Quadros | 64217a2 | 2016-03-18 13:18:12 +0200 | [diff] [blame] | 1047 | /* |
| 1048 | * Export any Ethernet MAC addresses from EEPROM. |
| 1049 | * On AM57xx the 2 MAC addresses define the address range |
| 1050 | */ |
| 1051 | board_ti_get_eth_mac_addr(0, mac_addr1); |
| 1052 | board_ti_get_eth_mac_addr(1, mac_addr2); |
| 1053 | |
| 1054 | if (is_valid_ethaddr(mac_addr1) && is_valid_ethaddr(mac_addr2)) { |
| 1055 | mac1 = mac_to_u64(mac_addr1); |
| 1056 | mac2 = mac_to_u64(mac_addr2); |
| 1057 | |
| 1058 | /* must contain an address range */ |
| 1059 | num_macs = mac2 - mac1 + 1; |
| 1060 | /* <= 50 to protect against user programming error */ |
| 1061 | if (num_macs > 0 && num_macs <= 50) { |
| 1062 | for (i = 0; i < num_macs; i++) { |
| 1063 | u64_to_mac(mac1 + i, mac_addr); |
| 1064 | if (is_valid_ethaddr(mac_addr)) { |
Simon Glass | 8551d55 | 2017-08-03 12:22:11 -0600 | [diff] [blame] | 1065 | eth_env_set_enetaddr_by_index("eth", |
| 1066 | i + 2, |
| 1067 | mac_addr); |
Roger Quadros | 64217a2 | 2016-03-18 13:18:12 +0200 | [diff] [blame] | 1068 | } |
| 1069 | } |
| 1070 | } |
| 1071 | } |
| 1072 | |
Felipe Balbi | 4750eb6 | 2014-11-10 14:02:44 -0600 | [diff] [blame] | 1073 | return ret; |
| 1074 | } |
| 1075 | #endif |
Lokesh Vutla | 9f15067 | 2015-06-16 20:36:05 +0530 | [diff] [blame] | 1076 | |
| 1077 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 1078 | /* VTT regulator enable */ |
| 1079 | static inline void vtt_regulator_enable(void) |
| 1080 | { |
| 1081 | if (omap_hw_init_context() == OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL) |
| 1082 | return; |
| 1083 | |
| 1084 | gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en"); |
| 1085 | gpio_direction_output(GPIO_DDR_VTT_EN, 1); |
| 1086 | } |
| 1087 | |
| 1088 | int board_early_init_f(void) |
| 1089 | { |
| 1090 | vtt_regulator_enable(); |
| 1091 | return 0; |
| 1092 | } |
| 1093 | #endif |
Daniel Allred | 7ceffb2 | 2016-05-19 19:10:54 -0500 | [diff] [blame] | 1094 | |
| 1095 | #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) |
| 1096 | int ft_board_setup(void *blob, bd_t *bd) |
| 1097 | { |
| 1098 | ft_cpu_setup(blob, bd); |
| 1099 | |
| 1100 | return 0; |
| 1101 | } |
| 1102 | #endif |
Lokesh Vutla | 00bf8b2 | 2016-06-10 09:35:43 +0530 | [diff] [blame] | 1103 | |
| 1104 | #ifdef CONFIG_SPL_LOAD_FIT |
| 1105 | int board_fit_config_name_match(const char *name) |
| 1106 | { |
Lokesh Vutla | 638e1c0 | 2016-11-25 11:14:20 +0530 | [diff] [blame] | 1107 | if (board_is_x15()) { |
| 1108 | if (board_is_x15_revb1()) { |
| 1109 | if (!strcmp(name, "am57xx-beagle-x15-revb1")) |
| 1110 | return 0; |
Lokesh Vutla | f35589c | 2017-08-23 11:39:06 +0530 | [diff] [blame] | 1111 | } else if (board_is_x15_revc()) { |
| 1112 | if (!strcmp(name, "am57xx-beagle-x15-revc")) |
| 1113 | return 0; |
Lokesh Vutla | 638e1c0 | 2016-11-25 11:14:20 +0530 | [diff] [blame] | 1114 | } else if (!strcmp(name, "am57xx-beagle-x15")) { |
| 1115 | return 0; |
| 1116 | } |
| 1117 | } else if (board_is_am572x_evm() && |
| 1118 | !strcmp(name, "am57xx-beagle-x15")) { |
Lokesh Vutla | 00bf8b2 | 2016-06-10 09:35:43 +0530 | [diff] [blame] | 1119 | return 0; |
Lokesh Vutla | 638e1c0 | 2016-11-25 11:14:20 +0530 | [diff] [blame] | 1120 | } else if (board_is_am572x_idk() && !strcmp(name, "am572x-idk")) { |
Schuyler Patton | 9951985 | 2016-06-10 09:35:45 +0530 | [diff] [blame] | 1121 | return 0; |
Lokesh Vutla | 58a3c1b | 2017-12-29 11:47:57 +0530 | [diff] [blame] | 1122 | } else if (board_is_am574x_idk() && !strcmp(name, "am574x-idk")) { |
| 1123 | return 0; |
Schuyler Patton | c665e27 | 2016-11-25 11:14:25 +0530 | [diff] [blame] | 1124 | } else if (board_is_am571x_idk() && !strcmp(name, "am571x-idk")) { |
| 1125 | return 0; |
Lokesh Vutla | 638e1c0 | 2016-11-25 11:14:20 +0530 | [diff] [blame] | 1126 | } |
| 1127 | |
| 1128 | return -1; |
Lokesh Vutla | 00bf8b2 | 2016-06-10 09:35:43 +0530 | [diff] [blame] | 1129 | } |
| 1130 | #endif |
Andreas Dannenberg | 5cf344b | 2016-06-27 09:19:22 -0500 | [diff] [blame] | 1131 | |
Andrew F. Davis | d355583 | 2019-02-11 08:00:08 -0600 | [diff] [blame] | 1132 | #if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE) |
| 1133 | int fastboot_set_reboot_flag(void) |
| 1134 | { |
| 1135 | printf("Setting reboot to fastboot flag ...\n"); |
| 1136 | env_set("dofastboot", "1"); |
| 1137 | env_save(); |
| 1138 | return 0; |
| 1139 | } |
| 1140 | #endif |
| 1141 | |
Caleb Robey | 0dfcc93 | 2020-01-02 08:17:25 -0600 | [diff] [blame^] | 1142 | #ifdef CONFIG_SUPPORT_EMMC_BOOT |
| 1143 | static int board_bootmode_has_emmc(void) |
| 1144 | { |
| 1145 | /* Check that boot mode is same as BBAI */ |
| 1146 | if (gd->arch.omap_boot_mode != 2) |
| 1147 | return -EIO; |
| 1148 | |
| 1149 | return 0; |
| 1150 | } |
| 1151 | #endif |
| 1152 | |
Andreas Dannenberg | 5cf344b | 2016-06-27 09:19:22 -0500 | [diff] [blame] | 1153 | #ifdef CONFIG_TI_SECURE_DEVICE |
| 1154 | void board_fit_image_post_process(void **p_image, size_t *p_size) |
| 1155 | { |
| 1156 | secure_boot_verify_image(p_image, p_size); |
| 1157 | } |
Andrew F. Davis | 7d25062 | 2016-11-29 16:33:26 -0600 | [diff] [blame] | 1158 | |
| 1159 | void board_tee_image_process(ulong tee_image, size_t tee_size) |
| 1160 | { |
| 1161 | secure_tee_install((u32)tee_image); |
| 1162 | } |
| 1163 | |
| 1164 | U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_TEE, board_tee_image_process); |
Andreas Dannenberg | 5cf344b | 2016-06-27 09:19:22 -0500 | [diff] [blame] | 1165 | #endif |