diff mbox series

[OpenWrt-Devel,2/2] sunxi: construct DTS name from device node name and SOC

Message ID 20191207222826.47389-3-freifunk@adrianschmutzler.de
State Accepted
Delegated to: Adrian Schmutzler
Headers show
Series Reduce redundant names in sunxi target | expand

Commit Message

Adrian Schmutzler Dec. 7, 2019, 10:28 p.m. UTC
The device part in the SUNXI_DTS variable always corresponds to
device node name. This is another redundancy that can be removed
by calculating the DTS name from a newly introduced SUNXI_SOC
variable and the node name.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
---
 target/linux/sunxi/image/Makefile      |  5 ++-
 target/linux/sunxi/image/cortex-a53.mk | 18 +++++++----
 target/linux/sunxi/image/cortex-a7.mk  | 44 +++++++++++++-------------
 target/linux/sunxi/image/cortex-a8.mk  | 13 ++++----
 4 files changed, 45 insertions(+), 35 deletions(-)

Comments

Adrian Schmutzler Dec. 7, 2019, 10:36 p.m. UTC | #1
> -  SUNXI_DTS:=sun7i-a20-olinuxino-micro
> +  SUNXI_SOC := =sun7i

The extra "=" has already been removed during my build tests (just forgot to commit it). If someone tests on this device, please remove it manually.

Adrian
Tomasz Maciej Nowak Dec. 10, 2019, 1:38 p.m. UTC | #2
Hi Adrian.

W dniu 07.12.2019 o 23:28, Adrian Schmutzler pisze:
> The device part in the SUNXI_DTS variable always corresponds to
> device node name. This is another redundancy that can be removed
> by calculating the DTS name from a newly introduced SUNXI_SOC
> variable and the node name.
> 
> Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> ---
>  target/linux/sunxi/image/Makefile      |  5 ++-
>  target/linux/sunxi/image/cortex-a53.mk | 18 +++++++----
>  target/linux/sunxi/image/cortex-a7.mk  | 44 +++++++++++++-------------
>  target/linux/sunxi/image/cortex-a8.mk  | 13 ++++----
>  4 files changed, 45 insertions(+), 35 deletions(-)
> 
> diff --git a/target/linux/sunxi/image/Makefile b/target/linux/sunxi/image/Makefile
> index 04e0abee49..929f4c70f9 100644
> --- a/target/linux/sunxi/image/Makefile
> +++ b/target/linux/sunxi/image/Makefile
> @@ -32,12 +32,15 @@ endef
>  # why \x00\x00\x00\x00 for zImage-initramfs
>  define Device/Default
>    PROFILES := Default
> -  DEVICE_VARS := SUNXI_DTS SUNXI_UBOOT
> +  DEVICE_VARS := SUNXI_SOC SUNXI_DTS SUNXI_DTS_DIR SUNXI_UBOOT

Instead of adding new target speciffic variables, wouldn't using already
specified ones be better? We have DEVICE_DTS and DEVICE_DTS_DIR. Also the
SUNXI_SOC feels bit redundant since it needs to be specified for each device
and it could be replaced with DEVICE_DTS := sun50i-h5-$(1) or simply full dts name.

