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