arm64: sun50i: Add support for Orange Pi 3
Subsystems (3)
v3 cover arm64: sun50i: Add support for Orange Pi 3
Changes since v2:
* drop "sunxi: board: Use eth_env_set_enetaddr_by_index()" as it breaks compilation without CONFIG_NET
* add "sunxi: board: extract creating a unique sid into a helper function" and use it for the the bdaddr so that it work without ethernet devices
* use if (CONFIG_FIXUP_BDADDR[0]) as suggested by Ondřej to give the compiler a better chance of discarding the function if the knob isn't set
Changes since v1:
* add CONFIG_FIXUP_BDADDR so fixing up a bdaddr is reusable
* try to use "bdaddr" first, then fall back to generating an address
Notes:
* the kernel patch for btbcm to accept the "local-bd-address" property is on master and will be in v5.5-rc1
Andre Heider (4):
sunxi: board: extract creating a unique sid into a helper function
arm: sunxi: add a config option to fixup a Bluetooth address
arm64: dts: sync Allwinner H6 files
arm64: dts: sun50i: Add support for Orange Pi 3
arch/arm/dts/Makefile | 1 + arch/arm/dts/sun50i-h6-beelink-gs1.dts | 27 +++ arch/arm/dts/sun50i-h6-orangepi-3.dts | 287 +++++++++++++++++++++++++ arch/arm/dts/sun50i-h6-orangepi.dtsi | 4 + arch/arm/dts/sun50i-h6-pine-h64.dts | 4 + arch/arm/dts/sun50i-h6.dtsi | 137 ++++++++++-- arch/arm/mach-sunxi/Kconfig | 11 + board/sunxi/MAINTAINERS | 5 + board/sunxi/board.c | 139 ++++++++---- configs/orangepi_3_defconfig | 18 ++ 10 files changed, 569 insertions(+), 64 deletions(-) create mode 100644 arch/arm/dts/sun50i-h6-orangepi-3.dts create mode 100644 configs/orangepi_3_defconfig
Signature · 1 line
2.24.0
PATCH v3 1/4 sunxi: board: extract creating a unique sid into a helper function
--- board/sunxi/board.c | 105 ++++++++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 47 deletions(-)
board/sunxi/board.c +58 -47
@@ -768,6 +768,38 @@ static void parse_spl_header(const uint32_t spl_addr)env_set_hex ("fel_scriptaddr" , spl->fel_script_address); } +static bool get_unique_sid (unsigned int *sid) +{ +if (sunxi_get_sid (sid) !=0 ) +return false; + +if (!sid[0 ]) +return false; + +/* +* The single words 1 - 3 of the SID have quite a few bits +* which are the same on many models, so we take a crc32 +* of all 3 words, to get a more unique value. +* +* Note we only do this on newer SoCs as we cannot change +* the algorithm on older SoCs since those have been using +* fixed mac-addresses based on only using word 3 for a +* long time and changing a fixed mac-address with an +* u-boot update is not good. +*/ +#if !defined(CONFIG_MACH_SUN4I ) && !defined(CONFIG_MACH_SUN5I ) && \ + !defined(CONFIG_MACH_SUN6I ) && !defined(CONFIG_MACH_SUN7I ) && \ + !defined(CONFIG_MACH_SUN8I_A23 ) && !defined(CONFIG_MACH_SUN8I_A33 ) + sid[3 ] =crc32 (0 , (unsigned char *)&sid[1 ],12 ); +#endif + +/* Ensure the NIC specific bytes of the mac are not all 0 */ +if ((sid[3 ] &0xffffff ) ==0 ) + sid[3 ] |=0x800000 ; + +return true; +} +/* * Note this function gets called multiple times. * It must not make any changes to env variables which already exist.
@@ -778,61 +810,40 @@ static void setup_environment(const void *fdt)unsigned int sid[4 ];uint8_t mac_addr[6 ];char ethaddr[16 ]; -int i, ret; +int i; - ret =sunxi_get_sid (sid); -if (ret ==0 && sid[0 ] !=0 ) { -/* -* The single words 1 - 3 of the SID have quite a few bits -* which are the same on many models, so we take a crc32 -* of all 3 words, to get a more unique value. -* -* Note we only do this on newer SoCs as we cannot change -* the algorithm on older SoCs since those have been using -* fixed mac-addresses based on only using word 3 for a -* long time and changing a fixed mac-address with an -* u-boot update is not good. -*/ -#if !defined(CONFIG_MACH_SUN4I ) && !defined(CONFIG_MACH_SUN5I ) && \ - !defined(CONFIG_MACH_SUN6I ) && !defined(CONFIG_MACH_SUN7I ) && \ - !defined(CONFIG_MACH_SUN8I_A23 ) && !defined(CONFIG_MACH_SUN8I_A33 ) - sid[3 ] =crc32 (0 , (unsigned char *)&sid[1 ],12 ); -#endif - -/* Ensure the NIC specific bytes of the mac are not all 0 */ -if ((sid[3 ] &0xffffff ) ==0 ) - sid[3 ] |=0x800000 ; +if (!get_unique_sid (sid)) +return ; -for (i =0 ; i <4 ; i++) { -sprintf (ethaddr,"ethernet%d" , i); -if (!fdt_get_alias (fdt, ethaddr)) -continue ; +for (i =0 ; i <4 ; i++) { +sprintf (ethaddr,"ethernet%d" , i); +if (!fdt_get_alias (fdt, ethaddr)) +continue ; -if (i ==0 ) -strcpy (ethaddr,"ethaddr" ); -else -sprintf (ethaddr,"eth%daddr" , i); +if (i ==0 ) +strcpy (ethaddr,"ethaddr" ); +else +sprintf (ethaddr,"eth%daddr" , i); -if (env_get (ethaddr)) -continue ; +if (env_get (ethaddr)) +continue ; -/* Non OUI / registered MAC address */ - mac_addr[0 ] = (i <<4 ) |0x02 ; - mac_addr[1 ] = (sid[0 ] >>0 ) &0xff ; - mac_addr[2 ] = (sid[3 ] >>24 ) &0xff ; - mac_addr[3 ] = (sid[3 ] >>16 ) &0xff ; - mac_addr[4 ] = (sid[3 ] >>8 ) &0xff ; - mac_addr[5 ] = (sid[3 ] >>0 ) &0xff ; +/* Non OUI / registered MAC address */ + mac_addr[0 ] = (i <<4 ) |0x02 ; + mac_addr[1 ] = (sid[0 ] >>0 ) &0xff ; + mac_addr[2 ] = (sid[3 ] >>24 ) &0xff ; + mac_addr[3 ] = (sid[3 ] >>16 ) &0xff ; + mac_addr[4 ] = (sid[3 ] >>8 ) &0xff ; + mac_addr[5 ] = (sid[3 ] >>0 ) &0xff ; -eth_env_set_enetaddr (ethaddr, mac_addr); - } +eth_env_set_enetaddr (ethaddr, mac_addr); + } -if (!env_get ("serial#" )) { -snprintf (serial_string,sizeof (serial_string), -"%08x%08x" , sid[0 ], sid[3 ]); +if (!env_get ("serial#" )) { +snprintf (serial_string,sizeof (serial_string), +"%08x%08x" , sid[0 ], sid[3 ]); -env_set ("serial#" , serial_string); - } +env_set ("serial#" , serial_string); } }
Signature · 1 line
2.24.0
PATCH v3 1/4 sunxi: board: extract creating a unique sid into a helper function
Quoted 3 lines · Andre Heider
Signed-off-by Andre Heider <[email protected]>---
Please add commit message, it looks hard to get what this patch is doing?
PATCH v3 2/4 arm: sunxi: add a config option to fixup a Bluetooth address
In reply to Andre HeiderSome Bluetooth controllers, like the BCM4345C5 of the Orange Pi 3, ship with the controller default address.
Add a config option to fix it up so it can function properly.
--- arch/arm/mach-sunxi/Kconfig | 11 +++++++++++ board/sunxi/board.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
arch/arm/mach-sunxi/Kconfig +11 -0
@@ -1009,4 +1009,15 @@ config PINE64_DT_SELECTION option, the device tree selection code specific to Pine64 which utilizes the DRAM size will be enabled. +config FIXUP_BDADDR + string "Fixup the Bluetooth controller address" + default "" + help + This option specifies the DT compatible name of the Bluetooth + controller for which to set the "local-bd-address" property. + Set this option if your device ships with the Bluetooth controller + default address. + The used address is "bdaddr" if set, and "ethaddr" with the LSB + flipped elsewise. + endif
board/sunxi/board.c +34 -0
@@ -876,6 +876,38 @@ int misc_init_r(void)return 0 ; } +static void fixup_bd_address (void *blob) +{ +/* Some devices ship with a Bluetooth controller default address. +* Set a valid address through the device tree. +*/ +uchar tmp[ETH_ALEN ], bdaddr[ETH_ALEN ]; +unsigned int sid[4 ]; +int i; + +if (!CONFIG_FIXUP_BDADDR [0 ]) +return ; + +if (eth_env_get_enetaddr ("bdaddr" , tmp)) { +/* Convert between the binary formats of the corresponding stacks */ +for (i =0 ; i <ETH_ALEN ; ++i) + bdaddr[i] = tmp[ETH_ALEN - i -1 ]; + }else { +if (!get_unique_sid (sid)) +return ; + + bdaddr[0 ] = ((sid[3 ] >>0 ) &0xff ) ^1 ; + bdaddr[1 ] = (sid[3 ] >>8 ) &0xff ; + bdaddr[2 ] = (sid[3 ] >>16 ) &0xff ; + bdaddr[3 ] = (sid[3 ] >>24 ) &0xff ; + bdaddr[4 ] = (sid[0 ] >>0 ) &0xff ; + bdaddr[5 ] =0x02 ; + } + +do_fixup_by_compat (blob,CONFIG_FIXUP_BDADDR , +"local-bd-address" , bdaddr,ETH_ALEN ,1 ); +} +int ft_board_setup (void *blob,bd_t *bd) {int __maybe_unused r;
@@ -886,6 +918,8 @@ int ft_board_setup(void *blob, bd_t *bd)*/ setup_environment (blob); +fixup_bd_address (blob); +#ifdef CONFIG_VIDEO_DT_SIMPLEFB r =sunxi_simplefb_setup (blob);if (r)
Signature · 1 line
2.24.0
PATCH v3 2/4 arm: sunxi: add a config option to fixup a Bluetooth address
Quoted 5 lines · Andre Heider
Some Bluetooth controllers, like the BCM4345C5 of the Orange Pi 3, ship with the controller default address.
Add a config option to fix it up so it can function properly.
You mean that the default factory address can't make functioning? also does it affect the boot process?
PATCH v3 2/4 arm: sunxi: add a config option to fixup a Bluetooth address
Quoted 9 lines · Jagan Teki
Quoted 5 lines · Andre Heider
Some Bluetooth controllers, like the BCM4345C5 of the Orange Pi 3, ship with the controller default address.
Add a config option to fix it up so it can function properly.
You mean that the default factory address can't make functioning? also does it affect the boot process?
Yes. With the default address, bluetooth functionality is disabled in the controller, unless some other address is set.
o.
PATCH v3 2/4 arm: sunxi: add a config option to fixup a Bluetooth address
Quoted 7 lines · Ond?ej Jirman
Quoted 5 lines · Jagan Teki
Quoted 4 lines · Andre Heider
Some Bluetooth controllers, like the BCM4345C5 of the Orange Pi 3, ship with the controller default address.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Add a config option to fix it up so it can function properly.
You mean that the default factory address can't make functioning? also does it affect the boot process?
Yes. With the default address, bluetooth functionality is disabled in the controller, unless some other address is set.
What about adding u-boot property instead of CONFIG macro. it would be easy to add it on board spec -u-boot.dtsi.
PATCH v3 3/4 arm64: dts: sync Allwinner H6 files
In reply to Andre HeiderTaken from the kernel tag v5.4.
Drop the /omit-if-no-ref/ keyword as it's not supported by u-boot.
--- arch/arm/dts/sun50i-h6-beelink-gs1.dts | 27 +++++ arch/arm/dts/sun50i-h6-orangepi.dtsi | 4 + arch/arm/dts/sun50i-h6-pine-h64.dts | 4 + arch/arm/dts/sun50i-h6.dtsi | 137 ++++++++++++++++++++++--- 4 files changed, 155 insertions(+), 17 deletions(-)
arch/arm/dts/sun50i-h6-beelink-gs1.dts +27 -0
@@ -25,6 +25,7 @@ connector { compatible = "hdmi-connector"; type = "a"; + ddc-en-gpios = <&pio 7 2 GPIO_ACTIVE_HIGH>; /* PH2 */ port { hdmi_con_in: endpoint {
@@ -51,6 +52,24 @@ regulator-max-microvolt = <5000000>; regulator-always-on; }; + + sound-spdif { + compatible = "simple-audio-card"; + simple-audio-card,name = "sun50i-h6-spdif"; + + simple-audio-card,cpu { + sound-dai = <&spdif>; + }; + + simple-audio-card,codec { + sound-dai = <&spdif_out>; + }; + }; + + spdif_out: spdif-out { + #sound-dai-cells = <0>; + compatible = "linux,spdif-dit"; + }; }; &de {
@@ -232,6 +251,10 @@ }; }; +&r_ir { + status = "okay"; +}; + &r_pio { /* * PL0 and PL1 are used for PMIC I2C
@@ -243,6 +266,10 @@ vcc-pm-supply = <®_aldo1>; }; +&spdif { + status = "okay"; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_ph_pins>;
arch/arm/dts/sun50i-h6-orangepi.dtsi +4 -0
@@ -189,6 +189,10 @@ }; }; +&r_ir { + status = "okay"; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_ph_pins>;
arch/arm/dts/sun50i-h6-pine-h64.dts +4 -0
@@ -255,6 +255,10 @@ }; }; +&r_ir { + status = "okay"; +}; + &r_pio { vcc-pm-supply = <®_aldo1>; };
arch/arm/dts/sun50i-h6.dtsi +120 -17
248 lines not on this page · raw message
Signature · 1 line
2.24.0
PATCH v3 3/4 arm64: dts: sync Allwinner H6 files
Quoted 3 lines · Andre Heider
Taken from the kernel tag v5.4.
Drop the /omit-if-no-ref/ keyword as it's not supported by u-boot.
Please sync it from v5.698d25b0b266d Merge branch 'sunxi/dt-for-5.6' into sunxi/for-next
PATCH v3 3/4 arm64: dts: sync Allwinner H6 files
Hi Jagan,
Quoted 8 lines · Jagan Teki
Quoted 3 lines · Andre Heider
Taken from the kernel tag v5.4.
Drop the /omit-if-no-ref/ keyword as it's not supported by u-boot.Please sync it from v5.6
98d25b0b266dMerge branch 'sunxi/dt-for-5.6' into sunxi/for-next
I assume you mean the sunxi tree[0], but there is no such commit? Why not just a stable hash from Linus' tree?
[0] https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux.git/
Thanks,
Andre
PATCH v3 3/4 arm64: dts: sync Allwinner H6 files
Quoted 5 lines · Andre Heider
Hi Jagan,
Quoted 2 lines · Jagan Teki
Quoted 1 line · Andre Heider
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Taken from the kernel tag v5.4.
Drop the /omit-if-no-ref/ keyword as it's not supported by u-boot.Please sync it from v5.6
98d25b0b266dMerge branch 'sunxi/dt-for-5.6' into sunxi/for-nextI assume you mean the sunxi tree[0], but there is no such commit?
nvm, found it in linux-next, will update the patches...
PATCH v3 4/4 arm64: dts: sun50i: Add support for Orange Pi 3
In reply to Andre HeiderThe dts is taken from kernel tag v5.4.
The Bluetooth controller of this device ships with a default adress, use the new CONFIG_FIXUP_BDADDR option to fix it up.
--- arch/arm/dts/Makefile | 1 + arch/arm/dts/sun50i-h6-orangepi-3.dts | 287 ++++++++++++++++++++++++++ board/sunxi/MAINTAINERS | 5 + configs/orangepi_3_defconfig | 18 ++ 4 files changed, 311 insertions(+) create mode 100644 arch/arm/dts/sun50i-h6-orangepi-3.dts create mode 100644 configs/orangepi_3_defconfig
arch/arm/dts/Makefile +1 -0
@@ -540,6 +540,7 @@ dtb-$(CONFIG_MACH_SUN50I_H5) += \ sun50i-h5-orangepi-zero-plus2.dtb dtb-$(CONFIG_MACH_SUN50I_H6) += \ sun50i-h6-beelink-gs1.dtb \ + sun50i-h6-orangepi-3.dtb \ sun50i-h6-orangepi-lite2.dtb \ sun50i-h6-orangepi-one-plus.dtb \ sun50i-h6-pine-h64.dtb
arch/arm/dts/sun50i-h6-orangepi-3.dts new file +287 -0
287 lines not on this page · raw message
board/sunxi/MAINTAINERS +5 -0
@@ -375,6 +375,11 @@ M: Icenowy Zheng <[email protected]> S: Maintained F: configs/teres_i_defconfig +ORANGEPI 3 BOARD +M: Andre Heider <[email protected]> +S: Maintained +F: configs/orangepi_3_defconfig + ORANGEPI LITE2 BOARD M: Jagan Teki <[email protected]> S: Maintained
configs/orangepi_3_defconfig new file +18 -0
@@ -0,0 +1,18 @@ +CONFIG_ARM=y +CONFIG_ARCH_SUNXI=y +CONFIG_NR_DRAM_BANKS=1 +CONFIG_SPL=y +CONFIG_MACH_SUN50I_H6=y +CONFIG_SUNXI_DRAM_H6_LPDDR3=y +CONFIG_MMC0_CD_PIN="PF6" +CONFIG_MMC_SUNXI_SLOT_EXTRA=2 +CONFIG_FIXUP_BDADDR="brcm,bcm4345c5" +# CONFIG_PSCI_RESET is not set +# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +CONFIG_USE_PREBOOT=y +# CONFIG_CMD_FLASH is not set +# CONFIG_SPL_DOS_PARTITION is not set +# CONFIG_SPL_EFI_PARTITION is not set +CONFIG_DEFAULT_DEVICE_TREE="sun50i-h6-orangepi-3" +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_OHCI_HCD=y
Signature · 1 line
2.24.0
v3 cover arm64: sun50i: Add support for Orange Pi 3
In reply to Andre HeiderQuoted 8 lines · Andre Heider
Changes since v2:
* drop "sunxi: board: Useeth_env_set_enetaddr_by_index()" as it breaks compilation withoutCONFIG_NET
* add "sunxi: board: extract creating a unique sid into a helper function" and use it for the the bdaddr so that it work without ethernet devices
* useif (CONFIG_FIXUP_BDADDR[0])as suggested by Ondřej to give the compiler a better chance of discarding the function if the knob isn't set
Jagan, Maxime,
does v3 look okay to you guys? Anything I need to address to get this in?
Thanks!
Andre
Quoted 29 lines
Changes since v1:
* addCONFIG_FIXUP_BDADDRso fixing up a bdaddr is reusable
* try to use "bdaddr" first, then fall back to generating an addressNotes:
* the kernel patch for btbcm to accept the "local-bd-address" property is on master and will be in v5.5-rc1Andre Heider (4):
sunxi: board: extract creating a unique sid into a helper function
arm: sunxi: add a config option to fixup a Bluetooth address
arm64: dts: sync Allwinner H6 files
arm64: dts: sun50i: Add support for Orange Pi 3arch/arm/dts/Makefile | 1 + arch/arm/dts/sun50i-h6-beelink-gs1.dts | 27 +++ arch/arm/dts/sun50i-h6-orangepi-3.dts | 287 +++++++++++++++++++++++++ arch/arm/dts/sun50i-h6-orangepi.dtsi | 4 + arch/arm/dts/sun50i-h6-pine-h64.dts | 4 + arch/arm/dts/sun50i-h6.dtsi | 137 ++++++++++-- arch/arm/mach-sunxi/Kconfig | 11 + board/sunxi/MAINTAINERS | 5 + board/sunxi/board.c | 139 ++++++++---- configs/orangepi_3_defconfig | 18 ++ 10 files changed, 569 insertions(+), 64 deletions(-)create mode 100644
arch/arm/dts/sun50i-h6-orangepi-3.dtscreate mode 100644 configs/orangepi_3_defconfig
v3 cover arm64: sun50i: Add support for Orange Pi 3
Quoted 11 lines · Andre Heider
Quoted 9 lines · Andre Heider
Changes since v2:
* drop "sunxi: board: Useeth_env_set_enetaddr_by_index()" as it breaks compilation withoutCONFIG_NET
* add "sunxi: board: extract creating a unique sid into a helper function"
and use it for the the bdaddr so that it work without ethernet devices
* useif (CONFIG_FIXUP_BDADDR[0])as suggested by Ondřej to give the compiler a better chance of discarding the function if the knob isn't set
Quoted 3 lines
Jagan, Maxime,
does v3 look okay to you guys? Anything I need to address to get this in?
How about this year? ;) Anyone? Bueller?
Quoted 34 lines
Thanks!
AndreQuoted 29 lines
Changes since v1:
* addCONFIG_FIXUP_BDADDRso fixing up a bdaddr is reusable
* try to use "bdaddr" first, then fall back to generating an addressNotes:
* the kernel patch for btbcm to accept the "local-bd-address" property is on master and will be in v5.5-rc1Andre Heider (4):
sunxi: board: extract creating a unique sid into a helper function
arm: sunxi: add a config option to fixup a Bluetooth address
arm64: dts: sync Allwinner H6 files
arm64: dts: sun50i: Add support for Orange Pi 3arch/arm/dts/Makefile | 1 +
arch/arm/dts/sun50i-h6-beelink-gs1.dts| 27 +++ arch/arm/dts/sun50i-h6-orangepi-3.dts | 287 +++++++++++++++++++++++++ arch/arm/dts/sun50i-h6-orangepi.dtsi | 4 + arch/arm/dts/sun50i-h6-pine-h64.dts | 4 + arch/arm/dts/sun50i-h6.dtsi | 137 ++++++++++-- arch/arm/mach-sunxi/Kconfig | 11 + board/sunxi/MAINTAINERS | 5 + board/sunxi/board.c | 139 ++++++++---- configs/orangepi_3_defconfig | 18 ++10 files changed, 569 insertions(+), 64 deletions(-)create mode 100644
arch/arm/dts/sun50i-h6-orangepi-3.dtscreate mode 100644 configs/orangepi_3_defconfig
v3 cover arm64: sun50i: Add support for Orange Pi 3
In reply to Andre HeiderQuoted 10 lines · Andre Heider
Quoted 8 lines · Andre Heider
Changes since v2:
* drop "sunxi: board: Useeth_env_set_enetaddr_by_index()" as it breaks compilation withoutCONFIG_NET
* add "sunxi: board: extract creating a unique sid into a helper function" and use it for the the bdaddr so that it work without ethernet devices
* useif (CONFIG_FIXUP_BDADDR[0])as suggested by Ondřej to give the compiler a better chance of discarding the function if the knob isn't set
Quoted 3 lines
Jagan, Maxime,
does v3 look okay to you guys? Anything I need to address to get this in?
Yeah, it looks good to me
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/20200106/9c211c2a/attachment.sig>