>    KERNEL_NAME := zImage
>    KERNEL := kernel-bin | uImage none
>    IMAGES := sdcard.img.gz
>    IMAGE/sdcard.img.gz := sunxi-sdcard | append-metadata | gzip
>    SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
> +  SUNXI_SOC :=
> +  SUNXI_DTS_DIR :=
> +  SUNXI_DTS = $$(SUNXI_DTS_DIR)$$(SUNXI_SOC)-$(lastword $(subst _, ,$(1)))
>  endef
>  
>  include cortex-a7.mk
> diff --git a/target/linux/sunxi/image/cortex-a53.mk b/target/linux/sunxi/image/cortex-a53.mk
> index d6c17d95ff..b0d087b9b1 100644
> --- a/target/linux/sunxi/image/cortex-a53.mk
> +++ b/target/linux/sunxi/image/cortex-a53.mk
> @@ -11,7 +11,8 @@ define Device/friendlyarm_nanopi-neo-plus2
>    DEVICE_VENDOR := FriendlyARM
>    DEVICE_MODEL := NanoPi NEO Plus2
>    SUPPORTED_DEVICES:=nanopi-neo-plus2
> -  SUNXI_DTS:=allwinner/sun50i-h5-nanopi-neo-plus2
> +  SUNXI_DTS_DIR := allwinner/
> +  SUNXI_SOC := sun50i-h5
>    KERNEL_NAME := Image
>    KERNEL := kernel-bin
>  endef
> @@ -22,7 +23,8 @@ define Device/friendlyarm_nanopi-neo2
>    DEVICE_VENDOR := FriendlyARM
>    DEVICE_MODEL := NanoPi NEO2
>    SUPPORTED_DEVICES:=nanopi-neo2
> -  SUNXI_DTS:=allwinner/sun50i-h5-nanopi-neo2
> +  SUNXI_DTS_DIR := allwinner/
> +  SUNXI_SOC := sun50i-h5
>    KERNEL_NAME := Image
>    KERNEL := kernel-bin
>  endef
> @@ -32,7 +34,8 @@ TARGET_DEVICES += friendlyarm_nanopi-neo2
>  define Device/pine64_pine64-plus
>    DEVICE_VENDOR := Pine64
>    DEVICE_MODEL := Pine64+
> -  SUNXI_DTS:=allwinner/sun50i-a64-pine64-plus
> +  SUNXI_DTS_DIR := allwinner/
> +  SUNXI_SOC := sun50i-a64
>    KERNEL_NAME := Image
>    KERNEL := kernel-bin
>  endef
> @@ -42,7 +45,8 @@ TARGET_DEVICES += pine64_pine64-plus
>  define Device/pine64_sopine-baseboard
>    DEVICE_VENDOR := Pine64
>    DEVICE_MODEL := SoPine
> -  SUNXI_DTS:=allwinner/sun50i-a64-sopine-baseboard
> +  SUNXI_DTS_DIR := allwinner/
> +  SUNXI_SOC := sun50i-a64
>    KERNEL_NAME := Image
>    KERNEL := kernel-bin
>  endef
> @@ -53,7 +57,8 @@ TARGET_DEVICES += pine64_sopine-baseboard
>  define Device/xunlong_orangepi-zero-plus
>    DEVICE_VENDOR := Xunlong
>    DEVICE_MODEL := Orange Pi Zero Plus
> -  SUNXI_DTS:=allwinner/sun50i-h5-orangepi-zero-plus
> +  SUNXI_DTS_DIR := allwinner/
> +  SUNXI_SOC := sun50i-h5
>    KERNEL_NAME := Image
>    KERNEL := kernel-bin
>  endef
> @@ -63,7 +68,8 @@ TARGET_DEVICES += xunlong_orangepi-zero-plus
>  define Device/xunlong_orangepi-pc2
>    DEVICE_VENDOR := Xunlong
>    DEVICE_MODEL := Orange Pi PC 2
> -  SUNXI_DTS:=allwinner/sun50i-h5-orangepi-pc2
> +  SUNXI_DTS_DIR := allwinner/
> +  SUNXI_SOC := sun50i-h5
>    KERNEL_NAME := Image
>    KERNEL := kernel-bin
>  endef
> diff --git a/target/linux/sunxi/image/cortex-a7.mk b/target/linux/sunxi/image/cortex-a7.mk
> index 32e094efb8..0465c2ba9a 100644
> --- a/target/linux/sunxi/image/cortex-a7.mk
> +++ b/target/linux/sunxi/image/cortex-a7.mk
> @@ -12,7 +12,7 @@ define Device/olimex_a20-olinuxino-lime
>    DEVICE_VENDOR := Olimex
>    DEVICE_MODEL := A20-OLinuXino-LIME
>    DEVICE_PACKAGES:=kmod-ata-core kmod-ata-sunxi kmod-rtc-sunxi
> -  SUNXI_DTS:=sun7i-a20-olinuxino-lime
> +  SUNXI_SOC := sun7i
>  endef
>  
>  TARGET_DEVICES += olimex_a20-olinuxino-lime
> @@ -22,7 +22,7 @@ define Device/olimex_a20-olinuxino-lime2
>    DEVICE_VENDOR := Olimex
>    DEVICE_MODEL := A20-OLinuXino-LIME2
>    DEVICE_PACKAGES:=kmod-ata-core kmod-ata-sunxi kmod-rtc-sunxi kmod-usb-hid
> -  SUNXI_DTS:=sun7i-a20-olinuxino-lime2
> +  SUNXI_SOC := sun7i
>  endef
>  
>  TARGET_DEVICES += olimex_a20-olinuxino-lime2
> @@ -33,7 +33,7 @@ define Device/olimex_a20-olinuxino-lime2-emmc
>    DEVICE_MODEL := A20-OLinuXino-LIME2
>    DEVICE_VARIANT := eMMC
>    DEVICE_PACKAGES:=kmod-ata-core kmod-ata-sunxi kmod-rtc-sunxi kmod-usb-hid
> -  SUNXI_DTS:=sun7i-a20-olinuxino-lime2-emmc
> +  SUNXI_SOC := sun7i
>  endef
>  
>  TARGET_DEVICES += olimex_a20-olinuxino-lime2-emmc
> @@ -43,7 +43,7 @@ define Device/olimex_a20-olinuxino-micro
>    DEVICE_VENDOR := Olimex
>    DEVICE_MODEL := A20-OLinuXino-MICRO
>    DEVICE_PACKAGES:=kmod-ata-core kmod-ata-sunxi kmod-sun4i-emac kmod-rtc-sunxi
> -  SUNXI_DTS:=sun7i-a20-olinuxino-micro
> +  SUNXI_SOC := =sun7i
>  endef
>  
>  TARGET_DEVICES += olimex_a20-olinuxino-micro
> @@ -53,7 +53,7 @@ define Device/lemaker_bananapi
>    DEVICE_VENDOR := LeMaker
>    DEVICE_MODEL := Banana Pi
>    DEVICE_PACKAGES:=kmod-rtc-sunxi kmod-ata-core kmod-ata-sunxi
> -  SUNXI_DTS:=sun7i-a20-bananapi
> +  SUNXI_SOC := sun7i-a20
>  endef
>  
>  TARGET_DEVICES += lemaker_bananapi
> @@ -63,7 +63,7 @@ define Device/lemaker_bananapro
>    DEVICE_VENDOR := LeMaker
>    DEVICE_MODEL := Banana Pro
>    DEVICE_PACKAGES:=kmod-rtc-sunxi kmod-ata-core kmod-ata-sunxi kmod-brcmfmac
> -  SUNXI_DTS:=sun7i-a20-bananapro
> +  SUNXI_SOC := sun7i-a20
>  endef
>  
>  TARGET_DEVICES += lemaker_bananapro
> @@ -73,7 +73,7 @@ define Device/cubietech_cubieboard2
>    DEVICE_VENDOR := Cubietech
>    DEVICE_MODEL := Cubieboard2
>    DEVICE_PACKAGES:=kmod-ata-core kmod-ata-sunxi kmod-sun4i-emac kmod-rtc-sunxi
> -  SUNXI_DTS:=sun7i-a20-cubieboard2
> +  SUNXI_SOC := sun7i-a20
>  endef
>  
>  TARGET_DEVICES += cubietech_cubieboard2
> @@ -83,7 +83,7 @@ define Device/cubietech_cubietruck
>    DEVICE_VENDOR := Cubietech
>    DEVICE_MODEL := Cubietruck
>    DEVICE_PACKAGES:=kmod-ata-core kmod-ata-sunxi kmod-rtc-sunxi kmod-brcmfmac
> -  SUNXI_DTS:=sun7i-a20-cubietruck
> +  SUNXI_SOC := sun7i-a20
>  endef
>  
>  TARGET_DEVICES += cubietech_cubietruck
> @@ -93,7 +93,7 @@ define Device/lamobo_lamobo-r1
>    DEVICE_VENDOR := Lamobo
>    DEVICE_MODEL := Lamobo R1
>    DEVICE_PACKAGES:=kmod-ata-sunxi kmod-rtl8192cu swconfig wpad-basic
> -  SUNXI_DTS:=sun7i-a20-lamobo-r1
> +  SUNXI_SOC := sun7i-a20
>  endef
>  
>  TARGET_DEVICES += lamobo_lamobo-r1
> @@ -103,7 +103,7 @@ define Device/mele_m9
>    DEVICE_VENDOR := Mele
>    DEVICE_MODEL := M9
>    DEVICE_PACKAGES:=kmod-sun4i-emac kmod-rtc-sunxi kmod-rtl8192cu
> -  SUNXI_DTS:=sun6i-a31-m9
> +  SUNXI_SOC := sun6i-a31
>  endef
>  
>  TARGET_DEVICES += mele_m9
> @@ -113,7 +113,7 @@ define Device/xunlong_orangepi-zero
>    DEVICE_VENDOR := Xunlong
>    DEVICE_MODEL := Orange Pi Zero
>    DEVICE_PACKAGES:=kmod-rtc-sunxi
> -  SUNXI_DTS:=sun8i-h2-plus-orangepi-zero
> +  SUNXI_SOC := sun8i-h2-plus
>  endef
>  
>  TARGET_DEVICES += xunlong_orangepi-zero
> @@ -123,7 +123,7 @@ define Device/xunlong_orangepi-r1
>    DEVICE_VENDOR := Xunlong
>    DEVICE_MODEL := Orange Pi R1
>    DEVICE_PACKAGES:=kmod-rtc-sunxi kmod-usb-net kmod-usb-net-rtl8152
> -  SUNXI_DTS:=sun8i-h2-plus-orangepi-r1
> +  SUNXI_SOC := sun8i-h2-plus
>  endef
>  
>  TARGET_DEVICES += xunlong_orangepi-r1
> @@ -134,7 +134,7 @@ define Device/sinovoip_bananapi-m2-plus
>    DEVICE_PACKAGES:=kmod-rtc-sunxi \
>  	kmod-leds-gpio kmod-ledtrig-heartbeat \
>  	kmod-brcmfmac brcmfmac-firmware-43430a0-sdio wpad-basic
> -  SUNXI_DTS:=sun8i-h3-bananapi-m2-plus
> +  SUNXI_SOC := sun8i-h3
>  endef
>  
>  TARGET_DEVICES += sinovoip_bananapi-m2-plus
> @@ -145,7 +145,7 @@ define Device/friendlyarm_nanopi-m1-plus
>    DEVICE_PACKAGES:=kmod-rtc-sunxi \
>  	kmod-leds-gpio kmod-ledtrig-heartbeat \
>  	kmod-brcmfmac brcmfmac-firmware-43430-sdio wpad-basic
> -  SUNXI_DTS:=sun8i-h3-nanopi-m1-plus
> +  SUNXI_SOC := sun8i-h3
>  endef
>  
>  TARGET_DEVICES += friendlyarm_nanopi-m1-plus
> @@ -154,7 +154,7 @@ TARGET_DEVICES += friendlyarm_nanopi-m1-plus
>  define Device/friendlyarm_nanopi-neo
>    DEVICE_VENDOR := FriendlyARM
>    DEVICE_MODEL := NanoPi NEO
> -  SUNXI_DTS:=sun8i-h3-nanopi-neo
> +  SUNXI_SOC := sun8i-h3
>  endef
>  
>  TARGET_DEVICES += friendlyarm_nanopi-neo
> @@ -164,7 +164,7 @@ define Device/xunlong_orangepi-one
>    DEVICE_VENDOR := Xunlong
>    DEVICE_MODEL := Orange Pi One
>    DEVICE_PACKAGES:=kmod-rtc-sunxi
> -  SUNXI_DTS:=sun8i-h3-orangepi-one
> +  SUNXI_SOC := sun8i-h3
>  endef
>  
>  TARGET_DEVICES += xunlong_orangepi-one
> @@ -174,7 +174,7 @@ define Device/xunlong_orangepi-pc
>    DEVICE_VENDOR := Xunlong
>    DEVICE_MODEL := Orange Pi PC
>    DEVICE_PACKAGES:=kmod-rtc-sunxi kmod-gpio-button-hotplug
> -  SUNXI_DTS:=sun8i-h3-orangepi-pc
> +  SUNXI_SOC := sun8i-h3
>  endef
>  
>  TARGET_DEVICES += xunlong_orangepi-pc
> @@ -184,7 +184,7 @@ define Device/xunlong_orangepi-pc-plus
>    DEVICE_VENDOR := Xunlong
>    DEVICE_MODEL := Orange Pi PC Plus
>    DEVICE_PACKAGES:=kmod-rtc-sunxi kmod-gpio-button-hotplug
> -  SUNXI_DTS:=sun8i-h3-orangepi-pc-plus
> +  SUNXI_SOC := sun8i-h3
>  endef
>  
>  TARGET_DEVICES += xunlong_orangepi-pc-plus
> @@ -194,7 +194,7 @@ define Device/xunlong_orangepi-plus
>    DEVICE_VENDOR := Xunlong
>    DEVICE_MODEL := Orange Pi Plus
>    DEVICE_PACKAGES:=kmod-rtc-sunxi
> -  SUNXI_DTS:=sun8i-h3-orangepi-plus
> +  SUNXI_SOC := sun8i-h3
>  endef
>  
>  TARGET_DEVICES += xunlong_orangepi-plus
> @@ -203,7 +203,7 @@ define Device/xunlong_orangepi-2
>    DEVICE_VENDOR := Xunlong
>    DEVICE_MODEL := Orange Pi 2
>    DEVICE_PACKAGES:=kmod-rtc-sunxi
> -  SUNXI_DTS:=sun8i-h3-orangepi-2
> +  SUNXI_SOC := sun8i-h3
>  endef
>  
>  TARGET_DEVICES += xunlong_orangepi-2
> @@ -213,7 +213,7 @@ define Device/linksprite_pcduino3
>    DEVICE_VENDOR := LinkSprite
>    DEVICE_MODEL := pcDuino3
>    DEVICE_PACKAGES:=kmod-sun4i-emac kmod-rtc-sunxi kmod-ata-core kmod-ata-sunxi kmod-rtl8xxxu rtl8188eu-firmware
> -  SUNXI_DTS:=sun7i-a20-pcduino3
> +  SUNXI_SOC := sun7i-a20
>  endef
>  
>  TARGET_DEVICES += linksprite_pcduino3
> @@ -222,7 +222,7 @@ define Device/lemaker_bananapi-m2-ultra
>    DEVICE_VENDOR := LeMaker
>    DEVICE_MODEL := Banana Pi M2 Ultra
>    DEVICE_PACKAGES:=kmod-rtc-sunxi kmod-ata-core kmod-ata-sunxi
> -  SUNXI_DTS:=sun8i-r40-bananapi-m2-ultra
> +  SUNXI_SOC := sun8i-r40
>  endef
>  
>  TARGET_DEVICES += lemaker_bananapi-m2-ultra
> diff --git a/target/linux/sunxi/image/cortex-a8.mk b/target/linux/sunxi/image/cortex-a8.mk
> index 073ed8f2d1..d6b5a46a22 100644
> --- a/target/linux/sunxi/image/cortex-a8.mk
> +++ b/target/linux/sunxi/image/cortex-a8.mk
> @@ -11,7 +11,7 @@ define Device/olimex_a10-olinuxino-lime
>    DEVICE_VENDOR := Olimex
>    DEVICE_MODEL := A10-OLinuXino-LIME
>    DEVICE_PACKAGES:=kmod-ata-core kmod-ata-sunxi kmod-sun4i-emac kmod-rtc-sunxi
> -  SUNXI_DTS:=sun4i-a10-olinuxino-lime
> +  SUNXI_SOC := sun4i
>  endef
>  
>  TARGET_DEVICES += olimex_a10-olinuxino-lime
> @@ -22,7 +22,8 @@ define Device/olimex_a13-olimex-som
>    DEVICE_MODEL := A13-SOM
>    DEVICE_PACKAGES:=kmod-rtl8192cu
>    SUPPORTED_DEVICES:=olimex,a13-olinuxino
> -  SUNXI_DTS:=sun5i-a13-olinuxino
> +  SUNXI_SOC := sun5i-a13
> +  SUNXI_DTS := sun5i-a13-olinuxino
>  endef
>  
>  TARGET_DEVICES += olimex_a13-olimex-som
> @@ -32,7 +33,7 @@ define Device/olimex_a13-olinuxino
>    DEVICE_VENDOR := Olimex
>    DEVICE_MODEL := A13-OLinuXino
>    DEVICE_PACKAGES:=kmod-rtl8192cu
> -  SUNXI_DTS:=sun5i-a13-olinuxino
> +  SUNXI_SOC := sun5i
>  endef
>  
>  TARGET_DEVICES += olimex_a13-olinuxino
> @@ -42,7 +43,7 @@ define Device/cubietech_a10-cubieboard
>    DEVICE_VENDOR := Cubietech
>    DEVICE_MODEL := Cubieboard
>    DEVICE_PACKAGES:=kmod-ata-core kmod-ata-sunxi kmod-sun4i-emac kmod-rtc-sunxi
> -  SUNXI_DTS:=sun4i-a10-cubieboard
> +  SUNXI_SOC := sun4i
>  endef
>  
>  TARGET_DEVICES += cubietech_a10-cubieboard
> @@ -52,7 +53,7 @@ define Device/linksprite_a10-pcduino
>    DEVICE_VENDOR := LinkSprite
>    DEVICE_MODEL := pcDuino
>    DEVICE_PACKAGES:=kmod-sun4i-emac kmod-rtc-sunxi kmod-rtl8192cu
> -  SUNXI_DTS:=sun4i-a10-pcduino
> +  SUNXI_SOC := sun4i
>  endef
>  
>  TARGET_DEVICES += linksprite_a10-pcduino
> @@ -62,7 +63,7 @@ define Device/marsboard_a10-marsboard
>    DEVICE_VENDOR := HAOYU Electronics
>    DEVICE_MODEL := MarsBoard A10
>    DEVICE_PACKAGES:=mod-ata-core kmod-ata-sunxi kmod-sun4i-emac kmod-rtc-sunxi sound-soc-sunxi
> -  SUNXI_DTS:=sun4i-a10-marsboard
> +  SUNXI_SOC := sun4i
>  endef
>  
>  TARGET_DEVICES += marsboard_a10-marsboard
> 

