Skip to contentSkip to conversation

dts: Add ability to build fallback DTBOs from arch/$(ARCH)/dts

PATCH Superseded Marek Vasut 3 participants 5 messages Oct 5, 2024 – Oct 7, 2024

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 dts: Add ability to build fallback DTBOs from arch/$(ARCH)/dts

Currently the enablement of OF_UPSTREAM results on the build system searching for DTs only in dts/upstream/ . There are platforms which use U-Boot specific DTBOs applied on top of U-Boot control DT during SPL stage, and source DTs for these are located in arch/$(ARCH)/dtb.

Add dedicated 'dtbos' target which builds only .dtbos and not .dtbs and in case CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS is enabled, build this target for arch/$(ARCH)/dtb to generate local U-Boot specific DTBOs.

Adjust top level Makefile so binman would search for .dtb and .dtbo in both OF_UPSTREAM specific paths and arch/$(ARCH)/dtb for the .dtbo case in case CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS is enabled.

---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Caleb Connolly <[email protected]>
Cc: Christoph Niedermaier <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Heinrich Schuchardt <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Lothar Rubusch <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: Nobuhiro Iwamatsu <[email protected]>
Cc: Rasmus Villemoes <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Stefano Babic <[email protected]>
Cc: Sumit Garg <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
V2: Gate this functionality behind CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS
---
NOTE: Depends on https://lore.kernel.org/u-boot/[email protected]/

---
 Makefile             |  4 ++++
 dts/Kconfig          | 16 ++++++++++++++++
 dts/Makefile         | 14 +++++++++++++-
 scripts/Makefile.dts |  6 ++++++
 4 files changed, 39 insertions(+), 1 deletion(-)
Makefile +4 -0
index af24de4165e..a5258e8cb3f 100644
@@ -1375,7 +1375,11 @@ of_list := "$(ext_dtb_list)"
 of_list_dirs := $(dir $(EXT_DTB))
 else
 of_list := $(CONFIG_OF_LIST)
+ifneq ($(CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS),)
+of_list_dirs := $(dt_dir) arch/$(ARCH)/dts
+else
 of_list_dirs := $(dt_dir)
+endif
 default_dt := $(if $(DEVICE_TREE),$(DEVICE_TREE),$(CONFIG_DEFAULT_DEVICE_TREE))
 endif
 
dts/Kconfig +16 -0
index 569d4be338e..385058b429f 100644
@@ -125,6 +125,22 @@ config OF_UPSTREAM_VENDOR
 	help
 	  Select the vendor to build all devicetree files for.
 
+config OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS
+	bool "Build local DTBOs as fallback for DTBOs missing upstream"
+	default n
+	depends on OF_UPSTREAM
+	help
+	  Enable building DTBOs from arch/$(ARCH)/dts as a fallback for
+	  DTBOs which are not part of Linux kernel upstream yet. This is
+	  a stopgap measure to expedite OF_UPSTREAM switch for platforms
+	  which already have main DT in Linux kernel upstream, but still
+	  have leftover DTBOs in U-Boot tree.
+
+	  Do not use this option, upstream your DTs and DTBOs instead.
+	  If the upstreaming is in progress, use with utmost caution.
+
+	  If unsure, say N.
+
 choice
 	prompt "Provider of DTB for DT control"
 	depends on OF_CONTROL
dts/Makefile +13 -1
index d6c2c9daf31..32c749a043a 100644
@@ -11,12 +11,18 @@ DEVICE_TREE := unset
 endif
 
 ifeq ($(CONFIG_OF_UPSTREAM),y)
+ifneq ($(CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS),)
+local_dtbos := local-dtbos
+else
+local_dtbos :=
+endif
 ifeq ($(CONFIG_ARM64),y)
 dt_dir := dts/upstream/src/arm64
 else
 dt_dir := dts/upstream/src/$(ARCH)
 endif
 else
+local_dtbos :=
 dt_dir := arch/$(ARCH)/dts
 endif
 
@@ -40,7 +46,7 @@ endif
 
 targets += dt.dtb
 
