Lokesh Vutla | 687054a | 2013-02-12 21:29:08 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2013 |
| 3 | * Texas Instruments Incorporated, <www.ti.com> |
| 4 | * |
| 5 | * Lokesh Vutla <lokeshvutla@ti.com> |
| 6 | * |
| 7 | * Based on previous work by: |
| 8 | * Aneesh V <aneesh@ti.com> |
| 9 | * Steve Sakoman <steve@sakoman.com> |
| 10 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 11 | * SPDX-License-Identifier: GPL-2.0+ |
Lokesh Vutla | 687054a | 2013-02-12 21:29:08 +0000 | [diff] [blame] | 12 | */ |
| 13 | #include <common.h> |
Nishanth Menon | cb19910 | 2013-03-26 05:20:54 +0000 | [diff] [blame] | 14 | #include <palmas.h> |
Dan Murphy | e9024ef | 2014-02-03 06:59:02 -0600 | [diff] [blame] | 15 | #include <sata.h> |
Lokesh Vutla | 25afe55 | 2016-03-08 09:18:05 +0530 | [diff] [blame] | 16 | #include <linux/string.h> |
Lokesh Vutla | 7b92252 | 2014-08-04 19:42:24 +0530 | [diff] [blame] | 17 | #include <asm/gpio.h> |
Kishon Vijay Abraham I | a17188c | 2015-02-23 18:40:19 +0530 | [diff] [blame] | 18 | #include <usb.h> |
| 19 | #include <linux/usb/gadget.h> |
Andreas Dannenberg | 17c2987 | 2016-06-27 09:19:22 -0500 | [diff] [blame] | 20 | #include <asm/omap_common.h> |
| 21 | #include <asm/omap_sec_common.h> |
Lokesh Vutla | 7b92252 | 2014-08-04 19:42:24 +0530 | [diff] [blame] | 22 | #include <asm/arch/gpio.h> |
Lokesh Vutla | 706dd34 | 2015-06-04 16:42:38 +0530 | [diff] [blame] | 23 | #include <asm/arch/dra7xx_iodelay.h> |
Lokesh Vutla | a763883 | 2016-03-08 09:18:06 +0530 | [diff] [blame] | 24 | #include <asm/emif.h> |
Lokesh Vutla | 687054a | 2013-02-12 21:29:08 +0000 | [diff] [blame] | 25 | #include <asm/arch/sys_proto.h> |
| 26 | #include <asm/arch/mmc_host_def.h> |
Roger Quadros | 21914ee | 2013-11-11 16:56:44 +0200 | [diff] [blame] | 27 | #include <asm/arch/sata.h> |
Tom Rini | 79b079f | 2014-04-03 07:52:56 -0400 | [diff] [blame] | 28 | #include <environment.h> |
Kishon Vijay Abraham I | a17188c | 2015-02-23 18:40:19 +0530 | [diff] [blame] | 29 | #include <dwc3-uboot.h> |
| 30 | #include <dwc3-omap-uboot.h> |
| 31 | #include <ti-usb-phy-uboot.h> |
Dan Murphy | 39fbac9 | 2016-03-30 12:58:37 -0500 | [diff] [blame] | 32 | #include <miiphy.h> |
Lokesh Vutla | 687054a | 2013-02-12 21:29:08 +0000 | [diff] [blame] | 33 | |
| 34 | #include "mux_data.h" |
Lokesh Vutla | 25afe55 | 2016-03-08 09:18:05 +0530 | [diff] [blame] | 35 | #include "../common/board_detect.h" |
| 36 | |
| 37 | #define board_is_dra74x_evm() board_ti_is("5777xCPU") |
Ravi Babu | 6b1c14b | 2016-03-15 18:09:14 -0500 | [diff] [blame] | 38 | #define board_is_dra72x_evm() board_ti_is("DRA72x-T") |
Lokesh Vutla | 463dd22 | 2016-11-23 13:25:24 +0530 | [diff] [blame^] | 39 | #define board_is_dra71x_evm() board_ti_is("DRA79x,D") |
Mugunthan V N | 1053a76 | 2016-09-27 13:01:42 +0530 | [diff] [blame] | 40 | #define board_is_dra74x_revh_or_later() (board_is_dra74x_evm() && \ |
| 41 | (strncmp("H", board_ti_get_rev(), 1) <= 0)) |
| 42 | #define board_is_dra72x_revc_or_later() (board_is_dra72x_evm() && \ |
| 43 | (strncmp("C", board_ti_get_rev(), 1) <= 0)) |
Lokesh Vutla | c4a2736 | 2016-03-08 09:18:08 +0530 | [diff] [blame] | 44 | #define board_ti_get_emif_size() board_ti_get_emif1_size() + \ |
| 45 | board_ti_get_emif2_size() |
Lokesh Vutla | 687054a | 2013-02-12 21:29:08 +0000 | [diff] [blame] | 46 | |
Mugunthan V N | b1e26e3 | 2013-07-08 16:04:41 +0530 | [diff] [blame] | 47 | #ifdef CONFIG_DRIVER_TI_CPSW |
| 48 | #include <cpsw.h> |
| 49 | #endif |
| 50 | |
Lokesh Vutla | 687054a | 2013-02-12 21:29:08 +0000 | [diff] [blame] | 51 | DECLARE_GLOBAL_DATA_PTR; |
| 52 | |
Lokesh Vutla | 7b92252 | 2014-08-04 19:42:24 +0530 | [diff] [blame] | 53 | /* GPIO 7_11 */ |
| 54 | #define GPIO_DDR_VTT_EN 203 |
| 55 | |
Lokesh Vutla | 25afe55 | 2016-03-08 09:18:05 +0530 | [diff] [blame] | 56 | #define SYSINFO_BOARD_NAME_MAX_LEN 37 |
| 57 | |
Lokesh Vutla | 687054a | 2013-02-12 21:29:08 +0000 | [diff] [blame] | 58 | const struct omap_sysinfo sysinfo = { |
Lokesh Vutla | 25afe55 | 2016-03-08 09:18:05 +0530 | [diff] [blame] | 59 | "Board: UNKNOWN(DRA7 EVM) REV UNKNOWN\n" |
Lokesh Vutla | 687054a | 2013-02-12 21:29:08 +0000 | [diff] [blame] | 60 | }; |
| 61 | |
Lokesh Vutla | a763883 | 2016-03-08 09:18:06 +0530 | [diff] [blame] | 62 | static const struct emif_regs emif1_ddr3_532_mhz_1cs = { |
| 63 | .sdram_config_init = 0x61851ab2, |
| 64 | .sdram_config = 0x61851ab2, |
| 65 | .sdram_config2 = 0x08000000, |
| 66 | .ref_ctrl = 0x000040F1, |
| 67 | .ref_ctrl_final = 0x00001035, |
| 68 | .sdram_tim1 = 0xCCCF36B3, |
| 69 | .sdram_tim2 = 0x308F7FDA, |
| 70 | .sdram_tim3 = 0x427F88A8, |
| 71 | .read_idle_ctrl = 0x00050000, |
| 72 | .zq_config = 0x0007190B, |
| 73 | .temp_alert_config = 0x00000000, |
| 74 | .emif_ddr_phy_ctlr_1_init = 0x0024400B, |
| 75 | .emif_ddr_phy_ctlr_1 = 0x0E24400B, |
| 76 | .emif_ddr_ext_phy_ctrl_1 = 0x10040100, |
| 77 | .emif_ddr_ext_phy_ctrl_2 = 0x00910091, |
| 78 | .emif_ddr_ext_phy_ctrl_3 = 0x00950095, |
| 79 | .emif_ddr_ext_phy_ctrl_4 = 0x009B009B, |
| 80 | .emif_ddr_ext_phy_ctrl_5 = 0x009E009E, |
| 81 | .emif_rd_wr_lvl_rmp_win = 0x00000000, |
| 82 | .emif_rd_wr_lvl_rmp_ctl = 0x80000000, |
| 83 | .emif_rd_wr_lvl_ctl = 0x00000000, |
| 84 | .emif_rd_wr_exec_thresh = 0x00000305 |
| 85 | }; |
| 86 | |
| 87 | static const struct emif_regs emif2_ddr3_532_mhz_1cs = { |
| 88 | .sdram_config_init = 0x61851B32, |
| 89 | .sdram_config = 0x61851B32, |
| 90 | .sdram_config2 = 0x08000000, |
| 91 | .ref_ctrl = 0x000040F1, |
| 92 | .ref_ctrl_final = 0x00001035, |
| 93 | .sdram_tim1 = 0xCCCF36B3, |
| 94 | .sdram_tim2 = 0x308F7FDA, |
| 95 | .sdram_tim3 = 0x427F88A8, |
| 96 | .read_idle_ctrl = 0x00050000, |
| 97 | .zq_config = 0x0007190B, |
| 98 | .temp_alert_config = 0x00000000, |
| 99 | .emif_ddr_phy_ctlr_1_init = 0x0024400B, |
| 100 | .emif_ddr_phy_ctlr_1 = 0x0E24400B, |
| 101 | .emif_ddr_ext_phy_ctrl_1 = 0x10040100, |
| 102 | .emif_ddr_ext_phy_ctrl_2 = 0x00910091, |
| 103 | .emif_ddr_ext_phy_ctrl_3 = 0x00950095, |
| 104 | .emif_ddr_ext_phy_ctrl_4 = 0x009B009B, |
| 105 | .emif_ddr_ext_phy_ctrl_5 = 0x009E009E, |
| 106 | .emif_rd_wr_lvl_rmp_win = 0x00000000, |
| 107 | .emif_rd_wr_lvl_rmp_ctl = 0x80000000, |
| 108 | .emif_rd_wr_lvl_ctl = 0x00000000, |
| 109 | .emif_rd_wr_exec_thresh = 0x00000305 |
| 110 | }; |
| 111 | |
| 112 | static const struct emif_regs emif_1_regs_ddr3_666_mhz_1cs_dra_es1 = { |
| 113 | .sdram_config_init = 0x61862B32, |
| 114 | .sdram_config = 0x61862B32, |
| 115 | .sdram_config2 = 0x08000000, |
| 116 | .ref_ctrl = 0x0000514C, |
| 117 | .ref_ctrl_final = 0x0000144A, |
| 118 | .sdram_tim1 = 0xD113781C, |
| 119 | .sdram_tim2 = 0x30717FE3, |
| 120 | .sdram_tim3 = 0x409F86A8, |
| 121 | .read_idle_ctrl = 0x00050000, |
| 122 | .zq_config = 0x5007190B, |
| 123 | .temp_alert_config = 0x00000000, |
| 124 | .emif_ddr_phy_ctlr_1_init = 0x0024400D, |
| 125 | .emif_ddr_phy_ctlr_1 = 0x0E24400D, |
| 126 | .emif_ddr_ext_phy_ctrl_1 = 0x10040100, |
| 127 | .emif_ddr_ext_phy_ctrl_2 = 0x00A400A4, |
| 128 | .emif_ddr_ext_phy_ctrl_3 = 0x00A900A9, |
| 129 | .emif_ddr_ext_phy_ctrl_4 = 0x00B000B0, |
| 130 | .emif_ddr_ext_phy_ctrl_5 = 0x00B000B0, |
| 131 | .emif_rd_wr_lvl_rmp_win = 0x00000000, |
| 132 | .emif_rd_wr_lvl_rmp_ctl = 0x80000000, |
| 133 | .emif_rd_wr_lvl_ctl = 0x00000000, |
| 134 | .emif_rd_wr_exec_thresh = 0x00000305 |
| 135 | }; |
| 136 | |
Ravi Babu | 6b1c14b | 2016-03-15 18:09:14 -0500 | [diff] [blame] | 137 | const struct emif_regs emif_1_regs_ddr3_666_mhz_1cs_dra_es2 = { |
| 138 | .sdram_config_init = 0x61862BB2, |
| 139 | .sdram_config = 0x61862BB2, |
| 140 | .sdram_config2 = 0x00000000, |
| 141 | .ref_ctrl = 0x0000514D, |
| 142 | .ref_ctrl_final = 0x0000144A, |
| 143 | .sdram_tim1 = 0xD1137824, |
| 144 | .sdram_tim2 = 0x30B37FE3, |
| 145 | .sdram_tim3 = 0x409F8AD8, |
| 146 | .read_idle_ctrl = 0x00050000, |
| 147 | .zq_config = 0x5007190B, |
| 148 | .temp_alert_config = 0x00000000, |
| 149 | .emif_ddr_phy_ctlr_1_init = 0x0824400E, |
| 150 | .emif_ddr_phy_ctlr_1 = 0x0E24400E, |
| 151 | .emif_ddr_ext_phy_ctrl_1 = 0x04040100, |
| 152 | .emif_ddr_ext_phy_ctrl_2 = 0x006B009F, |
| 153 | .emif_ddr_ext_phy_ctrl_3 = 0x006B00A2, |
| 154 | .emif_ddr_ext_phy_ctrl_4 = 0x006B00A8, |
| 155 | .emif_ddr_ext_phy_ctrl_5 = 0x006B00A8, |
| 156 | .emif_rd_wr_lvl_rmp_win = 0x00000000, |
| 157 | .emif_rd_wr_lvl_rmp_ctl = 0x80000000, |
| 158 | .emif_rd_wr_lvl_ctl = 0x00000000, |
| 159 | .emif_rd_wr_exec_thresh = 0x00000305 |
| 160 | }; |
| 161 | |
Lokesh Vutla | c4a2736 | 2016-03-08 09:18:08 +0530 | [diff] [blame] | 162 | const struct emif_regs emif1_ddr3_532_mhz_1cs_2G = { |
| 163 | .sdram_config_init = 0x61851ab2, |
| 164 | .sdram_config = 0x61851ab2, |
| 165 | .sdram_config2 = 0x08000000, |
| 166 | .ref_ctrl = 0x000040F1, |
| 167 | .ref_ctrl_final = 0x00001035, |
| 168 | .sdram_tim1 = 0xCCCF36B3, |
| 169 | .sdram_tim2 = 0x30BF7FDA, |
| 170 | .sdram_tim3 = 0x427F8BA8, |
| 171 | .read_idle_ctrl = 0x00050000, |
| 172 | .zq_config = 0x0007190B, |
| 173 | .temp_alert_config = 0x00000000, |
| 174 | .emif_ddr_phy_ctlr_1_init = 0x0024400B, |
| 175 | .emif_ddr_phy_ctlr_1 = 0x0E24400B, |
| 176 | .emif_ddr_ext_phy_ctrl_1 = 0x10040100, |
| 177 | .emif_ddr_ext_phy_ctrl_2 = 0x00910091, |
| 178 | .emif_ddr_ext_phy_ctrl_3 = 0x00950095, |
| 179 | .emif_ddr_ext_phy_ctrl_4 = 0x009B009B, |
| 180 | .emif_ddr_ext_phy_ctrl_5 = 0x009E009E, |
| 181 | .emif_rd_wr_lvl_rmp_win = 0x00000000, |
| 182 | .emif_rd_wr_lvl_rmp_ctl = 0x80000000, |
| 183 | .emif_rd_wr_lvl_ctl = 0x00000000, |
| 184 | .emif_rd_wr_exec_thresh = 0x00000305 |
| 185 | }; |
| 186 | |
| 187 | const struct emif_regs emif2_ddr3_532_mhz_1cs_2G = { |
| 188 | .sdram_config_init = 0x61851B32, |
| 189 | .sdram_config = 0x61851B32, |
| 190 | .sdram_config2 = 0x08000000, |
| 191 | .ref_ctrl = 0x000040F1, |
| 192 | .ref_ctrl_final = 0x00001035, |
| 193 | .sdram_tim1 = 0xCCCF36B3, |
| 194 | .sdram_tim2 = 0x308F7FDA, |
| 195 | .sdram_tim3 = 0x427F88A8, |
| 196 | .read_idle_ctrl = 0x00050000, |
| 197 | .zq_config = 0x0007190B, |
| 198 | .temp_alert_config = 0x00000000, |
| 199 | .emif_ddr_phy_ctlr_1_init = 0x0024400B, |
| 200 | .emif_ddr_phy_ctlr_1 = 0x0E24400B, |
| 201 | .emif_ddr_ext_phy_ctrl_1 = 0x10040100, |
| 202 | .emif_ddr_ext_phy_ctrl_2 = 0x00910091, |
| 203 | .emif_ddr_ext_phy_ctrl_3 = 0x00950095, |
| 204 | .emif_ddr_ext_phy_ctrl_4 = 0x009B009B, |
| 205 | .emif_ddr_ext_phy_ctrl_5 = 0x009E009E, |
| 206 | .emif_rd_wr_lvl_rmp_win = 0x00000000, |
| 207 | .emif_rd_wr_lvl_rmp_ctl = 0x80000000, |
| 208 | .emif_rd_wr_lvl_ctl = 0x00000000, |
| 209 | .emif_rd_wr_exec_thresh = 0x00000305 |
| 210 | }; |
| 211 | |
Lokesh Vutla | a763883 | 2016-03-08 09:18:06 +0530 | [diff] [blame] | 212 | void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs) |
| 213 | { |
Lokesh Vutla | c4a2736 | 2016-03-08 09:18:08 +0530 | [diff] [blame] | 214 | u64 ram_size; |
| 215 | |
| 216 | ram_size = board_ti_get_emif_size(); |
| 217 | |
Lokesh Vutla | a763883 | 2016-03-08 09:18:06 +0530 | [diff] [blame] | 218 | switch (omap_revision()) { |
| 219 | case DRA752_ES1_0: |
| 220 | case DRA752_ES1_1: |
| 221 | case DRA752_ES2_0: |
| 222 | switch (emif_nr) { |
| 223 | case 1: |
Lokesh Vutla | c4a2736 | 2016-03-08 09:18:08 +0530 | [diff] [blame] | 224 | if (ram_size > CONFIG_MAX_MEM_MAPPED) |
| 225 | *regs = &emif1_ddr3_532_mhz_1cs_2G; |
| 226 | else |
| 227 | *regs = &emif1_ddr3_532_mhz_1cs; |
Lokesh Vutla | a763883 | 2016-03-08 09:18:06 +0530 | [diff] [blame] | 228 | break; |
| 229 | case 2: |
Lokesh Vutla | c4a2736 | 2016-03-08 09:18:08 +0530 | [diff] [blame] | 230 | if (ram_size > CONFIG_MAX_MEM_MAPPED) |
| 231 | *regs = &emif2_ddr3_532_mhz_1cs_2G; |
| 232 | else |
| 233 | *regs = &emif2_ddr3_532_mhz_1cs; |
Lokesh Vutla | a763883 | 2016-03-08 09:18:06 +0530 | [diff] [blame] | 234 | break; |
| 235 | } |
| 236 | break; |
| 237 | case DRA722_ES1_0: |
Ravi Babu | 6b1c14b | 2016-03-15 18:09:14 -0500 | [diff] [blame] | 238 | case DRA722_ES2_0: |
| 239 | if (ram_size < CONFIG_MAX_MEM_MAPPED) |
| 240 | *regs = &emif_1_regs_ddr3_666_mhz_1cs_dra_es1; |
| 241 | else |
| 242 | *regs = &emif_1_regs_ddr3_666_mhz_1cs_dra_es2; |
Lokesh Vutla | a763883 | 2016-03-08 09:18:06 +0530 | [diff] [blame] | 243 | break; |
| 244 | default: |
| 245 | *regs = &emif1_ddr3_532_mhz_1cs; |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | static const struct dmm_lisa_map_regs lisa_map_dra7_1536MB = { |
| 250 | .dmm_lisa_map_0 = 0x0, |
| 251 | .dmm_lisa_map_1 = 0x80640300, |
| 252 | .dmm_lisa_map_2 = 0xC0500220, |
| 253 | .dmm_lisa_map_3 = 0xFF020100, |
| 254 | .is_ma_present = 0x1 |
| 255 | }; |
| 256 | |
| 257 | static const struct dmm_lisa_map_regs lisa_map_2G_x_2 = { |
| 258 | .dmm_lisa_map_0 = 0x0, |
| 259 | .dmm_lisa_map_1 = 0x0, |
| 260 | .dmm_lisa_map_2 = 0x80600100, |
| 261 | .dmm_lisa_map_3 = 0xFF020100, |
| 262 | .is_ma_present = 0x1 |
| 263 | }; |
| 264 | |
Lokesh Vutla | c4a2736 | 2016-03-08 09:18:08 +0530 | [diff] [blame] | 265 | const struct dmm_lisa_map_regs lisa_map_dra7_2GB = { |
| 266 | .dmm_lisa_map_0 = 0x0, |
| 267 | .dmm_lisa_map_1 = 0x0, |
| 268 | .dmm_lisa_map_2 = 0x80740300, |
| 269 | .dmm_lisa_map_3 = 0xFF020100, |
| 270 | .is_ma_present = 0x1 |
| 271 | }; |
| 272 | |
Ravi Babu | 6b1c14b | 2016-03-15 18:09:14 -0500 | [diff] [blame] | 273 | /* |
| 274 | * DRA722 EVM EMIF1 2GB CONFIGURATION |
| 275 | * EMIF1 4 devices of 512Mb x 8 Micron |
| 276 | */ |
| 277 | const struct dmm_lisa_map_regs lisa_map_2G_x_4 = { |
| 278 | .dmm_lisa_map_0 = 0x0, |
| 279 | .dmm_lisa_map_1 = 0x0, |
| 280 | .dmm_lisa_map_2 = 0x80700100, |
| 281 | .dmm_lisa_map_3 = 0xFF020100, |
| 282 | .is_ma_present = 0x1 |
| 283 | }; |
| 284 | |
Lokesh Vutla | a763883 | 2016-03-08 09:18:06 +0530 | [diff] [blame] | 285 | void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs) |
| 286 | { |
Lokesh Vutla | c4a2736 | 2016-03-08 09:18:08 +0530 | [diff] [blame] | 287 | u64 ram_size; |
| 288 | |
| 289 | ram_size = board_ti_get_emif_size(); |
| 290 | |
Lokesh Vutla | a763883 | 2016-03-08 09:18:06 +0530 | [diff] [blame] | 291 | switch (omap_revision()) { |
| 292 | case DRA752_ES1_0: |
| 293 | case DRA752_ES1_1: |
| 294 | case DRA752_ES2_0: |
Lokesh Vutla | c4a2736 | 2016-03-08 09:18:08 +0530 | [diff] [blame] | 295 | if (ram_size > CONFIG_MAX_MEM_MAPPED) |
| 296 | *dmm_lisa_regs = &lisa_map_dra7_2GB; |
| 297 | else |
| 298 | *dmm_lisa_regs = &lisa_map_dra7_1536MB; |
Lokesh Vutla | a763883 | 2016-03-08 09:18:06 +0530 | [diff] [blame] | 299 | break; |
| 300 | case DRA722_ES1_0: |
Ravi Babu | 6b1c14b | 2016-03-15 18:09:14 -0500 | [diff] [blame] | 301 | case DRA722_ES2_0: |
Lokesh Vutla | a763883 | 2016-03-08 09:18:06 +0530 | [diff] [blame] | 302 | default: |
Ravi Babu | 6b1c14b | 2016-03-15 18:09:14 -0500 | [diff] [blame] | 303 | if (ram_size < CONFIG_MAX_MEM_MAPPED) |
| 304 | *dmm_lisa_regs = &lisa_map_2G_x_2; |
| 305 | else |
| 306 | *dmm_lisa_regs = &lisa_map_2G_x_4; |
| 307 | break; |
Lokesh Vutla | a763883 | 2016-03-08 09:18:06 +0530 | [diff] [blame] | 308 | } |
| 309 | } |
| 310 | |
Keerthy | 1428d83 | 2016-06-07 16:05:25 +0530 | [diff] [blame] | 311 | struct vcores_data dra752_volts = { |
Lokesh Vutla | beb7127 | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 312 | .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM, |
| 313 | .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM, |
Keerthy | 1428d83 | 2016-06-07 16:05:25 +0530 | [diff] [blame] | 314 | .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 315 | .mpu.addr = TPS659038_REG_ADDR_SMPS12, |
| 316 | .mpu.pmic = &tps659038, |
| 317 | .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK, |
| 318 | |
Lokesh Vutla | beb7127 | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 319 | .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM, |
| 320 | .eve.value[OPP_OD] = VDD_EVE_DRA7_OD, |
| 321 | .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH, |
| 322 | .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM, |
| 323 | .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD, |
| 324 | .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH, |
Keerthy | 1428d83 | 2016-06-07 16:05:25 +0530 | [diff] [blame] | 325 | .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 326 | .eve.addr = TPS659038_REG_ADDR_SMPS45, |
| 327 | .eve.pmic = &tps659038, |
| 328 | .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK, |
| 329 | |
Lokesh Vutla | beb7127 | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 330 | .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM, |
| 331 | .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD, |
| 332 | .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH, |
| 333 | .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM, |
| 334 | .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD, |
| 335 | .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH, |
Keerthy | 1428d83 | 2016-06-07 16:05:25 +0530 | [diff] [blame] | 336 | .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 337 | .gpu.addr = TPS659038_REG_ADDR_SMPS6, |
| 338 | .gpu.pmic = &tps659038, |
| 339 | .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK, |
| 340 | |
Lokesh Vutla | beb7127 | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 341 | .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM, |
| 342 | .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM, |
Keerthy | 1428d83 | 2016-06-07 16:05:25 +0530 | [diff] [blame] | 343 | .core.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 344 | .core.addr = TPS659038_REG_ADDR_SMPS7, |
| 345 | .core.pmic = &tps659038, |
| 346 | |
Lokesh Vutla | beb7127 | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 347 | .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM, |
| 348 | .iva.value[OPP_OD] = VDD_IVA_DRA7_OD, |
| 349 | .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH, |
| 350 | .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM, |
| 351 | .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD, |
| 352 | .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH, |
Keerthy | 1428d83 | 2016-06-07 16:05:25 +0530 | [diff] [blame] | 353 | .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 354 | .iva.addr = TPS659038_REG_ADDR_SMPS8, |
| 355 | .iva.pmic = &tps659038, |
| 356 | .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK, |
| 357 | }; |
| 358 | |
| 359 | struct vcores_data dra722_volts = { |
Lokesh Vutla | beb7127 | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 360 | .mpu.value[OPP_NOM] = VDD_MPU_DRA7_NOM, |
| 361 | .mpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_MPU_NOM, |
Keerthy | 1428d83 | 2016-06-07 16:05:25 +0530 | [diff] [blame] | 362 | .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 363 | .mpu.addr = TPS65917_REG_ADDR_SMPS1, |
| 364 | .mpu.pmic = &tps659038, |
| 365 | .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK, |
| 366 | |
Lokesh Vutla | beb7127 | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 367 | .core.value[OPP_NOM] = VDD_CORE_DRA7_NOM, |
| 368 | .core.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_CORE_NOM, |
Keerthy | 1428d83 | 2016-06-07 16:05:25 +0530 | [diff] [blame] | 369 | .core.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 370 | .core.addr = TPS65917_REG_ADDR_SMPS2, |
| 371 | .core.pmic = &tps659038, |
| 372 | |
| 373 | /* |
| 374 | * The DSPEVE, GPU and IVA rails are usually grouped on DRA72x |
| 375 | * designs and powered by TPS65917 SMPS3, as on the J6Eco EVM. |
| 376 | */ |
Lokesh Vutla | beb7127 | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 377 | .gpu.value[OPP_NOM] = VDD_GPU_DRA7_NOM, |
| 378 | .gpu.value[OPP_OD] = VDD_GPU_DRA7_OD, |
| 379 | .gpu.value[OPP_HIGH] = VDD_GPU_DRA7_HIGH, |
| 380 | .gpu.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_GPU_NOM, |
| 381 | .gpu.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_GPU_OD, |
| 382 | .gpu.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_GPU_HIGH, |
Keerthy | 1428d83 | 2016-06-07 16:05:25 +0530 | [diff] [blame] | 383 | .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 384 | .gpu.addr = TPS65917_REG_ADDR_SMPS3, |
| 385 | .gpu.pmic = &tps659038, |
| 386 | .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK, |
| 387 | |
Lokesh Vutla | beb7127 | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 388 | .eve.value[OPP_NOM] = VDD_EVE_DRA7_NOM, |
| 389 | .eve.value[OPP_OD] = VDD_EVE_DRA7_OD, |
| 390 | .eve.value[OPP_HIGH] = VDD_EVE_DRA7_HIGH, |
| 391 | .eve.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_DSPEVE_NOM, |
| 392 | .eve.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_DSPEVE_OD, |
| 393 | .eve.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_DSPEVE_HIGH, |
Keerthy | 1428d83 | 2016-06-07 16:05:25 +0530 | [diff] [blame] | 394 | .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 395 | .eve.addr = TPS65917_REG_ADDR_SMPS3, |
| 396 | .eve.pmic = &tps659038, |
| 397 | .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK, |
| 398 | |
Lokesh Vutla | beb7127 | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 399 | .iva.value[OPP_NOM] = VDD_IVA_DRA7_NOM, |
| 400 | .iva.value[OPP_OD] = VDD_IVA_DRA7_OD, |
| 401 | .iva.value[OPP_HIGH] = VDD_IVA_DRA7_HIGH, |
| 402 | .iva.efuse.reg[OPP_NOM] = STD_FUSE_OPP_VMIN_IVA_NOM, |
| 403 | .iva.efuse.reg[OPP_OD] = STD_FUSE_OPP_VMIN_IVA_OD, |
| 404 | .iva.efuse.reg[OPP_HIGH] = STD_FUSE_OPP_VMIN_IVA_HIGH, |
Keerthy | 1428d83 | 2016-06-07 16:05:25 +0530 | [diff] [blame] | 405 | .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS, |
| 406 | .iva.addr = TPS65917_REG_ADDR_SMPS3, |
| 407 | .iva.pmic = &tps659038, |
| 408 | .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK, |
| 409 | }; |
| 410 | |
Lokesh Vutla | beb7127 | 2016-11-23 12:54:39 +0530 | [diff] [blame] | 411 | int get_voltrail_opp(int rail_offset) |
| 412 | { |
| 413 | int opp; |
| 414 | |
| 415 | switch (rail_offset) { |
| 416 | case VOLT_MPU: |
| 417 | opp = DRA7_MPU_OPP; |
| 418 | break; |
| 419 | case VOLT_CORE: |
| 420 | opp = DRA7_CORE_OPP; |
| 421 | break; |
| 422 | case VOLT_GPU: |
| 423 | opp = DRA7_GPU_OPP; |
| 424 | break; |
| 425 | case VOLT_EVE: |
| 426 | opp = DRA7_DSPEVE_OPP; |
| 427 | break; |
| 428 | case VOLT_IVA: |
| 429 | opp = DRA7_IVA_OPP; |
| 430 | break; |
| 431 | default: |
| 432 | opp = OPP_NOM; |
| 433 | } |
| 434 | |
| 435 | return opp; |
| 436 | } |
| 437 | |
Lokesh Vutla | 687054a | 2013-02-12 21:29:08 +0000 | [diff] [blame] | 438 | /** |
| 439 | * @brief board_init |
| 440 | * |
| 441 | * @return 0 |
| 442 | */ |
| 443 | int board_init(void) |
| 444 | { |
| 445 | gpmc_init(); |
| 446 | gd->bd->bi_boot_params = (0x80000000 + 0x100); /* boot param addr */ |
| 447 | |
| 448 | return 0; |
| 449 | } |
| 450 | |
Lokesh Vutla | d468b17 | 2016-03-08 09:18:09 +0530 | [diff] [blame] | 451 | void dram_init_banksize(void) |
| 452 | { |
| 453 | u64 ram_size; |
| 454 | |
| 455 | ram_size = board_ti_get_emif_size(); |
| 456 | |
| 457 | gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE; |
| 458 | gd->bd->bi_dram[0].size = get_effective_memsize(); |
| 459 | if (ram_size > CONFIG_MAX_MEM_MAPPED) { |
| 460 | gd->bd->bi_dram[1].start = 0x200000000; |
| 461 | gd->bd->bi_dram[1].size = ram_size - CONFIG_MAX_MEM_MAPPED; |
| 462 | } |
| 463 | } |
| 464 | |
Roger Quadros | 21914ee | 2013-11-11 16:56:44 +0200 | [diff] [blame] | 465 | int board_late_init(void) |
| 466 | { |
Lokesh Vutla | 4ec3f6e | 2014-07-14 19:57:58 +0530 | [diff] [blame] | 467 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
Lokesh Vutla | 25afe55 | 2016-03-08 09:18:05 +0530 | [diff] [blame] | 468 | char *name = "unknown"; |
| 469 | |
Lokesh Vutla | df6b506 | 2016-06-29 14:50:41 +0530 | [diff] [blame] | 470 | if (is_dra72x()) { |
| 471 | if (board_is_dra72x_revc_or_later()) |
| 472 | name = "dra72x-revc"; |
Lokesh Vutla | 463dd22 | 2016-11-23 13:25:24 +0530 | [diff] [blame^] | 473 | else if (board_is_dra71x_evm()) |
| 474 | name = "dra71x"; |
Lokesh Vutla | df6b506 | 2016-06-29 14:50:41 +0530 | [diff] [blame] | 475 | else |
| 476 | name = "dra72x"; |
| 477 | } else { |
Lokesh Vutla | 25afe55 | 2016-03-08 09:18:05 +0530 | [diff] [blame] | 478 | name = "dra7xx"; |
Lokesh Vutla | df6b506 | 2016-06-29 14:50:41 +0530 | [diff] [blame] | 479 | } |
Lokesh Vutla | 25afe55 | 2016-03-08 09:18:05 +0530 | [diff] [blame] | 480 | |
| 481 | set_board_info_env(name); |
Dileep Katta | f12467d | 2015-03-25 04:04:51 +0530 | [diff] [blame] | 482 | |
Lokesh Vutla | 71c1b58 | 2016-11-29 11:58:01 +0530 | [diff] [blame] | 483 | /* |
| 484 | * Default FIT boot on HS devices. Non FIT images are not allowed |
| 485 | * on HS devices. |
| 486 | */ |
| 487 | if (get_device_type() == HS_DEVICE) |
| 488 | setenv("boot_fit", "1"); |
| 489 | |
Paul Kocialkowski | 07815eb | 2015-08-27 19:37:12 +0200 | [diff] [blame] | 490 | omap_die_id_serial(); |
Lokesh Vutla | 4ec3f6e | 2014-07-14 19:57:58 +0530 | [diff] [blame] | 491 | #endif |
Roger Quadros | 21914ee | 2013-11-11 16:56:44 +0200 | [diff] [blame] | 492 | return 0; |
| 493 | } |
| 494 | |
Lokesh Vutla | 25afe55 | 2016-03-08 09:18:05 +0530 | [diff] [blame] | 495 | #ifdef CONFIG_SPL_BUILD |
| 496 | void do_board_detect(void) |
| 497 | { |
| 498 | int rc; |
| 499 | |
| 500 | rc = ti_i2c_eeprom_dra7_get(CONFIG_EEPROM_BUS_ADDRESS, |
| 501 | CONFIG_EEPROM_CHIP_ADDRESS); |
| 502 | if (rc) |
| 503 | printf("ti_i2c_eeprom_init failed %d\n", rc); |
| 504 | } |
| 505 | |
| 506 | #else |
| 507 | |
| 508 | void do_board_detect(void) |
| 509 | { |
| 510 | char *bname = NULL; |
| 511 | int rc; |
| 512 | |
| 513 | rc = ti_i2c_eeprom_dra7_get(CONFIG_EEPROM_BUS_ADDRESS, |
| 514 | CONFIG_EEPROM_CHIP_ADDRESS); |
| 515 | if (rc) |
| 516 | printf("ti_i2c_eeprom_init failed %d\n", rc); |
| 517 | |
| 518 | if (board_is_dra74x_evm()) { |
| 519 | bname = "DRA74x EVM"; |
Ravi Babu | 6b1c14b | 2016-03-15 18:09:14 -0500 | [diff] [blame] | 520 | } else if (board_is_dra72x_evm()) { |
| 521 | bname = "DRA72x EVM"; |
Lokesh Vutla | 463dd22 | 2016-11-23 13:25:24 +0530 | [diff] [blame^] | 522 | } else if (board_is_dra71x_evm()) { |
| 523 | bname = "DRA71x EVM"; |
Lokesh Vutla | 25afe55 | 2016-03-08 09:18:05 +0530 | [diff] [blame] | 524 | } else { |
Ravi Babu | 6b1c14b | 2016-03-15 18:09:14 -0500 | [diff] [blame] | 525 | /* If EEPROM is not populated */ |
Lokesh Vutla | 25afe55 | 2016-03-08 09:18:05 +0530 | [diff] [blame] | 526 | if (is_dra72x()) |
| 527 | bname = "DRA72x EVM"; |
| 528 | else |
| 529 | bname = "DRA74x EVM"; |
| 530 | } |
| 531 | |
| 532 | if (bname) |
| 533 | snprintf(sysinfo.board_string, SYSINFO_BOARD_NAME_MAX_LEN, |
| 534 | "Board: %s REV %s\n", bname, board_ti_get_rev()); |
| 535 | } |
| 536 | #endif /* CONFIG_SPL_BUILD */ |
| 537 | |
Keerthy | 1428d83 | 2016-06-07 16:05:25 +0530 | [diff] [blame] | 538 | void vcores_init(void) |
| 539 | { |
| 540 | if (board_is_dra74x_evm()) { |
| 541 | *omap_vcores = &dra752_volts; |
| 542 | } else if (board_is_dra72x_evm()) { |
| 543 | *omap_vcores = &dra722_volts; |
| 544 | } else { |
| 545 | /* If EEPROM is not populated */ |
| 546 | if (is_dra72x()) |
| 547 | *omap_vcores = &dra722_volts; |
| 548 | else |
| 549 | *omap_vcores = &dra752_volts; |
| 550 | } |
| 551 | } |
| 552 | |
Paul Kocialkowski | 3ef56e6 | 2016-02-27 19:18:56 +0100 | [diff] [blame] | 553 | void set_muxconf_regs(void) |
Lokesh Vutla | 687054a | 2013-02-12 21:29:08 +0000 | [diff] [blame] | 554 | { |
| 555 | do_set_mux32((*ctrl)->control_padconf_core_base, |
Lokesh Vutla | 706dd34 | 2015-06-04 16:42:38 +0530 | [diff] [blame] | 556 | early_padconf, ARRAY_SIZE(early_padconf)); |
Lokesh Vutla | 687054a | 2013-02-12 21:29:08 +0000 | [diff] [blame] | 557 | } |
| 558 | |
Lokesh Vutla | 706dd34 | 2015-06-04 16:42:38 +0530 | [diff] [blame] | 559 | #ifdef CONFIG_IODELAY_RECALIBRATION |
| 560 | void recalibrate_iodelay(void) |
| 561 | { |
Nishanth Menon | 8cac147 | 2016-03-15 18:09:17 -0500 | [diff] [blame] | 562 | struct pad_conf_entry const *pads, *delta_pads = NULL; |
Nishanth Menon | 0358923 | 2015-08-13 09:50:59 -0500 | [diff] [blame] | 563 | struct iodelay_cfg_entry const *iodelay; |
Nishanth Menon | 8cac147 | 2016-03-15 18:09:17 -0500 | [diff] [blame] | 564 | int npads, niodelays, delta_npads = 0; |
| 565 | int ret; |
Nishanth Menon | 0358923 | 2015-08-13 09:50:59 -0500 | [diff] [blame] | 566 | |
| 567 | switch (omap_revision()) { |
| 568 | case DRA722_ES1_0: |
Nishanth Menon | 8cac147 | 2016-03-15 18:09:17 -0500 | [diff] [blame] | 569 | case DRA722_ES2_0: |
| 570 | pads = dra72x_core_padconf_array_common; |
| 571 | npads = ARRAY_SIZE(dra72x_core_padconf_array_common); |
| 572 | if (board_is_dra72x_revc_or_later()) { |
| 573 | delta_pads = dra72x_rgmii_padconf_array_revc; |
| 574 | delta_npads = |
| 575 | ARRAY_SIZE(dra72x_rgmii_padconf_array_revc); |
| 576 | iodelay = dra72_iodelay_cfg_array_revc; |
| 577 | niodelays = ARRAY_SIZE(dra72_iodelay_cfg_array_revc); |
| 578 | } else { |
| 579 | delta_pads = dra72x_rgmii_padconf_array_revb; |
| 580 | delta_npads = |
| 581 | ARRAY_SIZE(dra72x_rgmii_padconf_array_revb); |
| 582 | iodelay = dra72_iodelay_cfg_array_revb; |
| 583 | niodelays = ARRAY_SIZE(dra72_iodelay_cfg_array_revb); |
| 584 | } |
Nishanth Menon | 0358923 | 2015-08-13 09:50:59 -0500 | [diff] [blame] | 585 | break; |
| 586 | case DRA752_ES1_0: |
| 587 | case DRA752_ES1_1: |
| 588 | pads = dra74x_core_padconf_array; |
| 589 | npads = ARRAY_SIZE(dra74x_core_padconf_array); |
| 590 | iodelay = dra742_es1_1_iodelay_cfg_array; |
| 591 | niodelays = ARRAY_SIZE(dra742_es1_1_iodelay_cfg_array); |
| 592 | break; |
| 593 | default: |
| 594 | case DRA752_ES2_0: |
| 595 | pads = dra74x_core_padconf_array; |
| 596 | npads = ARRAY_SIZE(dra74x_core_padconf_array); |
| 597 | iodelay = dra742_es2_0_iodelay_cfg_array; |
| 598 | niodelays = ARRAY_SIZE(dra742_es2_0_iodelay_cfg_array); |
Nishanth Menon | 76cff2b | 2015-08-13 09:51:00 -0500 | [diff] [blame] | 599 | /* Setup port1 and port2 for rgmii with 'no-id' mode */ |
| 600 | clrset_spare_register(1, 0, RGMII2_ID_MODE_N_MASK | |
| 601 | RGMII1_ID_MODE_N_MASK); |
Nishanth Menon | 0358923 | 2015-08-13 09:50:59 -0500 | [diff] [blame] | 602 | break; |
Nishanth Menon | 27d170a | 2015-06-04 16:42:39 +0530 | [diff] [blame] | 603 | } |
Nishanth Menon | 8cac147 | 2016-03-15 18:09:17 -0500 | [diff] [blame] | 604 | /* Setup I/O isolation */ |
| 605 | ret = __recalibrate_iodelay_start(); |
| 606 | if (ret) |
| 607 | goto err; |
| 608 | |
| 609 | /* Do the muxing here */ |
| 610 | do_set_mux32((*ctrl)->control_padconf_core_base, pads, npads); |
| 611 | |
| 612 | /* Now do the weird minor deltas that should be safe */ |
| 613 | if (delta_npads) |
| 614 | do_set_mux32((*ctrl)->control_padconf_core_base, |
| 615 | delta_pads, delta_npads); |
| 616 | |
| 617 | /* Setup IOdelay configuration */ |
| 618 | ret = do_set_iodelay((*ctrl)->iodelay_config_base, iodelay, niodelays); |
| 619 | err: |
| 620 | /* Closeup.. remove isolation */ |
| 621 | __recalibrate_iodelay_end(ret); |
Lokesh Vutla | 706dd34 | 2015-06-04 16:42:38 +0530 | [diff] [blame] | 622 | } |
| 623 | #endif |
| 624 | |
Lokesh Vutla | 687054a | 2013-02-12 21:29:08 +0000 | [diff] [blame] | 625 | #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_GENERIC_MMC) |
| 626 | int board_mmc_init(bd_t *bis) |
| 627 | { |
| 628 | omap_mmc_init(0, 0, 0, -1, -1); |
| 629 | omap_mmc_init(1, 0, 0, -1, -1); |
| 630 | return 0; |
| 631 | } |
| 632 | #endif |
Mugunthan V N | b1e26e3 | 2013-07-08 16:04:41 +0530 | [diff] [blame] | 633 | |
Kishon Vijay Abraham I | a17188c | 2015-02-23 18:40:19 +0530 | [diff] [blame] | 634 | #ifdef CONFIG_USB_DWC3 |
| 635 | static struct dwc3_device usb_otg_ss1 = { |
| 636 | .maximum_speed = USB_SPEED_SUPER, |
| 637 | .base = DRA7_USB_OTG_SS1_BASE, |
| 638 | .tx_fifo_resize = false, |
| 639 | .index = 0, |
| 640 | }; |
| 641 | |
| 642 | static struct dwc3_omap_device usb_otg_ss1_glue = { |
| 643 | .base = (void *)DRA7_USB_OTG_SS1_GLUE_BASE, |
| 644 | .utmi_mode = DWC3_OMAP_UTMI_MODE_SW, |
Kishon Vijay Abraham I | a17188c | 2015-02-23 18:40:19 +0530 | [diff] [blame] | 645 | .index = 0, |
| 646 | }; |
| 647 | |
| 648 | static struct ti_usb_phy_device usb_phy1_device = { |
| 649 | .pll_ctrl_base = (void *)DRA7_USB3_PHY1_PLL_CTRL, |
| 650 | .usb2_phy_power = (void *)DRA7_USB2_PHY1_POWER, |
| 651 | .usb3_phy_power = (void *)DRA7_USB3_PHY1_POWER, |
| 652 | .index = 0, |
| 653 | }; |
| 654 | |
| 655 | static struct dwc3_device usb_otg_ss2 = { |
| 656 | .maximum_speed = USB_SPEED_SUPER, |
| 657 | .base = DRA7_USB_OTG_SS2_BASE, |
| 658 | .tx_fifo_resize = false, |
| 659 | .index = 1, |
| 660 | }; |
| 661 | |
| 662 | static struct dwc3_omap_device usb_otg_ss2_glue = { |
| 663 | .base = (void *)DRA7_USB_OTG_SS2_GLUE_BASE, |
| 664 | .utmi_mode = DWC3_OMAP_UTMI_MODE_SW, |
Kishon Vijay Abraham I | a17188c | 2015-02-23 18:40:19 +0530 | [diff] [blame] | 665 | .index = 1, |
| 666 | }; |
| 667 | |
| 668 | static struct ti_usb_phy_device usb_phy2_device = { |
| 669 | .usb2_phy_power = (void *)DRA7_USB2_PHY2_POWER, |
| 670 | .index = 1, |
| 671 | }; |
| 672 | |
| 673 | int board_usb_init(int index, enum usb_init_type init) |
| 674 | { |
Kishon Vijay Abraham I | 6f1af1e | 2015-08-19 16:16:27 +0530 | [diff] [blame] | 675 | enable_usb_clocks(index); |
Kishon Vijay Abraham I | a17188c | 2015-02-23 18:40:19 +0530 | [diff] [blame] | 676 | switch (index) { |
| 677 | case 0: |
| 678 | if (init == USB_INIT_DEVICE) { |
| 679 | usb_otg_ss1.dr_mode = USB_DR_MODE_PERIPHERAL; |
| 680 | usb_otg_ss1_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID; |
| 681 | } else { |
| 682 | usb_otg_ss1.dr_mode = USB_DR_MODE_HOST; |
| 683 | usb_otg_ss1_glue.vbus_id_status = OMAP_DWC3_ID_GROUND; |
| 684 | } |
| 685 | |
| 686 | ti_usb_phy_uboot_init(&usb_phy1_device); |
| 687 | dwc3_omap_uboot_init(&usb_otg_ss1_glue); |
| 688 | dwc3_uboot_init(&usb_otg_ss1); |
| 689 | break; |
| 690 | case 1: |
| 691 | if (init == USB_INIT_DEVICE) { |
| 692 | usb_otg_ss2.dr_mode = USB_DR_MODE_PERIPHERAL; |
| 693 | usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID; |
| 694 | } else { |
| 695 | usb_otg_ss2.dr_mode = USB_DR_MODE_HOST; |
| 696 | usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_ID_GROUND; |
| 697 | } |
| 698 | |
| 699 | ti_usb_phy_uboot_init(&usb_phy2_device); |
| 700 | dwc3_omap_uboot_init(&usb_otg_ss2_glue); |
| 701 | dwc3_uboot_init(&usb_otg_ss2); |
| 702 | break; |
| 703 | default: |
| 704 | printf("Invalid Controller Index\n"); |
| 705 | } |
| 706 | |
| 707 | return 0; |
| 708 | } |
| 709 | |
| 710 | int board_usb_cleanup(int index, enum usb_init_type init) |
| 711 | { |
| 712 | switch (index) { |
| 713 | case 0: |
| 714 | case 1: |
| 715 | ti_usb_phy_uboot_exit(index); |
| 716 | dwc3_uboot_exit(index); |
| 717 | dwc3_omap_uboot_exit(index); |
| 718 | break; |
| 719 | default: |
| 720 | printf("Invalid Controller Index\n"); |
| 721 | } |
Kishon Vijay Abraham I | 6f1af1e | 2015-08-19 16:16:27 +0530 | [diff] [blame] | 722 | disable_usb_clocks(index); |
Kishon Vijay Abraham I | a17188c | 2015-02-23 18:40:19 +0530 | [diff] [blame] | 723 | return 0; |
| 724 | } |
| 725 | |
Kishon Vijay Abraham I | 2d48aa6 | 2015-02-23 18:40:23 +0530 | [diff] [blame] | 726 | int usb_gadget_handle_interrupts(int index) |
Kishon Vijay Abraham I | a17188c | 2015-02-23 18:40:19 +0530 | [diff] [blame] | 727 | { |
| 728 | u32 status; |
| 729 | |
Kishon Vijay Abraham I | 2d48aa6 | 2015-02-23 18:40:23 +0530 | [diff] [blame] | 730 | status = dwc3_omap_uboot_interrupt_status(index); |
Kishon Vijay Abraham I | a17188c | 2015-02-23 18:40:19 +0530 | [diff] [blame] | 731 | if (status) |
Kishon Vijay Abraham I | 2d48aa6 | 2015-02-23 18:40:23 +0530 | [diff] [blame] | 732 | dwc3_uboot_handle_interrupt(index); |
Kishon Vijay Abraham I | a17188c | 2015-02-23 18:40:19 +0530 | [diff] [blame] | 733 | |
| 734 | return 0; |
| 735 | } |
| 736 | #endif |
| 737 | |
Tom Rini | 79b079f | 2014-04-03 07:52:56 -0400 | [diff] [blame] | 738 | #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OS_BOOT) |
| 739 | int spl_start_uboot(void) |
| 740 | { |
| 741 | /* break into full u-boot on 'c' */ |
| 742 | if (serial_tstc() && serial_getc() == 'c') |
| 743 | return 1; |
| 744 | |
| 745 | #ifdef CONFIG_SPL_ENV_SUPPORT |
| 746 | env_init(); |
| 747 | env_relocate_spec(); |
| 748 | if (getenv_yesno("boot_os") != 1) |
| 749 | return 1; |
| 750 | #endif |
| 751 | |
| 752 | return 0; |
| 753 | } |
| 754 | #endif |
| 755 | |
Mugunthan V N | b1e26e3 | 2013-07-08 16:04:41 +0530 | [diff] [blame] | 756 | #ifdef CONFIG_DRIVER_TI_CPSW |
Mugunthan V N | 4c8014b | 2014-05-22 14:37:12 +0530 | [diff] [blame] | 757 | extern u32 *const omap_si_rev; |
| 758 | |
Mugunthan V N | b1e26e3 | 2013-07-08 16:04:41 +0530 | [diff] [blame] | 759 | static void cpsw_control(int enabled) |
| 760 | { |
| 761 | /* VTP can be added here */ |
| 762 | |
| 763 | return; |
| 764 | } |
| 765 | |
| 766 | static struct cpsw_slave_data cpsw_slaves[] = { |
| 767 | { |
| 768 | .slave_reg_ofs = 0x208, |
| 769 | .sliver_reg_ofs = 0xd80, |
Mugunthan V N | 9c653aa | 2014-02-18 07:31:52 -0500 | [diff] [blame] | 770 | .phy_addr = 2, |
Mugunthan V N | b1e26e3 | 2013-07-08 16:04:41 +0530 | [diff] [blame] | 771 | }, |
| 772 | { |
| 773 | .slave_reg_ofs = 0x308, |
| 774 | .sliver_reg_ofs = 0xdc0, |
Mugunthan V N | 9c653aa | 2014-02-18 07:31:52 -0500 | [diff] [blame] | 775 | .phy_addr = 3, |
Mugunthan V N | b1e26e3 | 2013-07-08 16:04:41 +0530 | [diff] [blame] | 776 | }, |
| 777 | }; |
| 778 | |
| 779 | static struct cpsw_platform_data cpsw_data = { |
| 780 | .mdio_base = CPSW_MDIO_BASE, |
| 781 | .cpsw_base = CPSW_BASE, |
| 782 | .mdio_div = 0xff, |
| 783 | .channels = 8, |
| 784 | .cpdma_reg_ofs = 0x800, |
Mugunthan V N | 4c8014b | 2014-05-22 14:37:12 +0530 | [diff] [blame] | 785 | .slaves = 2, |
Mugunthan V N | b1e26e3 | 2013-07-08 16:04:41 +0530 | [diff] [blame] | 786 | .slave_data = cpsw_slaves, |
| 787 | .ale_reg_ofs = 0xd00, |
| 788 | .ale_entries = 1024, |
| 789 | .host_port_reg_ofs = 0x108, |
| 790 | .hw_stats_reg_ofs = 0x900, |
| 791 | .bd_ram_ofs = 0x2000, |
| 792 | .mac_control = (1 << 5), |
| 793 | .control = cpsw_control, |
| 794 | .host_port_num = 0, |
| 795 | .version = CPSW_CTRL_VERSION_2, |
| 796 | }; |
| 797 | |
| 798 | int board_eth_init(bd_t *bis) |
| 799 | { |
| 800 | int ret; |
| 801 | uint8_t mac_addr[6]; |
| 802 | uint32_t mac_hi, mac_lo; |
| 803 | uint32_t ctrl_val; |
Mugunthan V N | b1e26e3 | 2013-07-08 16:04:41 +0530 | [diff] [blame] | 804 | |
| 805 | /* try reading mac address from efuse */ |
| 806 | mac_lo = readl((*ctrl)->control_core_mac_id_0_lo); |
| 807 | mac_hi = readl((*ctrl)->control_core_mac_id_0_hi); |
Mugunthan V N | e0a1d59 | 2014-01-07 19:57:38 +0530 | [diff] [blame] | 808 | mac_addr[0] = (mac_hi & 0xFF0000) >> 16; |
Mugunthan V N | b1e26e3 | 2013-07-08 16:04:41 +0530 | [diff] [blame] | 809 | mac_addr[1] = (mac_hi & 0xFF00) >> 8; |
Mugunthan V N | e0a1d59 | 2014-01-07 19:57:38 +0530 | [diff] [blame] | 810 | mac_addr[2] = mac_hi & 0xFF; |
| 811 | mac_addr[3] = (mac_lo & 0xFF0000) >> 16; |
Mugunthan V N | b1e26e3 | 2013-07-08 16:04:41 +0530 | [diff] [blame] | 812 | mac_addr[4] = (mac_lo & 0xFF00) >> 8; |
Mugunthan V N | e0a1d59 | 2014-01-07 19:57:38 +0530 | [diff] [blame] | 813 | mac_addr[5] = mac_lo & 0xFF; |
Mugunthan V N | b1e26e3 | 2013-07-08 16:04:41 +0530 | [diff] [blame] | 814 | |
| 815 | if (!getenv("ethaddr")) { |
| 816 | printf("<ethaddr> not set. Validating first E-fuse MAC\n"); |
| 817 | |
Joe Hershberger | 0adb5b7 | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 818 | if (is_valid_ethaddr(mac_addr)) |
Mugunthan V N | b1e26e3 | 2013-07-08 16:04:41 +0530 | [diff] [blame] | 819 | eth_setenv_enetaddr("ethaddr", mac_addr); |
| 820 | } |
Mugunthan V N | 8feb37b | 2014-02-18 07:31:56 -0500 | [diff] [blame] | 821 | |
| 822 | mac_lo = readl((*ctrl)->control_core_mac_id_1_lo); |
| 823 | mac_hi = readl((*ctrl)->control_core_mac_id_1_hi); |
| 824 | mac_addr[0] = (mac_hi & 0xFF0000) >> 16; |
| 825 | mac_addr[1] = (mac_hi & 0xFF00) >> 8; |
| 826 | mac_addr[2] = mac_hi & 0xFF; |
| 827 | mac_addr[3] = (mac_lo & 0xFF0000) >> 16; |
| 828 | mac_addr[4] = (mac_lo & 0xFF00) >> 8; |
| 829 | mac_addr[5] = mac_lo & 0xFF; |
| 830 | |
| 831 | if (!getenv("eth1addr")) { |
Joe Hershberger | 0adb5b7 | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 832 | if (is_valid_ethaddr(mac_addr)) |
Mugunthan V N | 8feb37b | 2014-02-18 07:31:56 -0500 | [diff] [blame] | 833 | eth_setenv_enetaddr("eth1addr", mac_addr); |
| 834 | } |
| 835 | |
Mugunthan V N | b1e26e3 | 2013-07-08 16:04:41 +0530 | [diff] [blame] | 836 | ctrl_val = readl((*ctrl)->control_core_control_io1) & (~0x33); |
| 837 | ctrl_val |= 0x22; |
| 838 | writel(ctrl_val, (*ctrl)->control_core_control_io1); |
| 839 | |
Mugunthan V N | 4c8014b | 2014-05-22 14:37:12 +0530 | [diff] [blame] | 840 | if (*omap_si_rev == DRA722_ES1_0) |
| 841 | cpsw_data.active_slave = 1; |
| 842 | |
Dan Murphy | 39fbac9 | 2016-03-30 12:58:37 -0500 | [diff] [blame] | 843 | if (board_is_dra72x_revc_or_later()) { |
| 844 | cpsw_slaves[0].phy_if = PHY_INTERFACE_MODE_RGMII_ID; |
| 845 | cpsw_slaves[1].phy_if = PHY_INTERFACE_MODE_RGMII_ID; |
| 846 | } |
| 847 | |
Mugunthan V N | b1e26e3 | 2013-07-08 16:04:41 +0530 | [diff] [blame] | 848 | ret = cpsw_register(&cpsw_data); |
| 849 | if (ret < 0) |
| 850 | printf("Error %d registering CPSW switch\n", ret); |
| 851 | |
| 852 | return ret; |
| 853 | } |
| 854 | #endif |
Lokesh Vutla | 7b92252 | 2014-08-04 19:42:24 +0530 | [diff] [blame] | 855 | |
| 856 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 857 | /* VTT regulator enable */ |
| 858 | static inline void vtt_regulator_enable(void) |
| 859 | { |
| 860 | if (omap_hw_init_context() == OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL) |
| 861 | return; |
| 862 | |
| 863 | /* Do not enable VTT for DRA722 */ |
Ravi Babu | 6b1c14b | 2016-03-15 18:09:14 -0500 | [diff] [blame] | 864 | if (is_dra72x()) |
Lokesh Vutla | 7b92252 | 2014-08-04 19:42:24 +0530 | [diff] [blame] | 865 | return; |
| 866 | |
| 867 | /* |
| 868 | * EVM Rev G and later use gpio7_11 for DDR3 termination. |
| 869 | * This is safe enough to do on older revs. |
| 870 | */ |
| 871 | gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en"); |
| 872 | gpio_direction_output(GPIO_DDR_VTT_EN, 1); |
| 873 | } |
| 874 | |
| 875 | int board_early_init_f(void) |
| 876 | { |
| 877 | vtt_regulator_enable(); |
| 878 | return 0; |
| 879 | } |
| 880 | #endif |
Daniel Allred | 62a09f0 | 2016-05-19 19:10:54 -0500 | [diff] [blame] | 881 | |
| 882 | #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) |
| 883 | int ft_board_setup(void *blob, bd_t *bd) |
| 884 | { |
| 885 | ft_cpu_setup(blob, bd); |
| 886 | |
| 887 | return 0; |
| 888 | } |
| 889 | #endif |
Lokesh Vutla | 09da87d | 2016-05-16 10:51:23 +0530 | [diff] [blame] | 890 | |
| 891 | #ifdef CONFIG_SPL_LOAD_FIT |
| 892 | int board_fit_config_name_match(const char *name) |
| 893 | { |
Mugunthan V N | e813138 | 2016-09-27 13:01:41 +0530 | [diff] [blame] | 894 | if (is_dra72x()) { |
| 895 | if (board_is_dra72x_revc_or_later()) { |
| 896 | if (!strcmp(name, "dra72-evm-revc")) |
| 897 | return 0; |
| 898 | } else if (!strcmp(name, "dra72-evm")) { |
| 899 | return 0; |
| 900 | } |
| 901 | } else if (!is_dra72x() && !strcmp(name, "dra7-evm")) { |
Lokesh Vutla | 09da87d | 2016-05-16 10:51:23 +0530 | [diff] [blame] | 902 | return 0; |
Mugunthan V N | e813138 | 2016-09-27 13:01:41 +0530 | [diff] [blame] | 903 | } |
| 904 | |
| 905 | return -1; |
Lokesh Vutla | 09da87d | 2016-05-16 10:51:23 +0530 | [diff] [blame] | 906 | } |
| 907 | #endif |
Andreas Dannenberg | 17c2987 | 2016-06-27 09:19:22 -0500 | [diff] [blame] | 908 | |
| 909 | #ifdef CONFIG_TI_SECURE_DEVICE |
| 910 | void board_fit_image_post_process(void **p_image, size_t *p_size) |
| 911 | { |
| 912 | secure_boot_verify_image(p_image, p_size); |
| 913 | } |
Andrew F. Davis | 0fcc5207 | 2016-11-29 16:33:25 -0600 | [diff] [blame] | 914 | |
| 915 | void board_tee_image_process(ulong tee_image, size_t tee_size) |
| 916 | { |
| 917 | secure_tee_install((u32)tee_image); |
| 918 | } |
| 919 | |
| 920 | U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_TEE, board_tee_image_process); |
Andreas Dannenberg | 17c2987 | 2016-06-27 09:19:22 -0500 | [diff] [blame] | 921 | #endif |