Regards
Adrian Schmutzler Dec. 11, 2019, 10:42 a.m. UTC | #3
Hi,

> -----Original Message-----
> From: Tomasz Maciej Nowak [mailto:tomek_n@o2.pl]
> Sent: Dienstag, 10. Dezember 2019 14:39
> To: Adrian Schmutzler <freifunk@adrianschmutzler.de>; openwrt-
> devel@lists.openwrt.org
> Subject: Re: [OpenWrt-Devel] [PATCH 2/2] sunxi: construct DTS name from
> device node name and SOC
> 
> Hi Adrian.
> 
> W dniu 07.12.2019 o 23:28, Adrian Schmutzler pisze:
> > The device part in the SUNXI_DTS variable always corresponds to
> > device node name. This is another redundancy that can be removed
> > by calculating the DTS name from a newly introduced SUNXI_SOC
> > variable and the node name.
> >
> > Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> > ---
> >  target/linux/sunxi/image/Makefile      |  5 ++-
> >  target/linux/sunxi/image/cortex-a53.mk | 18 +++++++----
> >  target/linux/sunxi/image/cortex-a7.mk  | 44 +++++++++++++-------------
> >  target/linux/sunxi/image/cortex-a8.mk  | 13 ++++----
> >  4 files changed, 45 insertions(+), 35 deletions(-)
> >
> > diff --git a/target/linux/sunxi/image/Makefile
> b/target/linux/sunxi/image/Makefile
> > index 04e0abee49..929f4c70f9 100644
> > --- a/target/linux/sunxi/image/Makefile
> > +++ b/target/linux/sunxi/image/Makefile
> > @@ -32,12 +32,15 @@ endef
> >  # why \x00\x00\x00\x00 for zImage-initramfs
> >  define Device/Default
> >    PROFILES := Default
> > -  DEVICE_VARS := SUNXI_DTS SUNXI_UBOOT
> > +  DEVICE_VARS := SUNXI_SOC SUNXI_DTS SUNXI_DTS_DIR SUNXI_UBOOT
> 
> Instead of adding new target speciffic variables, wouldn't using already
> specified ones be better? We have DEVICE_DTS and DEVICE_DTS_DIR. Also the