-$(DTB): arch-dtbs
+$(DTB): arch-dtbs $(local_dtbos)
 	$(Q)test -e $@ || (						\
 	echo >&2;							\
 	echo >&2 "Device Tree Source ($@) is not correctly specified.";	\
@@ -53,6 +59,12 @@ PHONY += arch-dtbs
 arch-dtbs:
 	$(Q)$(MAKE) $(build)=$(dt_dir) dtbs
 
+ifneq ($(CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS),)
+PHONY += local-dtbos
+local-dtbos:
+	$(Q)$(MAKE) $(build)=arch/$(ARCH)/dts dtbos
+endif
+
 ifeq ($(CONFIG_SPL_BUILD),y)
 obj-$(CONFIG_OF_EMBED) := dt-spl.dtb.o
 # support "out-of-tree" build for dtb-spl
scripts/Makefile.dts +6 -0
index 1fe142f2bbf..3ab67b3c247 100644
@@ -21,4 +21,10 @@ PHONY += dtbs
 dtbs: $(addprefix $(obj)/, $(dtb-y))
 	@:
 
+ifneq ($(CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS),)
+PHONY += dtbos
+dtbos: $(addprefix $(obj)/, $(filter-out %.dtb,$(dtb-y)))
+	@:
+endif
+
 clean-files := *.dtb *.dtbo */*.dtb */*.dtbo *_HS
Signature · 1 line
2.45.2
#1 lore raw

PATCH v2 2/2 arm64: dts: imx: Switch to using upstream DT on DH i.MX8MP DHCOM PDK2/PDK3

Enable OF_UPSTREAM to use upstream DT and add freescale/ prefix to the DEFAULT_DEVICE_TREE. And thereby directly build DTB from dts/upstream/src/ including *-u-boot.dtsi and DTBOs from arch/$(ARCH)/dts/ directory.

---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Caleb Connolly <[email protected]>
Cc: Christoph Niedermaier <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Heinrich Schuchardt <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Lothar Rubusch <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: Nobuhiro Iwamatsu <[email protected]>
Cc: Rasmus Villemoes <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Stefano Babic <[email protected]>
Cc: Sumit Garg <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
V2: Enable CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS

---
 arch/arm/dts/Makefile               |   2 -
 arch/arm/dts/imx8mp-dhcom-pdk2.dts  | 158 --------------
 arch/arm/dts/imx8mp-dhcom-pdk3.dts  | 317 ----------------------------
 configs/imx8mp_dhcom_pdk2_defconfig |   6 +-
 configs/imx8mp_dhcom_pdk3_defconfig |   6 +-
 5 files changed, 8 insertions(+), 481 deletions(-)
 delete mode 100644 arch/arm/dts/imx8mp-dhcom-pdk2.dts
 delete mode 100644 arch/arm/dts/imx8mp-dhcom-pdk3.dts
arch/arm/dts/Makefile +0 -2
index 83e38f0352a..ed97e1c26de 100644
@@ -969,8 +969,6 @@ dtb-$(CONFIG_ARCH_IMX8M) += \
 	imx8mp-dhcom-pdk-overlay-eth2xfast.dtbo \
 	imx8mp-debix-model-a.dtb \
 	imx8mp-dhcom-drc02.dtb \
-	imx8mp-dhcom-pdk2.dtb \
-	imx8mp-dhcom-pdk3.dtb \
 	imx8mp-dhcom-pdk3-overlay-rev100.dtbo \
 	imx8mp-dhcom-picoitx.dtb \
 	imx8mp-icore-mx8mp-edimm2.2.dtb \
arch/arm/dts/imx8mp-dhcom-pdk2.dts deleted +0 -158

158 lines not on this page · raw message

arch/arm/dts/imx8mp-dhcom-pdk3.dts deleted +0 -317

317 lines not on this page · raw message

configs/imx8mp_dhcom_pdk2_defconfig +4 -2
index f807b0cfc37..d527ca92c83 100644
@@ -12,7 +12,7 @@ CONFIG_ENV_SIZE=0x10000
 CONFIG_ENV_OFFSET=0xFE0000
 CONFIG_ENV_SECT_SIZE=0x1000
 CONFIG_DM_GPIO=y
-CONFIG_DEFAULT_DEVICE_TREE="imx8mp-dhcom-pdk2"
+CONFIG_DEFAULT_DEVICE_TREE="freescale/imx8mp-dhcom-pdk2"
 CONFIG_SPL_TEXT_BASE=0x920000
 CONFIG_TARGET_IMX8MP_DH_DHCOM_PDK2=y
 CONFIG_DM_RESET=y
@@ -48,7 +48,7 @@ CONFIG_USE_BOOTARGS=y
 CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="run dh_update_env distro_bootcmd ; reset"
 CONFIG_USE_PREBOOT=y
-CONFIG_DEFAULT_FDT_FILE="imx8mp-dhcom-pdk2.dtb"
+CONFIG_DEFAULT_FDT_FILE="freescale/imx8mp-dhcom-pdk2.dtb"
 CONFIG_SYS_CBSIZE=2048
 CONFIG_SYS_PBSIZE=2081
 CONFIG_CONSOLE_MUX=y
@@ -144,6 +144,8 @@ CONFIG_MMC_SPEED_MODE_SET=y
 CONFIG_PARTITION_TYPE_GUID=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
+CONFIG_OF_UPSTREAM=y
+CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_NOWHERE=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
configs/imx8mp_dhcom_pdk3_defconfig +4 -2
index 05895d6dd6f..5a41f140bb5 100644
@@ -12,7 +12,7 @@ CONFIG_ENV_SIZE=0x10000
 CONFIG_ENV_OFFSET=0xFE0000
 CONFIG_ENV_SECT_SIZE=0x1000
 CONFIG_DM_GPIO=y
-CONFIG_DEFAULT_DEVICE_TREE="imx8mp-dhcom-pdk3"
+CONFIG_DEFAULT_DEVICE_TREE="freescale/imx8mp-dhcom-pdk3"
 CONFIG_SPL_TEXT_BASE=0x920000
 CONFIG_TARGET_IMX8MP_DH_DHCOM_PDK2=y
 CONFIG_DM_RESET=y
@@ -50,7 +50,7 @@ CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="run dh_update_env distro_bootcmd ; reset"
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="gpio clear GPIO1_11 ; sleep 0.1 ; gpio set GPIO1_11 ; sleep 0.1 ; i2c dev 4 && i2c mw 0x70 0 4 && i2c probe 0x2d && i2c mw 0x2d 0xaa55.2 0"
-CONFIG_DEFAULT_FDT_FILE="imx8mp-dhcom-pdk3.dtb"
+CONFIG_DEFAULT_FDT_FILE="freescale/imx8mp-dhcom-pdk3.dtb"
 CONFIG_SYS_CBSIZE=2048
 CONFIG_SYS_PBSIZE=2081
 CONFIG_CONSOLE_MUX=y
@@ -147,6 +147,8 @@ CONFIG_MMC_SPEED_MODE_SET=y
 CONFIG_PARTITION_TYPE_GUID=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
+CONFIG_OF_UPSTREAM=y
+CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_NOWHERE=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
Signature · 1 line
2.45.2
Reviewed-by on v2 2/2
#2 lore raw

Re: [PATCH v2 2/2] arm64: dts: imx: Switch to using upstream DT on DH i.MX8MP DHCOM PDK2/PDK3

Quoted 25 lines · Marek Vasut

Enable OF_UPSTREAM to use upstream DT and add freescale/ prefix to the DEFAULT_DEVICE_TREE. And thereby directly build DTB from dts/upstream/src/ including *-u-boot.dtsi and DTBOs from arch/$(ARCH)/dts/ directory.

---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Caleb Connolly <[email protected]>
Cc: Christoph Niedermaier <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Heinrich Schuchardt <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Lothar Rubusch <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: Nobuhiro Iwamatsu <[email protected]>
Cc: Rasmus Villemoes <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Stefano Babic <[email protected]>
Cc: Sumit Garg <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
V2: Enable CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS

Quoted 10 lines
---
 arch/arm/dts/Makefile               |   2 -
 arch/arm/dts/imx8mp-dhcom-pdk2.dts  | 158 --------------
 arch/arm/dts/imx8mp-dhcom-pdk3.dts  | 317 ----------------------------
 configs/imx8mp_dhcom_pdk2_defconfig |   6 +-
 configs/imx8mp_dhcom_pdk3_defconfig |   6 +-
 5 files changed, 8 insertions(+), 481 deletions(-)
 delete mode 100644 arch/arm/dts/imx8mp-dhcom-pdk2.dts
 delete mode 100644 arch/arm/dts/imx8mp-dhcom-pdk3.dts

-Sumit

Quoted 565 lines
arch/arm/dts/Makefile +0 -2
index 83e38f0352a..ed97e1c26de 100644
@@ -969,8 +969,6 @@ dtb-$(CONFIG_ARCH_IMX8M) += \
        imx8mp-dhcom-pdk-overlay-eth2xfast.dtbo \
        imx8mp-debix-model-a.dtb \
        imx8mp-dhcom-drc02.dtb \
-       imx8mp-dhcom-pdk2.dtb \
-       imx8mp-dhcom-pdk3.dtb \
        imx8mp-dhcom-pdk3-overlay-rev100.dtbo \
        imx8mp-dhcom-picoitx.dtb \
        imx8mp-icore-mx8mp-edimm2.2.dtb \
arch/arm/dts/imx8mp-dhcom-pdk2.dts deleted +0 -158
deleted file mode 100644
index 8f4eff37c40..00000000000
@@ -1,158 +0,0 @@
-// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
-/*
- * Copyright (C) 2022 Marek Vasut <[email protected]>
- *
- * DHCOM iMX8MP variant:
- * DHCM-iMX8ML8-C160-R409-F1638-SPI16-GE-CAN2-SD-RTC-WBTA-ADC-T-RGB-CSI2-HS-I-01D2
- * DHCOM PCB number: 660-100 or newer
- * PDK2 PCB number: 516-400 or newer
- */
-
-/dts-v1/;
-
-#include <dt-bindings/leds/common.h>
-#include <dt-bindings/phy/phy-imx8-pcie.h>
-#include "imx8mp-dhcom-som.dtsi"
-
-/ {
-       model = "DH electronics i.MX8M Plus DHCOM Premium Developer Kit (2)";
-       compatible = "dh,imx8mp-dhcom-pdk2", "dh,imx8mp-dhcom-som",
-                    "fsl,imx8mp";
-
-       chosen {
-               stdout-path = &uart1;
-       };
-
-       gpio-keys {
-               compatible = "gpio-keys";
-
-               button-0 {
-                       gpios = <&gpio1 9 GPIO_ACTIVE_LOW>; /* GPIO A */
-                       label = "TA1-GPIO-A";
-                       linux,code = <KEY_A>;
-                       pinctrl-0 = <&pinctrl_dhcom_a>;
-                       pinctrl-names = "default";
-                       wakeup-source;
-               };
-
-               button-1 {
-                       gpios = <&gpio1 8 GPIO_ACTIVE_LOW>; /* GPIO B */
-                       label = "TA2-GPIO-B";
-                       linux,code = <KEY_B>;
-                       pinctrl-0 = <&pinctrl_dhcom_b>;
-                       pinctrl-names = "default";
-                       wakeup-source;
-               };
-
-               button-2 {
-                       gpios = <&gpio5 2 GPIO_ACTIVE_LOW>; /* GPIO C */
-                       label = "TA3-GPIO-C";
-                       linux,code = <KEY_C>;
-                       pinctrl-0 = <&pinctrl_dhcom_c>;
-                       pinctrl-names = "default";
-                       wakeup-source;
-               };
-
-               button-3 {
-                       gpios = <&gpio4 27 GPIO_ACTIVE_LOW>; /* GPIO D */
-                       label = "TA4-GPIO-D";
-                       linux,code = <KEY_D>;
-                       pinctrl-0 = <&pinctrl_dhcom_d>;
-                       pinctrl-names = "default";
-                       wakeup-source;
-               };
-       };
-
-       led {
-               compatible = "gpio-leds";
-
-               led-0 {
-                       color = <LED_COLOR_ID_GREEN>;
-                       default-state = "off";
-                       function = LED_FUNCTION_INDICATOR;
-                       gpios = <&gpio5 22 GPIO_ACTIVE_HIGH>; /* GPIO E */
-                       pinctrl-0 = <&pinctrl_dhcom_e>;
-                       pinctrl-names = "default";
-               };
-
-               led-1 {
-                       color = <LED_COLOR_ID_GREEN>;
-                       default-state = "off";
-                       function = LED_FUNCTION_INDICATOR;
-                       gpios = <&gpio5 23 GPIO_ACTIVE_HIGH>; /* GPIO F */
-                       pinctrl-0 = <&pinctrl_dhcom_f>;
-                       pinctrl-names = "default";
-               };
-
-               led-2 {
-                       color = <LED_COLOR_ID_GREEN>;
-                       default-state = "off";
-                       function = LED_FUNCTION_INDICATOR;
-                       gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>; /* GPIO H */
-                       pinctrl-0 = <&pinctrl_dhcom_h>;
-                       pinctrl-names = "default";
-               };
-
-               led-3 {
-                       color = <LED_COLOR_ID_GREEN>;
-                       default-state = "off";
-                       function = LED_FUNCTION_INDICATOR;
-                       gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>; /* GPIO I */
-                       pinctrl-0 = <&pinctrl_dhcom_i>;
-                       pinctrl-names = "default";
-               };
-       };
-};
-
-&fec { /* Second ethernet */
-       pinctrl-0 = <&pinctrl_fec_rgmii>;
-       phy-handle = <&ethphypdk>;
-       phy-mode = "rgmii";
-
-       mdio {
-               ethphypdk: ethernet-phy@7 { /* KSZ 9021 */
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       pinctrl-0 = <&pinctrl_ethphy1>;
-                       pinctrl-names = "default";
-                       interrupt-parent = <&gpio4>;
-                       interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
-                       max-speed = <100>;
-                       reg = <7>;
-                       reset-assert-us = <1000>;
-                       reset-deassert-us = <1000>;
-                       reset-gpios = <&gpio4 2 GPIO_ACTIVE_LOW>;
-                       rxc-skew-ps = <3000>;
-                       rxd0-skew-ps = <0>;
-                       rxd1-skew-ps = <0>;
-                       rxd2-skew-ps = <0>;
-                       rxd3-skew-ps = <0>;
-                       rxdv-skew-ps = <0>;
-                       txc-skew-ps = <3000>;
-                       txd0-skew-ps = <0>;
-                       txd1-skew-ps = <0>;
-                       txd2-skew-ps = <0>;
-                       txd3-skew-ps = <0>;
-                       txen-skew-ps = <0>;
-               };
-       };
-};
-
-&flexcan1 {
-       status = "okay";
-};
-
-&usb3_1 {
-       fsl,over-current-active-low;
-};
-
-&iomuxc {
-       /*
-        * GPIO_A,B,C,D are connected to buttons.
-        * GPIO_E,F,H,I are connected to LEDs.
-        * GPIO_M is connected to CLKOUT2.
-        */
-       pinctrl-0 = <&pinctrl_hog_base
-                    &pinctrl_dhcom_g &pinctrl_dhcom_j
-                    &pinctrl_dhcom_k &pinctrl_dhcom_l
-                    &pinctrl_dhcom_int>;
-};
arch/arm/dts/imx8mp-dhcom-pdk3.dts deleted +0 -317
deleted file mode 100644
index 867d238f2b5..00000000000
@@ -1,317 +0,0 @@
-// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
-/*
- * Copyright (C) 2023 Marek Vasut <[email protected]>
- *
- * DHCOM iMX8MP variant:
- * DHCM-iMX8ML8-C160-R409-F1638-SPI16-GE-CAN2-SD-RTC-WBTA-ADC-T-RGB-CSI2-HS-I-01D2
- * DHCOM PCB number: 660-100 or newer
- * PDK3 PCB number: 669-100 or newer
- */
-
-/dts-v1/;
-
-#include <dt-bindings/leds/common.h>
-#include <dt-bindings/phy/phy-imx8-pcie.h>
-#include "imx8mp-dhcom-som.dtsi"
-
-/ {
-       model = "DH electronics i.MX8M Plus DHCOM Premium Developer Kit (3)";
-       compatible = "dh,imx8mp-dhcom-pdk3", "dh,imx8mp-dhcom-som",
-                    "fsl,imx8mp";
-
-       chosen {
-               stdout-path = &uart1;
-       };
-
-       clk_ext_audio_codec: clock-codec {
-               #clock-cells = <0>;
-               clock-frequency = <24000000>;
-               compatible = "fixed-clock";
-       };
-
-       clk_xtal25: clk-xtal25 {
-               compatible = "fixed-clock";
-               #clock-cells = <0>;
-               clock-frequency = <25000000>;
-       };
-
-       connector {
-               compatible = "usb-c-connector";
-               label = "USB-C";
-               data-role = "dual";
-
-               ports {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-
-                       port@0 {
-                               reg = <0>;
-
-                               usb_c_0_hs_ep: endpoint {
-                                       remote-endpoint = <&dwc3_0_hs_ep>;
-                               };
-                       };
-
-                       port@1 {
-                               reg = <1>;
-
-                               usb_c_0_ss_ep: endpoint {
-                                       remote-endpoint = <&ptn5150_in_ep>;
-                               };
-                       };
-               };
-       };
-
-       gpio-keys {
-               compatible = "gpio-keys";
-
-               button-0 {
-                       gpios = <&gpio1 9 GPIO_ACTIVE_LOW>; /* GPIO A */
-                       label = "TA1-GPIO-A";
-                       linux,code = <KEY_A>;
-                       pinctrl-0 = <&pinctrl_dhcom_a>;
-                       pinctrl-names = "default";
-                       wakeup-source;
-               };
-
-               button-1 {
-                       gpios = <&gpio1 8 GPIO_ACTIVE_LOW>; /* GPIO B */
-                       label = "TA2-GPIO-B";
-                       linux,code = <KEY_B>;
-                       pinctrl-0 = <&pinctrl_dhcom_b>;
-                       pinctrl-names = "default";
-                       wakeup-source;
-               };
-
-               button-2 {
-                       gpios = <&gpio5 2 GPIO_ACTIVE_LOW>; /* GPIO C */
-                       label = "TA3-GPIO-C";
-                       linux,code = <KEY_C>;
-                       pinctrl-0 = <&pinctrl_dhcom_c>;
-                       pinctrl-names = "default";
-                       wakeup-source;
-               };
-
-               button-3 {
-                       gpios = <&gpio5 22 GPIO_ACTIVE_LOW>; /* GPIO E */
-                       label = "TA4-GPIO-E";
-                       linux,code = <KEY_E>;
-                       pinctrl-0 = <&pinctrl_dhcom_e>;
-                       pinctrl-names = "default";
-                       wakeup-source;
-               };
-       };
-
-       led {
-               compatible = "gpio-leds";
-
-               led-0 {
-                       color = <LED_COLOR_ID_GREEN>;
-                       default-state = "off";
-                       function = LED_FUNCTION_INDICATOR;
-                       function-enumerator = <0>;
-                       gpios = <&gpio4 27 GPIO_ACTIVE_HIGH>; /* GPIO D */
-                       pinctrl-0 = <&pinctrl_dhcom_d>;
-                       pinctrl-names = "default";
-               };
-
-               led-1 {
-                       color = <LED_COLOR_ID_GREEN>;
-                       default-state = "off";
-                       function = LED_FUNCTION_INDICATOR;
-                       function-enumerator = <1>;
-                       gpios = <&gpio5 23 GPIO_ACTIVE_HIGH>; /* GPIO F */
-                       pinctrl-0 = <&pinctrl_dhcom_f>;
-                       pinctrl-names = "default";
-               };
-
-               led-2 {
-                       color = <LED_COLOR_ID_GREEN>;
-                       default-state = "off";
-                       function = LED_FUNCTION_INDICATOR;
-                       function-enumerator = <2>;
-                       gpios = <&gpio1 0 GPIO_ACTIVE_HIGH>; /* GPIO G */
-                       pinctrl-0 = <&pinctrl_dhcom_g>;
-                       pinctrl-names = "default";
-               };
-
-               led-3 {
-                       color = <LED_COLOR_ID_GREEN>;
-                       default-state = "off";
-                       function = LED_FUNCTION_INDICATOR;
-                       function-enumerator = <3>;
-                       gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>; /* GPIO I */
-                       pinctrl-0 = <&pinctrl_dhcom_i>;
-                       pinctrl-names = "default";
-               };
-       };
-
-       reg_avdd: regulator-avdd {      /* AUDIO_VDD */
-               compatible = "regulator-fixed";
-               regulator-always-on;
-               regulator-min-microvolt = <3300000>;
-               regulator-max-microvolt = <3300000>;
-               regulator-name = "AUDIO_VDD";
-       };
-};
-
-&i2c5 {
-       i2cmux@70 {
-               compatible = "nxp,pca9540";
-               reg = <0x70>;
-               #address-cells = <1>;
-               #size-cells = <0>;
-
-               i2cmuxed0: i2c@0 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       reg = <0>;
-
-                       typec@3d {
-                               compatible = "nxp,ptn5150";
-                               reg = <0x3d>;
-                               interrupt-parent = <&gpio4>;
-                               interrupts = <25 IRQ_TYPE_EDGE_FALLING>;
-                               pinctrl-names = "default";
-                               pinctrl-0 = <&pinctrl_ptn5150>;
-                               status = "okay";
-
-                               ports {
-                                       #address-cells = <1>;
-                                       #size-cells = <0>;
-
-                                       port@0 {
-                                               reg = <0>;
-
-                                               ptn5150_in_ep: endpoint {
-                                                       remote-endpoint = <&usb_c_0_ss_ep>;
-                                               };
-                                       };
-
-                                       port@1 {
-                                               reg = <1>;
-
-                                               ptn5150_out_ep: endpoint {
-                                                       remote-endpoint = <&dwc3_0_ss_ep>;
-                                               };
-                                       };
-                               };
-                       };
-
-                       power-sensor@40 {
-                           compatible = "ti,ina238";
-                           reg = <0x40>;
-                           shunt-resistor = <20000>;   /* 0.02 R */
-                           ti,shunt-gain = <1>;        /* Drop cca. 40mV */
-                       };
-
-                       eeprom_board: eeprom@54 {
-                               compatible = "atmel,24c04";
-                               pagesize = <16>;
-                               reg = <0x54>;
-                       };
-
-                       pcieclk: clk@6b {
-                               compatible = "skyworks,si52144";
-                               reg = <0x6b>;
-                               clocks = <&clk_xtal25>;
-                               #clock-cells = <1>;
-                       };
-               };
-
-               i2cmuxed1: i2c@1 {      /* HDMI DDC I2C */
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       reg = <1>;
-               };
-       };
-};
-
-&fec { /* Second ethernet */
-       pinctrl-0 = <&pinctrl_fec_rgmii>;
-       phy-handle = <&ethphypdk>;
-       phy-mode = "rgmii-id";
-
-       mdio {
-               ethphypdk: ethernet-phy@7 { /* Micrel KSZ9131RNXI */
-                       compatible = "ethernet-phy-id0022.1642",
-                                    "ethernet-phy-ieee802.3-c22";
-                       interrupt-parent = <&gpio4>;
-                       interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
-                       pinctrl-0 = <&pinctrl_ethphy1>;
-                       pinctrl-names = "default";
-                       reg = <7>;
-                       reset-assert-us = <1000>;
-                       /* RESET_N signal rise time ~100ms */
-                       reset-deassert-us = <120000>;
-                       reset-gpios = <&gpio4 2 GPIO_ACTIVE_LOW>;
-                       status = "okay";
-               };
-       };
-};
-
-&flexcan1 {
-       status = "okay";
-};
-
-&pcie_phy {
-       clocks = <&pcieclk 1>;
-       clock-names = "ref";
-       fsl,refclk-pad-mode = <IMX8_PCIE_REFCLK_PAD_INPUT>;
-       status = "okay";
-};
-
-&pcie {
-       fsl,max-link-speed = <3>;
-       reset-gpio = <&gpio1 6 GPIO_ACTIVE_LOW>;
-       status = "okay";
-};
-
-&usb_dwc3_0 {
-       usb-role-switch;
-
-       port {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
-               dwc3_0_hs_ep: endpoint@0 {
-                       reg = <0>;
-                       remote-endpoint = <&usb_c_0_hs_ep>;
-               };
-
-               dwc3_0_ss_ep: endpoint@1 {
-                       reg = <1>;
-                       remote-endpoint = <&ptn5150_out_ep>;
-               };
-       };
-};
-
-&usb3_1 {
-       fsl,disable-port-power-control;
-       fsl,permanently-attached;
-};
-
-&usb_dwc3_1 {
-       /* This port has USB5734 Hub connected to it, PWR/OC pins are unused */
-       /delete-property/ pinctrl-names;
-       /delete-property/ pinctrl-0;
-};
-
-&iomuxc {
-       /*
-        * GPIO_A,B,C,E are connected to buttons.
-        * GPIO_D,F,G,I are connected to LEDs.
-        * GPIO_H is connected to USB Hub RESET_N.
-        * GPIO_M is connected to CLKOUT2.
-        */
-       pinctrl-0 = <&pinctrl_hog_base
-                    &pinctrl_dhcom_h &pinctrl_dhcom_j &pinctrl_dhcom_k
-                    &pinctrl_dhcom_l
-                    &pinctrl_dhcom_int>;
-
-       pinctrl_ptn5150: ptn5150grp {
-               fsl,pins = <
-                       MX8MP_IOMUXC_SAI2_TXC__GPIO4_IO25               0x40000000
-               >;
-       };
-};
configs/imx8mp_dhcom_pdk2_defconfig +4 -2
index f807b0cfc37..d527ca92c83 100644
@@ -12,7 +12,7 @@ CONFIG_ENV_SIZE=0x10000
 CONFIG_ENV_OFFSET=0xFE0000
 CONFIG_ENV_SECT_SIZE=0x1000
 CONFIG_DM_GPIO=y
