diff options
author | Tom Rini <trini@konsulko.com> | 2020-08-13 15:11:27 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-08-13 15:11:27 +0300 |
commit | 6808dc62d75de706c5aabc24e36caf52ead30fc7 (patch) | |
tree | a4bc8b1852fc82f0b2703085f9c9199c07bef9cd /board | |
parent | dbfca734d0e2b36a966be066cb2dc15e0fc71c85 (diff) | |
parent | d0a3c4f9dbf0d661d3b91f46f0fa4db2dc33bb78 (diff) | |
download | u-boot-6808dc62d75de706c5aabc24e36caf52ead30fc7.tar.xz |
Merge tag 'u-boot-stm32-20200813' of https://gitlab.denx.de/u-boot/custodians/u-boot-stm
- Use IS_ENABLED to prevent ifdef in board_key_check for STM32MP
- Add STM32 FMC2 EBI controller driver
- Fix dwc3-sti-glue which allows STiH410-B2260 to boot again
- Add fitImage its entry for 587-200 DHCOR SoM
- Add both PDK2 and DRC02 DT into DHCOM fitImage its
- Fix DHCOM KS8851 ethernet MAC address
- Remove stm32mp1 board.c file
- Use const for struct node_info in board stm32mp1.c file
Diffstat (limited to 'board')
-rw-r--r-- | board/dhelectronics/dh_stm32mp1/board.c | 33 | ||||
-rw-r--r-- | board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its | 32 | ||||
-rw-r--r-- | board/dhelectronics/dh_stm32mp1/u-boot-dhcor.its | 3 | ||||
-rw-r--r-- | board/st/common/stm32mp_dfu.c | 20 | ||||
-rw-r--r-- | board/st/stm32mp1/board.c | 36 | ||||
-rw-r--r-- | board/st/stm32mp1/stm32mp1.c | 201 |
6 files changed, 172 insertions, 153 deletions
diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c index 17dbf20d76..c9abe3cc6d 100644 --- a/board/dhelectronics/dh_stm32mp1/board.c +++ b/board/dhelectronics/dh_stm32mp1/board.c @@ -84,11 +84,26 @@ DECLARE_GLOBAL_DATA_PTR; int setup_mac_address(void) { unsigned char enetaddr[6]; + bool skip_eth0 = false; + bool skip_eth1 = false; struct udevice *dev; int off, ret; ret = eth_env_get_enetaddr("ethaddr", enetaddr); if (ret) /* ethaddr is already set */ + skip_eth0 = true; + + off = fdt_path_offset(gd->fdt_blob, "ethernet1"); + if (off < 0) { + /* ethernet1 is not present in the system */ + skip_eth1 = true; + } else { + ret = eth_env_get_enetaddr("eth1addr", enetaddr); + if (ret) /* eth1addr is already set */ + skip_eth1 = true; + } + + if (skip_eth0 && skip_eth1) return 0; off = fdt_path_offset(gd->fdt_blob, "eeprom0"); @@ -109,8 +124,14 @@ int setup_mac_address(void) return ret; } - if (is_valid_ethaddr(enetaddr)) - eth_env_set_enetaddr("ethaddr", enetaddr); + if (is_valid_ethaddr(enetaddr)) { + if (!skip_eth0) + eth_env_set_enetaddr("ethaddr", enetaddr); + + enetaddr[5]++; + if (!skip_eth1) + eth_env_set_enetaddr("eth1addr", enetaddr); + } return 0; } @@ -216,9 +237,13 @@ int board_early_init_f(void) #ifdef CONFIG_SPL_LOAD_FIT int board_fit_config_name_match(const char *name) { - char test[20]; + const char *compat; + char test[128]; + + compat = fdt_getprop(gd->fdt_blob, 0, "compatible", NULL); - snprintf(test, sizeof(test), "somrev%d_boardrev%d", somcode, brdcode); + snprintf(test, sizeof(test), "%s_somrev%d_boardrev%d", + compat, somcode, brdcode); if (!strcmp(name, test)) return 0; diff --git a/board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its b/board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its index 2776c41af1..905be57dff 100644 --- a/board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its +++ b/board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its @@ -23,17 +23,47 @@ arch = "arm"; compression = "none"; }; + + fdt-2 { + description = ".dtb"; + data = /incbin/("arch/arm/dts/stm32mp15xx-dhcom-drc02.dtb"); + type = "flat_dt"; + arch = "arm"; + compression = "none"; + }; }; configurations { default = "config-1"; config-1 { - description = "somrev0_boardrev0"; /* SoM+board model */ + /* DT+SoM+board model */ + description = "dh,stm32mp15xx-dhcom-pdk2_somrev0_boardrev0"; + loadables = "uboot"; + fdt = "fdt-1"; + }; + + config-2 { + /* DT+SoM+board model */ + description = "dh,stm32mp15xx-dhcom-pdk2_somrev1_boardrev0"; loadables = "uboot"; fdt = "fdt-1"; }; + config-3 { + /* DT+SoM+board model */ + description = "dh,stm32mp15xx-dhcom-drc02_somrev0_boardrev0"; + loadables = "uboot"; + fdt = "fdt-2"; + }; + + config-4 { + /* DT+SoM+board model */ + description = "dh,stm32mp15xx-dhcom-drc02_somrev1_boardrev0"; + loadables = "uboot"; + fdt = "fdt-2"; + }; + /* Add 587-100..587-400 with fdt-2..fdt-4 here */ }; }; diff --git a/board/dhelectronics/dh_stm32mp1/u-boot-dhcor.its b/board/dhelectronics/dh_stm32mp1/u-boot-dhcor.its index 8844508f1a..7419684f55 100644 --- a/board/dhelectronics/dh_stm32mp1/u-boot-dhcor.its +++ b/board/dhelectronics/dh_stm32mp1/u-boot-dhcor.its @@ -29,7 +29,8 @@ default = "config-1"; config-1 { - description = "somrev0_boardrev1"; /* SoM+board model */ + /* DT+SoM+board model */ + description = "arrow,stm32mp15xx-avenger96_somrev0_boardrev1"; loadables = "uboot"; fdt = "fdt-1"; }; diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c index 38eb0f27c9..aab7d741ac 100644 --- a/board/st/common/stm32mp_dfu.c +++ b/board/st/common/stm32mp_dfu.c @@ -114,11 +114,13 @@ void set_dfu_alt_info(char *interface, char *devstr) snprintf(buf, DFU_ALT_BUF_LEN, "ram 0=%s", CONFIG_DFU_ALT_RAM0); - if (!uclass_get_device(UCLASS_MMC, 0, &dev)) - board_get_alt_info_mmc(dev, buf); + if (CONFIG_IS_ENABLED(MMC)) { + if (!uclass_get_device(UCLASS_MMC, 0, &dev)) + board_get_alt_info_mmc(dev, buf); - if (!uclass_get_device(UCLASS_MMC, 1, &dev)) - board_get_alt_info_mmc(dev, buf); + if (!uclass_get_device(UCLASS_MMC, 1, &dev)) + board_get_alt_info_mmc(dev, buf); + } if (CONFIG_IS_ENABLED(MTD)) { /* probe all MTD devices */ @@ -140,12 +142,12 @@ void set_dfu_alt_info(char *interface, char *devstr) board_get_alt_info_mtd(mtd, buf); } -#ifdef CONFIG_DFU_VIRT - strncat(buf, "&virt 0=OTP", DFU_ALT_BUF_LEN); + if (IS_ENABLED(CONFIG_DFU_VIRT)) { + strncat(buf, "&virt 0=OTP", DFU_ALT_BUF_LEN); - if (IS_ENABLED(CONFIG_PMIC_STPMIC1)) - strncat(buf, "&virt 1=PMIC", DFU_ALT_BUF_LEN); -#endif + if (IS_ENABLED(CONFIG_PMIC_STPMIC1)) + strncat(buf, "&virt 1=PMIC", DFU_ALT_BUF_LEN); + } env_set("dfu_alt_info", buf); puts("DFU alt info setting: done\n"); diff --git a/board/st/stm32mp1/board.c b/board/st/stm32mp1/board.c deleted file mode 100644 index 00c61c2886..0000000000 --- a/board/st/stm32mp1/board.c +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause -/* - * Copyright (C) 2018, STMicroelectronics - All Rights Reserved - */ - -#include <common.h> -#include <asm/io.h> -#include <linux/bitops.h> -#include <linux/delay.h> - -#ifdef CONFIG_DEBUG_UART_BOARD_INIT -void board_debug_uart_init(void) -{ -#if (CONFIG_DEBUG_UART_BASE == STM32_UART4_BASE) - -#define RCC_MP_APB1ENSETR (STM32_RCC_BASE + 0x0A00) -#define RCC_MP_AHB4ENSETR (STM32_RCC_BASE + 0x0A28) - - /* UART4 clock enable */ - setbits_le32(RCC_MP_APB1ENSETR, BIT(16)); - -#define GPIOG_BASE 0x50008000 - /* GPIOG clock enable */ - writel(BIT(6), RCC_MP_AHB4ENSETR); - /* GPIO configuration for EVAL board - * => Uart4 TX = G11 - */ - writel(0xffbfffff, GPIOG_BASE + 0x00); - writel(0x00006000, GPIOG_BASE + 0x24); -#else - -#error("CONFIG_DEBUG_UART_BASE: not supported value") - -#endif -} -#endif diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c index 1d274c3157..3b677d339b 100644 --- a/board/st/stm32mp1/stm32mp1.c +++ b/board/st/stm32mp1/stm32mp1.c @@ -135,60 +135,61 @@ int checkboard(void) static void board_key_check(void) { -#if defined(CONFIG_FASTBOOT) || defined(CONFIG_CMD_STM32PROG) ofnode node; struct gpio_desc gpio; enum forced_boot_mode boot_mode = BOOT_NORMAL; + if (!IS_ENABLED(CONFIG_FASTBOOT) && !IS_ENABLED(CONFIG_CMD_STM32PROG)) + return; + node = ofnode_path("/config"); if (!ofnode_valid(node)) { debug("%s: no /config node?\n", __func__); return; } -#ifdef CONFIG_FASTBOOT - if (gpio_request_by_name_nodev(node, "st,fastboot-gpios", 0, - &gpio, GPIOD_IS_IN)) { - debug("%s: could not find a /config/st,fastboot-gpios\n", - __func__); - } else { - if (dm_gpio_get_value(&gpio)) { - puts("Fastboot key pressed, "); - boot_mode = BOOT_FASTBOOT; - } + if (IS_ENABLED(CONFIG_FASTBOOT)) { + if (gpio_request_by_name_nodev(node, "st,fastboot-gpios", 0, + &gpio, GPIOD_IS_IN)) { + debug("%s: could not find a /config/st,fastboot-gpios\n", + __func__); + } else { + if (dm_gpio_get_value(&gpio)) { + puts("Fastboot key pressed, "); + boot_mode = BOOT_FASTBOOT; + } - dm_gpio_free(NULL, &gpio); + dm_gpio_free(NULL, &gpio); + } } -#endif -#ifdef CONFIG_CMD_STM32PROG - if (gpio_request_by_name_nodev(node, "st,stm32prog-gpios", 0, - &gpio, GPIOD_IS_IN)) { - debug("%s: could not find a /config/st,stm32prog-gpios\n", - __func__); - } else { - if (dm_gpio_get_value(&gpio)) { - puts("STM32Programmer key pressed, "); - boot_mode = BOOT_STM32PROG; + if (IS_ENABLED(CONFIG_CMD_STM32PROG)) { + if (gpio_request_by_name_nodev(node, "st,stm32prog-gpios", 0, + &gpio, GPIOD_IS_IN)) { + debug("%s: could not find a /config/st,stm32prog-gpios\n", + __func__); + } else { + if (dm_gpio_get_value(&gpio)) { + puts("STM32Programmer key pressed, "); + boot_mode = BOOT_STM32PROG; + } + dm_gpio_free(NULL, &gpio); } - dm_gpio_free(NULL, &gpio); } -#endif - if (boot_mode != BOOT_NORMAL) { puts("entering download mode...\n"); clrsetbits_le32(TAMP_BOOT_CONTEXT, TAMP_BOOT_FORCED_MASK, boot_mode); } -#endif } -#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG) -#include <usb/dwc2_udc.h> int g_dnl_board_usb_cable_connected(void) { struct udevice *dwc2_udc_otg; int ret; + if (!IS_ENABLED(CONFIG_USB_GADGET_DWC2_OTG)) + return -ENODEV; + /* if typec stusb160x is present, means DK1 or DK2 board */ ret = stusb160x_cable_connected(); if (ret >= 0) @@ -203,14 +204,17 @@ int g_dnl_board_usb_cable_connected(void) return dwc2_udc_B_session_valid(dwc2_udc_otg); } +#ifdef CONFIG_USB_GADGET_DOWNLOAD #define STM32MP1_G_DNL_DFU_PRODUCT_NUM 0xdf11 #define STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM 0x0afb int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) { - if (!strcmp(name, "usb_dnl_dfu")) + if (IS_ENABLED(CONFIG_DFU_OVER_USB) && + !strcmp(name, "usb_dnl_dfu")) put_unaligned(STM32MP1_G_DNL_DFU_PRODUCT_NUM, &dev->idProduct); - else if (!strcmp(name, "usb_dnl_fastboot")) + else if (IS_ENABLED(CONFIG_FASTBOOT) && + !strcmp(name, "usb_dnl_fastboot")) put_unaligned(STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM, &dev->idProduct); else @@ -218,8 +222,7 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) return 0; } - -#endif /* CONFIG_USB_GADGET */ +#endif /* CONFIG_USB_GADGET_DOWNLOAD */ static int get_led(struct udevice **dev, char *led_string) { @@ -285,7 +288,6 @@ static void __maybe_unused led_error_blink(u32 nb_blink) hang(); } -#ifdef CONFIG_ADC static int board_check_usb_power(void) { struct ofnode_phandle_args adc_args; @@ -297,6 +299,10 @@ static int board_check_usb_power(void) int ret, uV, adc_count; u32 nb_blink; u8 i; + + if (!IS_ENABLED(CONFIG_ADC)) + return -ENODEV; + node = ofnode_path("/config"); if (!ofnode_valid(node)) { debug("%s: no /config node?\n", __func__); @@ -419,18 +425,14 @@ static int board_check_usb_power(void) return 0; } -#endif /* CONFIG_ADC */ static void sysconf_init(void) { -#ifndef CONFIG_TFABOOT u8 *syscfg; -#ifdef CONFIG_DM_REGULATOR struct udevice *pwr_dev; struct udevice *pwr_reg; struct udevice *dev; u32 otp = 0; -#endif int ret; u32 bootr, val; @@ -448,7 +450,6 @@ static void sysconf_init(void) bootr |= (bootr & SYSCFG_BOOTR_BOOT_MASK) << SYSCFG_BOOTR_BOOTPD_SHIFT; writel(bootr, syscfg + SYSCFG_BOOTR); -#ifdef CONFIG_DM_REGULATOR /* High Speed Low Voltage Pad mode Enable for SPI, SDMMC, ETH, QSPI * and TRACE. Needed above ~50MHz and conditioned by AFMUX selection. * The customer will have to disable this for low frequencies @@ -465,7 +466,7 @@ static void sysconf_init(void) ret = uclass_get_device_by_driver(UCLASS_PMIC, DM_GET_DRIVER(stm32mp_pwr_pmic), &pwr_dev); - if (!ret) { + if (!ret && IS_ENABLED(CONFIG_DM_REGULATOR)) { ret = uclass_get_device_by_driver(UCLASS_MISC, DM_GET_DRIVER(stm32mp_bsec), &dev); @@ -502,7 +503,6 @@ static void sysconf_init(void) debug("VDD unknown"); } } -#endif /* activate automatic I/O compensation * warning: need to ensure CSI enabled and ready in clock driver @@ -519,10 +519,8 @@ static void sysconf_init(void) } clrbits_le32(syscfg + SYSCFG_CMPCR, SYSCFG_CMPCR_SW_CTRL); -#endif } -#ifdef CONFIG_DM_REGULATOR /* Fix to make I2C1 usable on DK2 for touchscreen usage in kernel */ static int dk2_i2c1_fix(void) { @@ -530,6 +528,9 @@ static int dk2_i2c1_fix(void) struct gpio_desc hdmi, audio; int ret = 0; + if (!IS_ENABLED(CONFIG_DM_REGULATOR)) + return -ENODEV; + node = ofnode_path("/soc/i2c@40012000/hdmi-transmitter@39"); if (!ofnode_valid(node)) { pr_debug("%s: no hdmi-transmitter@39 ?\n", __func__); @@ -587,7 +588,6 @@ static bool board_is_dk2(void) return false; } -#endif static bool board_is_ev1(void) { @@ -635,14 +635,14 @@ int board_init(void) if (board_is_ev1()) board_ev1_init(); -#ifdef CONFIG_DM_REGULATOR if (board_is_dk2()) dk2_i2c1_fix(); - regulators_enable_boot_on(_DEBUG); -#endif + if (IS_ENABLED(CONFIG_DM_REGULATOR)) + regulators_enable_boot_on(_DEBUG); - sysconf_init(); + if (!IS_ENABLED(CONFIG_TFABOOT)) + sysconf_init(); if (CONFIG_IS_ENABLED(LED)) led_default_state(); @@ -654,52 +654,50 @@ int board_init(void) int board_late_init(void) { -#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG const void *fdt_compat; int fdt_compat_len; int ret; u32 otp; struct udevice *dev; char buf[10]; + char dtb_name[256]; + int buf_len; + + if (IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG)) { + fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible", + &fdt_compat_len); + if (fdt_compat && fdt_compat_len) { + if (strncmp(fdt_compat, "st,", 3) != 0) { + env_set("board_name", fdt_compat); + } else { + env_set("board_name", fdt_compat + 3); - fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible", - &fdt_compat_len); - if (fdt_compat && fdt_compat_len) { - if (strncmp(fdt_compat, "st,", 3) != 0) { - env_set("board_name", fdt_compat); - } else { - char dtb_name[256]; - int buf_len = sizeof(dtb_name); + buf_len = sizeof(dtb_name); + strncpy(dtb_name, fdt_compat + 3, buf_len); + buf_len -= strlen(fdt_compat + 3); + strncat(dtb_name, ".dtb", buf_len); + env_set("fdtfile", dtb_name); + } + } + ret = uclass_get_device_by_driver(UCLASS_MISC, + DM_GET_DRIVER(stm32mp_bsec), + &dev); - env_set("board_name", fdt_compat + 3); + if (!ret) + ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD), + &otp, sizeof(otp)); + if (ret > 0 && otp) { + snprintf(buf, sizeof(buf), "0x%04x", otp >> 16); + env_set("board_id", buf); - strncpy(dtb_name, fdt_compat + 3, buf_len); - buf_len -= strlen(fdt_compat + 3); - strncat(dtb_name, ".dtb", buf_len); - env_set("fdtfile", dtb_name); + snprintf(buf, sizeof(buf), "0x%04x", + ((otp >> 8) & 0xF) - 1 + 0xA); + env_set("board_rev", buf); } } - ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stm32mp_bsec), - &dev); - if (!ret) - ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD), - &otp, sizeof(otp)); - if (ret > 0 && otp) { - snprintf(buf, sizeof(buf), "0x%04x", otp >> 16); - env_set("board_id", buf); - - snprintf(buf, sizeof(buf), "0x%04x", - ((otp >> 8) & 0xF) - 1 + 0xA); - env_set("board_rev", buf); - } -#endif - -#ifdef CONFIG_ADC /* for DK1/DK2 boards */ board_check_usb_power(); -#endif /* CONFIG_ADC */ return 0; } @@ -787,31 +785,33 @@ enum env_location env_get_location(enum env_operation op, int prio) return ENVL_UNKNOWN; switch (bootmode & TAMP_BOOT_DEVICE_MASK) { -#if CONFIG_IS_ENABLED(ENV_IS_IN_MMC) - case BOOT_FLASH_SD: - case BOOT_FLASH_EMMC: - return ENVL_MMC; -#endif -#if CONFIG_IS_ENABLED(ENV_IS_IN_EXT4) case BOOT_FLASH_SD: case BOOT_FLASH_EMMC: - return ENVL_EXT4; -#endif -#if CONFIG_IS_ENABLED(ENV_IS_IN_UBI) + if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC)) + return ENVL_MMC; + else if (CONFIG_IS_ENABLED(ENV_IS_IN_EXT4)) + return ENVL_EXT4; + else + return ENVL_NOWHERE; + case BOOT_FLASH_NAND: case BOOT_FLASH_SPINAND: - return ENVL_UBI; -#endif -#if CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH) + if (CONFIG_IS_ENABLED(ENV_IS_IN_UBI)) + return ENVL_UBI; + else + return ENVL_NOWHERE; + case BOOT_FLASH_NOR: - return ENVL_SPI_FLASH; -#endif + if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH)) + return ENVL_SPI_FLASH; + else + return ENVL_NOWHERE; + default: return ENVL_NOWHERE; } } -#if defined(CONFIG_ENV_IS_IN_EXT4) const char *env_ext4_get_intf(void) { u32 bootmode = get_bootmode(); @@ -832,28 +832,25 @@ const char *env_ext4_get_dev_part(void) return dev_part[(bootmode & TAMP_BOOT_INSTANCE_MASK) - 1]; } -#endif - -#if defined(CONFIG_ENV_IS_IN_MMC) int mmc_get_env_dev(void) { u32 bootmode = get_bootmode(); return (bootmode & TAMP_BOOT_INSTANCE_MASK) - 1; } -#endif #if defined(CONFIG_OF_BOARD_SETUP) int ft_board_setup(void *blob, struct bd_info *bd) { -#ifdef CONFIG_FDT_FIXUP_PARTITIONS - struct node_info nodes[] = { + static const struct node_info nodes[] = { { "st,stm32f469-qspi", MTD_DEV_TYPE_NOR, }, { "st,stm32f469-qspi", MTD_DEV_TYPE_SPINAND}, { "st,stm32mp15-fmc2", MTD_DEV_TYPE_NAND, }, + { "st,stm32mp1-fmc2-nfc", MTD_DEV_TYPE_NAND, }, }; - fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes)); -#endif + + if (IS_ENABLED(CONFIG_FDT_FIXUP_PARTITIONS)) + fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes)); return 0; } |