Based on
https://github.com/openwrt/openwrt/commit/7a8d3432c739c6ff038295176e8b6324e92fc116
I had the impression that DEVICE_DTS and DEVICE_DTS_DIR are reserved keywords for a particular mechanism to append DTB.

Thus, and since the target has been using "custom" SUNXI_DTS variable so far, I decided to stick to that pattern.

> SUNXI_SOC feels bit redundant since it needs to be specified for each device
> and it could be replaced with DEVICE_DTS := sun50i-h5-$(1) or simply full dts
> name.

No, because I need to cut down the device name, so it would be
DEVICE_DTS := sun50i-h5-$(lastword $(subst _, ,$(1)))
which I would not like to repeat over and over.

I admit that changing the DTS variable is the weakest part in my patchset. However, I think introducing the SUNXI_SOC and SUNXI_DTS_DIR will make the target more organized. Despite, by this it becomes more consistent with other targets where this has been reorganized recently (i.e. ath79 and ramips, where we use ATH_SOC and MTK_SOC to do the very same).
At least I personally think that this is better that repeating the very same name again in the DTS definition.

Best

Adrian
Tomasz Maciej Nowak Dec. 13, 2019, 1:16 p.m. UTC | #4
W dniu 11.12.2019 o 11:42, Adrian Schmutzler pisze:
> Hi,
> 
>> -----Original Message-----
>> From: Tomasz Maciej Nowak [mailto:tomek_n@o2.pl]
>> Sent: Dienstag, 10. Dezember 2019 14:39
>> To: Adrian Schmutzler <freifunk@adrianschmutzler.de>; openwrt-
>> devel@lists.openwrt.org
>> Subject: Re: [OpenWrt-Devel] [PATCH 2/2] sunxi: construct DTS name from
>> device node name and SOC
>>
>> Hi Adrian.
>>
>> W dniu 07.12.2019 o 23:28, Adrian Schmutzler pisze:
>>> The device part in the SUNXI_DTS variable always corresponds to
>>> device node name. This is another redundancy that can be removed
>>> by calculating the DTS name from a newly introduced SUNXI_SOC
>>> variable and the node name.
>>>
>>> Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
>>> ---
>>>  target/linux/sunxi/image/Makefile      |  5 ++-
>>>  target/linux/sunxi/image/cortex-a53.mk | 18 +++++++----
>>>  target/linux/sunxi/image/cortex-a7.mk  | 44 +++++++++++++-------------
>>>  target/linux/sunxi/image/cortex-a8.mk  | 13 ++++----
>>>  4 files changed, 45 insertions(+), 35 deletions(-)
>>>
>>> diff --git a/target/linux/sunxi/image/Makefile
>> b/target/linux/sunxi/image/Makefile
>>> index 04e0abee49..929f4c70f9 100644
>>> --- a/target/linux/sunxi/image/Makefile
>>> +++ b/target/linux/sunxi/image/Makefile
>>> @@ -32,12 +32,15 @@ endef
>>>  # why \x00\x00\x00\x00 for zImage-initramfs
>>>  define Device/Default
>>>    PROFILES := Default
>>> -  DEVICE_VARS := SUNXI_DTS SUNXI_UBOOT
>>> +  DEVICE_VARS := SUNXI_SOC SUNXI_DTS SUNXI_DTS_DIR SUNXI_UBOOT
>>
>> Instead of adding new target speciffic variables, wouldn't using already
>> specified ones be better? We have DEVICE_DTS and DEVICE_DTS_DIR. Also the
> 
> Based on
> https://github.com/openwrt/openwrt/commit/7a8d3432c739c6ff038295176e8b6324e92fc116
> I had the impression that DEVICE_DTS and DEVICE_DTS_DIR are reserved keywords for a particular mechanism to append DTB.

