PinePhone automatic device tree selection
Subsystems (7)
Samuel Holland
maintainercover PinePhone automatic device tree selection
All,
This patch series implements a feature to automatically choose the right PinePhone device tree by probing the hardware. It then extends the functionality to pass the chosen DTB name to the boot command. Finally, I add device trees and a defconfig for the PinePhone.
I'm aware that Andre has concerns about updating the device tree files. It would be unfortunate for this to block new hardware support. Since the device trees are primarily maintained in the Linux repository, and only copied here, I believe compatibility concerns should be directed there, not here. In any case, the first 6 patches can be merged independently, so I request that they be merged even if patches 7-8 are not. I am mainly including the last two patches for ease of testing.
Samuel Holland (8):
sunxi: board: Use a more descriptive variable name
sunxi: board: Add a helper to get the SPL DT name
sunxi: board: Simplify Pine A64 DT selection logic
sunxi: board: Add PinePhone DT selection logic
sunxi: board: Save the chosen DT name in the SPL header
sunxi: board: Set fdtfile to match the DT chosen by SPL
sunxi: DT: A64: update device tree files
sunxi: a64: Add a defconfig for the PinePhone
arch/arm/dts/Makefile | 4 + arch/arm/dts/axp803.dtsi | 82 +-- arch/arm/dts/sun50i-a64-amarula-relic.dts | 109 +++- arch/arm/dts/sun50i-a64-bananapi-m64.dts | 118 ++-- arch/arm/dts/sun50i-a64-cpu-opp.dtsi | 75 +++ arch/arm/dts/sun50i-a64-nanopi-a64.dts | 70 +-- .../dts/sun50i-a64-oceanic-5205-5inmfd.dts | 31 +- arch/arm/dts/sun50i-a64-olinuxino-emmc.dts | 12 +- arch/arm/dts/sun50i-a64-olinuxino.dts | 113 ++-- arch/arm/dts/sun50i-a64-orangepi-win.dts | 127 +++-- arch/arm/dts/sun50i-a64-pine64-lts.dts | 7 +- arch/arm/dts/sun50i-a64-pine64-plus.dts | 52 +- arch/arm/dts/sun50i-a64-pine64.dts | 97 ++-- arch/arm/dts/sun50i-a64-pinebook-u-boot.dtsi | 17 - arch/arm/dts/sun50i-a64-pinebook.dts | 237 ++++++-- arch/arm/dts/sun50i-a64-pinephone-1.0.dts | 11 + arch/arm/dts/sun50i-a64-pinephone-1.1.dts | 30 + arch/arm/dts/sun50i-a64-pinephone-1.2.dts | 40 ++ arch/arm/dts/sun50i-a64-pinephone.dtsi | 429 ++++++++++++++ arch/arm/dts/sun50i-a64-pinetab.dts | 460 +++++++++++++++ arch/arm/dts/sun50i-a64-sopine-baseboard.dts | 113 ++-- arch/arm/dts/sun50i-a64-sopine.dtsi | 69 +-- arch/arm/dts/sun50i-a64-teres-i-u-boot.dtsi | 41 -- arch/arm/dts/sun50i-a64-teres-i.dts | 138 ++++- arch/arm/dts/sun50i-a64.dtsi | 532 ++++++++++++++---- arch/arm/mach-sunxi/Kconfig | 7 + board/sunxi/board.c | 97 +++- configs/pinephone_defconfig | 12 + include/dt-bindings/clock/sun50i-a64-ccu.h | 4 +- include/dt-bindings/clock/sun8i-de2.h | 3 + include/dt-bindings/reset/sun8i-de2.h | 1 + 31 files changed, 2488 insertions(+), 650 deletions(-) create mode 100644 arch/arm/dts/sun50i-a64-cpu-opp.dtsi delete mode 100644 arch/arm/dts/sun50i-a64-pinebook-u-boot.dtsi create mode 100644 arch/arm/dts/sun50i-a64-pinephone-1.0.dts create mode 100644 arch/arm/dts/sun50i-a64-pinephone-1.1.dts create mode 100644 arch/arm/dts/sun50i-a64-pinephone-1.2.dts create mode 100644 arch/arm/dts/sun50i-a64-pinephone.dtsi create mode 100644 arch/arm/dts/sun50i-a64-pinetab.dts delete mode 100644 arch/arm/dts/sun50i-a64-teres-i-u-boot.dtsi create mode 100644 configs/pinephone_defconfig
Signature · 1 line
2.26.2
Samuel Holland
maintainerPATCH 1/8 sunxi: board: Use a more descriptive variable name
The variable "cmp_str" always leaves me wondering if it is the DT name of the current board (yes) or DT name in the FIT config entry (no).
In preparation for expanding the functionality here, rename it to something that obviously means "this is the DT name we are looking for".
--- board/sunxi/board.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
board/sunxi/board.c +6 -6
@@ -892,14 +892,14 @@ int ft_board_setup(void *blob, struct bd_info *bd)int board_fit_config_name_match (const char *name) {struct boot_file_head *spl =get_spl_header (SPL_DT_HEADER_VERSION ); -const char *cmp_str = (const char *)spl; +const char *best_dt_name = (const char *)spl;/* Check if there is a DT name stored in the SPL header and use that. */ if (spl !=INVALID_SPL_HEADER && spl->dt_name_offset) { - cmp_str += spl->dt_name_offset; + best_dt_name += spl->dt_name_offset; }else {#ifdef CONFIG_DEFAULT_DEVICE_TREE - cmp_str =CONFIG_DEFAULT_DEVICE_TREE ; + best_dt_name =CONFIG_DEFAULT_DEVICE_TREE ;#else return 0 ;#endif
@@ -907,15 +907,15 @@ int board_fit_config_name_match(const char *name)#ifdef CONFIG_PINE64_DT_SELECTION /* Differentiate the two Pine64 board DTs by their DRAM size. */ -if (strstr (name,"-pine64" ) &&strstr (cmp_str,"-pine64" )) { +if (strstr (name,"-pine64" ) &&strstr (best_dt_name,"-pine64" )) {if ((gd->ram_size >512 *1024 *1024 ))return !strstr (name,"plus" );else return !!strstr (name,"plus" ); }else { -return strcmp (name, cmp_str); +return strcmp (name, best_dt_name); }#endif - return strcmp(name, cmp_str); + return strcmp(name, best_dt_name); }#endif
Signature · 1 line
2.26.2
PATCH 1/8 sunxi: board: Use a more descriptive variable name
Quoted 7 lines · Samuel Holland
The variable "
cmp_str" always leaves me wondering if it is the DT name of the current board (yes) or DT name in the FIT config entry (no).In preparation for expanding the functionality here, rename it to something that obviously means "this is the DT name we are looking for".
Signed-off-by Samuel Holland <[email protected]>
Cheers,
Andre
Quoted 46 lines
--- board/sunxi/board.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)board/sunxi/board.c +6
-6@@ -892,14 +892,14 @@ int ft_board_setup(void *blob, struct bd_info *bd)int board_fit_config_name_match (const char *name) {struct boot_file_head *spl =get_spl_header (SPL_DT_HEADER_VERSION ); -const char *cmp_str = (const char *)spl; +const char *best_dt_name = (const char *)spl;/* Check if there is a DT name stored in the SPL header and use that. */ if (spl !=INVALID_SPL_HEADER && spl->dt_name_offset) { - cmp_str += spl->dt_name_offset; + best_dt_name += spl->dt_name_offset; }else {#ifdef CONFIG_DEFAULT_DEVICE_TREE - cmp_str =CONFIG_DEFAULT_DEVICE_TREE ; + best_dt_name =CONFIG_DEFAULT_DEVICE_TREE ;#else return 0 ;#endif @@ -907,15 +907,15 @@ int board_fit_config_name_match(const char *name)#ifdef CONFIG_PINE64_DT_SELECTION /* Differentiate the two Pine64 board DTs by their DRAM size. */ -if (strstr (name,"-pine64" ) &&strstr (cmp_str,"-pine64" )) { +if (strstr (name,"-pine64" ) &&strstr (best_dt_name,"-pine64" )) {if ((gd->ram_size >512 *1024 *1024 ))return !strstr (name,"plus" );else return !!strstr (name,"plus" ); }else { -return strcmp (name, cmp_str); +return strcmp (name, best_dt_name); }#endif - return strcmp(name, cmp_str); + return strcmp(name, best_dt_name); }#endif
Samuel Holland
maintainerPATCH 2/8 sunxi: board: Add a helper to get the SPL DT name
In reply to Samuel HollandThis moves the validity checking and typecasts all to one place away from the string comparison logic, and it detangles the compile-time and runtime control flow.
The new helper will also be used by U-Boot proper in a future commit.
--- board/sunxi/board.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-)
board/sunxi/board.c +17 -9
@@ -319,6 +319,17 @@ static struct boot_file_head * get_spl_header(uint8_t req_version)return spl; } +static const char *get_spl_dt_name (void ) +{ +struct boot_file_head *spl =get_spl_header (SPL_DT_HEADER_VERSION ); + +/* Check if there is a DT name stored in the SPL header. */ +if (spl !=INVALID_SPL_HEADER && spl->dt_name_offset) +return (char *)spl + spl->dt_name_offset; + +return NULL ; +} +int dram_init (void ) {struct boot_file_head *spl =get_spl_header (SPL_DRAM_HEADER_VERSION );
@@ -891,20 +902,17 @@ int ft_board_setup(void *blob, struct bd_info *bd)#ifdef CONFIG_SPL_LOAD_FIT int board_fit_config_name_match (const char *name) { -struct boot_file_head *spl =get_spl_header (SPL_DT_HEADER_VERSION ); -const char *best_dt_name = (const char *)spl; +const char *best_dt_name =get_spl_dt_name (); -/* Check if there is a DT name stored in the SPL header and use that. */ -if (spl !=INVALID_SPL_HEADER && spl->dt_name_offset) { - best_dt_name += spl->dt_name_offset; - }else {#ifdef CONFIG_DEFAULT_DEVICE_TREE +if (best_dt_name ==NULL ) best_dt_name =CONFIG_DEFAULT_DEVICE_TREE ; -#else -return 0 ;#endif - }; +if (best_dt_name ==NULL ) { +/* No DT name was provided, so accept the first config. */ +return 0 ; + }#ifdef CONFIG_PINE64_DT_SELECTION /* Differentiate the two Pine64 board DTs by their DRAM size. */ if (strstr (name,"-pine64" ) &&strstr (best_dt_name,"-pine64" )) {
Signature · 1 line
2.26.2
PATCH 2/8 sunxi: board: Add a helper to get the SPL DT name
Quoted 7 lines · Samuel Holland
This moves the validity checking and typecasts all to one place away from the string comparison logic, and it detangles the compile-time and runtime control flow.
The new helper will also be used by U-Boot proper in a future commit.
Signed-off-by Samuel Holland <[email protected]>
Thanks,
Andre
Quoted 54 lines
--- board/sunxi/board.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-)board/sunxi/board.c +17
-9@@ -319,6 +319,17 @@ static struct boot_file_head * get_spl_header(uint8_t req_version)return spl; } +static const char *get_spl_dt_name (void ) +{ +struct boot_file_head *spl =get_spl_header (SPL_DT_HEADER_VERSION ); + +/* Check if there is a DT name stored in the SPL header. */ +if (spl !=INVALID_SPL_HEADER && spl->dt_name_offset) +return (char *)spl + spl->dt_name_offset; + +return NULL ; +} +int dram_init (void ) {struct boot_file_head *spl =get_spl_header (SPL_DRAM_HEADER_VERSION );@@ -891,20 +902,17 @@ int ft_board_setup(void *blob, struct bd_info *bd)#ifdef CONFIG_SPL_LOAD_FIT int board_fit_config_name_match (const char *name) { -struct boot_file_head *spl =get_spl_header (SPL_DT_HEADER_VERSION ); -const char *best_dt_name = (const char *)spl; +const char *best_dt_name =get_spl_dt_name (); -/* Check if there is a DT name stored in the SPL header and use that. */ -if (spl !=INVALID_SPL_HEADER && spl->dt_name_offset) { - best_dt_name += spl->dt_name_offset; - }else {#ifdef CONFIG_DEFAULT_DEVICE_TREE +if (best_dt_name ==NULL ) best_dt_name =CONFIG_DEFAULT_DEVICE_TREE ; -#else -return 0 ;#endif - }; +if (best_dt_name ==NULL ) { +/* No DT name was provided, so accept the first config. */ +return 0 ; + }#ifdef CONFIG_PINE64_DT_SELECTION /* Differentiate the two Pine64 board DTs by their DRAM size. */ if (strstr (name,"-pine64" ) &&strstr (best_dt_name,"-pine64" )) {
Samuel Holland
maintainerPATCH 3/8 sunxi: board: Simplify Pine A64 DT selection logic
In reply to Samuel HollandInstead of using an entirely separate matching algorithm, simply update the name of the DT we want to match. Enabling this logic does not depend on the FIT config name, only on the initial guess of the board name.
Importantly, the initial guess must be "sun50i-a64-pine64-plus", because otherwise the logic would trigger when "sun50i-a64-pine64-lts" was written to the SPL header.
--- board/sunxi/board.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
board/sunxi/board.c +4 -8
@@ -914,14 +914,10 @@ int board_fit_config_name_match(const char *name)return 0 ; }#ifdef CONFIG_PINE64_DT_SELECTION -/* Differentiate the two Pine64 board DTs by their DRAM size. */ -if (strstr (name,"-pine64" ) &&strstr (best_dt_name,"-pine64" )) { -if ((gd->ram_size >512 *1024 *1024 )) -return !strstr (name,"plus" ); -else -return !!strstr (name,"plus" ); - }else { -return strcmp (name, best_dt_name); + else if (strstr(best_dt_name, "-pine64-plus")) { +/* Differentiate the Pine A64 boards by their DRAM size. */ +if ((gd->ram_size ==512 *1024 *1024 )) + best_dt_name ="sun50i-a64-pine64" ; }#endif return strcmp (name, best_dt_name);
Signature · 1 line
2.26.2
PATCH 3/8 sunxi: board: Simplify Pine A64 DT selection logic
Quoted 3 lines · Samuel Holland
Instead of using an entirely separate matching algorithm, simply update the name of the DT we want to match. Enabling this logic does not depend on the FIT config name, only on the initial guess of the board name.
Yeah, clever solution. The original code was indeed quite confusing, partly because it tried to desperately save on code size. Turns out your solution is much smaller now ;-)
Quoted 3 lines
Importantly, the initial guess must be "sun50i-a64-pine64-plus", because otherwise the logic would trigger when "sun50i-a64-pine64-lts" was written to the SPL header.
Ah, good catch.
Quoted 2 lines
Signed-off-by Samuel Holland <[email protected]>
One nit below, with that:
Quoted 11 lines
--- board/sunxi/board.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)board/sunxi/board.c +0
-0@@ -914,14 +914,10 @@ int board_fit_config_name_match(const char *name)return 0 ; }
board/sunxi/board.c int board_fit_config_name_match(const char *name) · line 917
Quoted 10 lines
board/sunxi/board.c +1
-8#ifdef CONFIG_PINE64_DT_SELECTION -/* Differentiate the two Pine64 board DTs by their DRAM size. */ -if (strstr (name,"-pine64" ) &&strstr (best_dt_name,"-pine64" )) { -if ((gd->ram_size >512 *1024 *1024 )) -return !strstr (name,"plus" ); -else -return !!strstr (name,"plus" ); - }else { -return strcmp (name, best_dt_name); + else if (strstr(best_dt_name, "-pine64-plus")) {
I think you don't need this "else" here, as the "if" part returns already. Makes this even easier to read.
Cheers,
Andre.
Quoted 7 lines
board/sunxi/board.c +3
-0+/* Differentiate the Pine A64 boards by their DRAM size. */ +if ((gd->ram_size ==512 *1024 *1024 )) + best_dt_name = "sun50i-a64-pine64"; }#endif return strcmp (name, best_dt_name);
Samuel Holland
maintainerPATCH 4/8 sunxi: board: Add PinePhone DT selection logic
In reply to Samuel HollandThere are two different publicly-released revisions of the PinePhone hardware, versions 1.1 and 1.2; and they need different device trees. Since some GPIO pins were rerouted, we can use that to distinguish between them.
--- arch/arm/mach-sunxi/Kconfig | 7 +++++++ board/sunxi/board.c | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+)
arch/arm/mach-sunxi/Kconfig +7 -0
@@ -1010,4 +1010,11 @@ config PINE64_DT_SELECTION option, the device tree selection code specific to Pine64 which utilizes the DRAM size will be enabled. +config PINEPHONE_DT_SELECTION + bool "Enable PinePhone device tree selection code" + depends on MACH_SUN50I + help + Enable this option to automatically select the device tree for the + correct PinePhone hardware revision during boot. + endif
board/sunxi/board.c +21 -0
@@ -27,6 +27,7 @@#include <asm/arch/dram.h> #include <asm/arch/gpio.h> #include <asm/arch/mmc.h> +#include <asm/arch/prcm.h> #include <asm/arch/spl.h> #include <linux/delay.h> #include <u-boot/crc.h>
@@ -920,6 +921,26 @@ int board_fit_config_name_match(const char *name) best_dt_name ="sun50i-a64-pine64" ; }#endif +#ifdef CONFIG_PINEPHONE_DT_SELECTION + else if (strstr(best_dt_name, "-pinephone")) { +/* Differentiate the PinePhone revisions by GPIO inputs. */ +prcm_apb0_enable (PRCM_APB0_GATE_PIO ); +sunxi_gpio_set_pull (SUNXI_GPL (6 ),SUNXI_GPIO_PULL_UP ); +sunxi_gpio_set_cfgpin (SUNXI_GPL (6 ),SUNXI_GPIO_INPUT ); +udelay (100 ); + +/* PL6 is pulled low by the modem on v1.2. */ +if (gpio_get_value (SUNXI_GPL (6 )) ==0 ) + best_dt_name ="sun50i-a64-pinephone-1.2" ; +else + best_dt_name ="sun50i-a64-pinephone-1.1" ; + +sunxi_gpio_set_cfgpin (SUNXI_GPL (6 ),SUNXI_GPIO_DISABLE ); +sunxi_gpio_set_pull (SUNXI_GPL (6 ),SUNXI_GPIO_PULL_DISABLE ); +prcm_apb0_disable (PRCM_APB0_GATE_PIO ); + } +#endif +return strcmp (name, best_dt_name); }#endif
Signature · 1 line
2.26.2
PATCH 4/8 sunxi: board: Add PinePhone DT selection logic
On 03/09/2020 06:07, Samuel Holland wrote:
Hi,
Quoted 4 lines
There are two different publicly-released revisions of the PinePhone hardware, versions 1.1 and 1.2; and they need different device trees. Since some GPIO pins were rerouted, we can use that to distinguish between them.
Nice one. I once had a similar solution to differentiate between the (otherwise very similar) Pinebook and Pine64-LTS.
Quoted 2 lines
Signed-off-by Samuel Holland <[email protected]>
With the "else" down below removed:
Quoted 34 lines
--- arch/arm/mach-sunxi/Kconfig | 7 +++++++ board/sunxi/board.c | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+)arch/arm/mach-sunxi/Kconfig +7
-0@@ -1010,4 +1010,11 @@ config PINE64_DT_SELECTION option, the device tree selection code specific to Pine64 which utilizes the DRAM size will be enabled. +config PINEPHONE_DT_SELECTION + bool "Enable PinePhone device tree selection code" + depends on MACH_SUN50I + help + Enable this option to automatically select the device tree for the + correct PinePhone hardware revision during boot. + endifboard/sunxi/board.c +1
-0@@ -27,6 +27,7 @@#include <asm/arch/dram.h> #include <asm/arch/gpio.h> #include <asm/arch/mmc.h> +#include <asm/arch/prcm.h> #include <asm/arch/spl.h> #include <linux/delay.h> #include <u-boot/crc.h>
board/sunxi/board.c int board_fit_config_name_match(const char *name) · line 925
Quoted 5 lines
board/sunxi/board.c +2
-0@@ -920,6 +921,26 @@ int board_fit_config_name_match(const char *name) best_dt_name ="sun50i-a64-pine64" ; }#endif +#ifdef CONFIG_PINEPHONE_DT_SELECTION + else if (strstr(best_dt_name, "-pinephone")) {
I think to improve readability and increase robustness against future changes you can lose the "else" here. Even if both selection methods should be selected, only one will realistically match the strstr() comparison.
Quoted 5 lines
board/sunxi/board.c +5
-0+/* Differentiate the PinePhone revisions by GPIO inputs. */ +prcm_apb0_enable (PRCM_APB0_GATE_PIO ); +sunxi_gpio_set_pull (SUNXI_GPL (6 ),SUNXI_GPIO_PULL_UP ); +sunxi_gpio_set_cfgpin (SUNXI_GPL (6 ),SUNXI_GPIO_INPUT ); +udelay (100 );
board/sunxi/board.c int board_fit_config_name_match(const char *name) · line 940
Quoted 10 lines
board/sunxi/board.c +10
-0+ +/* PL6 is pulled low by the modem on v1.2. */ +if (gpio_get_value (SUNXI_GPL (6 )) ==0 ) + best_dt_name ="sun50i-a64-pinephone-1.2" ; +else + best_dt_name ="sun50i-a64-pinephone-1.1" ; + +sunxi_gpio_set_cfgpin (SUNXI_GPL (6 ),SUNXI_GPIO_DISABLE ); +sunxi_gpio_set_pull (SUNXI_GPL (6 ),SUNXI_GPIO_PULL_DISABLE ); +prcm_apb0_disable (PRCM_APB0_GATE_PIO );
Looking forward, this should probably restore the former state, in case some code elsewhere had enabled the PIO gate already. But for now, with the current code state, this is fine.
Cheers,
Andre
Quoted 7 lines
board/sunxi/board.c +3
-0+ } +#endif +return strcmp (name, best_dt_name); }#endif
PATCH 4/8 sunxi: board: Add PinePhone DT selection logic
In reply to Samuel HollandQuoted 41 lines · Samuel Holland
There are two different publicly-released revisions of the PinePhone hardware, versions 1.1 and 1.2; and they need different device trees. Since some GPIO pins were rerouted, we can use that to distinguish between them.
Signed-off-by Samuel Holland <[email protected]>--- arch/arm/mach-sunxi/Kconfig | 7 +++++++ board/sunxi/board.c | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+)arch/arm/mach-sunxi/Kconfig +7
-0@@ -1010,4 +1010,11 @@ config PINE64_DT_SELECTION option, the device tree selection code specific to Pine64 which utilizes the DRAM size will be enabled. +config PINEPHONE_DT_SELECTION + bool "Enable PinePhone device tree selection code" + depends on MACH_SUN50I + help + Enable this option to automatically select the device tree for the + correct PinePhone hardware revision during boot. + endifboard/sunxi/board.c +1
-0@@ -27,6 +27,7 @@#include <asm/arch/dram.h> #include <asm/arch/gpio.h> #include <asm/arch/mmc.h> +#include <asm/arch/prcm.h> #include <asm/arch/spl.h> #include <linux/delay.h> #include <u-boot/crc.h>
board/sunxi/board.c int board_fit_config_name_match(const char *name) · line 924
Quoted 4 lines
board/sunxi/board.c +1
-0@@ -920,6 +921,26 @@ int board_fit_config_name_match(const char *name) best_dt_name = "sun50i-a64-pine64"; }#endif +#ifdef CONFIG_PINEPHONE_DT_SELECTION
Look like these board detection CONFIG items are keep on increasing. Better to have something like CONFIG_SUNXI_DT_SELECTION for all dt selection code.
Samuel Holland
maintainerPATCH 4/8 sunxi: board: Add PinePhone DT selection logic
Quoted 42 lines · Jagan Teki
Quoted 41 lines · Samuel Holland
There are two different publicly-released revisions of the PinePhone hardware, versions 1.1 and 1.2; and they need different device trees. Since some GPIO pins were rerouted, we can use that to distinguish between them.
Signed-off-by Samuel Holland <[email protected]>--- arch/arm/mach-sunxi/Kconfig | 7 +++++++ board/sunxi/board.c | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+)arch/arm/mach-sunxi/Kconfig +7
-0@@ -1010,4 +1010,11 @@ config PINE64_DT_SELECTION option, the device tree selection code specific to Pine64 which utilizes the DRAM size will be enabled. +config PINEPHONE_DT_SELECTION + bool "Enable PinePhone device tree selection code" + depends on MACH_SUN50I + help + Enable this option to automatically select the device tree for the + correct PinePhone hardware revision during boot. + endifboard/sunxi/board.c +1
-0@@ -27,6 +27,7 @@#include <asm/arch/dram.h> #include <asm/arch/gpio.h> #include <asm/arch/mmc.h> +#include <asm/arch/prcm.h> #include <asm/arch/spl.h> #include <linux/delay.h> #include <u-boot/crc.h> @@ -920,6 +921,26 @@ int board_fit_config_name_match(const char *name)
Quoted 8 lines
board/sunxi/board.c int board_fit_config_name_match(const char *name) · line 924
Quoted 4 lines
board/sunxi/board.c +1
-0best_dt_name = "sun50i-a64-pine64"; }#endif +#ifdef CONFIG_PINEPHONE_DT_SELECTION Look like these board detection CONFIG items are keep on increasing. Better to have something like
CONFIG_SUNXI_DT_SELECTIONfor all dt selection code.
Are you sure? This is in SPL, where we are always running out of space. And a single SPL binary cannot work on both Pine A64 and PinePhone anyway, since they have different DRAM types. I think the space savings is worth the cost of the extra config symbol (especially if more boards need special handling in the future).
Cheers,
Samuel
PATCH 4/8 sunxi: board: Add PinePhone DT selection logic
Quoted 53 lines · Samuel Holland
Quoted 42 lines · Jagan Teki
Quoted 41 lines · Samuel Holland
There are two different publicly-released revisions of the PinePhone hardware, versions 1.1 and 1.2; and they need different device trees. Since some GPIO pins were rerouted, we can use that to distinguish between them.
Signed-off-by Samuel Holland <[email protected]>--- arch/arm/mach-sunxi/Kconfig | 7 +++++++ board/sunxi/board.c | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+)arch/arm/mach-sunxi/Kconfig +7
-0@@ -1010,4 +1010,11 @@ config PINE64_DT_SELECTION option, the device tree selection code specific to Pine64 which utilizes the DRAM size will be enabled. +config PINEPHONE_DT_SELECTION + bool "Enable PinePhone device tree selection code" + depends on MACH_SUN50I + help + Enable this option to automatically select the device tree for the + correct PinePhone hardware revision during boot. + endifboard/sunxi/board.c +1
-0@@ -27,6 +27,7 @@#include <asm/arch/dram.h> #include <asm/arch/gpio.h> #include <asm/arch/mmc.h> +#include <asm/arch/prcm.h> #include <asm/arch/spl.h> #include <linux/delay.h> #include <u-boot/crc.h> @@ -920,6 +921,26 @@ int board_fit_config_name_match(const char *name)Quoted 8 lines
board/sunxi/board.c int board_fit_config_name_match(const char *name) · line 924
Quoted 4 lines
board/sunxi/board.c +1
-0best_dt_name = "sun50i-a64-pine64"; }#endif +#ifdef CONFIG_PINEPHONE_DT_SELECTION Look like these board detection CONFIG items are keep on increasing. Better to have something like
CONFIG_SUNXI_DT_SELECTIONfor all dt selection code.
Quoted 4 lines
Are you sure? This is in SPL, where we are always running out of space. And a single SPL binary cannot work on both Pine A64 and PinePhone anyway, since they have different DRAM types. I think the space savings is worth the cost of the extra config symbol (especially if more boards need special handling in the future).
Does marking 'dt selection only' code as a single config symbol is increasing the SPL size?
Jagan.
PATCH 4/8 sunxi: board: Add PinePhone DT selection logic
In reply to Samuel HollandQuoted 52 lines · Samuel Holland
Quoted 42 lines · Jagan Teki
Quoted 41 lines · Samuel Holland
There are two different publicly-released revisions of the PinePhone hardware, versions 1.1 and 1.2; and they need different device trees. Since some GPIO pins were rerouted, we can use that to distinguish between them.
Signed-off-by Samuel Holland <[email protected]>--- arch/arm/mach-sunxi/Kconfig | 7 +++++++ board/sunxi/board.c | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+)arch/arm/mach-sunxi/Kconfig +7
-0@@ -1010,4 +1010,11 @@ config PINE64_DT_SELECTION option, the device tree selection code specific to Pine64 which utilizes the DRAM size will be enabled. +config PINEPHONE_DT_SELECTION + bool "Enable PinePhone device tree selection code" + depends on MACH_SUN50I + help + Enable this option to automatically select the device tree for the + correct PinePhone hardware revision during boot. + endifboard/sunxi/board.c +1
-0@@ -27,6 +27,7 @@#include <asm/arch/dram.h> #include <asm/arch/gpio.h> #include <asm/arch/mmc.h> +#include <asm/arch/prcm.h> #include <asm/arch/spl.h> #include <linux/delay.h> #include <u-boot/crc.h> @@ -920,6 +921,26 @@ int board_fit_config_name_match(const char *name)Quoted 8 lines
board/sunxi/board.c int board_fit_config_name_match(const char *name) · line 924
Quoted 4 lines
board/sunxi/board.c +1
-0best_dt_name = "sun50i-a64-pine64"; }#endif +#ifdef CONFIG_PINEPHONE_DT_SELECTION Look like these board detection CONFIG items are keep on increasing. Better to have something like
CONFIG_SUNXI_DT_SELECTIONfor all dt selection code.
Quoted 4 lines
Are you sure? This is in SPL, where we are always running out of space. And a single SPL binary cannot work on both Pine A64 and PinePhone anyway, since they have different DRAM types. I think the space savings is worth the cost of the extra config symbol (especially if more boards need special handling in the future).
I agree, it will save some space and it's not like it's unmaintainable at the moment.
Maxime
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201022/58004894/attachment.sig>
Samuel Holland
maintainerPATCH 5/8 sunxi: board: Save the chosen DT name in the SPL header
In reply to Samuel HollandThis overwrites the name loaded from the SPL image. It will be different if there was previously no name provided, or if a more accurate name was determined by the board variant selection logic. This means that the DT name in the SPL header now always matches the DT appended to U-Boot.
--- board/sunxi/board.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
board/sunxi/board.c +26 -1
@@ -331,6 +331,21 @@ static const char *get_spl_dt_name(void)return NULL ; } +static void set_spl_dt_name (const char *name) +{ +struct boot_file_head *spl =get_spl_header (SPL_ENV_HEADER_VERSION ); + +if (spl ==INVALID_SPL_HEADER ) +return ; + +/* Promote the header version for U-Boot proper, if needed. */ +if (spl->spl_signature[3 ] <SPL_DT_HEADER_VERSION ) + spl->spl_signature[3 ] =SPL_DT_HEADER_VERSION ; + +strcpy ((char *)&spl->string_pool, name); + spl->dt_name_offset = offsetof(struct boot_file_head , string_pool); +} +int dram_init (void ) {struct boot_file_head *spl =get_spl_header (SPL_DRAM_HEADER_VERSION );
@@ -904,6 +919,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)int board_fit_config_name_match (const char *name) {const char *best_dt_name =get_spl_dt_name (); +int ret;#ifdef CONFIG_DEFAULT_DEVICE_TREE if (best_dt_name ==NULL )
@@ -941,6 +957,15 @@ int board_fit_config_name_match(const char *name) }#endif -return strcmp (name, best_dt_name); + ret =strcmp (name, best_dt_name); + +/* +* If one of the FIT configurations matches the most accurate DT name, +* update the SPL header to provide that DT name to U-Boot proper. +*/ +if (ret ==0 ) +set_spl_dt_name (best_dt_name); + +return ret; }#endif
Signature · 1 line
2.26.2
PATCH 5/8 sunxi: board: Save the chosen DT name in the SPL header
Quoted 3 lines · Samuel Holland
This overwrites the name loaded from the SPL image. It will be different
if there was previously no name provided, or if a more accurate name was
determined by the board variant selection logic. This means that the DT> name in the SPL header now always matches the DT appended to U-Boot.
That's a nice way of preserving all this fancy DT selection choices for U-Boot proper!
Quoted 1 line
Signed-off-by Samuel Holland <[email protected]>
One hint below, but nevertheless:
Quoted 14 lines
--- board/sunxi/board.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)board/sunxi/board.c +2
-0@@ -331,6 +331,21 @@ static const char *get_spl_dt_name(void)return NULL ; } +static void set_spl_dt_name (const char *name) +{
board/sunxi/board.c static const char *get_spl_dt_name(void) · line 345
Quoted 10 lines
board/sunxi/board.c +10
-0+struct boot_file_head *spl =get_spl_header (SPL_ENV_HEADER_VERSION ); + +if (spl ==INVALID_SPL_HEADER ) +return ; + +/* Promote the header version for U-Boot proper, if needed. */ +if (spl->spl_signature[3 ] <SPL_DT_HEADER_VERSION ) + spl->spl_signature[3 ] =SPL_DT_HEADER_VERSION ; + +strcpy ((char *)&spl->string_pool, name);
Let's hope nobody ever optimises the strcpy() routine, as this might break (when doing unaligned accesses) on device memory, as in this case.
Cheers,
Andre.
Quoted 32 lines
board/sunxi/board.c +14
-1+ spl->dt_name_offset = offsetof(struct boot_file_head , string_pool); +} +int dram_init (void ) {struct boot_file_head *spl =get_spl_header (SPL_DRAM_HEADER_VERSION );@@ -904,6 +919,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)int board_fit_config_name_match (const char *name) {const char *best_dt_name =get_spl_dt_name (); +int ret;#ifdef CONFIG_DEFAULT_DEVICE_TREE if (best_dt_name ==NULL )@@ -941,6 +957,15 @@ int board_fit_config_name_match(const char *name) }#endif -return strcmp (name, best_dt_name); + ret =strcmp (name, best_dt_name); + +/* +* If one of the FIT configurations matches the most accurate DT name, +* update the SPL header to provide that DT name to U-Boot proper. +*/ +if (ret ==0 ) +set_spl_dt_name (best_dt_name); + +return ret; }#endif
Samuel Holland
maintainerPATCH 5/8 sunxi: board: Save the chosen DT name in the SPL header
Quoted 26 lines · Andr? Przywara
Quoted 3 lines · Samuel Holland
This overwrites the name loaded from the SPL image. It will be different
if there was previously no name provided, or if a more accurate name was
determined by the board variant selection logic. This means that the DT> name in the SPL header now always matches the DT appended to U-Boot.That's a nice way of preserving all this fancy DT selection choices for U-Boot proper!
Quoted 1 line
Signed-off-by Samuel Holland <[email protected]>One hint below, but nevertheless:
Reviewed-by Andre Przywara <[email protected]>Quoted 12 lines
--- board/sunxi/board.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)board/sunxi/board.c +0
-0@@ -331,6 +331,21 @@ static const char *get_spl_dt_name(void)return NULL ; }
Quoted 15 lines
board/sunxi/board.c static const char *get_spl_dt_name(void) · line 345
Quoted 12 lines
board/sunxi/board.c +12
-0+static void set_spl_dt_name (const char *name) +{ +struct boot_file_head *spl =get_spl_header (SPL_ENV_HEADER_VERSION ); + +if (spl ==INVALID_SPL_HEADER ) +return ; + +/* Promote the header version for U-Boot proper, if needed. */ +if (spl->spl_signature[3 ] <SPL_DT_HEADER_VERSION ) + spl->spl_signature[3 ] =SPL_DT_HEADER_VERSION ; + +strcpy ((char *)&spl->string_pool, name);Let's hope nobody ever optimises the
strcpy()routine, as this might break (when doing unaligned accesses) on device memory, as in this case.
Why would any part of SRAM A1 be mapped as device memory? If U-Boot maps its own code as device memory, and then implements a strcpy that requires aligned multi-byte access (i.e. cannot handle arbitrary naturally-aligned char *), then this code here isn't the bug.
Cheers,
Samuel
Quoted 36 lines
Cheers,
Andre.Quoted 32 lines
board/sunxi/board.c +14
-1+ spl->dt_name_offset = offsetof(struct boot_file_head , string_pool); +} +int dram_init (void ) {struct boot_file_head *spl =get_spl_header (SPL_DRAM_HEADER_VERSION );@@ -904,6 +919,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)int board_fit_config_name_match (const char *name) {const char *best_dt_name =get_spl_dt_name (); +int ret;#ifdef CONFIG_DEFAULT_DEVICE_TREE if (best_dt_name ==NULL )@@ -941,6 +957,15 @@ int board_fit_config_name_match(const char *name) }#endif -return strcmp (name, best_dt_name); + ret =strcmp (name, best_dt_name); + +/* +* If one of the FIT configurations matches the most accurate DT name, +* update the SPL header to provide that DT name to U-Boot proper. +*/ +if (ret ==0 ) +set_spl_dt_name (best_dt_name); + +return ret; }#endif
PATCH 5/8 sunxi: board: Save the chosen DT name in the SPL header
On 22/09/2020 02:12, Samuel Holland wrote:
Hi,
Quoted 43 lines · Andr? Przywara
Quoted 26 lines · Samuel Holland
Quoted 3 lines
This overwrites the name loaded from the SPL image. It will be different
if there was previously no name provided, or if a more accurate name was
determined by the board variant selection logic. This means that the DT> name in the SPL header now always matches the DT appended to U-Boot.That's a nice way of preserving all this fancy DT selection choices for U-Boot proper!
Quoted 1 line
Signed-off-by Samuel Holland <[email protected]>One hint below, but nevertheless:
Reviewed-by Andre Przywara <[email protected]>Quoted 12 lines
--- board/sunxi/board.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)board/sunxi/board.c +0
-0@@ -331,6 +331,21 @@ static const char *get_spl_dt_name(void)return NULL ; }Quoted 15 lines
board/sunxi/board.c static const char *get_spl_dt_name(void) · line 345
Quoted 12 lines
board/sunxi/board.c +12
-0+static void set_spl_dt_name (const char *name) +{ +struct boot_file_head *spl =get_spl_header (SPL_ENV_HEADER_VERSION ); + +if (spl ==INVALID_SPL_HEADER ) +return ; + +/* Promote the header version for U-Boot proper, if needed. */ +if (spl->spl_signature[3 ] <SPL_DT_HEADER_VERSION ) + spl->spl_signature[3 ] =SPL_DT_HEADER_VERSION ; + +strcpy ((char *)&spl->string_pool, name);Let's hope nobody ever optimises the
strcpy()routine, as this might break (when doing unaligned accesses) on device memory, as in this case.
Quoted 1 line
Why would any part of SRAM A1 be mapped as device memory?
Because we do so in arch/arm/mach-sunxi/board.c:
static struct mm_region sunxi_mem_map[] = {
{
/* SRAM, MMIO regions */
.virt = 0x0UL,
.phys = 0x0UL,
.size = 0x40000000UL,
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
PTE_BLOCK_NON_SHARE
}, {Quoted 1 line
If U-Boot maps its own code as device memory,
DRAM is mapped as normal cacheable memory (the line after those above). So U-Boot's code and its own data are safe.
Quoted 3 lines
and then implements a strcpy that requires aligned
multi-byte access (i.e. cannot handle arbitrary naturally-aligned char *), then this code here isn't the bug.
The problem is that letting the compiler generate code that does access non-normal memory is broken. Device memory needs to be accessed via MMIO accessors only, everything else is architecturally wrong.
We are somewhat saved by the fact that SRAM, by its very nature, implements memory semantics, so it supports the GRE semantics that the compiler relies on. But unaligned accesses trap on device memory nevertheless.
As I said, it probably works at the moment, under the current conditions, but is fragile.
Cheers,
Andre
Quoted 34 lines
Quoted 33 lines
Quoted 32 lines
board/sunxi/board.c +14
-1+ spl->dt_name_offset = offsetof(struct boot_file_head , string_pool); +} +int dram_init (void ) {struct boot_file_head *spl =get_spl_header (SPL_DRAM_HEADER_VERSION );@@ -904,6 +919,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)int board_fit_config_name_match (const char *name) {const char *best_dt_name =get_spl_dt_name (); +int ret;#ifdef CONFIG_DEFAULT_DEVICE_TREE if (best_dt_name ==NULL )@@ -941,6 +957,15 @@ int board_fit_config_name_match(const char *name) }#endif -return strcmp (name, best_dt_name); + ret =strcmp (name, best_dt_name); + +/* +* If one of the FIT configurations matches the most accurate DT name, +* update the SPL header to provide that DT name to U-Boot proper. +*/ +if (ret ==0 ) +set_spl_dt_name (best_dt_name); + +return ret; }#endif
Samuel Holland
maintainerPATCH 6/8 sunxi: board: Set fdtfile to match the DT chosen by SPL
In reply to Samuel HollandPreviously, fdtfile was always the value in CONFIG_DEFAULT_DEVICE_TREE. This meant that, regardless of the DT chosen by SPL (either by changing the header in the image or by the selection code at runtime), Linux always used the default DT.
By using the name from the SPL header (which, because of the previous commit, always matches the DT used by U-Boot proper), Linux also sees the same board as U-Boot/SPL, even if the boot script later loads a DT from disk.
--- board/sunxi/board.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
board/sunxi/board.c +11 -0
@@ -870,6 +870,7 @@ static void setup_environment(const void *fdt)int misc_init_r (void ) { +const char *spl_dt_name;uint boot;env_set ("fel_booted" ,NULL );
@@ -888,6 +889,16 @@ int misc_init_r(void)env_set ("mmc_bootdev" ,"1" ); } +/* Set fdtfile to match the FIT configuration chosen in SPL. */ + spl_dt_name =get_spl_dt_name (); +if (spl_dt_name) { +char *prefix =IS_ENABLED (CONFIG_ARM64 ) ?"allwinner/" :"" ; +char str[64 ]; + +snprintf (str,sizeof (str),"%s%s.dtb" , prefix, spl_dt_name); +env_set ("fdtfile" , str); + } +setup_environment (gd->fdt_blob);#ifdef CONFIG_USB_ETHER
Signature · 1 line
2.26.2
PATCH 6/8 sunxi: board: Set fdtfile to match the DT chosen by SPL
On 03/09/2020 06:07, Samuel Holland wrote:
Hi,
Quoted 9 lines
Previously, fdtfile was always the value in
CONFIG_DEFAULT_DEVICE_TREE. This meant that, regardless of the DT chosen by SPL (either by changing the header in the image or by the selection code at runtime), Linux always used the default DT.By using the name from the SPL header (which, because of the previous commit, always matches the DT used by U-Boot proper), Linux also sees the same board as U-Boot/SPL, even if the boot script later loads a DT from disk.
I strongly frown upon proliferating the broken way of explicitly loading a DT from somewhere, when the DT embedded in U-Boot should be all we will ever need.
But making the selected DT available to U-Boot scripts doesn't really hurt or prevent us from doing it properly, so:
Quoted 1 line
Signed-off-by Samuel Holland <[email protected]>
One nit below, with that:
Cheers,
Andre
Quoted 17 lines
--- board/sunxi/board.c | 11 +++++++++++ 1 file changed, 11 insertions(+)board/sunxi/board.c +1
-0@@ -870,6 +870,7 @@ static void setup_environment(const void *fdt)int misc_init_r (void ) { +const char *spl_dt_name;uint boot;env_set ("fel_booted" ,NULL );
board/sunxi/board.c int misc_init_r(void) · line 896
Quoted 8 lines
board/sunxi/board.c +5
-0@@ -888,6 +889,16 @@ int misc_init_r(void)env_set ("mmc_bootdev" ,"1" ); } +/* Set fdtfile to match the FIT configuration chosen in SPL. */ + spl_dt_name =get_spl_dt_name (); +if (spl_dt_name) { +char *prefix =IS_ENABLED (CONFIG_ARM64 ) ?"allwinner/" :"" ; +char str[64 ];
The longest name (including the directory name) is 49 characters so far, so let's hope that people don't go crazy with their DT names. Shall we check the return value of snprintf() and at least complain? In contrast to strncpy(), snprintf() is safe, but might still truncate the name.
Cheers,
Andre.
Quoted 9 lines
board/sunxi/board.c +5
-0+ +snprintf (str,sizeof (str),"%s%s.dtb" , prefix, spl_dt_name); +env_set ("fdtfile" , str); + } +setup_environment (gd->fdt_blob);#ifdef CONFIG_USB_ETHER
Samuel Holland
maintainerPATCH 6/8 sunxi: board: Set fdtfile to match the DT chosen by SPL
Quoted 9 lines · Andr? Przywara
On 03/09/2020 06:07, Samuel Holland wrote:
Hi,
Quoted 5 lines
Previously, fdtfile was always the value in
CONFIG_DEFAULT_DEVICE_TREE. This meant that, regardless of the DT chosen by SPL (either by changing the header in the image or by the selection code at runtime), Linux always used the default DT.
Quoted 8 lines
Quoted 4 lines
By using the name from the SPL header (which, because of the previous commit, always matches the DT used by U-Boot proper), Linux also sees the same board as U-Boot/SPL, even if the boot script later loads a DT from disk.
I strongly frown upon proliferating the broken way of explicitly loading a DT from somewhere, when the DT embedded in U-Boot should be all we will ever need.
The embedded DT is only "all you ever need" if 1) your DT is 100% complete and accurate (ha, ha, ha) or 2) you re-flash U-Boot every time the device tree changes, which is risky and an unnecessary waste of flash memory write cycles.
Having a built-in DT that's always available and mostly works is quite useful, but complaining that distros and users want to update their DTs without patching, recompiling, and re-flashing U-Boot is frankly ridiculous. Especially considering that the U-Boot DTs are usually out of date, and users might not want to update the U-Boot code for various reasons.
Quoted 31 lines
But making the selected DT available to U-Boot scripts doesn't really hurt or prevent us from doing it properly, so:
Quoted 1 line
Signed-off-by Samuel Holland <[email protected]>One nit below, with that:
Reviewed-by Andre Przywara <[email protected]>Cheers,
AndreQuoted 20 lines
--- board/sunxi/board.c | 11 +++++++++++ 1 file changed, 11 insertions(+)board/sunxi/board.c +1
-0@@ -870,6 +870,7 @@ static void setup_environment(const void *fdt)int misc_init_r (void ) { +const char *spl_dt_name;uint boot;env_set ("fel_booted" ,NULL );@@ -888,6 +889,16 @@ int misc_init_r(void)env_set ("mmc_bootdev" ,"1" ); }
Quoted 10 lines
board/sunxi/board.c int misc_init_r(void) · line 896
Quoted 5 lines
board/sunxi/board.c +5
-0+/* Set fdtfile to match the FIT configuration chosen in SPL. */ + spl_dt_name =get_spl_dt_name (); +if (spl_dt_name) { +char *prefix =IS_ENABLED (CONFIG_ARM64 ) ?"allwinner/" :"" ; +char str[64 ];The longest name (including the directory name) is 49 characters so far, so let's hope that people don't go crazy with their DT names. Shall we check the return value of
snprintf()and at least complain? In contrast tostrncpy(),snprintf()is safe, but might still truncate the name.
What kind of complaint were you thinking of? Trying to actually use a truncated $fdtfile would produce a "file not found" error. Maybe that would be obvious enough?
Cheers,
Samuel
Quoted 13 lines
Cheers,
Andre.Quoted 9 lines
board/sunxi/board.c +5
-0+ +snprintf (str,sizeof (str),"%s%s.dtb" , prefix, spl_dt_name); +env_set ("fdtfile" , str); + } +setup_environment (gd->fdt_blob);#ifdef CONFIG_USB_ETHER
PATCH 6/8 sunxi: board: Set fdtfile to match the DT chosen by SPL
Quoted 15 lines · Samuel Holland
Quoted 14 lines · Andr? Przywara
On 03/09/2020 06:07, Samuel Holland wrote:
Hi,
Quoted 9 lines
Previously, fdtfile was always the value in
CONFIG_DEFAULT_DEVICE_TREE. This meant that, regardless of the DT chosen by SPL (either by changing the header in the image or by the selection code at runtime), Linux always used the default DT.By using the name from the SPL header (which, because of the previous commit, always matches the DT used by U-Boot proper), Linux also sees the same board as U-Boot/SPL, even if the boot script later loads a DT from disk.
Quoted 7 lines
Quoted 3 lines
I strongly frown upon proliferating the broken way of explicitly loading a DT from somewhere, when the DT embedded in U-Boot should be all we will ever need.
The embedded DT is only "all you ever need" if 1) your DT is 100% complete and accurate (ha, ha, ha) or 2) you re-flash U-Boot every time the device tree changes, which is risky and an unnecessary waste of flash memory write cycles.
Ideally it doesn't change that often, and I don't see how a DT update on a filesystem would be different when it comes to flash tear and wear. Either U-Boot and the boot FS live on the very same (NAND flash) based media (eMMC), or U-Boot lives on NOR flash, which has a much greater number of write cycles.
Quoted 5 lines
Having a built-in DT that's always available and mostly works is quite useful, but complaining that distros and users want to update their DTs without patching, recompiling, and re-flashing U-Boot is frankly ridiculous. Especially considering that the U-Boot DTs are usually out of date, and users might not want to update the U-Boot code for various reasons.
You have a point here: U-Boot updates are typically more tedious and more risky. If it just comes to a DT update, this could actually be done without compiling U-Boot, though, by re-packing the FIT image.
The more general problem is that you rely on your distributions to ship your board's DT. In the embedded world, where distribution means "some image specifically compiled for this particular board", this isn't a problem. But for more generic distributions, or OSes outside of Linux, it can become quite tedious to collect all possible DTs. Also for instance Linux 5.7 or 5.8 don't carry the Pinephone-1.2 DTS, even though the code is perfectly able to handle this revision.
Quoted 42 lines
Quoted 31 lines
But making the selected DT available to U-Boot scripts doesn't really hurt or prevent us from doing it properly, so:
Quoted 1 line
Signed-off-by Samuel Holland <[email protected]>One nit below, with that:
Reviewed-by Andre Przywara <[email protected]>Cheers,
AndreQuoted 20 lines
--- board/sunxi/board.c | 11 +++++++++++ 1 file changed, 11 insertions(+)board/sunxi/board.c +1
-0@@ -870,6 +870,7 @@ static void setup_environment(const void *fdt)int misc_init_r (void ) { +const char *spl_dt_name;uint boot;env_set ("fel_booted" ,NULL );@@ -888,6 +889,16 @@ int misc_init_r(void)env_set ("mmc_bootdev" ,"1" ); }Quoted 10 lines
board/sunxi/board.c int misc_init_r(void) · line 896
Quoted 5 lines
board/sunxi/board.c +5
-0+/* Set fdtfile to match the FIT configuration chosen in SPL. */ + spl_dt_name =get_spl_dt_name (); +if (spl_dt_name) { +char *prefix =IS_ENABLED (CONFIG_ARM64 ) ?"allwinner/" :"" ; +char str[64 ];The longest name (including the directory name) is 49 characters so far, so let's hope that people don't go crazy with their DT names. Shall we check the return value of
snprintf()and at least complain? In contrast tostrncpy(),snprintf()is safe, but might still truncate the name.
Quoted 2 lines
What kind of complaint were you thinking of? Trying to actually use a truncated $fdtfile would produce a "file not found" error. Maybe that would be obvious enough?
True, that should be good enough.
Cheers,
Andre
Quoted 11 lines
Quoted 10 lines
board/sunxi/board.c int misc_init_r(void) · line 904
Quoted 9 lines
board/sunxi/board.c +5
-0+ +snprintf (str,sizeof (str),"%s%s.dtb" , prefix, spl_dt_name); +env_set ("fdtfile" , str); + } +setup_environment (gd->fdt_blob);#ifdef CONFIG_USB_ETHER
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Samuel Holland
maintainerPATCH 7/8 sunxi: DT: A64: update device tree files
In reply to Samuel HollandImport updated device trees from Linux v5.9-rc3. This picks up new hardware (PinePhone, PineTab); and it drops the U-Boot specific DTSI files for the Pinebook and the Teres-I, since the ANX6345 bridge is now supported upstream.
A couple of headers needed updates for recently-added hardware support.
--- arch/arm/dts/Makefile | 4 + arch/arm/dts/axp803.dtsi | 82 +-- arch/arm/dts/sun50i-a64-amarula-relic.dts | 109 +++- arch/arm/dts/sun50i-a64-bananapi-m64.dts | 118 ++-- arch/arm/dts/sun50i-a64-cpu-opp.dtsi | 75 +++ arch/arm/dts/sun50i-a64-nanopi-a64.dts | 70 +-- .../dts/sun50i-a64-oceanic-5205-5inmfd.dts | 31 +- arch/arm/dts/sun50i-a64-olinuxino-emmc.dts | 12 +- arch/arm/dts/sun50i-a64-olinuxino.dts | 113 ++-- arch/arm/dts/sun50i-a64-orangepi-win.dts | 127 +++-- arch/arm/dts/sun50i-a64-pine64-lts.dts | 7 +- arch/arm/dts/sun50i-a64-pine64-plus.dts | 52 +- arch/arm/dts/sun50i-a64-pine64.dts | 97 ++-- arch/arm/dts/sun50i-a64-pinebook-u-boot.dtsi | 17 - arch/arm/dts/sun50i-a64-pinebook.dts | 237 ++++++-- arch/arm/dts/sun50i-a64-pinephone-1.0.dts | 11 + arch/arm/dts/sun50i-a64-pinephone-1.1.dts | 30 + arch/arm/dts/sun50i-a64-pinephone-1.2.dts | 40 ++ arch/arm/dts/sun50i-a64-pinephone.dtsi | 429 ++++++++++++++ arch/arm/dts/sun50i-a64-pinetab.dts | 460 +++++++++++++++ arch/arm/dts/sun50i-a64-sopine-baseboard.dts | 113 ++-- arch/arm/dts/sun50i-a64-sopine.dtsi | 69 +-- arch/arm/dts/sun50i-a64-teres-i-u-boot.dtsi | 41 -- arch/arm/dts/sun50i-a64-teres-i.dts | 138 ++++- arch/arm/dts/sun50i-a64.dtsi | 532 ++++++++++++++---- include/dt-bindings/clock/sun50i-a64-ccu.h | 4 +- include/dt-bindings/clock/sun8i-de2.h | 3 + include/dt-bindings/reset/sun8i-de2.h | 1 + 28 files changed, 2390 insertions(+), 632 deletions(-) create mode 100644 arch/arm/dts/sun50i-a64-cpu-opp.dtsi delete mode 100644 arch/arm/dts/sun50i-a64-pinebook-u-boot.dtsi create mode 100644 arch/arm/dts/sun50i-a64-pinephone-1.0.dts create mode 100644 arch/arm/dts/sun50i-a64-pinephone-1.1.dts create mode 100644 arch/arm/dts/sun50i-a64-pinephone-1.2.dts create mode 100644 arch/arm/dts/sun50i-a64-pinephone.dtsi create mode 100644 arch/arm/dts/sun50i-a64-pinetab.dts delete mode 100644 arch/arm/dts/sun50i-a64-teres-i-u-boot.dtsi
arch/arm/dts/Makefile +4 -0
@@ -608,6 +608,10 @@ dtb-$(CONFIG_MACH_SUN50I) += \ sun50i-a64-pine64-plus.dtb \ sun50i-a64-pine64.dtb \ sun50i-a64-pinebook.dtb \ + sun50i-a64-pinephone-1.0.dtb \ + sun50i-a64-pinephone-1.1.dtb \ + sun50i-a64-pinephone-1.2.dtb \ + sun50i-a64-pinetab.dtb \ sun50i-a64-sopine-baseboard.dtb \ sun50i-a64-teres-i.dtb dtb-$(CONFIG_MACH_SUN9I) += \
arch/arm/dts/axp803.dtsi +41 -41
95 lines not on this page · raw message
arch/arm/dts/sun50i-a64-amarula-relic.dts +105 -4
139 lines not on this page · raw message
arch/arm/dts/sun50i-a64-bananapi-m64.dts +75 -43
167 lines not on this page · raw message
arch/arm/dts/sun50i-a64-cpu-opp.dtsi new file +75 -0
75 lines not on this page · raw message
arch/arm/dts/sun50i-a64-nanopi-a64.dts +23 -47
95 lines not on this page · raw message
arch/arm/dts/sun50i-a64-oceanic-5205-5inmfd.dts +26 -5
@@ -1,9 +1,7 @@ // SPDX-License-Identifier: (GPL-2.0+ OR MIT) -/* - * Copyright (C) 2019 Oceanic Systems (UK) Ltd. - * Copyright (C) 2019 Amarula Solutions B.V. - * Author: Jagan Teki <[email protected]> - */ +// Copyright (C) 2019 Oceanic Systems (UK) Ltd. +// Copyright (C) 2019 Amarula Solutions B.V. +// Author: Jagan Teki <[email protected]> /dts-v1/;
@@ -37,6 +35,22 @@ status = "okay"; }; +&i2c0 { + status = "okay"; + + touchscreen at 5d { + compatible = "goodix,gt911"; + reg = <0x5d>; + AVDD28-supply = <®_ldo_io0>; /* VDD_CTP: GPIO0-LDO */ + interrupt-parent = <&pio>; + interrupts = <7 4 IRQ_TYPE_EDGE_FALLING>; + irq-gpios = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* CTP-INT: PH4 */ + reset-gpios = <&pio 7 11 GPIO_ACTIVE_HIGH>; /* CTP-RST: PH11 */ + touchscreen-inverted-x; + touchscreen-inverted-y; + }; +}; + &mdio { ext_rgmii_phy: ethernet-phy at 1 { compatible = "ethernet-phy-ieee802.3-c22";
@@ -52,6 +66,13 @@ regulator-name = "vcc-phy"; }; +®_ldo_io0 { + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + regulator-name = "vdd-ctp"; + status = "okay"; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_pb_pins>;
arch/arm/dts/sun50i-a64-olinuxino-emmc.dts +7 -5
@@ -1,8 +1,6 @@ // SPDX-License-Identifier: (GPL-2.0+ OR MIT) -/* - * Copyright (C) 2018 Martin Ayotte <[email protected]> - * Copyright (C) 2019 Sunil Mohan Adapa <[email protected]> - */ +// Copyright (C) 2018 Martin Ayotte <[email protected]> +// Copyright (C) 2019 Sunil Mohan Adapa <[email protected]> #include "sun50i-a64-olinuxino.dts"
@@ -15,9 +13,13 @@ pinctrl-names = "default"; pinctrl-0 = <&mmc2_pins>; vmmc-supply = <®_dcdc1>; - vqmmc-supply = <®_dcdc1>; + vqmmc-supply = <®_eldo1>; bus-width = <8>; non-removable; cap-mmc-hw-reset; status = "okay"; }; + +&pio { + vcc-pc-supply = <®_eldo1>; +};
arch/arm/dts/sun50i-a64-olinuxino.dts +71 -42
152 lines not on this page · raw message
arch/arm/dts/sun50i-a64-orangepi-win.dts +85 -42
179 lines not on this page · raw message
arch/arm/dts/sun50i-a64-pine64-lts.dts +2 -5
@@ -1,8 +1,5 @@ -/* - * SPDX-License-Identifier: (GPL-2.0+ OR MIT) - * - * Copyright (c) 2018 ARM Ltd. - */ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +// Copyright (c) 2018 ARM Ltd. #include "sun50i-a64-sopine-baseboard.dts"
arch/arm/dts/sun50i-a64-pine64-plus.dts +11 -41
58 lines not on this page · raw message
arch/arm/dts/sun50i-a64-pine64.dts +54 -43
128 lines not on this page · raw message
arch/arm/dts/sun50i-a64-pinebook-u-boot.dtsi deleted +0 -17
@@ -1,17 +0,0 @@ -// SPDX-License-Identifier: (GPL-2.0+ OR MIT) -/* - * Copyright (C) 2018 Vasily Khoruzhick <[email protected]> - * - */ - -#include "sunxi-u-boot.dtsi" - -/* The ANX6345 eDP-bridge is on r_i2c */ -&r_i2c { - anx6345: edp-bridge at 38 { - compatible = "analogix,anx6345"; - reg = <0x38>; - reset-gpios = <&pio 3 24 GPIO_ACTIVE_LOW>; /* PD24 */ - status = "okay"; - }; -};
arch/arm/dts/sun50i-a64-pinebook.dts +181 -56
341 lines not on this page · raw message
arch/arm/dts/sun50i-a64-pinephone-1.0.dts new file +11 -0
@@ -0,0 +1,11 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +// Copyright (C) 2020 Ondrej Jirman <[email protected]> + +/dts-v1/; + +#include "sun50i-a64-pinephone.dtsi" + +/ { + model = "Pine64 PinePhone Developer Batch (1.0)"; + compatible = "pine64,pinephone-1.0", "allwinner,sun50i-a64"; +};
arch/arm/dts/sun50i-a64-pinephone-1.1.dts new file +30 -0
@@ -0,0 +1,30 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +// Copyright (C) 2020 Ondrej Jirman <[email protected]> + +/dts-v1/; + +#include "sun50i-a64-pinephone.dtsi" + +/ { + model = "Pine64 PinePhone Braveheart (1.1)"; + compatible = "pine64,pinephone-1.1", "allwinner,sun50i-a64"; +}; + +&backlight { + power-supply = <®_ldo_io0>; + /* + * PWM backlight circuit on this PinePhone revision was changed since + * 1.0, and the lowest PWM duty cycle that doesn't lead to backlight + * being off is around 20%. Duty cycle for the lowest brightness level + * also varries quite a bit between individual boards, so the lowest + * value here was chosen as a safe default. + */ + brightness-levels = < + 774 793 814 842 + 882 935 1003 1088 + 1192 1316 1462 1633 + 1830 2054 2309 2596 + 2916 3271 3664 4096>; + num-interpolated-steps = <50>; + default-brightness-level = <400>; +};
arch/arm/dts/sun50i-a64-pinephone-1.2.dts new file +40 -0
@@ -0,0 +1,40 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +// Copyright (C) 2020 Ondrej Jirman <[email protected]> + +/dts-v1/; + +#include "sun50i-a64-pinephone.dtsi" + +/ { + model = "Pine64 PinePhone (1.2)"; + compatible = "pine64,pinephone-1.2", "allwinner,sun50i-a64"; +}; + +&backlight { + power-supply = <®_ldo_io0>; + /* + * PWM backlight circuit on this PinePhone revision was changed since 1.0, + * and the lowest PWM duty cycle that doesn't lead to backlight being off + * is around 10%. Duty cycle for the lowest brightness level also varries + * quite a bit between individual boards, so the lowest value here was + * chosen as a safe default. + */ + brightness-levels = < + 5000 5248 5506 5858 6345 + 6987 7805 8823 10062 11543 + 13287 15317 17654 20319 23336 + 26724 30505 34702 39335 44427 + 50000 + >; + num-interpolated-steps = <50>; + default-brightness-level = <500>; +}; + +&lis3mdl { + /* + * Board revision 1.2 fixed routing of the interrupt to DRDY pin, + * enable interrupts. + */ + interrupt-parent = <&pio>; + interrupts = <1 1 IRQ_TYPE_EDGE_RISING>; /* PB1 */ +};
arch/arm/dts/sun50i-a64-pinephone.dtsi new file +429 -0
429 lines not on this page · raw message
arch/arm/dts/sun50i-a64-pinetab.dts new file +460 -0
460 lines not on this page · raw message
arch/arm/dts/sun50i-a64-sopine-baseboard.dts +69 -44
146 lines not on this page · raw message
arch/arm/dts/sun50i-a64-sopine.dtsi +25 -44
77 lines not on this page · raw message
arch/arm/dts/sun50i-a64-teres-i-u-boot.dtsi deleted +0 -41
41 lines not on this page · raw message
arch/arm/dts/sun50i-a64-teres-i.dts +125 -13
189 lines not on this page · raw message
arch/arm/dts/sun50i-a64.dtsi +434 -98
40 lines not on this page · raw message
include/dt-bindings/clock/sun50i-a64-ccu.h +3 -1
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.26.2
Part of the diff is not shown here. View the raw message.
Samuel Holland
maintainerPATCH 8/8 sunxi: a64: Add a defconfig for the PinePhone
In reply to Samuel HollandThe PinePhone is a smartphone produced by Pine64, with an A64 SoC, 2 or 3 GiB LPDDR3 RAM, 16 or 32 GiB eMMC, 720x1440 MIPI-DSI panel, and Quectel EG25-G modem.
There are two main board revisions: 1.1 for early adopters, and 1.2 for mass production. Since there is code to detect the board revision at boot, one config/image can support both boards.
--- configs/pinephone_defconfig | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 configs/pinephone_defconfig
configs/pinephone_defconfig new file +12 -0
@@ -0,0 +1,12 @@ +CONFIG_ARM=y +CONFIG_ARCH_SUNXI=y +CONFIG_SPL=y +CONFIG_MACH_SUN50I=y +CONFIG_SUNXI_DRAM_LPDDR3_STOCK=y +CONFIG_DRAM_CLK=552 +CONFIG_DRAM_ZQ=3881949 +CONFIG_MMC_SUNXI_SLOT_EXTRA=2 +CONFIG_PINEPHONE_DT_SELECTION=y +# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pinephone-1.2" +CONFIG_OF_LIST="sun50i-a64-pinephone-1.1 sun50i-a64-pinephone-1.2"
Signature · 1 line
2.26.2
cover PinePhone automatic device tree selection
In reply to Samuel HollandHi,
Quoted 7 lines · Samuel Holland
All,
This patch series implements a feature to automatically choose the right PinePhone device tree by probing the hardware. It then extends the functionality to pass the chosen DTB name to the boot command. Finally, I add device trees and a defconfig for the PinePhone.
Quoted 7 lines
I'm aware that Andre has concerns about updating the device tree files. It would be unfortunate for this to block new hardware support. Since the device trees are primarily maintained in the Linux repository, and only copied here, I believe compatibility concerns should be directed there, not here. In any case, the first 6 patches can be merged independently, so I request that they be merged even if patches 7-8 are not. I am mainly including the last two patches for ease of testing.
It looks great to me, thanks!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200903/a573b906/attachment.sig>
cover PinePhone automatic device tree selection
In reply to Samuel HollandOn 03/09/2020 06:07, Samuel Holland wrote:
Hi Samuel,
Quoted 7 lines
This patch series implements a feature to automatically choose the right PinePhone device tree by probing the hardware. It then extends the functionality to pass the chosen DTB name to the boot command. Finally, I add device trees and a defconfig for the PinePhone.
I'm aware that Andre has concerns about updating the device tree files. It would be unfortunate for this to block new hardware support.
I agree that it shouldn't block it.
Quoted 4 lines
Since
the device trees are primarily maintained in the Linux repository, and only copied here, I believe compatibility concerns should be directed there, not here.
Sigh. I tried that there, multiple times, and was basically dismissed. IIRC the main argument was that we (as the sunxi community) do not have the resources to pull off something like compatible DTs. The DTs are being created and written as we go, so maintaining forward compatibility is not something the Linux maintainers wanted to subscribe to. And while I see that's *some* extra effort, I argued that it's worth it, even providing solutions. Otherwise I am afraid that we end up in the embedded rabbit hole that we see today, where dozens of images are traded around, even though there are generic distributions available.
We parted by agreeing on putting those necessary DT changes into U-Boot instead. Commit ababb5920e899 is one example of this. I tried to prevent further changes, but failed.
Quoted 3 lines
In any case, the first 6 patches can be merged independently, so I request that they be merged even if patches 7-8 are not. I am mainly including the last two patches for ease of testing.
So I have some easy patches that improve DT compatibility, I guess we can just apply them later. The most prominent issue is the change of the RTC compatible name. This seems to cost us the RTC (bearable?) and, in turn, the debouncing feature of the GPIO controller (through the newly introduced clock in the RTC).
There seem to be more issues that popped up in testing. I guess we would need to define some supported kernels, and test them. The effort for this depends on how far back we want to support Linux kernels and with what feature set. I ran a headless board fine here with Ubuntu's 18.04 original kernel, which is 4.15 based. I might concede to give this up, if needed, to go back to only 4.19 (Debian), or maybe 4.18 (Ubuntu 18.04.2 HWE kernel).
I will have a look at the other patches later. It seems like you jump through some hoops to be able to set fdtfile in U-Boot proper later? I consider this conceptually dodgy ($fdtcontroladdr should be all you need), but don't care enough, as it does not seem to break things.
Cheers,
Andre
Quoted 52 lines
Samuel Holland (8):
sunxi: board: Use a more descriptive variable name
sunxi: board: Add a helper to get the SPL DT name
sunxi: board: Simplify Pine A64 DT selection logic
sunxi: board: Add PinePhone DT selection logic
sunxi: board: Save the chosen DT name in the SPL header
sunxi: board: Set fdtfile to match the DT chosen by SPL
sunxi: DT: A64: update device tree files
sunxi: a64: Add a defconfig for the PinePhonearch/arm/dts/Makefile | 4 + arch/arm/dts/axp803.dtsi | 82 +-- arch/arm/dts/sun50i-a64-amarula-relic.dts | 109 +++- arch/arm/dts/sun50i-a64-bananapi-m64.dts | 118 ++-- arch/arm/dts/sun50i-a64-cpu-opp.dtsi | 75 +++ arch/arm/dts/sun50i-a64-nanopi-a64.dts | 70 +-- .../dts/sun50i-a64-oceanic-5205-5inmfd.dts | 31 +- arch/arm/dts/sun50i-a64-olinuxino-emmc.dts | 12 +- arch/arm/dts/sun50i-a64-olinuxino.dts | 113 ++-- arch/arm/dts/sun50i-a64-orangepi-win.dts | 127 +++-- arch/arm/dts/sun50i-a64-pine64-lts.dts | 7 +- arch/arm/dts/sun50i-a64-pine64-plus.dts | 52 +- arch/arm/dts/sun50i-a64-pine64.dts | 97 ++-- arch/arm/dts/sun50i-a64-pinebook-u-boot.dtsi | 17 - arch/arm/dts/sun50i-a64-pinebook.dts | 237 ++++++-- arch/arm/dts/sun50i-a64-pinephone-1.0.dts | 11 + arch/arm/dts/sun50i-a64-pinephone-1.1.dts | 30 + arch/arm/dts/sun50i-a64-pinephone-1.2.dts | 40 ++ arch/arm/dts/sun50i-a64-pinephone.dtsi | 429 ++++++++++++++ arch/arm/dts/sun50i-a64-pinetab.dts | 460 +++++++++++++++ arch/arm/dts/sun50i-a64-sopine-baseboard.dts | 113 ++-- arch/arm/dts/sun50i-a64-sopine.dtsi | 69 +-- arch/arm/dts/sun50i-a64-teres-i-u-boot.dtsi | 41 -- arch/arm/dts/sun50i-a64-teres-i.dts | 138 ++++- arch/arm/dts/sun50i-a64.dtsi | 532 ++++++++++++++---- arch/arm/mach-sunxi/Kconfig | 7 + board/sunxi/board.c | 97 +++- configs/pinephone_defconfig | 12 + include/dt-bindings/clock/sun50i-a64-ccu.h | 4 +- include/dt-bindings/clock/sun8i-de2.h | 3 + include/dt-bindings/reset/sun8i-de2.h | 1 + 31 files changed, 2488 insertions(+), 650 deletions(-) create mode 100644 arch/arm/dts/sun50i-a64-cpu-opp.dtsi delete mode 100644 arch/arm/dts/sun50i-a64-pinebook-u-boot.dtsi create mode 100644 arch/arm/dts/sun50i-a64-pinephone-1.0.dts create mode 100644 arch/arm/dts/sun50i-a64-pinephone-1.1.dts create mode 100644 arch/arm/dts/sun50i-a64-pinephone-1.2.dts create mode 100644 arch/arm/dts/sun50i-a64-pinephone.dtsi create mode 100644 arch/arm/dts/sun50i-a64-pinetab.dts delete mode 100644 arch/arm/dts/sun50i-a64-teres-i-u-boot.dtsi create mode 100644 configs/pinephone_defconfig
cover PinePhone automatic device tree selection
Quoted 38 lines · Andr? Przywara
On 03/09/2020 06:07, Samuel Holland wrote:
Hi Samuel,
Quoted 7 lines
This patch series implements a feature to automatically choose the right PinePhone device tree by probing the hardware. It then extends the functionality to pass the chosen DTB name to the boot command. Finally, I add device trees and a defconfig for the PinePhone.
I'm aware that Andre has concerns about updating the device tree files. It would be unfortunate for this to block new hardware support.
I agree that it shouldn't block it.
Quoted 4 lines
Since
the device trees are primarily maintained in the Linux repository, and only copied here, I believe compatibility concerns should be directed there, not here.Sigh. I tried that there, multiple times, and was basically dismissed. IIRC the main argument was that we (as the sunxi community) do not have the resources to pull off something like compatible DTs. The DTs are being created and written as we go, so maintaining forward compatibility is not something the Linux maintainers wanted to subscribe to. And while I see that's *some* extra effort, I argued that it's worth it, even providing solutions. Otherwise I am afraid that we end up in the embedded rabbit hole that we see today, where dozens of images are traded around, even though there are generic distributions available.
We parted by agreeing on putting those necessary DT changes into U-Boot instead. Commit
ababb5920e899is one example of this. I tried to prevent further changes, but failed.Quoted 3 lines
In any case, the first 6 patches can be merged independently, so I request that they be merged even if patches 7-8 are not. I am mainly including the last two patches for ease of testing.
Quoted 5 lines
So I have some easy patches that improve DT compatibility, I guess we can just apply them later. The most prominent issue is the change of the RTC compatible name. This seems to cost us the RTC (bearable?) and, in turn, the debouncing feature of the GPIO controller (through the newly introduced clock in the RTC).
Can those fixes go into -u-boot.dtsi files, that would then make syncing with upstream easier while having less chances to regress the compatibility.
Quoted 7 lines
There seem to be more issues that popped up in testing. I guess we would need to define some supported kernels, and test them. The effort for this depends on how far back we want to support Linux kernels and with what feature set. I ran a headless board fine here with Ubuntu's 18.04 original kernel, which is 4.15 based. I might concede to give this up, if needed, to go back to only 4.19 (Debian), or maybe 4.18 (Ubuntu 18.04.2 HWE kernel).
I feel it should be the people that want to run newer U-Boot on those older releases with older kernels to do the work. In reality what is the actual demand for those use cases?
Quoted 61 lines
I will have a look at the other patches later. It seems like you jump through some hoops to be able to set fdtfile in U-Boot proper later? I consider this conceptually dodgy ($fdtcontroladdr should be all you need), but don't care enough, as it does not seem to break things.
Cheers,
AndreQuoted 52 lines
Samuel Holland (8):
sunxi: board: Use a more descriptive variable name
sunxi: board: Add a helper to get the SPL DT name
sunxi: board: Simplify Pine A64 DT selection logic
sunxi: board: Add PinePhone DT selection logic
sunxi: board: Save the chosen DT name in the SPL header
sunxi: board: Set fdtfile to match the DT chosen by SPL
sunxi: DT: A64: update device tree files
sunxi: a64: Add a defconfig for the PinePhonearch/arm/dts/Makefile | 4 + arch/arm/dts/axp803.dtsi | 82 +-- arch/arm/dts/sun50i-a64-amarula-relic.dts | 109 +++- arch/arm/dts/sun50i-a64-bananapi-m64.dts | 118 ++-- arch/arm/dts/sun50i-a64-cpu-opp.dtsi | 75 +++ arch/arm/dts/sun50i-a64-nanopi-a64.dts | 70 +-- .../dts/sun50i-a64-oceanic-5205-5inmfd.dts | 31 +- arch/arm/dts/sun50i-a64-olinuxino-emmc.dts | 12 +- arch/arm/dts/sun50i-a64-olinuxino.dts | 113 ++-- arch/arm/dts/sun50i-a64-orangepi-win.dts | 127 +++-- arch/arm/dts/sun50i-a64-pine64-lts.dts | 7 +- arch/arm/dts/sun50i-a64-pine64-plus.dts | 52 +- arch/arm/dts/sun50i-a64-pine64.dts | 97 ++-- arch/arm/dts/sun50i-a64-pinebook-u-boot.dtsi | 17 - arch/arm/dts/sun50i-a64-pinebook.dts | 237 ++++++-- arch/arm/dts/sun50i-a64-pinephone-1.0.dts | 11 + arch/arm/dts/sun50i-a64-pinephone-1.1.dts | 30 + arch/arm/dts/sun50i-a64-pinephone-1.2.dts | 40 ++ arch/arm/dts/sun50i-a64-pinephone.dtsi | 429 ++++++++++++++ arch/arm/dts/sun50i-a64-pinetab.dts | 460 +++++++++++++++ arch/arm/dts/sun50i-a64-sopine-baseboard.dts | 113 ++-- arch/arm/dts/sun50i-a64-sopine.dtsi | 69 +-- arch/arm/dts/sun50i-a64-teres-i-u-boot.dtsi | 41 -- arch/arm/dts/sun50i-a64-teres-i.dts | 138 ++++- arch/arm/dts/sun50i-a64.dtsi | 532 ++++++++++++++---- arch/arm/mach-sunxi/Kconfig | 7 + board/sunxi/board.c | 97 +++- configs/pinephone_defconfig | 12 + include/dt-bindings/clock/sun50i-a64-ccu.h | 4 +- include/dt-bindings/clock/sun8i-de2.h | 3 + include/dt-bindings/reset/sun8i-de2.h | 1 + 31 files changed, 2488 insertions(+), 650 deletions(-) create mode 100644 arch/arm/dts/sun50i-a64-cpu-opp.dtsi delete mode 100644 arch/arm/dts/sun50i-a64-pinebook-u-boot.dtsi create mode 100644 arch/arm/dts/sun50i-a64-pinephone-1.0.dts create mode 100644 arch/arm/dts/sun50i-a64-pinephone-1.1.dts create mode 100644 arch/arm/dts/sun50i-a64-pinephone-1.2.dts create mode 100644 arch/arm/dts/sun50i-a64-pinephone.dtsi create mode 100644 arch/arm/dts/sun50i-a64-pinetab.dts delete mode 100644 arch/arm/dts/sun50i-a64-teres-i-u-boot.dtsi create mode 100644 configs/pinephone_defconfig
cover PinePhone automatic device tree selection
In reply to Samuel HollandQuoted 16 lines · Samuel Holland
All,
This patch series implements a feature to automatically choose the right PinePhone device tree by probing the hardware. It then extends the functionality to pass the chosen DTB name to the boot command. Finally, I add device trees and a defconfig for the PinePhone.
I'm aware that Andre has concerns about updating the device tree files. It would be unfortunate for this to block new hardware support. Since the device trees are primarily maintained in the Linux repository, and only copied here, I believe compatibility concerns should be directed there, not here. In any case, the first 6 patches can be merged independently, so I request that they be merged even if patches 7-8 are not. I am mainly including the last two patches for ease of testing.
Quoted 9 lines
Samuel Holland (8):
sunxi: board: Use a more descriptive variable name
sunxi: board: Add a helper to get the SPL DT name
sunxi: board: Simplify Pine A64 DT selection logic
sunxi: board: Add PinePhone DT selection logic
sunxi: board: Save the chosen DT name in the SPL header
sunxi: board: Set fdtfile to match the DT chosen by SPL
sunxi: DT: A64: update device tree files
sunxi: a64: Add a defconfig for the PinePhone
I can see some comments from Andre, please fix and send next version.
Jagan.