]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ARM: stm32: Implement board coding on AV96
authorMarek Vasut <marex@denx.de>
Wed, 22 Apr 2020 11:18:11 +0000 (13:18 +0200)
committerPatrick Delaunay <patrick.delaunay@st.com>
Thu, 14 May 2020 07:02:12 +0000 (09:02 +0200)
The AV96 board does exist in multiple variants. To cater for all of
them, implement board code handling. There are two GPIOs which code
the type of the board, read them out and use the value to pick the
correct device tree from an fitImage.

Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Patrice Chotard <patrice.chotard@st.com>
Change-Id: Iddb330b9a66500495885457cbe17edc0eacaaf43

arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi
arch/arm/dts/stm32mp15xx-dhcor-avenger96-u-boot.dtsi
arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi
board/dhelectronics/dh_stm32mp1/Kconfig
board/dhelectronics/dh_stm32mp1/board.c
board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its [new file with mode: 0644]
board/dhelectronics/dh_stm32mp1/u-boot-dhcor.its [new file with mode: 0644]
configs/stm32mp15_dhcom_basic_defconfig
configs/stm32mp15_dhcor_basic_defconfig
include/configs/dh_stm32mp1.h [new file with mode: 0644]

index b57f3d520c63a0f8914e3f5f0b5616dd64596dfc..54f7ec57b79fc26a78cc979d965060ad4bfa8177 100644 (file)
@@ -23,6 +23,7 @@
                u-boot,error-led = "error";
                st,fastboot-gpios = <&gpioa 13 GPIO_ACTIVE_LOW>;
                st,stm32prog-gpios = <&gpioa 14 GPIO_ACTIVE_LOW>;
+               dh,som-coding-gpios = <&gpiof 12 0>, <&gpiof 13 0>, <&gpiof 15 0>;
        };
 
        led {
index 3f82f207055b631581229fa8e2953345ff94d282..cb92fc9c141a55af64759d5f296aba4e16652789 100644 (file)
@@ -15,6 +15,7 @@
        config {
                u-boot,boot-led = "led1";
                u-boot,error-led = "led4";
+               dh,board-coding-gpios = <&gpiog 13 0>, <&gpiod 9 0>;
        };
 };
 
index 5de7b87b9a1b30c6362322a27b6ad8915ef173db..aa81ed83930a32dda138b78ac54404a91297c090 100644 (file)
 #include "stm32mp15-u-boot.dtsi"
 #include "stm32mp15-ddr3-2x4Gb-1066-binG.dtsi"
 
+/ {
+       u-boot,dm-pre-reloc;
+       config {
+               dh,som-coding-gpios = <&gpioz 7 0>, <&gpiof 3 0>;
+       };
+};
+
 &i2c4 {
        u-boot,dm-pre-reloc;
 };
index 8eab986640ceb16ef4e7e896475c0254e1ff597a..0a839f2546e6d33abc7ab3866a198348c8016603 100644 (file)
@@ -7,7 +7,7 @@ config SYS_VENDOR
        default "dhelectronics"
 
 config SYS_CONFIG_NAME
-       default "stm32mp1"
+       default "dh_stm32mp1"
 
 config ENV_SECT_SIZE
        default 0x10000 if ENV_IS_IN_SPI_FLASH
index 322558157ec56bed02a303a10a54207cfafcb891..5193868d7cf11711bcb34c761c44fe0b1fe82531 100644 (file)
@@ -133,6 +133,62 @@ int checkboard(void)
        return 0;
 }
 
+#ifdef CONFIG_BOARD_EARLY_INIT_F
+static u8 brdcode __section("data");
+static u8 somcode __section("data");
+
+static void board_get_coding_straps(void)
+{
+       struct gpio_desc gpio[4];
+       ofnode node;
+       int i, ret;
+
+       node = ofnode_path("/config");
+       if (!ofnode_valid(node)) {
+               printf("%s: no /config node?\n", __func__);
+               return;
+       }
+
+       brdcode = 0;
+       somcode = 0;
+
+       ret = gpio_request_list_by_name_nodev(node, "dh,som-coding-gpios",
+                                             gpio, ARRAY_SIZE(gpio),
+                                             GPIOD_IS_IN);
+       for (i = 0; i < ret; i++)
+               somcode |= !!dm_gpio_get_value(&(gpio[i])) << i;
+
+       ret = gpio_request_list_by_name_nodev(node, "dh,board-coding-gpios",
+                                             gpio, ARRAY_SIZE(gpio),
+                                             GPIOD_IS_IN);
+       for (i = 0; i < ret; i++)
+               brdcode |= !!dm_gpio_get_value(&(gpio[i])) << i;
+
+       printf("Code:  SoM:rev=%d Board:rev=%d\n", somcode, brdcode);
+}
+
+int board_early_init_f(void)
+{
+       board_get_coding_straps();
+
+       return 0;
+}
+
+#ifdef CONFIG_SPL_LOAD_FIT
+int board_fit_config_name_match(const char *name)
+{
+       char test[20];
+
+       snprintf(test, sizeof(test), "somrev%d_boardrev%d", somcode, brdcode);
+
+       if (!strcmp(name, test))
+               return 0;
+
+       return -EINVAL;
+}
+#endif
+#endif
+
 static void board_key_check(void)
 {
 #if defined(CONFIG_FASTBOOT) || defined(CONFIG_CMD_STM32PROG)
@@ -478,6 +534,11 @@ int board_late_init(void)
        if (!strcmp(boot_device, "serial") || !strcmp(boot_device, "usb"))
                env_set("bootdelay", "0");
 
+#ifdef CONFIG_BOARD_EARLY_INIT_F
+       env_set_ulong("dh_som_rev", somcode);
+       env_set_ulong("dh_board_rev", brdcode);
+#endif
+
        return 0;
 }
 