These are not reserved at all. Other targets use it.

> 
> Thus, and since the target has been using "custom" SUNXI_DTS variable so far, I decided to stick to that pattern.

Looking at git history that variable precedes DEVICE_DTS, so I assume there was
no one bothered to convert it when global one was introduced. Now is best time
to do that.

> 
>> SUNXI_SOC feels bit redundant since it needs to be specified for each device
>> and it could be replaced with DEVICE_DTS := sun50i-h5-$(1) or simply full dts
>> name.
> 
> No, because I need to cut down the device name, so it would be
> DEVICE_DTS := sun50i-h5-$(lastword $(subst _, ,$(1)))
> which I would not like to repeat over and over.

Yeah, forgot about replacing separator with dash.

> 
> I admit that changing the DTS variable is the weakest part in my patchset. However, I think introducing the SUNXI_SOC and SUNXI_DTS_DIR will make the target more organized. Despite, by this it becomes more consistent with other targets where this has been reorganized recently (i.e. ath79 and ramips, where we use ATH_SOC and MTK_SOC to do the very same).
> At least I personally think that this is better that repeating the very same name again in the DTS definition.

Well, I've no strong feelings against using SUNXI_SOC, it's reasonable given
Your explanation, but SUNXI_DTS_DIR should be changed to global one.

> 
> Best
> 
> Adrian
> 

Regards
diff mbox series

Patch

diff --git a/target/linux/sunxi/image/Makefile b/target/linux/sunxi/image/Makefile
index 04e0abee49..929f4c70f9 100644
--- a/target/linux/sunxi/image/Makefile
+++ b/target/linux/sunxi/image/Makefile
@@ -32,12 +32,15 @@  endef
 # why \x00\x00\x00\x00 for zImage-initramfs
 define Device/Default
   PROFILES := Default
-  DEVICE_VARS := SUNXI_DTS SUNXI_UBOOT
+  DEVICE_VARS := SUNXI_SOC SUNXI_DTS SUNXI_DTS_DIR SUNXI_UBOOT
   KERNEL_NAME := zImage
   KERNEL := kernel-bin | uImage none
   IMAGES := sdcard.img.gz
   IMAGE/sdcard.img.gz := sunxi-sdcard | append-metadata | gzip
   SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
