1 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
3 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
6 #define LOG_CATEGORY LOGC_BOARD
14 #include <efi_loader.h>
16 #include <env_internal.h>
17 #include <fdt_simplefb.h>
18 #include <fdt_support.h>
20 #include <generic-phy.h>
31 #include <remoteproc.h>
36 #include <asm/global_data.h>
39 #include <asm/arch/stm32.h>
40 #include <asm/arch/sys_proto.h>
41 #include <dm/ofnode.h>
42 #include <jffs2/load_kernel.h>
43 #include <linux/bitops.h>
44 #include <linux/delay.h>
45 #include <linux/err.h>
46 #include <linux/iopoll.h>
47 #include <power/regulator.h>
48 #include <usb/dwc2_udc.h>
50 #include "../../st/common/stusb160x.h"
52 /* SYSCFG registers */
53 #define SYSCFG_BOOTR 0x00
54 #define SYSCFG_PMCSETR 0x04
55 #define SYSCFG_IOCTRLSETR 0x18
56 #define SYSCFG_ICNR 0x1C
57 #define SYSCFG_CMPCR 0x20
58 #define SYSCFG_CMPENSETR 0x24
59 #define SYSCFG_PMCCLRR 0x44
61 #define SYSCFG_BOOTR_BOOT_MASK GENMASK(2, 0)
62 #define SYSCFG_BOOTR_BOOTPD_SHIFT 4
64 #define SYSCFG_IOCTRLSETR_HSLVEN_TRACE BIT(0)
65 #define SYSCFG_IOCTRLSETR_HSLVEN_QUADSPI BIT(1)
66 #define SYSCFG_IOCTRLSETR_HSLVEN_ETH BIT(2)
67 #define SYSCFG_IOCTRLSETR_HSLVEN_SDMMC BIT(3)
68 #define SYSCFG_IOCTRLSETR_HSLVEN_SPI BIT(4)
70 #define SYSCFG_CMPCR_SW_CTRL BIT(1)
71 #define SYSCFG_CMPCR_READY BIT(8)
73 #define SYSCFG_CMPENSETR_MPU_EN BIT(0)
75 #define SYSCFG_PMCSETR_ETH_CLK_SEL BIT(16)
76 #define SYSCFG_PMCSETR_ETH_REF_CLK_SEL BIT(17)
78 #define SYSCFG_PMCSETR_ETH_SELMII BIT(20)
80 #define SYSCFG_PMCSETR_ETH_SEL_MASK GENMASK(23, 21)
81 #define SYSCFG_PMCSETR_ETH_SEL_GMII_MII 0
82 #define SYSCFG_PMCSETR_ETH_SEL_RGMII BIT(21)
83 #define SYSCFG_PMCSETR_ETH_SEL_RMII BIT(23)
85 #define USB_LOW_THRESHOLD_UV 200000
86 #define USB_WARNING_LOW_THRESHOLD_UV 660000
87 #define USB_START_LOW_THRESHOLD_UV 1230000
88 #define USB_START_HIGH_THRESHOLD_UV 2150000
90 #if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)
91 struct efi_fw_image fw_images[1];
93 struct efi_capsule_update_info update_info = {
94 .num_images = ARRAY_SIZE(fw_images),
98 #endif /* EFI_HAVE_CAPSULE_SUPPORT */
100 int board_early_init_f(void)
102 /* nothing to do, only used in SPL */
112 const char *fdt_compat;
115 if (IS_ENABLED(CONFIG_TFABOOT)) {
116 if (IS_ENABLED(CONFIG_STM32MP15x_STM32IMAGE))
117 mode = "trusted - stm32image";
124 fdt_compat = ofnode_get_property(ofnode_root(), "compatible",
127 log_info("Board: stm32mp1 in %s mode (%s)\n", mode,
128 fdt_compat && fdt_compat_len ? fdt_compat : "");
130 /* display the STMicroelectronics board identification */
131 if (IS_ENABLED(CONFIG_CMD_STBOARD)) {
132 ret = uclass_get_device_by_driver(UCLASS_MISC,
133 DM_DRIVER_GET(stm32mp_bsec),
136 ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD),
139 log_info("Board: MB%04x Var%d.%d Rev.%c-%02d\n",
143 ((otp >> 8) & 0xF) - 1 + 'A',
150 static void board_key_check(void)
153 struct gpio_desc gpio;
154 enum forced_boot_mode boot_mode = BOOT_NORMAL;
156 if (!IS_ENABLED(CONFIG_FASTBOOT) && !IS_ENABLED(CONFIG_CMD_STM32PROG))
159 node = ofnode_path("/config");
160 if (!ofnode_valid(node)) {
161 log_debug("no /config node?\n");
164 if (IS_ENABLED(CONFIG_FASTBOOT)) {
165 if (gpio_request_by_name_nodev(node, "st,fastboot-gpios", 0,
166 &gpio, GPIOD_IS_IN)) {
167 log_debug("could not find a /config/st,fastboot-gpios\n");
170 if (dm_gpio_get_value(&gpio)) {
171 log_notice("Fastboot key pressed, ");
172 boot_mode = BOOT_FASTBOOT;
175 dm_gpio_free(NULL, &gpio);
178 if (IS_ENABLED(CONFIG_CMD_STM32PROG)) {
179 if (gpio_request_by_name_nodev(node, "st,stm32prog-gpios", 0,
180 &gpio, GPIOD_IS_IN)) {
181 log_debug("could not find a /config/st,stm32prog-gpios\n");
184 if (dm_gpio_get_value(&gpio)) {
185 log_notice("STM32Programmer key pressed, ");
186 boot_mode = BOOT_STM32PROG;
188 dm_gpio_free(NULL, &gpio);
191 if (boot_mode != BOOT_NORMAL) {
192 log_notice("entering download mode...\n");
193 clrsetbits_le32(TAMP_BOOT_CONTEXT,
194 TAMP_BOOT_FORCED_MASK,
199 int g_dnl_board_usb_cable_connected(void)
201 struct udevice *dwc2_udc_otg;
204 if (!IS_ENABLED(CONFIG_USB_GADGET_DWC2_OTG))
208 * In case of USB boot device is detected, consider USB cable is
211 if ((get_bootmode() & TAMP_BOOT_DEVICE_MASK) == BOOT_SERIAL_USB)
214 /* if typec stusb160x is present, means DK1 or DK2 board */
215 ret = stusb160x_cable_connected();
219 ret = uclass_get_device_by_driver(UCLASS_USB_GADGET_GENERIC,
220 DM_DRIVER_GET(dwc2_udc_otg),
223 log_debug("dwc2_udc_otg init failed\n");
227 return dwc2_udc_B_session_valid(dwc2_udc_otg);
230 #ifdef CONFIG_USB_GADGET_DOWNLOAD
231 #define STM32MP1_G_DNL_DFU_PRODUCT_NUM 0xdf11
232 #define STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM 0x0afb
234 int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
236 if (IS_ENABLED(CONFIG_DFU_OVER_USB) &&
237 !strcmp(name, "usb_dnl_dfu"))
238 put_unaligned(STM32MP1_G_DNL_DFU_PRODUCT_NUM, &dev->idProduct);
239 else if (IS_ENABLED(CONFIG_FASTBOOT) &&
240 !strcmp(name, "usb_dnl_fastboot"))
241 put_unaligned(STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM,
244 put_unaligned(CONFIG_USB_GADGET_PRODUCT_NUM, &dev->idProduct);
248 #endif /* CONFIG_USB_GADGET_DOWNLOAD */
250 static int get_led(struct udevice **dev, char *led_string)
252 const char *led_name;
255 led_name = ofnode_conf_read_str(led_string);
257 log_debug("could not find %s config string\n", led_string);
260 ret = led_get_by_label(led_name, dev);
262 log_debug("get=%d\n", ret);
269 static int setup_led(enum led_state_t cmd)
274 if (!CONFIG_IS_ENABLED(LED))
277 ret = get_led(&dev, "u-boot,boot-led");
281 ret = led_set_state(dev, cmd);
285 static void __maybe_unused led_error_blink(u32 nb_blink)
294 if (CONFIG_IS_ENABLED(LED)) {
295 ret = get_led(&led, "u-boot,error-led");
297 /* make u-boot,error-led blinking */
298 /* if U32_MAX and 125ms interval, for 17.02 years */
299 for (i = 0; i < 2 * nb_blink; i++) {
300 led_set_state(led, LEDST_TOGGLE);
304 led_set_state(led, LEDST_ON);
308 /* infinite: the boot process must be stopped */
309 if (nb_blink == U32_MAX)
313 static int adc_measurement(ofnode node, int adc_count, int *min_uV, int *max_uV)
315 struct ofnode_phandle_args adc_args;
321 for (i = 0; i < adc_count; i++) {
322 if (ofnode_parse_phandle_with_args(node, "st,adc_usb_pd",
323 "#io-channel-cells", 0, i,
325 log_debug("can't find /config/st,adc_usb_pd\n");
329 ret = uclass_get_device_by_ofnode(UCLASS_ADC, adc_args.node,
333 log_err("Can't get adc device(%d)\n", ret);
337 ret = adc_channel_single_shot(adc->name, adc_args.args[0],
340 log_err("single shot failed for %s[%d]!\n",
341 adc->name, adc_args.args[0]);
345 if (!adc_raw_to_uV(adc, raw, &uV)) {
350 log_debug("%s[%02d] = %u, %d uV\n",
351 adc->name, adc_args.args[0], raw, uV);
353 log_err("Can't get uV value for %s[%d]\n",
354 adc->name, adc_args.args[0]);
361 static int board_check_usb_power(void)
365 int min_uV = USB_START_HIGH_THRESHOLD_UV;
370 if (!IS_ENABLED(CONFIG_ADC))
373 node = ofnode_path("/config");
374 if (!ofnode_valid(node)) {
375 log_debug("no /config node?\n");
380 * Retrieve the ADC channels devices and get measurement
383 adc_count = ofnode_count_phandle_with_args(node, "st,adc_usb_pd",
384 "#io-channel-cells", 0);
386 if (adc_count == -ENOENT)
389 log_err("Can't find adc channel (%d)\n", adc_count);
394 /* perform maximum of 2 ADC measurements to detect power supply current */
395 for (i = 0; i < 2; i++) {
396 ret = adc_measurement(node, adc_count, &min_uV, &max_uV);
401 * If highest value is inside 1.23 Volts and 2.10 Volts, that means
402 * board is plugged on an USB-C 3A power supply and boot process can
405 if (max_uV > USB_START_LOW_THRESHOLD_UV &&
406 max_uV <= USB_START_HIGH_THRESHOLD_UV &&
407 min_uV <= USB_LOW_THRESHOLD_UV)
411 log_err("Previous ADC measurements was not the one expected, retry in 20ms\n");
412 mdelay(20); /* equal to max tPDDebounce duration (min 10ms - max 20ms) */
416 log_notice("****************************************************\n");
418 * If highest and lowest value are either both below
419 * USB_LOW_THRESHOLD_UV or both above USB_LOW_THRESHOLD_UV, that
420 * means USB TYPE-C is in unattached mode, this is an issue, make
421 * u-boot,error-led blinking and stop boot process.
423 if ((max_uV > USB_LOW_THRESHOLD_UV &&
424 min_uV > USB_LOW_THRESHOLD_UV) ||
425 (max_uV <= USB_LOW_THRESHOLD_UV &&
426 min_uV <= USB_LOW_THRESHOLD_UV)) {
427 log_notice("* ERROR USB TYPE-C connection in unattached mode *\n");
428 log_notice("* Check that USB TYPE-C cable is correctly plugged *\n");
429 /* with 125ms interval, led will blink for 17.02 years ....*/
433 if (max_uV > USB_LOW_THRESHOLD_UV &&
434 max_uV <= USB_WARNING_LOW_THRESHOLD_UV &&
435 min_uV <= USB_LOW_THRESHOLD_UV) {
436 log_notice("* WARNING 500mA power supply detected *\n");
440 if (max_uV > USB_WARNING_LOW_THRESHOLD_UV &&
441 max_uV <= USB_START_LOW_THRESHOLD_UV &&
442 min_uV <= USB_LOW_THRESHOLD_UV) {
443 log_notice("* WARNING 1.5A power supply detected *\n");
448 * If highest value is above 2.15 Volts that means that the USB TypeC
449 * supplies more than 3 Amp, this is not compliant with TypeC specification
451 if (max_uV > USB_START_HIGH_THRESHOLD_UV) {
452 log_notice("* USB TYPE-C charger not compliant with *\n");
453 log_notice("* specification *\n");
454 log_notice("****************************************************\n\n");
455 /* with 125ms interval, led will blink for 17.02 years ....*/
458 log_notice("* Current too low, use a 3A power supply! *\n");
459 log_notice("****************************************************\n\n");
462 led_error_blink(nb_blink);
467 static void sysconf_init(void)
470 struct udevice *pwr_dev;
471 struct udevice *pwr_reg;
477 syscfg = (u8 *)syscon_get_first_range(STM32MP_SYSCON_SYSCFG);
479 /* interconnect update : select master using the port 1 */
482 /* today information is hardcoded in U-Boot */
483 writel(BIT(9), syscfg + SYSCFG_ICNR);
485 /* disable Pull-Down for boot pin connected to VDD */
486 bootr = readl(syscfg + SYSCFG_BOOTR);
487 bootr &= ~(SYSCFG_BOOTR_BOOT_MASK << SYSCFG_BOOTR_BOOTPD_SHIFT);
488 bootr |= (bootr & SYSCFG_BOOTR_BOOT_MASK) << SYSCFG_BOOTR_BOOTPD_SHIFT;
489 writel(bootr, syscfg + SYSCFG_BOOTR);
491 /* High Speed Low Voltage Pad mode Enable for SPI, SDMMC, ETH, QSPI
492 * and TRACE. Needed above ~50MHz and conditioned by AFMUX selection.
493 * The customer will have to disable this for low frequencies
494 * or if AFMUX is selected but the function not used, typically for
495 * TRACE. Otherwise, impact on power consumption.
498 * enabling High Speed mode while VDD>2.7V
499 * with the OTP product_below_2v5 (OTP 18, BIT 13)
500 * erroneously set to 1 can damage the IC!
501 * => U-Boot set the register only if VDD < 2.7V (in DT)
502 * but this value need to be consistent with board design
504 ret = uclass_get_device_by_driver(UCLASS_PMIC,
505 DM_DRIVER_GET(stm32mp_pwr_pmic),
508 ret = uclass_get_device_by_driver(UCLASS_MISC,
509 DM_DRIVER_GET(stm32mp_bsec),
512 log_err("Can't find stm32mp_bsec driver\n");
516 ret = misc_read(dev, STM32_BSEC_SHADOW(18), &otp, 4);
520 /* get VDD = vdd-supply */
521 ret = device_get_supply_regulator(pwr_dev, "vdd-supply",
524 /* check if VDD is Low Voltage */
526 if (regulator_get_value(pwr_reg) < 2700000) {
527 writel(SYSCFG_IOCTRLSETR_HSLVEN_TRACE |
528 SYSCFG_IOCTRLSETR_HSLVEN_QUADSPI |
529 SYSCFG_IOCTRLSETR_HSLVEN_ETH |
530 SYSCFG_IOCTRLSETR_HSLVEN_SDMMC |
531 SYSCFG_IOCTRLSETR_HSLVEN_SPI,
532 syscfg + SYSCFG_IOCTRLSETR);
535 log_err("product_below_2v5=0: HSLVEN protected by HW\n");
538 log_err("product_below_2v5=1: HSLVEN update is destructive, no update as VDD>2.7V\n");
541 log_debug("VDD unknown");
545 /* activate automatic I/O compensation
546 * warning: need to ensure CSI enabled and ready in clock driver
548 writel(SYSCFG_CMPENSETR_MPU_EN, syscfg + SYSCFG_CMPENSETR);
550 /* poll until ready (1s timeout) */
551 ret = readl_poll_timeout(syscfg + SYSCFG_CMPCR, val,
552 val & SYSCFG_CMPCR_READY,
555 log_err("SYSCFG: I/O compensation failed, timeout.\n");
559 clrbits_le32(syscfg + SYSCFG_CMPCR, SYSCFG_CMPCR_SW_CTRL);
562 static int board_stm32mp15x_dk2_init(void)
565 struct gpio_desc hdmi, audio;
568 /* Fix to make I2C1 usable on DK2 for touchscreen usage in kernel */
569 node = ofnode_path("/soc/i2c@40012000/hdmi-transmitter@39");
570 if (!ofnode_valid(node)) {
571 log_debug("no hdmi-transmitter@39 ?\n");
575 if (gpio_request_by_name_nodev(node, "reset-gpios", 0,
576 &hdmi, GPIOD_IS_OUT)) {
577 log_debug("could not find reset-gpios\n");
581 node = ofnode_path("/soc/i2c@40012000/cs42l51@4a");
582 if (!ofnode_valid(node)) {
583 log_debug("no cs42l51@4a ?\n");
587 if (gpio_request_by_name_nodev(node, "reset-gpios", 0,
588 &audio, GPIOD_IS_OUT)) {
589 log_debug("could not find reset-gpios\n");
593 /* before power up, insure that HDMI and AUDIO IC is under reset */
594 ret = dm_gpio_set_value(&hdmi, 1);
596 log_err("can't set_value for hdmi_nrst gpio");
599 ret = dm_gpio_set_value(&audio, 1);
601 log_err("can't set_value for audio_nrst gpio");
605 /* power-up audio IC */
606 regulator_autoset_by_name("v1v8_audio", NULL);
608 /* power-up HDMI IC */
609 regulator_autoset_by_name("v1v2_hdmi", NULL);
610 regulator_autoset_by_name("v3v3_hdmi", NULL);
616 static bool board_is_stm32mp15x_dk2(void)
618 if (CONFIG_IS_ENABLED(TARGET_ST_STM32MP15x) &&
619 of_machine_is_compatible("st,stm32mp157c-dk2"))
625 static bool board_is_stm32mp15x_ev1(void)
627 if (CONFIG_IS_ENABLED(TARGET_ST_STM32MP15x) &&
628 (of_machine_is_compatible("st,stm32mp157a-ev1") ||
629 of_machine_is_compatible("st,stm32mp157c-ev1") ||
630 of_machine_is_compatible("st,stm32mp157d-ev1") ||
631 of_machine_is_compatible("st,stm32mp157f-ev1")))
637 /* touchscreen driver: only used for pincontrol configuration */
638 static const struct udevice_id goodix_ids[] = {
639 { .compatible = "goodix,gt9147", },
643 U_BOOT_DRIVER(goodix) = {
646 .of_match = goodix_ids,
649 static void board_stm32mp15x_ev1_init(void)
653 /* configure IRQ line on EV1 for touchscreen before LCD reset */
654 uclass_get_device_by_driver(UCLASS_NOP, DM_DRIVER_GET(goodix), &dev);
657 /* board dependent setup after realloc */
662 if (board_is_stm32mp15x_ev1())
663 board_stm32mp15x_ev1_init();
665 if (board_is_stm32mp15x_dk2())
666 board_stm32mp15x_dk2_init();
668 regulators_enable_boot_on(_DEBUG);
671 * sysconf initialisation done only when U-Boot is running in secure
672 * done in TF-A for TFABOOT.
674 if (IS_ENABLED(CONFIG_ARMV7_NONSEC))
679 #if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)
680 efi_guid_t image_type_guid = STM32MP_FIP_IMAGE_GUID;
682 guidcpy(&fw_images[0].image_type_id, &image_type_guid);
683 fw_images[0].fw_name = u"STM32MP-FIP";
684 fw_images[0].image_index = 1;
689 int board_late_init(void)
691 const void *fdt_compat;
700 if (IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG)) {
701 fdt_compat = ofnode_get_property(ofnode_root(), "compatible",
703 if (fdt_compat && fdt_compat_len) {
704 if (strncmp(fdt_compat, "st,", 3) != 0) {
705 env_set("board_name", fdt_compat);
707 env_set("board_name", fdt_compat + 3);
709 buf_len = sizeof(dtb_name);
710 strncpy(dtb_name, fdt_compat + 3, buf_len);
711 buf_len -= strlen(fdt_compat + 3);
712 strncat(dtb_name, ".dtb", buf_len);
713 env_set("fdtfile", dtb_name);
716 ret = uclass_get_device_by_driver(UCLASS_MISC,
717 DM_DRIVER_GET(stm32mp_bsec),
721 ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD),
723 if (ret > 0 && otp) {
724 snprintf(buf, sizeof(buf), "0x%04x", otp >> 16);
725 env_set("board_id", buf);
727 snprintf(buf, sizeof(buf), "0x%04x",
728 ((otp >> 8) & 0xF) - 1 + 0xA);
729 env_set("board_rev", buf);
733 /* for DK1/DK2 boards */
734 board_check_usb_power();
739 void board_quiesce_devices(void)
741 setup_led(LEDST_OFF);
744 /* eth init function : weak called in eqos driver */
745 int board_interface_eth_init(struct udevice *dev,
746 phy_interface_t interface_type)
750 bool eth_clk_sel_reg = false;
751 bool eth_ref_clk_sel_reg = false;
753 /* Gigabit Ethernet 125MHz clock selection. */
754 eth_clk_sel_reg = dev_read_bool(dev, "st,eth-clk-sel");
756 /* Ethernet 50Mhz RMII clock selection */
757 eth_ref_clk_sel_reg =
758 dev_read_bool(dev, "st,eth-ref-clk-sel");
760 syscfg = (u8 *)syscon_get_first_range(STM32MP_SYSCON_SYSCFG);
765 switch (interface_type) {
766 case PHY_INTERFACE_MODE_MII:
767 value = SYSCFG_PMCSETR_ETH_SEL_GMII_MII |
768 SYSCFG_PMCSETR_ETH_REF_CLK_SEL;
769 log_debug("PHY_INTERFACE_MODE_MII\n");
771 case PHY_INTERFACE_MODE_GMII:
773 value = SYSCFG_PMCSETR_ETH_SEL_GMII_MII |
774 SYSCFG_PMCSETR_ETH_CLK_SEL;
776 value = SYSCFG_PMCSETR_ETH_SEL_GMII_MII;
777 log_debug("PHY_INTERFACE_MODE_GMII\n");
779 case PHY_INTERFACE_MODE_RMII:
780 if (eth_ref_clk_sel_reg)
781 value = SYSCFG_PMCSETR_ETH_SEL_RMII |
782 SYSCFG_PMCSETR_ETH_REF_CLK_SEL;
784 value = SYSCFG_PMCSETR_ETH_SEL_RMII;
785 log_debug("PHY_INTERFACE_MODE_RMII\n");
787 case PHY_INTERFACE_MODE_RGMII:
788 case PHY_INTERFACE_MODE_RGMII_ID:
789 case PHY_INTERFACE_MODE_RGMII_RXID:
790 case PHY_INTERFACE_MODE_RGMII_TXID:
792 value = SYSCFG_PMCSETR_ETH_SEL_RGMII |
793 SYSCFG_PMCSETR_ETH_CLK_SEL;
795 value = SYSCFG_PMCSETR_ETH_SEL_RGMII;
796 log_debug("PHY_INTERFACE_MODE_RGMII\n");
799 log_debug("Do not manage %d interface\n",
801 /* Do not manage others interfaces */
805 /* clear and set ETH configuration bits */
806 writel(SYSCFG_PMCSETR_ETH_SEL_MASK | SYSCFG_PMCSETR_ETH_SELMII |
807 SYSCFG_PMCSETR_ETH_REF_CLK_SEL | SYSCFG_PMCSETR_ETH_CLK_SEL,
808 syscfg + SYSCFG_PMCCLRR);
809 writel(value, syscfg + SYSCFG_PMCSETR);
814 enum env_location env_get_location(enum env_operation op, int prio)
816 u32 bootmode = get_bootmode();
821 switch (bootmode & TAMP_BOOT_DEVICE_MASK) {
823 case BOOT_FLASH_EMMC:
824 if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC))
826 else if (CONFIG_IS_ENABLED(ENV_IS_IN_EXT4))
831 case BOOT_FLASH_NAND:
832 case BOOT_FLASH_SPINAND:
833 if (IS_ENABLED(CONFIG_ENV_IS_IN_UBI))
839 if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH))
840 return ENVL_SPI_FLASH;
849 const char *env_ext4_get_intf(void)
851 u32 bootmode = get_bootmode();
853 switch (bootmode & TAMP_BOOT_DEVICE_MASK) {
855 case BOOT_FLASH_EMMC:
862 int mmc_get_boot(void)
865 u32 boot_mode = get_bootmode();
866 unsigned int instance = (boot_mode & TAMP_BOOT_INSTANCE_MASK) - 1;
868 const u32 sdmmc_addr[] = {
874 if (instance >= ARRAY_SIZE(sdmmc_addr))
877 /* search associated sdmmc node in devicetree */
878 snprintf(cmd, sizeof(cmd), "mmc@%x", sdmmc_addr[instance]);
879 if (uclass_get_device_by_name(UCLASS_MMC, cmd, &dev)) {
880 log_err("mmc%d = %s not found in device tree!\n", instance, cmd);
887 const char *env_ext4_get_dev_part(void)
889 static char *const env_dev_part =
890 #ifdef CONFIG_ENV_EXT4_DEVICE_AND_PART
891 CONFIG_ENV_EXT4_DEVICE_AND_PART;
895 static char *const dev_part[] = {"0:auto", "1:auto", "2:auto"};
897 if (strlen(env_dev_part) > 0)
900 return dev_part[mmc_get_boot()];
903 int mmc_get_env_dev(void)
905 const int mmc_env_dev = CONFIG_IS_ENABLED(ENV_IS_IN_MMC, (CONFIG_SYS_MMC_ENV_DEV), (-1));
907 if (mmc_env_dev >= 0)
910 /* use boot instance to select the correct mmc device identifier */
911 return mmc_get_boot();
914 #if defined(CONFIG_OF_BOARD_SETUP)
915 int ft_board_setup(void *blob, struct bd_info *bd)
917 fdt_copy_fixed_partitions(blob);
919 if (IS_ENABLED(CONFIG_FDT_SIMPLEFB))
920 fdt_simplefb_enable_and_mem_rsv(blob);
926 static void board_copro_image_process(ulong fw_image, size_t fw_size)
928 int ret, id = 0; /* Copro id fixed to 0 as only one coproc on mp1 */
930 if (!rproc_is_initialized())
932 log_err("Remote Processor %d initialization failed\n",
937 ret = rproc_load(id, fw_image, fw_size);
938 log_err("Load Remote Processor %d with data@addr=0x%08lx %u bytes:%s\n",
939 id, fw_image, fw_size, ret ? " Failed!" : " Success!");
945 U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_COPRO, board_copro_image_process);
947 #if defined(CONFIG_FWU_MULTI_BANK_UPDATE)
952 * fwu_plat_get_bootidx() - Get the value of the boot index
953 * @boot_idx: Boot index value
955 * Get the value of the bank(partition) from which the platform
956 * has booted. This value is passed to U-Boot from the earlier
957 * stage bootloader which loads and boots all the relevant
961 void fwu_plat_get_bootidx(uint *boot_idx)
963 *boot_idx = (readl(TAMP_FWU_BOOT_INFO_REG) >>
964 TAMP_FWU_BOOT_IDX_OFFSET) & TAMP_FWU_BOOT_IDX_MASK;
966 #endif /* CONFIG_FWU_MULTI_BANK_UPDATE */