-CONFIG_DEFAULT_DEVICE_TREE="imx8mp-dhcom-pdk2"
+CONFIG_DEFAULT_DEVICE_TREE="freescale/imx8mp-dhcom-pdk2"
 CONFIG_SPL_TEXT_BASE=0x920000
 CONFIG_TARGET_IMX8MP_DH_DHCOM_PDK2=y
 CONFIG_DM_RESET=y
@@ -48,7 +48,7 @@ CONFIG_USE_BOOTARGS=y
 CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="run dh_update_env distro_bootcmd ; reset"
 CONFIG_USE_PREBOOT=y
-CONFIG_DEFAULT_FDT_FILE="imx8mp-dhcom-pdk2.dtb"
+CONFIG_DEFAULT_FDT_FILE="freescale/imx8mp-dhcom-pdk2.dtb"
 CONFIG_SYS_CBSIZE=2048
 CONFIG_SYS_PBSIZE=2081
 CONFIG_CONSOLE_MUX=y
@@ -144,6 +144,8 @@ CONFIG_MMC_SPEED_MODE_SET=y
 CONFIG_PARTITION_TYPE_GUID=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
+CONFIG_OF_UPSTREAM=y
+CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_NOWHERE=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
configs/imx8mp_dhcom_pdk3_defconfig +4 -3
index 05895d6dd6f..5a41f140bb5 100644
@@ -12,7 +12,7 @@ CONFIG_ENV_SIZE=0x10000
 CONFIG_ENV_OFFSET=0xFE0000
 CONFIG_ENV_SECT_SIZE=0x1000
 CONFIG_DM_GPIO=y