+  SUNXI_SOC :=
+  SUNXI_DTS_DIR :=
+  SUNXI_DTS = $$(SUNXI_DTS_DIR)$$(SUNXI_SOC)-$(lastword $(subst _, ,$(1)))
 endef
 
 include cortex-a7.mk
diff --git a/target/linux/sunxi/image/cortex-a53.mk b/target/linux/sunxi/image/cortex-a53.mk
index d6c17d95ff..b0d087b9b1 100644
--- a/target/linux/sunxi/image/cortex-a53.mk
+++ b/target/linux/sunxi/image/cortex-a53.mk
@@ -11,7 +11,8 @@  define Device/friendlyarm_nanopi-neo-plus2
   DEVICE_VENDOR := FriendlyARM
   DEVICE_MODEL := NanoPi NEO Plus2
   SUPPORTED_DEVICES:=nanopi-neo-plus2
-  SUNXI_DTS:=allwinner/sun50i-h5-nanopi-neo-plus2
+  SUNXI_DTS_DIR := allwinner/
+  SUNXI_SOC := sun50i-h5
   KERNEL_NAME := Image
   KERNEL := kernel-bin
 endef
@@ -22,7 +23,8 @@  define Device/friendlyarm_nanopi-neo2
   DEVICE_VENDOR := FriendlyARM
   DEVICE_MODEL := NanoPi NEO2
   SUPPORTED_DEVICES:=nanopi-neo2
-  SUNXI_DTS:=allwinner/sun50i-h5-nanopi-neo2
+  SUNXI_DTS_DIR := allwinner/
+  SUNXI_SOC := sun50i-h5
   KERNEL_NAME := Image
   KERNEL := kernel-bin
 endef
@@ -32,7 +34,8 @@  TARGET_DEVICES += friendlyarm_nanopi-neo2
 define Device/pine64_pine64-plus
   DEVICE_VENDOR := Pine64
   DEVICE_MODEL := Pine64+
-  SUNXI_DTS:=allwinner/sun50i-a64-pine64-plus
+  SUNXI_DTS_DIR := allwinner/
+  SUNXI_SOC := sun50i-a64
   KERNEL_NAME := Image
   KERNEL := kernel-bin
 endef
@@ -42,7 +45,8 @@  TARGET_DEVICES += pine64_pine64-plus
 define Device/pine64_sopine-baseboard
   DEVICE_VENDOR := Pine64
   DEVICE_MODEL := SoPine
-  SUNXI_DTS:=allwinner/sun50i-a64-sopine-baseboard
+  SUNXI_DTS_DIR := allwinner/
+  SUNXI_SOC := sun50i-a64
   KERNEL_NAME := Image
   KERNEL := kernel-bin
 endef
@@ -53,7 +57,8 @@  TARGET_DEVICES += pine64_sopine-baseboard
 define Device/xunlong_orangepi-zero-plus
   DEVICE_VENDOR := Xunlong
   DEVICE_MODEL := Orange Pi Zero Plus
-  SUNXI_DTS:=allwinner/sun50i-h5-orangepi-zero-plus
+  SUNXI_DTS_DIR := allwinner/
+  SUNXI_SOC := sun50i-h5
   KERNEL_NAME := Image
   KERNEL := kernel-bin
 endef
@@ -63,7 +68,8 @@  TARGET_DEVICES += xunlong_orangepi-zero-plus
 define Device/xunlong_orangepi-pc2
   DEVICE_VENDOR := Xunlong
   DEVICE_MODEL := Orange Pi PC 2
-  SUNXI_DTS:=allwinner/sun50i-h5-orangepi-pc2
+  SUNXI_DTS_DIR := allwinner/
+  SUNXI_SOC := sun50i-h5
   KERNEL_NAME := Image
   KERNEL := kernel-bin
 endef
diff --git a/target/linux/sunxi/image/cortex-a7.mk b/target/linux/sunxi/image/cortex-a7.mk
index 32e094efb8..0465c2ba9a 100644
--- a/target/linux/sunxi/image/cortex-a7.mk
+++ b/target/linux/sunxi/image/cortex-a7.mk
@@ -12,7 +12,7 @@  define Device/olimex_a20-olinuxino-lime
   DEVICE_VENDOR := Olimex
   DEVICE_MODEL := A20-OLinuXino-LIME
   DEVICE_PACKAGES:=kmod-ata-core kmod-ata-sunxi kmod-rtc-sunxi
-  SUNXI_DTS:=sun7i-a20-olinuxino-lime
+  SUNXI_SOC := sun7i
 endef
 
 TARGET_DEVICES += olimex_a20-olinuxino-lime
@@ -22,7 +22,7 @@  define Device/olimex_a20-olinuxino-lime2
   DEVICE_VENDOR := Olimex
   DEVICE_MODEL := A20-OLinuXino-LIME2
   DEVICE_PACKAGES:=kmod-ata-core kmod-ata-sunxi kmod-rtc-sunxi kmod-usb-hid
-  SUNXI_DTS:=sun7i-a20-olinuxino-lime2
+  SUNXI_SOC := sun7i
 endef
 
 TARGET_DEVICES += olimex_a20-olinuxino-lime2
@@ -33,7 +33,7 @@  define Device/olimex_a20-olinuxino-lime2-emmc
   DEVICE_MODEL := A20-OLinuXino-LIME2
   DEVICE_VARIANT := eMMC
   DEVICE_PACKAGES:=kmod-ata-core kmod-ata-sunxi kmod-rtc-sunxi kmod-usb-hid
-  SUNXI_DTS:=sun7i-a20-olinuxino-lime2-emmc
+  SUNXI_SOC := sun7i
 endef
 
 TARGET_DEVICES += olimex_a20-olinuxino-lime2-emmc
@@ -43,7 +43,7 @@  define Device/olimex_a20-olinuxino-micro
   DEVICE_VENDOR := Olimex
   DEVICE_MODEL := A20-OLinuXino-MICRO
   DEVICE_PACKAGES:=kmod-ata-core kmod-ata-sunxi kmod-sun4i-emac kmod-rtc-sunxi
-  SUNXI_DTS:=sun7i-a20-olinuxino-micro
+  SUNXI_SOC := =sun7i
 endef
 
 TARGET_DEVICES += olimex_a20-olinuxino-micro
