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_simplefb.h>
17 #include <fdt_support.h>
19 #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)
86 * Get a global data pointer
88 DECLARE_GLOBAL_DATA_PTR;
90 #define USB_LOW_THRESHOLD_UV 200000
91 #define USB_WARNING_LOW_THRESHOLD_UV 660000
92 #define USB_START_LOW_THRESHOLD_UV 1230000
93 #define USB_START_HIGH_THRESHOLD_UV 2150000
95 int board_early_init_f(void)
97 /* nothing to do, only used in SPL */
107 const char *fdt_compat;
110 if (IS_ENABLED(CONFIG_TFABOOT)) {
111 if (IS_ENABLED(CONFIG_STM32MP15x_STM32IMAGE))
112 mode = "trusted - stm32image";
119 fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible",
122 log_info("Board: stm32mp1 in %s mode (%s)\n", mode,
123 fdt_compat && fdt_compat_len ? fdt_compat : "");
125 /* display the STMicroelectronics board identification */
126 if (CONFIG_IS_ENABLED(CMD_STBOARD)) {
127 ret = uclass_get_device_by_driver(UCLASS_MISC,
128 DM_DRIVER_GET(stm32mp_bsec),
131 ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD),
134 log_info("Board: MB%04x Var%d.%d Rev.%c-%02d\n",
138 ((otp >> 8) & 0xF) - 1 + 'A',
145 static void board_key_check(void)
148 struct gpio_desc gpio;
149 enum forced_boot_mode boot_mode = BOOT_NORMAL;
151 if (!IS_ENABLED(CONFIG_FASTBOOT) && !IS_ENABLED(CONFIG_CMD_STM32PROG))
154 node = ofnode_path("/config");
155 if (!ofnode_valid(node)) {
156 log_debug("no /config node?\n");
159 if (IS_ENABLED(CONFIG_FASTBOOT)) {
160 if (gpio_request_by_name_nodev(node, "st,fastboot-gpios", 0,
161 &gpio, GPIOD_IS_IN)) {
162 log_debug("could not find a /config/st,fastboot-gpios\n");
165 if (dm_gpio_get_value(&gpio)) {
166 log_notice("Fastboot key pressed, ");
167 boot_mode = BOOT_FASTBOOT;
170 dm_gpio_free(NULL, &gpio);
173 if (IS_ENABLED(CONFIG_CMD_STM32PROG)) {
174 if (gpio_request_by_name_nodev(node, "st,stm32prog-gpios", 0,
175 &gpio, GPIOD_IS_IN)) {
176 log_debug("could not find a /config/st,stm32prog-gpios\n");
179 if (dm_gpio_get_value(&gpio)) {
180 log_notice("STM32Programmer key pressed, ");
181 boot_mode = BOOT_STM32PROG;
183 dm_gpio_free(NULL, &gpio);
186 if (boot_mode != BOOT_NORMAL) {
187 log_notice("entering download mode...\n");
188 clrsetbits_le32(TAMP_BOOT_CONTEXT,
189 TAMP_BOOT_FORCED_MASK,
194 int g_dnl_board_usb_cable_connected(void)
196 struct udevice *dwc2_udc_otg;
199 if (!IS_ENABLED(CONFIG_USB_GADGET_DWC2_OTG))
202 /* if typec stusb160x is present, means DK1 or DK2 board */
203 ret = stusb160x_cable_connected();
207 ret = uclass_get_device_by_driver(UCLASS_USB_GADGET_GENERIC,
208 DM_DRIVER_GET(dwc2_udc_otg),
211 log_debug("dwc2_udc_otg init failed\n");
215 return dwc2_udc_B_session_valid(dwc2_udc_otg);
218 #ifdef CONFIG_USB_GADGET_DOWNLOAD
219 #define STM32MP1_G_DNL_DFU_PRODUCT_NUM 0xdf11
220 #define STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM 0x0afb
222 int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
224 if (IS_ENABLED(CONFIG_DFU_OVER_USB) &&
225 !strcmp(name, "usb_dnl_dfu"))
226 put_unaligned(STM32MP1_G_DNL_DFU_PRODUCT_NUM, &dev->idProduct);
227 else if (IS_ENABLED(CONFIG_FASTBOOT) &&
228 !strcmp(name, "usb_dnl_fastboot"))
229 put_unaligned(STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM,
232 put_unaligned(CONFIG_USB_GADGET_PRODUCT_NUM, &dev->idProduct);
236 #endif /* CONFIG_USB_GADGET_DOWNLOAD */
238 static int get_led(struct udevice **dev, char *led_string)
240 const char *led_name;
243 led_name = ofnode_conf_read_str(led_string);
245 log_debug("could not find %s config string\n", led_string);
248 ret = led_get_by_label(led_name, dev);
250 log_debug("get=%d\n", ret);
257 static int setup_led(enum led_state_t cmd)
262 if (!CONFIG_IS_ENABLED(LED))
265 ret = get_led(&dev, "u-boot,boot-led");
269 ret = led_set_state(dev, cmd);
273 static void __maybe_unused led_error_blink(u32 nb_blink)
282 if (CONFIG_IS_ENABLED(LED)) {
283 ret = get_led(&led, "u-boot,error-led");
285 /* make u-boot,error-led blinking */
286 /* if U32_MAX and 125ms interval, for 17.02 years */
287 for (i = 0; i < 2 * nb_blink; i++) {
288 led_set_state(led, LEDST_TOGGLE);
292 led_set_state(led, LEDST_ON);
296 /* infinite: the boot process must be stopped */
297 if (nb_blink == U32_MAX)
301 static int adc_measurement(ofnode node, int adc_count, int *min_uV, int *max_uV)
303 struct ofnode_phandle_args adc_args;
309 for (i = 0; i < adc_count; i++) {
310 if (ofnode_parse_phandle_with_args(node, "st,adc_usb_pd",
311 "#io-channel-cells", 0, i,
313 log_debug("can't find /config/st,adc_usb_pd\n");
317 ret = uclass_get_device_by_ofnode(UCLASS_ADC, adc_args.node,
321 log_err("Can't get adc device(%d)\n", ret);
325 ret = adc_channel_single_shot(adc->name, adc_args.args[0],
328 log_err("single shot failed for %s[%d]!\n",
329 adc->name, adc_args.args[0]);
333 if (!adc_raw_to_uV(adc, raw, &uV)) {
338 log_debug("%s[%02d] = %u, %d uV\n",
339 adc->name, adc_args.args[0], raw, uV);
341 log_err("Can't get uV value for %s[%d]\n",
342 adc->name, adc_args.args[0]);
349 static int board_check_usb_power(void)
353 int min_uV = USB_START_HIGH_THRESHOLD_UV;
358 if (!IS_ENABLED(CONFIG_ADC))
361 node = ofnode_path("/config");
362 if (!ofnode_valid(node)) {
363 log_debug("no /config node?\n");
368 * Retrieve the ADC channels devices and get measurement
371 adc_count = ofnode_count_phandle_with_args(node, "st,adc_usb_pd",
372 "#io-channel-cells", 0);
374 if (adc_count == -ENOENT)
377 log_err("Can't find adc channel (%d)\n", adc_count);
382 /* perform maximum of 2 ADC measurements to detect power supply current */
383 for (i = 0; i < 2; i++) {
384 ret = adc_measurement(node, adc_count, &min_uV, &max_uV);
389 * If highest value is inside 1.23 Volts and 2.10 Volts, that means
390 * board is plugged on an USB-C 3A power supply and boot process can
393 if (max_uV > USB_START_LOW_THRESHOLD_UV &&
394 max_uV <= USB_START_HIGH_THRESHOLD_UV &&
395 min_uV <= USB_LOW_THRESHOLD_UV)
399 log_err("Previous ADC measurements was not the one expected, retry in 20ms\n");
400 mdelay(20); /* equal to max tPDDebounce duration (min 10ms - max 20ms) */
404 log_notice("****************************************************\n");
406 * If highest and lowest value are either both below
407 * USB_LOW_THRESHOLD_UV or both above USB_LOW_THRESHOLD_UV, that
408 * means USB TYPE-C is in unattached mode, this is an issue, make
409 * u-boot,error-led blinking and stop boot process.
411 if ((max_uV > USB_LOW_THRESHOLD_UV &&
412 min_uV > USB_LOW_THRESHOLD_UV) ||
413 (max_uV <= USB_LOW_THRESHOLD_UV &&
414 min_uV <= USB_LOW_THRESHOLD_UV)) {
415 log_notice("* ERROR USB TYPE-C connection in unattached mode *\n");
416 log_notice("* Check that USB TYPE-C cable is correctly plugged *\n");
417 /* with 125ms interval, led will blink for 17.02 years ....*/
421 if (max_uV > USB_LOW_THRESHOLD_UV &&
422 max_uV <= USB_WARNING_LOW_THRESHOLD_UV &&
423 min_uV <= USB_LOW_THRESHOLD_UV) {
424 log_notice("* WARNING 500mA power supply detected *\n");
428 if (max_uV > USB_WARNING_LOW_THRESHOLD_UV &&
429 max_uV <= USB_START_LOW_THRESHOLD_UV &&
430 min_uV <= USB_LOW_THRESHOLD_UV) {
431 log_notice("* WARNING 1.5A power supply detected *\n");
436 * If highest value is above 2.15 Volts that means that the USB TypeC
437 * supplies more than 3 Amp, this is not compliant with TypeC specification
439 if (max_uV > USB_START_HIGH_THRESHOLD_UV) {
440 log_notice("* USB TYPE-C charger not compliant with *\n");
441 log_notice("* specification *\n");
442 log_notice("****************************************************\n\n");
443 /* with 125ms interval, led will blink for 17.02 years ....*/
446 log_notice("* Current too low, use a 3A power supply! *\n");
447 log_notice("****************************************************\n\n");
450 led_error_blink(nb_blink);
455 static void sysconf_init(void)
458 struct udevice *pwr_dev;
459 struct udevice *pwr_reg;
465 syscfg = (u8 *)syscon_get_first_range(STM32MP_SYSCON_SYSCFG);
467 /* interconnect update : select master using the port 1 */
470 /* today information is hardcoded in U-Boot */
471 writel(BIT(9), syscfg + SYSCFG_ICNR);
473 /* disable Pull-Down for boot pin connected to VDD */
474 bootr = readl(syscfg + SYSCFG_BOOTR);
475 bootr &= ~(SYSCFG_BOOTR_BOOT_MASK << SYSCFG_BOOTR_BOOTPD_SHIFT);
476 bootr |= (bootr & SYSCFG_BOOTR_BOOT_MASK) << SYSCFG_BOOTR_BOOTPD_SHIFT;
477 writel(bootr, syscfg + SYSCFG_BOOTR);
479 /* High Speed Low Voltage Pad mode Enable for SPI, SDMMC, ETH, QSPI
480 * and TRACE. Needed above ~50MHz and conditioned by AFMUX selection.
481 * The customer will have to disable this for low frequencies
482 * or if AFMUX is selected but the function not used, typically for
483 * TRACE. Otherwise, impact on power consumption.
486 * enabling High Speed mode while VDD>2.7V
487 * with the OTP product_below_2v5 (OTP 18, BIT 13)
488 * erroneously set to 1 can damage the IC!
489 * => U-Boot set the register only if VDD < 2.7V (in DT)
490 * but this value need to be consistent with board design
492 ret = uclass_get_device_by_driver(UCLASS_PMIC,
493 DM_DRIVER_GET(stm32mp_pwr_pmic),
495 if (!ret && IS_ENABLED(CONFIG_DM_REGULATOR)) {
496 ret = uclass_get_device_by_driver(UCLASS_MISC,
497 DM_DRIVER_GET(stm32mp_bsec),
500 log_err("Can't find stm32mp_bsec driver\n");
504 ret = misc_read(dev, STM32_BSEC_SHADOW(18), &otp, 4);
508 /* get VDD = vdd-supply */
509 ret = device_get_supply_regulator(pwr_dev, "vdd-supply",
512 /* check if VDD is Low Voltage */
514 if (regulator_get_value(pwr_reg) < 2700000) {
515 writel(SYSCFG_IOCTRLSETR_HSLVEN_TRACE |
516 SYSCFG_IOCTRLSETR_HSLVEN_QUADSPI |
517 SYSCFG_IOCTRLSETR_HSLVEN_ETH |
518 SYSCFG_IOCTRLSETR_HSLVEN_SDMMC |
519 SYSCFG_IOCTRLSETR_HSLVEN_SPI,
520 syscfg + SYSCFG_IOCTRLSETR);
523 log_err("product_below_2v5=0: HSLVEN protected by HW\n");
526 log_err("product_below_2v5=1: HSLVEN update is destructive, no update as VDD>2.7V\n");
529 log_debug("VDD unknown");
533 /* activate automatic I/O compensation
534 * warning: need to ensure CSI enabled and ready in clock driver
536 writel(SYSCFG_CMPENSETR_MPU_EN, syscfg + SYSCFG_CMPENSETR);
538 /* poll until ready (1s timeout) */
539 ret = readl_poll_timeout(syscfg + SYSCFG_CMPCR, val,
540 val & SYSCFG_CMPCR_READY,
543 log_err("SYSCFG: I/O compensation failed, timeout.\n");
547 clrbits_le32(syscfg + SYSCFG_CMPCR, SYSCFG_CMPCR_SW_CTRL);
550 /* Fix to make I2C1 usable on DK2 for touchscreen usage in kernel */
551 static int dk2_i2c1_fix(void)
554 struct gpio_desc hdmi, audio;
557 if (!IS_ENABLED(CONFIG_DM_REGULATOR))
560 node = ofnode_path("/soc/i2c@40012000/hdmi-transmitter@39");
561 if (!ofnode_valid(node)) {
562 log_debug("no hdmi-transmitter@39 ?\n");
566 if (gpio_request_by_name_nodev(node, "reset-gpios", 0,
567 &hdmi, GPIOD_IS_OUT)) {
568 log_debug("could not find reset-gpios\n");
572 node = ofnode_path("/soc/i2c@40012000/cs42l51@4a");
573 if (!ofnode_valid(node)) {
574 log_debug("no cs42l51@4a ?\n");
578 if (gpio_request_by_name_nodev(node, "reset-gpios", 0,
579 &audio, GPIOD_IS_OUT)) {
580 log_debug("could not find reset-gpios\n");
584 /* before power up, insure that HDMI and AUDIO IC is under reset */
585 ret = dm_gpio_set_value(&hdmi, 1);
587 log_err("can't set_value for hdmi_nrst gpio");
590 ret = dm_gpio_set_value(&audio, 1);
592 log_err("can't set_value for audio_nrst gpio");
596 /* power-up audio IC */
597 regulator_autoset_by_name("v1v8_audio", NULL);
599 /* power-up HDMI IC */
600 regulator_autoset_by_name("v1v2_hdmi", NULL);
601 regulator_autoset_by_name("v3v3_hdmi", NULL);
607 static bool board_is_dk2(void)
609 if (CONFIG_IS_ENABLED(TARGET_ST_STM32MP15x) &&
610 of_machine_is_compatible("st,stm32mp157c-dk2"))
616 static bool board_is_ev1(void)
618 if (CONFIG_IS_ENABLED(TARGET_ST_STM32MP15x) &&
619 (of_machine_is_compatible("st,stm32mp157a-ev1") ||
620 of_machine_is_compatible("st,stm32mp157c-ev1") ||
621 of_machine_is_compatible("st,stm32mp157d-ev1") ||
622 of_machine_is_compatible("st,stm32mp157f-ev1")))
628 /* touchscreen driver: only used for pincontrol configuration */
629 static const struct udevice_id goodix_ids[] = {
630 { .compatible = "goodix,gt9147", },
634 U_BOOT_DRIVER(goodix) = {
637 .of_match = goodix_ids,
640 static void board_ev1_init(void)
644 /* configure IRQ line on EV1 for touchscreen before LCD reset */
645 uclass_get_device_by_driver(UCLASS_NOP, DM_DRIVER_GET(goodix), &dev);
648 /* board dependent setup after realloc */
659 if (IS_ENABLED(CONFIG_DM_REGULATOR))
660 regulators_enable_boot_on(_DEBUG);
663 * sysconf initialisation done only when U-Boot is running in secure
664 * done in TF-A for TFABOOT.
666 if (IS_ENABLED(CONFIG_ARMV7_NONSEC))
669 if (CONFIG_IS_ENABLED(LED))
677 int board_late_init(void)
679 const void *fdt_compat;
688 if (IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG)) {
689 fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible",
691 if (fdt_compat && fdt_compat_len) {
692 if (strncmp(fdt_compat, "st,", 3) != 0) {
693 env_set("board_name", fdt_compat);
695 env_set("board_name", fdt_compat + 3);
697 buf_len = sizeof(dtb_name);
698 strncpy(dtb_name, fdt_compat + 3, buf_len);
699 buf_len -= strlen(fdt_compat + 3);
700 strncat(dtb_name, ".dtb", buf_len);
701 env_set("fdtfile", dtb_name);
704 ret = uclass_get_device_by_driver(UCLASS_MISC,
705 DM_DRIVER_GET(stm32mp_bsec),
709 ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD),
711 if (ret > 0 && otp) {
712 snprintf(buf, sizeof(buf), "0x%04x", otp >> 16);
713 env_set("board_id", buf);
715 snprintf(buf, sizeof(buf), "0x%04x",
716 ((otp >> 8) & 0xF) - 1 + 0xA);
717 env_set("board_rev", buf);
721 /* for DK1/DK2 boards */
722 board_check_usb_power();
727 void board_quiesce_devices(void)
729 setup_led(LEDST_OFF);
732 /* eth init function : weak called in eqos driver */
733 int board_interface_eth_init(struct udevice *dev,
734 phy_interface_t interface_type)
738 bool eth_clk_sel_reg = false;
739 bool eth_ref_clk_sel_reg = false;
741 /* Gigabit Ethernet 125MHz clock selection. */
742 eth_clk_sel_reg = dev_read_bool(dev, "st,eth-clk-sel");
744 /* Ethernet 50Mhz RMII clock selection */
745 eth_ref_clk_sel_reg =
746 dev_read_bool(dev, "st,eth-ref-clk-sel");
748 syscfg = (u8 *)syscon_get_first_range(STM32MP_SYSCON_SYSCFG);
753 switch (interface_type) {
754 case PHY_INTERFACE_MODE_MII:
755 value = SYSCFG_PMCSETR_ETH_SEL_GMII_MII |
756 SYSCFG_PMCSETR_ETH_REF_CLK_SEL;
757 log_debug("PHY_INTERFACE_MODE_MII\n");
759 case PHY_INTERFACE_MODE_GMII:
761 value = SYSCFG_PMCSETR_ETH_SEL_GMII_MII |
762 SYSCFG_PMCSETR_ETH_CLK_SEL;
764 value = SYSCFG_PMCSETR_ETH_SEL_GMII_MII;
765 log_debug("PHY_INTERFACE_MODE_GMII\n");
767 case PHY_INTERFACE_MODE_RMII:
768 if (eth_ref_clk_sel_reg)
769 value = SYSCFG_PMCSETR_ETH_SEL_RMII |
770 SYSCFG_PMCSETR_ETH_REF_CLK_SEL;
772 value = SYSCFG_PMCSETR_ETH_SEL_RMII;
773 log_debug("PHY_INTERFACE_MODE_RMII\n");
775 case PHY_INTERFACE_MODE_RGMII:
776 case PHY_INTERFACE_MODE_RGMII_ID:
777 case PHY_INTERFACE_MODE_RGMII_RXID:
778 case PHY_INTERFACE_MODE_RGMII_TXID:
780 value = SYSCFG_PMCSETR_ETH_SEL_RGMII |
781 SYSCFG_PMCSETR_ETH_CLK_SEL;
783 value = SYSCFG_PMCSETR_ETH_SEL_RGMII;
784 log_debug("PHY_INTERFACE_MODE_RGMII\n");
787 log_debug("Do not manage %d interface\n",
789 /* Do not manage others interfaces */
793 /* clear and set ETH configuration bits */
794 writel(SYSCFG_PMCSETR_ETH_SEL_MASK | SYSCFG_PMCSETR_ETH_SELMII |
795 SYSCFG_PMCSETR_ETH_REF_CLK_SEL | SYSCFG_PMCSETR_ETH_CLK_SEL,
796 syscfg + SYSCFG_PMCCLRR);
797 writel(value, syscfg + SYSCFG_PMCSETR);
802 enum env_location env_get_location(enum env_operation op, int prio)
804 u32 bootmode = get_bootmode();
809 switch (bootmode & TAMP_BOOT_DEVICE_MASK) {
811 case BOOT_FLASH_EMMC:
812 if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC))
814 else if (CONFIG_IS_ENABLED(ENV_IS_IN_EXT4))
819 case BOOT_FLASH_NAND:
820 case BOOT_FLASH_SPINAND:
821 if (CONFIG_IS_ENABLED(ENV_IS_IN_UBI))
827 if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH))
828 return ENVL_SPI_FLASH;
837 const char *env_ext4_get_intf(void)
839 u32 bootmode = get_bootmode();
841 switch (bootmode & TAMP_BOOT_DEVICE_MASK) {
843 case BOOT_FLASH_EMMC:
850 int mmc_get_boot(void)
853 u32 boot_mode = get_bootmode();
854 unsigned int instance = (boot_mode & TAMP_BOOT_INSTANCE_MASK) - 1;
856 const u32 sdmmc_addr[] = {
862 if (instance > ARRAY_SIZE(sdmmc_addr))
865 /* search associated sdmmc node in devicetree */
866 snprintf(cmd, sizeof(cmd), "mmc@%x", sdmmc_addr[instance]);
867 if (uclass_get_device_by_name(UCLASS_MMC, cmd, &dev)) {
868 log_err("mmc%d = %s not found in device tree!\n", instance, cmd);
875 const char *env_ext4_get_dev_part(void)
877 static char *const env_dev_part =
878 #ifdef CONFIG_ENV_EXT4_DEVICE_AND_PART
879 CONFIG_ENV_EXT4_DEVICE_AND_PART;
883 static char *const dev_part[] = {"0:auto", "1:auto", "2:auto"};
885 if (strlen(env_dev_part) > 0)
888 return dev_part[mmc_get_boot()];
891 int mmc_get_env_dev(void)
893 if (CONFIG_SYS_MMC_ENV_DEV >= 0)
894 return CONFIG_SYS_MMC_ENV_DEV;
896 /* use boot instance to select the correct mmc device identifier */
897 return mmc_get_boot();
900 #if defined(CONFIG_OF_BOARD_SETUP)
901 int ft_board_setup(void *blob, struct bd_info *bd)
903 static const struct node_info nodes[] = {
904 { "st,stm32f469-qspi", MTD_DEV_TYPE_NOR, },
905 { "st,stm32f469-qspi", MTD_DEV_TYPE_SPINAND},
906 { "st,stm32mp15-fmc2", MTD_DEV_TYPE_NAND, },
907 { "st,stm32mp1-fmc2-nfc", MTD_DEV_TYPE_NAND, },
911 /* Check the boot-source and don't update MTD for serial or usb boot */
912 boot_device = env_get("boot_device");
914 (strcmp(boot_device, "serial") && strcmp(boot_device, "usb")))
915 if (IS_ENABLED(CONFIG_FDT_FIXUP_PARTITIONS))
916 fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
918 if (CONFIG_IS_ENABLED(FDT_SIMPLEFB))
919 fdt_simplefb_enable_and_mem_rsv(blob);
925 static void board_copro_image_process(ulong fw_image, size_t fw_size)
927 int ret, id = 0; /* Copro id fixed to 0 as only one coproc on mp1 */
929 if (!rproc_is_initialized())
931 log_err("Remote Processor %d initialization failed\n",
936 ret = rproc_load(id, fw_image, fw_size);
937 log_err("Load Remote Processor %d with data@addr=0x%08lx %u bytes:%s\n",
938 id, fw_image, fw_size, ret ? " Failed!" : " Success!");
944 U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_COPRO, board_copro_image_process);