Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 2 | /* |
| 3 | * K2G EVM : Board initialization |
| 4 | * |
| 5 | * (C) Copyright 2015 |
| 6 | * Texas Instruments Incorporated, <www.ti.com> |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 7 | */ |
| 8 | #include <common.h> |
Simon Glass | eba6b8d | 2019-11-14 12:57:50 -0700 | [diff] [blame] | 9 | #include <eeprom.h> |
Simon Glass | 6eaea25 | 2019-08-01 09:46:48 -0600 | [diff] [blame] | 10 | #include <env.h> |
Simon Glass | f11478f | 2019-12-28 10:45:07 -0700 | [diff] [blame] | 11 | #include <hang.h> |
Simon Glass | 2dc9c34 | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 12 | #include <image.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 13 | #include <init.h> |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 14 | #include <asm/arch/clock.h> |
Vitaly Andrianov | cafc8f4 | 2015-09-19 16:26:52 +0530 | [diff] [blame] | 15 | #include <asm/ti-common/keystone_net.h> |
Roger Quadros | 44157de | 2015-09-19 16:26:53 +0530 | [diff] [blame] | 16 | #include <asm/arch/psc_defs.h> |
| 17 | #include <asm/arch/mmc_host_def.h> |
Cooper Jr., Franklin | 74f22ca | 2017-06-16 17:25:15 -0500 | [diff] [blame] | 18 | #include <fdtdec.h> |
| 19 | #include <i2c.h> |
Andrew F. Davis | eab8f40 | 2017-07-31 10:58:21 -0500 | [diff] [blame] | 20 | #include <remoteproc.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 21 | #include <linux/bitops.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 22 | #include <linux/delay.h> |
Vitaly Andrianov | 680ec77 | 2015-09-19 16:26:45 +0530 | [diff] [blame] | 23 | #include "mux-k2g.h" |
Roger Quadros | 601ab90 | 2017-03-13 15:04:32 +0200 | [diff] [blame] | 24 | #include "../common/board_detect.h" |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 25 | |
Cooper Jr., Franklin | 74f22ca | 2017-06-16 17:25:15 -0500 | [diff] [blame] | 26 | #define K2G_GP_AUDIO_CODEC_ADDRESS 0x1B |
| 27 | |
Lokesh Vutla | e22e764 | 2017-05-03 16:58:25 +0530 | [diff] [blame] | 28 | const unsigned int sysclk_array[MAX_SYSCLK] = { |
| 29 | 19200000, |
| 30 | 24000000, |
| 31 | 25000000, |
| 32 | 26000000, |
| 33 | }; |
| 34 | |
Lokesh Vutla | a9a0e12 | 2017-05-03 16:58:26 +0530 | [diff] [blame] | 35 | unsigned int get_external_clk(u32 clk) |
| 36 | { |
| 37 | unsigned int clk_freq; |
| 38 | u8 sysclk_index = get_sysclk_index(); |
| 39 | |
| 40 | switch (clk) { |
| 41 | case sys_clk: |
| 42 | clk_freq = sysclk_array[sysclk_index]; |
| 43 | break; |
| 44 | case pa_clk: |
| 45 | clk_freq = sysclk_array[sysclk_index]; |
| 46 | break; |
| 47 | case tetris_clk: |
| 48 | clk_freq = sysclk_array[sysclk_index]; |
| 49 | break; |
| 50 | case ddr3a_clk: |
| 51 | clk_freq = sysclk_array[sysclk_index]; |
| 52 | break; |
| 53 | case uart_clk: |
| 54 | clk_freq = sysclk_array[sysclk_index]; |
| 55 | break; |
| 56 | default: |
| 57 | clk_freq = 0; |
| 58 | break; |
| 59 | } |
| 60 | |
| 61 | return clk_freq; |
| 62 | } |
Vitaly Andrianov | 7fd5b64 | 2015-09-19 16:26:41 +0530 | [diff] [blame] | 63 | |
Rex Chang | 4df43d4 | 2017-12-28 20:39:59 +0530 | [diff] [blame] | 64 | int speeds[DEVSPEED_NUMSPDS] = { |
Lokesh Vutla | 9027e08 | 2016-03-04 10:36:41 -0600 | [diff] [blame] | 65 | SPD400, |
| 66 | SPD600, |
| 67 | SPD800, |
| 68 | SPD900, |
| 69 | SPD1000, |
| 70 | SPD900, |
| 71 | SPD800, |
| 72 | SPD600, |
| 73 | SPD400, |
| 74 | SPD200, |
| 75 | }; |
| 76 | |
| 77 | static int dev_speeds[DEVSPEED_NUMSPDS] = { |
| 78 | SPD600, |
| 79 | SPD800, |
| 80 | SPD900, |
| 81 | SPD1000, |
| 82 | SPD900, |
| 83 | SPD800, |
| 84 | SPD600, |
| 85 | SPD400, |
| 86 | }; |
| 87 | |
Lokesh Vutla | e22e764 | 2017-05-03 16:58:25 +0530 | [diff] [blame] | 88 | static struct pll_init_data main_pll_config[MAX_SYSCLK][NUM_SPDS] = { |
| 89 | [SYSCLK_19MHz] = { |
| 90 | [SPD400] = {MAIN_PLL, 125, 3, 2}, |
| 91 | [SPD600] = {MAIN_PLL, 125, 2, 2}, |
| 92 | [SPD800] = {MAIN_PLL, 250, 3, 2}, |
Lokesh Vutla | 318735b | 2017-05-20 05:49:27 +0530 | [diff] [blame] | 93 | [SPD900] = {MAIN_PLL, 187, 2, 2}, |
| 94 | [SPD1000] = {MAIN_PLL, 104, 1, 2}, |
Lokesh Vutla | e22e764 | 2017-05-03 16:58:25 +0530 | [diff] [blame] | 95 | }, |
| 96 | [SYSCLK_24MHz] = { |
| 97 | [SPD400] = {MAIN_PLL, 100, 3, 2}, |
| 98 | [SPD600] = {MAIN_PLL, 300, 6, 2}, |
| 99 | [SPD800] = {MAIN_PLL, 200, 3, 2}, |
Lokesh Vutla | 318735b | 2017-05-20 05:49:27 +0530 | [diff] [blame] | 100 | [SPD900] = {MAIN_PLL, 75, 1, 2}, |
| 101 | [SPD1000] = {MAIN_PLL, 250, 3, 2}, |
Lokesh Vutla | e22e764 | 2017-05-03 16:58:25 +0530 | [diff] [blame] | 102 | }, |
| 103 | [SYSCLK_25MHz] = { |
| 104 | [SPD400] = {MAIN_PLL, 32, 1, 2}, |
| 105 | [SPD600] = {MAIN_PLL, 48, 1, 2}, |
| 106 | [SPD800] = {MAIN_PLL, 64, 1, 2}, |
Lokesh Vutla | 318735b | 2017-05-20 05:49:27 +0530 | [diff] [blame] | 107 | [SPD900] = {MAIN_PLL, 72, 1, 2}, |
| 108 | [SPD1000] = {MAIN_PLL, 80, 1, 2}, |
Lokesh Vutla | e22e764 | 2017-05-03 16:58:25 +0530 | [diff] [blame] | 109 | }, |
| 110 | [SYSCLK_26MHz] = { |
| 111 | [SPD400] = {MAIN_PLL, 400, 13, 2}, |
| 112 | [SPD600] = {MAIN_PLL, 230, 5, 2}, |
| 113 | [SPD800] = {MAIN_PLL, 123, 2, 2}, |
Lokesh Vutla | 318735b | 2017-05-20 05:49:27 +0530 | [diff] [blame] | 114 | [SPD900] = {MAIN_PLL, 69, 1, 2}, |
| 115 | [SPD1000] = {MAIN_PLL, 384, 5, 2}, |
Lokesh Vutla | e22e764 | 2017-05-03 16:58:25 +0530 | [diff] [blame] | 116 | }, |
Lokesh Vutla | 9027e08 | 2016-03-04 10:36:41 -0600 | [diff] [blame] | 117 | }; |
| 118 | |
Lokesh Vutla | e22e764 | 2017-05-03 16:58:25 +0530 | [diff] [blame] | 119 | static struct pll_init_data tetris_pll_config[MAX_SYSCLK][NUM_SPDS] = { |
| 120 | [SYSCLK_19MHz] = { |
| 121 | [SPD200] = {TETRIS_PLL, 625, 6, 10}, |
| 122 | [SPD400] = {TETRIS_PLL, 125, 1, 6}, |
| 123 | [SPD600] = {TETRIS_PLL, 125, 1, 4}, |
| 124 | [SPD800] = {TETRIS_PLL, 333, 2, 4}, |
| 125 | [SPD900] = {TETRIS_PLL, 187, 2, 2}, |
| 126 | [SPD1000] = {TETRIS_PLL, 104, 1, 2}, |
| 127 | }, |
| 128 | [SYSCLK_24MHz] = { |
| 129 | [SPD200] = {TETRIS_PLL, 250, 3, 10}, |
| 130 | [SPD400] = {TETRIS_PLL, 100, 1, 6}, |
| 131 | [SPD600] = {TETRIS_PLL, 100, 1, 4}, |
| 132 | [SPD800] = {TETRIS_PLL, 400, 3, 4}, |
| 133 | [SPD900] = {TETRIS_PLL, 75, 1, 2}, |
| 134 | [SPD1000] = {TETRIS_PLL, 250, 3, 2}, |
| 135 | }, |
| 136 | [SYSCLK_25MHz] = { |
| 137 | [SPD200] = {TETRIS_PLL, 80, 1, 10}, |
| 138 | [SPD400] = {TETRIS_PLL, 96, 1, 6}, |
| 139 | [SPD600] = {TETRIS_PLL, 96, 1, 4}, |
| 140 | [SPD800] = {TETRIS_PLL, 128, 1, 4}, |
| 141 | [SPD900] = {TETRIS_PLL, 72, 1, 2}, |
| 142 | [SPD1000] = {TETRIS_PLL, 80, 1, 2}, |
| 143 | }, |
| 144 | [SYSCLK_26MHz] = { |
| 145 | [SPD200] = {TETRIS_PLL, 307, 4, 10}, |
| 146 | [SPD400] = {TETRIS_PLL, 369, 4, 6}, |
| 147 | [SPD600] = {TETRIS_PLL, 369, 4, 4}, |
| 148 | [SPD800] = {TETRIS_PLL, 123, 1, 4}, |
| 149 | [SPD900] = {TETRIS_PLL, 69, 1, 2}, |
| 150 | [SPD1000] = {TETRIS_PLL, 384, 5, 2}, |
| 151 | }, |
Lokesh Vutla | 9027e08 | 2016-03-04 10:36:41 -0600 | [diff] [blame] | 152 | }; |
| 153 | |
Lokesh Vutla | e22e764 | 2017-05-03 16:58:25 +0530 | [diff] [blame] | 154 | static struct pll_init_data uart_pll_config[MAX_SYSCLK] = { |
| 155 | [SYSCLK_19MHz] = {UART_PLL, 160, 1, 8}, |
| 156 | [SYSCLK_24MHz] = {UART_PLL, 128, 1, 8}, |
| 157 | [SYSCLK_25MHz] = {UART_PLL, 768, 5, 10}, |
| 158 | [SYSCLK_26MHz] = {UART_PLL, 384, 13, 2}, |
| 159 | }; |
| 160 | |
| 161 | static struct pll_init_data nss_pll_config[MAX_SYSCLK] = { |
| 162 | [SYSCLK_19MHz] = {NSS_PLL, 625, 6, 2}, |
| 163 | [SYSCLK_24MHz] = {NSS_PLL, 250, 3, 2}, |
| 164 | [SYSCLK_25MHz] = {NSS_PLL, 80, 1, 2}, |
| 165 | [SYSCLK_26MHz] = {NSS_PLL, 1000, 13, 2}, |
| 166 | }; |
| 167 | |
Rex Chang | 4df43d4 | 2017-12-28 20:39:59 +0530 | [diff] [blame] | 168 | static struct pll_init_data ddr3_pll_config_800[MAX_SYSCLK] = { |
Lokesh Vutla | e22e764 | 2017-05-03 16:58:25 +0530 | [diff] [blame] | 169 | [SYSCLK_19MHz] = {DDR3A_PLL, 167, 1, 16}, |
| 170 | [SYSCLK_24MHz] = {DDR3A_PLL, 133, 1, 16}, |
| 171 | [SYSCLK_25MHz] = {DDR3A_PLL, 128, 1, 16}, |
| 172 | [SYSCLK_26MHz] = {DDR3A_PLL, 123, 1, 16}, |
| 173 | }; |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 174 | |
Rex Chang | 4df43d4 | 2017-12-28 20:39:59 +0530 | [diff] [blame] | 175 | static struct pll_init_data ddr3_pll_config_1066[MAX_SYSCLK] = { |
| 176 | [SYSCLK_19MHz] = {DDR3A_PLL, 194, 1, 14}, |
| 177 | [SYSCLK_24MHz] = {DDR3A_PLL, 156, 1, 14}, |
| 178 | [SYSCLK_25MHz] = {DDR3A_PLL, 149, 1, 14}, |
| 179 | [SYSCLK_26MHz] = {DDR3A_PLL, 144, 1, 14}, |
| 180 | }; |
| 181 | |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 182 | struct pll_init_data *get_pll_init_data(int pll) |
| 183 | { |
Lokesh Vutla | 9027e08 | 2016-03-04 10:36:41 -0600 | [diff] [blame] | 184 | int speed; |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 185 | struct pll_init_data *data = NULL; |
Lokesh Vutla | e22e764 | 2017-05-03 16:58:25 +0530 | [diff] [blame] | 186 | u8 sysclk_index = get_sysclk_index(); |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 187 | |
| 188 | switch (pll) { |
| 189 | case MAIN_PLL: |
Lokesh Vutla | 9027e08 | 2016-03-04 10:36:41 -0600 | [diff] [blame] | 190 | speed = get_max_dev_speed(dev_speeds); |
Lokesh Vutla | e22e764 | 2017-05-03 16:58:25 +0530 | [diff] [blame] | 191 | data = &main_pll_config[sysclk_index][speed]; |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 192 | break; |
| 193 | case TETRIS_PLL: |
Rex Chang | 4df43d4 | 2017-12-28 20:39:59 +0530 | [diff] [blame] | 194 | speed = get_max_arm_speed(speeds); |
Lokesh Vutla | e22e764 | 2017-05-03 16:58:25 +0530 | [diff] [blame] | 195 | data = &tetris_pll_config[sysclk_index][speed]; |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 196 | break; |
| 197 | case NSS_PLL: |
Lokesh Vutla | e22e764 | 2017-05-03 16:58:25 +0530 | [diff] [blame] | 198 | data = &nss_pll_config[sysclk_index]; |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 199 | break; |
| 200 | case UART_PLL: |
Lokesh Vutla | e22e764 | 2017-05-03 16:58:25 +0530 | [diff] [blame] | 201 | data = &uart_pll_config[sysclk_index]; |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 202 | break; |
| 203 | case DDR3_PLL: |
Rex Chang | 4df43d4 | 2017-12-28 20:39:59 +0530 | [diff] [blame] | 204 | if (cpu_revision() & CPU_66AK2G1x) { |
| 205 | speed = get_max_arm_speed(speeds); |
| 206 | if (speed == SPD1000) |
| 207 | data = &ddr3_pll_config_1066[sysclk_index]; |
| 208 | else |
| 209 | data = &ddr3_pll_config_800[sysclk_index]; |
| 210 | } else { |
| 211 | data = &ddr3_pll_config_800[sysclk_index]; |
| 212 | } |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 213 | break; |
| 214 | default: |
| 215 | data = NULL; |
| 216 | } |
| 217 | |
| 218 | return data; |
| 219 | } |
| 220 | |
| 221 | s16 divn_val[16] = { |
| 222 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 |
| 223 | }; |
| 224 | |
Masahiro Yamada | 0a78017 | 2017-05-09 20:31:39 +0900 | [diff] [blame] | 225 | #if defined(CONFIG_MMC) |
Roger Quadros | 44157de | 2015-09-19 16:26:53 +0530 | [diff] [blame] | 226 | int board_mmc_init(bd_t *bis) |
| 227 | { |
| 228 | if (psc_enable_module(KS2_LPSC_MMC)) { |
| 229 | printf("%s module enabled failed\n", __func__); |
| 230 | return -1; |
| 231 | } |
| 232 | |
Rex Chang | 4df43d4 | 2017-12-28 20:39:59 +0530 | [diff] [blame] | 233 | if (board_is_k2g_gp() || board_is_k2g_g1()) |
Cooper Jr., Franklin | 16e2897 | 2017-06-16 17:25:26 -0500 | [diff] [blame] | 234 | omap_mmc_init(0, 0, 0, -1, -1); |
| 235 | |
Roger Quadros | 44157de | 2015-09-19 16:26:53 +0530 | [diff] [blame] | 236 | omap_mmc_init(1, 0, 0, -1, -1); |
| 237 | return 0; |
| 238 | } |
| 239 | #endif |
| 240 | |
Jean-Jacques Hiblot | 2037fa4 | 2017-09-15 12:57:24 +0200 | [diff] [blame] | 241 | #if defined(CONFIG_MULTI_DTB_FIT) |
Cooper Jr., Franklin | 43ff224 | 2017-06-16 17:25:16 -0500 | [diff] [blame] | 242 | int board_fit_config_name_match(const char *name) |
| 243 | { |
| 244 | bool eeprom_read = board_ti_was_eeprom_read(); |
| 245 | |
| 246 | if (!strcmp(name, "keystone-k2g-generic") && !eeprom_read) |
| 247 | return 0; |
Rex Chang | 4df43d4 | 2017-12-28 20:39:59 +0530 | [diff] [blame] | 248 | else if (!strcmp(name, "keystone-k2g-evm") && |
| 249 | (board_ti_is("66AK2GGP") || board_ti_is("66AK2GG1"))) |
Cooper Jr., Franklin | 43ff224 | 2017-06-16 17:25:16 -0500 | [diff] [blame] | 250 | return 0; |
Cooper Jr., Franklin | a66a4c7 | 2017-06-16 17:25:32 -0500 | [diff] [blame] | 251 | else if (!strcmp(name, "keystone-k2g-ice") && board_ti_is("66AK2GIC")) |
| 252 | return 0; |
Cooper Jr., Franklin | 43ff224 | 2017-06-16 17:25:16 -0500 | [diff] [blame] | 253 | else |
| 254 | return -1; |
| 255 | } |
| 256 | #endif |
| 257 | |
Cooper Jr., Franklin | 74f22ca | 2017-06-16 17:25:15 -0500 | [diff] [blame] | 258 | #if defined(CONFIG_DTB_RESELECT) |
| 259 | static int k2g_alt_board_detect(void) |
| 260 | { |
Jean-Jacques Hiblot | 52a5151 | 2018-12-07 14:50:49 +0100 | [diff] [blame] | 261 | #ifndef CONFIG_DM_I2C |
Cooper Jr., Franklin | 74f22ca | 2017-06-16 17:25:15 -0500 | [diff] [blame] | 262 | int rc; |
| 263 | |
| 264 | rc = i2c_set_bus_num(1); |
| 265 | if (rc) |
| 266 | return rc; |
| 267 | |
| 268 | rc = i2c_probe(K2G_GP_AUDIO_CODEC_ADDRESS); |
| 269 | if (rc) |
| 270 | return rc; |
Jean-Jacques Hiblot | 52a5151 | 2018-12-07 14:50:49 +0100 | [diff] [blame] | 271 | #else |
| 272 | struct udevice *bus, *dev; |
| 273 | int rc; |
Cooper Jr., Franklin | 74f22ca | 2017-06-16 17:25:15 -0500 | [diff] [blame] | 274 | |
Jean-Jacques Hiblot | 52a5151 | 2018-12-07 14:50:49 +0100 | [diff] [blame] | 275 | rc = uclass_get_device_by_seq(UCLASS_I2C, 1, &bus); |
| 276 | if (rc) |
| 277 | return rc; |
| 278 | rc = dm_i2c_probe(bus, K2G_GP_AUDIO_CODEC_ADDRESS, 0, &dev); |
| 279 | if (rc) |
| 280 | return rc; |
| 281 | #endif |
Cooper Jr., Franklin | 74f22ca | 2017-06-16 17:25:15 -0500 | [diff] [blame] | 282 | ti_i2c_eeprom_am_set("66AK2GGP", "1.0X"); |
| 283 | |
| 284 | return 0; |
| 285 | } |
| 286 | |
Lokesh Vutla | 2f31ff1 | 2016-05-26 19:05:44 +0530 | [diff] [blame] | 287 | static void k2g_reset_mux_config(void) |
| 288 | { |
| 289 | /* Unlock the reset mux register */ |
| 290 | clrbits_le32(KS2_RSTMUX8, RSTMUX_LOCK8_MASK); |
| 291 | |
| 292 | /* Configure BOOTCFG_RSTMUX8 for WDT event to cause a device reset */ |
| 293 | clrsetbits_le32(KS2_RSTMUX8, RSTMUX_OMODE8_MASK, |
| 294 | RSTMUX_OMODE8_DEV_RESET << RSTMUX_OMODE8_SHIFT); |
| 295 | |
| 296 | /* lock the reset mux register to prevent any spurious writes. */ |
| 297 | setbits_le32(KS2_RSTMUX8, RSTMUX_LOCK8_MASK); |
| 298 | } |
| 299 | |
Cooper Jr., Franklin | 3413a58 | 2017-06-16 17:25:17 -0500 | [diff] [blame] | 300 | int embedded_dtb_select(void) |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 301 | { |
Cooper Jr., Franklin | 3413a58 | 2017-06-16 17:25:17 -0500 | [diff] [blame] | 302 | int rc; |
| 303 | rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS, |
| 304 | CONFIG_EEPROM_CHIP_ADDRESS); |
| 305 | if (rc) { |
| 306 | rc = k2g_alt_board_detect(); |
| 307 | if (rc) { |
| 308 | printf("Unable to do board detection\n"); |
| 309 | return -1; |
| 310 | } |
| 311 | } |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 312 | |
Cooper Jr., Franklin | 3413a58 | 2017-06-16 17:25:17 -0500 | [diff] [blame] | 313 | fdtdec_setup(); |
Vitaly Andrianov | 680ec77 | 2015-09-19 16:26:45 +0530 | [diff] [blame] | 314 | |
Cooper Jr., Franklin | f4bfac8 | 2017-06-16 17:25:23 -0500 | [diff] [blame] | 315 | k2g_mux_config(); |
| 316 | |
Lokesh Vutla | 2f31ff1 | 2016-05-26 19:05:44 +0530 | [diff] [blame] | 317 | k2g_reset_mux_config(); |
| 318 | |
Rex Chang | 4df43d4 | 2017-12-28 20:39:59 +0530 | [diff] [blame] | 319 | if (board_is_k2g_gp() || board_is_k2g_g1()) { |
Cooper Jr., Franklin | 16e2897 | 2017-06-16 17:25:26 -0500 | [diff] [blame] | 320 | /* deassert FLASH_HOLD */ |
| 321 | clrbits_le32(K2G_GPIO1_BANK2_BASE + K2G_GPIO_DIR_OFFSET, |
| 322 | BIT(9)); |
| 323 | setbits_le32(K2G_GPIO1_BANK2_BASE + K2G_GPIO_SETDATA_OFFSET, |
| 324 | BIT(9)); |
Murali Karicheri | 420a488 | 2019-02-21 12:02:04 -0500 | [diff] [blame] | 325 | } else if (board_is_k2g_ice()) { |
| 326 | /* GBE Phy workaround. For Phy to latch the input |
| 327 | * configuration, a GPIO reset is asserted at the |
| 328 | * Phy reset pin to latch configuration correctly after SoC |
| 329 | * reset. GPIO0 Pin 10 (Ball AA20) is used for this on ICE |
| 330 | * board. Just do a low to high transition. |
| 331 | */ |
| 332 | clrbits_le32(K2G_GPIO0_BANK0_BASE + K2G_GPIO_DIR_OFFSET, |
| 333 | BIT(10)); |
| 334 | setbits_le32(K2G_GPIO0_BANK0_BASE + K2G_GPIO_CLRDATA_OFFSET, |
| 335 | BIT(10)); |
| 336 | /* Delay just to get a transition to high */ |
| 337 | udelay(100); |
| 338 | setbits_le32(K2G_GPIO0_BANK0_BASE + K2G_GPIO_SETDATA_OFFSET, |
| 339 | BIT(10)); |
Cooper Jr., Franklin | 16e2897 | 2017-06-16 17:25:26 -0500 | [diff] [blame] | 340 | } |
Lokesh Vutla | bd46e0e | 2015-09-19 16:26:54 +0530 | [diff] [blame] | 341 | |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 342 | return 0; |
| 343 | } |
| 344 | #endif |
| 345 | |
Roger Quadros | 601ab90 | 2017-03-13 15:04:32 +0200 | [diff] [blame] | 346 | #ifdef CONFIG_BOARD_LATE_INIT |
| 347 | int board_late_init(void) |
| 348 | { |
| 349 | #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_TI_I2C_BOARD_DETECT) |
| 350 | int rc; |
| 351 | |
| 352 | rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS, |
| 353 | CONFIG_EEPROM_CHIP_ADDRESS); |
| 354 | if (rc) |
| 355 | printf("ti_i2c_eeprom_init failed %d\n", rc); |
| 356 | |
| 357 | board_ti_set_ethaddr(1); |
| 358 | #endif |
| 359 | |
Cooper Jr., Franklin | 7e2edb4 | 2017-06-16 17:25:27 -0500 | [diff] [blame] | 360 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
| 361 | if (board_is_k2g_gp()) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 362 | env_set("board_name", "66AK2GGP\0"); |
Rex Chang | 4df43d4 | 2017-12-28 20:39:59 +0530 | [diff] [blame] | 363 | else if (board_is_k2g_g1()) |
| 364 | env_set("board_name", "66AK2GG1\0"); |
Cooper Jr., Franklin | 7e2edb4 | 2017-06-16 17:25:27 -0500 | [diff] [blame] | 365 | else if (board_is_k2g_ice()) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 366 | env_set("board_name", "66AK2GIC\0"); |
Cooper Jr., Franklin | 7e2edb4 | 2017-06-16 17:25:27 -0500 | [diff] [blame] | 367 | #endif |
Cooper Jr., Franklin | 3413a58 | 2017-06-16 17:25:17 -0500 | [diff] [blame] | 368 | return 0; |
| 369 | } |
| 370 | #endif |
| 371 | |
| 372 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 373 | int board_early_init_f(void) |
| 374 | { |
| 375 | init_plls(); |
| 376 | |
| 377 | k2g_mux_config(); |
| 378 | |
Roger Quadros | 601ab90 | 2017-03-13 15:04:32 +0200 | [diff] [blame] | 379 | return 0; |
| 380 | } |
| 381 | #endif |
| 382 | |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 383 | #ifdef CONFIG_SPL_BUILD |
| 384 | void spl_init_keystone_plls(void) |
| 385 | { |
| 386 | init_plls(); |
| 387 | } |
| 388 | #endif |
Vitaly Andrianov | cafc8f4 | 2015-09-19 16:26:52 +0530 | [diff] [blame] | 389 | |
Andrew F. Davis | eab8f40 | 2017-07-31 10:58:21 -0500 | [diff] [blame] | 390 | #ifdef CONFIG_TI_SECURE_DEVICE |
| 391 | void board_pmmc_image_process(ulong pmmc_image, size_t pmmc_size) |
| 392 | { |
Andrew F. Davis | a75e8a8 | 2018-02-14 11:53:38 -0600 | [diff] [blame] | 393 | int id = env_get_ulong("dev_pmmc", 10, 0); |
Andrew F. Davis | eab8f40 | 2017-07-31 10:58:21 -0500 | [diff] [blame] | 394 | int ret; |
| 395 | |
| 396 | if (!rproc_is_initialized()) |
| 397 | rproc_init(); |
| 398 | |
| 399 | ret = rproc_load(id, pmmc_image, pmmc_size); |
| 400 | printf("Load Remote Processor %d with data@addr=0x%08lx %u bytes:%s\n", |
| 401 | id, pmmc_image, pmmc_size, ret ? " Failed!" : " Success!"); |
| 402 | |
| 403 | if (!ret) |
| 404 | rproc_start(id); |
| 405 | } |
| 406 | |
| 407 | U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_PMMC, board_pmmc_image_process); |
| 408 | #endif |