diff --git a/board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its b/board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its
new file mode 100644 (file)
index 0000000..2776c41
--- /dev/null
@@ -0,0 +1,39 @@
+/dts-v1/;
+
+/ {
+       description = "U-Boot mainline";
+       #address-cells = <1>;
+
+       images {
+               uboot {
+                       description = "U-Boot (32-bit)";
+                       data = /incbin/("u-boot-nodtb.bin");
+                       type = "standalone";
+                       os = "U-Boot";
+                       arch = "arm";
+                       compression = "none";
+                       load = <0xc0100000>;
+                       entry = <0xc0100000>;
+               };
+
+               fdt-1 {
+                       description = ".dtb";
+                       data = /incbin/("arch/arm/dts/stm32mp15xx-dhcom-pdk2.dtb");
+                       type = "flat_dt";
+                       arch = "arm";
+                       compression = "none";
+               };
+       };
+
+       configurations {
+               default = "config-1";
+
+               config-1 {
+                       description = "somrev0_boardrev0"; /* SoM+board model */
+                       loadables = "uboot";
+                       fdt = "fdt-1";
+               };
+
+               /* 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
new file mode 100644 (file)
index 0000000..8844508
--- /dev/null
@@ -0,0 +1,39 @@
+/dts-v1/;
+
+/ {
+       description = "U-Boot mainline";
+       #address-cells = <1>;
+
+       images {
+               uboot {
+                       description = "U-Boot (32-bit)";
+                       data = /incbin/("u-boot-nodtb.bin");
+                       type = "standalone";
+                       os = "U-Boot";
+                       arch = "arm";
+                       compression = "none";
+                       load = <0xc0100000>;
+                       entry = <0xc0100000>;
+               };
+
+               fdt-1 {
+                       description = ".dtb";
+                       data = /incbin/("arch/arm/dts/stm32mp15xx-dhcor-avenger96.dtb");
+                       type = "flat_dt";
+                       arch = "arm";
+                       compression = "none";
+               };
+       };
+
+       configurations {
+               default = "config-1";
+
+               config-1 {
+                       description = "somrev0_boardrev1"; /* SoM+board model */
+                       loadables = "uboot";
+                       fdt = "fdt-1";
+               };
+
+               /* Add 586-200..586-400 with fdt-2..fdt-4 here */
+       };
+};
index c2f3a5ebc15a793bde0160bc6f97b905f83b71a8..12c43264669146c9db5e211196771490f2728525 100644 (file)
@@ -12,7 +12,11 @@ CONFIG_SPL_SPI_SUPPORT=y
 CONFIG_SPL_TEXT_BASE=0x2FFC2500
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_FIT_SOURCE="board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its"
 CONFIG_BOOTCOMMAND="run bootcmd_stm32mp"
+CONFIG_BOARD_EARLY_INIT_F=y
+CONFIG_SPL_LEGACY_IMAGE_SUPPORT=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=3
 CONFIG_SPL_I2C_SUPPORT=y
index 523de82fec0a54294a8165332bf57f4d293e5d0f..770fa47872c985ae08d2fc1b08a0c3127ff29a07 100644 (file)
@@ -12,7 +12,11 @@ CONFIG_SPL_SPI_SUPPORT=y
 CONFIG_SPL_TEXT_BASE=0x2FFC2500
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_FIT_SOURCE="board/dhelectronics/dh_stm32mp1/u-boot-dhcor.its"
 CONFIG_BOOTCOMMAND="run bootcmd_stm32mp"
+CONFIG_BOARD_EARLY_INIT_F=y
+CONFIG_SPL_LEGACY_IMAGE_SUPPORT=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=3
 CONFIG_SPL_I2C_SUPPORT=y
diff --git a/include/configs/dh_stm32mp1.h b/include/configs/dh_stm32mp1.h
new file mode 100644 (file)
index 0000000..89d317b
--- /dev/null
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
+/*
+ * Copyright (C) 2020 Marek Vasut <marex@denx.de>
+ *
+ * Configuration settings for the DH STM32MP15x SoMs
+ */
+
+#ifndef __CONFIG_DH_STM32MP1_H__
+#define __CONFIG_DH_STM32MP1_H__
+
+#include <configs/stm32mp1.h>
+
+#define CONFIG_SPL_TARGET              "u-boot.itb"
+
+#endif