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