@@ -53,7 +53,7 @@  define Device/lemaker_bananapi
   DEVICE_VENDOR := LeMaker
   DEVICE_MODEL := Banana Pi
   DEVICE_PACKAGES:=kmod-rtc-sunxi kmod-ata-core kmod-ata-sunxi
-  SUNXI_DTS:=sun7i-a20-bananapi
+  SUNXI_SOC := sun7i-a20
 endef
 
 TARGET_DEVICES += lemaker_bananapi
@@ -63,7 +63,7 @@  define Device/lemaker_bananapro
   DEVICE_VENDOR := LeMaker
   DEVICE_MODEL := Banana Pro
   DEVICE_PACKAGES:=kmod-rtc-sunxi kmod-ata-core kmod-ata-sunxi kmod-brcmfmac
-  SUNXI_DTS:=sun7i-a20-bananapro
+  SUNXI_SOC := sun7i-a20
 endef
 
 TARGET_DEVICES += lemaker_bananapro
@@ -73,7 +73,7 @@  define Device/cubietech_cubieboard2
   DEVICE_VENDOR := Cubietech
   DEVICE_MODEL := Cubieboard2
   DEVICE_PACKAGES:=kmod-ata-core kmod-ata-sunxi kmod-sun4i-emac kmod-rtc-sunxi
-  SUNXI_DTS:=sun7i-a20-cubieboard2
+  SUNXI_SOC := sun7i-a20
 endef
 
 TARGET_DEVICES += cubietech_cubieboard2
@@ -83,7 +83,7 @@  define Device/cubietech_cubietruck
   DEVICE_VENDOR := Cubietech
   DEVICE_MODEL := Cubietruck
   DEVICE_PACKAGES:=kmod-ata-core kmod-ata-sunxi kmod-rtc-sunxi kmod-brcmfmac
-  SUNXI_DTS:=sun7i-a20-cubietruck
+  SUNXI_SOC := sun7i-a20
 endef
 
 TARGET_DEVICES += cubietech_cubietruck
@@ -93,7 +93,7 @@  define Device/lamobo_lamobo-r1
   DEVICE_VENDOR := Lamobo
   DEVICE_MODEL := Lamobo R1
   DEVICE_PACKAGES:=kmod-ata-sunxi kmod-rtl8192cu swconfig wpad-basic
-  SUNXI_DTS:=sun7i-a20-lamobo-r1
+  SUNXI_SOC := sun7i-a20
 endef
 
 TARGET_DEVICES += lamobo_lamobo-r1
@@ -103,7 +103,7 @@  define Device/mele_m9
   DEVICE_VENDOR := Mele
   DEVICE_MODEL := M9
   DEVICE_PACKAGES:=kmod-sun4i-emac kmod-rtc-sunxi kmod-rtl8192cu
-  SUNXI_DTS:=sun6i-a31-m9
+  SUNXI_SOC := sun6i-a31
 endef
 
 TARGET_DEVICES += mele_m9
@@ -113,7 +113,7 @@  define Device/xunlong_orangepi-zero
   DEVICE_VENDOR := Xunlong
   DEVICE_MODEL := Orange Pi Zero
   DEVICE_PACKAGES:=kmod-rtc-sunxi
-  SUNXI_DTS:=sun8i-h2-plus-orangepi-zero
+  SUNXI_SOC := sun8i-h2-plus
 endef
 
 TARGET_DEVICES += xunlong_orangepi-zero
@@ -123,7 +123,7 @@  define Device/xunlong_orangepi-r1
   DEVICE_VENDOR := Xunlong
   DEVICE_MODEL := Orange Pi R1
   DEVICE_PACKAGES:=kmod-rtc-sunxi kmod-usb-net kmod-usb-net-rtl8152
-  SUNXI_DTS:=sun8i-h2-plus-orangepi-r1
+  SUNXI_SOC := sun8i-h2-plus
 endef
 
 TARGET_DEVICES += xunlong_orangepi-r1
@@ -134,7 +134,7 @@  define Device/sinovoip_bananapi-m2-plus
   DEVICE_PACKAGES:=kmod-rtc-sunxi \
 	kmod-leds-gpio kmod-ledtrig-heartbeat \
 	kmod-brcmfmac brcmfmac-firmware-43430a0-sdio wpad-basic
-  SUNXI_DTS:=sun8i-h3-bananapi-m2-plus
+  SUNXI_SOC := sun8i-h3
 endef
 
 TARGET_DEVICES += sinovoip_bananapi-m2-plus
@@ -145,7 +145,7 @@  define Device/friendlyarm_nanopi-m1-plus
   DEVICE_PACKAGES:=kmod-rtc-sunxi \
 	kmod-leds-gpio kmod-ledtrig-heartbeat \
 	kmod-brcmfmac brcmfmac-firmware-43430-sdio wpad-basic
-  SUNXI_DTS:=sun8i-h3-nanopi-m1-plus
+  SUNXI_SOC := sun8i-h3
 endef
 
 TARGET_DEVICES += friendlyarm_nanopi-m1-plus
@@ -154,7 +154,7 @@  TARGET_DEVICES += friendlyarm_nanopi-m1-plus
 define Device/friendlyarm_nanopi-neo
   DEVICE_VENDOR := FriendlyARM
   DEVICE_MODEL := NanoPi NEO
-  SUNXI_DTS:=sun8i-h3-nanopi-neo
+  SUNXI_SOC := sun8i-h3
 endef
 
 TARGET_DEVICES += friendlyarm_nanopi-neo
@@ -164,7 +164,7 @@  define Device/xunlong_orangepi-one
   DEVICE_VENDOR := Xunlong
   DEVICE_MODEL := Orange Pi One
   DEVICE_PACKAGES:=kmod-rtc-sunxi
-  SUNXI_DTS:=sun8i-h3-orangepi-one
+  SUNXI_SOC := sun8i-h3
 endef
 
 TARGET_DEVICES += xunlong_orangepi-one
@@ -174,7 +174,7 @@  define Device/xunlong_orangepi-pc
   DEVICE_VENDOR := Xunlong
   DEVICE_MODEL := Orange Pi PC
   DEVICE_PACKAGES:=kmod-rtc-sunxi kmod-gpio-button-hotplug
