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
15 #include <env_internal.h>
16 #include <fdt_support.h>
18 #include <generic-phy.h>
30 #include <remoteproc.h>
35 #include <asm/global_data.h>
38 #include <asm/arch/stm32.h>
39 #include <asm/arch/sys_proto.h>
40 #include <dm/ofnode.h>
41 #include <jffs2/load_kernel.h>
42 #include <linux/bitops.h>
43 #include <linux/delay.h>
44 #include <linux/err.h>
45 #include <linux/iopoll.h>
46 #include <power/regulator.h>
47 #include <usb/dwc2_udc.h>
49 #include "../../st/common/stusb160x.h"
51 /* SYSCFG registers */
52 #define SYSCFG_BOOTR 0x00
53 #define SYSCFG_PMCSETR 0x04
54 #define SYSCFG_IOCTRLSETR 0x18
55 #define SYSCFG_ICNR 0x1C
56 #define SYSCFG_CMPCR 0x20
57 #define SYSCFG_CMPENSETR 0x24
58 #define SYSCFG_PMCCLRR 0x44
60 #define SYSCFG_BOOTR_BOOT_MASK GENMASK(2, 0)
61 #define SYSCFG_BOOTR_BOOTPD_SHIFT 4
63 #define SYSCFG_IOCTRLSETR_HSLVEN_TRACE BIT(0)
64 #define SYSCFG_IOCTRLSETR_HSLVEN_QUADSPI BIT(1)
65 #define SYSCFG_IOCTRLSETR_HSLVEN_ETH BIT(2)
66 #define SYSCFG_IOCTRLSETR_HSLVEN_SDMMC BIT(3)
67 #define SYSCFG_IOCTRLSETR_HSLVEN_SPI BIT(4)
69 #define SYSCFG_CMPCR_SW_CTRL BIT(1)
70 #define SYSCFG_CMPCR_READY BIT(8)
72 #define SYSCFG_CMPENSETR_MPU_EN BIT(0)
74 #define SYSCFG_PMCSETR_ETH_CLK_SEL BIT(16)
75 #define SYSCFG_PMCSETR_ETH_REF_CLK_SEL BIT(17)
77 #define SYSCFG_PMCSETR_ETH_SELMII BIT(20)
79 #define SYSCFG_PMCSETR_ETH_SEL_MASK GENMASK(23, 21)
80 #define SYSCFG_PMCSETR_ETH_SEL_GMII_MII 0
81 #define SYSCFG_PMCSETR_ETH_SEL_RGMII BIT(21)
82 #define SYSCFG_PMCSETR_ETH_SEL_RMII BIT(23)
85 * Get a global data pointer
87 DECLARE_GLOBAL_DATA_PTR;
89 #define USB_LOW_THRESHOLD_UV 200000
90 #define USB_WARNING_LOW_THRESHOLD_UV 660000
91 #define USB_START_LOW_THRESHOLD_UV 1230000
92 #define USB_START_HIGH_THRESHOLD_UV 2150000
94 int board_early_init_f(void)
96 /* nothing to do, only used in SPL */
106 const char *fdt_compat;
109 if (IS_ENABLED(CONFIG_TFABOOT)) {
110 if (IS_ENABLED(CONFIG_STM32MP15x_STM32IMAGE))
111 mode = "trusted - stm32image";
118 fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible",
121 log_info("Board: stm32mp1 in %s mode (%s)\n", mode,
122 fdt_compat && fdt_compat_len ? fdt_compat : "");
124 /* display the STMicroelectronics board identification */
125 if (CONFIG_IS_ENABLED(CMD_STBOARD)) {
126 ret = uclass_get_device_by_driver(UCLASS_MISC,
127 DM_DRIVER_GET(stm32mp_bsec),
130 ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD),
133 log_info("Board: MB%04x Var%d.%d Rev.%c-%02d\n",
137 ((otp >> 8) & 0xF) - 1 + 'A',
144 static void board_key_check(void)
147 struct gpio_desc gpio;
148 enum forced_boot_mode boot_mode = BOOT_NORMAL;
150 if (!IS_ENABLED(CONFIG_FASTBOOT) && !IS_ENABLED(CONFIG_CMD_STM32PROG))
153 node = ofnode_path("/config");
154 if (!ofnode_valid(node)) {
155 log_debug("no /config node?\n");
158 if (IS_ENABLED(CONFIG_FASTBOOT)) {
159 if (gpio_request_by_name_nodev(node, "st,fastboot-gpios", 0,
160 &gpio, GPIOD_IS_IN)) {
161 log_debug("could not find a /config/st,fastboot-gpios\n");
164 if (dm_gpio_get_value(&gpio)) {
165 log_notice("Fastboot key pressed, ");
166 boot_mode = BOOT_FASTBOOT;
169 dm_gpio_free(NULL, &gpio);
172 if (IS_ENABLED(CONFIG_CMD_STM32PROG)) {
173 if (gpio_request_by_name_nodev(node, "st,stm32prog-gpios", 0,
174 &gpio, GPIOD_IS_IN)) {
175 log_debug("could not find a /config/st,stm32prog-gpios\n");
178 if (dm_gpio_get_value(&gpio)) {
179 log_notice("STM32Programmer key pressed, ");
180 boot_mode = BOOT_STM32PROG;
182 dm_gpio_free(NULL, &gpio);
185 if (boot_mode != BOOT_NORMAL) {
186 log_notice("entering download mode...\n");
187 clrsetbits_le32(TAMP_BOOT_CONTEXT,
188 TAMP_BOOT_FORCED_MASK,
193 int g_dnl_board_usb_cable_connected(void)
195 struct udevice *dwc2_udc_otg;
198 if (!IS_ENABLED(CONFIG_USB_GADGET_DWC2_OTG))
201 /* if typec stusb160x is present, means DK1 or DK2 board */
202 ret = stusb160x_cable_connected();
206 ret = uclass_get_device_by_driver(UCLASS_USB_GADGET_GENERIC,
207 DM_DRIVER_GET(dwc2_udc_otg),
210 log_debug("dwc2_udc_otg init failed\n");
214 return dwc2_udc_B_session_valid(dwc2_udc_otg);
217 #ifdef CONFIG_USB_GADGET_DOWNLOAD
218 #define STM32MP1_G_DNL_DFU_PRODUCT_NUM 0xdf11
219 #define STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM 0x0afb
221 int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
223 if (IS_ENABLED(CONFIG_DFU_OVER_USB) &&
224 !strcmp(name, "usb_dnl_dfu"))
225 put_unaligned(STM32MP1_G_DNL_DFU_PRODUCT_NUM, &dev->idProduct);
226 else if (IS_ENABLED(CONFIG_FASTBOOT) &&
227 !strcmp(name, "usb_dnl_fastboot"))
228 put_unaligned(STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM,
231 put_unaligned(CONFIG_USB_GADGET_PRODUCT_NUM, &dev->idProduct);
235 #endif /* CONFIG_USB_GADGET_DOWNLOAD */
237 static int get_led(struct udevice **dev, char *led_string)
239 const char *led_name;
242 led_name = ofnode_conf_read_str(led_string);
244 log_debug("could not find %s config string\n", led_string);
247 ret = led_get_by_label(led_name, dev);
249 log_debug("get=%d\n", ret);
256 static int setup_led(enum led_state_t cmd)
261 if (!CONFIG_IS_ENABLED(LED))
264 ret = get_led(&dev, "u-boot,boot-led");
268 ret = led_set_state(dev, cmd);
272 static void __maybe_unused led_error_blink(u32 nb_blink)
281 if (CONFIG_IS_ENABLED(LED)) {
282 ret = get_led(&led, "u-boot,error-led");
284 /* make u-boot,error-led blinking */
285 /* if U32_MAX and 125ms interval, for 17.02 years */
286 for (i = 0; i < 2 * nb_blink; i++) {
287 led_set_state(led, LEDST_TOGGLE);
291 led_set_state(led, LEDST_ON);
295 /* infinite: the boot process must be stopped */
296 if (nb_blink == U32_MAX)
300 static int adc_measurement(ofnode node, int adc_count, int *min_uV, int *max_uV)
302 struct ofnode_phandle_args adc_args;
308 for (i = 0; i < adc_count; i++) {
309 if (ofnode_parse_phandle_with_args(node, "st,adc_usb_pd",
310 "#io-channel-cells", 0, i,
312 log_debug("can't find /config/st,adc_usb_pd\n");
316 ret = uclass_get_device_by_ofnode(UCLASS_ADC, adc_args.node,
320 log_err("Can't get adc device(%d)\n", ret);
324 ret = adc_channel_single_shot(adc->name, adc_args.args[0],
327 log_err("single shot failed for %s[%d]!\n",
328 adc->name, adc_args.args[0]);
332 if (!adc_raw_to_uV(adc, raw, &uV)) {
337 log_debug("%s[%02d] = %u, %d uV\n",
338 adc->name, adc_args.args[0], raw, uV);
340 log_err("Can't get uV value for %s[%d]\n",
341 adc->name, adc_args.args[0]);
348 static int board_check_usb_power(void)
352 int min_uV = USB_START_HIGH_THRESHOLD_UV;
357 if (!IS_ENABLED(CONFIG_ADC))
360 node = ofnode_path("/config");
361 if (!ofnode_valid(node)) {
362 log_debug("no /config node?\n");
367 * Retrieve the ADC channels devices and get measurement
370 adc_count = ofnode_count_phandle_with_args(node, "st,adc_usb_pd",
371 "#io-channel-cells", 0);
373 if (adc_count == -ENOENT)
376 log_err("Can't find adc channel (%d)\n", adc_count);
381 /* perform maximum of 2 ADC measurements to detect power supply current */
382 for (i = 0; i < 2; i++) {
383 ret = adc_measurement(node, adc_count, &min_uV, &max_uV);
388 * If highest value is inside 1.23 Volts and 2.10 Volts, that means
389 * board is plugged on an USB-C 3A power supply and boot process can
392 if (max_uV > USB_START_LOW_THRESHOLD_UV &&
393 max_uV <= USB_START_HIGH_THRESHOLD_UV &&
394 min_uV <= USB_LOW_THRESHOLD_UV)
398 log_err("Previous ADC measurements was not the one expected, retry in 20ms\n");
399 mdelay(20); /* equal to max tPDDebounce duration (min 10ms - max 20ms) */
403 log_notice("****************************************************\n");
405 * If highest and lowest value are either both below
406 * USB_LOW_THRESHOLD_UV or both above USB_LOW_THRESHOLD_UV, that
407 * means USB TYPE-C is in unattached mode, this is an issue, make
408 * u-boot,error-led blinking and stop boot process.
410 if ((max_uV > USB_LOW_THRESHOLD_UV &&
411 min_uV > USB_LOW_THRESHOLD_UV) ||
412 (max_uV <= USB_LOW_THRESHOLD_UV &&
413 min_uV <= USB_LOW_THRESHOLD_UV)) {
414 log_notice("* ERROR USB TYPE-C connection in unattached mode *\n");
415 log_notice("* Check that USB TYPE-C cable is correctly plugged *\n");
416 /* with 125ms interval, led will blink for 17.02 years ....*/
420 if (max_uV > USB_LOW_THRESHOLD_UV &&
421 max_uV <= USB_WARNING_LOW_THRESHOLD_UV &&
422 min_uV <= USB_LOW_THRESHOLD_UV) {
423 log_notice("* WARNING 500mA power supply detected *\n");
427 if (max_uV > USB_WARNING_LOW_THRESHOLD_UV &&
428 max_uV <= USB_START_LOW_THRESHOLD_UV &&
429 min_uV <= USB_LOW_THRESHOLD_UV) {
430 log_notice("* WARNING 1.5A power supply detected *\n");
435 * If highest value is above 2.15 Volts that means that the USB TypeC
436 * supplies more than 3 Amp, this is not compliant with TypeC specification
438 if (max_uV > USB_START_HIGH_THRESHOLD_UV) {
439 log_notice("* USB TYPE-C charger not compliant with *\n");
440 log_notice("* specification *\n");
441 log_notice("****************************************************\n\n");
442 /* with 125ms interval, led will blink for 17.02 years ....*/
445 log_notice("* Current too low, use a 3A power supply! *\n");
446 log_notice("****************************************************\n\n");
449 led_error_blink(nb_blink);
454 static void sysconf_init(void)
457 struct udevice *pwr_dev;
458 struct udevice *pwr_reg;
464 syscfg = (u8 *)syscon_get_first_range(STM32MP_SYSCON_SYSCFG);
466 /* interconnect update : select master using the port 1 */
469 /* today information is hardcoded in U-Boot */
470 writel(BIT(9), syscfg + SYSCFG_ICNR);
472 /* disable Pull-Down for boot pin connected to VDD */
473 bootr = readl(syscfg + SYSCFG_BOOTR);
474 bootr &= ~(SYSCFG_BOOTR_BOOT_MASK << SYSCFG_BOOTR_BOOTPD_SHIFT);
475 bootr |= (bootr & SYSCFG_BOOTR_BOOT_MASK) << SYSCFG_BOOTR_BOOTPD_SHIFT;
476 writel(bootr, syscfg + SYSCFG_BOOTR);
478 /* High Speed Low Voltage Pad mode Enable for SPI, SDMMC, ETH, QSPI
479 * and TRACE. Needed above ~50MHz and conditioned by AFMUX selection.
480 * The customer will have to disable this for low frequencies
481 * or if AFMUX is selected but the function not used, typically for
482 * TRACE. Otherwise, impact on power consumption.
485 * enabling High Speed mode while VDD>2.7V
486 * with the OTP product_below_2v5 (OTP 18, BIT 13)
487 * erroneously set to 1 can damage the IC!
488 * => U-Boot set the register only if VDD < 2.7V (in DT)
489 * but this value need to be consistent with board design
491 ret = uclass_get_device_by_driver(UCLASS_PMIC,
492 DM_DRIVER_GET(stm32mp_pwr_pmic),
494 if (!ret && IS_ENABLED(CONFIG_DM_REGULATOR)) {
495 ret = uclass_get_device_by_driver(UCLASS_MISC,
496 DM_DRIVER_GET(stm32mp_bsec),
499 log_err("Can't find stm32mp_bsec driver\n");
503 ret = misc_read(dev, STM32_BSEC_SHADOW(18), &otp, 4);
507 /* get VDD = vdd-supply */
508 ret = device_get_supply_regulator(pwr_dev, "vdd-supply",
511 /* check if VDD is Low Voltage */
513 if (regulator_get_value(pwr_reg) < 2700000) {
514 writel(SYSCFG_IOCTRLSETR_HSLVEN_TRACE |
515 SYSCFG_IOCTRLSETR_HSLVEN_QUADSPI |
516 SYSCFG_IOCTRLSETR_HSLVEN_ETH |
517 SYSCFG_IOCTRLSETR_HSLVEN_SDMMC |
518 SYSCFG_IOCTRLSETR_HSLVEN_SPI,
519 syscfg + SYSCFG_IOCTRLSETR);
522 log_err("product_below_2v5=0: HSLVEN protected by HW\n");
525 log_err("product_below_2v5=1: HSLVEN update is destructive, no update as VDD>2.7V\n");
528 log_debug("VDD unknown");
532 /* activate automatic I/O compensation
533 * warning: need to ensure CSI enabled and ready in clock driver
535 writel(SYSCFG_CMPENSETR_MPU_EN, syscfg + SYSCFG_CMPENSETR);
537 /* poll until ready (1s timeout) */
538 ret = readl_poll_timeout(syscfg + SYSCFG_CMPCR, val,
539 val & SYSCFG_CMPCR_READY,
542 log_err("SYSCFG: I/O compensation failed, timeout.\n");
546 clrbits_le32(syscfg + SYSCFG_CMPCR, SYSCFG_CMPCR_SW_CTRL);
549 /* Fix to make I2C1 usable on DK2 for touchscreen usage in kernel */
550 static int dk2_i2c1_fix(void)
553 struct gpio_desc hdmi, audio;
556 if (!IS_ENABLED(CONFIG_DM_REGULATOR))
559 node = ofnode_path("/soc/i2c@40012000/hdmi-transmitter@39");
560 if (!ofnode_valid(node)) {
561 log_debug("no hdmi-transmitter@39 ?\n");
565 if (gpio_request_by_name_nodev(node, "reset-gpios", 0,
566 &hdmi, GPIOD_IS_OUT)) {
567 log_debug("could not find reset-gpios\n");
571 node = ofnode_path("/soc/i2c@40012000/cs42l51@4a");
572 if (!ofnode_valid(node)) {
573 log_debug("no cs42l51@4a ?\n");
577 if (gpio_request_by_name_nodev(node, "reset-gpios", 0,
578 &audio, GPIOD_IS_OUT)) {
579 log_debug("could not find reset-gpios\n");
583 /* before power up, insure that HDMI and AUDIO IC is under reset */
584 ret = dm_gpio_set_value(&hdmi, 1);
586 log_err("can't set_value for hdmi_nrst gpio");
589 ret = dm_gpio_set_value(&audio, 1);
591 log_err("can't set_value for audio_nrst gpio");
595 /* power-up audio IC */
596 regulator_autoset_by_name("v1v8_audio", NULL);
598 /* power-up HDMI IC */
599 regulator_autoset_by_name("v1v2_hdmi", NULL);
600 regulator_autoset_by_name("v3v3_hdmi", NULL);
606 static bool board_is_dk2(void)
608 if (CONFIG_IS_ENABLED(TARGET_ST_STM32MP15x) &&
609 of_machine_is_compatible("st,stm32mp157c-dk2"))
615 static bool board_is_ev1(void)
617 if (CONFIG_IS_ENABLED(TARGET_ST_STM32MP15x) &&
618 (of_machine_is_compatible("st,stm32mp157a-ev1") ||
619 of_machine_is_compatible("st,stm32mp157c-ev1") ||
620 of_machine_is_compatible("st,stm32mp157d-ev1") ||
621 of_machine_is_compatible("st,stm32mp157f-ev1")))
627 /* touchscreen driver: only used for pincontrol configuration */
628 static const struct udevice_id goodix_ids[] = {
629 { .compatible = "goodix,gt9147", },
633 U_BOOT_DRIVER(goodix) = {
636 .of_match = goodix_ids,
639 static void board_ev1_init(void)
643 /* configure IRQ line on EV1 for touchscreen before LCD reset */
644 uclass_get_device_by_driver(UCLASS_NOP, DM_DRIVER_GET(goodix), &dev);
647 /* board dependent setup after realloc */
658 if (IS_ENABLED(CONFIG_DM_REGULATOR))
659 regulators_enable_boot_on(_DEBUG);
662 * sysconf initialisation done only when U-Boot is running in secure
663 * done in TF-A for TFABOOT.
665 if (IS_ENABLED(CONFIG_ARMV7_NONSEC))
668 if (CONFIG_IS_ENABLED(LED))
676 int board_late_init(void)
678 const void *fdt_compat;
687 if (IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG)) {
688 fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible",
690 if (fdt_compat && fdt_compat_len) {
691 if (strncmp(fdt_compat, "st,", 3) != 0) {
692 env_set("board_name", fdt_compat);
694 env_set("board_name", fdt_compat + 3);
696 buf_len = sizeof(dtb_name);
697 strncpy(dtb_name, fdt_compat + 3, buf_len);
698 buf_len -= strlen(fdt_compat + 3);
699 strncat(dtb_name, ".dtb", buf_len);
700 env_set("fdtfile", dtb_name);
703 ret = uclass_get_device_by_driver(UCLASS_MISC,
704 DM_DRIVER_GET(stm32mp_bsec),
708 ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD),
710 if (ret > 0 && otp) {
711 snprintf(buf, sizeof(buf), "0x%04x", otp >> 16);
712 env_set("board_id", buf);
714 snprintf(buf, sizeof(buf), "0x%04x",
715 ((otp >> 8) & 0xF) - 1 + 0xA);
716 env_set("board_rev", buf);
720 /* for DK1/DK2 boards */
721 board_check_usb_power();
726 void board_quiesce_devices(void)
728 setup_led(LEDST_OFF);
731 /* eth init function : weak called in eqos driver */
732 int board_interface_eth_init(struct udevice *dev,
733 phy_interface_t interface_type)
737 bool eth_clk_sel_reg = false;
738 bool eth_ref_clk_sel_reg = false;
740 /* Gigabit Ethernet 125MHz clock selection. */
741 eth_clk_sel_reg = dev_read_bool(dev, "st,eth-clk-sel");
743 /* Ethernet 50Mhz RMII clock selection */
744 eth_ref_clk_sel_reg =
745 dev_read_bool(dev, "st,eth-ref-clk-sel");
747 syscfg = (u8 *)syscon_get_first_range(STM32MP_SYSCON_SYSCFG);
752 switch (interface_type) {
753 case PHY_INTERFACE_MODE_MII:
754 value = SYSCFG_PMCSETR_ETH_SEL_GMII_MII |
755 SYSCFG_PMCSETR_ETH_REF_CLK_SEL;
756 log_debug("PHY_INTERFACE_MODE_MII\n");
758 case PHY_INTERFACE_MODE_GMII:
760 value = SYSCFG_PMCSETR_ETH_SEL_GMII_MII |
761 SYSCFG_PMCSETR_ETH_CLK_SEL;
763 value = SYSCFG_PMCSETR_ETH_SEL_GMII_MII;
764 log_debug("PHY_INTERFACE_MODE_GMII\n");
766 case PHY_INTERFACE_MODE_RMII:
767 if (eth_ref_clk_sel_reg)
768 value = SYSCFG_PMCSETR_ETH_SEL_RMII |
769 SYSCFG_PMCSETR_ETH_REF_CLK_SEL;
771 value = SYSCFG_PMCSETR_ETH_SEL_RMII;
772 log_debug("PHY_INTERFACE_MODE_RMII\n");
774 case PHY_INTERFACE_MODE_RGMII:
775 case PHY_INTERFACE_MODE_RGMII_ID:
776 case PHY_INTERFACE_MODE_RGMII_RXID:
777 case PHY_INTERFACE_MODE_RGMII_TXID:
779 value = SYSCFG_PMCSETR_ETH_SEL_RGMII |
780 SYSCFG_PMCSETR_ETH_CLK_SEL;
782 value = SYSCFG_PMCSETR_ETH_SEL_RGMII;
783 log_debug("PHY_INTERFACE_MODE_RGMII\n");
786 log_debug("Do not manage %d interface\n",
788 /* Do not manage others interfaces */
792 /* clear and set ETH configuration bits */
793 writel(SYSCFG_PMCSETR_ETH_SEL_MASK | SYSCFG_PMCSETR_ETH_SELMII |
794 SYSCFG_PMCSETR_ETH_REF_CLK_SEL | SYSCFG_PMCSETR_ETH_CLK_SEL,
795 syscfg + SYSCFG_PMCCLRR);
796 writel(value, syscfg + SYSCFG_PMCSETR);
801 enum env_location env_get_location(enum env_operation op, int prio)
803 u32 bootmode = get_bootmode();
808 switch (bootmode & TAMP_BOOT_DEVICE_MASK) {
810 case BOOT_FLASH_EMMC:
811 if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC))
813 else if (CONFIG_IS_ENABLED(ENV_IS_IN_EXT4))
818 case BOOT_FLASH_NAND:
819 case BOOT_FLASH_SPINAND:
820 if (CONFIG_IS_ENABLED(ENV_IS_IN_UBI))
826 if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH))
827 return ENVL_SPI_FLASH;
836 const char *env_ext4_get_intf(void)
838 u32 bootmode = get_bootmode();
840 switch (bootmode & TAMP_BOOT_DEVICE_MASK) {
842 case BOOT_FLASH_EMMC:
849 int mmc_get_boot(void)
852 u32 boot_mode = get_bootmode();
853 unsigned int instance = (boot_mode & TAMP_BOOT_INSTANCE_MASK) - 1;
855 const u32 sdmmc_addr[] = {
861 if (instance > ARRAY_SIZE(sdmmc_addr))
864 /* search associated sdmmc node in devicetree */
865 snprintf(cmd, sizeof(cmd), "mmc@%x", sdmmc_addr[instance]);
866 if (uclass_get_device_by_name(UCLASS_MMC, cmd, &dev)) {
867 log_err("mmc%d = %s not found in device tree!\n", instance, cmd);
874 const char *env_ext4_get_dev_part(void)
876 static char *const env_dev_part =
877 #ifdef CONFIG_ENV_EXT4_DEVICE_AND_PART
878 CONFIG_ENV_EXT4_DEVICE_AND_PART;
882 static char *const dev_part[] = {"0:auto", "1:auto", "2:auto"};
884 if (strlen(env_dev_part) > 0)
887 return dev_part[mmc_get_boot()];
890 int mmc_get_env_dev(void)
892 if (CONFIG_SYS_MMC_ENV_DEV >= 0)
893 return CONFIG_SYS_MMC_ENV_DEV;
895 /* use boot instance to select the correct mmc device identifier */
896 return mmc_get_boot();
899 #if defined(CONFIG_OF_BOARD_SETUP)
900 int ft_board_setup(void *blob, struct bd_info *bd)
902 static const struct node_info nodes[] = {
903 { "st,stm32f469-qspi", MTD_DEV_TYPE_NOR, },
904 { "st,stm32f469-qspi", MTD_DEV_TYPE_SPINAND},
905 { "st,stm32mp15-fmc2", MTD_DEV_TYPE_NAND, },
906 { "st,stm32mp1-fmc2-nfc", MTD_DEV_TYPE_NAND, },
910 /* Check the boot-source and don't update MTD for serial or usb boot */
911 boot_device = env_get("boot_device");
913 (strcmp(boot_device, "serial") && strcmp(boot_device, "usb")))
914 if (IS_ENABLED(CONFIG_FDT_FIXUP_PARTITIONS))
915 fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
921 static void board_copro_image_process(ulong fw_image, size_t fw_size)
923 int ret, id = 0; /* Copro id fixed to 0 as only one coproc on mp1 */
925 if (!rproc_is_initialized())
927 log_err("Remote Processor %d initialization failed\n",
932 ret = rproc_load(id, fw_image, fw_size);
933 log_err("Load Remote Processor %d with data@addr=0x%08lx %u bytes:%s\n",
934 id, fw_image, fw_size, ret ? " Failed!" : " Success!");
940 U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_COPRO, board_copro_image_process);