-CONFIG_DEFAULT_DEVICE_TREE="imx8mp-dhcom-pdk3"
+CONFIG_DEFAULT_DEVICE_TREE="freescale/imx8mp-dhcom-pdk3"
 CONFIG_SPL_TEXT_BASE=0x920000
 CONFIG_TARGET_IMX8MP_DH_DHCOM_PDK2=y
 CONFIG_DM_RESET=y
@@ -50,7 +50,7 @@ CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="run dh_update_env distro_bootcmd ; reset"
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="gpio clear GPIO1_11 ; sleep 0.1 ; gpio set GPIO1_11 ; sleep 0.1 ; i2c dev 4 && i2c mw 0x70 0 4 && i2c probe 0x2d && i2c mw 0x2d 0xaa55.2 0"
-CONFIG_DEFAULT_FDT_FILE="imx8mp-dhcom-pdk3.dtb"
+CONFIG_DEFAULT_FDT_FILE="freescale/imx8mp-dhcom-pdk3.dtb"
 CONFIG_SYS_CBSIZE=2048
 CONFIG_SYS_PBSIZE=2081
 CONFIG_CONSOLE_MUX=y
@@ -147,6 +147,8 @@ CONFIG_MMC_SPEED_MODE_SET=y
 CONFIG_PARTITION_TYPE_GUID=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
