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