Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | // SPDX-License-Identifier: GPL-2.0-or-later /* Copyright (C) 2025 Toradex */ #include <asm/arch/clock.h> #include <asm/arch/mu.h> #include <asm/arch/sys_proto.h> #include <asm/mach-imx/boot_mode.h> #include <asm/mach-imx/ele_api.h> #include <asm/sections.h> #include <asm/global_data.h> #include <clk.h> #include <dm/ofnode.h> #include <dm/uclass.h> #include <hang.h> #include <i2c.h> #include <init.h> #include <spl.h> DECLARE_GLOBAL_DATA_PTR; #define EC_I2C_BUS_NODE_PATH "/soc/bus@42000000/i2c@42540000" int spl_board_boot_device(enum boot_device boot_dev_spl) { switch (boot_dev_spl) { case SD1_BOOT: case MMC1_BOOT: return BOOT_DEVICE_MMC1; case SD2_BOOT: case MMC2_BOOT: return BOOT_DEVICE_MMC2; case USB_BOOT: return BOOT_DEVICE_BOARD; default: return BOOT_DEVICE_NONE; } } static void ec_boot_notify(void) { struct udevice *bus; struct udevice *i2c_dev; ofnode node; int ret; u8 val = 0x03; node = ofnode_path(EC_I2C_BUS_NODE_PATH); if (!ofnode_valid(node)) { puts("Failed to find Toradex EC I2C BUS node\n"); return; } ret = uclass_get_device_by_ofnode(UCLASS_I2C, node, &bus); if (ret) { puts("Failed to get Toradex EC I2C BUS\n"); return; } ret = dm_i2c_probe(bus, 0x28, 0, &i2c_dev); if (ret) { puts("Toradex EC not found\n"); return; } /* USB configuration before this command (when SoC starts in recovery): * - SoC USB1 -> Smarc USB0 * - SoC USB2 -> NC * After the command: * - SoC USB1 -> SoM hub -> Smarc USB1, USB2, USB3 and USB4 * - SoC USB2 -> Smarc USB0 */ ret = dm_i2c_write(i2c_dev, 0xD0, &val, 1); if (ret) puts("Cannot send command to Toradex EC\n"); } void spl_board_init(void) { int ret; ret = ele_start_rng(); if (ret) printf("Fail to start RNG: %d\n", ret); } void board_init_f(ulong dummy) { int ret; /* Clear the BSS. */ memset(__bss_start, 0, __bss_end - __bss_start); if (IS_ENABLED(CONFIG_SPL_RECOVER_DATA_SECTION)) spl_save_restore_data(); timer_init(); /* Need dm_init() to run before any SCMI calls */ spl_early_init(); /* Need to enable SCMI drivers and ELE driver before console */ ret = imx9_probe_mu(); if (ret) hang(); /* MU not probed, nothing can be outputed, hang */ arch_cpu_init(); preloader_console_init(); debug("SOC: 0x%x\n", gd->arch.soc_rev); debug("LC: 0x%x\n", gd->arch.lifecycle); ec_boot_notify(); get_reset_reason(true, false); board_init_r(NULL, 0); } |