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