+CONFIG_OF_UPSTREAM=y
+CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_NOWHERE=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
--

2.45.2

Reviewed-by on v2 1/2
#3 lore raw
In reply to Marek Vasut

Hi Marek,

Quoted 91 lines · Marek Vasut

Currently the enablement of OF_UPSTREAM results on the build system searching for DTs only in dts/upstream/ . There are platforms which use U-Boot specific DTBOs applied on top of U-Boot control DT during SPL stage, and source DTs for these are located in arch/$(ARCH)/dtb.

Add dedicated 'dtbos' target which builds only .dtbos and not .dtbs and in case CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS is enabled, build this target for arch/$(ARCH)/dtb to generate local U-Boot specific DTBOs.

Adjust top level Makefile so binman would search for .dtb and .dtbo in both OF_UPSTREAM specific paths and arch/$(ARCH)/dtb for the .dtbo case in case CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS is enabled.

---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Caleb Connolly <[email protected]>
Cc: Christoph Niedermaier <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Heinrich Schuchardt <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Lothar Rubusch <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: Nobuhiro Iwamatsu <[email protected]>
Cc: Rasmus Villemoes <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Stefano Babic <[email protected]>
Cc: Sumit Garg <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
V2: Gate this functionality behind CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS
---
NOTE: Depends on https://lore.kernel.org/u-boot/[email protected]/