-  SUNXI_DTS:=sun8i-h3-orangepi-pc
+  SUNXI_SOC := sun8i-h3
 endef
 
 TARGET_DEVICES += xunlong_orangepi-pc
@@ -184,7 +184,7 @@  define Device/xunlong_orangepi-pc-plus
   DEVICE_VENDOR := Xunlong
   DEVICE_MODEL := Orange Pi PC Plus
   DEVICE_PACKAGES:=kmod-rtc-sunxi kmod-gpio-button-hotplug
-  SUNXI_DTS:=sun8i-h3-orangepi-pc-plus
+  SUNXI_SOC := sun8i-h3
 endef
 
 TARGET_DEVICES += xunlong_orangepi-pc-plus
@@ -194,7 +194,7 @@  define Device/xunlong_orangepi-plus
   DEVICE_VENDOR := Xunlong
   DEVICE_MODEL := Orange Pi Plus
   DEVICE_PACKAGES:=kmod-rtc-sunxi
-  SUNXI_DTS:=sun8i-h3-orangepi-plus
+  SUNXI_SOC := sun8i-h3
 endef
 
 TARGET_DEVICES += xunlong_orangepi-plus
@@ -203,7 +203,7 @@  define Device/xunlong_orangepi-2
   DEVICE_VENDOR := Xunlong
   DEVICE_MODEL := Orange Pi 2
   DEVICE_PACKAGES:=kmod-rtc-sunxi
-  SUNXI_DTS:=sun8i-h3-orangepi-2
+  SUNXI_SOC := sun8i-h3
 endef
 
 TARGET_DEVICES += xunlong_orangepi-2
@@ -213,7 +213,7 @@  define Device/linksprite_pcduino3
   DEVICE_VENDOR := LinkSprite
   DEVICE_MODEL := pcDuino3
   DEVICE_PACKAGES:=kmod-sun4i-emac kmod-rtc-sunxi kmod-ata-core kmod-ata-sunxi kmod-rtl8xxxu rtl8188eu-firmware
-  SUNXI_DTS:=sun7i-a20-pcduino3
+  SUNXI_SOC := sun7i-a20
 endef
 
 TARGET_DEVICES += linksprite_pcduino3
@@ -222,7 +222,7 @@  define Device/lemaker_bananapi-m2-ultra
   DEVICE_VENDOR := LeMaker
   DEVICE_MODEL := Banana Pi M2 Ultra
   DEVICE_PACKAGES:=kmod-rtc-sunxi kmod-ata-core kmod-ata-sunxi
-  SUNXI_DTS:=sun8i-r40-bananapi-m2-ultra
+  SUNXI_SOC := sun8i-r40
 endef
 
 TARGET_DEVICES += lemaker_bananapi-m2-ultra
diff --git a/target/linux/sunxi/image/cortex-a8.mk b/target/linux/sunxi/image/cortex-a8.mk
index 073ed8f2d1..d6b5a46a22 100644
--- a/target/linux/sunxi/image/cortex-a8.mk
+++ b/target/linux/sunxi/image/cortex-a8.mk
@@ -11,7 +11,7 @@  define Device/olimex_a10-olinuxino-lime
   DEVICE_VENDOR := Olimex
   DEVICE_MODEL := A10-OLinuXino-LIME
   DEVICE_PACKAGES:=kmod-ata-core kmod-ata-sunxi kmod-sun4i-emac kmod-rtc-sunxi
-  SUNXI_DTS:=sun4i-a10-olinuxino-lime
+  SUNXI_SOC := sun4i
 endef
 
 TARGET_DEVICES += olimex_a10-olinuxino-lime
@@ -22,7 +22,8 @@  define Device/olimex_a13-olimex-som
   DEVICE_MODEL := A13-SOM
   DEVICE_PACKAGES:=kmod-rtl8192cu
   SUPPORTED_DEVICES:=olimex,a13-olinuxino
-  SUNXI_DTS:=sun5i-a13-olinuxino
+  SUNXI_SOC := sun5i-a13
+  SUNXI_DTS := sun5i-a13-olinuxino
 endef
 
 TARGET_DEVICES += olimex_a13-olimex-som
@@ -32,7 +33,7 @@  define Device/olimex_a13-olinuxino
   DEVICE_VENDOR := Olimex
   DEVICE_MODEL := A13-OLinuXino
   DEVICE_PACKAGES:=kmod-rtl8192cu
-  SUNXI_DTS:=sun5i-a13-olinuxino
+  SUNXI_SOC := sun5i
 endef
 
 TARGET_DEVICES += olimex_a13-olinuxino
@@ -42,7 +43,7 @@  define Device/cubietech_a10-cubieboard
   DEVICE_VENDOR := Cubietech
   DEVICE_MODEL := Cubieboard
   DEVICE_PACKAGES:=kmod-ata-core kmod-ata-sunxi kmod-sun4i-emac kmod-rtc-sunxi
-  SUNXI_DTS:=sun4i-a10-cubieboard
+  SUNXI_SOC := sun4i
 endef
 
 TARGET_DEVICES += cubietech_a10-cubieboard
@@ -52,7 +53,7 @@  define Device/linksprite_a10-pcduino
   DEVICE_VENDOR := LinkSprite
   DEVICE_MODEL := pcDuino
   DEVICE_PACKAGES:=kmod-sun4i-emac kmod-rtc-sunxi kmod-rtl8192cu
-  SUNXI_DTS:=sun4i-a10-pcduino
+  SUNXI_SOC := sun4i
 endef
 
 TARGET_DEVICES += linksprite_a10-pcduino
@@ -62,7 +63,7 @@  define Device/marsboard_a10-marsboard
   DEVICE_VENDOR := HAOYU Electronics
   DEVICE_MODEL := MarsBoard A10
   DEVICE_PACKAGES:=mod-ata-core kmod-ata-sunxi kmod-sun4i-emac kmod-rtc-sunxi sound-soc-sunxi
-  SUNXI_DTS:=sun4i-a10-marsboard
+  SUNXI_SOC := sun4i
 endef
 
 TARGET_DEVICES += marsboard_a10-marsboard