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