blob: 2398bead782981de5eabf2807df9e6dfdb9fabab [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 *
5 * Copyright (C) 2018-2019 Texas Instruments Incorporated - http://www.ti.com/
6 * Lokesh Vutla <lokeshvutla@ti.com>
7 *
8 */
9
10#include <common.h>
Simon Glassed38aef2020-05-10 11:40:03 -060011#include <env.h>
Simon Glass2dc9c342020-05-10 11:40:01 -060012#include <fdt_support.h>
Aswath Govindraju1e2b4202021-07-21 21:28:39 +053013#include <generic-phy.h>
Simon Glass2dc9c342020-05-10 11:40:01 -060014#include <image.h>
Simon Glass6980b6b2019-11-14 12:57:45 -070015#include <init.h>
Simon Glass0f2af882020-05-10 11:40:05 -060016#include <log.h>
Simon Glass274e0b02020-05-10 11:39:56 -060017#include <net.h>
Andreas Dannenbergd036a212020-01-07 13:15:54 +053018#include <asm/arch/hardware.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060019#include <asm/global_data.h>
Andreas Dannenbergd036a212020-01-07 13:15:54 +053020#include <asm/gpio.h>
Lokesh Vutla1a9dd212019-06-13 10:29:49 +053021#include <asm/io.h>
22#include <spl.h>
Tero Kristo1a2c7ba2020-02-14 11:18:19 +020023#include <dm.h>
24#include <dm/uclass-internal.h>
Lokesh Vutla1a9dd212019-06-13 10:29:49 +053025
Andreas Dannenbergd036a212020-01-07 13:15:54 +053026#include "../common/board_detect.h"
27
28#define board_is_j721e_som() (board_ti_k3_is("J721EX-PM1-SOM") || \
29 board_ti_k3_is("J721EX-PM2-SOM"))
30
Sinthu Raja1c24ab42022-02-09 15:06:50 +053031#define board_is_j721e_sk() (board_ti_k3_is("J721EX-EAIK") || \
32 board_ti_k3_is("J721EX-SK"))
33
Aswath Govindraju1e2b4202021-07-21 21:28:39 +053034#define board_is_j7200_som() (board_ti_k3_is("J7200X-PM1-SOM") || \
35 board_ti_k3_is("J7200X-PM2-SOM"))
Lokesh Vutlae2af9662020-08-05 22:44:25 +053036
Andreas Dannenbergd036a212020-01-07 13:15:54 +053037/* Max number of MAC addresses that are parsed/processed per daughter card */
38#define DAUGHTER_CARD_NO_OF_MAC_ADDR 8
39
Lokesh Vutla1a9dd212019-06-13 10:29:49 +053040DECLARE_GLOBAL_DATA_PTR;
41
42int board_init(void)
43{
44 return 0;
45}
46
47int dram_init(void)
48{
49#ifdef CONFIG_PHYS_64BIT
50 gd->ram_size = 0x100000000;
51#else
52 gd->ram_size = 0x80000000;
53#endif
54
55 return 0;
56}
57
Pali Rohár4f4f5832022-09-09 17:32:40 +020058phys_size_t board_get_usable_ram_top(phys_size_t total_size)
Lokesh Vutla1a9dd212019-06-13 10:29:49 +053059{
60#ifdef CONFIG_PHYS_64BIT
61 /* Limit RAM used by U-Boot to the DDR low region */
62 if (gd->ram_top > 0x100000000)
63 return 0x100000000;
64#endif
65
66 return gd->ram_top;
67}
68
69int dram_init_banksize(void)
70{
71 /* Bank 0 declares the memory available in the DDR low region */
Tom Rinibb4dd962022-11-16 13:10:37 -050072 gd->bd->bi_dram[0].start = CFG_SYS_SDRAM_BASE;
Lokesh Vutla1a9dd212019-06-13 10:29:49 +053073 gd->bd->bi_dram[0].size = 0x80000000;
74 gd->ram_size = 0x80000000;
75
76#ifdef CONFIG_PHYS_64BIT
77 /* Bank 1 declares the memory available in the DDR high region */
Tom Rinibb4dd962022-11-16 13:10:37 -050078 gd->bd->bi_dram[1].start = CFG_SYS_SDRAM_BASE1;
Lokesh Vutla1a9dd212019-06-13 10:29:49 +053079 gd->bd->bi_dram[1].size = 0x80000000;
80 gd->ram_size = 0x100000000;
81#endif
82
83 return 0;
84}
85
86#ifdef CONFIG_SPL_LOAD_FIT
87int board_fit_config_name_match(const char *name)
88{
Sinthu Raja944ff632022-02-09 15:06:52 +053089 bool eeprom_read = board_ti_was_eeprom_read();
90
91 if (!eeprom_read || board_is_j721e_som()) {
92 if (!strcmp(name, "k3-j721e-common-proc-board") ||
93 !strcmp(name, "k3-j721e-r5-common-proc-board"))
94 return 0;
95 } else if (board_is_j721e_sk()) {
96 if (!strcmp(name, "k3-j721e-sk") ||
97 !strcmp(name, "k3-j721e-r5-sk"))
98 return 0;
99 }
Lokesh Vutla1a9dd212019-06-13 10:29:49 +0530100
101 return -1;
102}
103#endif
Suman Anna8eac9e62019-06-13 10:29:50 +0530104
Vignesh Raghavendra685d8652020-08-07 00:26:57 +0530105#if CONFIG_IS_ENABLED(DM_GPIO) && CONFIG_IS_ENABLED(OF_LIBFDT)
106/* Returns 1, if onboard mux is set to hyperflash */
107static void __maybe_unused detect_enable_hyperflash(void *blob)
108{
109 struct gpio_desc desc = {0};
Vaishnav Achathb8b17442022-05-09 11:50:16 +0530110 char *hypermux_sel_gpio = (board_is_j721e_som()) ? "8" : "6";
Vignesh Raghavendra685d8652020-08-07 00:26:57 +0530111
Vaishnav Achathb8b17442022-05-09 11:50:16 +0530112 if (dm_gpio_lookup_name(hypermux_sel_gpio, &desc))
Vignesh Raghavendra685d8652020-08-07 00:26:57 +0530113 return;
114
Vaishnav Achathb8b17442022-05-09 11:50:16 +0530115 if (dm_gpio_request(&desc, hypermux_sel_gpio))
Vignesh Raghavendra685d8652020-08-07 00:26:57 +0530116 return;
117
118 if (dm_gpio_set_dir_flags(&desc, GPIOD_IS_IN))
119 return;
120
121 if (dm_gpio_get_value(&desc)) {
122 int offset;
123
124 do_fixup_by_compat(blob, "ti,am654-hbmc", "status",
125 "okay", sizeof("okay"), 0);
126 offset = fdt_node_offset_by_compatible(blob, -1,
Vignesh Raghavendra57b78362020-09-17 16:48:16 +0530127 "ti,am654-ospi");
Vignesh Raghavendra685d8652020-08-07 00:26:57 +0530128 fdt_setprop(blob, offset, "status", "disabled",
129 sizeof("disabled"));
130 }
131}
132#endif
133
Vaishnav Achathb8b17442022-05-09 11:50:16 +0530134#if defined(CONFIG_SPL_BUILD) && (defined(CONFIG_TARGET_J7200_A72_EVM) || defined(CONFIG_TARGET_J7200_R5_EVM) || \
135 defined(CONFIG_TARGET_J721E_A72_EVM) || defined(CONFIG_TARGET_J721E_R5_EVM))
Vignesh Raghavendra4c3c3d22020-08-13 14:56:16 +0530136void spl_perform_fixups(struct spl_image_info *spl_image)
137{
138 detect_enable_hyperflash(spl_image->fdt_addr);
139}
140#endif
141
Suman Anna8eac9e62019-06-13 10:29:50 +0530142#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900143int ft_board_setup(void *blob, struct bd_info *bd)
Suman Anna8eac9e62019-06-13 10:29:50 +0530144{
Vignesh Raghavendra685d8652020-08-07 00:26:57 +0530145 detect_enable_hyperflash(blob);
146
Andrew Davisb1c29792023-04-06 11:38:10 -0500147 return 0;
Suman Anna8eac9e62019-06-13 10:29:50 +0530148}
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530149#endif
150
Lokesh Vutla5a08e652020-08-05 22:44:14 +0530151#ifdef CONFIG_TI_I2C_BOARD_DETECT
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530152int do_board_detect(void)
153{
154 int ret;
155
Sinthu Raja944ff632022-02-09 15:06:52 +0530156 if (board_ti_was_eeprom_read())
157 return 0;
158
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530159 ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
160 CONFIG_EEPROM_CHIP_ADDRESS);
Sinthu Raja812364f2022-02-09 15:06:49 +0530161 if (ret) {
162 printf("EEPROM not available at 0x%02x, trying to read at 0x%02x\n",
163 CONFIG_EEPROM_CHIP_ADDRESS, CONFIG_EEPROM_CHIP_ADDRESS + 1);
164 ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
165 CONFIG_EEPROM_CHIP_ADDRESS + 1);
166 if (ret)
167 pr_err("Reading on-board EEPROM at 0x%02x failed %d\n",
168 CONFIG_EEPROM_CHIP_ADDRESS + 1, ret);
169 }
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530170
171 return ret;
172}
173
Lokesh Vutla1db6b642020-01-07 13:15:55 +0530174int checkboard(void)
175{
176 struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
177
178 if (do_board_detect())
179 /* EEPROM not populated */
180 printf("Board: %s rev %s\n", "J721EX-PM1-SOM", "E2");
181 else
182 printf("Board: %s rev %s\n", ep->name, ep->version);
183
184 return 0;
185}
186
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530187/*
188 * Declaration of daughtercards to probe. Note that when adding more
189 * cards they should be grouped by the 'i2c_addr' field to allow for a
190 * more efficient probing process.
191 */
192static const struct {
193 u8 i2c_addr; /* I2C address of card EEPROM */
194 char *card_name; /* EEPROM-programmed card name */
195 char *dtbo_name; /* Device tree overlay to apply */
196 u8 eth_offset; /* ethXaddr MAC address index offset */
197} ext_cards[] = {
198 {
199 0x51,
200 "J7X-BASE-CPB",
201 "", /* No dtbo for this board */
202 0,
203 },
204 {
205 0x52,
206 "J7X-INFOTAN-EXP",
207 "", /* No dtbo for this board */
208 0,
209 },
210 {
211 0x52,
212 "J7X-GESI-EXP",
213 "", /* No dtbo for this board */
214 5, /* Start populating from eth5addr */
215 },
216 {
217 0x54,
218 "J7X-VSC8514-ETH",
219 "", /* No dtbo for this board */
220 1, /* Start populating from eth1addr */
221 },
222};
223
224static bool daughter_card_detect_flags[ARRAY_SIZE(ext_cards)];
225
226const char *board_fit_get_additionnal_images(int index, const char *type)
227{
228 int i, j;
229
230 if (strcmp(type, FIT_FDT_PROP))
231 return NULL;
232
233 j = 0;
234 for (i = 0; i < ARRAY_SIZE(ext_cards); i++) {
235 if (daughter_card_detect_flags[i]) {
236 if (j == index) {
237 /*
238 * Return dtbo name only if populated,
239 * otherwise stop parsing here.
240 */
241 if (strlen(ext_cards[i].dtbo_name))
242 return ext_cards[i].dtbo_name;
243 else
244 return NULL;
245 };
246
247 j++;
248 }
249 }
250
251 return NULL;
252}
253
254static int probe_daughtercards(void)
255{
256 char mac_addr[DAUGHTER_CARD_NO_OF_MAC_ADDR][TI_EEPROM_HDR_ETH_ALEN];
257 bool eeprom_read_success;
258 struct ti_am6_eeprom ep;
259 u8 previous_i2c_addr;
260 u8 mac_addr_cnt;
261 int i;
262 int ret;
263
264 /* Mark previous I2C address variable as not populated */
265 previous_i2c_addr = 0xff;
266
267 /* No EEPROM data was read yet */
268 eeprom_read_success = false;
269
270 /* Iterate through list of daughtercards */
271 for (i = 0; i < ARRAY_SIZE(ext_cards); i++) {
272 /* Obtain card-specific I2C address */
273 u8 i2c_addr = ext_cards[i].i2c_addr;
274
275 /* Read card EEPROM if not already read previously */
276 if (i2c_addr != previous_i2c_addr) {
277 /* Store I2C address so we can avoid reading twice */
278 previous_i2c_addr = i2c_addr;
279
280 /* Get and parse the daughter card EEPROM record */
281 ret = ti_i2c_eeprom_am6_get(CONFIG_EEPROM_BUS_ADDRESS,
282 i2c_addr,
283 &ep,
284 (char **)mac_addr,
285 DAUGHTER_CARD_NO_OF_MAC_ADDR,
286 &mac_addr_cnt);
287 if (ret) {
288 debug("%s: No daughtercard EEPROM at 0x%02x found %d\n",
289 __func__, i2c_addr, ret);
290 eeprom_read_success = false;
291 /* Skip to the next daughtercard to probe */
292 continue;
293 }
294
295 /* EEPROM read successful, okay to further process. */
296 eeprom_read_success = true;
297 }
298
299 /* Only continue processing if EEPROM data was read */
300 if (!eeprom_read_success)
301 continue;
302
303 /* Only process the parsed data if we found a match */
304 if (strncmp(ep.name, ext_cards[i].card_name, sizeof(ep.name)))
305 continue;
306
307 printf("Detected: %s rev %s\n", ep.name, ep.version);
308 daughter_card_detect_flags[i] = true;
309
310#ifndef CONFIG_SPL_BUILD
311 int j;
312 /*
313 * Populate any MAC addresses from daughtercard into the U-Boot
314 * environment, starting with a card-specific offset so we can
315 * have multiple ext_cards contribute to the MAC pool in a well-
316 * defined manner.
317 */
318 for (j = 0; j < mac_addr_cnt; j++) {
319 if (!is_valid_ethaddr((u8 *)mac_addr[j]))
320 continue;
321
322 eth_env_set_enetaddr_by_index("eth",
323 ext_cards[i].eth_offset + j,
324 (uchar *)mac_addr[j]);
325 }
Suman Anna8eac9e62019-06-13 10:29:50 +0530326#endif
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530327 }
328#ifndef CONFIG_SPL_BUILD
329 char name_overlays[1024] = { 0 };
330
331 for (i = 0; i < ARRAY_SIZE(ext_cards); i++) {
332 if (!daughter_card_detect_flags[i])
333 continue;
334
335 /* Skip if no overlays are to be added */
336 if (!strlen(ext_cards[i].dtbo_name))
337 continue;
338
339 /*
340 * Make sure we are not running out of buffer space by checking
341 * if we can fit the new overlay, a trailing space to be used
342 * as a separator, plus the terminating zero.
343 */
344 if (strlen(name_overlays) + strlen(ext_cards[i].dtbo_name) + 2 >
345 sizeof(name_overlays))
346 return -ENOMEM;
347
348 /* Append to our list of overlays */
349 strcat(name_overlays, ext_cards[i].dtbo_name);
350 strcat(name_overlays, " ");
351 }
352
353 /* Apply device tree overlay(s) to the U-Boot environment, if any */
354 if (strlen(name_overlays))
355 return env_set("name_overlays", name_overlays);
356#endif
357
358 return 0;
359}
Lokesh Vutla5a08e652020-08-05 22:44:14 +0530360#endif
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530361
Aswath Govindraju1e2b4202021-07-21 21:28:39 +0530362void configure_serdes_torrent(void)
363{
364 struct udevice *dev;
365 struct phy serdes;
366 int ret;
367
368 if (!IS_ENABLED(CONFIG_PHY_CADENCE_TORRENT))
369 return;
370
371 ret = uclass_get_device_by_driver(UCLASS_PHY,
372 DM_DRIVER_GET(torrent_phy_provider),
373 &dev);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530374 if (ret) {
Aswath Govindraju1e2b4202021-07-21 21:28:39 +0530375 printf("Torrent init failed:%d\n", ret);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530376 return;
377 }
Aswath Govindraju1e2b4202021-07-21 21:28:39 +0530378
379 serdes.dev = dev;
380 serdes.id = 0;
381
382 ret = generic_phy_init(&serdes);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530383 if (ret) {
384 printf("phy_init failed!!: %d\n", ret);
385 return;
386 }
Aswath Govindraju1e2b4202021-07-21 21:28:39 +0530387
388 ret = generic_phy_power_on(&serdes);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530389 if (ret) {
390 printf("phy_power_on failed!!: %d\n", ret);
391 return;
392 }
Aswath Govindraju1e2b4202021-07-21 21:28:39 +0530393}
394
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530395void configure_serdes_sierra(void)
396{
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530397 struct udevice *dev, *link_dev;
398 struct phy link;
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530399 int ret, count, i;
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530400 int link_count = 0;
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530401
402 if (!IS_ENABLED(CONFIG_PHY_CADENCE_SIERRA))
403 return;
404
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530405 ret = uclass_get_device_by_driver(UCLASS_MISC,
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530406 DM_DRIVER_GET(sierra_phy_provider),
407 &dev);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530408 if (ret) {
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530409 printf("Sierra init failed:%d\n", ret);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530410 return;
411 }
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530412
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530413 count = device_get_child_count(dev);
414 for (i = 0; i < count; i++) {
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530415 ret = device_get_child(dev, i, &link_dev);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530416 if (ret) {
417 printf("probe of sierra child node %d failed: %d\n", i, ret);
418 return;
419 }
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530420 if (link_dev->driver->id == UCLASS_PHY) {
421 link.dev = link_dev;
422 link.id = link_count++;
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530423
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530424 ret = generic_phy_power_on(&link);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530425 if (ret) {
426 printf("phy_power_on failed!!: %d\n", ret);
427 return;
428 }
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530429 }
430 }
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530431}
432
Sinthu Rajae861aa92022-02-09 15:06:48 +0530433#ifdef CONFIG_BOARD_LATE_INIT
434static void setup_board_eeprom_env(void)
435{
436 char *name = "j721e";
437
438 if (do_board_detect())
439 goto invalid_eeprom;
440
441 if (board_is_j721e_som())
442 name = "j721e";
Sinthu Raja1c24ab42022-02-09 15:06:50 +0530443 else if (board_is_j721e_sk())
444 name = "j721e-sk";
Sinthu Rajae861aa92022-02-09 15:06:48 +0530445 else if (board_is_j7200_som())
446 name = "j7200";
447 else
448 printf("Unidentified board claims %s in eeprom header\n",
449 board_ti_get_name());
450
451invalid_eeprom:
452 set_board_info_env_am6(name);
453}
454
455static void setup_serial(void)
456{
457 struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
458 unsigned long board_serial;
459 char *endp;
460 char serial_string[17] = { 0 };
461
462 if (env_get("serial#"))
463 return;
464
465 board_serial = hextoul(ep->serial, &endp);
466 if (*endp != '\0') {
467 pr_err("Error: Can't set serial# to %s\n", ep->serial);
468 return;
469 }
470
471 snprintf(serial_string, sizeof(serial_string), "%016lx", board_serial);
472 env_set("serial#", serial_string);
473}
474
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530475int board_late_init(void)
476{
Lokesh Vutla5a08e652020-08-05 22:44:14 +0530477 if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT)) {
478 setup_board_eeprom_env();
479 setup_serial();
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530480
Lokesh Vutla5a08e652020-08-05 22:44:14 +0530481 /* Check for and probe any plugged-in daughtercards */
Sinthu Raja9a4fa302022-02-09 15:06:51 +0530482 if (board_is_j721e_som() || board_is_j7200_som())
483 probe_daughtercards();
Lokesh Vutla5a08e652020-08-05 22:44:14 +0530484 }
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530485
Aswath Govindraju1e2b4202021-07-21 21:28:39 +0530486 if (board_is_j7200_som())
487 configure_serdes_torrent();
488
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530489 if (board_is_j721e_som())
490 configure_serdes_sierra();
491
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530492 return 0;
493}
Sinthu Rajae861aa92022-02-09 15:06:48 +0530494#endif
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530495
Vaishnav Achathb8b17442022-05-09 11:50:16 +0530496static int __maybe_unused detect_SW3_1_state(void)
497{
498 if (IS_ENABLED(CONFIG_TARGET_J7200_A72_EVM) || IS_ENABLED(CONFIG_TARGET_J721E_A72_EVM)) {
499 struct gpio_desc desc = {0};
500 int ret;
501 char *hypermux_sel_gpio = (board_is_j721e_som()) ? "8" : "6";
502
503 ret = dm_gpio_lookup_name(hypermux_sel_gpio, &desc);
504 if (ret) {
505 printf("error getting GPIO lookup name: %d\n", ret);
506 return ret;
507 }
508
509 ret = dm_gpio_request(&desc, hypermux_sel_gpio);
510 if (ret) {
511 printf("error requesting GPIO: %d\n", ret);
512 goto err_free_gpio;
513 }
514
515 ret = dm_gpio_set_dir_flags(&desc, GPIOD_IS_IN);
516 if (ret) {
517 printf("error setting direction flag of GPIO: %d\n", ret);
518 goto err_free_gpio;
519 }
520
521 ret = dm_gpio_get_value(&desc);
522 if (ret < 0)
523 printf("error getting value of GPIO: %d\n", ret);
524
525err_free_gpio:
526 dm_gpio_free(desc.dev, &desc);
527 return ret;
528 }
529}
530
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530531void spl_board_init(void)
532{
Tero Kristo1a2c7ba2020-02-14 11:18:19 +0200533#if defined(CONFIG_ESM_K3) || defined(CONFIG_ESM_PMIC)
534 struct udevice *dev;
535 int ret;
536#endif
537
Lokesh Vutla046ad432020-08-05 22:44:24 +0530538 if ((IS_ENABLED(CONFIG_TARGET_J721E_A72_EVM) ||
539 IS_ENABLED(CONFIG_TARGET_J7200_A72_EVM)) &&
Sinthu Raja9a4fa302022-02-09 15:06:51 +0530540 IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT)) {
541 if (!board_is_j721e_sk())
542 probe_daughtercards();
543 }
Tero Kristo1a2c7ba2020-02-14 11:18:19 +0200544
545#ifdef CONFIG_ESM_K3
546 if (board_ti_k3_is("J721EX-PM2-SOM")) {
547 ret = uclass_get_device_by_driver(UCLASS_MISC,
Simon Glass65130cd2020-12-28 20:34:56 -0700548 DM_DRIVER_GET(k3_esm), &dev);
Tero Kristo1a2c7ba2020-02-14 11:18:19 +0200549 if (ret)
550 printf("ESM init failed: %d\n", ret);
551 }
552#endif
553
554#ifdef CONFIG_ESM_PMIC
555 if (board_ti_k3_is("J721EX-PM2-SOM")) {
556 ret = uclass_get_device_by_driver(UCLASS_MISC,
Simon Glass65130cd2020-12-28 20:34:56 -0700557 DM_DRIVER_GET(pmic_esm),
Tero Kristo1a2c7ba2020-02-14 11:18:19 +0200558 &dev);
559 if (ret)
560 printf("ESM PMIC init failed: %d\n", ret);
561 }
562#endif
Vaishnav Achathb8b17442022-05-09 11:50:16 +0530563 if ((IS_ENABLED(CONFIG_TARGET_J7200_A72_EVM) || IS_ENABLED(CONFIG_TARGET_J721E_A72_EVM)) &&
564 IS_ENABLED(CONFIG_HBMC_AM654)) {
565 struct udevice *dev;
566 int ret;
567
568 ret = detect_SW3_1_state();
569 if (ret == 1) {
570 ret = uclass_get_device_by_driver(UCLASS_MTD,
571 DM_DRIVER_GET(hbmc_am654),
572 &dev);
573 if (ret)
574 debug("Failed to probe hyperflash\n");
575 }
576 }
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530577}