---
 Makefile             |  4 ++++
 dts/Kconfig          | 16 ++++++++++++++++
 dts/Makefile         | 14 +++++++++++++-
 scripts/Makefile.dts |  6 ++++++
 4 files changed, 39 insertions(+), 1 deletion(-)
Makefile +4 -0
index af24de4165e..a5258e8cb3f 100644
@@ -1375,7 +1375,11 @@ of_list := "$(ext_dtb_list)"
 of_list_dirs := $(dir $(EXT_DTB))
 else
 of_list := $(CONFIG_OF_LIST)
+ifneq ($(CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS),)
+of_list_dirs := $(dt_dir) arch/$(ARCH)/dts
+else
 of_list_dirs := $(dt_dir)
+endif
 default_dt := $(if $(DEVICE_TREE),$(DEVICE_TREE),$(CONFIG_DEFAULT_DEVICE_TREE))
 endif
 
dts/Kconfig +16 -0
index 569d4be338e..385058b429f 100644
@@ -125,6 +125,22 @@ config OF_UPSTREAM_VENDOR
        help
          Select the vendor to build all devicetree files for.
 
+config OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS
+       bool "Build local DTBOs as fallback for DTBOs missing upstream"
+       default n
+       depends on OF_UPSTREAM
+       help
+         Enable building DTBOs from arch/$(ARCH)/dts as a fallback for
+         DTBOs which are not part of Linux kernel upstream yet. This is
+         a stopgap measure to expedite OF_UPSTREAM switch for platforms
+         which already have main DT in Linux kernel upstream, but still
+         have leftover DTBOs in U-Boot tree.
+
+         Do not use this option, upstream your DTs and DTBOs instead.
+         If the upstreaming is in progress, use with utmost caution.
+
+         If unsure, say N.
+
 choice
        prompt "Provider of DTB for DT control"
        depends on OF_CONTROL
