add UARTs/I2Cs H6 overlays + disable them in Main DT

This commit is contained in:
Martin Ayotte 2018-11-13 16:47:06 -05:00
parent ced3bf0a40
commit e89b17e284
3 changed files with 307 additions and 8 deletions

View File

@ -39,7 +39,7 @@ index bec8c4a..25d3be2 100644
+ resets = <&ccu RST_BUS_I2C0>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c0_pins>;
+ status = "okay";
+ status = "disabled";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ };
@ -52,7 +52,7 @@ index bec8c4a..25d3be2 100644
+ resets = <&ccu RST_BUS_I2C1>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c1_pins>;
+ status = "okay";
+ status = "disabled";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ };
@ -65,7 +65,7 @@ index bec8c4a..25d3be2 100644
+ resets = <&ccu RST_BUS_I2C2>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c2_pins>;
+ status = "okay";
+ status = "disabled";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ };

View File

@ -35,7 +35,7 @@ index 4d8ca45..f05c995 100644
+&uart3 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart3_pins>;
+ status = "okay";
+ status = "disabled";
+};
+
&usb2otg {
@ -52,7 +52,7 @@ index 4d8ca45..f05c995 100644
+&uart3 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart3_pins>;
+ status = "okay";
+ status = "disabled";
+};
+
&usb2otg {

View File

@ -4535,7 +4535,7 @@ new file mode 100644
index 0000000..5cad268
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/Makefile
@@ -0,0 +1,40 @@
@@ -0,0 +1,47 @@
+# SPDX-License-Identifier: GPL-2.0
+dtbo-$(CONFIG_ARCH_SUNXI) += \
+ sun50i-a64-i2c0.dtbo \
@ -4567,11 +4567,18 @@ index 0000000..5cad268
+ sun50i-h5-usbhost1.dtbo \
+ sun50i-h5-usbhost2.dtbo \
+ sun50i-h5-usbhost3.dtbo \
+ sun50i-h5-w1-gpio.dtbo
+ sun50i-h5-w1-gpio.dtbo \
+ sun50i-h6-i2c0.dtbo \
+ sun50i-h6-i2c1.dtbo \
+ sun50i-h6-i2c2.dtbo \
+ sun50i-h6-uart1.dtbo \
+ sun50i-h6-uart2.dtbo \
+ sun50i-h6-uart3.dtbo
+
+scr-$(CONFIG_ARCH_SUNXI) += \
+ sun50i-a64-fixup.scr \
+ sun50i-h5-fixup.scr
+ sun50i-h5-fixup.scr \
+ sun50i-h6-fixup.scr
+
+dtbotxt-$(CONFIG_ARCH_SUNXI) += \
+ README.sun50i-a64-overlays \
@ -6339,6 +6346,298 @@ index 0000000..6e99626
+ };
+ };
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-i2c0.dts b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-i2c0.dts
index e69de29..7e7ee8c 100644
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-i2c0.dts
@@ -0,0 +1,20 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+ compatible = "allwinner,sun50i-h6";
+
+ fragment@0 {
+ target-path = "/aliases";
+ __overlay__ {
+ i2c0 = "/soc/i2c@5002000";
+ };
+ };
+
+ fragment@1 {
+ target = <&i2c0>;
+ __overlay__ {
+ status = "okay";
+ };
+ };
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-i2c1.dts b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-i2c1.dts
index e69de29..1117698 100644
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-i2c1.dts
@@ -0,0 +1,20 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+ compatible = "allwinner,sun50i-h6";
+
+ fragment@0 {
+ target-path = "/aliases";
+ __overlay__ {
+ i2c1 = "/soc/i2c@5002400";
+ };
+ };
+
+ fragment@1 {
+ target = <&i2c1>;
+ __overlay__ {
+ status = "okay";
+ };
+ };
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-i2c2.dts b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-i2c2.dts
index e69de29..b627529 100644
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-i2c2.dts
@@ -0,0 +1,20 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+ compatible = "allwinner,sun50i-h6";
+
+ fragment@0 {
+ target-path = "/aliases";
+ __overlay__ {
+ i2c2 = "/soc/i2c@5002800";
+ };
+ };
+
+ fragment@1 {
+ target = <&i2c2>;
+ __overlay__ {
+ status = "okay";
+ };
+ };
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-uart1.dts b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-uart1.dts
index e69de29..44aa94e 100644
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-uart1.dts
@@ -0,0 +1,22 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+ compatible = "allwinner,sun50i-h6";
+
+ fragment@0 {
+ target-path = "/aliases";
+ __overlay__ {
+ serial1 = "/soc/serial@5000400";
+ };
+ };
+
+ fragment@1 {
+ target = <&uart1>;
+ __overlay__ {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart1_pins>;
+ status = "okay";
+ };
+ };
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-uart2.dts b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-uart2.dts
index e69de29..7a1860e 100644
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-uart2.dts
@@ -0,0 +1,32 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+ compatible = "allwinner,sun50i-h6";
+
+ fragment@0 {
+ target-path = "/aliases";
+ __overlay__ {
+ serial2 = "/soc/serial@5000800";
+ };
+ };
+
+ fragment@1 {
+ target = <&pio>;
+ __overlay__ {
+ uart2_rts_cts: uart2_rts_cts {
+ pins = "PD21", "PD22";
+ function = "uart2";
+ };
+ };
+ };
+
+ fragment@2 {
+ target = <&uart2>;
+ __overlay__ {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart2_pins>;
+ status = "okay";
+ };
+ };
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-uart3.dts b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-uart3.dts
index e69de29..38a59ac 100644
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-uart3.dts
@@ -0,0 +1,32 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+ compatible = "allwinner,sun50i-h6";
+
+ fragment@0 {
+ target-path = "/aliases";
+ __overlay__ {
+ serial3 = "/soc/serial@05000c00";
+ };
+ };
+
+ fragment@1 {
+ target = <&pio>;
+ __overlay__ {
+ uart3_rts_cts: uart3_rts_cts {
+ pins = "PD25", "PD26";
+ function = "uart3";
+ };
+ };
+ };
+
+ fragment@2 {
+ target = <&uart3>;
+ __overlay__ {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart3_pins>;
+ status = "okay";
+ };
+ };
+};
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-fixup.scr-cmd b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-fixup.scr-cmd
new file mode 100644
index 0000000..fba1c4f
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-fixup.scr-cmd
@@ -0,0 +1,110 @@
+# overlays fixup script
+# implements (or rather substitutes) overlay arguments functionality
+# using u-boot scripting, environment variables and "fdt" command
+
+# setexpr test_var ${tmp_bank} - A
+# works only for hex numbers (A-F)
+
+setenv decompose_pin 'setexpr tmp_bank sub "P(A|C|D|G)\\d+" "\\1";
+setexpr tmp_pin sub "P\\S(\\d+)" "\\1";
+test "${tmp_bank}" = "A" && setenv tmp_bank 0;
+test "${tmp_bank}" = "C" && setenv tmp_bank 2;
+test "${tmp_bank}" = "D" && setenv tmp_bank 3;
+test "${tmp_bank}" = "G" && setenv tmp_bank 6'
+
+if test -n "${param_spinor_spi_bus}"; then
+ test "${param_spinor_spi_bus}" = "0" && setenv tmp_spi_path "spi@5010000"
+ test "${param_spinor_spi_bus}" = "1" && setenv tmp_spi_path "spi@5011000"
+ fdt set /soc/${tmp_spi_path} status "okay"
+ fdt set /soc/${tmp_spi_path}/spiflash status "okay"
+ if test -n "${param_spinor_max_freq}"; then
+ fdt set /soc/${tmp_spi_path}/spiflash spi-max-frequency "<${param_spinor_max_freq}>"
+ fi
+ if test "${param_spinor_spi_cs}" = "1"; then
+ fdt set /soc/${tmp_spi_path}/spiflash reg "<1>"
+ fi
+ env delete tmp_spi_path
+fi
+
+if test -n "${param_spidev_spi_bus}"; then
+ test "${param_spidev_spi_bus}" = "0" && setenv tmp_spi_path "spi@5010000"
+ test "${param_spidev_spi_bus}" = "1" && setenv tmp_spi_path "spi@5011000"
+ fdt set /soc/${tmp_spi_path} status "okay"
+ fdt set /soc/${tmp_spi_path}/spidev status "okay"
+ if test -n "${param_spidev_max_freq}"; then
+ fdt set /soc/${tmp_spi_path}/spidev spi-max-frequency "<${param_spidev_max_freq}>"
+ fi
+ if test "${param_spidev_spi_cs}" = "1"; then
+ fdt set /soc/${tmp_spi_path}/spidev reg "<1>"
+ fi
+ env delete tmp_spi_path
+fi
+
+if test -n "${param_pps_pin}"; then
+ setenv tmp_bank "${param_pps_pin}"
+ setenv tmp_pin "${param_pps_pin}"
+ run decompose_pin
+ fdt set /soc/pinctrl@300b000/pps_pins pins "${param_pps_pin}"
+ fdt get value tmp_phandle /soc/pinctrl@300b000 phandle
+ fdt set /pps@0 gpios "<${tmp_phandle} ${tmp_bank} ${tmp_pin} 0>"
+ env delete tmp_pin tmp_bank tmp_phandle
+fi
+
+if test "${param_pps_falling_edge}" = "1"; then
+ fdt set /pps@0 assert-falling-edge
+fi
+
+for f in ${overlays}; do
+ if test "${f}" = "pwm"; then
+ setenv bootargs_new ""
+ for arg in ${bootargs}; do
+ if test "${arg}" = "console=ttyS0,115200"; then
+ echo "Warning: Disabling ttyS0 console due to enabled PWM overlay"
+ else
+ setenv bootargs_new "${bootargs_new} ${arg}"
+ fi
+ done
+ setenv bootargs "${bootargs_new}"
+ fi
+done
+
+if test -n "${param_w1_pin}"; then
+ setenv tmp_bank "${param_w1_pin}"
+ setenv tmp_pin "${param_w1_pin}"
+ run decompose_pin
+ fdt set /soc/pinctrl@300b000/w1_pins pins "${param_w1_pin}"
+ fdt get value tmp_phandle /soc/pinctrl@300b000 phandle
+ fdt set /onewire@0 gpios "<${tmp_phandle} ${tmp_bank} ${tmp_pin} 0>"
+ env delete tmp_pin tmp_bank tmp_phandle
+fi
+
+if test "${param_w1_pin_int_pullup}" = "1"; then
+ fdt set /soc/pinctrl@300b000/w1_pins bias-pull-up
+fi
+
+if test "${param_uart1_rtscts}" = "1"; then
+ fdt get value tmp_phandle1 /soc/pinctrl@300b000/uart1 phandle
+ fdt get value tmp_phandle2 /soc/pinctrl@300b000/uart1_rts_cts phandle
+ fdt set /soc/serial@5000400 pinctrl-names "default" "default"
+ fdt set /soc/serial@5000400 pinctrl-0 "<${tmp_phandle1}>"
+ fdt set /soc/serial@5000400 pinctrl-1 "<${tmp_phandle2}>"
+ env delete tmp_phandle1 tmp_phandle2
+fi
+
+if test "${param_uart2_rtscts}" = "1"; then
+ fdt get value tmp_phandle1 /soc/pinctrl@300b000/uart2 phandle
+ fdt get value tmp_phandle2 /soc/pinctrl@300b000/uart2_rts_cts phandle
+ fdt set /soc/serial@5000800 pinctrl-names "default" "default"
+ fdt set /soc/serial@5000800 pinctrl-0 "<${tmp_phandle1}>"
+ fdt set /soc/serial@5000800 pinctrl-1 "<${tmp_phandle2}>"
+ env delete tmp_phandle1 tmp_phandle2
+fi
+
+if test "${param_uart3_rtscts}" = "1"; then
+ fdt get value tmp_phandle1 /soc/pinctrl@300b000/uart3 phandle
+ fdt get value tmp_phandle2 /soc/pinctrl@300b000/uart3_rts_cts phandle
+ fdt set /soc/serial@5000c00 pinctrl-names "default" "default"
+ fdt set /soc/serial@5000c00 pinctrl-0 "<${tmp_phandle1}>"
+ fdt set /soc/serial@5000c00 pinctrl-1 "<${tmp_phandle2}>"
+ env delete tmp_phandle1 tmp_phandle2
+fi
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 26e6af4..65b9435 100644
--- a/scripts/Makefile.lib