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) |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 226 | int board_mmc_init(struct bd_info *bis) |
Roger Quadros | 44157de | 2015-09-19 16:26:53 +0530 | [diff] [blame] | 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; |
Lokesh Vutla | ac38c92 | 2020-12-17 22:58:07 +0530 | [diff] [blame] | 251 | else if (!strcmp(name, "keystone-k2g-ice") && |
| 252 | (board_ti_is("66AK2GIC") || board_is_k2g_i1())) |
Cooper Jr., Franklin | a66a4c7 | 2017-06-16 17:25:32 -0500 | [diff] [blame] | 253 | return 0; |
Cooper Jr., Franklin | 43ff224 | 2017-06-16 17:25:16 -0500 | [diff] [blame] | 254 | else |
| 255 | return -1; |
| 256 | } |
| 257 | #endif |
| 258 | |
Cooper Jr., Franklin | 74f22ca | 2017-06-16 17:25:15 -0500 | [diff] [blame] | 259 | #if defined(CONFIG_DTB_RESELECT) |
| 260 | static int k2g_alt_board_detect(void) |
| 261 | { |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame^] | 262 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Cooper Jr., Franklin | 74f22ca | 2017-06-16 17:25:15 -0500 | [diff] [blame] | 263 | int rc; |
| 264 | |
| 265 | rc = i2c_set_bus_num(1); |
| 266 | if (rc) |
| 267 | return rc; |
| 268 | |
| 269 | rc = i2c_probe(K2G_GP_AUDIO_CODEC_ADDRESS); |
| 270 | if (rc) |
| 271 | return rc; |
Jean-Jacques Hiblot | 52a5151 | 2018-12-07 14:50:49 +0100 | [diff] [blame] | 272 | #else |
| 273 | struct udevice *bus, *dev; |
| 274 | int rc; |
Cooper Jr., Franklin | 74f22ca | 2017-06-16 17:25:15 -0500 | [diff] [blame] | 275 | |
Jean-Jacques Hiblot | 52a5151 | 2018-12-07 14:50:49 +0100 | [diff] [blame] | 276 | rc = uclass_get_device_by_seq(UCLASS_I2C, 1, &bus); |
| 277 | if (rc) |
| 278 | return rc; |
| 279 | rc = dm_i2c_probe(bus, K2G_GP_AUDIO_CODEC_ADDRESS, 0, &dev); |
| 280 | if (rc) |
| 281 | return rc; |
| 282 | #endif |
Cooper Jr., Franklin | 74f22ca | 2017-06-16 17:25:15 -0500 | [diff] [blame] | 283 | ti_i2c_eeprom_am_set("66AK2GGP", "1.0X"); |
| 284 | |
| 285 | return 0; |
| 286 | } |
| 287 | |
Lokesh Vutla | 2f31ff1 | 2016-05-26 19:05:44 +0530 | [diff] [blame] | 288 | static void k2g_reset_mux_config(void) |
| 289 | { |
| 290 | /* Unlock the reset mux register */ |
| 291 | clrbits_le32(KS2_RSTMUX8, RSTMUX_LOCK8_MASK); |
| 292 | |
| 293 | /* Configure BOOTCFG_RSTMUX8 for WDT event to cause a device reset */ |
| 294 | clrsetbits_le32(KS2_RSTMUX8, RSTMUX_OMODE8_MASK, |
| 295 | RSTMUX_OMODE8_DEV_RESET << RSTMUX_OMODE8_SHIFT); |
| 296 | |
| 297 | /* lock the reset mux register to prevent any spurious writes. */ |
| 298 | setbits_le32(KS2_RSTMUX8, RSTMUX_LOCK8_MASK); |
| 299 | } |
| 300 | |
Cooper Jr., Franklin | 3413a58 | 2017-06-16 17:25:17 -0500 | [diff] [blame] | 301 | int embedded_dtb_select(void) |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 302 | { |
Cooper Jr., Franklin | 3413a58 | 2017-06-16 17:25:17 -0500 | [diff] [blame] | 303 | int rc; |
| 304 | rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS, |
| 305 | CONFIG_EEPROM_CHIP_ADDRESS); |
| 306 | if (rc) { |
| 307 | rc = k2g_alt_board_detect(); |
| 308 | if (rc) { |
| 309 | printf("Unable to do board detection\n"); |
| 310 | return -1; |
| 311 | } |
| 312 | } |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 313 | |
Cooper Jr., Franklin | 3413a58 | 2017-06-16 17:25:17 -0500 | [diff] [blame] | 314 | fdtdec_setup(); |
Vitaly Andrianov | 680ec77 | 2015-09-19 16:26:45 +0530 | [diff] [blame] | 315 | |
Cooper Jr., Franklin | f4bfac8 | 2017-06-16 17:25:23 -0500 | [diff] [blame] | 316 | k2g_mux_config(); |
| 317 | |
Lokesh Vutla | 2f31ff1 | 2016-05-26 19:05:44 +0530 | [diff] [blame] | 318 | k2g_reset_mux_config(); |
| 319 | |
Rex Chang | 4df43d4 | 2017-12-28 20:39:59 +0530 | [diff] [blame] | 320 | if (board_is_k2g_gp() || board_is_k2g_g1()) { |
Cooper Jr., Franklin | 16e2897 | 2017-06-16 17:25:26 -0500 | [diff] [blame] | 321 | /* deassert FLASH_HOLD */ |
| 322 | clrbits_le32(K2G_GPIO1_BANK2_BASE + K2G_GPIO_DIR_OFFSET, |
| 323 | BIT(9)); |
| 324 | setbits_le32(K2G_GPIO1_BANK2_BASE + K2G_GPIO_SETDATA_OFFSET, |
| 325 | BIT(9)); |
Lokesh Vutla | ac38c92 | 2020-12-17 22:58:07 +0530 | [diff] [blame] | 326 | } else if (board_is_k2g_ice() || board_is_k2g_i1()) { |
Murali Karicheri | 420a488 | 2019-02-21 12:02:04 -0500 | [diff] [blame] | 327 | /* GBE Phy workaround. For Phy to latch the input |
| 328 | * configuration, a GPIO reset is asserted at the |
| 329 | * Phy reset pin to latch configuration correctly after SoC |
| 330 | * reset. GPIO0 Pin 10 (Ball AA20) is used for this on ICE |
| 331 | * board. Just do a low to high transition. |
| 332 | */ |
| 333 | clrbits_le32(K2G_GPIO0_BANK0_BASE + K2G_GPIO_DIR_OFFSET, |
| 334 | BIT(10)); |
| 335 | setbits_le32(K2G_GPIO0_BANK0_BASE + K2G_GPIO_CLRDATA_OFFSET, |
| 336 | BIT(10)); |
| 337 | /* Delay just to get a transition to high */ |
| 338 | udelay(100); |
| 339 | setbits_le32(K2G_GPIO0_BANK0_BASE + K2G_GPIO_SETDATA_OFFSET, |
| 340 | BIT(10)); |
Cooper Jr., Franklin | 16e2897 | 2017-06-16 17:25:26 -0500 | [diff] [blame] | 341 | } |
Lokesh Vutla | bd46e0e | 2015-09-19 16:26:54 +0530 | [diff] [blame] | 342 | |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 343 | return 0; |
| 344 | } |
| 345 | #endif |
| 346 | |
Roger Quadros | 601ab90 | 2017-03-13 15:04:32 +0200 | [diff] [blame] | 347 | #ifdef CONFIG_BOARD_LATE_INIT |
| 348 | int board_late_init(void) |
| 349 | { |
| 350 | #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_TI_I2C_BOARD_DETECT) |
| 351 | int rc; |
| 352 | |
| 353 | rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS, |
| 354 | CONFIG_EEPROM_CHIP_ADDRESS); |
| 355 | if (rc) |
| 356 | printf("ti_i2c_eeprom_init failed %d\n", rc); |
| 357 | |
| 358 | board_ti_set_ethaddr(1); |
| 359 | #endif |
| 360 | |
Cooper Jr., Franklin | 7e2edb4 | 2017-06-16 17:25:27 -0500 | [diff] [blame] | 361 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
| 362 | if (board_is_k2g_gp()) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 363 | env_set("board_name", "66AK2GGP\0"); |
Rex Chang | 4df43d4 | 2017-12-28 20:39:59 +0530 | [diff] [blame] | 364 | else if (board_is_k2g_g1()) |
| 365 | env_set("board_name", "66AK2GG1\0"); |
Cooper Jr., Franklin | 7e2edb4 | 2017-06-16 17:25:27 -0500 | [diff] [blame] | 366 | else if (board_is_k2g_ice()) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 367 | env_set("board_name", "66AK2GIC\0"); |
Lokesh Vutla | ac38c92 | 2020-12-17 22:58:07 +0530 | [diff] [blame] | 368 | else if (board_is_k2g_i1()) |
| 369 | env_set("board_name", "66AK2GI1\0"); |
Cooper Jr., Franklin | 7e2edb4 | 2017-06-16 17:25:27 -0500 | [diff] [blame] | 370 | #endif |
Cooper Jr., Franklin | 3413a58 | 2017-06-16 17:25:17 -0500 | [diff] [blame] | 371 | return 0; |
| 372 | } |
| 373 | #endif |
| 374 | |
| 375 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 376 | int board_early_init_f(void) |
| 377 | { |
| 378 | init_plls(); |
| 379 | |
| 380 | k2g_mux_config(); |
| 381 | |
Roger Quadros | 601ab90 | 2017-03-13 15:04:32 +0200 | [diff] [blame] | 382 | return 0; |
| 383 | } |
| 384 | #endif |
| 385 | |
Vitaly Andrianov | 2964684 | 2015-09-19 16:26:40 +0530 | [diff] [blame] | 386 | #ifdef CONFIG_SPL_BUILD |
| 387 | void spl_init_keystone_plls(void) |
| 388 | { |
| 389 | init_plls(); |
| 390 | } |
| 391 | #endif |
Vitaly Andrianov | cafc8f4 | 2015-09-19 16:26:52 +0530 | [diff] [blame] | 392 | |
Andrew F. Davis | eab8f40 | 2017-07-31 10:58:21 -0500 | [diff] [blame] | 393 | #ifdef CONFIG_TI_SECURE_DEVICE |
| 394 | void board_pmmc_image_process(ulong pmmc_image, size_t pmmc_size) |
| 395 | { |
Andrew F. Davis | a75e8a8 | 2018-02-14 11:53:38 -0600 | [diff] [blame] | 396 | int id = env_get_ulong("dev_pmmc", 10, 0); |
Andrew F. Davis | eab8f40 | 2017-07-31 10:58:21 -0500 | [diff] [blame] | 397 | int ret; |
| 398 | |
| 399 | if (!rproc_is_initialized()) |
| 400 | rproc_init(); |
| 401 | |
| 402 | ret = rproc_load(id, pmmc_image, pmmc_size); |
| 403 | printf("Load Remote Processor %d with data@addr=0x%08lx %u bytes:%s\n", |
| 404 | id, pmmc_image, pmmc_size, ret ? " Failed!" : " Success!"); |
| 405 | |
| 406 | if (!ret) |
| 407 | rproc_start(id); |
| 408 | } |
| 409 | |
| 410 | U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_PMMC, board_pmmc_image_process); |
| 411 | #endif |