dts/Makefile +0 -0
index d6c2c9daf31..32c749a043a 100644

dts/Makefile DEVICE_TREE := unset · line 14

Quoted 4 lines
dts/Makefile +1 -0
@@ -11,12 +11,18 @@ DEVICE_TREE := unset
 endif
 
 ifeq ($(CONFIG_OF_UPSTREAM),y)
+ifneq ($(CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS),)

Since CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS already has a dependency on CONFIG_OF_UPSTREAM via Kconfig, can we avoid the nested ifeq sequence here? This will avoid a redundant local_dtbos assignment...

dts/Makefile DEVICE_TREE := unset · line 25

Quoted 11 lines
dts/Makefile +5 -0
+local_dtbos := local-dtbos
+else
+local_dtbos :=
+endif
 ifeq ($(CONFIG_ARM64),y)
 dt_dir := dts/upstream/src/arm64
 else
 dt_dir := dts/upstream/src/$(ARCH)
 endif
 else
+local_dtbos :=

...here.

With that fixed, feel free to add:

-Sumit

Quoted 43 lines
dts/Makefile +7 -1
 dt_dir := arch/$(ARCH)/dts
 endif
 
@@ -40,7 +46,7 @@ endif
 
 targets += dt.dtb
 
-$(DTB): arch-dtbs
+$(DTB): arch-dtbs $(local_dtbos)
        $(Q)test -e $@ || (                                             \
        echo >&2;                                                       \
        echo >&2 "Device Tree Source ($@) is not correctly specified."; \
@@ -53,6 +59,12 @@ PHONY += arch-dtbs
 arch-dtbs:
        $(Q)$(MAKE) $(build)=$(dt_dir) dtbs
 
+ifneq ($(CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS),)
+PHONY += local-dtbos
+local-dtbos:
+       $(Q)$(MAKE) $(build)=arch/$(ARCH)/dts dtbos
+endif
+
 ifeq ($(CONFIG_SPL_BUILD),y)
 obj-$(CONFIG_OF_EMBED) := dt-spl.dtb.o
 # support "out-of-tree" build for dtb-spl
scripts/Makefile.dts +6 -1
index 1fe142f2bbf..3ab67b3c247 100644
@@ -21,4 +21,10 @@ PHONY += dtbs
 dtbs: $(addprefix $(obj)/, $(dtb-y))
        @:
 
+ifneq ($(CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS),)
+PHONY += dtbos
+dtbos: $(addprefix $(obj)/, $(filter-out %.dtb,$(dtb-y)))
+       @:
+endif
+
 clean-files := *.dtb *.dtbo */*.dtb */*.dtbo *_HS
--

2.45.2

Reviewed-by on v2 1/2
#4 lore raw
In reply to Marek Vasut
Quoted 36 lines · Marek Vasut

Currently the enablement of OF_UPSTREAM results on the build system searching for DTs only in dts/upstream/ . There are platforms which use U-Boot specific DTBOs applied on top of U-Boot control DT during SPL stage, and source DTs for these are located in arch/$(ARCH)/dtb.

Add dedicated 'dtbos' target which builds only .dtbos and not .dtbs and in case CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS is enabled, build this target for arch/$(ARCH)/dtb to generate local U-Boot specific DTBOs.

Adjust top level Makefile so binman would search for .dtb and .dtbo in both OF_UPSTREAM specific paths and arch/$(ARCH)/dtb for the .dtbo case in case CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS is enabled.

---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Caleb Connolly <[email protected]>
Cc: Christoph Niedermaier <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Heinrich Schuchardt <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Lothar Rubusch <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: Nobuhiro Iwamatsu <[email protected]>
Cc: Rasmus Villemoes <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Stefano Babic <[email protected]>
Cc: Sumit Garg <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
V2: Gate this functionality behind CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS
---
NOTE: Depends on https://lore.kernel.org/u-boot/[email protected]/

Quoted 6 lines
---
 Makefile             |  4 ++++
 dts/Kconfig          | 16 ++++++++++++++++
 dts/Makefile         | 14 +++++++++++++-
 scripts/Makefile.dts |  6 ++++++
 4 files changed, 39 insertions(+), 1 deletion(-)

Congratulations, you win the prize for the longest CONFIG name!