blob: 5d090048ceb068c6c6eaba2505bc7361e6d60a4e [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/sys_proto.h>
19#include <asm/arch/hardware.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060020#include <asm/global_data.h>
Andreas Dannenbergd036a212020-01-07 13:15:54 +053021#include <asm/gpio.h>
Lokesh Vutla1a9dd212019-06-13 10:29:49 +053022#include <asm/io.h>
23#include <spl.h>
Suman Anna8eac9e62019-06-13 10:29:50 +053024#include <asm/arch/sys_proto.h>
Tero Kristo1a2c7ba2020-02-14 11:18:19 +020025#include <dm.h>
26#include <dm/uclass-internal.h>
Lokesh Vutla1a9dd212019-06-13 10:29:49 +053027
Andreas Dannenbergd036a212020-01-07 13:15:54 +053028#include "../common/board_detect.h"
29
30#define board_is_j721e_som() (board_ti_k3_is("J721EX-PM1-SOM") || \
31 board_ti_k3_is("J721EX-PM2-SOM"))
32
Sinthu Raja1c24ab42022-02-09 15:06:50 +053033#define board_is_j721e_sk() (board_ti_k3_is("J721EX-EAIK") || \
34 board_ti_k3_is("J721EX-SK"))
35
Aswath Govindraju1e2b4202021-07-21 21:28:39 +053036#define board_is_j7200_som() (board_ti_k3_is("J7200X-PM1-SOM") || \
37 board_ti_k3_is("J7200X-PM2-SOM"))
Lokesh Vutlae2af9662020-08-05 22:44:25 +053038
Andreas Dannenbergd036a212020-01-07 13:15:54 +053039/* Max number of MAC addresses that are parsed/processed per daughter card */
40#define DAUGHTER_CARD_NO_OF_MAC_ADDR 8
41
Lokesh Vutla1a9dd212019-06-13 10:29:49 +053042DECLARE_GLOBAL_DATA_PTR;
43
44int board_init(void)
45{
46 return 0;
47}
48
49int dram_init(void)
50{
51#ifdef CONFIG_PHYS_64BIT
52 gd->ram_size = 0x100000000;
53#else
54 gd->ram_size = 0x80000000;
55#endif
56
57 return 0;
58}
59
60ulong board_get_usable_ram_top(ulong total_size)
61{
62#ifdef CONFIG_PHYS_64BIT
63 /* Limit RAM used by U-Boot to the DDR low region */
64 if (gd->ram_top > 0x100000000)
65 return 0x100000000;
66#endif
67
68 return gd->ram_top;
69}
70
71int dram_init_banksize(void)
72{
73 /* Bank 0 declares the memory available in the DDR low region */
74 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
75 gd->bd->bi_dram[0].size = 0x80000000;
76 gd->ram_size = 0x80000000;
77
78#ifdef CONFIG_PHYS_64BIT
79 /* Bank 1 declares the memory available in the DDR high region */
80 gd->bd->bi_dram[1].start = CONFIG_SYS_SDRAM_BASE1;
81 gd->bd->bi_dram[1].size = 0x80000000;
82 gd->ram_size = 0x100000000;
83#endif
84
85 return 0;
86}
87
88#ifdef CONFIG_SPL_LOAD_FIT
89int board_fit_config_name_match(const char *name)
90{
Sinthu Raja944ff632022-02-09 15:06:52 +053091 bool eeprom_read = board_ti_was_eeprom_read();
92
93 if (!eeprom_read || board_is_j721e_som()) {
94 if (!strcmp(name, "k3-j721e-common-proc-board") ||
95 !strcmp(name, "k3-j721e-r5-common-proc-board"))
96 return 0;
97 } else if (board_is_j721e_sk()) {
98 if (!strcmp(name, "k3-j721e-sk") ||
99 !strcmp(name, "k3-j721e-r5-sk"))
100 return 0;
101 }
Lokesh Vutla1a9dd212019-06-13 10:29:49 +0530102
103 return -1;
104}
105#endif
Suman Anna8eac9e62019-06-13 10:29:50 +0530106
Vignesh Raghavendra685d8652020-08-07 00:26:57 +0530107#if CONFIG_IS_ENABLED(DM_GPIO) && CONFIG_IS_ENABLED(OF_LIBFDT)
108/* Returns 1, if onboard mux is set to hyperflash */
109static void __maybe_unused detect_enable_hyperflash(void *blob)
110{
111 struct gpio_desc desc = {0};
Vaishnav Achathb8b17442022-05-09 11:50:16 +0530112 char *hypermux_sel_gpio = (board_is_j721e_som()) ? "8" : "6";
Vignesh Raghavendra685d8652020-08-07 00:26:57 +0530113
Vaishnav Achathb8b17442022-05-09 11:50:16 +0530114 if (dm_gpio_lookup_name(hypermux_sel_gpio, &desc))
Vignesh Raghavendra685d8652020-08-07 00:26:57 +0530115 return;
116
Vaishnav Achathb8b17442022-05-09 11:50:16 +0530117 if (dm_gpio_request(&desc, hypermux_sel_gpio))
Vignesh Raghavendra685d8652020-08-07 00:26:57 +0530118 return;
119
120 if (dm_gpio_set_dir_flags(&desc, GPIOD_IS_IN))
121 return;
122
123 if (dm_gpio_get_value(&desc)) {
124 int offset;
125
126 do_fixup_by_compat(blob, "ti,am654-hbmc", "status",
127 "okay", sizeof("okay"), 0);
128 offset = fdt_node_offset_by_compatible(blob, -1,
Vignesh Raghavendra57b78362020-09-17 16:48:16 +0530129 "ti,am654-ospi");
Vignesh Raghavendra685d8652020-08-07 00:26:57 +0530130 fdt_setprop(blob, offset, "status", "disabled",
131 sizeof("disabled"));
132 }
133}
134#endif
135
Vaishnav Achathb8b17442022-05-09 11:50:16 +0530136#if defined(CONFIG_SPL_BUILD) && (defined(CONFIG_TARGET_J7200_A72_EVM) || defined(CONFIG_TARGET_J7200_R5_EVM) || \
137 defined(CONFIG_TARGET_J721E_A72_EVM) || defined(CONFIG_TARGET_J721E_R5_EVM))
Vignesh Raghavendra4c3c3d22020-08-13 14:56:16 +0530138void spl_perform_fixups(struct spl_image_info *spl_image)
139{
140 detect_enable_hyperflash(spl_image->fdt_addr);
141}
142#endif
143
Suman Anna8eac9e62019-06-13 10:29:50 +0530144#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900145int ft_board_setup(void *blob, struct bd_info *bd)
Suman Anna8eac9e62019-06-13 10:29:50 +0530146{
147 int ret;
148
Suman Anna3ff49252020-08-05 22:44:15 +0530149 ret = fdt_fixup_msmc_ram(blob, "/bus@100000", "sram@70000000");
150 if (ret < 0)
151 ret = fdt_fixup_msmc_ram(blob, "/interconnect@100000",
152 "sram@70000000");
Suman Anna8eac9e62019-06-13 10:29:50 +0530153 if (ret)
154 printf("%s: fixing up msmc ram failed %d\n", __func__, ret);
155
Vignesh Raghavendra685d8652020-08-07 00:26:57 +0530156 detect_enable_hyperflash(blob);
157
Suman Anna8eac9e62019-06-13 10:29:50 +0530158 return ret;
159}
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530160#endif
161
Lokesh Vutla5a08e652020-08-05 22:44:14 +0530162#ifdef CONFIG_TI_I2C_BOARD_DETECT
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530163int do_board_detect(void)
164{
165 int ret;
166
Sinthu Raja944ff632022-02-09 15:06:52 +0530167 if (board_ti_was_eeprom_read())
168 return 0;
169
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530170 ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
171 CONFIG_EEPROM_CHIP_ADDRESS);
Sinthu Raja812364f2022-02-09 15:06:49 +0530172 if (ret) {
173 printf("EEPROM not available at 0x%02x, trying to read at 0x%02x\n",
174 CONFIG_EEPROM_CHIP_ADDRESS, CONFIG_EEPROM_CHIP_ADDRESS + 1);
175 ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
176 CONFIG_EEPROM_CHIP_ADDRESS + 1);
177 if (ret)
178 pr_err("Reading on-board EEPROM at 0x%02x failed %d\n",
179 CONFIG_EEPROM_CHIP_ADDRESS + 1, ret);
180 }
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530181
182 return ret;
183}
184
Lokesh Vutla1db6b642020-01-07 13:15:55 +0530185int checkboard(void)
186{
187 struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
188
189 if (do_board_detect())
190 /* EEPROM not populated */
191 printf("Board: %s rev %s\n", "J721EX-PM1-SOM", "E2");
192 else
193 printf("Board: %s rev %s\n", ep->name, ep->version);
194
195 return 0;
196}
197
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530198/*
199 * Declaration of daughtercards to probe. Note that when adding more
200 * cards they should be grouped by the 'i2c_addr' field to allow for a
201 * more efficient probing process.
202 */
203static const struct {
204 u8 i2c_addr; /* I2C address of card EEPROM */
205 char *card_name; /* EEPROM-programmed card name */
206 char *dtbo_name; /* Device tree overlay to apply */
207 u8 eth_offset; /* ethXaddr MAC address index offset */
208} ext_cards[] = {
209 {
210 0x51,
211 "J7X-BASE-CPB",
212 "", /* No dtbo for this board */
213 0,
214 },
215 {
216 0x52,
217 "J7X-INFOTAN-EXP",
218 "", /* No dtbo for this board */
219 0,
220 },
221 {
222 0x52,
223 "J7X-GESI-EXP",
224 "", /* No dtbo for this board */
225 5, /* Start populating from eth5addr */
226 },
227 {
228 0x54,
229 "J7X-VSC8514-ETH",
230 "", /* No dtbo for this board */
231 1, /* Start populating from eth1addr */
232 },
233};
234
235static bool daughter_card_detect_flags[ARRAY_SIZE(ext_cards)];
236
237const char *board_fit_get_additionnal_images(int index, const char *type)
238{
239 int i, j;
240
241 if (strcmp(type, FIT_FDT_PROP))
242 return NULL;
243
244 j = 0;
245 for (i = 0; i < ARRAY_SIZE(ext_cards); i++) {
246 if (daughter_card_detect_flags[i]) {
247 if (j == index) {
248 /*
249 * Return dtbo name only if populated,
250 * otherwise stop parsing here.
251 */
252 if (strlen(ext_cards[i].dtbo_name))
253 return ext_cards[i].dtbo_name;
254 else
255 return NULL;
256 };
257
258 j++;
259 }
260 }
261
262 return NULL;
263}
264
265static int probe_daughtercards(void)
266{
267 char mac_addr[DAUGHTER_CARD_NO_OF_MAC_ADDR][TI_EEPROM_HDR_ETH_ALEN];
268 bool eeprom_read_success;
269 struct ti_am6_eeprom ep;
270 u8 previous_i2c_addr;
271 u8 mac_addr_cnt;
272 int i;
273 int ret;
274
275 /* Mark previous I2C address variable as not populated */
276 previous_i2c_addr = 0xff;
277
278 /* No EEPROM data was read yet */
279 eeprom_read_success = false;
280
281 /* Iterate through list of daughtercards */
282 for (i = 0; i < ARRAY_SIZE(ext_cards); i++) {
283 /* Obtain card-specific I2C address */
284 u8 i2c_addr = ext_cards[i].i2c_addr;
285
286 /* Read card EEPROM if not already read previously */
287 if (i2c_addr != previous_i2c_addr) {
288 /* Store I2C address so we can avoid reading twice */
289 previous_i2c_addr = i2c_addr;
290
291 /* Get and parse the daughter card EEPROM record */
292 ret = ti_i2c_eeprom_am6_get(CONFIG_EEPROM_BUS_ADDRESS,
293 i2c_addr,
294 &ep,
295 (char **)mac_addr,
296 DAUGHTER_CARD_NO_OF_MAC_ADDR,
297 &mac_addr_cnt);
298 if (ret) {
299 debug("%s: No daughtercard EEPROM at 0x%02x found %d\n",
300 __func__, i2c_addr, ret);
301 eeprom_read_success = false;
302 /* Skip to the next daughtercard to probe */
303 continue;
304 }
305
306 /* EEPROM read successful, okay to further process. */
307 eeprom_read_success = true;
308 }
309
310 /* Only continue processing if EEPROM data was read */
311 if (!eeprom_read_success)
312 continue;
313
314 /* Only process the parsed data if we found a match */
315 if (strncmp(ep.name, ext_cards[i].card_name, sizeof(ep.name)))
316 continue;
317
318 printf("Detected: %s rev %s\n", ep.name, ep.version);
319 daughter_card_detect_flags[i] = true;
320
321#ifndef CONFIG_SPL_BUILD
322 int j;
323 /*
324 * Populate any MAC addresses from daughtercard into the U-Boot
325 * environment, starting with a card-specific offset so we can
326 * have multiple ext_cards contribute to the MAC pool in a well-
327 * defined manner.
328 */
329 for (j = 0; j < mac_addr_cnt; j++) {
330 if (!is_valid_ethaddr((u8 *)mac_addr[j]))
331 continue;
332
333 eth_env_set_enetaddr_by_index("eth",
334 ext_cards[i].eth_offset + j,
335 (uchar *)mac_addr[j]);
336 }
Suman Anna8eac9e62019-06-13 10:29:50 +0530337#endif
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530338 }
339#ifndef CONFIG_SPL_BUILD
340 char name_overlays[1024] = { 0 };
341
342 for (i = 0; i < ARRAY_SIZE(ext_cards); i++) {
343 if (!daughter_card_detect_flags[i])
344 continue;
345
346 /* Skip if no overlays are to be added */
347 if (!strlen(ext_cards[i].dtbo_name))
348 continue;
349
350 /*
351 * Make sure we are not running out of buffer space by checking
352 * if we can fit the new overlay, a trailing space to be used
353 * as a separator, plus the terminating zero.
354 */
355 if (strlen(name_overlays) + strlen(ext_cards[i].dtbo_name) + 2 >
356 sizeof(name_overlays))
357 return -ENOMEM;
358
359 /* Append to our list of overlays */
360 strcat(name_overlays, ext_cards[i].dtbo_name);
361 strcat(name_overlays, " ");
362 }
363
364 /* Apply device tree overlay(s) to the U-Boot environment, if any */
365 if (strlen(name_overlays))
366 return env_set("name_overlays", name_overlays);
367#endif
368
369 return 0;
370}
Lokesh Vutla5a08e652020-08-05 22:44:14 +0530371#endif
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530372
Aswath Govindraju1e2b4202021-07-21 21:28:39 +0530373void configure_serdes_torrent(void)
374{
375 struct udevice *dev;
376 struct phy serdes;
377 int ret;
378
379 if (!IS_ENABLED(CONFIG_PHY_CADENCE_TORRENT))
380 return;
381
382 ret = uclass_get_device_by_driver(UCLASS_PHY,
383 DM_DRIVER_GET(torrent_phy_provider),
384 &dev);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530385 if (ret) {
Aswath Govindraju1e2b4202021-07-21 21:28:39 +0530386 printf("Torrent init failed:%d\n", ret);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530387 return;
388 }
Aswath Govindraju1e2b4202021-07-21 21:28:39 +0530389
390 serdes.dev = dev;
391 serdes.id = 0;
392
393 ret = generic_phy_init(&serdes);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530394 if (ret) {
395 printf("phy_init failed!!: %d\n", ret);
396 return;
397 }
Aswath Govindraju1e2b4202021-07-21 21:28:39 +0530398
399 ret = generic_phy_power_on(&serdes);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530400 if (ret) {
401 printf("phy_power_on failed!!: %d\n", ret);
402 return;
403 }
Aswath Govindraju1e2b4202021-07-21 21:28:39 +0530404}
405
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530406void configure_serdes_sierra(void)
407{
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530408 struct udevice *dev, *link_dev;
409 struct phy link;
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530410 int ret, count, i;
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530411 int link_count = 0;
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530412
413 if (!IS_ENABLED(CONFIG_PHY_CADENCE_SIERRA))
414 return;
415
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530416 ret = uclass_get_device_by_driver(UCLASS_MISC,
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530417 DM_DRIVER_GET(sierra_phy_provider),
418 &dev);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530419 if (ret) {
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530420 printf("Sierra init failed:%d\n", ret);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530421 return;
422 }
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530423
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530424 count = device_get_child_count(dev);
425 for (i = 0; i < count; i++) {
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530426 ret = device_get_child(dev, i, &link_dev);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530427 if (ret) {
428 printf("probe of sierra child node %d failed: %d\n", i, ret);
429 return;
430 }
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530431 if (link_dev->driver->id == UCLASS_PHY) {
432 link.dev = link_dev;
433 link.id = link_count++;
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530434
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530435 ret = generic_phy_power_on(&link);
Aswath Govindraju6dc4f6a2022-06-10 18:23:38 +0530436 if (ret) {
437 printf("phy_power_on failed!!: %d\n", ret);
438 return;
439 }
Aswath Govindraju5930ad22022-03-04 17:45:26 +0530440 }
441 }
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530442}
443
Sinthu Rajae861aa92022-02-09 15:06:48 +0530444#ifdef CONFIG_BOARD_LATE_INIT
445static void setup_board_eeprom_env(void)
446{
447 char *name = "j721e";
448
449 if (do_board_detect())
450 goto invalid_eeprom;
451
452 if (board_is_j721e_som())
453 name = "j721e";
Sinthu Raja1c24ab42022-02-09 15:06:50 +0530454 else if (board_is_j721e_sk())
455 name = "j721e-sk";
Sinthu Rajae861aa92022-02-09 15:06:48 +0530456 else if (board_is_j7200_som())
457 name = "j7200";
458 else
459 printf("Unidentified board claims %s in eeprom header\n",
460 board_ti_get_name());
461
462invalid_eeprom:
463 set_board_info_env_am6(name);
464}
465
466static void setup_serial(void)
467{
468 struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
469 unsigned long board_serial;
470 char *endp;
471 char serial_string[17] = { 0 };
472
473 if (env_get("serial#"))
474 return;
475
476 board_serial = hextoul(ep->serial, &endp);
477 if (*endp != '\0') {
478 pr_err("Error: Can't set serial# to %s\n", ep->serial);
479 return;
480 }
481
482 snprintf(serial_string, sizeof(serial_string), "%016lx", board_serial);
483 env_set("serial#", serial_string);
484}
485
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530486int board_late_init(void)
487{
Lokesh Vutla5a08e652020-08-05 22:44:14 +0530488 if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT)) {
489 setup_board_eeprom_env();
490 setup_serial();
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530491
Lokesh Vutla5a08e652020-08-05 22:44:14 +0530492 /* Check for and probe any plugged-in daughtercards */
Sinthu Raja9a4fa302022-02-09 15:06:51 +0530493 if (board_is_j721e_som() || board_is_j7200_som())
494 probe_daughtercards();
Lokesh Vutla5a08e652020-08-05 22:44:14 +0530495 }
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530496
Aswath Govindraju1e2b4202021-07-21 21:28:39 +0530497 if (board_is_j7200_som())
498 configure_serdes_torrent();
499
Aswath Govindrajua2775f32022-01-28 13:41:38 +0530500 if (board_is_j721e_som())
501 configure_serdes_sierra();
502
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530503 return 0;
504}
Sinthu Rajae861aa92022-02-09 15:06:48 +0530505#endif
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530506
Vaishnav Achathb8b17442022-05-09 11:50:16 +0530507static int __maybe_unused detect_SW3_1_state(void)
508{
509 if (IS_ENABLED(CONFIG_TARGET_J7200_A72_EVM) || IS_ENABLED(CONFIG_TARGET_J721E_A72_EVM)) {
510 struct gpio_desc desc = {0};
511 int ret;
512 char *hypermux_sel_gpio = (board_is_j721e_som()) ? "8" : "6";
513
514 ret = dm_gpio_lookup_name(hypermux_sel_gpio, &desc);
515 if (ret) {
516 printf("error getting GPIO lookup name: %d\n", ret);
517 return ret;
518 }
519
520 ret = dm_gpio_request(&desc, hypermux_sel_gpio);
521 if (ret) {
522 printf("error requesting GPIO: %d\n", ret);
523 goto err_free_gpio;
524 }
525
526 ret = dm_gpio_set_dir_flags(&desc, GPIOD_IS_IN);
527 if (ret) {
528 printf("error setting direction flag of GPIO: %d\n", ret);
529 goto err_free_gpio;
530 }
531
532 ret = dm_gpio_get_value(&desc);
533 if (ret < 0)
534 printf("error getting value of GPIO: %d\n", ret);
535
536err_free_gpio:
537 dm_gpio_free(desc.dev, &desc);
538 return ret;
539 }
540}
541
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530542void spl_board_init(void)
543{
Tero Kristo1a2c7ba2020-02-14 11:18:19 +0200544#if defined(CONFIG_ESM_K3) || defined(CONFIG_ESM_PMIC)
545 struct udevice *dev;
546 int ret;
547#endif
548
Lokesh Vutla046ad432020-08-05 22:44:24 +0530549 if ((IS_ENABLED(CONFIG_TARGET_J721E_A72_EVM) ||
550 IS_ENABLED(CONFIG_TARGET_J7200_A72_EVM)) &&
Sinthu Raja9a4fa302022-02-09 15:06:51 +0530551 IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT)) {
552 if (!board_is_j721e_sk())
553 probe_daughtercards();
554 }
Tero Kristo1a2c7ba2020-02-14 11:18:19 +0200555
556#ifdef CONFIG_ESM_K3
557 if (board_ti_k3_is("J721EX-PM2-SOM")) {
558 ret = uclass_get_device_by_driver(UCLASS_MISC,
Simon Glass65130cd2020-12-28 20:34:56 -0700559 DM_DRIVER_GET(k3_esm), &dev);
Tero Kristo1a2c7ba2020-02-14 11:18:19 +0200560 if (ret)
561 printf("ESM init failed: %d\n", ret);
562 }
563#endif
564
565#ifdef CONFIG_ESM_PMIC
566 if (board_ti_k3_is("J721EX-PM2-SOM")) {
567 ret = uclass_get_device_by_driver(UCLASS_MISC,
Simon Glass65130cd2020-12-28 20:34:56 -0700568 DM_DRIVER_GET(pmic_esm),
Tero Kristo1a2c7ba2020-02-14 11:18:19 +0200569 &dev);
570 if (ret)
571 printf("ESM PMIC init failed: %d\n", ret);
572 }
573#endif
Vaishnav Achathb8b17442022-05-09 11:50:16 +0530574 if ((IS_ENABLED(CONFIG_TARGET_J7200_A72_EVM) || IS_ENABLED(CONFIG_TARGET_J721E_A72_EVM)) &&
575 IS_ENABLED(CONFIG_HBMC_AM654)) {
576 struct udevice *dev;
577 int ret;
578
579 ret = detect_SW3_1_state();
580 if (ret == 1) {
581 ret = uclass_get_device_by_driver(UCLASS_MTD,
582 DM_DRIVER_GET(hbmc_am654),
583 &dev);
584 if (ret)
585 debug("Failed to probe hyperflash\n");
586 }
587 }
Andreas Dannenbergd036a212020-01-07 13:15:54 +0530588}