arm64: sun50i: Add support for Orange Pi 3
Subsystems (3)
v4 cover arm64: sun50i: Add support for Orange Pi 3
Changes since v3:
* use dts files from linux-next 98d25b0b266d
* added commit description to "sunxi: board: extract creating a unique sid into a helper function"
* added Maxime's Acked-by
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 v4 1/4 sunxi: board: extract creating a unique sid into a helper function
Refactor setup_environment() so we can use the created sid for a Bluetooth address too.
--- board/sunxi/board.c | 105 ++++++++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 47 deletions(-)
board/sunxi/board.c +58 -47
@@ -770,6 +770,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.
@@ -780,61 +812,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.1
PATCH v4 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
@@ -1010,4 +1010,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
@@ -878,6 +878,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;
@@ -888,6 +920,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.1
PATCH v4 3/4 arm64: dts: sync Allwinner H6 files
In reply to Andre HeiderTaken from the linux-next commit:98d25b0b266d Merge branch 'sunxi/dt-for-5.6' into sunxi/for-next
Drop the /omit-if-no-ref/ keyword as it's not supported by u-boot.
--- arch/arm/dts/sun50i-h6-beelink-gs1.dts | 48 +++- arch/arm/dts/sun50i-h6-orangepi-lite2.dts | 6 +- arch/arm/dts/sun50i-h6-orangepi-one-plus.dts | 8 +- arch/arm/dts/sun50i-h6-orangepi.dtsi | 18 +- arch/arm/dts/sun50i-h6-pine-h64.dts | 33 ++- arch/arm/dts/sun50i-h6.dtsi | 262 +++++++++++++++++-- 6 files changed, 328 insertions(+), 47 deletions(-)
arch/arm/dts/sun50i-h6-beelink-gs1.dts +44 -4
@@ -1,7 +1,5 @@ -// SPDX-License-Identifier: (GPL-2.0+ or MIT) -/* - * Copyright (C) 2019 Clément Péron <[email protected]> - */ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +// Copyright (C) 2019 Clément Péron <[email protected]> /dts-v1/;
@@ -25,6 +23,7 @@ connector { compatible = "hdmi-connector"; type = "a"; + ddc-en-gpios = <&pio 7 2 GPIO_ACTIVE_HIGH>; /* PH2 */ port { hdmi_con_in: endpoint {
@@ -51,12 +50,34 @@ 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 { status = "okay"; }; +&dwc3 { + status = "okay"; +}; + &ehci0 { status = "okay"; };
@@ -70,6 +91,11 @@ status = "okay"; }; +&gpu { + mali-supply = <®_dcdcc>; + status = "okay"; +}; + &hdmi { status = "okay"; };
@@ -206,6 +232,7 @@ }; reg_dcdcc: dcdcc { + regulator-enable-ramp-delay = <32000>; regulator-min-microvolt = <810000>; regulator-max-microvolt = <1080000>; regulator-name = "vdd-gpu";
@@ -232,6 +259,11 @@ }; }; +&r_ir { + linux,rc-map-name = "rc-beelink-gs1"; + status = "okay"; +}; + &r_pio { /* * PL0 and PL1 are used for PMIC I2C
@@ -243,6 +275,10 @@ vcc-pm-supply = <®_aldo1>; }; +&spdif { + status = "okay"; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_ph_pins>;
@@ -258,3 +294,7 @@ usb0_vbus-supply = <®_vcc5v>; status = "okay"; }; + +&usb3phy { + status = "okay"; +};
arch/arm/dts/sun50i-h6-orangepi-lite2.dts +2 -4
@@ -1,7 +1,5 @@ -// SPDX-License-Identifier: (GPL-2.0+ or MIT) -/* - * Copyright (C) 2018 Jagan Teki <[email protected]> - */ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +// Copyright (C) 2018 Jagan Teki <[email protected]> #include "sun50i-h6-orangepi.dtsi"
arch/arm/dts/sun50i-h6-orangepi-one-plus.dts +3 -5
@@ -1,8 +1,6 @@ -// SPDX-License-Identifier: (GPL-2.0+ or MIT) -/* - * Copyright (C) 2018 Amarula Solutions - * Author: Jagan Teki <[email protected]> - */ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +// Copyright (C) 2018 Amarula Solutions +// Author: Jagan Teki <[email protected]> #include "sun50i-h6-orangepi.dtsi"
arch/arm/dts/sun50i-h6-orangepi.dtsi +13 -5
@@ -1,8 +1,6 @@ -// SPDX-License-Identifier: (GPL-2.0+ or MIT) -/* - * Copyright (C) 2018 Amarula Solutions - * Author: Jagan Teki <[email protected]> - */ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +// Copyright (C) 2018 Amarula Solutions +// Author: Jagan Teki <[email protected]> /dts-v1/;
@@ -55,6 +53,11 @@ status = "okay"; }; +&gpu { + mali-supply = <®_dcdcc>; + status = "okay"; +}; + &mmc0 { vmmc-supply = <®_cldo1>; cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>;
@@ -163,6 +166,7 @@ }; reg_dcdcc: dcdcc { + regulator-enable-ramp-delay = <32000>; regulator-min-microvolt = <810000>; regulator-max-microvolt = <1080000>; regulator-name = "vdd-gpu";
@@ -189,6 +193,10 @@ }; }; +&r_ir { + status = "okay"; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_ph_pins>;
arch/arm/dts/sun50i-h6-pine-h64.dts +26 -7
@@ -1,7 +1,5 @@ -// SPDX-License-Identifier: (GPL-2.0+ or MIT) -/* - * Copyright (c) 2017 Icenowy Zheng <[email protected]> - */ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +// Copyright (c) 2017 Icenowy Zheng <[email protected]> /dts-v1/;
@@ -10,7 +8,7 @@ #include <dt-bindings/gpio/gpio.h> / { - model = "Pine H64"; + model = "Pine H64 model A"; compatible = "pine64,pine-h64", "allwinner,sun50i-h6"; aliases {
@@ -22,9 +20,10 @@ stdout-path = "serial0:115200n8"; }; - connector { + hdmi_connector: connector { compatible = "hdmi-connector"; type = "a"; + ddc-en-gpios = <&pio 7 2 GPIO_ACTIVE_HIGH>; /* PH2 */ port { hdmi_con_in: endpoint {
@@ -52,6 +51,16 @@ }; }; + reg_gmac_3v3: gmac-3v3 { + compatible = "regulator-fixed"; + regulator-name = "vcc-gmac-3v3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + startup-delay-us = <100000>; + gpio = <&pio 2 16 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + reg_usb_vbus: vbus { compatible = "regulator-fixed"; regulator-name = "usb-vbus";
@@ -68,7 +77,7 @@ pinctrl-0 = <&ext_rgmii_pins>; phy-mode = "rgmii"; phy-handle = <&ext_rgmii_phy>; - phy-supply = <®_aldo2>; + phy-supply = <®_gmac_3v3>; allwinner,rx-delay-ps = <200>; allwinner,tx-delay-ps = <200>; status = "okay";
@@ -85,6 +94,11 @@ status = "okay"; }; +&gpu { + mali-supply = <®_dcdcc>; + status = "okay"; +}; + &hdmi { status = "okay"; };
@@ -221,6 +235,7 @@ }; reg_dcdcc: dcdcc { + regulator-enable-ramp-delay = <32000>; regulator-min-microvolt = <810000>; regulator-max-microvolt = <1080000>; regulator-name = "vdd-gpu";
@@ -255,6 +270,10 @@ }; }; +&r_ir { + status = "okay"; +}; + &r_pio { vcc-pm-supply = <®_aldo1>; };
arch/arm/dts/sun50i-h6.dtsi +240 -22
415 lines not on this page · raw message
Signature · 1 line
2.24.1
PATCH v4 4/4 arm64: dts: sun50i: Add support for Orange Pi 3
In reply to Andre HeiderThe dts is taken from the linux-next commit:98d25b0b266d Merge branch 'sunxi/dt-for-5.6' into sunxi/for-next
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 | 322 ++++++++++++++++++++++++++ board/sunxi/MAINTAINERS | 5 + configs/orangepi_3_defconfig | 18 ++ 4 files changed, 346 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
@@ -556,6 +556,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 +322 -0
322 lines not on this page · raw message
board/sunxi/MAINTAINERS +5 -0
@@ -385,6 +385,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.1