blob: c541880107ec11ed74fdad63ce626efa0db68429 [file] [log] [blame]
Lokesh Vutla1a9dd212019-06-13 10:29:49 +05301// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Board specific initialization for J721E EVM
4 *
Nishanth Menoneaa39c62023-11-01 15:56:03 -05005 * Copyright (C) 2018-2019 Texas Instruments Incorporated - https://www.ti.com/
Lokesh Vutla1a9dd212019-06-13 10:29:49 +05306 * Lokesh Vutla <lokeshvutla@ti.com>
7 *
8 */
9
Aswath Govindraju1e2b4202021-07-21 21:28:39 +053010#include <generic-phy.h>
Simon Glass2dc9c342020-05-10 11:40:01 -060011#include <image.h>
Simon Glass274e0b02020-05-10 11:39:56 -060012#include <net.h>
Andreas Dannenbergd036a212020-01-07 13:15:54 +053013#include <asm/arch/hardware.h>
14#include <asm/gpio.h>
Lokesh Vutla1a9dd212019-06-13 10:29:49 +053015#include <spl.h>
Tero Kristo1a2c7ba2020-02-14 11:18:19 +020016#include <dm.h>
Lokesh Vutla1a9dd212019-06-13 10:29:49 +053017
Andreas Dannenbergd036a212020-01-07 13:15:54 +053018#include "../common/board_detect.h"
19
20#define board_is_j721e_som() (board_ti_k3_is("J721EX-PM1-SOM") || \
21 board_ti_k3_is("J721EX-PM2-SOM"))
22
Sinthu Raja1c24ab42022-02-09 15:06:50 +053023#define board_is_j721e_sk() (board_ti_k3_is("J721EX-EAIK") || \
24 board_ti_k3_is("J721EX-SK"))
25
Aswath Govindraju1e2b4202021-07-21 21:28:39 +053026#define board_is_j7200_som() (board_ti_k3_is("J7200X-PM1-SOM") || \
27 board_ti_k3_is("J7200X-PM2-SOM"))
Lokesh Vutlae2af9662020-08-05 22:44:25 +053028
Andreas Dannenbergd036a212020-01-07 13:15:54 +053029/* Max number of MAC addresses that are parsed/processed per daughter card */
30#define DAUGHTER_CARD_NO_OF_MAC_ADDR 8
31
Lokesh Vutla1a9dd212019-06-13 10:29:49 +053032DECLARE_GLOBAL_DATA_PTR;
33
34int board_init(void)
35{
36 return 0;
37}
38
39int dram_init(void)
40{
41#ifdef CONFIG_PHYS_64BIT
42 gd->ram_size = 0x100000000;
43#else
44 gd->ram_size = 0x80000000;
45#endif
46
47 return 0;
48}
49
Heinrich Schuchardt51a9aac2023-08-12 20:16:58 +020050phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
Lokesh Vutla1a9dd212019-06-13 10:29:49 +053051{
52#ifdef CONFIG_PHYS_64BIT
53 /* Limit RAM used by U-Boot to the DDR low region */
54 if (gd->ram_top > 0x100000000)
55 return 0x100000000;
56#endif
57
58 return gd->ram_top;
59}
60
61int dram_init_banksize(void)
62{
63 /* Bank 0 declares the memory available in the DDR low region */
Andrew Davisff64dc22023-11-30 08:49:11 -060064 gd->bd->bi_dram[0].start = 0x80000000;
Lokesh Vutla1a9dd212019-06-13 10:29:49 +053065 gd->bd->bi_dram[0].size = 0x80000000;
66 gd->ram_size = 0x80000000;
67
68#ifdef CONFIG_PHYS_64BIT
69 /* Bank 1 declares the memory available in the DDR high region */
Andrew Davisff64dc22023-11-30 08:49:11 -060070 gd->bd->bi_dram[1].start = 0x880000000;
Lokesh Vutla1a9dd212019-06-13 10:29:49 +053071 gd->bd->bi_dram[1].size = 0x80000000;
72 gd->ram_size = 0x100000000;
73#endif
74
75 return 0;
76}
77
78#ifdef CONFIG_SPL_LOAD_FIT
79int board_fit_config_name_match(const char *name)
80{
Sinthu Raja944ff632022-02-09 15:06:52 +053081 bool eeprom_read = board_ti_was_eeprom_read();
82
83 if (!eeprom_read || board_is_j721e_som()) {
84 if (!strcmp(name, "k3-j721e-common-proc-board") ||
85 !strcmp(name, "k3-j721e-r5-common-proc-board"))
86 return 0;
87 } else if (board_is_j721e_sk()) {
88 if (!strcmp(name, "k3-j721e-sk") ||
89 !strcmp(name, "k3-j721e-r5-sk"))
90 return 0;
91 }
Lokesh Vutla1a9dd212019-06-13 10:29:49 +053092
93 return -1;
94}
95#endif
Suman Anna8eac9e62019-06-13 10:29:50 +053096
Vignesh Raghavendra685d8652020-08-07 00:26:57 +053097#if CONFIG_IS_ENABLED(DM_GPIO) && CONFIG_IS_ENABLED(OF_LIBFDT)
98/* Returns 1, if onboard mux is set to hyperflash */
99static void __maybe_unused detect_enable_hyperflash(void *blob)
100{
101 struct gpio_desc desc = {0};
Vaishnav Achathb8b17442022-05-09 11:50:16 +0530102 char *hypermux_sel_gpio = (board_is_j721e_som()) ? "8" : "6";
Vignesh Raghavendra685d8652020-08-07 00:26:57 +0530103
Vaishnav Achathb8b17442022-05-09 11:50:16 +0530104 if (dm_gpio_lookup_name(hypermux_sel_gpio, &desc))
Vignesh Raghavendra685d8652020-08-07 00:26:57 +0530105 return;
106
Vaishnav Achathb8b17442022-05-09 11:50:16 +0530107 if (dm_gpio_request(&desc, hypermux_sel_gpio))
Vignesh Raghavendra685d8652020-08-07 00:26:57 +0530108 return;
109
110 if (dm_gpio_set_dir_flags(&desc, GPIOD_IS_IN))
111 return;
112
113 if (dm_gpio_get_value(&desc)) {
114 int offset;
115
116 do_fixup_by_compat(blob, "ti,am654-hbmc", "status",
117 "okay", sizeof("okay"), 0);
118 offset = fdt_node_offset_by_compatible(blob, -1,
Vignesh Raghavendra57b78362020-09-17 16:48:16 +0530119 "ti,am654-ospi");
Vignesh Raghavendra685d8652020-08-07 00:26:57 +0530120 fdt_setprop(blob, offset, "status", "disabled",
121 sizeof("disabled"));
122 }
123}
124#endif
125
Vaishnav Achathb8b17442022-05-09 11:50:16 +0530126#if defined(CONFIG_SPL_BUILD) && (defined(CONFIG_TARGET_J7200_A72_EVM) || defined(CONFIG_TARGET_J7200_R5_EVM) || \
127 defined(CONFIG_TARGET_J721E_A72_EVM) || defined(CONFIG_TARGET_J721E_R5_EVM))
Vignesh Raghavendra4c3c3d22020-08-13 14:56:16 +0530128void spl_perform_fixups(struct spl_image_info *spl_image)
129{
130 detect_enable_hyperflash(spl_image->fdt_addr);
131}
132#endif
133
Suman Anna8eac9e62019-06-13 10:29:50 +0530134#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900135int ft_board_setup(void *blob, struct bd_info *bd)
Suman Anna8eac9e62019-06-13 10:29:50 +0530136{
Vignesh Raghavendra685d8652020-08-07 00:26:57 +0530137 detect_enable_hyperflash(blob);
138
Andrew Davisb1c29792023-04-06 11:38:10 -0500139 return 0;
Suman Anna8eac9e62019-06-13 10:29:50 +0530140}
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530141#endif
142
Lokesh Vutla5a08e652020-08-05 22:44:14 +0530143#ifdef CONFIG_TI_I2C_BOARD_DETECT
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530144int do_board_detect(void)
145{
146 int ret;
147
Sinthu Raja944ff632022-02-09 15:06:52 +0530148 if (board_ti_was_eeprom_read())
149 return 0;
150
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530151 ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
152 CONFIG_EEPROM_CHIP_ADDRESS);
Sinthu Raja812364f2022-02-09 15:06:49 +0530153 if (ret) {
154 printf("EEPROM not available at 0x%02x, trying to read at 0x%02x\n",
155 CONFIG_EEPROM_CHIP_ADDRESS, CONFIG_EEPROM_CHIP_ADDRESS + 1);
156 ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
157 CONFIG_EEPROM_CHIP_ADDRESS + 1);
158 if (ret)
159 pr_err("Reading on-board EEPROM at 0x%02x failed %d\n",
160 CONFIG_EEPROM_CHIP_ADDRESS + 1, ret);
161 }
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530162
163 return ret;
164}
165
Lokesh Vutla1db6b642020-01-07 13:15:55 +0530166int checkboard(void)
167{
168 struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
169
170 if (do_board_detect())
171 /* EEPROM not populated */
172 printf("Board: %s rev %s\n", "J721EX-PM1-SOM", "E2");
173 else
174 printf("Board: %s rev %s\n", ep->name, ep->version);
175
176 return 0;
177}
178
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530179/*
180 * Declaration of daughtercards to probe. Note that when adding more
181 * cards they should be grouped by the 'i2c_addr' field to allow for a
182 * more efficient probing process.
183 */
184static const struct {
185 u8 i2c_addr; /* I2C address of card EEPROM */
186 char *card_name; /* EEPROM-programmed card name */
187 char *dtbo_name; /* Device tree overlay to apply */
188 u8 eth_offset; /* ethXaddr MAC address index offset */
189} ext_cards[] = {
190 {
191 0x51,
192 "J7X-BASE-CPB",
193 "", /* No dtbo for this board */
194 0,
195 },
196 {
197 0x52,
198 "J7X-INFOTAN-EXP",
199 "", /* No dtbo for this board */
200 0,
201 },
202 {
203 0x52,
204 "J7X-GESI-EXP",
205 "", /* No dtbo for this board */
206 5, /* Start populating from eth5addr */
207 },
208 {
209 0x54,
210 "J7X-VSC8514-ETH",
211 "", /* No dtbo for this board */
212 1, /* Start populating from eth1addr */
213 },
214};
215
216static bool daughter_card_detect_flags[ARRAY_SIZE(ext_cards)];
217
218const char *board_fit_get_additionnal_images(int index, const char *type)
219{
220 int i, j;
221
222 if (strcmp(type, FIT_FDT_PROP))
223 return NULL;
224
225 j = 0;
226 for (i = 0; i < ARRAY_SIZE(ext_cards); i++) {
227 if (daughter_card_detect_flags[i]) {
228 if (j == index) {
229 /*
230 * Return dtbo name only if populated,
231 * otherwise stop parsing here.
232 */
233 if (strlen(ext_cards[i].dtbo_name))
234 return ext_cards[i].dtbo_name;
235 else
236 return NULL;
237 };
238
239 j++;
240 }
241 }
242
243 return NULL;
244}
245
246static int probe_daughtercards(void)
247{
248 char mac_addr[DAUGHTER_CARD_NO_OF_MAC_ADDR][TI_EEPROM_HDR_ETH_ALEN];
249 bool eeprom_read_success;
250 struct ti_am6_eeprom ep;
251 u8 previous_i2c_addr;
252 u8 mac_addr_cnt;
253 int i;
254 int ret;
255
256 /* Mark previous I2C address variable as not populated */
257 previous_i2c_addr = 0xff;
258
259 /* No EEPROM data was read yet */
260 eeprom_read_success = false;
261
262 /* Iterate through list of daughtercards */
263 for (i = 0; i < ARRAY_SIZE(ext_cards); i++) {
264 /* Obtain card-specific I2C address */
265 u8 i2c_addr = ext_cards[i].i2c_addr;
266
267 /* Read card EEPROM if not already read previously */
268 if (i2c_addr != previous_i2c_addr) {
269 /* Store I2C address so we can avoid reading twice */
270 previous_i2c_addr = i2c_addr;
271
272 /* Get and parse the daughter card EEPROM record */
273 ret = ti_i2c_eeprom_am6_get(CONFIG_EEPROM_BUS_ADDRESS,
274 i2c_addr,
275 &ep,
276 (char **)mac_addr,
277 DAUGHTER_CARD_NO_OF_MAC_ADDR,
278 &mac_addr_cnt);
279 if (ret) {
280 debug("%s: No daughtercard EEPROM at 0x%02x found %d\n",
281 __func__, i2c_addr, ret);
282 eeprom_read_success = false;
283 /* Skip to the next daughtercard to probe */
284 continue;
285 }
286
287 /* EEPROM read successful, okay to further process. */
288 eeprom_read_success = true;
289 }
290
291 /* Only continue processing if EEPROM data was read */
292 if (!eeprom_read_success)
293 continue;
294
295 /* Only process the parsed data if we found a match */
296 if (strncmp(ep.name, ext_cards[i].card_name, sizeof(ep.name)))
297 continue;
298
299 printf("Detected: %s rev %s\n", ep.name, ep.version);
300 daughter_card_detect_flags[i] = true;
301
Nishanth Menon4f4c9d82023-11-04 02:21:41 -0500302 if (!IS_ENABLED(CONFIG_SPL_BUILD)) {
303 int j;
304 /*
305 * Populate any MAC addresses from daughtercard into the U-Boot
306 * environment, starting with a card-specific offset so we can
307 * have multiple ext_cards contribute to the MAC pool in a well-
308 * defined manner.
309 */
310 for (j = 0; j < mac_addr_cnt; j++) {
311 if (!is_valid_ethaddr((u8 *)mac_addr[j]))
312 continue;
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530313
Nishanth Menon4f4c9d82023-11-04 02:21:41 -0500314 eth_env_set_enetaddr_by_index("eth",
315 ext_cards[i].eth_offset + j,
316 (uchar *)mac_addr[j]);
317 }
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530318 }
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530319 }
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530320
Nishanth Menon4f4c9d82023-11-04 02:21:41 -0500321 if (!IS_ENABLED(CONFIG_SPL_BUILD)) {
322 char name_overlays[1024] = { 0 };
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530323
Nishanth Menon4f4c9d82023-11-04 02:21:41 -0500324 for (i = 0; i < ARRAY_SIZE(ext_cards); i++) {
325 if (!daughter_card_detect_flags[i])
326 continue;
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530327
Nishanth Menon4f4c9d82023-11-04 02:21:41 -0500328 /* Skip if no overlays are to be added */
329 if (!strlen(ext_cards[i].dtbo_name))
330 continue;
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530331
Nishanth Menon4f4c9d82023-11-04 02:21:41 -0500332 /*
333 * Make sure we are not running out of buffer space by checking
334 * if we can fit the new overlay, a trailing space to be used
335 * as a separator, plus the terminating zero.
336 */
337 if (strlen(name_overlays) + strlen(ext_cards[i].dtbo_name) + 2 >
338 sizeof(name_overlays))
339 return -ENOMEM;
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530340
Nishanth Menon4f4c9d82023-11-04 02:21:41 -0500341 /* Append to our list of overlays */
342 strcat(name_overlays, ext_cards[i].dtbo_name);
343 strcat(name_overlays, " ");
344 }
345
346 /* Apply device tree overlay(s) to the U-Boot environment, if any */
347 if (strlen(name_overlays))
348 return env_set("name_overlays", name_overlays);
349 }
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530350
351 return 0;
352}
Lokesh Vutla5a08e652020-08-05 22:44:14 +0530353#endif
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530354
Aswath Govindraju1e2b4202021-07-21 21:28:39 +0530355void configure_serdes_torrent(void)
356{
357 struct udevice *dev;
358 struct phy serdes;
359 int ret;
360
361 if (!IS_ENABLED(CONFIG_PHY_CADENCE_TORRENT))
362 return;
363
364 ret = uclass_get_device_by_driver(UCLASS_PHY,
365 DM_DRIVER_GET(torrent_phy_provider),
366 &dev);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530367 if (ret) {
Aswath Govindraju1e2b4202021-07-21 21:28:39 +0530368 printf("Torrent init failed:%d\n", ret);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530369 return;
370 }
Aswath Govindraju1e2b4202021-07-21 21:28:39 +0530371
372 serdes.dev = dev;
373 serdes.id = 0;
374
375 ret = generic_phy_init(&serdes);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530376 if (ret) {
377 printf("phy_init failed!!: %d\n", ret);
378 return;
379 }
Aswath Govindraju1e2b4202021-07-21 21:28:39 +0530380
381 ret = generic_phy_power_on(&serdes);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530382 if (ret) {
383 printf("phy_power_on failed!!: %d\n", ret);
384 return;
385 }
Aswath Govindraju1e2b4202021-07-21 21:28:39 +0530386}
387
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530388void configure_serdes_sierra(void)
389{
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530390 struct udevice *dev, *link_dev;
391 struct phy link;
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530392 int ret, count, i;
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530393 int link_count = 0;
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530394
395 if (!IS_ENABLED(CONFIG_PHY_CADENCE_SIERRA))
396 return;
397
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530398 ret = uclass_get_device_by_driver(UCLASS_MISC,
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530399 DM_DRIVER_GET(sierra_phy_provider),
400 &dev);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530401 if (ret) {
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530402 printf("Sierra init failed:%d\n", ret);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530403 return;
404 }
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530405
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530406 count = device_get_child_count(dev);
407 for (i = 0; i < count; i++) {
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530408 ret = device_get_child(dev, i, &link_dev);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530409 if (ret) {
410 printf("probe of sierra child node %d failed: %d\n", i, ret);
411 return;
412 }
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530413 if (link_dev->driver->id == UCLASS_PHY) {
414 link.dev = link_dev;
415 link.id = link_count++;
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530416
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530417 ret = generic_phy_power_on(&link);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530418 if (ret) {
419 printf("phy_power_on failed!!: %d\n", ret);
420 return;
421 }
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530422 }
423 }
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530424}
425
Sinthu Rajae861aa92022-02-09 15:06:48 +0530426#ifdef CONFIG_BOARD_LATE_INIT
427static void setup_board_eeprom_env(void)
428{
429 char *name = "j721e";
430
431 if (do_board_detect())
432 goto invalid_eeprom;
433
434 if (board_is_j721e_som())
435 name = "j721e";
Sinthu Raja1c24ab42022-02-09 15:06:50 +0530436 else if (board_is_j721e_sk())
437 name = "j721e-sk";
Sinthu Rajae861aa92022-02-09 15:06:48 +0530438 else if (board_is_j7200_som())
439 name = "j7200";
440 else
441 printf("Unidentified board claims %s in eeprom header\n",
442 board_ti_get_name());
443
444invalid_eeprom:
445 set_board_info_env_am6(name);
446}
447
448static void setup_serial(void)
449{
450 struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
451 unsigned long board_serial;
452 char *endp;
453 char serial_string[17] = { 0 };
454
455 if (env_get("serial#"))
456 return;
457
458 board_serial = hextoul(ep->serial, &endp);
459 if (*endp != '\0') {
460 pr_err("Error: Can't set serial# to %s\n", ep->serial);
461 return;
462 }
463
464 snprintf(serial_string, sizeof(serial_string), "%016lx", board_serial);
465 env_set("serial#", serial_string);
466}
467
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530468int board_late_init(void)
469{
Lokesh Vutla5a08e652020-08-05 22:44:14 +0530470 if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT)) {
471 setup_board_eeprom_env();
472 setup_serial();
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530473
Lokesh Vutla5a08e652020-08-05 22:44:14 +0530474 /* Check for and probe any plugged-in daughtercards */
Sinthu Raja9a4fa302022-02-09 15:06:51 +0530475 if (board_is_j721e_som() || board_is_j7200_som())
476 probe_daughtercards();
Lokesh Vutla5a08e652020-08-05 22:44:14 +0530477 }
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530478
Aswath Govindraju1e2b4202021-07-21 21:28:39 +0530479 if (board_is_j7200_som())
480 configure_serdes_torrent();
481
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530482 if (board_is_j721e_som())
483 configure_serdes_sierra();
484
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530485 return 0;
486}
Sinthu Rajae861aa92022-02-09 15:06:48 +0530487#endif
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530488
Vaishnav Achathb8b17442022-05-09 11:50:16 +0530489static int __maybe_unused detect_SW3_1_state(void)
490{
491 if (IS_ENABLED(CONFIG_TARGET_J7200_A72_EVM) || IS_ENABLED(CONFIG_TARGET_J721E_A72_EVM)) {
492 struct gpio_desc desc = {0};
493 int ret;
494 char *hypermux_sel_gpio = (board_is_j721e_som()) ? "8" : "6";
495
496 ret = dm_gpio_lookup_name(hypermux_sel_gpio, &desc);
497 if (ret) {
498 printf("error getting GPIO lookup name: %d\n", ret);
499 return ret;
500 }
501
502 ret = dm_gpio_request(&desc, hypermux_sel_gpio);
503 if (ret) {
504 printf("error requesting GPIO: %d\n", ret);
505 goto err_free_gpio;
506 }
507
508 ret = dm_gpio_set_dir_flags(&desc, GPIOD_IS_IN);
509 if (ret) {
510 printf("error setting direction flag of GPIO: %d\n", ret);
511 goto err_free_gpio;
512 }
513
514 ret = dm_gpio_get_value(&desc);
515 if (ret < 0)
516 printf("error getting value of GPIO: %d\n", ret);
517
518err_free_gpio:
519 dm_gpio_free(desc.dev, &desc);
520 return ret;
521 }
522}
523
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530524void spl_board_init(void)
525{
Tero Kristo1a2c7ba2020-02-14 11:18:19 +0200526 struct udevice *dev;
527 int ret;
Tero Kristo1a2c7ba2020-02-14 11:18:19 +0200528
Lokesh Vutla046ad432020-08-05 22:44:24 +0530529 if ((IS_ENABLED(CONFIG_TARGET_J721E_A72_EVM) ||
530 IS_ENABLED(CONFIG_TARGET_J7200_A72_EVM)) &&
Sinthu Raja9a4fa302022-02-09 15:06:51 +0530531 IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT)) {
532 if (!board_is_j721e_sk())
533 probe_daughtercards();
534 }
Tero Kristo1a2c7ba2020-02-14 11:18:19 +0200535
Nishanth Menon591443e2023-11-04 02:21:40 -0500536 if (IS_ENABLED(CONFIG_ESM_K3)) {
Tero Kristo1a2c7ba2020-02-14 11:18:19 +0200537 ret = uclass_get_device_by_driver(UCLASS_MISC,
Simon Glass65130cd2020-12-28 20:34:56 -0700538 DM_DRIVER_GET(k3_esm), &dev);
Tero Kristo1a2c7ba2020-02-14 11:18:19 +0200539 if (ret)
540 printf("ESM init failed: %d\n", ret);
541 }
Tero Kristo1a2c7ba2020-02-14 11:18:19 +0200542
Nishanth Menon591443e2023-11-04 02:21:40 -0500543 if (IS_ENABLED(CONFIG_ESM_PMIC)) {
Tero Kristo1a2c7ba2020-02-14 11:18:19 +0200544 ret = uclass_get_device_by_driver(UCLASS_MISC,
Simon Glass65130cd2020-12-28 20:34:56 -0700545 DM_DRIVER_GET(pmic_esm),
Tero Kristo1a2c7ba2020-02-14 11:18:19 +0200546 &dev);
547 if (ret)
548 printf("ESM PMIC init failed: %d\n", ret);
549 }
Vaishnav Achathb8b17442022-05-09 11:50:16 +0530550 if ((IS_ENABLED(CONFIG_TARGET_J7200_A72_EVM) || IS_ENABLED(CONFIG_TARGET_J721E_A72_EVM)) &&
551 IS_ENABLED(CONFIG_HBMC_AM654)) {
552 struct udevice *dev;
553 int ret;
554
555 ret = detect_SW3_1_state();
556 if (ret == 1) {
557 ret = uclass_get_device_by_driver(UCLASS_MTD,
558 DM_DRIVER_GET(hbmc_am654),
559 &dev);
560 if (ret)
561 debug("Failed to probe hyperflash\n");
562 }
563 }
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530564}