diff --git a/patch/kernel/archive/meson64-6.13/0000.patching_config.yaml b/patch/kernel/archive/meson64-6.13/0000.patching_config.yaml new file mode 100644 index 000000000..393d99177 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/0000.patching_config.yaml @@ -0,0 +1,38 @@ +config: + + # Just some info stuff; not used by the patching scripts + name: meson64-6.7 + kind: kernel + type: mainline # or: vendor + branch: linux-6.7.y + last-known-good-tag: v6.7.0 + maintainers: + - { github: rpardini, name: Ricardo Pardini, email: ricardo@pardini.net, armbian-forum: rpardini } + + # .dts files in these directories will be copied as-is to the build tree; later ones overwrite earlier ones. + # This is meant to provide a way to "add a board DTS" without having to null-patch them in. + dts-directories: + # will copy patch/kernel/archive/meson64-MAJOR.MINOR/dt-boards/*.dts to arch/arm64/boot/dts/amlogic + - { source: "dt", target: "arch/arm64/boot/dts/amlogic" } + + # every file in these directories will be copied as-is to the build tree; later ones overwrite earlier ones + # This is meant as a way to have overlays, bare, in a directory, without having to null-patch them in. + # @TODO need a solution to auto-Makefile the overlays as well + overlay-directories: + # will copy patch/kernel/archive/meson64-MAJOR.MINOR/overlay/**/* to arch/arm64/boot/dts/amlogic/overlay + - { source: "overlay", target: "arch/arm64/boot/dts/amlogic/overlay" } + + # the Makefile in each of these directories will be magically patched to include the dts files copied + # or patched-in; overlay subdir will be included "-y" if it exists. + # No more Makefile patching needed, yay! + auto-patch-dt-makefile: + - { directory: "arch/arm64/boot/dts/amlogic", config-var: "CONFIG_ARCH_MESON" } + + # configuration for when applying patches to git / auto-rewriting patches (development cycle helpers) + patches-to-git: + do-not-commit-files: + - "MAINTAINERS" # constant churn, drop them. sorry. + - "Documentation/devicetree/bindings/arm/amlogic.yaml" # constant churn, conflicts on every bump, drop it. sorry. + do-not-commit-regexes: # Python-style regexes + - "^arch/([a-zA-Z0-9]+)/boot/dts/([a-zA-Z0-9]+)/Makefile$" # ignore DT Makefile patches, we've an auto-patcher now + diff --git a/patch/kernel/archive/meson64-6.13/board-bananapi-cm4-cm4io.patch b/patch/kernel/archive/meson64-6.13/board-bananapi-cm4-cm4io.patch new file mode 100644 index 000000000..3990b4e33 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-bananapi-cm4-cm4io.patch @@ -0,0 +1,121 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Patrick Yavitz +Date: Tue, 25 Jul 2023 13:31:54 -0400 +Subject: arch: arm64: dts: amlogic: meson g12b bananapi cm4 + +Signed-off-by: Patrick Yavitz +--- + arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4-cm4io.dts | 9 +++++-- + arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4.dtsi | 12 ++++++++-- + 2 files changed, 17 insertions(+), 4 deletions(-) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4-cm4io.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4-cm4io.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4-cm4io.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4-cm4io.dts +@@ -50,14 +50,15 @@ leds { + led-blue { + color = ; + function = LED_FUNCTION_STATUS; +- gpios = <&gpio_ao GPIOAO_7 GPIO_ACTIVE_HIGH>; ++ gpios = <&gpio_ao GPIOAO_7 GPIO_ACTIVE_LOW>; + linux,default-trigger = "heartbeat"; + }; + + led-green { + color = ; + function = LED_FUNCTION_STATUS; +- gpios = <&gpio_ao GPIOAO_2 GPIO_ACTIVE_HIGH>; ++ gpios = <&gpio_ao GPIOAO_2 GPIO_ACTIVE_LOW>; ++ linux,default-trigger = "default-on"; + }; + }; + +@@ -120,6 +121,10 @@ codec { + }; + }; + ++&reboot { ++ sd-vqen = <&gpio_ao GPIOAO_3 GPIO_ACTIVE_HIGH>; ++}; ++ + &cecb_AO { + status = "okay"; + }; +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4.dtsi +@@ -12,6 +12,15 @@ aliases { + rtc1 = &vrtc; + }; + ++ reboot: meson64-reboot { ++ compatible = "meson64,reboot"; ++ sys_reset = <0x84000009>; ++ sys_poweroff = <0x84000008>; ++ ++ sd-vqsw = <&gpio_ao GPIOAO_9 GPIO_ACTIVE_HIGH>; ++ sd-vmmc = <&gpio_ao GPIOAO_8 GPIO_ACTIVE_HIGH>; ++ }; ++ + chosen { + stdout-path = "serial0:115200n8"; + }; +@@ -369,8 +378,7 @@ &uart_A { + + bluetooth { + compatible = "realtek,rtl8822cs-bt"; +- enable-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>; +- host-wake-gpios = <&gpio GPIOX_19 GPIO_ACTIVE_HIGH>; ++ enable-gpios = <&gpio GPIOX_19 GPIO_ACTIVE_HIGH>; + device-wake-gpios = <&gpio GPIOX_18 GPIO_ACTIVE_HIGH>; + }; + }; +-- +Armbian + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Patrick Yavitz +Date: Sun, 8 Sep 2024 05:55:13 -0400 +Subject: BananaPi CM4: improve SDIO WiFi speeds + +Signed-off-by: Patrick Yavitz +--- + arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4.dtsi | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4.dtsi +@@ -303,8 +303,10 @@ &sd_emmc_a { + #size-cells = <0>; + + bus-width = <4>; ++ cap-sd-highspeed; ++ sd-uhs-sdr50; + sd-uhs-sdr104; +- max-frequency = <50000000>; ++ max-frequency = <100000000>; + + non-removable; + disable-wp; +@@ -312,10 +314,13 @@ &sd_emmc_a { + /* WiFi firmware requires power in suspend */ + keep-power-in-suspend; + ++ /* Removing quirk improves WiFi performance */ ++ /delete-property/ amlogic,dram-access-quirk; ++ + mmc-pwrseq = <&sdio_pwrseq>; + + vmmc-supply = <&vddao_3v3>; +- vqmmc-supply = <&vddao_3v3>; ++ vqmmc-supply = <&vddao_1v8>; + + status = "okay"; + +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-bananapi-m2s.patch b/patch/kernel/archive/meson64-6.13/board-bananapi-m2s.patch new file mode 100644 index 000000000..2ee977f5c --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-bananapi-m2s.patch @@ -0,0 +1,62 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Patrick Yavitz +Date: Tue, 25 Jul 2023 13:34:18 -0400 +Subject: arch: arm64: dts: amlogic: meson g12b bananapi m2s + +Signed-off-by: Patrick Yavitz +--- + arch/arm64/boot/dts/amlogic/meson-g12b-a311d-bananapi-m2s.dts | 4 ++++ + arch/arm64/boot/dts/amlogic/meson-g12b-bananapi.dtsi | 9 +++++++++ + arch/arm64/boot/dts/amlogic/meson-g12b-s922x-bananapi-m2s.dts | 4 ++++ + 3 files changed, 17 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-a311d-bananapi-m2s.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-a311d-bananapi-m2s.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-g12b-a311d-bananapi-m2s.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-g12b-a311d-bananapi-m2s.dts +@@ -18,6 +18,10 @@ aliases { + }; + }; + ++&reboot { ++ sd-vqen = <&gpio_ao GPIOAO_3 GPIO_ACTIVE_HIGH>; ++}; ++ + /* Camera (CSI) bus */ + &i2c1 { + status = "okay"; +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi.dtsi +@@ -17,6 +17,15 @@ aliases { + rtc1 = &vrtc; + }; + ++ reboot: meson64-reboot { ++ compatible = "meson64,reboot"; ++ sys_reset = <0x84000009>; ++ sys_poweroff = <0x84000008>; ++ ++ sd-vqsw = <&gpio_ao GPIOAO_9 GPIO_ACTIVE_HIGH>; ++ sd-vmmc = <&gpio_ao GPIOAO_8 GPIO_ACTIVE_HIGH>; ++ }; ++ + chosen { + stdout-path = "serial0:115200n8"; + }; +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-s922x-bananapi-m2s.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-s922x-bananapi-m2s.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-g12b-s922x-bananapi-m2s.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-g12b-s922x-bananapi-m2s.dts +@@ -12,3 +12,7 @@ / { + compatible = "bananapi,bpi-m2s", "amlogic,s922x", "amlogic,g12b"; + model = "BananaPi M2S"; + }; ++ ++&reboot { ++ sd-vqen = <&gpio_ao GPIOAO_3 GPIO_ACTIVE_HIGH>; ++}; +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-bananapim5-001-sd-use-270-mmc-clock-phase-via-dt.patch b/patch/kernel/archive/meson64-6.13/board-bananapim5-001-sd-use-270-mmc-clock-phase-via-dt.patch new file mode 100644 index 000000000..a7fc8f521 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-bananapim5-001-sd-use-270-mmc-clock-phase-via-dt.patch @@ -0,0 +1,45 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Igor Pecovnik +Date: Sat, 11 Feb 2023 18:30:00 +0100 +Subject: BananaPi M5: 270 clock phase, via amlogic,mmc-phase + +Rework of Ricardo Pardini patch. + +Signed-off-by: Igor Pecovnik +--- + arch/arm64/boot/dts/amlogic/meson-sm1-bananapi.dtsi | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi.dtsi b/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi.dtsi +@@ -8,6 +8,7 @@ + #include + #include + #include ++#include + + / { + adc-keys { +@@ -394,6 +395,8 @@ &sd_emmc_b { + cd-gpios = <&gpio GPIOC_6 GPIO_ACTIVE_LOW>; + vmmc-supply = <&tflash_vdd>; + vqmmc-supply = <&vddio_c>; ++ ++ amlogic,mmc-phase = ; + }; + + /* eMMC */ +@@ -413,6 +416,8 @@ &sd_emmc_c { + mmc-pwrseq = <&emmc_pwrseq>; + vmmc-supply = <&vddao_3v3>; + vqmmc-supply = <&emmc_1v8>; ++ ++ amlogic,mmc-phase = ; + }; + + &uart_AO { +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-bananapim5-002-add-wifi-bt-support.patch b/patch/kernel/archive/meson64-6.13/board-bananapim5-002-add-wifi-bt-support.patch new file mode 100644 index 000000000..4a35b7a32 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-bananapim5-002-add-wifi-bt-support.patch @@ -0,0 +1,112 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Patrick Yavitz +Date: Wed, 2 Aug 2023 19:36:07 -0400 +Subject: arch: arm64: dts: amlogic: add wifi/bt support to bananapi m5 + +The BPI-M5 has an optional RTL8822CS WiFi/BT mezzanine board. Describe +the board but mark the sd_emmc_a and uart_A nodes disabled so they can +be enabled via overlay or fdtput when the board is connected. + +Signed-off-by: Patrick Yavitz +--- + arch/arm64/boot/dts/amlogic/meson-sm1-bananapi-m5.dts | 66 +++++++++- + 1 file changed, 65 insertions(+), 1 deletion(-) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi-m5.dts b/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi-m5.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi-m5.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi-m5.dts +@@ -25,6 +25,20 @@ cvbs_connector_in: endpoint { + }; + }; + ++ sdio_pwrseq: sdio-pwrseq { ++ compatible = "mmc-pwrseq-simple"; ++ reset-gpios = <&gpio GPIOX_6 GPIO_ACTIVE_LOW>; ++ clocks = <&wifi32k>; ++ clock-names = "ext_clock"; ++ }; ++ ++ wifi32k: wifi32k { ++ compatible = "pwm-clock"; ++ #clock-cells = <0>; ++ clock-frequency = <32768>; ++ pwms = <&pwm_ef 0 30518 0>; /* PWM_E at 32.768KHz */ ++ }; ++ + sound { + compatible = "amlogic,axg-sound-card"; + model = "BPI-M5"; +@@ -153,7 +167,6 @@ &acodec { + status = "okay"; + }; + +- + &clkc_audio { + status = "okay"; + }; +@@ -176,6 +189,42 @@ &frddr_c { + status = "okay"; + }; + ++&pwm_ef { ++ status = "okay"; ++ pinctrl-0 = <&pwm_e_pins>; ++ pinctrl-names = "default"; ++}; ++ ++/* SDIO */ ++&sd_emmc_a { ++ /* enable if WiFi/BT board connected */ ++ status = "disabled"; ++ pinctrl-0 = <&sdio_pins>; ++ pinctrl-1 = <&sdio_clk_gate_pins>; ++ pinctrl-names = "default", "clk-gate"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ bus-width = <4>; ++ sd-uhs-sdr104; ++ max-frequency = <50000000>; ++ ++ non-removable; ++ disable-wp; ++ ++ /* WiFi firmware requires power in suspend */ ++ keep-power-in-suspend; ++ ++ mmc-pwrseq = <&sdio_pwrseq>; ++ ++ vmmc-supply = <&vddao_3v3>; ++ vqmmc-supply = <&vddao_1v8>; ++ ++ rtl8822cs: wifi@1 { ++ reg = <1>; ++ }; ++}; ++ + &tdmif_b { + status = "okay"; + }; +@@ -223,3 +272,18 @@ &toddr_b { + &toddr_c { + status = "okay"; + }; ++ ++&uart_A { ++ /* enable if WiFi/BT board connected */ ++ status = "disabled"; ++ pinctrl-0 = <&uart_a_pins>, <&uart_a_cts_rts_pins>; ++ pinctrl-names = "default"; ++ uart-has-rtscts; ++ ++ bluetooth { ++ compatible = "realtek,rtl8822cs-bt"; ++ enable-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>; ++ host-wake-gpios = <&gpio GPIOX_19 GPIO_ACTIVE_HIGH>; ++ device-wake-gpios = <&gpio GPIOX_18 GPIO_ACTIVE_HIGH>; ++ }; ++}; +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-bananapism1-add-uart_A-and-AO_B.patch b/patch/kernel/archive/meson64-6.13/board-bananapism1-add-uart_A-and-AO_B.patch new file mode 100644 index 000000000..5f66a931a --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-bananapism1-add-uart_A-and-AO_B.patch @@ -0,0 +1,87 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Patrick Yavitz +Date: Thu, 21 Sep 2023 13:46:59 +0200 +Subject: arm64: dts: amlogic: meson-sm1-bananapi: add uart A and AO_B + +- rpardini: rebase on 6.11-rc7 + +Signed-off-by: Patrick Yavitz +--- + arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi | 9 +++++++++ + arch/arm64/boot/dts/amlogic/meson-sm1-bananapi-m2-pro.dts | 10 ++++++++++ + arch/arm64/boot/dts/amlogic/meson-sm1-bananapi.dtsi | 7 +++++++ + 3 files changed, 26 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +@@ -1922,6 +1922,15 @@ mux { + }; + }; + ++ uart_ao_b_pins: uart-b-ao { ++ mux { ++ groups = "uart_ao_b_tx_8", ++ "uart_ao_b_rx_9"; ++ function = "uart_ao_b"; ++ bias-disable; ++ }; ++ }; ++ + uart_ao_a_cts_rts_pins: uart-ao-a-cts-rts { + mux { + groups = "uart_ao_a_cts", +diff --git a/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi-m2-pro.dts b/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi-m2-pro.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi-m2-pro.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi-m2-pro.dts +@@ -13,6 +13,10 @@ / { + compatible = "bananapi,bpi-m2-pro", "amlogic,sm1"; + model = "Banana Pi BPI-M2-PRO"; + ++ aliases { ++ serial1 = &uart_A; ++ }; ++ + sound { + compatible = "amlogic,axg-sound-card"; + model = "BPI-M2-PRO"; +@@ -99,3 +103,9 @@ &tdmout_b { + &tohdmitx { + status = "okay"; + }; ++ ++&uart_A { ++ status = "disabled"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&uart_a_pins>; ++}; +diff --git a/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi.dtsi b/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi.dtsi +@@ -26,6 +26,7 @@ button-sw3 { + + aliases { + serial0 = &uart_AO; ++ serial4 = &uart_AO_B; + ethernet0 = ðmac; + }; + +@@ -426,6 +427,12 @@ &uart_AO { + pinctrl-names = "default"; + }; + ++&uart_AO_B { ++ status = "disabled"; ++ pinctrl-0 = <&uart_ao_b_pins>; ++ pinctrl-names = "default"; ++}; ++ + &usb { + status = "okay"; + }; +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-khadas-vim3-fix-missing-i2c3-nod.patch b/patch/kernel/archive/meson64-6.13/board-khadas-vim3-fix-missing-i2c3-nod.patch new file mode 100644 index 000000000..9e5b1ad6e --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-khadas-vim3-fix-missing-i2c3-nod.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Christian Hewitt +Date: Fri, 21 Feb 2020 04:43:22 +0000 +Subject: WIP: arm64: dts: meson: khadas-vim3: fix missing i2c3 node + +Fixes: c6d29c66e582 ("arm64: dts: meson-g12b-khadas-vim3: add initial device-tree") + +The i2c3 node was missed in the original device-tree and is required for the +optional Khadas 3705 fan to work. + +Suggested-by: Art Nikpal +Signed-off-by: Christian Hewittt +--- + arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi b/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi +@@ -336,6 +336,13 @@ hdmi_tx_tmds_out: endpoint { + }; + }; + ++&i2c3 { ++ clock-frequency = <100000>; ++ pinctrl-0 = <&i2c3_sda_a_pins>, <&i2c3_sck_a_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++}; ++ + &i2c_AO { + status = "okay"; + pinctrl-0 = <&i2c_ao_sck_pins>, <&i2c_ao_sda_pins>; +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-khadas-vims-add-rtc-vrtc-aliases.patch b/patch/kernel/archive/meson64-6.13/board-khadas-vims-add-rtc-vrtc-aliases.patch new file mode 100644 index 000000000..173fa7e50 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-khadas-vims-add-rtc-vrtc-aliases.patch @@ -0,0 +1,58 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Christian Hewitt +Date: Thu, 21 Jan 2021 01:35:36 +0000 +Subject: HACK: arm64: dts: meson: add rtc/vrtc aliases to Khadas VIM + +Add aliases to ensure the vrtc time (which normally proves first) is /dev/rtc1 +while the onboard rtc chip claims /dev/rtc0. + +Signed-off-by: Christian Hewitt +--- + arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts +@@ -29,6 +29,8 @@ button-function { + aliases { + serial2 = &uart_AO_B; + ethernet0 = ðmac; ++ rtc0 = &rtc; ++ rtc1 = &vrtc; + }; + + gpio-keys-polled { +-- +Armbian + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Christian Hewitt +Date: Sat, 6 Nov 2021 13:01:08 +0000 +Subject: HACK: arm64: dts: meson: add rtc/vrtc aliases to Khadas VIM2 + +Add aliases to ensure the vrtc time (which normally proves first) is /dev/rtc1 +while the onboard rtc chip claims /dev/rtc0. + +Signed-off-by: Christian Hewitt +--- + arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts b/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts +@@ -18,6 +18,8 @@ / { + aliases { + serial0 = &uart_AO; + serial2 = &uart_AO_B; ++ rtc0 = &rtc; ++ rtc1 = &vrtc; + }; + + chosen { +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-nanopi-k2-add-uartC-alias.patch b/patch/kernel/archive/meson64-6.13/board-nanopi-k2-add-uartC-alias.patch new file mode 100644 index 000000000..f0e9918bd --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-nanopi-k2-add-uartC-alias.patch @@ -0,0 +1,26 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martin Ayotte +Date: Thu, 6 Dec 2018 18:03:17 -0500 +Subject: add uartC alias for nanopi-k2 + +add uartC alias for nanopi-k2 +- 839f2f151073928ed1e62d415ba5317f525b9e24: 1553615840: Martin Ayotte : 'add uartA overlay for Odroid-C2' +--- + arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts +@@ -15,6 +15,7 @@ / { + + aliases { + serial0 = &uart_AO; ++ serial2 = &uart_C; + ethernet0 = ðmac; + }; + +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-nanopi-k2-enable-emmc.patch b/patch/kernel/archive/meson64-6.13/board-nanopi-k2-enable-emmc.patch new file mode 100644 index 000000000..6405bd43c --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-nanopi-k2-enable-emmc.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Igor Pecovnik +Date: Tue, 4 Jun 2019 21:35:48 +0200 +Subject: nanopik2 - enable eMMC + +[ nanopik2 ] enable eMMC support for u-boot and kernel +--- + arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts +@@ -362,7 +362,7 @@ &sd_emmc_b { + + /* eMMC */ + &sd_emmc_c { +- status = "disabled"; ++ status = "okay"; + pinctrl-0 = <&emmc_pins>, <&emmc_ds_pins>; + pinctrl-1 = <&emmc_clk_gate_pins>; + pinctrl-names = "default", "clk-gate"; +@@ -372,8 +372,6 @@ &sd_emmc_c { + non-removable; + disable-wp; + cap-mmc-highspeed; +- mmc-ddr-1_8v; +- mmc-hs200-1_8v; + + mmc-pwrseq = <&emmc_pwrseq>; + vmmc-supply = <&vcc3v3>; +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-odroidc2-add-uartA-uartC.patch b/patch/kernel/archive/meson64-6.13/board-odroidc2-add-uartA-uartC.patch new file mode 100644 index 000000000..1a6cbae6d --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-odroidc2-add-uartA-uartC.patch @@ -0,0 +1,50 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martin Ayotte +Date: Thu, 26 Oct 2017 16:31:22 +0300 +Subject: add uartA and uartC for Odroid-C2 + +add uartA and uartC for Odroid-C2 + +- 839f2f151073928ed1e62d415ba5317f525b9e24: Martin Ayotte : 'add uartA overlay for Odroid-C2' +- b5c9e6ee8d4a97c5092109a12164c131eb4b46e9: Martin Ayotte : 'add uartA for odroidc2 in NEXT' +- 22ca2b92a002fe22e2a61428741618295c424664: Martin Ayotte : 'fix missing pinctrl-0 for ODroidC2 uartA' +- 140da6ad43f4a0d47c221271f62bb7c0a57064ea: Martin Ayotte : 'add uartC to OdroidC2' +--- + arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts | 14 ++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts +@@ -17,6 +17,8 @@ / { + + aliases { + serial0 = &uart_AO; ++ serial1 = &uart_A; ++ serial2 = &uart_C; + ethernet0 = ðmac; + }; + +@@ -387,6 +389,18 @@ &uart_AO { + pinctrl-names = "default"; + }; + ++&uart_A { ++ status = "disabled"; ++ pinctrl-0 = <&uart_a_pins>; ++ pinctrl-names = "default"; ++}; ++ ++&uart_C { ++ status = "disabled"; ++ pinctrl-0 = <&uart_c_pins>; ++ pinctrl-names = "default"; ++}; ++ + &usb0_phy { + status = "disabled"; + phy-supply = <&usb_otg_pwr>; +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-odroidc2-enable-SPI.patch b/patch/kernel/archive/meson64-6.13/board-odroidc2-enable-SPI.patch new file mode 100644 index 000000000..7c070a0ab --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-odroidc2-enable-SPI.patch @@ -0,0 +1,52 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Thomas McKahan +Date: Sat, 6 Oct 2018 22:50:14 -0400 +Subject: Odroid C2 enable SPI + +Odroid C2 enable SPI + +- f928b31d8a1983fd8cfd9c97de084e532283b106: 1543550719: Thomas McKahan : '[ meson64-dev ] fix Odroid C2 boot, add spidev' +--- + arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts | 26 ++++++++++ + 1 file changed, 26 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts +@@ -176,6 +176,32 @@ hdmi_connector_in: endpoint { + }; + }; + ++ spi-gpio { ++ compatible = "spi-gpio"; ++ #address-cells = <0x1>; ++ #size-cells = <0x0>; ++ ranges; ++ status = "disabled"; ++ sck-gpios = <&gpio GPIOX_2 0>; ++ miso-gpios = <&gpio GPIOX_4 0>; ++ mosi-gpios = <&gpio GPIOX_7 0>; ++ cs-gpios = <&gpio GPIOX_3 0 ++ &gpio GPIOX_1 0>; ++ num-chipselects = <2>; ++ ++ /* clients */ ++ spidev0@0 { ++ compatible = "armbian,spi-dev"; ++ reg = <0>; ++ spi-max-frequency = <500000>; ++ }; ++ spidev0@1 { ++ compatible = "armbian,spi-dev"; ++ reg = <1>; ++ spi-max-frequency = <500000>; ++ }; ++ }; ++ + sound { + compatible = "amlogic,gx-sound-card"; + model = "ODROID-C2"; +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-odroidc2-enable-scpi-dvfs.patch b/patch/kernel/archive/meson64-6.13/board-odroidc2-enable-scpi-dvfs.patch new file mode 100644 index 000000000..1de23f578 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-odroidc2-enable-scpi-dvfs.patch @@ -0,0 +1,27 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: zador-blood-stained +Date: Thu, 26 Oct 2017 16:31:22 +0300 +Subject: Enable odroidc2-dev DVFS + +Enable odroidc2-dev DVFS (#763) +--- + arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts +@@ -364,7 +364,8 @@ &saradc { + }; + + &scpi_clocks { +- status = "disabled"; ++ /* Works only with new blobs that have limited DVFS table */ ++ status = "okay"; + }; + + /* SD */ +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-odroidc2-usb-hub-disable-autosuspend-for-Genesys-Logic-.patch b/patch/kernel/archive/meson64-6.13/board-odroidc2-usb-hub-disable-autosuspend-for-Genesys-Logic-.patch new file mode 100644 index 000000000..10907691e --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-odroidc2-usb-hub-disable-autosuspend-for-Genesys-Logic-.patch @@ -0,0 +1,33 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Christian Hewitt +Date: Mon, 3 Jan 2022 10:44:17 +0000 +Subject: LOCAL: usb: hub: disable autosuspend for Genesys Logic Hubs + +Disable autosuspend in Genesys Logic hubs to allow USB devices on the +Odroid C2 board to be used. The alternative to this patch is setting +usbcore.autosuspend=-1 in boot params. + +This patch only impacts GXBB devices as GXL/GXM onwards use the newer +dwc3 core which does not have the problem. + +Signed-off-by: Christian Hewitt +--- + drivers/usb/core/hub.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c +index 111111111111..222222222222 100644 +--- a/drivers/usb/core/hub.c ++++ b/drivers/usb/core/hub.c +@@ -5965,7 +5965,7 @@ static const struct usb_device_id hub_id_table[] = { + | USB_DEVICE_ID_MATCH_INT_CLASS, + .idVendor = USB_VENDOR_GENESYS_LOGIC, + .bInterfaceClass = USB_CLASS_HUB, +- .driver_info = HUB_QUIRK_CHECK_PORT_AUTOSUSPEND}, ++ .driver_info = HUB_QUIRK_DISABLE_AUTOSUSPEND}, + { .match_flags = USB_DEVICE_ID_MATCH_VENDOR + | USB_DEVICE_ID_MATCH_PRODUCT, + .idVendor = USB_VENDOR_TEXAS_INSTRUMENTS, +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-odroidc4-reset.patch b/patch/kernel/archive/meson64-6.13/board-odroidc4-reset.patch new file mode 100644 index 000000000..8ad61c277 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-odroidc4-reset.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Ash Hughes +Date: Sat, 18 Feb 2023 07:46:38 -0300 +Subject: adapted meson64-reboot driver, fix reboot on odroid C4 when using + UHS-II SD cards + +bring back fixed version of `odroid-reboot` driver (Fix reboot on odroid C4 when using UHS-II SD cards) +--- + arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts b/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-c4.dts +@@ -11,6 +11,16 @@ / { + compatible = "hardkernel,odroid-c4", "amlogic,sm1"; + model = "Hardkernel ODROID-C4"; + ++ meson64-reboot { ++ compatible = "meson64,reboot"; ++ sys_reset = <0x84000009>; ++ sys_poweroff = <0x84000008>; ++ ++ sd-vqen = <&gpio_ao GPIOE_2 GPIO_ACTIVE_HIGH>; ++ sd-vqsw = <&gpio_ao GPIOAO_6 GPIO_ACTIVE_HIGH>; ++ sd-vmmc = <&gpio_ao GPIOAO_3 GPIO_ACTIVE_HIGH>; ++ }; ++ + leds { + compatible = "gpio-leds"; + +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-odroidhc4-enable-fan1_input.patch b/patch/kernel/archive/meson64-6.13/board-odroidhc4-enable-fan1_input.patch new file mode 100644 index 000000000..26720cb2e --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-odroidhc4-enable-fan1_input.patch @@ -0,0 +1,29 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Ricardo Pardini +Date: Sun, 26 Jun 2022 03:47:06 +0200 +Subject: ODROID-HC4: add DT attributes to enable fan1_input + +- from vendor kernel modified DT +- this allows userspace fancontrol/pwmconfig to work +--- + arch/arm64/boot/dts/amlogic/meson-sm1-odroid-hc4.dts | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-hc4.dts b/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-hc4.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-hc4.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-sm1-odroid-hc4.dts +@@ -21,6 +21,10 @@ fan0: pwm-fan { + #cooling-cells = <2>; + cooling-levels = <0 120 170 220>; + pwms = <&pwm_cd 1 40000 0>; ++ fan-supply = <&vcc_5v>; ++ interrupt-parent = <&gpio_intc>; ++ interrupts = <84 IRQ_TYPE_EDGE_FALLING>; ++ pulses-per-revolutions = <2>; + }; + + leds { +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-odroidn2plus-Add-missing-CPU-opp.patch b/patch/kernel/archive/meson64-6.13/board-odroidn2plus-Add-missing-CPU-opp.patch new file mode 100644 index 000000000..d6511912b --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-odroidn2plus-Add-missing-CPU-opp.patch @@ -0,0 +1,46 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Igor Pecovnik +Date: Wed, 10 Feb 2021 18:07:08 +0100 +Subject: Add missing CPU opp values for clocking g12b / N2+ higher + +Signed-off-by: Igor Pecovnik +--- + arch/arm64/boot/dts/amlogic/meson-g12b-a311d.dtsi | 16 ++++++++++ + 1 file changed, 16 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-a311d.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12b-a311d.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-g12b-a311d.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-g12b-a311d.dtsi +@@ -45,6 +45,14 @@ opp-1800000000 { + opp-hz = /bits/ 64 <1800000000>; + opp-microvolt = <1001000>; + }; ++ opp-1908000000 { ++ opp-hz = /bits/ 64 <1908000000>; ++ opp-microvolt = <1030000>; ++ }; ++ opp-2016000000 { ++ opp-hz = /bits/ 64 <2016000000>; ++ opp-microvolt = <1040000>; ++ }; + }; + + cpub_opp_table_1: opp-table-1 { +@@ -105,5 +113,13 @@ opp-2208000000 { + opp-hz = /bits/ 64 <2208000000>; + opp-microvolt = <1011000>; + }; ++ opp-2304000000 { ++ opp-hz = /bits/ 64 <2304000000>; ++ opp-microvolt = <1030000>; ++ }; ++ opp-2400000000 { ++ opp-hz = /bits/ 64 <2400000000>; ++ opp-microvolt = <1040000>; ++ }; + }; + }; +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-radxa-zero-dts-add-aliases-for-serial-i2c-and-spi.patch b/patch/kernel/archive/meson64-6.13/board-radxa-zero-dts-add-aliases-for-serial-i2c-and-spi.patch new file mode 100644 index 000000000..720442f12 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-radxa-zero-dts-add-aliases-for-serial-i2c-and-spi.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Patrick Yavitz +Date: Tue, 24 Oct 2023 08:17:17 -0400 +Subject: arm64: dts: Radxa Zero: set aliases for serial, i2c and spi + +Signed-off-by: Patrick Yavitz +--- + arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts | 12 ++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts b/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts +@@ -15,6 +15,18 @@ / { + + aliases { + serial0 = &uart_AO; ++ serial1 = &uart_AO_B; ++ serial2 = &uart_A; ++ serial3 = &uart_B; ++ serial4 = &uart_C; ++ i2c0 = &i2c0; ++ i2c1 = &i2c1; ++ i2c2 = &i2c2; ++ i2c3 = &i2c3; ++ i2c4 = &i2c_AO; ++ spi0 = &spicc0; ++ spi1 = &spicc1; ++ spi2 = &spifc; + }; + + chosen { +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-radxa-zero-dts-add-support-for-the-usb-c-controller.patch b/patch/kernel/archive/meson64-6.13/board-radxa-zero-dts-add-support-for-the-usb-c-controller.patch new file mode 100644 index 000000000..1263cda9a --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-radxa-zero-dts-add-support-for-the-usb-c-controller.patch @@ -0,0 +1,104 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Christian Hewitt +Date: Tue, 17 Aug 2021 16:16:43 +0000 +Subject: arm64: dts: meson: radxa-zero: add support for the usb type-c + controller + +Radxa Zero uses an FUSB302 type-c controller, so lets enable it. + +NB: Polarity swapping via GPIO is not implemented in the current driver +(see drivers/usb/typec/tcpm/fusb302.c) so it is not possible to handle +GPIOAO_6 for USB3 polarity control. + +Includes: +- arm64: dts: amlogic: fix interrupt storm from fusb302 on Radxa Zero + it makes load average >1. use correct pin for interrupt from fusb302. + +Signed-off-by: FUKAUMI Naoki +Suggested-by: Neil Armstrong +Signed-off-by: Christian Hewitt +Signed-off-by: Yuntian Zhang +--- + arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts | 48 ++++++++++ + 1 file changed, 48 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts b/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts +@@ -72,6 +72,14 @@ sdio_pwrseq: sdio-pwrseq { + clock-names = "ext_clock"; + }; + ++ typec2_vbus: regulator-typec2_vbus { ++ compatible = "regulator-fixed"; ++ regulator-name = "TYPEC2_VBUS"; ++ regulator-min-microvolt = <5000000>; ++ regulator-max-microvolt = <5000000>; ++ vin-supply = <&ao_5v>; ++ }; ++ + ao_5v: regulator-ao-5v { + compatible = "regulator-fixed"; + regulator-name = "AO_5V"; +@@ -206,6 +214,18 @@ wifi32k: wifi32k { + }; + }; + ++&ao_pinctrl { ++ /* Ensure the TYPE C controller irq pin is not driven by the SoC */ ++ fusb302_irq_pins: fusb302_irq { ++ mux { ++ groups = "GPIOAO_5"; ++ function = "gpio_aobus"; ++ bias-pull-up; ++ output-disable; ++ }; ++ }; ++}; ++ + &arb { + status = "okay"; + }; +@@ -293,6 +313,26 @@ &ir { + pinctrl-names = "default"; + }; + ++&i2c3 { ++ pinctrl-0 = <&i2c3_sda_a_pins>, <&i2c3_sck_a_pins>; ++ pinctrl-names = "default"; ++ status = "okay"; ++ ++ fusb302@22 { ++ compatible = "fcs,fusb302"; ++ reg = <0x22>; ++ ++ pinctrl-0 = <&fusb302_irq_pins>; ++ pinctrl-names = "default"; ++ interrupt-parent = <&gpio_intc>; ++ interrupts = <5 IRQ_TYPE_LEVEL_LOW>; ++ ++ vbus-supply = <&typec2_vbus>; ++ ++ status = "okay"; ++ }; ++}; ++ + &pwm_AO_cd { + pinctrl-0 = <&pwm_ao_d_e_pins>; + pinctrl-names = "default"; +@@ -417,3 +457,11 @@ &uart_AO { + &usb { + status = "okay"; + }; ++ ++&usb2_phy0 { ++ phy-supply = <&typec2_vbus>; ++}; ++ ++&usb3_pcie_phy { ++ phy-supply = <&typec2_vbus>; ++}; +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-radxa-zero-dts-slow-down-sdio-for-working-emmc.patch b/patch/kernel/archive/meson64-6.13/board-radxa-zero-dts-slow-down-sdio-for-working-emmc.patch new file mode 100644 index 000000000..76ee25bd6 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-radxa-zero-dts-slow-down-sdio-for-working-emmc.patch @@ -0,0 +1,25 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Chen Jiali +Date: Tue, 23 Apr 2024 16:05:42 +0800 +Subject: Reduce eMMC frequency to improve compatibility + +--- + arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts b/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts +@@ -413,7 +413,7 @@ &sd_emmc_c { + cap-mmc-highspeed; + mmc-ddr-1_8v; + mmc-hs200-1_8v; +- max-frequency = <200000000>; ++ max-frequency = <150000000>; + disable-wp; + + mmc-pwrseq = <&emmc_pwrseq>; +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-radxa-zero-dts-slow-down-sdio-for-working-wifi.patch b/patch/kernel/archive/meson64-6.13/board-radxa-zero-dts-slow-down-sdio-for-working-wifi.patch new file mode 100644 index 000000000..6ced91999 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-radxa-zero-dts-slow-down-sdio-for-working-wifi.patch @@ -0,0 +1,29 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Yuntian Zhang +Date: Mon, 27 Jun 2022 15:06:32 +0800 +Subject: VENDOR: Radxa Zero Wi-Fi fix + +Credit: pyavitz from Armbian + +Signed-off-by: Yuntian Zhang +Signed-off-by: Patrick Yavitz +--- + arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts b/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts +@@ -365,7 +365,7 @@ &sd_emmc_a { + + bus-width = <4>; + cap-sd-highspeed; +- sd-uhs-sdr50; ++ cap-mmc-highspeed; + max-frequency = <100000000>; + + non-removable; +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/board-t95z-add-rc-remote-keymap.patch b/patch/kernel/archive/meson64-6.13/board-t95z-add-rc-remote-keymap.patch new file mode 100644 index 000000000..2111c5697 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/board-t95z-add-rc-remote-keymap.patch @@ -0,0 +1,153 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Christian Hewitt +Date: Mon, 13 Feb 2023 11:38:16 +0000 +Subject: add rc keymaps for Sunvell T95Z Plus + +WIP: media: rc: add keymap for Sunvell T95Z Plus +WIP: dt-bindings: media: rc: add rc-sunvell-t95z-plus +Add a binding for the rc-sunvell-t95z-plus remote keymap +WIP: dt-bindings: add sunvell vendor prefix +Add vendor prefix for Shenzhen Sunvell Electronics Co., Ltd + +Signed-off-by: Christian Hewitt +--- + Documentation/devicetree/bindings/media/rc.yaml | 1 + + Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 + + drivers/media/rc/keymaps/Makefile | 1 + + drivers/media/rc/keymaps/rc-sunvell-t95z-plus.c | 75 ++++++++++ + include/media/rc-map.h | 1 + + 5 files changed, 80 insertions(+) + +diff --git a/Documentation/devicetree/bindings/media/rc.yaml b/Documentation/devicetree/bindings/media/rc.yaml +index 111111111111..222222222222 100644 +--- a/Documentation/devicetree/bindings/media/rc.yaml ++++ b/Documentation/devicetree/bindings/media/rc.yaml +@@ -128,6 +128,7 @@ properties: + - rc-reddo + - rc-snapstream-firefly + - rc-streamzap ++ - rc-sunvell-t95z-plus + - rc-su3000 + - rc-tanix-tx3mini + - rc-tanix-tx5max +diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml +index 111111111111..222222222222 100644 +--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml ++++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml +@@ -1437,6 +1437,8 @@ patternProperties: + description: Sundance DSP Inc. + "^sunplus,.*": + description: Sunplus Technology Co., Ltd. ++ "^sunvell,.*": ++ description: Shenzhen Sunvell Electronics Co., Ltd + "^SUNW,.*": + description: Sun Microsystems, Inc + "^supermicro,.*": +diff --git a/drivers/media/rc/keymaps/Makefile b/drivers/media/rc/keymaps/Makefile +index 111111111111..222222222222 100644 +--- a/drivers/media/rc/keymaps/Makefile ++++ b/drivers/media/rc/keymaps/Makefile +@@ -108,6 +108,7 @@ obj-$(CONFIG_RC_MAP) += \ + rc-reddo.o \ + rc-snapstream-firefly.o \ + rc-streamzap.o \ ++ rc-sunvell-t95z-plus.o \ + rc-su3000.o \ + rc-tanix-tx3mini.o \ + rc-tanix-tx5max.o \ +diff --git a/drivers/media/rc/keymaps/rc-sunvell-t95z-plus.c b/drivers/media/rc/keymaps/rc-sunvell-t95z-plus.c +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/drivers/media/rc/keymaps/rc-sunvell-t95z-plus.c +@@ -0,0 +1,75 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * Copyright (c) 2023 Christian Hewitt ++#include ++ ++/* ++ * Keytable for Sunvell T95Z Plus remote control ++ * ++ */ ++ ++static struct rc_map_table sunvell_t95z_plus[] = { ++ { 0xdf1c, KEY_POWER }, ++ // TV CONTROLS ++ ++ { 0xdf4b, KEY_PREVIOUS }, ++ { 0xdf01, KEY_SCREEN }, // TV ++ { 0xdf5d, KEY_VOLUMEUP }, ++ ++ { 0xdf4f, KEY_NEXT }, ++ { 0xdf5f, KEY_FAVORITES }, // KODI ++ { 0xdf5c, KEY_VOLUMEDOWN }, ++ ++ { 0xdf42, KEY_HOME }, ++ { 0xdf0a, KEY_BACK }, ++ ++ { 0xdf1a, KEY_UP }, ++ { 0xdf47, KEY_LEFT }, ++ { 0xdf06, KEY_ENTER }, ++ { 0xdf07, KEY_RIGHT }, ++ { 0xdf48, KEY_DOWN }, ++ ++ { 0xdf03, KEY_INFO }, // MOUSE ++ { 0xdf18, KEY_MENU }, ++ ++ { 0xdf54, KEY_1 }, ++ { 0xdf16, KEY_2 }, ++ { 0xdf15, KEY_3 }, ++ { 0xdf50, KEY_4 }, ++ { 0xdf12, KEY_5 }, ++ { 0xdf11, KEY_6 }, ++ { 0xdf4c, KEY_7 }, ++ { 0xdf0e, KEY_8 }, ++ { 0xdf0d, KEY_9 }, ++ { 0xdf41, KEY_WWW }, // WORLD ++ { 0xdf0c, KEY_0 }, ++ { 0xdf10, KEY_DELETE }, ++}; ++ ++static struct rc_map_list sunvell_t95z_plus_map = { ++ .map = { ++ .scan = sunvell_t95z_plus, ++ .size = ARRAY_SIZE(sunvell_t95z_plus), ++ .rc_proto = RC_PROTO_NEC, ++ .name = RC_MAP_SUNVELL_T95Z_PLUS, ++ } ++}; ++ ++static int __init init_rc_map_sunvell_t95z_plus(void) ++{ ++ return rc_map_register(&sunvell_t95z_plus_map); ++} ++ ++static void __exit exit_rc_map_sunvell_t95z_plus(void) ++{ ++ rc_map_unregister(&sunvell_t95z_plus_map); ++} ++ ++module_init(init_rc_map_sunvell_t95z_plus) ++module_exit(exit_rc_map_sunvell_t95z_plus) ++ ++MODULE_LICENSE("GPL"); ++MODULE_AUTHOR("Christian Hewitt "); +diff --git a/include/media/rc-map.h b/include/media/rc-map.h +index 111111111111..222222222222 100644 +--- a/include/media/rc-map.h ++++ b/include/media/rc-map.h +@@ -315,6 +315,7 @@ struct rc_map *rc_map_get(const char *name); + #define RC_MAP_REDDO "rc-reddo" + #define RC_MAP_SNAPSTREAM_FIREFLY "rc-snapstream-firefly" + #define RC_MAP_STREAMZAP "rc-streamzap" ++#define RC_MAP_SUNVELL_T95Z_PLUS "rc-sunvell-t95z-plus" + #define RC_MAP_SU3000 "rc-su3000" + #define RC_MAP_TANIX_TX3MINI "rc-tanix-tx3mini" + #define RC_MAP_TANIX_TX5MAX "rc-tanix-tx5max" +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/driver-power-meson64-reset.patch b/patch/kernel/archive/meson64-6.13/driver-power-meson64-reset.patch new file mode 100644 index 000000000..7640a49d8 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/driver-power-meson64-reset.patch @@ -0,0 +1,236 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Patrick Yavitz +Date: Thu, 1 Jun 2023 06:32:23 +0200 +Subject: pyavitz meson64-generalized `odroid-reboot` driver + +--- + drivers/power/reset/Kconfig | 7 + + drivers/power/reset/Makefile | 1 + + drivers/power/reset/meson64-reboot.c | 186 ++++++++++ + 3 files changed, 194 insertions(+) + +diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig +index 111111111111..222222222222 100644 +--- a/drivers/power/reset/Kconfig ++++ b/drivers/power/reset/Kconfig +@@ -159,6 +159,13 @@ config POWER_RESET_ODROID_GO_ULTRA_POWEROFF + help + This driver supports Power off for Odroid Go Ultra device. + ++config POWER_RESET_MESON64 ++ bool "Meson64 reboot/power-off driver" ++ depends on ARCH_MESON ++ help ++ The driver supports restart / power off for amlogic ++ g12a, g12b and sm1 SoCs ++ + config POWER_RESET_PIIX4_POWEROFF + tristate "Intel PIIX4 power-off driver" + depends on PCI +diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile +index 111111111111..222222222222 100644 +--- a/drivers/power/reset/Makefile ++++ b/drivers/power/reset/Makefile +@@ -15,6 +15,7 @@ obj-$(CONFIG_POWER_RESET_HISI) += hisi-reboot.o + obj-$(CONFIG_POWER_RESET_LINKSTATION) += linkstation-poweroff.o + obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o + obj-$(CONFIG_POWER_RESET_MT6323) += mt6323-poweroff.o ++obj-$(CONFIG_POWER_RESET_MESON64) += meson64-reboot.o + obj-$(CONFIG_POWER_RESET_QCOM_PON) += qcom-pon.o + obj-$(CONFIG_POWER_RESET_OCELOT_RESET) += ocelot-reset.o + obj-$(CONFIG_POWER_RESET_ODROID_GO_ULTRA_POWEROFF) += odroid-go-ultra-poweroff.o +diff --git a/drivers/power/reset/meson64-reboot.c b/drivers/power/reset/meson64-reboot.c +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/drivers/power/reset/meson64-reboot.c +@@ -0,0 +1,186 @@ ++// SPDX-License-Identifier: (GPL-2.0) ++/* ++ * drivers/power/reset/meson64-reboot.c ++ * ++ * Copyright (C) 2017 Amlogic, Inc. All rights reserved. ++ * Copyright (C) 2023 Ash Hughes (sehguh.hsa@gmail.com) ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, but WITHOUT ++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for ++ * more details. ++ * ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++ ++#include ++#include ++#include ++ ++#include ++#include ++ ++int sd_vqsw; ++int sd_vmmc; ++int sd_vqen; ++ ++static u32 psci_function_id_restart; ++static u32 psci_function_id_poweroff; ++ ++#define CHECK_RET(ret) { \ ++ if (ret) \ ++ pr_err("[%s] gpio op failed(%d) at line %d\n",\ ++ __func__, ret, __LINE__); \ ++} ++ ++static noinline int __invoke_psci_fn_smc(u64 function_id, u64 arg0, u64 arg1, ++ u64 arg2) ++{ ++ struct arm_smccc_res res; ++ ++ arm_smccc_smc((unsigned long)function_id, ++ (unsigned long)arg0, ++ (unsigned long)arg1, ++ (unsigned long)arg2, ++ 0, 0, 0, 0, &res); ++ return res.a0; ++} ++ ++void meson64_card_reset(void) ++{ ++ int ret = 0; ++ ++ if ((sd_vqsw == 0) && (sd_vmmc == 0)) ++ return; ++ ++ if (sd_vqen == 0) { ++ gpio_free(sd_vqsw); ++ gpio_free(sd_vmmc); ++ ret = gpio_request_one(sd_vqsw, ++ GPIOF_OUT_INIT_LOW, "REBOOT"); ++ CHECK_RET(ret); ++ mdelay(10); ++ ret = gpio_direction_output(sd_vqsw, 1); ++ CHECK_RET(ret); ++ ret = gpio_request_one(sd_vmmc, ++ GPIOF_OUT_INIT_LOW, "REBOOT"); ++ CHECK_RET(ret); ++ mdelay(10); ++ ret = gpio_direction_output(sd_vqsw, 0); ++ CHECK_RET(ret); ++ ret = gpio_direction_output(sd_vmmc, 1); ++ CHECK_RET(ret); ++ mdelay(5); ++ gpio_free(sd_vqsw); ++ gpio_free(sd_vmmc); ++ } else { ++ gpio_free(sd_vqsw); ++ gpio_free(sd_vqen); ++ gpio_free(sd_vmmc); ++ ++ ret = gpio_request_one(sd_vqsw, ++ GPIOF_OUT_INIT_LOW, "REBOOT"); ++ CHECK_RET(ret); ++ ret = gpio_request_one(sd_vqen, ++ GPIOF_OUT_INIT_LOW, "REBOOT"); ++ CHECK_RET(ret); ++ ret = gpio_request_one(sd_vmmc, ++ GPIOF_OUT_INIT_LOW, "REBOOT"); ++ CHECK_RET(ret); ++ mdelay(100); ++ ret = gpio_direction_input(sd_vqen); ++ CHECK_RET(ret); ++ ret = gpio_direction_input(sd_vmmc); ++ CHECK_RET(ret); ++ ret = gpio_direction_input(sd_vqsw); ++ CHECK_RET(ret); ++ mdelay(5); ++ gpio_free(sd_vqen); ++ gpio_free(sd_vmmc); ++ gpio_free(sd_vqsw); ++ } ++} ++ ++static int do_meson64_restart(struct notifier_block *this, unsigned long mode, void *cmd) ++{ ++ meson64_card_reset(); ++ return NOTIFY_DONE; ++} ++ ++static struct notifier_block meson64_restart_handler = { ++ .notifier_call = do_meson64_restart, ++ .priority = 130, ++}; ++ ++static void do_meson64_poweroff(void) ++{ ++ meson64_card_reset(); ++ ++ __invoke_psci_fn_smc(0x82000042, 1, 0, 0); ++} ++ ++static int meson64_restart_probe(struct platform_device *pdev) ++{ ++ struct device_node *of_node; ++ u32 id; ++ ++ if (!of_property_read_u32(pdev->dev.of_node, "sys_reset", &id)) { ++ psci_function_id_restart = id; ++ register_restart_handler(&meson64_restart_handler); ++ } ++ ++ if (!of_property_read_u32(pdev->dev.of_node, "sys_poweroff", &id)) { ++ psci_function_id_poweroff = id; ++ pm_power_off = do_meson64_poweroff; ++ } ++ ++ of_node = pdev->dev.of_node; ++ ++ sd_vqsw = of_get_named_gpio(of_node, "sd-vqsw", 0); ++ if (!gpio_is_valid(sd_vqsw)) sd_vqsw = 0; ++ ++ sd_vmmc = of_get_named_gpio(of_node, "sd-vmmc", 0); ++ if (!gpio_is_valid(sd_vmmc)) sd_vmmc = 0; ++ ++ sd_vqen = of_get_named_gpio(of_node, "sd-vqen", 0); ++ if (!gpio_is_valid(sd_vqen)) sd_vqen = 0; ++ ++ return 0; ++} ++ ++static const struct of_device_id of_meson64_restart_match[] = { ++ { .compatible = "meson64,reboot", }, ++ {}, ++}; ++MODULE_DEVICE_TABLE(of, of_meson64_restart_match); ++ ++static struct platform_driver meson64_restart_driver = { ++ .probe = meson64_restart_probe, ++ .driver = { ++ .name = "meson64-restart", ++ .of_match_table = of_match_ptr(of_meson64_restart_match), ++ }, ++}; ++ ++static int __init meson64_restart_init(void) ++{ ++ return platform_driver_register(&meson64_restart_driver); ++} ++device_initcall(meson64_restart_init); ++ +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/drv-spi-spidev-remove-warnings.patch b/patch/kernel/archive/meson64-6.13/drv-spi-spidev-remove-warnings.patch new file mode 100644 index 000000000..b480422c8 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/drv-spi-spidev-remove-warnings.patch @@ -0,0 +1,33 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: John Doe +Date: Wed, 14 Aug 2024 16:33:07 +0000 +Subject: rockchip64: edge: 6.10.5 drv:spi:spidev remove warnings + +Signed-off-by: John Doe +--- + drivers/spi/spidev.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c +index 111111111111..222222222222 100644 +--- a/drivers/spi/spidev.c ++++ b/drivers/spi/spidev.c +@@ -699,6 +699,7 @@ static const struct class spidev_class = { + }; + + static const struct spi_device_id spidev_spi_ids[] = { ++ { .name = "spi-dev" }, + { .name = "bh2228fv" }, + { .name = "dh2228fv" }, + { .name = "jg10309-01" }, +@@ -729,6 +730,7 @@ static int spidev_of_check(struct device *dev) + } + + static const struct of_device_id spidev_dt_ids[] = { ++ { .compatible = "armbian,spi-dev", .data = &spidev_of_check }, + { .compatible = "cisco,spi-petra", .data = &spidev_of_check }, + { .compatible = "dh,dhcom-board", .data = &spidev_of_check }, + { .compatible = "elgin,jg10309-01", .data = &spidev_of_check }, +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-axg-amper-gateway-am-gz80x.dts b/patch/kernel/archive/meson64-6.13/dt/meson-axg-amper-gateway-am-gz80x.dts new file mode 100644 index 000000000..57c9b607f --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-axg-amper-gateway-am-gz80x.dts @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2024 Patrick Yavitz + */ + +/dts-v1/; + +#include "meson-axg-amper-gateway-gz80x.dtsi" + +/ { + compatible = "amper,gateway-am-gz80x", "amlogic,a113x", "amlogic,meson-axg"; + model = "Amper Gateway AM-GZ80x"; + + aliases { + serial1 = &uart_B; + serial2 = &uart_AO_B; + ethernet0 = ðmac; + }; + + /* 1024MB RAM */ + memory@0 { + device_type = "memory"; + reg = <0x0 0x0 0x0 0x40000000>; + }; +}; + +&sd_emmc_b { + sdio: wifi@1 { + reg = <1>; + }; +}; + +&uart_B { + status = "okay"; + pinctrl-0 = <&uart_b_z_pins>; + pinctrl-names = "default"; +}; diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-axg-amper-gateway-gz80x.dtsi b/patch/kernel/archive/meson64-6.13/dt/meson-axg-amper-gateway-gz80x.dtsi new file mode 100644 index 000000000..951446925 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-axg-amper-gateway-gz80x.dtsi @@ -0,0 +1,297 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2024 Patrick Yavitz + */ + +/dts-v1/; + +#include "meson-axg.dtsi" +#include +#include +#include + +/ { + aliases { + serial0 = &uart_AO; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + emmc_pwrseq: emmc-pwrseq { + compatible = "mmc-pwrseq-emmc"; + reset-gpios = <&gpio BOOT_9 GPIO_ACTIVE_LOW>; + }; + + gpio-keys-polled { + compatible = "gpio-keys-polled"; + poll-interval = <100>; + + button-power { + label = "power"; + linux,code = ; + gpios = <&gpio_ao GPIOAO_6 GPIO_ACTIVE_HIGH>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led-blue { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&gpio_ao GPIOAO_3 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "default-on"; + }; + + led-green { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&gpio_ao GPIOAO_4 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "mmc1"; + }; + + led-red { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&gpio_ao GPIOAO_7 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "usb-host"; + }; + }; + + reserved-memory { + linux,cma { + size = <0x0 0x400000>; + }; + }; + + sdio_pwrseq: sdio-pwrseq { + compatible = "mmc-pwrseq-simple"; + reset-gpios = <&gpio GPIOX_7 GPIO_ACTIVE_LOW>; + clocks = <&wifi32k>; + clock-names = "ext_clock"; + }; + + thermal-zones { + cpu_thermal: cpu-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + thermal-sensors = <&scpi_sensors 0>; + trips { + cpu_passive: cpu-passive { + temperature = <70000>; /* millicelsius */ + hysteresis = <2000>; /* millicelsius */ + type = "passive"; + }; + + cpu_hot: cpu-hot { + temperature = <80000>; /* millicelsius */ + hysteresis = <2000>; /* millicelsius */ + type = "hot"; + }; + + cpu_critical: cpu-critical { + temperature = <100000>; /* millicelsius */ + hysteresis = <2000>; /* millicelsius */ + type = "critical"; + }; + }; + + cpu_cooling_maps: cooling-maps { + map0 { + trip = <&cpu_passive>; + cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + + map1 { + trip = <&cpu_hot>; + cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + }; + + usb_pwr: regulator-usb_pwr { + compatible = "regulator-fixed"; + regulator-name = "USB_PWR"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + vin-supply = <&vcc_5v>; + regulator-always-on; + + gpio = <&gpio_ao GPIOAO_5 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + vcc_3v3: regulator-vcc_3v3 { + compatible = "regulator-fixed"; + regulator-name = "VCC_3V3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + vin-supply = <&vddao_3v3>; + regulator-always-on; + }; + + vcc_5v: regulator-vcc_5v { + compatible = "regulator-fixed"; + regulator-name = "VCC5V"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-always-on; + }; + + vddao_3v3: regulator-vddao_3v3 { + compatible = "regulator-fixed"; + regulator-name = "VDDAO_3V3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + vin-supply = <&vcc_5v>; + regulator-always-on; + }; + + vddio_ao18: regulator-vddio_ao18 { + compatible = "regulator-fixed"; + regulator-name = "VDDIO_AO18"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + vin-supply = <&vddao_3v3>; + regulator-always-on; + }; + + vddio_boot: regulator-vddio_boot { + compatible = "regulator-fixed"; + regulator-name = "VDDIO_BOOT"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + vin-supply = <&vddao_3v3>; + regulator-always-on; + }; + + vccq_1v8: regulator-vccq_1v8 { + compatible = "regulator-fixed"; + regulator-name = "VCCQ_1V8"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + vin-supply = <&vddao_3v3>; + regulator-always-on; + }; + + wifi32k: wifi32k { + compatible = "pwm-clock"; + #clock-cells = <0>; + clock-frequency = <32768>; + pwms = <&pwm_ab 0 30518 0>; /* PWM_A at 32.768KHz */ + }; +}; + +&cpu0 { + #cooling-cells = <2>; +}; + +&cpu1 { + #cooling-cells = <2>; +}; + +&cpu2 { + #cooling-cells = <2>; +}; + +&cpu3 { + #cooling-cells = <2>; +}; + +ðmac { + status = "okay"; + pinctrl-0 = <ð_rmii_x_pins>; + pinctrl-names = "default"; + phy-mode = "rmii"; +}; + +/* Peripheral I2C bus (on motherboard) */ +&i2c_AO { + status = "okay"; + pinctrl-0 = <&i2c_ao_sck_10_pins>, <&i2c_ao_sda_11_pins>; + pinctrl-names = "default"; +}; + +&pwm_ab { + status = "okay"; + pinctrl-0 = <&pwm_a_x20_pins>; + pinctrl-names = "default"; +}; + +/* WiFi module */ +&sd_emmc_b { + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + + pinctrl-0 = <&sdio_pins>; + pinctrl-1 = <&sdio_clk_gate_pins>; + pinctrl-names = "default", "clk-gate"; + + bus-width = <4>; + cap-sd-highspeed; + max-frequency = <50000000>; + disable-wp; + non-removable; + + mmc-pwrseq = <&sdio_pwrseq>; + + vmmc-supply = <&vddao_3v3>; + vqmmc-supply = <&vddio_boot>; +}; + +/* eMMC Storage */ +&sd_emmc_c { + status = "okay"; + pinctrl-0 = <&emmc_pins>, <&emmc_ds_pins>; + pinctrl-1 = <&emmc_clk_gate_pins>; + pinctrl-names = "default", "clk-gate"; + + bus-width = <8>; + cap-mmc-highspeed; + max-frequency = <200000000>; + non-removable; + disable-wp; + mmc-ddr-1_8v; + mmc-hs200-1_8v; + + mmc-pwrseq = <&emmc_pwrseq>; + + vmmc-supply = <&vcc_3v3>; + vqmmc-supply = <&vccq_1v8>; +}; + +&spicc1 { + status = "okay"; + pinctrl-0 = <&spi1_x_pins>, <&spi1_ss0_x_pins>; + pinctrl-names = "default"; +}; + +/* UART Console */ +&uart_AO { + status = "okay"; + pinctrl-0 = <&uart_ao_a_pins>; + pinctrl-names = "default"; +}; + +/* UART Wireless module */ +&uart_AO_B { + status = "okay"; + pinctrl-0 = <&uart_ao_b_z_pins>; + pinctrl-names = "default"; + reset-gpios = <&gpio GPIOZ_6 GPIO_ACTIVE_HIGH>; +}; + +&usb { + status = "okay"; + vbus-supply = <&usb_pwr>; +}; diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-g12-enable-spinor.dtsi b/patch/kernel/archive/meson64-6.13/dt/meson-g12-enable-spinor.dtsi new file mode 100644 index 000000000..a6f11e8cd --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-g12-enable-spinor.dtsi @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +/* + * Replace emmc_data_8b_pins to emmc_data_4b_pins from sd_emmc_c pinctrl-0, and change bus-width to 4 then spifc can be enabled. + */ +&sd_emmc_c { + pinctrl-0 = <&emmc_ctrl_pins>, <&emmc_data_4b_pins>, <&emmc_ds_pins>; + bus-width = <4>; +}; + +&spifc { + status = "okay"; +}; diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-g12a-radxa-zero-spidev.dts b/patch/kernel/archive/meson64-6.13/dt/meson-g12a-radxa-zero-spidev.dts new file mode 100644 index 000000000..5ee13525d --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-g12a-radxa-zero-spidev.dts @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +/dts-v1/; + +#include "meson-g12a-radxa-zero.dts" + +/ { + model = "Radxa Zero with SPIDEV and I2C - MOSI pin 19, CLK pin 23 - SDA pin 3, SCL pin 5"; +}; + +&spicc1 { + pinctrl-0 = <&spicc1_pins &spicc1_ss0_pins>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + spidev@0 { + compatible = "armbian,spi-dev"; + status = "okay"; + reg = <0>; + spi-max-frequency = <10000000>; + }; +}; + +&i2c3 { + status = "okay"; + pinctrl-0 = <&i2c3_sck_a_pins &i2c3_sda_a_pins>; + pinctrl-names = "default"; +}; diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-g12b-a311d-khadas-vim3-spidev.dts b/patch/kernel/archive/meson64-6.13/dt/meson-g12b-a311d-khadas-vim3-spidev.dts new file mode 100644 index 000000000..8982a04c9 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-g12b-a311d-khadas-vim3-spidev.dts @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +/dts-v1/; + +#include "meson-g12b-a311d-khadas-vim3.dts" + +/ { + model = "Khadas VIM3 with SPIDEV and I2C - MOSI pin 37, CLK pin 16 - SDA pin 23, SCL pin 23"; +}; + +&spicc1 { + pinctrl-0 = <&spicc1_pins &spicc1_ss0_pins>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + spidev@0 { + compatible = "armbian,spi-dev"; + status = "okay"; + reg = <0>; + spi-max-frequency = <10000000>; + }; +}; + +&i2c3 { + status = "okay"; + pinctrl-0 = <&i2c3_sck_a_pins &i2c3_sda_a_pins>; + pinctrl-names = "default"; +}; diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-g12b-a311d-khadas-vim3-spinor.dts b/patch/kernel/archive/meson64-6.13/dt/meson-g12b-a311d-khadas-vim3-spinor.dts new file mode 100644 index 000000000..e21dd8fd3 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-g12b-a311d-khadas-vim3-spinor.dts @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +/dts-v1/; + +#include "meson-g12b-a311d-khadas-vim3.dts" + +/ { + model = "Khadas VIM3 with SPI NOR flash"; +}; + +#include "meson-g12-enable-spinor.dtsi" diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-g12b-odroid-n2-plus-spidev.dts b/patch/kernel/archive/meson64-6.13/dt/meson-g12b-odroid-n2-plus-spidev.dts new file mode 100644 index 000000000..a87ddd464 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-g12b-odroid-n2-plus-spidev.dts @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +/dts-v1/; + +#include "meson-g12b-odroid-n2-plus.dts" + +/ { + model = "Hardkernel ODROID-N2Plus with SPIDEV - MISO is pin 19, CLK is pin 23"; +}; + +&spicc0 { + cs-gpios = <&gpio GPIOX_10 GPIO_ACTIVE_LOW>; + status = "okay"; + spidev@0 { + compatible = "armbian,spi-dev"; + status = "okay"; + reg = <0>; + spi-max-frequency = <10000000>; + }; +}; + diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-g12b-odroid-n2-plus-spinor.dts b/patch/kernel/archive/meson64-6.13/dt/meson-g12b-odroid-n2-plus-spinor.dts new file mode 100644 index 000000000..0677d7725 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-g12b-odroid-n2-plus-spinor.dts @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +/dts-v1/; + +#include "meson-g12b-odroid-n2-plus.dts" + +/ { + model = "Hardkernel ODROID-N2Plus with SPI NOR flash"; +}; + +#include "meson-g12-enable-spinor.dtsi" diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-g12b-odroid-n2-spinor.dts b/patch/kernel/archive/meson64-6.13/dt/meson-g12b-odroid-n2-spinor.dts new file mode 100644 index 000000000..521498d9f --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-g12b-odroid-n2-spinor.dts @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +/dts-v1/; + +#include "meson-g12b-odroid-n2.dts" + +/ { + model = "Hardkernel ODROID-N2 with SPI NOR flash"; +}; + +#include "meson-g12-enable-spinor.dtsi" diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-g12b-radxa-zero2-spidev.dts b/patch/kernel/archive/meson64-6.13/dt/meson-g12b-radxa-zero2-spidev.dts new file mode 100644 index 000000000..0d16cde21 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-g12b-radxa-zero2-spidev.dts @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +/dts-v1/; + +#include "meson-g12b-radxa-zero2.dts" + +/ { + model = "Radxa Zero2 with SPIDEV and I2C - MOSI pin 19, CLK pin 23 - SDA pin 3, SCL pin 5"; +}; + +&spicc1 { + pinctrl-0 = <&spicc1_pins &spicc1_ss0_pins>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + spidev@0 { + compatible = "armbian,spi-dev"; + status = "okay"; + reg = <0>; + spi-max-frequency = <10000000>; + }; +}; + +&i2c3 { + status = "okay"; + pinctrl-0 = <&i2c3_sck_a_pins &i2c3_sda_a_pins>; + pinctrl-names = "default"; +}; diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-g12b-waveshare-cm4-io-base-b.dts b/patch/kernel/archive/meson64-6.13/dt/meson-g12b-waveshare-cm4-io-base-b.dts new file mode 100644 index 000000000..3957c8592 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-g12b-waveshare-cm4-io-base-b.dts @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2024 Patrick Yavitz + */ + +/dts-v1/; + +#include "meson-g12b-bananapi-cm4-cm4io.dts" + +/ { + compatible = "bananapi,bpi-cm4io", "bananapi,bpi-cm4", "amlogic,a311d", "amlogic,g12b"; + model = "Waveshare CM4-IO-BASE-B with BPI-CM4 Module"; + + aliases { + rtc0 = &rtc; + }; +}; + +&i2c1 { + rtc: rtc@51 { + compatible = "nxp,pcf85063a"; + reg = <0x51>; + wakeup-source; + }; + + fanctrl: emc2305@2f { + compatible = "smsc,emc2305"; + reg = <0x2f>; + #cooling-cells = <0x02>; + wakeup-source; + }; +}; + +&cpu_thermal { + trips { + fanmid0: fanmid0 { + temperature = <60000>; + hysteresis = <2000>; + type = "active"; + }; + + fanmax0: fanmax0 { + temperature = <65000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + map0 { + trip = <&fanmid0>; + cooling-device = <&fanctrl 2 6>; + }; + + map1 { + trip = <&fanmax0>; + cooling-device = <&fanctrl 7 THERMAL_NO_LIMIT>; + }; + }; +}; + +&usb { + dr_mode = "host"; +}; diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-gxm-c400-plus.dts b/patch/kernel/archive/meson64-6.13/dt/meson-gxm-c400-plus.dts new file mode 100644 index 000000000..714c6fef3 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-gxm-c400-plus.dts @@ -0,0 +1,66 @@ +/dts-v1/; + +#include "meson-gxm.dtsi" +#include "meson-gx-p23x-q20x.dtsi" + +/ { + compatible = "magicsee,c400-plus", "amlogic,s912", "amlogic,meson-gxm"; + model = "Magicsee C400 Plus"; +}; + +/* Q201 has only internal PHY port */ +ðmac { + phy-mode = "rmii"; + phy-handle = <&internal_phy>; +}; + +&sd_emmc_a { + brcmf: wifi@1 { + reg = <1>; + compatible = "brcm,bcm4329-fmac"; + }; +}; + +&uart_A { + status = "okay"; + pinctrl-0 = <&uart_a_pins>, <&uart_a_cts_rts_pins>; + pinctrl-names = "default"; + uart-has-rtscts; + + bluetooth { + compatible = "qcom,qca9377-bt"; + enable-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>; + max-speed = <2000000>; + clocks = <&wifi32k>; + clock-names = "lpo"; + }; +}; + +/* Wireless SDIO Module */ +&sd_emmc_a { + status = "okay"; + pinctrl-0 = <&sdio_pins>; + pinctrl-1 = <&sdio_clk_gate_pins>; + pinctrl-names = "default", "clk-gate"; + #address-cells = <1>; + #size-cells = <0>; + + bus-width = <4>; + cap-sd-highspeed; + sd-uhs-sdr12; + sd-uhs-sdr25; + sd-uhs-sdr50; + sd-uhs-sdr104; + max-frequency = <50000000>; + + non-removable; + disable-wp; + + /* WiFi firmware requires power to be kept while in suspend */ + keep-power-in-suspend; + + mmc-pwrseq = <&sdio_pwrseq>; + + vmmc-supply = <&vddao_3v3>; + vqmmc-supply = <&vddio_boot>; +}; \ No newline at end of file diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-gxm-mini-m8s-pro.dts b/patch/kernel/archive/meson64-6.13/dt/meson-gxm-mini-m8s-pro.dts new file mode 100644 index 000000000..ef56c270d --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-gxm-mini-m8s-pro.dts @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) Christian Hewitt + */ + +/dts-v1/; + +#include "meson-gxm.dtsi" +#include "meson-gx-p23x-q20x.dtsi" +#include +#include + +/ { + compatible = "azw,gt1-ultimate", "amlogic,s912", "amlogic,meson-gxm"; + model = "Mini M8S Pro"; + + leds { + compatible = "gpio-leds"; + + led-white { + color = ; + function = LED_FUNCTION_POWER; + gpios = <&gpio_ao GPIOAO_9 GPIO_ACTIVE_HIGH>; + default-state = "on"; + panic-indicator; + }; + }; + + adc-keys { + compatible = "adc-keys"; + io-channels = <&saradc 0>; + io-channel-names = "buttons"; + keyup-threshold-microvolt = <1710000>; + + button-function { + label = "update"; + linux,code = ; + press-threshold-microvolt = <10000>; + }; + }; +}; + +ðmac { + pinctrl-0 = <ð_pins>; + pinctrl-names = "default"; + phy-handle = <&external_phy>; + amlogic,tx-delay-ns = <2>; + phy-mode = "rgmii"; +}; + +&external_mdio { + external_phy: ethernet-phy@0 { + /* Realtek RTL8211F (0x001cc916) */ + reg = <0>; + max-speed = <1000>; + + reset-assert-us = <10000>; + reset-deassert-us = <80000>; + reset-gpios = <&gpio GPIOZ_14 GPIO_ACTIVE_LOW>; + + interrupt-parent = <&gpio_intc>; + /* MAC_INTR on GPIOZ_15 */ + interrupts = <25 IRQ_TYPE_LEVEL_LOW>; + }; +}; + +&ir { + linux,rc-map-name = "rc-beelink-gs1"; +}; + +&sd_emmc_a { + brcmf: wifi@1 { + reg = <1>; + compatible = "qcom,qca9377"; + }; +}; + +&uart_A { + status = "okay"; + pinctrl-0 = <&uart_a_pins>, <&uart_a_cts_rts_pins>; + pinctrl-names = "default"; + uart-has-rtscts; + + bluetooth { + compatible = "qcom,qca9377-bt"; + enable-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>; + max-speed = <2000000>; + clocks = <&wifi32k>; + clock-names = "lpo"; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-gxm-t95z-plus.dts b/patch/kernel/archive/meson64-6.13/dt/meson-gxm-t95z-plus.dts new file mode 100644 index 000000000..5f4bd19d5 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-gxm-t95z-plus.dts @@ -0,0 +1,166 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) Christian Hewitt + */ + +/dts-v1/; + +#include "meson-gxm.dtsi" +#include "meson-gx-p23x-q20x.dtsi" +#include +#include + +/ { + compatible = "sunvell,t95z-plus", "amlogic,s912", "amlogic,meson-gxm"; + model = "Sunvell T95Z Plus"; + + leds { + compatible = "gpio-leds"; + + led-green { + color = ; + function = LED_FUNCTION_POWER; + gpios = <&gpio_ao GPIOAO_9 GPIO_ACTIVE_HIGH>; + default-state = "on"; + }; + + led-blue { + color = ; + function = LED_FUNCTION_POWER; + gpios = <&gpio GPIODV_25 GPIO_ACTIVE_HIGH>; + default-state = "off"; + panic-indicator; + }; + }; + + adc-keys { + compatible = "adc-keys"; + io-channels = <&saradc 0>; + io-channel-names = "buttons"; + keyup-threshold-microvolt = <1710000>; + + button-function { + label = "update"; + linux,code = ; + press-threshold-microvolt = <10000>; + }; + }; + + spi { + compatible = "spi-gpio"; + + /* T95Z v1 (enabled) */ + sck-gpios = <&gpio GPIODV_22 GPIO_ACTIVE_HIGH>; + mosi-gpios = <&gpio GPIODV_23 GPIO_ACTIVE_HIGH>; + cs-gpios = <&gpio GPIODV_21 GPIO_ACTIVE_LOW>; + + /* T95Z v2 (disabled) + sck-gpios = <&gpio GPIODV_19 GPIO_ACTIVE_HIGH>; + mosi-gpios = <&gpio GPIODV_18 GPIO_ACTIVE_HIGH>; + cs-gpios = <&gpio GPIODV_20 GPIO_ACTIVE_LOW>; + */ + + num-chipselects = <1>; + #address-cells = <1>; + #size-cells = <0>; + + tm1628: led-controller@0 { + compatible = "titanmec,tm1628"; + reg = <0>; + spi-3wire; + spi-lsb-first; + spi-rx-delay-us = <1>; + spi-max-frequency = <500000>; + #address-cells = <2>; + #size-cells = <0>; + + titanmec,segment-mapping = /bits/ 8 <4 5 6 1 2 3 7>; + titanmec,grid = /bits/ 8 <2 3 4 5 1>; + + alarm@1,1 { + reg = <1 1>; + function = LED_FUNCTION_ALARM; + }; + + usb@1,2 { + reg = <1 2>; + function = LED_FUNCTION_USB; + }; + + play@1,3 { + reg = <1 3>; + function = "play"; + }; + + pause@1,4 { + reg = <1 4>; + function = "pause"; + }; + + colon@1,5 { + reg = <1 5>; + function = "colon"; + }; + + lan@1,6 { + reg = <1 6>; + function = LED_FUNCTION_LAN; + }; + + wlan@1,7 { + reg = <1 7>; + function = LED_FUNCTION_WLAN; + }; + }; + }; +}; + +ðmac { + pinctrl-0 = <ð_pins>; + pinctrl-names = "default"; + + phy-handle = <&external_phy>; + phy-mode = "rgmii"; + + amlogic,tx-delay-ns = <2>; +}; + +&external_mdio { + external_phy: ethernet-phy@1 { + /* ZTE ZX2AA500 */ + compatible = "ethernet-phy-id0381.5c11", + "ethernet-phy-ieee802.3-c22"; + reg = <1>; + max-speed = <1000>; + + reset-assert-us = <10000>; + reset-deassert-us = <80000>; + reset-gpios = <&gpio GPIOZ_14 GPIO_ACTIVE_LOW>; + + interrupt-parent = <&gpio_intc>; + /* MAC_INTR on GPIOZ_15 */ + interrupts = <25 IRQ_TYPE_LEVEL_LOW>; + }; +}; + +&sd_emmc_a { + brcmf: wifi@1 { + reg = <1>; + compatible = "brcm,bcm4329-fmac"; + }; +}; + +&uart_A { + status = "okay"; + pinctrl-0 = <&uart_a_pins>, <&uart_a_cts_rts_pins>; + pinctrl-names = "default"; + uart-has-rtscts; + + bluetooth { + compatible = "brcm,bcm43438-bt"; + shutdown-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>; + max-speed = <2000000>; + clocks = <&wifi32k>; + clock-names = "lpo"; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-sm1-jethome-jethub-j200-spinor.dts b/patch/kernel/archive/meson64-6.13/dt/meson-sm1-jethome-jethub-j200-spinor.dts new file mode 100644 index 000000000..b4d2542cd --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-sm1-jethome-jethub-j200-spinor.dts @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2024 JetHome + * Author: Viacheslav Bocharov + */ + +/dts-v1/; + +#include "meson-sm1-jethome-jethub-j200.dts" + +/ { + model = "JetHub D2 with SPI NOR flash"; +}; + +#include "meson-g12-enable-spinor.dtsi" diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-sm1-jethome-jethub-j200.dts b/patch/kernel/archive/meson64-6.13/dt/meson-sm1-jethome-jethub-j200.dts new file mode 100644 index 000000000..e13d081d8 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-sm1-jethome-jethub-j200.dts @@ -0,0 +1,710 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2024 JetHome + * Author: Viacheslav Bocharov + * + * JetHub D2 rev 1.3 + */ + +/dts-v1/; + +#include "meson-sm1.dtsi" + +#include +#include +#include + + +/ { + + compatible = "jethome,jethub-j200", "amlogic,sm1"; + model = "JetHome JetHub D2"; + + aliases { + serial0 = &uart_AO; + ethernet0 = ðmac; + rtc0 = &rtc; + rtc1 = &vrtc; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + memory@0 { + device_type = "memory"; + reg = <0x0 0x0 0x0 0x40000000>; + }; + + emmc_pwrseq: emmc-pwrseq { + compatible = "mmc-pwrseq-emmc"; + reset-gpios = <&gpio BOOT_12 GPIO_ACTIVE_LOW>; + }; + + tflash_vdd: regulator-tflash_vdd { + compatible = "regulator-fixed"; + + regulator-name = "TFLASH_VDD"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + + gpio = <&gpio_ao GPIOAO_3 GPIO_OPEN_DRAIN>; + enable-active-high; + regulator-always-on; + }; + + tf_io: gpio-regulator-tf_io { + compatible = "regulator-gpio"; + + regulator-name = "TF_IO"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + vin-supply = <&vcc_5v>; + + enable-gpios = <&gpio_ao GPIOE_2 GPIO_OPEN_DRAIN>; + enable-active-high; + regulator-always-on; + + gpios = <&gpio_ao GPIOAO_6 GPIO_OPEN_SOURCE>; + gpios-states = <0>; + + states = <3300000 0>, + <1800000 1>; + }; + + flash_1v8: regulator-flash_1v8 { + compatible = "regulator-fixed"; + regulator-name = "FLASH_1V8"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + vin-supply = <&vcc_3v3>; + regulator-always-on; + }; + + main_12v: regulator-main_12v { + compatible = "regulator-fixed"; + regulator-name = "12V"; + regulator-min-microvolt = <12000000>; + regulator-max-microvolt = <12000000>; + regulator-always-on; + }; + + vcc_5v: regulator-vcc_5v { + compatible = "regulator-fixed"; + regulator-name = "5V"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-always-on; + vin-supply = <&main_12v>; + gpio = <&gpio GPIOH_8 GPIO_OPEN_DRAIN>; + enable-active-high; + }; + + vcc_1v8: regulator-vcc_1v8 { + compatible = "regulator-fixed"; + regulator-name = "VCC_1V8"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + vin-supply = <&vcc_3v3>; + regulator-always-on; + }; + + vcc_3v3: regulator-vcc_3v3 { + compatible = "regulator-fixed"; + regulator-name = "VCC_3V3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + vin-supply = <&vddao_3v3>; + regulator-always-on; + }; + + vddcpu: regulator-vddcpu { + /* + * MP8756GD Regulator. + */ + compatible = "pwm-regulator"; + + regulator-name = "VDDCPU"; + regulator-min-microvolt = <721000>; + regulator-max-microvolt = <1022000>; + + pwm-supply = <&main_12v>; + + pwms = <&pwm_AO_cd 1 1250 0>; + pwm-dutycycle-range = <100 0>; + + regulator-boot-on; + regulator-always-on; + }; + + usb_pwr_en: regulator-usb_pwr_en { + compatible = "regulator-fixed"; + regulator-name = "USB_PWR_EN"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + vin-supply = <&vcc_5v>; + + /* Connected to the internal USB-Hub */ + gpio = <&gpio_ao GPIOAO_2 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + vddao_1v8: regulator-vddao_1v8 { + compatible = "regulator-fixed"; + regulator-name = "VDDAO_1V8"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + vin-supply = <&vddao_3v3>; + regulator-always-on; + }; + + vddao_3v3: regulator-vddao_3v3 { + compatible = "regulator-fixed"; + regulator-name = "VDDAO_3V3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + vin-supply = <&main_12v>; + regulator-always-on; + }; + + hdmi-connector { + compatible = "hdmi-connector"; + type = "a"; + + port { + hdmi_connector_in: endpoint { + remote-endpoint = <&hdmi_tx_tmds_out>; + }; + }; + }; + + sound { + compatible = "amlogic,axg-sound-card"; + audio-aux-devs = <&tdmout_b>; + audio-routing = "TDM_B Playback", "TDMOUT_B OUT"; + + assigned-clocks = <&clkc CLKID_MPLL2>, + <&clkc CLKID_MPLL0>, + <&clkc CLKID_MPLL1>; + assigned-clock-parents = <0>, <0>, <0>; + assigned-clock-rates = <294912000>, + <270950400>, + <393216000>; + + /* 8ch hdmi interface */ + dai-link-0 { + sound-dai = <&tdmif_b>; + dai-format = "i2s"; + dai-tdm-slot-tx-mask-0 = <1 1>; + dai-tdm-slot-tx-mask-1 = <1 1>; + dai-tdm-slot-tx-mask-2 = <1 1>; + dai-tdm-slot-tx-mask-3 = <1 1>; + mclk-fs = <256>; + + codec { + sound-dai = <&tohdmitx TOHDMITX_I2S_IN_B>; + }; + }; + + /* hdmi glue */ + dai-link-1 { + sound-dai = <&tohdmitx TOHDMITX_I2S_OUT>; + + codec { + sound-dai = <&hdmi_tx>; + }; + }; + }; + + meson64-reboot { + compatible = "meson64,reboot"; + sys_reset = <0x84000009>; + sys_poweroff = <0x84000008>; + + sd-vqen = <&gpio GPIOE_2 GPIO_ACTIVE_HIGH>; + sd-vqsw = <&gpio_ao GPIOAO_6 GPIO_ACTIVE_HIGH>; + sd-vmmc = <&gpio_ao GPIOAO_3 GPIO_ACTIVE_HIGH>; + }; + + leds { + compatible = "gpio-leds"; + + led-green { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&gpio_ao GPIOAO_11 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "heartbeat"; + panic-indicator; + }; + + led-red { + color = ; + function = LED_FUNCTION_POWER; + gpios = <&gpio GPIOH_5 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; + + }; + + sound { + model = "JETHUB-D2"; + }; + +}; + +&arb { + status = "okay"; +}; + +&cec_AO { + pinctrl-0 = <&cec_ao_a_h_pins>; + pinctrl-names = "default"; + status = "disabled"; + hdmi-phandle = <&hdmi_tx>; +}; + +&cecb_AO { + pinctrl-0 = <&cec_ao_b_h_pins>; + pinctrl-names = "default"; + status = "okay"; + hdmi-phandle = <&hdmi_tx>; +}; + +&clkc_audio { + status = "okay"; +}; + +&cpu0 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU_CLK>; + clock-latency = <50000>; +}; + +&cpu1 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU1_CLK>; + clock-latency = <50000>; +}; + +&cpu2 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU2_CLK>; + clock-latency = <50000>; +}; + +&cpu3 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU3_CLK>; + clock-latency = <50000>; +}; + +&ext_mdio { + external_phy: ethernet-phy@0 { + /* Realtek RTL8211F (0x001cc916) */ + reg = <0>; + max-speed = <1000>; + + reset-assert-us = <10000>; + reset-deassert-us = <80000>; + reset-gpios = <&gpio GPIOZ_15 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>; + + interrupt-parent = <&gpio_intc>; + /* MAC_INTR on GPIOZ_14 */ + interrupts = ; + }; +}; + +ðmac { + pinctrl-0 = <ð_pins>, <ð_rgmii_pins>; + pinctrl-names = "default"; + status = "okay"; + phy-mode = "rgmii"; + phy-handle = <&external_phy>; + amlogic,tx-delay-ns = <2>; +}; + +&gpio { + gpio-line-names = + /* GPIOZ */ + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", + /* GPIOH */ + "HDMITX_SDA", /* GPIOH_0 */ + "HDMITX_SCL", /* GPIOH_1 */ + "HDMITX_HPD_IN", /* GPIOH_2 */ + "AO_CEC_A", /* GPIOH_3 */ + "HUB_RESET", /* GPIOH_4 */ + "LED_RED", /* GPIOH_5 */ + "I2C_SDA_MODULES", /* GPIOH_6 */ + "I2C_SCL_MODULES", /* GPIOH_7 */ + "5V_EN", /* GPIOH_8 */ + /* BOOT */ + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", + /* GPIOC */ + "", "", "", "", "", "", "", "", + /* GPIOA */ + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", + "I2C_SDA_SYSBUS", /* GPIOA_14 */ + "I2C_SCL_SYSBUS", /* GPIOA_15 */ + /* GPIOX */ + "", "", "", "", "", "", /* GPIOX_0 - GPIOX_5 */ + "RS485_TX", /* GPIOX_6 */ + "RS485_RX", /* GPIOX_7 */ + "", "", "", "", "", "", /* GPIOX_8 - GPIOX_13 */ + "", "", /* GPIOX_14 - GPIOX_15 */ + "GPIO_EXPANDER_INT", /* GPIOX_16 */ + "I2C_SDA_LCDBUS", /* GPIOX_17 */ + "I2C_SCL_LCDBUS", /* GPIOX_18 */ + ""; /* GPIOX_19 */ + /* + * WARNING: The USB Hub needs a reset signal to be turned low in + * order to be detected by the USB Controller. This signal should + * be handled by a USB specific power sequence to reset the Hub + * when the USB bus is powered down. + */ + usb-hub-hog { + gpio-hog; + gpios = ; + output-low; + line-name = "usb-hub-reset"; + }; + +}; + +&gpio_ao { + gpio-line-names = + /* GPIOAO */ + "CONSOLE_TX", /* GPIOAO_0 */ + "CONSOLE_RX", /* GPIOAO_1 */ + "USB_OTG_PWR_EN", /* GPIOAO_2 */ + "TFLASH_VDD_EN", /* GPIOAO_3 */ + "MCU_RESET", /* GPIOAO_4 */ + "POWER_GOOD", /* GPIOAO_5 */ + "TF_3V3N_1V8_EN", /* GPIOAO_6 */ + "MCU_BOOT", /* GPIOAO_7 */ + "MCU_UART_TX", /* GPIOAO_8 */ + "MCU_UART_RX", /* GPIOAO_9 */ + "BUTTON_USR", /* GPIOAO_10 */ + "LED_GREEN", /* GPIOAO_11 */ + /* GPIOE */ + "VDDEE_PWM", "VDDCPU_PWM", "TF_PWR_EN"; +}; + +&hdmi_tx { + status = "okay"; + pinctrl-0 = <&hdmitx_hpd_pins>, <&hdmitx_ddc_pins>; + pinctrl-names = "default"; + hdmi-supply = <&vcc_5v>; +}; + +&hdmi_tx_tmds_port { + hdmi_tx_tmds_out: endpoint { + remote-endpoint = <&hdmi_connector_in>; + }; +}; + +&pwm_AO_cd { + pinctrl-0 = <&pwm_ao_d_e_pins>; + pinctrl-names = "default"; + clocks = <&xtal>; + clock-names = "clkin1"; + status = "okay"; +}; + +&saradc { + status = "okay"; +}; + +/* SD card */ +&sd_emmc_b { + status = "okay"; + pinctrl-0 = <&sdcard_c_pins>; + pinctrl-1 = <&sdcard_clk_gate_c_pins>; + pinctrl-names = "default", "clk-gate"; + + bus-width = <4>; + cap-sd-highspeed; + max-frequency = <200000000>; + sd-uhs-sdr12; + sd-uhs-sdr25; + sd-uhs-sdr50; + sd-uhs-sdr104; + disable-wp; + + cd-gpios = <&gpio GPIOC_6 GPIO_ACTIVE_LOW>; + vmmc-supply = <&tflash_vdd>; + vqmmc-supply = <&tf_io>; +}; + +/* eMMC */ +&sd_emmc_c { + status = "okay"; + pinctrl-0 = <&emmc_ctrl_pins>, <&emmc_data_8b_pins>, <&emmc_ds_pins>; + pinctrl-1 = <&emmc_clk_gate_pins>; + pinctrl-names = "default", "clk-gate"; + + bus-width = <8>; + cap-mmc-highspeed; + mmc-ddr-1_8v; + mmc-hs200-1_8v; + max-frequency = <200000000>; + disable-wp; + + mmc-pwrseq = <&emmc_pwrseq>; + vmmc-supply = <&vcc_3v3>; + vqmmc-supply = <&flash_1v8>; +}; + +&spifc { + status = "disabled"; + pinctrl-0 = <&nor_pins>; + pinctrl-names = "default"; + clock-frequency = <400000>; + + flash: nor-flash@0 { + compatible = "sst,w25q256", "jedec,spi-nor"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0>; + spi-max-frequency = <30000000>; + }; +}; + +&tdmif_b { + status = "okay"; +}; + +&tdmout_b { + status = "okay"; +}; + +&tohdmitx { + status = "okay"; +}; + +&uart_AO { + status = "okay"; + pinctrl-0 = <&uart_ao_a_pins>; + pinctrl-names = "default"; +}; + +&uart_AO_B { + status = "okay"; + pinctrl-0 = <&uart_ao_b_8_9_pins>; + pinctrl-names = "default"; +}; + +&uart_B { + status = "okay"; + pinctrl-0 = <&uart_b_pins>; + pinctrl-names = "default"; + clock-frequency = <400000>; +}; + + +&usb { + status = "okay"; + vbus-supply = <&usb_pwr_en>; +}; + +&usb2_phy0 { + phy-supply = <&vcc_5v>; +}; + + +/* I2C for modules */ +&i2c1 { + status = "okay"; + pinctrl-0 = <&i2c1_sda_h6_pins>, <&i2c1_sck_h7_pins>; + pinctrl-names = "default"; + clock-frequency = <400000>; + + /* GPIO expander */ + u9: gpio@22 { + compatible = "nxp,pca9535"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + interrupt-parent = <&gpio_intc>; + interrupts = ; + + gpio-line-names = + "RELAY_1", "RELAY_2", + "", "", + "UXM1_RESET", "UXM1_BOOT", + "UXM2_RESET", "UXM2_BOOT", + "DIN_1", "DIN_2", "DIN_3", + "","","","",""; + }; + + /* 1-wire */ + w1: onewire@18 { + compatible = "maxim,ds2482"; + reg = <0x18>; + }; + +}; + + +/* I2C for lcd/etc */ +&i2c2 { + status = "okay"; + pinctrl-0 = <&i2c2_sda_x_pins>, <&i2c2_sck_x_pins>; + pinctrl-names = "default"; + clock-frequency = <400000>; +}; + +/* I2C_EE_M3: I2C for CPU board */ +&i2c3 { + status = "okay"; + pinctrl-0 = <&i2c3_sda_a_pins>, <&i2c3_sck_a_pins>; + pinctrl-names = "default"; + clock-frequency = <400000>; + + /* I2C for rtc */ + rtc: rtc@51 { + status = "okay"; + compatible = "nxp,pcf8563"; + reg = <0x51>; + wakeup-source; + }; + + /* FRAM on base board */ + fram: eeprom@52 { + compatible = "atmel,24c64"; + reg = <0x52>; + pagesize = <0x20>; + label = "fram"; + address-width = <0x10>; + vcc-supply = <&vddao_3v3>; + }; + + /* EEPROM on CPU board */ + eepromc: eeprom@54 { + compatible = "atmel,24c64"; + reg = <0x54>; + pagesize = <0x20>; + label = "eepromc"; + address-width = <0x10>; + vcc-supply = <&vddao_3v3>; + }; + + /* EEPROM on base board */ + eeprompd: eeprom@56 { + compatible = "atmel,24c64"; + reg = <0x56>; + pagesize = <0x20>; + label = "eeprompd"; + address-width = <0x10>; + vcc-supply = <&vddao_3v3>; + }; + + /* EEPROM on power module */ + eeprompm: eeprom@57 { + compatible = "atmel,24c64"; + reg = <0x57>; + pagesize = <0x20>; + label = "eeprompm"; + address-width = <0x10>; + vcc-supply = <&vddao_3v3>; + }; + + /* temperature sensors */ + temp1: tmp102@48 { + compatible = "ti,tmp102"; + reg = <0x48>; + }; + + temp2: tmp102@49 { + compatible = "ti,tmp102"; + reg = <0x49>; + }; + +}; + +&efuse { + eth_mac: eth-mac@0 { + reg = <0x0 0x6>; + }; + + bt_mac: bt-mac@6 { + reg = <0x6 0x6>; + }; + + wifi_mac: wifi-mac@c { + reg = <0xc 0x6>; + }; + + bid: bid@12 { + reg = <0x12 0x20>; + }; + + sn: sn@32 { + reg = <0x32 0x20>; + }; +}; + +&cpu_thermal { + trips { + cpu_passive: cpu-passive { + temperature = <70000>; /* millicelsius */ + hysteresis = <2000>; /* millicelsius */ + type = "passive"; + }; + + cpu_hot: cpu-hot { + temperature = <85000>; /* millicelsius */ + hysteresis = <2000>; /* millicelsius */ + type = "hot"; + }; + + cpu_critical: cpu-critical { + temperature = <90000>; /* millicelsius */ + hysteresis = <2000>; /* millicelsius */ + type = "critical"; + }; + }; + + cooling-maps { + map0 { + trip = <&cpu_passive>; + cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + + map1 { + trip = <&cpu_hot>; + cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; +}; + +&ddr_thermal { + trips { + ddr_passive: ddr-passive { + temperature = <70000>; /* millicelsius */ + hysteresis = <2000>; /* millicelsius */ + type = "passive"; + }; + + ddr_critical: ddr-critical { + temperature = <85000>; /* millicelsius */ + hysteresis = <2000>; /* millicelsius */ + type = "critical"; + }; + }; + +}; diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-sm1-khadas-vim3l-spidev.dts b/patch/kernel/archive/meson64-6.13/dt/meson-sm1-khadas-vim3l-spidev.dts new file mode 100644 index 000000000..e7a0f5a3f --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-sm1-khadas-vim3l-spidev.dts @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +/dts-v1/; + +#include "meson-sm1-khadas-vim3l.dts" + +/ { + model = "Khadas VIM3L with SPIDEV and I2C - MOSI pin 37, CLK pin 16 - SDA pin 23, SCL pin 23"; +}; + +&spicc1 { + pinctrl-0 = <&spicc1_pins &spicc1_ss0_pins>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + spidev@0 { + compatible = "armbian,spi-dev"; + status = "okay"; + reg = <0>; + spi-max-frequency = <10000000>; + }; +}; + +&i2c3 { + status = "okay"; + pinctrl-0 = <&i2c3_sck_a_pins &i2c3_sda_a_pins>; + pinctrl-names = "default"; +}; diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-sm1-khadas-vim3l-spinor.dts b/patch/kernel/archive/meson64-6.13/dt/meson-sm1-khadas-vim3l-spinor.dts new file mode 100644 index 000000000..f0d547e0c --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-sm1-khadas-vim3l-spinor.dts @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +/dts-v1/; + +#include "meson-sm1-khadas-vim3l.dts" + +/ { + model = "Khadas VIM3L with SPI NOR flash"; +}; + +#include "meson-g12-enable-spinor.dtsi" diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-sm1-odroid-c4-spidev.dts b/patch/kernel/archive/meson64-6.13/dt/meson-sm1-odroid-c4-spidev.dts new file mode 100644 index 000000000..4688b4005 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-sm1-odroid-c4-spidev.dts @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +/dts-v1/; + +#include "meson-sm1-odroid-c4.dts" + +/ { + model = "Hardkernel ODROID-C4 - MOSI is pin y, CLK is pin x"; +}; + +&spicc1 { + pinctrl-0 = <&spicc1_pins &spicc1_ss0_pins>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + spidev@0 { + compatible = "armbian,spi-dev"; + status = "okay"; + reg = <0>; + spi-max-frequency = <10000000>; + }; +}; + diff --git a/patch/kernel/archive/meson64-6.13/dt/meson-sm1-ugoos-x3.dts b/patch/kernel/archive/meson64-6.13/dt/meson-sm1-ugoos-x3.dts new file mode 100644 index 000000000..884a08836 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/dt/meson-sm1-ugoos-x3.dts @@ -0,0 +1,293 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2019 BayLibre SAS. All rights reserved. + * Copyright (c) 2020 Christian Hewitt + * Copyright (c) 2021 flippy + */ + +/dts-v1/; + +#include "meson-sm1-ac2xx.dtsi" +#include + +/ { + compatible = "amlogic,sm1"; + model = "Ugoos X3"; + + aliases { + rtc0 = &rtc; + rtc1 = &vrtc; + mmc0 = &sd_emmc_a; + mmc1 = &sd_emmc_b; + mmc2 = &sd_emmc_c; + }; + + leds { + compatible = "gpio-leds"; + + red_led { + label = "red"; + gpios = <&gpio_ao GPIOAO_10 GPIO_ACTIVE_HIGH>; + default-state = "on"; + }; + + blue_led { + label = "blue"; + gpios = <&gpio_ao GPIOAO_11 GPIO_ACTIVE_HIGH>; + default-state = "on"; + }; + }; + + sound { + compatible = "amlogic,axg-sound-card"; + model = "UGOOS-X3"; + audio-aux-devs = <&tdmout_b>; + audio-routing = "TDMOUT_B IN 0", "FRDDR_A OUT 1", + "TDMOUT_B IN 1", "FRDDR_B OUT 1", + "TDMOUT_B IN 2", "FRDDR_C OUT 1", + "TDM_B Playback", "TDMOUT_B OUT"; + + assigned-clocks = <&clkc CLKID_MPLL2>, + <&clkc CLKID_MPLL0>, + <&clkc CLKID_MPLL1>; + assigned-clock-parents = <0>, <0>, <0>; + assigned-clock-rates = <294912000>, + <270950400>, + <393216000>; + status = "okay"; + + dai-link-0 { + sound-dai = <&frddr_a>; + }; + + dai-link-1 { + sound-dai = <&frddr_b>; + }; + + dai-link-2 { + sound-dai = <&frddr_c>; + }; + + /* 8ch hdmi interface */ + dai-link-3 { + sound-dai = <&tdmif_b>; + dai-format = "i2s"; + dai-tdm-slot-tx-mask-0 = <1 1>; + dai-tdm-slot-tx-mask-1 = <1 1>; + dai-tdm-slot-tx-mask-2 = <1 1>; + dai-tdm-slot-tx-mask-3 = <1 1>; + mclk-fs = <256>; + + codec { + sound-dai = <&tohdmitx TOHDMITX_I2S_IN_B>; + }; + }; + + /* hdmi glue */ + dai-link-4 { + sound-dai = <&tohdmitx TOHDMITX_I2S_OUT>; + + codec { + sound-dai = <&hdmi_tx>; + }; + }; + }; + + vddgpu: regulator-vddgpu { + compatible = "regulator-fixed"; + regulator-name = "mali"; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <800000>; + vin-supply = <&ao_5v>; + regulator-always-on; + }; + + usb_pwr_en: regulator-usb-pwr-en { + compatible = "regulator-fixed"; + regulator-name = "USB_PWR_EN"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + vin-supply = <&ao_5v>; + + gpio = <&gpio GPIOH_5 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; +}; + +&vddcpu { + regulator-min-microvolt = <721000>; + regulator-max-microvolt = <1022000>; + pwms = <&pwm_AO_cd 1 1250 0>; +}; + +&arb { + status = "okay"; +}; + +&clkc_audio { + status = "okay"; +}; + +ðmac { + status = "okay"; + + pinctrl-0 = <ð_pins>, <ð_rgmii_pins>; + pinctrl-names = "default"; + phy-mode = "rgmii-txid"; + phy-handle = <&external_phy>; + + rx-internal-delay-ps = <800>; + + snps,aal; + snps,rxpbl = <0x8>; + snps,txpbl = <0x8>; + + rx-fifo-depth = <4096>; + tx-fifo-depth = <4096>; + + nvmem-cells = <ð_mac>; + nvmem-cell-names = "eth_mac"; +}; + +&ext_mdio { + external_phy: ethernet-phy@0 { + /* Realtek RTL8211F (0x001cc916) */ + reg = <0>; + max-speed = <1000>; + + reset-assert-us = <10000>; + reset-deassert-us = <80000>; + reset-gpios = <&gpio GPIOZ_15 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>; + + interrupt-parent = <&gpio_intc>; + /* MAC_INTR on GPIOZ_14 */ + interrupts = ; + }; +}; + +&frddr_a { + status = "okay"; +}; + +&frddr_b { + status = "okay"; +}; + +&frddr_c { + status = "okay"; +}; + +&tdmif_b { + status = "okay"; +}; + +&tdmout_b { + status = "okay"; +}; + +&tohdmitx { + status = "okay"; +}; + +&uart_A { + status = "okay"; + + pinctrl-0 = <&uart_a_pins>, <&uart_a_cts_rts_pins>; + pinctrl-names = "default"; + uart-has-rtscts; + + bluetooth { + compatible = "brcm,bcm43438-bt"; + shutdown-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>; + max-speed = <2000000>; + clocks = <&wifi32k>; + clock-names = "lpo"; + }; +}; + +&mali { + mali-supply=<&vddgpu>; +}; + +&usb { + dr_mode = "host"; + vbus-supply = <&usb_pwr_en>; +}; + +&usb2_phy0 { + phy-supply = <&ao_5v>; +}; + +&usb2_phy1 { + phy-supply = <&ao_5v>; +}; + +&i2c3 { + status = "okay"; + pinctrl-0 = <&i2c3_sda_a_pins>, <&i2c3_sck_a_pins>; + pinctrl-names = "default"; + + rtc: rtc@51 { + compatible = "haoyu,hym8563"; + reg = <0x51>; + wakeup-source; + + #clock-cells = <0>; + clock-frequency = <32768>; + clock-output-names = "xin32k"; + }; +}; + +/* SDIO */ +&sd_emmc_a { + /delete-property/ sd-uhs-sdr104; + sd-uhs-sdr50; + max-frequency = <100000000>; + + //sd-uhs-ddr50; + //max-frequency = <50000000>; + + //sd-uhs-sdr104; + //max-frequency = <200000000>; +}; + +/* SD card */ +&sd_emmc_b { + cap-sd-highspeed; + max-frequency = <100000000>; +}; + +/* eMMC */ +&sd_emmc_c { + max-frequency = <200000000>; +}; + +&cpu_opp_table { + opp-2016000000 { + opp-hz = /bits/ 64 <2016000000>; + opp-microvolt = <1000000>; + }; +}; + +&efuse { + eth_mac: eth_mac@0 { + reg = <0x0 0x06>; + }; + + bt_mac: bt_mac@6 { + reg = <0x6 0x06>; + }; + + wifi_mac: wifi_mac@12 { + reg = <0x0c 0x06>; + }; + + usid: usid@18 { + reg = <0x12 0x10>; + }; +}; +/* +&openvfd { + status = "disabled"; +}; +*/ \ No newline at end of file diff --git a/patch/kernel/archive/meson64-6.13/general-add-Amlogic-Meson-GX-PM-Suspend.patch b/patch/kernel/archive/meson64-6.13/general-add-Amlogic-Meson-GX-PM-Suspend.patch new file mode 100644 index 000000000..c4fc44b09 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-add-Amlogic-Meson-GX-PM-Suspend.patch @@ -0,0 +1,134 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Neil Armstrong +Date: Thu, 3 Nov 2016 15:29:23 +0100 +Subject: HACK: arm64: meson: add Amlogic Meson GX PM Suspend + +The Amlogic Meson GX SoCs uses a non-standard argument to the +PSCI CPU_SUSPEND call to enter system suspend. + +Implement such call within platform_suspend_ops. + +Signed-off-by: Neil Armstrong +--- + drivers/firmware/meson/Kconfig | 6 + + drivers/firmware/meson/Makefile | 1 + + drivers/firmware/meson/meson_gx_pm.c | 86 ++++++++++ + 3 files changed, 93 insertions(+) + +diff --git a/drivers/firmware/meson/Kconfig b/drivers/firmware/meson/Kconfig +index 111111111111..222222222222 100644 +--- a/drivers/firmware/meson/Kconfig ++++ b/drivers/firmware/meson/Kconfig +@@ -9,3 +9,9 @@ config MESON_SM + depends on ARM64_4K_PAGES + help + Say y here to enable the Amlogic secure monitor driver ++ ++config MESON_GX_PM ++ bool ++ default ARCH_MESON if ARM64 ++ help ++ Say y here to enable the Amlogic GX SoC Power Management +diff --git a/drivers/firmware/meson/Makefile b/drivers/firmware/meson/Makefile +index 111111111111..222222222222 100644 +--- a/drivers/firmware/meson/Makefile ++++ b/drivers/firmware/meson/Makefile +@@ -1,2 +1,3 @@ + # SPDX-License-Identifier: GPL-2.0-only + obj-$(CONFIG_MESON_SM) += meson_sm.o ++obj-$(CONFIG_MESON_GX_PM) += meson_gx_pm.o +diff --git a/drivers/firmware/meson/meson_gx_pm.c b/drivers/firmware/meson/meson_gx_pm.c +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/drivers/firmware/meson/meson_gx_pm.c +@@ -0,0 +1,86 @@ ++/* ++ * Amlogic Meson GX Power Management ++ * ++ * Copyright (c) 2016 Baylibre, SAS. ++ * Author: Neil Armstrong ++ * ++ * This program is free software; you can redistribute it and/or modify it ++ * under the terms of version 2 of the GNU General Public License as ++ * published by the Free Software Foundation. ++ * ++ * This program is distributed in the hope that it will be useful, but WITHOUT ++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for ++ * more details. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include ++ ++#include ++ ++/* ++ * The Amlogic GX SoCs uses a special argument value to the ++ * PSCI CPU_SUSPEND method to enter SUSPEND_MEM. ++ */ ++ ++#define MESON_SUSPEND_PARAM 0x0010000 ++#define PSCI_FN_NATIVE(version, name) PSCI_##version##_FN64_##name ++ ++static int meson_gx_suspend_finish(unsigned long arg) ++{ ++ struct arm_smccc_res res; ++ ++ arm_smccc_smc(PSCI_FN_NATIVE(0_2, CPU_SUSPEND), arg, ++ virt_to_phys(cpu_resume), 0, 0, 0, 0, 0, &res); ++ ++ return res.a0; ++} ++ ++static int meson_gx_suspend_enter(suspend_state_t state) ++{ ++ switch (state) { ++ case PM_SUSPEND_MEM: ++ return cpu_suspend(MESON_SUSPEND_PARAM, ++ meson_gx_suspend_finish); ++ } ++ ++ return -EINVAL; ++} ++ ++static const struct platform_suspend_ops meson_gx_pm_ops = { ++ .enter = meson_gx_suspend_enter, ++ .valid = suspend_valid_only_mem, ++}; ++ ++static const struct of_device_id meson_gx_pm_match[] = { ++ { .compatible = "amlogic,meson-gx-pm", }, ++ { /* sentinel */ }, ++}; ++MODULE_DEVICE_TABLE(of, meson_gx_pm_match); ++ ++static int meson_gx_pm_probe(struct platform_device *pdev) ++{ ++ suspend_set_ops(&meson_gx_pm_ops); ++ ++ return 0; ++} ++ ++static struct platform_driver meson_gx_pm_driver = { ++ .probe = meson_gx_pm_probe, ++ .driver = { ++ .name = "meson-gx-pm", ++ .of_match_table = meson_gx_pm_match, ++ }, ++}; ++ ++module_platform_driver(meson_gx_pm_driver); ++ ++MODULE_AUTHOR("Neil Armstrong "); ++MODULE_DESCRIPTION("Amlogic Meson GX PM driver"); ++MODULE_LICENSE("GPL v2"); +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-add-overlay-compilation-support.patch b/patch/kernel/archive/meson64-6.13/general-add-overlay-compilation-support.patch new file mode 100644 index 000000000..267fd37eb --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-add-overlay-compilation-support.patch @@ -0,0 +1,66 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Paolo Sabatino +Date: Wed, 2 Oct 2024 19:30:34 +0300 +Subject: compile .scr and install overlays in right path + +--- + scripts/Makefile.dtbinst | 13 +++++++++- + scripts/Makefile.dtbs | 8 +++++- + 2 files changed, 19 insertions(+), 2 deletions(-) + +diff --git a/scripts/Makefile.dtbinst b/scripts/Makefile.dtbinst +index 111111111111..222222222222 100644 +--- a/scripts/Makefile.dtbinst ++++ b/scripts/Makefile.dtbinst +@@ -33,7 +33,18 @@ endef + + $(foreach d, $(sort $(dir $(dtbs))), $(eval $(call gen_install_rules,$(d)))) + +-dtbs := $(notdir $(dtbs)) ++# Very convoluted way to flatten all the device tree ++# directories, but keep the "/overlay/" directory ++ ++# topmost directory (ie: from rockchip/overlay/rk322x-emmc.dtbo extracts rockchip) ++topmost_dir = $(firstword $(subst /, ,$(dtbs))) ++# collect dtbs entries which starts with "$topmost_dir/overlay/", then remove "$topmost_dir" ++dtbs_overlays = $(subst $(topmost_dir)/,,$(filter $(topmost_dir)/overlay/%, $(dtbs))) ++# collect the non-overlay dtbs ++dtbs_regular = $(filter-out $(topmost_dir)/overlay/%, $(dtbs)) ++# compose the dtbs variable flattening all the non-overlays entries ++# and appending the overlays entries ++dtbs := $(notdir $(dtbs_regular)) $(dtbs_overlays) + + endif # CONFIG_ARCH_WANT_FLAT_DTB_INSTALL + +diff --git a/scripts/Makefile.dtbs b/scripts/Makefile.dtbs +index 111111111111..222222222222 100644 +--- a/scripts/Makefile.dtbs ++++ b/scripts/Makefile.dtbs +@@ -122,17 +122,23 @@ dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) + quiet_cmd_dtc = DTC $(quiet_dtb_check_tag) $@ + cmd_dtc = \ + $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ +- $(DTC) -o $@ -b 0 $(addprefix -i,$(dir $<) $(DTC_INCLUDE)) \ ++ $(DTC) -@ -o $@ -b 0 $(addprefix -i,$(dir $<) $(DTC_INCLUDE)) \ + $(DTC_FLAGS) -d $(depfile).dtc.tmp $(dtc-tmp) ; \ + cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) \ + $(cmd_dtb_check) + ++quiet_cmd_scr = MKIMAGE $@ ++cmd_scr = mkimage -C none -A $(ARCH) -T script -d $< $@ ++ + $(obj)/%.dtb: $(obj)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE + $(call if_changed_dep,dtc) + + $(obj)/%.dtbo: $(src)/%.dtso $(DTC) FORCE + $(call if_changed_dep,dtc) + ++$(obj)/%.scr: $(src)/%.scr-cmd FORCE ++ $(call if_changed,scr) ++ + # targets + # --------------------------------------------------------------------------- + +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-driver-tm1628-auxdisplay-add-support-for-Titanmec-TM16.patch b/patch/kernel/archive/meson64-6.13/general-driver-tm1628-auxdisplay-add-support-for-Titanmec-TM16.patch new file mode 100644 index 000000000..0989fdb06 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-driver-tm1628-auxdisplay-add-support-for-Titanmec-TM16.patch @@ -0,0 +1,585 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Sun, 20 Feb 2022 08:24:47 +0000 +Subject: FROMLIST(v5): auxdisplay: add support for Titanmec TM1628 7 segment + display controller + etc + +FROMLIST(v5): MAINTAINERS: Add entry for tm1628 auxdisplay driver + +Signed-off-by: Heiner Kallweit + +FROMLIST(v5): auxdisplay: add support for Titanmec TM1628 7 segment display controller + +This patch adds support for the Titanmec TM1628 7 segment display +controller. It's based on previous RFC work from Andreas Farber. +The RFC version placed the driver in the LED subsystem, but this was +NAK'ed by the LED maintainer. Therefore I moved the driver to +/drivers/auxdisplay what seems most reasonable to me. + +Further changes to the RFC version: +- Driver can be built also w/o LED class support, for displays that + don't have any symbols to be exposed as LED's. +- Simplified the code and rewrote a lot of it. +- Driver is now kind of a MVP, but functionality should be sufficient + for most use cases. +- Use the existing 7 segment support in uapi/linux/map_to_7segment.h + as suggested by Geert Uytterhoeven. + +Note: There's a number of chips from other manufacturers that are + almost identical, e.g. FD628, SM1628. Only difference I saw so + far is that they partially support other display modes. + TM1628: 6x12, 7x11 + SM1628C: 4x13, 5x12, 6x11, 7x10 + For typical displays on devices using these chips this + difference shouldn't matter. + +Successfully tested on a TX3 Mini TV box that has an SM1628C and a +display with 4 digits and 7 symbols. + +Co-developed-by: Andreas Farber +Signed-off-by: Andreas Farber +Signed-off-by: Heiner Kallweit + +FROMLIST(v5): docs: ABI: document tm1628 attribute display-text + +Document the attribute for reading / writing the text to be displayed on +the 7 segment display. + +Signed-off-by: Heiner Kallweit + +FROMLIST(v5): dt-bindings: auxdisplay: Add Titan Micro Electronics TM1628 + +Add a YAML schema binding for TM1628 auxdisplay +(7/11-segment LED) controller. + +This patch is partially based on previous RFC work from +Andreas Farber . + +Co-developed-by: Andreas Farber +Signed-off-by: Andreas Farber +Signed-off-by: Heiner Kallweit +--- + Documentation/ABI/testing/sysfs-devices-auxdisplay-tm1628 | 7 + + Documentation/devicetree/bindings/auxdisplay/titanmec,tm1628.yaml | 82 ++ + drivers/auxdisplay/Kconfig | 11 + + drivers/auxdisplay/Makefile | 1 + + drivers/auxdisplay/tm1628.c | 376 ++++++++++ + 5 files changed, 477 insertions(+) + +diff --git a/Documentation/ABI/testing/sysfs-devices-auxdisplay-tm1628 b/Documentation/ABI/testing/sysfs-devices-auxdisplay-tm1628 +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/Documentation/ABI/testing/sysfs-devices-auxdisplay-tm1628 +@@ -0,0 +1,7 @@ ++What: /sys/devices/.../display-text ++Date: February 2022 ++Contact: Heiner Kallweit ++Description: ++ The text to be displayed on the 7 segment display. ++ Any printable character is allowed as input, but some ++ can not be displayed in a readable way with 7 segments. +diff --git a/Documentation/devicetree/bindings/auxdisplay/titanmec,tm1628.yaml b/Documentation/devicetree/bindings/auxdisplay/titanmec,tm1628.yaml +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/Documentation/devicetree/bindings/auxdisplay/titanmec,tm1628.yaml +@@ -0,0 +1,82 @@ ++# SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) ++%YAML 1.2 ++--- ++$id: http://devicetree.org/schemas/leds/titanmec,tm1628.yaml# ++$schema: http://devicetree.org/meta-schemas/core.yaml# ++ ++title: Titan Micro Electronics TM1628 LED controller ++ ++properties: ++ compatible: ++ enum: ++ - titanmec,tm1628 ++ ++ reg: ++ maxItems: 1 ++ ++ grid: ++ description: ++ Mapping of display digit position to grid number. ++ This implicitly defines the display size. ++ $ref: /schemas/types.yaml#/definitions/uint8-array ++ minItems: 1 ++ maxItems: 7 ++ ++ segment-mapping: ++ description: ++ Mapping of 7 segment display segments A-G to bit numbers 1-12. ++ $ref: /schemas/types.yaml#/definitions/uint8-array ++ minItems: 7 ++ maxItems: 7 ++ ++ "#address-cells": ++ const: 2 ++ ++ "#size-cells": ++ const: 0 ++ ++required: ++ - compatible ++ - reg ++ ++patternProperties: ++ "^.*@[1-7],([1-9]|1[0-6])$": ++ type: object ++ description: | ++ Properties for a single LED. ++ ++ properties: ++ reg: ++ description: | ++ 1-based grid number, followed by 1-based segment bit number. ++ maxItems: 1 ++ ++ required: ++ - reg ++ ++examples: ++ - | ++ #include ++ ++ spi { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ led-controller@0 { ++ compatible = "titanmec,tm1628"; ++ reg = <0>; ++ spi-3-wire; ++ spi-lsb-first; ++ spi-max-frequency = <500000>; ++ grid = /bits/ 8 <4 3 2 1>; ++ segment-mapping = /bits/ 8 <4 5 6 1 2 3 7>; ++ #address-cells = <2>; ++ #size-cells = <0>; ++ ++ alarmn@5,4 { ++ reg = <5 4>; ++ function = LED_FUNCTION_ALARM; ++ }; ++ }; ++ }; ++... +diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig +index 111111111111..222222222222 100644 +--- a/drivers/auxdisplay/Kconfig ++++ b/drivers/auxdisplay/Kconfig +@@ -59,6 +59,17 @@ config LCD2S + is a simple single color character display. You have to connect it + to an I2C bus. + ++config TM1628 ++ tristate "TM1628 driver for LED 7/11 segment displays" ++ depends on SPI ++ depends on OF || COMPILE_TEST ++ help ++ Say Y to enable support for Titan Micro Electronics TM1628 ++ LED controller. ++ ++ It's a 3-wire SPI device controlling a two-dimensional grid of ++ LEDs. Dimming is applied to all outputs through an internal PWM. ++ + menuconfig PARPORT_PANEL + tristate "Parallel port LCD/Keypad Panel support" + depends on PARPORT +diff --git a/drivers/auxdisplay/Makefile b/drivers/auxdisplay/Makefile +index 111111111111..222222222222 100644 +--- a/drivers/auxdisplay/Makefile ++++ b/drivers/auxdisplay/Makefile +@@ -16,3 +16,4 @@ obj-$(CONFIG_LINEDISP) += line-display.o + obj-$(CONFIG_MAX6959) += max6959.o + obj-$(CONFIG_PARPORT_PANEL) += panel.o + obj-$(CONFIG_SEG_LED_GPIO) += seg-led-gpio.o ++obj-$(CONFIG_TM1628) += tm1628.o +diff --git a/drivers/auxdisplay/tm1628.c b/drivers/auxdisplay/tm1628.c +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/drivers/auxdisplay/tm1628.c +@@ -0,0 +1,376 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later ++/* ++ * Titan Micro Electronics TM1628 LED controller ++ * ++ * Copyright (c) 2019 Andreas Färber ++ * Copyright (c) 2022 Heiner Kallweit ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define TM1628_CMD_DISPLAY_MODE (0 << 6) ++#define TM1628_DISPLAY_MODE_6_12 0x02 ++#define TM1628_DISPLAY_MODE_7_11 0x03 ++ ++#define TM1628_CMD_DATA (1 << 6) ++#define TM1628_DATA_TEST_MODE BIT(3) ++#define TM1628_DATA_FIXED_ADDR BIT(2) ++#define TM1628_DATA_WRITE_DATA 0x00 ++#define TM1628_DATA_READ_DATA 0x02 ++ ++#define TM1628_CMD_DISPLAY_CTRL (2 << 6) ++#define TM1628_DISPLAY_CTRL_DISPLAY_ON BIT(3) ++ ++#define TM1628_CMD_SET_ADDRESS (3 << 6) ++ ++#define TM1628_BRIGHTNESS_MAX 7 ++#define NUM_LED_SEGS 7 ++ ++/* Physical limits, depending on the mode the chip may support less */ ++#define MAX_GRID_SIZE 7 ++#define MAX_SEGMENT_NUM 16 ++ ++struct tm1628_led { ++ struct led_classdev leddev; ++ struct tm1628 *ctrl; ++ u32 grid; ++ u32 seg; ++}; ++ ++struct tm1628 { ++ struct spi_device *spi; ++ __le16 data[MAX_GRID_SIZE]; ++ struct mutex disp_lock; ++ char text[MAX_GRID_SIZE + 1]; ++ u8 segment_mapping[NUM_LED_SEGS]; ++ u8 grid[MAX_GRID_SIZE]; ++ int grid_size; ++ struct tm1628_led leds[]; ++}; ++ ++/* Command 1: Display Mode Setting */ ++static int tm1628_set_display_mode(struct spi_device *spi, u8 grid_mode) ++{ ++ const u8 cmd = TM1628_CMD_DISPLAY_MODE | grid_mode; ++ ++ return spi_write(spi, &cmd, 1); ++} ++ ++/* Command 3: Address Setting */ ++static int tm1628_set_address(struct spi_device *spi, u8 offset) ++{ ++ const u8 cmd = TM1628_CMD_SET_ADDRESS | (offset * sizeof(__le16)); ++ ++ return spi_write(spi, &cmd, 1); ++} ++ ++/* Command 2: Data Setting */ ++static int tm1628_write_data(struct spi_device *spi, unsigned int offset, ++ unsigned int len) ++{ ++ struct tm1628 *s = spi_get_drvdata(spi); ++ const u8 cmd = TM1628_CMD_DATA | TM1628_DATA_WRITE_DATA; ++ struct spi_transfer xfers[] = { ++ { ++ .tx_buf = &cmd, ++ .len = 1, ++ }, ++ { ++ .tx_buf = (__force void *)(s->data + offset), ++ .len = len * sizeof(__le16), ++ }, ++ }; ++ ++ if (offset + len > MAX_GRID_SIZE) { ++ dev_err(&spi->dev, "Invalid data address offset %u len %u\n", ++ offset, len); ++ return -EINVAL; ++ } ++ ++ tm1628_set_address(spi, offset); ++ ++ return spi_sync_transfer(spi, xfers, ARRAY_SIZE(xfers)); ++} ++ ++/* Command 4: Display Control */ ++static int tm1628_set_display_ctrl(struct spi_device *spi, bool on) ++{ ++ u8 cmd = TM1628_CMD_DISPLAY_CTRL | TM1628_BRIGHTNESS_MAX; ++ ++ if (on) ++ cmd |= TM1628_DISPLAY_CTRL_DISPLAY_ON; ++ ++ return spi_write(spi, &cmd, 1); ++} ++ ++static int tm1628_show_text(struct tm1628 *s) ++{ ++ static SEG7_CONVERSION_MAP(map_seg7, MAP_ASCII7SEG_ALPHANUM); ++ int msg_len, i, ret; ++ ++ msg_len = strlen(s->text); ++ ++ mutex_lock(&s->disp_lock); ++ ++ for (i = 0; i < s->grid_size; i++) { ++ int pos = s->grid[i] - 1; ++ int j, char7_raw, char7; ++ ++ if (i >= msg_len) { ++ s->data[pos] = 0; ++ continue; ++ } ++ ++ char7_raw = map_to_seg7(&map_seg7, s->text[i]); ++ ++ for (j = 0, char7 = 0; j < NUM_LED_SEGS; j++) { ++ if (char7_raw & BIT(j)) ++ char7 |= BIT(s->segment_mapping[j] - 1); ++ } ++ ++ s->data[pos] = cpu_to_le16(char7); ++ } ++ ++ ret = tm1628_write_data(s->spi, 0, s->grid_size); ++ ++ mutex_unlock(&s->disp_lock); ++ ++ return ret; ++} ++ ++static int tm1628_led_set_brightness(struct led_classdev *led_cdev, ++ enum led_brightness brightness) ++{ ++ struct tm1628_led *led = container_of(led_cdev, struct tm1628_led, leddev); ++ struct tm1628 *s = led->ctrl; ++ int ret, offset = led->grid - 1; ++ __le16 bit = cpu_to_le16(BIT(led->seg - 1)); ++ ++ mutex_lock(&s->disp_lock); ++ ++ if (brightness == LED_OFF) ++ s->data[offset] &= ~bit; ++ else ++ s->data[offset] |= bit; ++ ++ ret = tm1628_write_data(s->spi, offset, 1); ++ ++ mutex_unlock(&s->disp_lock); ++ ++ return ret; ++} ++ ++static enum led_brightness tm1628_led_get_brightness(struct led_classdev *led_cdev) ++{ ++ struct tm1628_led *led = container_of(led_cdev, struct tm1628_led, leddev); ++ struct tm1628 *s = led->ctrl; ++ int offset = led->grid - 1; ++ __le16 bit = cpu_to_le16(BIT(led->seg - 1)); ++ bool on; ++ ++ mutex_lock(&s->disp_lock); ++ on = s->data[offset] & bit; ++ mutex_unlock(&s->disp_lock); ++ ++ return on ? LED_ON : LED_OFF; ++} ++ ++static int tm1628_register_led(struct tm1628 *s, struct fwnode_handle *node, ++ u32 grid, u32 seg, struct tm1628_led *led) ++{ ++ struct device *dev = &s->spi->dev; ++ struct led_init_data init_data = { .fwnode = node }; ++ ++ led->ctrl = s; ++ led->grid = grid; ++ led->seg = seg; ++ led->leddev.max_brightness = LED_ON; ++ led->leddev.brightness_set_blocking = tm1628_led_set_brightness; ++ led->leddev.brightness_get = tm1628_led_get_brightness; ++ ++ return devm_led_classdev_register_ext(dev, &led->leddev, &init_data); ++} ++ ++static ssize_t display_text_show(struct device *dev, struct device_attribute *attr, ++ char *buf) ++{ ++ struct tm1628 *s = dev_get_drvdata(dev); ++ ++ return sysfs_emit(buf, "%s\n", s->text); ++} ++ ++static ssize_t display_text_store(struct device *dev, struct device_attribute *attr, ++ const char *buf, size_t count) ++{ ++ struct tm1628 *s = dev_get_drvdata(dev); ++ int ret, i; ++ ++ for (i = 0; i < count && i < s->grid_size && isprint(buf[i]); i++) ++ s->text[i] = buf[i]; ++ ++ s->text[i] = '\0'; ++ ++ ret = tm1628_show_text(s); ++ if (ret < 0) ++ return ret; ++ ++ return count; ++} ++ ++static const DEVICE_ATTR_RW(display_text); ++ ++static int tm1628_spi_probe(struct spi_device *spi) ++{ ++ struct fwnode_handle *child; ++ unsigned int num_leds; ++ struct tm1628 *s; ++ int ret, i; ++ ++ num_leds = device_get_child_node_count(&spi->dev); ++ ++ s = devm_kzalloc(&spi->dev, struct_size(s, leds, num_leds), GFP_KERNEL); ++ if (!s) ++ return -ENOMEM; ++ ++ s->spi = spi; ++ spi_set_drvdata(spi, s); ++ ++ mutex_init(&s->disp_lock); ++ ++ /* According to TM1628 datasheet */ ++ msleep(200); ++ ++ /* Clear screen */ ++ ret = tm1628_write_data(spi, 0, MAX_GRID_SIZE); ++ if (ret) ++ return ret; ++ ++ /* For now we support 6x12 mode only. This should be sufficient for most use cases */ ++ ret = tm1628_set_display_mode(spi, TM1628_DISPLAY_MODE_6_12); ++ if (ret) ++ return ret; ++ ++ ret = tm1628_set_display_ctrl(spi, true); ++ if (ret) ++ return ret; ++ ++ num_leds = 0; ++ ++ if (!IS_REACHABLE(CONFIG_LEDS_CLASS)) ++ goto no_leds; ++ ++ device_for_each_child_node(&spi->dev, child) { ++ u32 reg[2]; ++ ++ ret = fwnode_property_read_u32_array(child, "reg", reg, 2); ++ if (ret) { ++ dev_err(&spi->dev, "Reading %s reg property failed (%d)\n", ++ fwnode_get_name(child), ret); ++ continue; ++ } ++ ++ if (reg[0] == 0 || reg[0] > MAX_GRID_SIZE) { ++ dev_err(&spi->dev, "Invalid grid %u at %s\n", ++ reg[0], fwnode_get_name(child)); ++ continue; ++ } ++ ++ if (reg[1] == 0 || reg[1] > MAX_SEGMENT_NUM) { ++ dev_err(&spi->dev, "Invalid segment %u at %s\n", ++ reg[1], fwnode_get_name(child)); ++ continue; ++ } ++ ++ ret = tm1628_register_led(s, child, reg[0], reg[1], s->leds + num_leds); ++ if (ret) { ++ dev_err(&spi->dev, "Failed to register LED %s (%d)\n", ++ fwnode_get_name(child), ret); ++ continue; ++ } ++ num_leds++; ++ } ++ ++no_leds: ++ ret = device_property_count_u8(&spi->dev, "titanmec,grid"); ++ if (ret < 1 || ret > MAX_GRID_SIZE) { ++ dev_err(&spi->dev, "Invalid display length (%d)\n", ret); ++ return -EINVAL; ++ } ++ ++ s->grid_size = ret; ++ ++ ret = device_property_read_u8_array(&spi->dev, "titanmec,grid", s->grid, s->grid_size); ++ if (ret < 0) ++ return ret; ++ ++ for (i = 0; i < s->grid_size; i++) { ++ if (s->grid[i] < 1 || s->grid[i] > s->grid_size) ++ return -EINVAL; ++ } ++ ++ ret = device_property_read_u8_array(&spi->dev, "titanmec,segment-mapping", ++ s->segment_mapping, NUM_LED_SEGS); ++ if (ret < 0) ++ return ret; ++ ++ for (i = 0; i < NUM_LED_SEGS; i++) { ++ if (s->segment_mapping[i] < 1 || s->segment_mapping[i] > MAX_SEGMENT_NUM) ++ return -EINVAL; ++ } ++ ++ ret = device_create_file(&spi->dev, &dev_attr_display_text); ++ if (ret) ++ return ret; ++ ++ dev_info(&spi->dev, "Configured display with %u digits and %u symbols\n", ++ s->grid_size, num_leds); ++ ++ return 0; ++} ++ ++static void tm1628_spi_remove(struct spi_device *spi) ++{ ++ device_remove_file(&spi->dev, &dev_attr_display_text); ++ tm1628_set_display_ctrl(spi, false); ++} ++ ++static void tm1628_spi_shutdown(struct spi_device *spi) ++{ ++ tm1628_set_display_ctrl(spi, false); ++} ++ ++static const struct of_device_id tm1628_spi_of_matches[] = { ++ { .compatible = "titanmec,tm1628" }, ++ {} ++}; ++MODULE_DEVICE_TABLE(of, tm1628_spi_of_matches); ++ ++static const struct spi_device_id tm1628_spi_id_table[] = { ++ { "tm1628" }, ++ {}, ++}; ++MODULE_DEVICE_TABLE(spi, tm1628_spi_id_table); ++ ++static struct spi_driver tm1628_spi_driver = { ++ .probe = tm1628_spi_probe, ++ .remove = tm1628_spi_remove, ++ .shutdown = tm1628_spi_shutdown, ++ .id_table = tm1628_spi_id_table, ++ ++ .driver = { ++ .name = "tm1628", ++ .of_match_table = tm1628_spi_of_matches, ++ }, ++}; ++module_spi_driver(tm1628_spi_driver); ++ ++MODULE_DESCRIPTION("TM1628 LED controller driver"); ++MODULE_AUTHOR("Andreas Färber "); ++MODULE_AUTHOR("Heiner Kallweit "); ++MODULE_LICENSE("GPL"); +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-drm-dw-hdmi-call-hdmi_set_cts_n-after-clock.patch b/patch/kernel/archive/meson64-6.13/general-drm-dw-hdmi-call-hdmi_set_cts_n-after-clock.patch new file mode 100644 index 000000000..7734c4c34 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-drm-dw-hdmi-call-hdmi_set_cts_n-after-clock.patch @@ -0,0 +1,30 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jonas Karlman +Date: Mon, 9 Jul 2018 21:25:15 +0200 +Subject: TEMP: drm: dw-hdmi: call hdmi_set_cts_n after clock is enabled + +Unknown patch. Archeology: +- 99f6bef7de297253a659c22d4a35343a209f98b8: Igor Pecovnik : 'Attach Meson64 CURRENT to 5.6.y and make DEV = CURRENT at this point. (#1956)' +--- + drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +index 111111111111..222222222222 100644 +--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c ++++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +@@ -765,6 +765,11 @@ static void hdmi_enable_audio_clk(struct dw_hdmi *hdmi, bool enable) + else + hdmi->mc_clkdis |= HDMI_MC_CLKDIS_AUDCLK_DISABLE; + hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS); ++ ++ if (enable) { ++ hdmi_set_cts_n(hdmi, hdmi->audio_cts, 0); ++ hdmi_set_cts_n(hdmi, hdmi->audio_cts, hdmi->audio_n); ++ } + } + + static u8 *hdmi_audio_get_eld(struct dw_hdmi *hdmi) +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-drm-panfrost-fix-reference-leak.patch b/patch/kernel/archive/meson64-6.13/general-drm-panfrost-fix-reference-leak.patch new file mode 100644 index 000000000..97fb7f4d7 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-drm-panfrost-fix-reference-leak.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Qinglang Miao +Date: Sat, 28 Nov 2020 16:10:04 +0000 +Subject: drm/panfrost: fix reference leak in panfrost_job_hw_submit + +pm_runtime_get_sync will increment pm usage counter even it +failed. Forgetting to putting operation will result in a +reference leak here. + +A new function pm_runtime_resume_and_get is introduced in +[0] to keep usage counter balanced. So We fix the reference +leak by replacing it with new funtion. + +[0] dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") + +Fixes: f3ba91228e8e ("drm/panfrost: Add initial panfrost driver") +Reported-by: Hulk Robot +Signed-off-by: Qinglang Miao +--- + drivers/gpu/drm/panfrost/panfrost_job.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c +index 111111111111..222222222222 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_job.c ++++ b/drivers/gpu/drm/panfrost/panfrost_job.c +@@ -204,7 +204,7 @@ static void panfrost_job_hw_submit(struct panfrost_job *job, int js) + + panfrost_devfreq_record_busy(&pfdev->pfdevfreq); + +- ret = pm_runtime_get_sync(pfdev->dev); ++ ret = pm_runtime_resume_and_get(pfdev->dev); + if (ret < 0) + return; + +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-fix-Kodi-sysinfo-CPU-information.patch b/patch/kernel/archive/meson64-6.13/general-fix-Kodi-sysinfo-CPU-information.patch new file mode 100644 index 000000000..7166e299f --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-fix-Kodi-sysinfo-CPU-information.patch @@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Christian Hewitt +Date: Sat, 13 Apr 2019 05:45:18 +0000 +Subject: HACK: arm64: fix Kodi sysinfo CPU information + +This allows the CPU information to show in the Kodi sysinfo screen, e.g. + +"ARMv8 Processor rev 4 (v81)" on Amlogic devices + +Signed-off-by: Christian Hewitt +--- + arch/arm64/kernel/cpuinfo.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c +index 111111111111..222222222222 100644 +--- a/arch/arm64/kernel/cpuinfo.c ++++ b/arch/arm64/kernel/cpuinfo.c +@@ -206,8 +206,7 @@ static int c_show(struct seq_file *m, void *v) + * "processor". Give glibc what it expects. + */ + seq_printf(m, "processor\t: %d\n", i); +- if (compat) +- seq_printf(m, "model name\t: ARMv8 Processor rev %d (%s)\n", ++ seq_printf(m, "model name\t: ARMv8 Processor rev %d (%s)\n", + MIDR_REVISION(midr), COMPAT_ELF_PLATFORM); + + seq_printf(m, "BogoMIPS\t: %lu.%02lu\n", +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-gpu-drm-add-new-display-resolution-2560x1440.patch b/patch/kernel/archive/meson64-6.13/general-gpu-drm-add-new-display-resolution-2560x1440.patch new file mode 100644 index 000000000..58d2d1688 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-gpu-drm-add-new-display-resolution-2560x1440.patch @@ -0,0 +1,72 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Dongjin Kim +Date: Thu, 10 Sep 2020 11:01:33 +0900 +Subject: ODROID-COMMON: gpu/drm: add new display resolution 2560x1440 + +Signed-off-by: Joy Cho +Signed-off-by: Dongjin Kim +- rpardini: hammer for 6.4-rc5 +--- + drivers/gpu/drm/meson/meson_vclk.c | 18 ++++++++++ + drivers/gpu/drm/meson/meson_venc.c | 2 +- + 2 files changed, 19 insertions(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/meson/meson_vclk.c b/drivers/gpu/drm/meson/meson_vclk.c +index 111111111111..222222222222 100644 +--- a/drivers/gpu/drm/meson/meson_vclk.c ++++ b/drivers/gpu/drm/meson/meson_vclk.c +@@ -357,6 +357,8 @@ enum { + MESON_VCLK_HDMI_594000, + /* 2970 /1 /1 /1 /5 /1 => /1 /2 */ + MESON_VCLK_HDMI_594000_YUV420, ++/* 4830 /2 /1 /2 /5 /1 => /1 /1 */ ++ MESON_VCLK_HDMI_241500, + }; + + struct meson_vclk_params { +@@ -467,6 +469,18 @@ struct meson_vclk_params { + .vid_pll_div = VID_PLL_DIV_5, + .vclk_div = 1, + }, ++ [MESON_VCLK_HDMI_241500] = { ++ .pll_freq = 4830000, ++ .phy_freq = 2415000, ++ .venc_freq = 241500, ++ .vclk_freq = 241500, ++ .pixel_freq = 241500, ++ .pll_od1 = 2, ++ .pll_od2 = 1, ++ .pll_od3 = 2, ++ .vid_pll_div = VID_PLL_DIV_5, ++ .vclk_div = 1, ++ }, + { /* sentinel */ }, + }; + +@@ -873,6 +887,10 @@ static void meson_vclk_set(struct meson_drm *priv, unsigned int pll_base_freq, + m = 0xf7; + frac = vic_alternate_clock ? 0x8148 : 0x10000; + break; ++ case 4830000: ++ m = 0xc9; ++ frac = 0xd560; ++ break; + } + + meson_hdmi_pll_set_params(priv, m, frac, od1, od2, od3); +diff --git a/drivers/gpu/drm/meson/meson_venc.c b/drivers/gpu/drm/meson/meson_venc.c +index 111111111111..222222222222 100644 +--- a/drivers/gpu/drm/meson/meson_venc.c ++++ b/drivers/gpu/drm/meson/meson_venc.c +@@ -868,7 +868,7 @@ meson_venc_hdmi_supported_mode(const struct drm_display_mode *mode) + DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_NVSYNC)) + return MODE_BAD; + +- if (mode->hdisplay < 400 || mode->hdisplay > 1920) ++ if (mode->hdisplay < 400 || mode->hdisplay > 2560) + return MODE_BAD_HVALUE; + + if (mode->vdisplay < 480 || mode->vdisplay > 1920) +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-input-touchscreen-Add-D-WAV-Multitouch.patch b/patch/kernel/archive/meson64-6.13/general-input-touchscreen-Add-D-WAV-Multitouch.patch new file mode 100644 index 000000000..950309a90 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-input-touchscreen-Add-D-WAV-Multitouch.patch @@ -0,0 +1,636 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Hyeonki Hong +Date: Thu, 5 Mar 2020 19:01:43 +0900 +Subject: ODROID-COMMON: input/touchscreen: Add D-WAV Multitouch driver. + +Change-Id: Ia1c8c29d3f69c6ba5d630279c4cc98119b68ab71 +--- + drivers/hid/hid-ids.h | 6 + + drivers/hid/hid-quirks.c | 3 + + drivers/input/touchscreen/Kconfig | 10 + + drivers/input/touchscreen/Makefile | 1 + + drivers/input/touchscreen/dwav-usb-mt.c | 554 ++++++++++ + 5 files changed, 574 insertions(+) + +diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h +index 111111111111..222222222222 100644 +--- a/drivers/hid/hid-ids.h ++++ b/drivers/hid/hid-ids.h +@@ -1475,4 +1475,10 @@ + #define USB_VENDOR_ID_SIGNOTEC 0x2133 + #define USB_DEVICE_ID_SIGNOTEC_VIEWSONIC_PD1011 0x0018 + ++#define USB_DEVICE_ID_DWAV_MULTITOUCH 0x0005 ++ ++#define USB_VENDOR_ID_ODROID 0x16b4 ++#define USB_DEVICE_ID_VU5 0x0704 ++#define USB_DEVICE_ID_VU7PLUS 0x0705 ++ + #endif +diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c +index 111111111111..222222222222 100644 +--- a/drivers/hid/hid-quirks.c ++++ b/drivers/hid/hid-quirks.c +@@ -891,6 +891,9 @@ static const struct hid_device_id hid_ignore_list[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_DPAD) }, + #endif + { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) }, ++ ++ { HID_USB_DEVICE(USB_VENDOR_ID_ODROID, USB_DEVICE_ID_VU5) }, ++ { HID_USB_DEVICE(USB_VENDOR_ID_ODROID, USB_DEVICE_ID_VU7PLUS) }, + { } + }; + +diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig +index 111111111111..222222222222 100644 +--- a/drivers/input/touchscreen/Kconfig ++++ b/drivers/input/touchscreen/Kconfig +@@ -1388,4 +1388,14 @@ config TOUCHSCREEN_HIMAX_HX83112B + To compile this driver as a module, choose M here: the + module will be called himax_hx83112b. + ++config TOUCHSCREEN_DWAV_USB_MT ++ tristate "D-WAV Scientific USB MultiTouch" ++ depends on USB_ARCH_HAS_HCD ++ select USB ++ help ++ Say Y here if you have a D-WAV Scientific USB(HID) based MultiTouch ++ controller. ++ ++ module will be called dwav-usb-mt. ++ + endif +diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile +index 111111111111..222222222222 100644 +--- a/drivers/input/touchscreen/Makefile ++++ b/drivers/input/touchscreen/Makefile +@@ -116,4 +116,5 @@ obj-$(CONFIG_TOUCHSCREEN_RASPBERRYPI_FW) += raspberrypi-ts.o + obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o + obj-$(CONFIG_TOUCHSCREEN_IQS7211) += iqs7211.o + obj-$(CONFIG_TOUCHSCREEN_ZINITIX) += zinitix.o ++obj-$(CONFIG_TOUCHSCREEN_DWAV_USB_MT) += dwav-usb-mt.o + obj-$(CONFIG_TOUCHSCREEN_HIMAX_HX83112B) += himax_hx83112b.o +diff --git a/drivers/input/touchscreen/dwav-usb-mt.c b/drivers/input/touchscreen/dwav-usb-mt.c +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/drivers/input/touchscreen/dwav-usb-mt.c +@@ -0,0 +1,554 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * D-WAV Scientific USB(HID) MultiTouch Screen Driver(Based on usbtouchscreen.c) ++ * ++ * Copyright (C) Hardkernel, 2015 ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++ ++#define USB_VENDOR_ID_DWAV 0x0eef /* 800 x 480, 7" DWAV touch */ ++#define USB_DEVICE_ID_VU7 0x0005 ++ ++#define USB_VENDOR_ID_ODROID 0x16b4 ++#define USB_DEVICE_ID_VU5 0x0704 ++#define USB_DEVICE_ID_VU7PLUS 0x0705 ++ ++enum { ++ ODROID_VU7 = 0, /* 800 x 480, 7" Touch */ ++ ODROID_VU5, /* 800 x 480, 5" Touch */ ++ ODROID_VU7PLUS, /* 1024 x 600, 7" Touch */ ++}; ++ ++struct usbtouch_device_info { ++ char name[64]; ++ int max_x; ++ int max_y; ++ int max_press; ++ int max_finger; ++}; ++ ++const struct usbtouch_device_info DEV_INFO[] = { ++ [ODROID_VU7] = { ++ .name = "ODROID VU7 MultiTouch(800x480)", ++ .max_x = 800, ++ .max_y = 480, ++ .max_press = 255, ++ .max_finger = 5, ++ }, ++ [ODROID_VU5] = { ++ .name = "ODROID VU5 MultiTouch(800x480)", ++ .max_x = 800, ++ .max_y = 480, ++ .max_press = 255, ++ .max_finger = 5, ++ }, ++ [ODROID_VU7PLUS] = { ++ .name = "ODROID VU7 Plus MultiTouch(1024x600)", ++ .max_x = 1024, ++ .max_y = 600, ++ .max_press = 255, ++ .max_finger = 5, ++ }, ++}; ++ ++static const struct usb_device_id dwav_usb_mt_devices[] = { ++ {USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_VU7), ++ .driver_info = ODROID_VU7}, ++ {USB_DEVICE(USB_VENDOR_ID_ODROID, USB_DEVICE_ID_VU5), ++ .driver_info = ODROID_VU5}, ++ {USB_DEVICE(USB_VENDOR_ID_ODROID, USB_DEVICE_ID_VU7PLUS), ++ .driver_info = ODROID_VU7PLUS}, ++ {} ++}; ++ ++struct dwav_raw { /* Total 25 bytes */ ++ unsigned char header; /* frame header 0xAA*/ ++ unsigned char press; ++ /* Touch flag (1:valid touch data, 0:touch finished) */ ++ unsigned short x1; /* 1st x */ ++ unsigned short y1; /* 1st y */ ++ unsigned char end; ++ /* 1st touch finish flags 0xBB, RPI only uses the first 7 bytes */ ++ unsigned char ids; /* touch ID(bit field) */ ++ unsigned short y2; ++ unsigned short x2; ++ unsigned short y3; ++ unsigned short x3; ++ unsigned short y4; ++ unsigned short x4; ++ unsigned short y5; ++ unsigned short x5; ++ unsigned char tail; /* frame end 0xCC */ ++}; ++ ++#define TS_EVENT_UNKNOWN 0x00 ++#define TS_EVENT_PRESS 0x01 ++#define TS_EVENT_RELEASE 0x02 ++ ++struct finger_t { ++ unsigned int status; /* ts event type */ ++ unsigned int x; /* ts data x */ ++ unsigned int y; /* ts data y */ ++} __packed; ++ ++struct dwav_usb_mt { ++ char name[128], phys[64]; ++ ++ int dev_id; ++ /* for URB Data DMA */ ++ dma_addr_t data_dma; ++ unsigned char *data; ++ int data_size; ++ ++ struct urb *irq; ++ struct usb_interface *interface; ++ struct input_dev *input; ++ ++ struct finger_t *finger; ++}; ++ ++static void dwav_usb_mt_report(struct dwav_usb_mt *dwav_usb_mt) ++{ ++ int id, max_x, max_y, max_press, max_finger; ++ ++ max_x = DEV_INFO[dwav_usb_mt->dev_id].max_x; ++ max_y = DEV_INFO[dwav_usb_mt->dev_id].max_y; ++ max_press = DEV_INFO[dwav_usb_mt->dev_id].max_press; ++ max_finger = DEV_INFO[dwav_usb_mt->dev_id].max_finger; ++ ++ for (id = 0; id < max_finger; id++) { ++ ++ if (dwav_usb_mt->finger[id].status == TS_EVENT_UNKNOWN) ++ continue; ++ ++ if (dwav_usb_mt->finger[id].x >= max_x || ++ dwav_usb_mt->finger[id].y >= max_y) ++ continue; ++ ++ input_mt_slot(dwav_usb_mt->input, id); ++ ++ if (dwav_usb_mt->finger[id].status != TS_EVENT_RELEASE) { ++ input_mt_report_slot_state(dwav_usb_mt->input, ++ MT_TOOL_FINGER, true); ++ input_report_abs(dwav_usb_mt->input, ++ ABS_MT_POSITION_X, ++ dwav_usb_mt->finger[id].x); ++ input_report_abs(dwav_usb_mt->input, ++ ABS_MT_POSITION_Y, ++ dwav_usb_mt->finger[id].y); ++ input_report_abs(dwav_usb_mt->input, ++ ABS_MT_PRESSURE, ++ max_press); ++ } else { ++ input_mt_report_slot_state(dwav_usb_mt->input, ++ MT_TOOL_FINGER, false); ++ dwav_usb_mt->finger[id].status = TS_EVENT_UNKNOWN; ++ } ++ input_mt_report_pointer_emulation(dwav_usb_mt->input, true); ++ input_sync(dwav_usb_mt->input); ++ } ++} ++ ++static void dwav_usb_mt_process(struct dwav_usb_mt *dwav_usb_mt, ++ unsigned char *pkt, int len) ++{ ++ struct dwav_raw *dwav_raw = (struct dwav_raw *)pkt; ++ unsigned char bit_mask, cnt; ++ ++ for (cnt = 0, bit_mask = 0x01; ++ cnt < DEV_INFO[dwav_usb_mt->dev_id].max_finger; ++ cnt++, bit_mask <<= 1) { ++ if ((dwav_raw->ids & bit_mask) && dwav_raw->press) { ++ dwav_usb_mt->finger[cnt].status = TS_EVENT_PRESS; ++ switch (cnt) { ++ case 0: ++ dwav_usb_mt->finger[cnt].x ++ = cpu_to_be16(dwav_raw->x1); ++ dwav_usb_mt->finger[cnt].y ++ = cpu_to_be16(dwav_raw->y1); ++ break; ++ case 1: ++ dwav_usb_mt->finger[cnt].x ++ = cpu_to_be16(dwav_raw->x2); ++ dwav_usb_mt->finger[cnt].y ++ = cpu_to_be16(dwav_raw->y2); ++ break; ++ case 2: ++ dwav_usb_mt->finger[cnt].x ++ = cpu_to_be16(dwav_raw->x3); ++ dwav_usb_mt->finger[cnt].y ++ = cpu_to_be16(dwav_raw->y3); ++ break; ++ case 3: ++ dwav_usb_mt->finger[cnt].x ++ = cpu_to_be16(dwav_raw->x4); ++ dwav_usb_mt->finger[cnt].y ++ = cpu_to_be16(dwav_raw->y4); ++ break; ++ case 4: ++ dwav_usb_mt->finger[cnt].x ++ = cpu_to_be16(dwav_raw->x5); ++ dwav_usb_mt->finger[cnt].y ++ = cpu_to_be16(dwav_raw->y5); ++ break; ++ default: ++ break; ++ } ++ } else { ++ if (dwav_usb_mt->finger[cnt].status == TS_EVENT_PRESS) ++ dwav_usb_mt->finger[cnt].status ++ = TS_EVENT_RELEASE; ++ else ++ dwav_usb_mt->finger[cnt].status ++ = TS_EVENT_UNKNOWN; ++ } ++ } ++ dwav_usb_mt_report(dwav_usb_mt); ++} ++ ++static void dwav_usb_mt_irq(struct urb *urb) ++{ ++ struct dwav_usb_mt *dwav_usb_mt = urb->context; ++ struct device *dev = &dwav_usb_mt->interface->dev; ++ int retval; ++ ++ switch (urb->status) { ++ case 0: ++ /* success */ ++ break; ++ case -ETIME: ++ /* this urb is timing out */ ++ dev_dbg(dev, "%s - urb timed out - was the device unplugged?\n", ++ __func__); ++ return; ++ case -ECONNRESET: ++ case -ENOENT: ++ case -ESHUTDOWN: ++ case -EPIPE: ++ /* this urb is terminated, clean up */ ++ dev_dbg(dev, "%s - urb shutting down with status: %d\n", ++ __func__, urb->status); ++ return; ++ default: ++ dev_dbg(dev, "%s - nonzero urb status received: %d\n", ++ __func__, urb->status); ++ goto exit; ++ } ++ ++ dwav_usb_mt_process(dwav_usb_mt, dwav_usb_mt->data, urb->actual_length); ++ ++exit: ++ usb_mark_last_busy(interface_to_usbdev(dwav_usb_mt->interface)); ++ retval = usb_submit_urb(urb, GFP_ATOMIC); ++ if (retval) { ++ dev_err(dev, "%s - usb_submit_urb failed with result: %d\n", ++ __func__, retval); ++ } ++} ++ ++static int dwav_usb_mt_open(struct input_dev *input) ++{ ++ struct dwav_usb_mt *dwav_usb_mt = input_get_drvdata(input); ++ int r; ++ ++ dwav_usb_mt->irq->dev = interface_to_usbdev(dwav_usb_mt->interface); ++ ++ r = usb_autopm_get_interface(dwav_usb_mt->interface) ? -EIO : 0; ++ if (r < 0) ++ goto out; ++ ++ if (usb_submit_urb(dwav_usb_mt->irq, GFP_KERNEL)) { ++ r = -EIO; ++ goto out_put; ++ } ++ ++ dwav_usb_mt->interface->needs_remote_wakeup = 1; ++out_put: ++ usb_autopm_put_interface(dwav_usb_mt->interface); ++out: ++ return r; ++} ++ ++static void dwav_usb_mt_close(struct input_dev *input) ++{ ++ struct dwav_usb_mt *dwav_usb_mt = input_get_drvdata(input); ++ int r; ++ ++ usb_kill_urb(dwav_usb_mt->irq); ++ ++ r = usb_autopm_get_interface(dwav_usb_mt->interface); ++ ++ dwav_usb_mt->interface->needs_remote_wakeup = 0; ++ if (!r) ++ usb_autopm_put_interface(dwav_usb_mt->interface); ++} ++ ++static int dwav_usb_mt_suspend(struct usb_interface *intf, pm_message_t message) ++{ ++ struct dwav_usb_mt *dwav_usb_mt = usb_get_intfdata(intf); ++ ++ usb_kill_urb(dwav_usb_mt->irq); ++ ++ return 0; ++} ++ ++static int dwav_usb_mt_resume(struct usb_interface *intf) ++{ ++ struct dwav_usb_mt *dwav_usb_mt = usb_get_intfdata(intf); ++ struct input_dev *input = dwav_usb_mt->input; ++ int result = 0; ++ ++ mutex_lock(&input->mutex); ++ if (input->users) ++ result = usb_submit_urb(dwav_usb_mt->irq, GFP_NOIO); ++ mutex_unlock(&input->mutex); ++ ++ return result; ++} ++ ++static int dwav_usb_mt_reset_resume(struct usb_interface *intf) ++{ ++ struct dwav_usb_mt *dwav_usb_mt = usb_get_intfdata(intf); ++ struct input_dev *input = dwav_usb_mt->input; ++ int err = 0; ++ ++ /* restart IO if needed */ ++ mutex_lock(&input->mutex); ++ if (input->users) ++ err = usb_submit_urb(dwav_usb_mt->irq, GFP_NOIO); ++ mutex_unlock(&input->mutex); ++ ++ return err; ++} ++ ++static void dwav_usb_mt_free_buffers(struct usb_device *udev, ++ struct dwav_usb_mt *dwav_usb_mt) ++{ ++ usb_free_coherent(udev, dwav_usb_mt->data_size, ++ dwav_usb_mt->data, dwav_usb_mt->data_dma); ++} ++ ++static struct usb_endpoint_descriptor *dwav_usb_mt_get_input_endpoint( ++ struct usb_host_interface *interface) ++{ ++ int i; ++ ++ for (i = 0; i < interface->desc.bNumEndpoints; i++) { ++ if (usb_endpoint_dir_in(&interface->endpoint[i].desc)) ++ return &interface->endpoint[i].desc; ++ } ++ ++ return NULL; ++} ++ ++static int dwav_usb_mt_init(struct dwav_usb_mt *dwav_usb_mt, void *dev) ++{ ++ int err; ++ struct input_dev *input_dev = (struct input_dev *)dev; ++ ++ input_dev->name = dwav_usb_mt->name; ++ input_dev->phys = dwav_usb_mt->phys; ++ ++ input_set_drvdata(input_dev, dwav_usb_mt); ++ ++ input_dev->open = dwav_usb_mt_open; ++ input_dev->close = dwav_usb_mt_close; ++ ++ input_dev->id.bustype = BUS_USB; ++ ++ /* single touch */ ++ input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); ++ input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); ++ ++ input_set_abs_params(input_dev, ABS_X, 0, ++ DEV_INFO[dwav_usb_mt->dev_id].max_x, 0, 0); ++ input_set_abs_params(input_dev, ABS_Y, 0, ++ DEV_INFO[dwav_usb_mt->dev_id].max_y, 0, 0); ++ ++ /* multi touch */ ++ input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, ++ DEV_INFO[dwav_usb_mt->dev_id].max_x, 0, 0); ++ input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, ++ DEV_INFO[dwav_usb_mt->dev_id].max_y, 0, 0); ++ input_mt_init_slots(input_dev, ++ DEV_INFO[dwav_usb_mt->dev_id].max_finger, 0); ++ ++ err = input_register_device(input_dev); ++ if (err) { ++ pr_err("%s - input_register_device failed, err: %d\n", ++ __func__, err); ++ return err; ++ } ++ ++ dwav_usb_mt->input = input_dev; ++ ++ return 0; ++} ++ ++static int dwav_usb_mt_probe(struct usb_interface *intf, ++ const struct usb_device_id *id) ++{ ++ struct dwav_usb_mt *dwav_usb_mt = NULL; ++ struct input_dev *input_dev = NULL; ++ struct usb_endpoint_descriptor *endpoint; ++ struct usb_device *udev = interface_to_usbdev(intf); ++ ++ int err = 0; ++ ++ endpoint = dwav_usb_mt_get_input_endpoint(intf->cur_altsetting); ++ if (!endpoint) ++ return -ENXIO; ++ ++ dwav_usb_mt = kzalloc(sizeof(struct dwav_usb_mt), GFP_KERNEL); ++ if (!dwav_usb_mt) ++ return -ENOMEM; ++ ++ dwav_usb_mt->dev_id = id->driver_info; ++ ++ dwav_usb_mt->finger = kzalloc(sizeof(struct finger_t) * ++ DEV_INFO[dwav_usb_mt->dev_id].max_finger, ++ GFP_KERNEL); ++ ++ if (!dwav_usb_mt->finger) ++ goto err_free_mem; ++ ++ input_dev = input_allocate_device(); ++ if (!input_dev) ++ goto err_free_mem; ++ ++ dwav_usb_mt->data_size = sizeof(struct dwav_raw); ++ dwav_usb_mt->data = usb_alloc_coherent(udev, dwav_usb_mt->data_size, ++ GFP_KERNEL, &dwav_usb_mt->data_dma); ++ if (!dwav_usb_mt->data) ++ goto err_free_mem; ++ ++ dwav_usb_mt->irq = usb_alloc_urb(0, GFP_KERNEL); ++ if (!dwav_usb_mt->irq) { ++ dev_dbg(&intf->dev, ++ "%s - usb_alloc_urb failed: usbtouch->irq\n", ++ __func__); ++ goto err_free_buffers; ++ } ++ ++ if (usb_endpoint_type(endpoint) == USB_ENDPOINT_XFER_INT) { ++ usb_fill_int_urb(dwav_usb_mt->irq, udev, ++ usb_rcvintpipe(udev, endpoint->bEndpointAddress), ++ dwav_usb_mt->data, dwav_usb_mt->data_size, ++ dwav_usb_mt_irq, dwav_usb_mt, endpoint->bInterval); ++ } else { ++ usb_fill_bulk_urb(dwav_usb_mt->irq, udev, ++ usb_rcvbulkpipe(udev, endpoint->bEndpointAddress), ++ dwav_usb_mt->data, dwav_usb_mt->data_size, ++ dwav_usb_mt_irq, dwav_usb_mt); ++ } ++ ++ dwav_usb_mt->irq->dev = udev; ++ dwav_usb_mt->irq->transfer_dma = dwav_usb_mt->data_dma; ++ dwav_usb_mt->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; ++ ++ dwav_usb_mt->interface = intf; ++ ++ if (udev->manufacturer) ++ strscpy(dwav_usb_mt->name, ++ udev->manufacturer, sizeof(dwav_usb_mt->name)); ++ ++ if (udev->product) { ++ if (udev->manufacturer) ++ strlcat(dwav_usb_mt->name, ++ " ", sizeof(dwav_usb_mt->name)); ++ ++ strlcat(dwav_usb_mt->name, ++ udev->product, sizeof(dwav_usb_mt->name)); ++ } ++ ++ if (!strlen(dwav_usb_mt->name)) { ++ snprintf(dwav_usb_mt->name, sizeof(dwav_usb_mt->name), ++ "D-WAV Scientific MultiTouch %04x:%04x", ++ le16_to_cpu(udev->descriptor.idVendor), ++ le16_to_cpu(udev->descriptor.idProduct)); ++ } ++ ++ usb_make_path(udev, dwav_usb_mt->phys, sizeof(dwav_usb_mt->phys)); ++ strlcat(dwav_usb_mt->phys, "/input0", sizeof(dwav_usb_mt->phys)); ++ ++ usb_to_input_id(udev, &input_dev->id); ++ ++ input_dev->dev.parent = &intf->dev; ++ ++ err = dwav_usb_mt_init(dwav_usb_mt, (void *)input_dev); ++ if (err) ++ goto err_free_urb; ++ ++ usb_set_intfdata(intf, dwav_usb_mt); ++ ++ dev_info(&intf->dev, "%s\n", DEV_INFO[dwav_usb_mt->dev_id].name); ++ ++ return 0; ++ ++err_free_urb: ++ usb_free_urb(dwav_usb_mt->irq); ++ ++err_free_buffers: ++ dwav_usb_mt_free_buffers(udev, dwav_usb_mt); ++ ++err_free_mem: ++ if (input_dev) ++ input_free_device(input_dev); ++ kfree(dwav_usb_mt); ++ ++ return err; ++} ++ ++static void dwav_usb_mt_disconnect(struct usb_interface *intf) ++{ ++ struct dwav_usb_mt *dwav_usb_mt = usb_get_intfdata(intf); ++ ++ if (!dwav_usb_mt) ++ return; ++ ++ dev_dbg(&intf->dev, ++ "%s - dwav_usb_mt is initialized, cleaning up\n", ++ __func__); ++ ++ usb_set_intfdata(intf, NULL); ++ ++ /* this will stop IO via close */ ++ input_unregister_device(dwav_usb_mt->input); ++ ++ usb_free_urb(dwav_usb_mt->irq); ++ ++ dwav_usb_mt_free_buffers(interface_to_usbdev(intf), dwav_usb_mt); ++ ++ kfree(dwav_usb_mt); ++} ++ ++MODULE_DEVICE_TABLE(usb, dwav_usb_mt_devices); ++ ++static struct usb_driver dwav_usb_mt_driver = { ++ .name = "dwav_usb_mt", ++ .probe = dwav_usb_mt_probe, ++ .disconnect = dwav_usb_mt_disconnect, ++ .suspend = dwav_usb_mt_suspend, ++ .resume = dwav_usb_mt_resume, ++ .reset_resume = dwav_usb_mt_reset_resume, ++ .id_table = dwav_usb_mt_devices, ++ .supports_autosuspend = 1, ++}; ++ ++module_usb_driver(dwav_usb_mt_driver); ++ ++MODULE_AUTHOR("Hardkernel Co.,Ltd"); ++MODULE_DESCRIPTION("D-WAV USB(HID) MultiTouch Driver"); ++MODULE_LICENSE("GPL"); ++ ++MODULE_ALIAS("dwav_usb_mt"); +\ No newline at end of file +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-media-cec-silence-CEC-timeout-message-HACK.patch b/patch/kernel/archive/meson64-6.13/general-media-cec-silence-CEC-timeout-message-HACK.patch new file mode 100644 index 000000000..4905e2e4f --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-media-cec-silence-CEC-timeout-message-HACK.patch @@ -0,0 +1,40 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Christian Hewitt +Date: Tue, 7 Jan 2020 07:12:47 +0000 +Subject: HACK: media: cec: silence CEC timeout message + +If testing with an AVR that does not pass-through CEC state the system +log fills with timeout messages. Silence this to stop the log rotation +and ensure other issues are visible. + +[ 42.718009] cec-meson_ao_cec: message ff 84 50 00 01 timed out +[ 45.021994] cec-meson_ao_cec: message ff 87 00 15 82 timed out +[ 47.325965] cec-meson_ao_cec: message 10 timed out +[ 49.630023] cec-meson_ao_cec: message 10 timed out +[ 51.933960] cec-meson_ao_cec: message 10 timed out + +Signed-off-by: Christian Hewitt +--- + drivers/media/cec/core/cec-adap.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/drivers/media/cec/core/cec-adap.c b/drivers/media/cec/core/cec-adap.c +index 111111111111..222222222222 100644 +--- a/drivers/media/cec/core/cec-adap.c ++++ b/drivers/media/cec/core/cec-adap.c +@@ -510,9 +510,9 @@ int cec_thread_func(void *_adap) + * default). + */ + if (adap->transmitting) { +- pr_warn("cec-%s: message %*ph timed out\n", adap->name, +- adap->transmitting->msg.len, +- adap->transmitting->msg.msg); ++ //pr_warn("cec-%s: message %*ph timed out\n", adap->name, ++ // adap->transmitting->msg.len, ++ // adap->transmitting->msg.msg); + /* Just give up on this. */ + cec_data_cancel(adap->transmitting, + CEC_TX_STATUS_TIMEOUT, 0); +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-memory-marked-nomap.patch b/patch/kernel/archive/meson64-6.13/general-memory-marked-nomap.patch new file mode 100644 index 000000000..dc7329403 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-memory-marked-nomap.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Stefan Agner +Date: Wed, 15 Sep 2021 05:00:45 +0000 +Subject: HACK: of: partial revert of fdt.c changes + +This resolves reports similar to the below which are present in dmesg +since Linux 5.10; which are also causing crashes in some distros: + +[ 0.000000] OF: fdt: Reserved memory: failed to reserve memory for node 'secmon@5000000': base 0x0000000005000000, size 3 MiB + +Signed-off-by: Christian Hewitt +--- + drivers/of/of_reserved_mem.c | 9 --------- + 1 file changed, 9 deletions(-) + +diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c +index 111111111111..222222222222 100644 +--- a/drivers/of/of_reserved_mem.c ++++ b/drivers/of/of_reserved_mem.c +@@ -82,15 +82,6 @@ static int __init early_init_dt_reserve_memory(phys_addr_t base, + phys_addr_t size, bool nomap) + { + if (nomap) { +- /* +- * If the memory is already reserved (by another region), we +- * should not allow it to be marked nomap, but don't worry +- * if the region isn't memory as it won't be mapped. +- */ +- if (memblock_overlaps_region(&memblock.memory, base, size) && +- memblock_is_region_reserved(base, size)) +- return -EBUSY; +- + return memblock_mark_nomap(base, size); + } + return memblock_reserve(base, size); +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-meson-aiu-Fix-HDMI-codec-control-selection.patch b/patch/kernel/archive/meson64-6.13/general-meson-aiu-Fix-HDMI-codec-control-selection.patch new file mode 100644 index 000000000..70d874407 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-meson-aiu-Fix-HDMI-codec-control-selection.patch @@ -0,0 +1,232 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martin Blumenstingl +Date: Sun, 3 Oct 2021 05:35:48 +0000 +Subject: ASoC: meson: aiu: Fix HDMI codec control selection + +The HDMI controllers on Amlogic Meson SoCs which use the AIU +audio-controller have two different audio format inputs: +- I2S which is also the only configuration supported on GXBB, GXL and + GXM SoCs since there's no SPDIF support in the DesignWare HDMI + controller driver (at the time of writing this) +- SPDIF can be used optionally, including pass-through formats + +Switching between these requires us to set different registers: +AIU_HDMI_CLK_DATA_CTRL[1:0] "HDMI_DATA_CLK_SEL": +- 0x0 disables the HDMI output clock +- 0x1 selects the PCM clock +- 0x2 selects the AIU clock +- 0x3 is reserved + +AIU_HDMI_CLK_DATA_CTRL[5:4] "HDMI_DATA_SEL": +- 0x0 outputs constant zero, disables HDMI data +- 0x1 selects PCM data +- 0x2 selects AIU I2S data +- 0x3 is reserved + +AIU_CLK_CTRL_MORE[6] "HDMITX_SEL_AOCLKX2": +- 0x0 selects cts_i958 as AIU clk to hdmi_tx_audio_master_clk +- 0x1 selects cts_aoclkx2_int as AIU clk to hdmi_tx_audio_master_clk + +The Meson8/8b/8m2 vendor driver uses the following settings: +SPDIF output to the HDMI controller: +- 0x2 (AIU clock) in AIU_HDMI_CLK_DATA_CTRL[1:0] +- 0x0 (no HDMI data) in AIU_HDMI_CLK_DATA_CTRL[5:4] +- 0x0 (using cts_i958 as AIU clk) in AIU_CLK_CTRL_MORE[6] +I2S output to the HDMI controller: +- 0x2 (AIU clock) in AIU_HDMI_CLK_DATA_CTRL[1:0] +- 0x2 (I2S data) in AIU_HDMI_CLK_DATA_CTRL[5:4] +- 0x0 (using cts_aoclkx2_int as AIU clk) in AIU_CLK_CTRL_MORE[6] + +The GXBB/GXL/GXM vendor driver uses the following settings: +SPDIF output to the HDMI controller: +- not setting AIU_HDMI_CLK_DATA_CTRL at all +- 0x0 (using cts_i958 as AIU clk) in AIU_CLK_CTRL_MORE[6] +I2S output to the HDMI controller: +- 0x2 (AIU clock) in AIU_HDMI_CLK_DATA_CTRL[1:0] +- 0x2 (I2S data) in AIU_HDMI_CLK_DATA_CTRL[5:4] +- 0x0 (using cts_aoclkx2_int as AIU clk) in AIU_CLK_CTRL_MORE[6] + +Set the three registers at the same time following what the vendor +driver does on Meson8/8b/8m2 SoCs. This makes the SPDIF output to the +HDMI controller work. The entries and order of the entries in the enum +is not changed on purpose to not break old configurations. + +Fixes: b82b734c0e9a7 ("ASoC: meson: aiu: add hdmi codec control support") +Signed-off-by: Martin Blumenstingl +--- + sound/soc/meson/aiu-codec-ctrl.c | 108 +++++++--- + sound/soc/meson/aiu-encoder-i2s.c | 6 - + 2 files changed, 80 insertions(+), 34 deletions(-) + +diff --git a/sound/soc/meson/aiu-codec-ctrl.c b/sound/soc/meson/aiu-codec-ctrl.c +index 111111111111..222222222222 100644 +--- a/sound/soc/meson/aiu-codec-ctrl.c ++++ b/sound/soc/meson/aiu-codec-ctrl.c +@@ -12,14 +12,60 @@ + #include "aiu.h" + #include "meson-codec-glue.h" + +-#define CTRL_CLK_SEL GENMASK(1, 0) +-#define CTRL_DATA_SEL_SHIFT 4 +-#define CTRL_DATA_SEL (0x3 << CTRL_DATA_SEL_SHIFT) +- +-static const char * const aiu_codec_ctrl_mux_texts[] = { +- "DISABLED", "PCM", "I2S", ++#define AIU_HDMI_CLK_DATA_CTRL_CLK_SEL GENMASK(1, 0) ++#define AIU_HDMI_CLK_DATA_CTRL_CLK_SEL_DISABLE 0x0 ++#define AIU_HDMI_CLK_DATA_CTRL_CLK_SEL_PCM 0x1 ++#define AIU_HDMI_CLK_DATA_CTRL_CLK_SEL_AIU 0x2 ++#define AIU_HDMI_CLK_DATA_CTRL_DATA_SEL GENMASK(5, 4) ++#define AIU_HDMI_CLK_DATA_CTRL_DATA_SEL_OUTPUT_ZERO 0x0 ++#define AIU_HDMI_CLK_DATA_CTRL_DATA_SEL_PCM_DATA 0x1 ++#define AIU_HDMI_CLK_DATA_CTRL_DATA_SEL_I2S_DATA 0x2 ++ ++#define AIU_CLK_CTRL_MORE_AMCLK BIT(6) ++ ++#define AIU_HDMI_CTRL_MUX_DISABLED 0 ++#define AIU_HDMI_CTRL_MUX_PCM 1 ++#define AIU_HDMI_CTRL_MUX_I2S 2 ++ ++static const char * const aiu_codec_hdmi_ctrl_mux_texts[] = { ++ [AIU_HDMI_CTRL_MUX_DISABLED] = "DISABLED", ++ [AIU_HDMI_CTRL_MUX_PCM] = "PCM", ++ [AIU_HDMI_CTRL_MUX_I2S] = "I2S", + }; + ++static int aiu_codec_ctrl_mux_get_enum(struct snd_kcontrol *kcontrol, ++ struct snd_ctl_elem_value *ucontrol) ++{ ++ struct snd_soc_component *component = ++ snd_soc_dapm_kcontrol_component(kcontrol); ++ unsigned int ctrl, more, mux = AIU_HDMI_CTRL_MUX_DISABLED; ++ ++ ctrl = snd_soc_component_read(component, AIU_HDMI_CLK_DATA_CTRL); ++ if (FIELD_GET(AIU_HDMI_CLK_DATA_CTRL_CLK_SEL, ctrl) != ++ AIU_HDMI_CLK_DATA_CTRL_CLK_SEL_AIU) { ++ goto out; ++ } ++ ++ more = snd_soc_component_read(component, AIU_CLK_CTRL_MORE); ++ if (FIELD_GET(AIU_HDMI_CLK_DATA_CTRL_DATA_SEL, ctrl) == ++ AIU_HDMI_CLK_DATA_CTRL_DATA_SEL_I2S_DATA && ++ !!(more & AIU_CLK_CTRL_MORE_AMCLK)) { ++ mux = AIU_HDMI_CTRL_MUX_I2S; ++ goto out; ++ } ++ ++ if (FIELD_GET(AIU_HDMI_CLK_DATA_CTRL_DATA_SEL, ctrl) == ++ AIU_HDMI_CLK_DATA_CTRL_DATA_SEL_OUTPUT_ZERO && ++ !(more & AIU_CLK_CTRL_MORE_AMCLK)) { ++ mux = AIU_HDMI_CTRL_MUX_PCM; ++ goto out; ++ } ++ ++out: ++ ucontrol->value.enumerated.item[0] = mux; ++ return 0; ++} ++ + static int aiu_codec_ctrl_mux_put_enum(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) + { +@@ -28,45 +74,51 @@ static int aiu_codec_ctrl_mux_put_enum(struct snd_kcontrol *kcontrol, + struct snd_soc_dapm_context *dapm = + snd_soc_dapm_kcontrol_dapm(kcontrol); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; +- unsigned int mux, changed; ++ unsigned int mux, ctrl, more; + + mux = snd_soc_enum_item_to_val(e, ucontrol->value.enumerated.item[0]); +- changed = snd_soc_component_test_bits(component, e->reg, +- CTRL_DATA_SEL, +- FIELD_PREP(CTRL_DATA_SEL, mux)); + +- if (!changed) +- return 0; ++ if (mux == AIU_HDMI_CTRL_MUX_I2S) { ++ ctrl = FIELD_PREP(AIU_HDMI_CLK_DATA_CTRL_DATA_SEL, ++ AIU_HDMI_CLK_DATA_CTRL_DATA_SEL_I2S_DATA); ++ more = AIU_CLK_CTRL_MORE_AMCLK; ++ } else { ++ ctrl = FIELD_PREP(AIU_HDMI_CLK_DATA_CTRL_DATA_SEL, ++ AIU_HDMI_CLK_DATA_CTRL_DATA_SEL_OUTPUT_ZERO); ++ more = 0; ++ } ++ ++ if (mux == AIU_HDMI_CTRL_MUX_DISABLED) { ++ ctrl |= FIELD_PREP(AIU_HDMI_CLK_DATA_CTRL_CLK_SEL, ++ AIU_HDMI_CLK_DATA_CTRL_CLK_SEL_DISABLE); ++ } else { ++ ctrl |= FIELD_PREP(AIU_HDMI_CLK_DATA_CTRL_CLK_SEL, ++ AIU_HDMI_CLK_DATA_CTRL_CLK_SEL_AIU); ++ } + + /* Force disconnect of the mux while updating */ + snd_soc_dapm_mux_update_power(dapm, kcontrol, 0, NULL, NULL); + +- /* Reset the source first */ +- snd_soc_component_update_bits(component, e->reg, +- CTRL_CLK_SEL | +- CTRL_DATA_SEL, +- FIELD_PREP(CTRL_CLK_SEL, 0) | +- FIELD_PREP(CTRL_DATA_SEL, 0)); ++ snd_soc_component_update_bits(component, AIU_HDMI_CLK_DATA_CTRL, ++ AIU_HDMI_CLK_DATA_CTRL_CLK_SEL | ++ AIU_HDMI_CLK_DATA_CTRL_DATA_SEL, ++ ctrl); + +- /* Set the appropriate source */ +- snd_soc_component_update_bits(component, e->reg, +- CTRL_CLK_SEL | +- CTRL_DATA_SEL, +- FIELD_PREP(CTRL_CLK_SEL, mux) | +- FIELD_PREP(CTRL_DATA_SEL, mux)); ++ snd_soc_component_update_bits(component, AIU_CLK_CTRL_MORE, ++ AIU_CLK_CTRL_MORE_AMCLK, ++ more); + + snd_soc_dapm_mux_update_power(dapm, kcontrol, mux, e, NULL); + + return 1; + } + +-static SOC_ENUM_SINGLE_DECL(aiu_hdmi_ctrl_mux_enum, AIU_HDMI_CLK_DATA_CTRL, +- CTRL_DATA_SEL_SHIFT, +- aiu_codec_ctrl_mux_texts); ++static SOC_ENUM_SINGLE_VIRT_DECL(aiu_hdmi_ctrl_mux_enum, ++ aiu_codec_hdmi_ctrl_mux_texts); + + static const struct snd_kcontrol_new aiu_hdmi_ctrl_mux = + SOC_DAPM_ENUM_EXT("HDMI Source", aiu_hdmi_ctrl_mux_enum, +- snd_soc_dapm_get_enum_double, ++ aiu_codec_ctrl_mux_get_enum, + aiu_codec_ctrl_mux_put_enum); + + static const struct snd_soc_dapm_widget aiu_hdmi_ctrl_widgets[] = { +diff --git a/sound/soc/meson/aiu-encoder-i2s.c b/sound/soc/meson/aiu-encoder-i2s.c +index 111111111111..222222222222 100644 +--- a/sound/soc/meson/aiu-encoder-i2s.c ++++ b/sound/soc/meson/aiu-encoder-i2s.c +@@ -23,7 +23,6 @@ + #define AIU_CLK_CTRL_AOCLK_INVERT BIT(6) + #define AIU_CLK_CTRL_LRCLK_INVERT BIT(7) + #define AIU_CLK_CTRL_LRCLK_SKEW GENMASK(9, 8) +-#define AIU_CLK_CTRL_MORE_HDMI_AMCLK BIT(6) + #define AIU_CLK_CTRL_MORE_I2S_DIV GENMASK(5, 0) + #define AIU_CODEC_DAC_LRCLK_CTRL_DIV GENMASK(11, 0) + +@@ -176,11 +175,6 @@ static int aiu_encoder_i2s_set_clocks(struct snd_soc_component *component, + if (ret) + return ret; + +- /* Make sure amclk is used for HDMI i2s as well */ +- snd_soc_component_update_bits(component, AIU_CLK_CTRL_MORE, +- AIU_CLK_CTRL_MORE_HDMI_AMCLK, +- AIU_CLK_CTRL_MORE_HDMI_AMCLK); +- + return 0; + } + +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-meson-mmc-1-arm64-amlogic-mmc-meson-gx-Add-core-tx-rx-eMMC-SD-SD.patch b/patch/kernel/archive/meson64-6.13/general-meson-mmc-1-arm64-amlogic-mmc-meson-gx-Add-core-tx-rx-eMMC-SD-SD.patch new file mode 100644 index 000000000..a0894a748 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-meson-mmc-1-arm64-amlogic-mmc-meson-gx-Add-core-tx-rx-eMMC-SD-SD.patch @@ -0,0 +1,108 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Vyacheslav Bocharov +Date: Mon, 7 Nov 2022 14:19:08 +0100 +Subject: arm64: amlogic: mmc: meson-gx: Add core, tx, rx eMMC/SD/SDIO phase + clock settings from devicetree data + +The mmc driver has the same phase values for all meson platforms. However, +some platforms (and even some boards) require different values. This patch +transfers the values from the set in the code to the variables in the +device-tree file. + +Signed-off-by: Vyacheslav Bocharov +--- + drivers/mmc/host/meson-gx-mmc.c | 19 +++-- + include/dt-bindings/mmc/meson-gx-mmc.h | 35 ++++++++++ + 2 files changed, 48 insertions(+), 6 deletions(-) + +diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c +index 111111111111..222222222222 100644 +--- a/drivers/mmc/host/meson-gx-mmc.c ++++ b/drivers/mmc/host/meson-gx-mmc.c +@@ -27,6 +27,7 @@ + #include + #include + #include ++#include + + #define DRIVER_NAME "meson-gx-mmc" + +@@ -36,8 +37,6 @@ + #define CLK_CORE_PHASE_MASK GENMASK(9, 8) + #define CLK_TX_PHASE_MASK GENMASK(11, 10) + #define CLK_RX_PHASE_MASK GENMASK(13, 12) +-#define CLK_PHASE_0 0 +-#define CLK_PHASE_180 2 + #define CLK_V2_TX_DELAY_MASK GENMASK(19, 16) + #define CLK_V2_RX_DELAY_MASK GENMASK(23, 20) + #define CLK_V2_ALWAYS_ON BIT(24) +@@ -426,13 +425,21 @@ static int meson_mmc_clk_init(struct meson_host *host) + const char *mux_parent_names[MUX_CLK_NUM_PARENTS]; + const char *clk_parent[1]; + u32 clk_reg; +- ++ u32 phase[3]; // ++ ++ if (!(host->dev && host->dev->of_node) || (device_property_read_u32_array(host->dev, ++ "amlogic,mmc-phase", phase, 3) < 0)) { ++ dev_dbg(host->dev, "get amlogic,mmc-phase failed, use default phase settings\n"); ++ phase[0] = CLK_PHASE_180; ++ phase[1] = CLK_PHASE_0; ++ phase[2] = CLK_PHASE_0; ++ } + /* init SD_EMMC_CLOCK to sane defaults w/min clock rate */ + clk_reg = CLK_ALWAYS_ON(host); + clk_reg |= CLK_DIV_MASK; +- clk_reg |= FIELD_PREP(CLK_CORE_PHASE_MASK, CLK_PHASE_180); +- clk_reg |= FIELD_PREP(CLK_TX_PHASE_MASK, CLK_PHASE_0); +- clk_reg |= FIELD_PREP(CLK_RX_PHASE_MASK, CLK_PHASE_0); ++ clk_reg |= FIELD_PREP(CLK_CORE_PHASE_MASK, phase[0]); ++ clk_reg |= FIELD_PREP(CLK_TX_PHASE_MASK, phase[1]); ++ clk_reg |= FIELD_PREP(CLK_RX_PHASE_MASK, phase[2]); + if (host->mmc->caps & MMC_CAP_SDIO_IRQ) + clk_reg |= CLK_IRQ_SDIO_SLEEP(host); + writel(clk_reg, host->regs + SD_EMMC_CLOCK); +diff --git a/include/dt-bindings/mmc/meson-gx-mmc.h b/include/dt-bindings/mmc/meson-gx-mmc.h +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/include/dt-bindings/mmc/meson-gx-mmc.h +@@ -0,0 +1,35 @@ ++/* SPDX-License-Identifier: (GPL-2.0+ or MIT) */ ++/* ++ * Copyright (c) 2022 Vyacheslav Bocharov ++ * Author: Vyacheslav Bocharov ++ */ ++ ++#ifndef _DT_BINDINGS_MESON_GX_MMC_H ++#define _DT_BINDINGS_MESON_GX_MMC_H ++ ++/* ++ * Cfg_rx_phase: RX clock phase ++ * bits: 9:8 R/W ++ * default: 0 ++ * Recommended value: 0 ++ * ++ * Cfg_tx_phase: TX clock phase ++ * bits: 9:8 R/W ++ * default: 0 ++ * Recommended value: 2 ++ * ++ * Cfg_co_phase: Core clock phase ++ * bits: 9:8 R/W ++ * default: 0 ++ * Recommended value: 2 ++ * ++ * values: 0: 0 phase, 1: 90 phase, 2: 180 phase, 3: 270 phase. ++ */ ++ ++#define CLK_PHASE_0 0 ++#define CLK_PHASE_90 1 ++#define CLK_PHASE_180 2 ++#define CLK_PHASE_270 3 ++ ++ ++#endif +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-meson-mmc-2-arm64-amlogic-dts-meson-update-meson-axg-device-tree.patch b/patch/kernel/archive/meson64-6.13/general-meson-mmc-2-arm64-amlogic-dts-meson-update-meson-axg-device-tree.patch new file mode 100644 index 000000000..da5343474 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-meson-mmc-2-arm64-amlogic-dts-meson-update-meson-axg-device-tree.patch @@ -0,0 +1,44 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Vyacheslav Bocharov +Date: Mon, 7 Nov 2022 16:19:08 +0300 +Subject: arm64: amlogic: dts: meson: update meson-axg device-tree for new + core, tx, rx phase clock settings. + +Use phase 270 for core MMC clock on axg meson boards. + +Signed-off-by: Vyacheslav Bocharov +--- + arch/arm64/boot/dts/amlogic/meson-axg.dtsi | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi +@@ -13,6 +13,7 @@ + #include + #include + #include ++#include + + / { + compatible = "amlogic,meson-axg"; +@@ -1922,6 +1923,7 @@ sd_emmc_b: mmc@5000 { + <&clkc CLKID_SD_EMMC_B_CLK0>, + <&clkc CLKID_FCLK_DIV2>; + clock-names = "core", "clkin0", "clkin1"; ++ amlogic,mmc-phase = ; + resets = <&reset RESET_SD_EMMC_B>; + }; + +@@ -1935,6 +1937,7 @@ sd_emmc_c: mmc@7000 { + <&clkc CLKID_FCLK_DIV2>; + clock-names = "core", "clkin0", "clkin1"; + resets = <&reset RESET_SD_EMMC_C>; ++ amlogic,mmc-phase = ; + }; + + nfc: nand-controller@7800 { +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-meson-mmc-3-arm64-dts-docs-Update-mmc-meson-gx-documentation-for.patch b/patch/kernel/archive/meson64-6.13/general-meson-mmc-3-arm64-dts-docs-Update-mmc-meson-gx-documentation-for.patch new file mode 100644 index 000000000..2fc36e8ba --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-meson-mmc-3-arm64-dts-docs-Update-mmc-meson-gx-documentation-for.patch @@ -0,0 +1,51 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Vyacheslav Bocharov +Date: Thu, 10 Nov 2022 14:52:47 +0300 +Subject: arm64: dts: docs: Update mmc meson-gx documentation for new config + option amlogic,mmc-phase + +- amlogic,mmc-phases: 3-element array of clock phases for core, tx, rx +clock with values: + 0: CLK_PHASE_0 - 0 phase + 1: CLK_PHASE_90 - 90 phase + 2: CLK_PHASE_180 - 180 phase + 3: CLK_PHASE_270 - 270 phase +By default driver use value. + +Signed-off-by: Vyacheslav Bocharov +- rpardini: in 6.4, Documentation/devicetree/bindings/mmc/amlogic,meson-gx.txt is gone + and now replaced by Documentation/devicetree/bindings/mmc/amlogic,meson-gx-mmc.yaml +--- + Documentation/devicetree/bindings/mmc/amlogic,meson-gx-mmc.yaml | 11 ++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/Documentation/devicetree/bindings/mmc/amlogic,meson-gx-mmc.yaml b/Documentation/devicetree/bindings/mmc/amlogic,meson-gx-mmc.yaml +index 111111111111..222222222222 100644 +--- a/Documentation/devicetree/bindings/mmc/amlogic,meson-gx-mmc.yaml ++++ b/Documentation/devicetree/bindings/mmc/amlogic,meson-gx-mmc.yaml +@@ -54,6 +54,16 @@ properties: + power-domains: + maxItems: 1 + ++ amlogic,mmc-phases: ++ type: integer ++ description: | ++ 3-element array of clock phases for core, tx, rx clock with values: ++ 0: CLK_PHASE_0 - 0 phase ++ 1: CLK_PHASE_90 - 90 phase ++ 2: CLK_PHASE_180 - 180 phase ++ 3: CLK_PHASE_270 - 270 phase ++ By default driver use value. ++ + required: + - compatible + - reg +@@ -76,4 +86,5 @@ examples: + clock-names = "core", "clkin0", "clkin1"; + pinctrl-0 = <&emm_pins>; + resets = <&reset_mmc>; ++ amlogic,mmc-phases = ; + }; +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-meson-vdec-add-HEVC-decode-codec.patch b/patch/kernel/archive/meson64-6.13/general-meson-vdec-add-HEVC-decode-codec.patch new file mode 100644 index 000000000..065439470 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-meson-vdec-add-HEVC-decode-codec.patch @@ -0,0 +1,1608 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: benjamin545 +Date: Thu, 15 Jul 2021 17:08:42 -0400 +Subject: WIP: drivers: meson: vdec: add HEVC decode codec + +Unknown patch. From LibreELEC? +--- + drivers/staging/media/meson/vdec/Makefile | 2 +- + drivers/staging/media/meson/vdec/codec_hevc.c | 1440 ++++++++++ + drivers/staging/media/meson/vdec/codec_hevc.h | 13 + + drivers/staging/media/meson/vdec/esparser.c | 2 +- + drivers/staging/media/meson/vdec/hevc_regs.h | 1 + + drivers/staging/media/meson/vdec/vdec_platform.c | 49 + + 6 files changed, 1505 insertions(+), 2 deletions(-) + +diff --git a/drivers/staging/media/meson/vdec/Makefile b/drivers/staging/media/meson/vdec/Makefile +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/meson/vdec/Makefile ++++ b/drivers/staging/media/meson/vdec/Makefile +@@ -3,6 +3,6 @@ + + meson-vdec-objs = esparser.o vdec.o vdec_helpers.o vdec_platform.o + meson-vdec-objs += vdec_1.o vdec_hevc.o +-meson-vdec-objs += codec_mpeg12.o codec_h264.o codec_hevc_common.o codec_vp9.o ++meson-vdec-objs += codec_mpeg12.o codec_h264.o codec_hevc_common.o codec_vp9.o codec_hevc.o + + obj-$(CONFIG_VIDEO_MESON_VDEC) += meson-vdec.o +diff --git a/drivers/staging/media/meson/vdec/codec_hevc.c b/drivers/staging/media/meson/vdec/codec_hevc.c +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/drivers/staging/media/meson/vdec/codec_hevc.c +@@ -0,0 +1,1440 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * Copyright (C) 2018 Maxime Jourdan ++ * Copyright (C) 2015 Amlogic, Inc. All rights reserved. ++ */ ++ ++#include ++#include ++ ++#include "codec_hevc.h" ++#include "dos_regs.h" ++#include "hevc_regs.h" ++#include "vdec_helpers.h" ++#include "codec_hevc_common.h" ++ ++/* HEVC reg mapping */ ++#define HEVC_DEC_STATUS_REG HEVC_ASSIST_SCRATCH_0 ++ #define HEVC_ACTION_DONE 0xff ++#define HEVC_RPM_BUFFER HEVC_ASSIST_SCRATCH_1 ++#define HEVC_SHORT_TERM_RPS HEVC_ASSIST_SCRATCH_2 ++#define HEVC_VPS_BUFFER HEVC_ASSIST_SCRATCH_3 ++#define HEVC_SPS_BUFFER HEVC_ASSIST_SCRATCH_4 ++#define HEVC_PPS_BUFFER HEVC_ASSIST_SCRATCH_5 ++#define HEVC_SAO_UP HEVC_ASSIST_SCRATCH_6 ++#define HEVC_STREAM_SWAP_BUFFER HEVC_ASSIST_SCRATCH_7 ++#define H265_MMU_MAP_BUFFER HEVC_ASSIST_SCRATCH_7 ++#define HEVC_STREAM_SWAP_BUFFER2 HEVC_ASSIST_SCRATCH_8 ++#define HEVC_sao_mem_unit HEVC_ASSIST_SCRATCH_9 ++#define HEVC_SAO_ABV HEVC_ASSIST_SCRATCH_A ++#define HEVC_sao_vb_size HEVC_ASSIST_SCRATCH_B ++#define HEVC_SAO_VB HEVC_ASSIST_SCRATCH_C ++#define HEVC_SCALELUT HEVC_ASSIST_SCRATCH_D ++#define HEVC_WAIT_FLAG HEVC_ASSIST_SCRATCH_E ++#define RPM_CMD_REG HEVC_ASSIST_SCRATCH_F ++#define LMEM_DUMP_ADR HEVC_ASSIST_SCRATCH_F ++#define DEBUG_REG1 HEVC_ASSIST_SCRATCH_G ++#define HEVC_DECODE_MODE2 HEVC_ASSIST_SCRATCH_H ++#define NAL_SEARCH_CTL HEVC_ASSIST_SCRATCH_I ++#define HEVC_DECODE_MODE HEVC_ASSIST_SCRATCH_J ++ #define DECODE_MODE_SINGLE 0 ++#define DECODE_STOP_POS HEVC_ASSIST_SCRATCH_K ++#define HEVC_AUX_ADR HEVC_ASSIST_SCRATCH_L ++#define HEVC_AUX_DATA_SIZE HEVC_ASSIST_SCRATCH_M ++#define HEVC_DECODE_SIZE HEVC_ASSIST_SCRATCH_N ++ ++#define AMRISC_MAIN_REQ 0x04 ++ ++/* HEVC Constants */ ++#define MAX_REF_PIC_NUM 24 ++#define MAX_REF_ACTIVE 16 ++#define MAX_TILE_COL_NUM 10 ++#define MAX_TILE_ROW_NUM 20 ++#define MAX_SLICE_NUM 800 ++#define INVALID_POC 0x80000000 ++ ++/* HEVC Workspace layout */ ++#define MPRED_MV_BUF_SIZE 0x120000 ++ ++#define IPP_SIZE 0x4000 ++#define SAO_ABV_SIZE 0x30000 ++#define SAO_VB_SIZE 0x30000 ++#define SH_TM_RPS_SIZE 0x800 ++#define VPS_SIZE 0x800 ++#define SPS_SIZE 0x800 ++#define PPS_SIZE 0x2000 ++#define SAO_UP_SIZE 0x2800 ++#define SWAP_BUF_SIZE 0x800 ++#define SWAP_BUF2_SIZE 0x800 ++#define SCALELUT_SIZE 0x8000 ++#define DBLK_PARA_SIZE 0x20000 ++#define DBLK_DATA_SIZE 0x80000 ++#define DBLK_DATA2_SIZE 0x80000 ++#define MMU_VBH_SIZE 0x5000 ++#define MPRED_ABV_SIZE 0x8000 ++#define MPRED_MV_SIZE (MPRED_MV_BUF_SIZE * MAX_REF_PIC_NUM) ++#define RPM_BUF_SIZE 0x100 ++#define LMEM_SIZE 0xA00 ++ ++#define IPP_OFFSET 0x00 ++#define SAO_ABV_OFFSET (IPP_OFFSET + IPP_SIZE) ++#define SAO_VB_OFFSET (SAO_ABV_OFFSET + SAO_ABV_SIZE) ++#define SH_TM_RPS_OFFSET (SAO_VB_OFFSET + SAO_VB_SIZE) ++#define VPS_OFFSET (SH_TM_RPS_OFFSET + SH_TM_RPS_SIZE) ++#define SPS_OFFSET (VPS_OFFSET + VPS_SIZE) ++#define PPS_OFFSET (SPS_OFFSET + SPS_SIZE) ++#define SAO_UP_OFFSET (PPS_OFFSET + PPS_SIZE) ++#define SWAP_BUF_OFFSET (SAO_UP_OFFSET + SAO_UP_SIZE) ++#define SWAP_BUF2_OFFSET (SWAP_BUF_OFFSET + SWAP_BUF_SIZE) ++#define SCALELUT_OFFSET (SWAP_BUF2_OFFSET + SWAP_BUF2_SIZE) ++#define DBLK_PARA_OFFSET (SCALELUT_OFFSET + SCALELUT_SIZE) ++#define DBLK_DATA_OFFSET (DBLK_PARA_OFFSET + DBLK_PARA_SIZE) ++#define DBLK_DATA2_OFFSET (DBLK_DATA_OFFSET + DBLK_DATA_SIZE) ++#define MMU_VBH_OFFSET (DBLK_DATA2_OFFSET + DBLK_DATA2_SIZE) ++#define MPRED_ABV_OFFSET (MMU_VBH_OFFSET + MMU_VBH_SIZE) ++#define MPRED_MV_OFFSET (MPRED_ABV_OFFSET + MPRED_ABV_SIZE) ++#define RPM_OFFSET (MPRED_MV_OFFSET + MPRED_MV_SIZE) ++#define LMEM_OFFSET (RPM_OFFSET + RPM_BUF_SIZE) ++ ++/* ISR decode status */ ++#define HEVC_DEC_IDLE 0x0 ++#define HEVC_NAL_UNIT_VPS 0x1 ++#define HEVC_NAL_UNIT_SPS 0x2 ++#define HEVC_NAL_UNIT_PPS 0x3 ++#define HEVC_NAL_UNIT_CODED_SLICE_SEGMENT 0x4 ++#define HEVC_CODED_SLICE_SEGMENT_DAT 0x5 ++#define HEVC_SLICE_DECODING 0x6 ++#define HEVC_NAL_UNIT_SEI 0x7 ++#define HEVC_SLICE_SEGMENT_DONE 0x8 ++#define HEVC_NAL_SEARCH_DONE 0x9 ++#define HEVC_DECPIC_DATA_DONE 0xa ++#define HEVC_DECPIC_DATA_ERROR 0xb ++#define HEVC_SEI_DAT 0xc ++#define HEVC_SEI_DAT_DONE 0xd ++ ++/* RPM misc_flag0 */ ++#define PCM_LOOP_FILTER_DISABLED_FLAG_BIT 0 ++#define PCM_ENABLE_FLAG_BIT 1 ++#define LOOP_FILER_ACROSS_TILES_ENABLED_FLAG_BIT 2 ++#define PPS_LOOP_FILTER_ACROSS_SLICES_ENABLED_FLAG_BIT 3 ++#define DEBLOCKING_FILTER_OVERRIDE_ENABLED_FLAG_BIT 4 ++#define PPS_DEBLOCKING_FILTER_DISABLED_FLAG_BIT 5 ++#define DEBLOCKING_FILTER_OVERRIDE_FLAG_BIT 6 ++#define SLICE_DEBLOCKING_FILTER_DISABLED_FLAG_BIT 7 ++#define SLICE_SAO_LUMA_FLAG_BIT 8 ++#define SLICE_SAO_CHROMA_FLAG_BIT 9 ++#define SLICE_LOOP_FILTER_ACROSS_SLICES_ENABLED_FLAG_BIT 10 ++ ++/* Constants for HEVC_MPRED_CTRL1 */ ++#define AMVP_MAX_NUM_CANDS_MEM 3 ++#define AMVP_MAX_NUM_CANDS 2 ++#define NUM_CHROMA_MODE 5 ++#define DM_CHROMA_IDX 36 ++ ++/* Buffer sizes */ ++#define SIZE_WORKSPACE ALIGN(LMEM_OFFSET + LMEM_SIZE, 64 * SZ_1K) ++#define SIZE_AUX (SZ_1K * 16) ++#define SIZE_FRAME_MMU (0x1200 * 4) ++#define RPM_SIZE 0x80 ++#define RPS_USED_BIT 14 ++ ++/* Data received from the HW in this form, do not rearrange */ ++union rpm_param { ++ struct { ++ u16 data[RPM_SIZE]; ++ } l; ++ struct { ++ u16 CUR_RPS[MAX_REF_ACTIVE]; ++ u16 num_ref_idx_l0_active; ++ u16 num_ref_idx_l1_active; ++ u16 slice_type; ++ u16 slice_temporal_mvp_enable_flag; ++ u16 dependent_slice_segment_flag; ++ u16 slice_segment_address; ++ u16 num_title_rows_minus1; ++ u16 pic_width_in_luma_samples; ++ u16 pic_height_in_luma_samples; ++ u16 log2_min_coding_block_size_minus3; ++ u16 log2_diff_max_min_coding_block_size; ++ u16 log2_max_pic_order_cnt_lsb_minus4; ++ u16 POClsb; ++ u16 collocated_from_l0_flag; ++ u16 collocated_ref_idx; ++ u16 log2_parallel_merge_level; ++ u16 five_minus_max_num_merge_cand; ++ u16 sps_num_reorder_pics_0; ++ u16 modification_flag; ++ u16 tiles_flags; ++ u16 num_tile_columns_minus1; ++ u16 num_tile_rows_minus1; ++ u16 tile_width[8]; ++ u16 tile_height[8]; ++ u16 misc_flag0; ++ u16 pps_beta_offset_div2; ++ u16 pps_tc_offset_div2; ++ u16 slice_beta_offset_div2; ++ u16 slice_tc_offset_div2; ++ u16 pps_cb_qp_offset; ++ u16 pps_cr_qp_offset; ++ u16 first_slice_segment_in_pic_flag; ++ u16 m_temporalId; ++ u16 m_nalUnitType; ++ u16 vui_num_units_in_tick_hi; ++ u16 vui_num_units_in_tick_lo; ++ u16 vui_time_scale_hi; ++ u16 vui_time_scale_lo; ++ u16 bit_depth; ++ u16 profile_etc; ++ u16 sei_frame_field_info; ++ u16 video_signal_type; ++ u16 modification_list[0x20]; ++ u16 conformance_window_flag; ++ u16 conf_win_left_offset; ++ u16 conf_win_right_offset; ++ u16 conf_win_top_offset; ++ u16 conf_win_bottom_offset; ++ u16 chroma_format_idc; ++ u16 color_description; ++ u16 aspect_ratio_idc; ++ u16 sar_width; ++ u16 sar_height; ++ } p; ++}; ++ ++enum nal_unit_type { ++ NAL_UNIT_CODED_SLICE_BLA = 16, ++ NAL_UNIT_CODED_SLICE_BLANT = 17, ++ NAL_UNIT_CODED_SLICE_BLA_N_LP = 18, ++ NAL_UNIT_CODED_SLICE_IDR = 19, ++ NAL_UNIT_CODED_SLICE_IDR_N_LP = 20, ++}; ++ ++enum slice_type { ++ B_SLICE = 0, ++ P_SLICE = 1, ++ I_SLICE = 2, ++}; ++ ++/* A frame being decoded */ ++struct hevc_frame { ++ struct list_head list; ++ struct vb2_v4l2_buffer *vbuf; ++ u32 offset; ++ u32 poc; ++ ++ int referenced; ++ u32 num_reorder_pic; ++ ++ u32 cur_slice_idx; ++ u32 cur_slice_type; ++ ++ /* 2 lists (L0/L1) ; 800 slices ; 16 refs */ ++ u32 ref_poc_list[2][MAX_SLICE_NUM][MAX_REF_ACTIVE]; ++ u32 ref_num[2]; ++}; ++ ++struct codec_hevc { ++ struct mutex lock; ++ ++ /* Common part of the HEVC decoder */ ++ struct codec_hevc_common common; ++ ++ /* Buffer for the HEVC Workspace */ ++ void *workspace_vaddr; ++ dma_addr_t workspace_paddr; ++ ++ /* AUX buffer */ ++ void *aux_vaddr; ++ dma_addr_t aux_paddr; ++ ++ /* Contains many information parsed from the bitstream */ ++ union rpm_param rpm_param; ++ ++ /* Information computed from the RPM */ ++ u32 lcu_size; // Largest Coding Unit ++ u32 lcu_x_num; ++ u32 lcu_y_num; ++ u32 lcu_total; ++ ++ /* Current Frame being handled */ ++ struct hevc_frame *cur_frame; ++ u32 curr_poc; ++ /* Collocated Reference Picture */ ++ struct hevc_frame *col_frame; ++ u32 col_poc; ++ ++ /* All ref frames used by the HW at a given time */ ++ struct list_head ref_frames_list; ++ u32 frames_num; ++ ++ /* Coded resolution reported by the hardware */ ++ u32 width, height; ++ /* Resolution minus the conformance window offsets */ ++ u32 dst_width, dst_height; ++ ++ u32 prev_tid0_poc; ++ u32 slice_segment_addr; ++ u32 slice_addr; ++ u32 ldc_flag; ++ ++ /* Whether we detected the bitstream as 10-bit */ ++ int is_10bit; ++}; ++ ++static u32 codec_hevc_num_pending_bufs(struct amvdec_session *sess) ++{ ++ struct codec_hevc *hevc; ++ u32 ret; ++ ++ hevc = sess->priv; ++ if (!hevc) ++ return 0; ++ ++ mutex_lock(&hevc->lock); ++ ret = hevc->frames_num; ++ mutex_unlock(&hevc->lock); ++ ++ return ret; ++} ++ ++/* Update the L0 and L1 reference lists for a given frame */ ++static void codec_hevc_update_frame_refs(struct amvdec_session *sess, ++ struct hevc_frame *frame) ++{ ++ struct codec_hevc *hevc = sess->priv; ++ union rpm_param *params = &hevc->rpm_param; ++ int num_ref_idx_l0_active = ++ (params->p.num_ref_idx_l0_active > MAX_REF_ACTIVE) ? ++ MAX_REF_ACTIVE : params->p.num_ref_idx_l0_active; ++ int num_ref_idx_l1_active = ++ (params->p.num_ref_idx_l1_active > MAX_REF_ACTIVE) ? ++ MAX_REF_ACTIVE : params->p.num_ref_idx_l1_active; ++ int ref_picset0[MAX_REF_ACTIVE] = { 0 }; ++ int ref_picset1[MAX_REF_ACTIVE] = { 0 }; ++ u16 *mod_list = params->p.modification_list; ++ int num_neg = 0; ++ int num_pos = 0; ++ int total_num; ++ int i; ++ ++ for (i = 0; i < MAX_REF_ACTIVE; i++) { ++ frame->ref_poc_list[0][frame->cur_slice_idx][i] = 0; ++ frame->ref_poc_list[1][frame->cur_slice_idx][i] = 0; ++ } ++ ++ for (i = 0; i < MAX_REF_ACTIVE; i++) { ++ u16 cur_rps = params->p.CUR_RPS[i]; ++ int delt = cur_rps & ((1 << (RPS_USED_BIT - 1)) - 1); ++ ++ if (cur_rps & 0x8000) ++ break; ++ ++ if (!((cur_rps >> RPS_USED_BIT) & 1)) ++ continue; ++ ++ if ((cur_rps >> (RPS_USED_BIT - 1)) & 1) { ++ ref_picset0[num_neg] = ++ frame->poc - ((1 << (RPS_USED_BIT - 1)) - delt); ++ num_neg++; ++ } else { ++ ref_picset1[num_pos] = frame->poc + delt; ++ num_pos++; ++ } ++ } ++ ++ total_num = num_neg + num_pos; ++ ++ if (total_num <= 0) ++ goto end; ++ ++ for (i = 0; i < num_ref_idx_l0_active; i++) { ++ int cidx; ++ if (params->p.modification_flag & 0x1) ++ cidx = mod_list[i]; ++ else ++ cidx = i % total_num; ++ ++ frame->ref_poc_list[0][frame->cur_slice_idx][i] = ++ cidx >= num_neg ? ref_picset1[cidx - num_neg] : ++ ref_picset0[cidx]; ++ } ++ ++ if (params->p.slice_type != B_SLICE) ++ goto end; ++ ++ if (params->p.modification_flag & 0x2) { ++ for (i = 0; i < num_ref_idx_l1_active; i++) { ++ int cidx; ++ if (params->p.modification_flag & 0x1) ++ cidx = mod_list[num_ref_idx_l0_active + i]; ++ else ++ cidx = mod_list[i]; ++ ++ frame->ref_poc_list[1][frame->cur_slice_idx][i] = ++ (cidx >= num_pos) ? ref_picset0[cidx - num_pos] ++ : ref_picset1[cidx]; ++ } ++ } else { ++ for (i = 0; i < num_ref_idx_l1_active; i++) { ++ int cidx = i % total_num; ++ frame->ref_poc_list[1][frame->cur_slice_idx][i] = ++ cidx >= num_pos ? ref_picset0[cidx - num_pos] : ++ ref_picset1[cidx]; ++ } ++ } ++ ++end: ++ frame->ref_num[0] = num_ref_idx_l0_active; ++ frame->ref_num[1] = num_ref_idx_l1_active; ++ ++ dev_dbg(sess->core->dev, ++ "Frame %u; slice %u; slice_type %u; num_l0 %u; num_l1 %u\n", ++ frame->poc, frame->cur_slice_idx, params->p.slice_type, ++ frame->ref_num[0], frame->ref_num[1]); ++} ++ ++static void codec_hevc_update_ldc_flag(struct codec_hevc *hevc) ++{ ++ struct hevc_frame *frame = hevc->cur_frame; ++ u32 slice_type = frame->cur_slice_type; ++ u32 slice_idx = frame->cur_slice_idx; ++ int i; ++ ++ hevc->ldc_flag = 0; ++ ++ if (slice_type == I_SLICE) ++ return; ++ ++ hevc->ldc_flag = 1; ++ for (i = 0; (i < frame->ref_num[0]) && hevc->ldc_flag; i++) { ++ if (frame->ref_poc_list[0][slice_idx][i] > frame->poc) { ++ hevc->ldc_flag = 0; ++ break; ++ } ++ } ++ ++ if (slice_type == P_SLICE) ++ return; ++ ++ for (i = 0; (i < frame->ref_num[1]) && hevc->ldc_flag; i++) { ++ if (frame->ref_poc_list[1][slice_idx][i] > frame->poc) { ++ hevc->ldc_flag = 0; ++ break; ++ } ++ } ++} ++ ++/* Tag "old" frames that are no longer referenced */ ++static void codec_hevc_update_referenced(struct codec_hevc *hevc) ++{ ++ union rpm_param *param = &hevc->rpm_param; ++ struct hevc_frame *frame; ++ int i; ++ u32 curr_poc = hevc->curr_poc; ++ ++ list_for_each_entry(frame, &hevc->ref_frames_list, list) { ++ int is_referenced = 0; ++ u32 poc_tmp; ++ ++ if (!frame->referenced) ++ continue; ++ ++ for (i = 0; i < MAX_REF_ACTIVE; i++) { ++ int delt; ++ if (param->p.CUR_RPS[i] & 0x8000) ++ break; ++ ++ delt = param->p.CUR_RPS[i] & ++ ((1 << (RPS_USED_BIT - 1)) - 1); ++ if (param->p.CUR_RPS[i] & (1 << (RPS_USED_BIT - 1))) { ++ poc_tmp = curr_poc - ++ ((1 << (RPS_USED_BIT - 1)) - delt); ++ } else ++ poc_tmp = curr_poc + delt; ++ if (poc_tmp == frame->poc) { ++ is_referenced = 1; ++ break; ++ } ++ } ++ ++ frame->referenced = is_referenced; ++ } ++} ++ ++static struct hevc_frame * ++codec_hevc_get_lowest_poc_frame(struct codec_hevc *hevc) ++{ ++ struct hevc_frame *tmp, *ret = NULL; ++ u32 poc = INT_MAX; ++ ++ list_for_each_entry(tmp, &hevc->ref_frames_list, list) { ++ if (tmp->poc < poc) { ++ ret = tmp; ++ poc = tmp->poc; ++ } ++ } ++ ++ return ret; ++} ++ ++/* Try to output as many frames as possible */ ++static void codec_hevc_output_frames(struct amvdec_session *sess) ++{ ++ struct hevc_frame *tmp; ++ struct codec_hevc *hevc = sess->priv; ++ ++ while ((tmp = codec_hevc_get_lowest_poc_frame(hevc))) { ++ if (hevc->curr_poc && ++ (tmp->referenced || ++ tmp->num_reorder_pic >= hevc->frames_num)) ++ break; ++ ++ dev_dbg(sess->core->dev, "DONE frame poc %u; vbuf %u\n", ++ tmp->poc, tmp->vbuf->vb2_buf.index); ++ amvdec_dst_buf_done_offset(sess, tmp->vbuf, tmp->offset, ++ V4L2_FIELD_NONE, false); ++ list_del(&tmp->list); ++ kfree(tmp); ++ hevc->frames_num--; ++ } ++} ++ ++ ++static int ++codec_hevc_setup_workspace(struct amvdec_session *sess, ++ struct codec_hevc *hevc) ++{ ++ struct amvdec_core *core = sess->core; ++ u32 revision = core->platform->revision; ++ dma_addr_t wkaddr; ++ ++ /* Allocate some memory for the HEVC decoder's state */ ++ hevc->workspace_vaddr = dma_alloc_coherent(core->dev, SIZE_WORKSPACE, ++ &wkaddr, GFP_KERNEL); ++ if (!hevc->workspace_vaddr) ++ return -ENOMEM; ++ ++ hevc->workspace_paddr = wkaddr; ++ ++ amvdec_write_dos(core, HEVCD_IPP_LINEBUFF_BASE, wkaddr + IPP_OFFSET); ++ amvdec_write_dos(core, HEVC_RPM_BUFFER, wkaddr + RPM_OFFSET); ++ amvdec_write_dos(core, HEVC_SHORT_TERM_RPS, wkaddr + SH_TM_RPS_OFFSET); ++ amvdec_write_dos(core, HEVC_VPS_BUFFER, wkaddr + VPS_OFFSET); ++ amvdec_write_dos(core, HEVC_SPS_BUFFER, wkaddr + SPS_OFFSET); ++ amvdec_write_dos(core, HEVC_PPS_BUFFER, wkaddr + PPS_OFFSET); ++ amvdec_write_dos(core, HEVC_SAO_UP, wkaddr + SAO_UP_OFFSET); ++ ++ if (codec_hevc_use_mmu(revision, sess->pixfmt_cap, hevc->is_10bit)) { ++ amvdec_write_dos(core, HEVC_SAO_MMU_VH0_ADDR, ++ wkaddr + MMU_VBH_OFFSET); ++ amvdec_write_dos(core, HEVC_SAO_MMU_VH1_ADDR, ++ wkaddr + MMU_VBH_OFFSET + (MMU_VBH_SIZE / 2)); ++ ++ if (revision >= VDEC_REVISION_G12A) ++ amvdec_write_dos(core, HEVC_ASSIST_MMU_MAP_ADDR, ++ hevc->common.mmu_map_paddr); ++ else ++ amvdec_write_dos(core, H265_MMU_MAP_BUFFER, ++ hevc->common.mmu_map_paddr); ++ } else if (revision < VDEC_REVISION_G12A) { ++ amvdec_write_dos(core, HEVC_STREAM_SWAP_BUFFER, ++ wkaddr + SWAP_BUF_OFFSET); ++ amvdec_write_dos(core, HEVC_STREAM_SWAP_BUFFER2, ++ wkaddr + SWAP_BUF2_OFFSET); ++ } ++ ++ amvdec_write_dos(core, HEVC_SCALELUT, wkaddr + SCALELUT_OFFSET); ++ amvdec_write_dos(core, HEVC_DBLK_CFG4, wkaddr + DBLK_PARA_OFFSET); ++ amvdec_write_dos(core, HEVC_DBLK_CFG5, wkaddr + DBLK_DATA_OFFSET); ++ if (revision >= VDEC_REVISION_G12A) ++ amvdec_write_dos(core, HEVC_DBLK_CFGE, ++ wkaddr + DBLK_DATA2_OFFSET); ++ ++ amvdec_write_dos(core, LMEM_DUMP_ADR, wkaddr + LMEM_OFFSET); ++ ++ return 0; ++} ++ ++static int codec_hevc_start(struct amvdec_session *sess) ++{ ++ struct amvdec_core *core = sess->core; ++ struct codec_hevc *hevc; ++ u32 val; ++ int i; ++ int ret; ++ ++ hevc = kzalloc(sizeof(*hevc), GFP_KERNEL); ++ if (!hevc) ++ return -ENOMEM; ++ ++ INIT_LIST_HEAD(&hevc->ref_frames_list); ++ hevc->curr_poc = INVALID_POC; ++ ++ ret = codec_hevc_setup_workspace(sess, hevc); ++ if (ret) ++ goto free_hevc; ++ ++ val = BIT(0); /* stream_fetch_enable */ ++ if (core->platform->revision >= VDEC_REVISION_G12A) ++ val |= (0xf << 25); /* arwlen_axi_max */ ++ amvdec_write_dos_bits(core, HEVC_STREAM_CONTROL, val); ++ ++ val = amvdec_read_dos(core, HEVC_PARSER_INT_CONTROL) & 0x03ffffff; ++ val |= (3 << 29) | BIT(27) | BIT(24) | BIT(22) | BIT(7) | BIT(4) | ++ BIT(0); ++ amvdec_write_dos(core, HEVC_PARSER_INT_CONTROL, val); ++ amvdec_write_dos_bits(core, HEVC_SHIFT_STATUS, BIT(1) | BIT(0)); ++ amvdec_write_dos(core, HEVC_SHIFT_CONTROL, ++ (3 << 6) | BIT(5) | BIT(2) | BIT(0)); ++ amvdec_write_dos(core, HEVC_CABAC_CONTROL, 1); ++ amvdec_write_dos(core, HEVC_PARSER_CORE_CONTROL, 1); ++ amvdec_write_dos(core, HEVC_DEC_STATUS_REG, 0); ++ ++ amvdec_write_dos(core, HEVC_IQIT_SCALELUT_WR_ADDR, 0); ++ for (i = 0; i < 1024; ++i) ++ amvdec_write_dos(core, HEVC_IQIT_SCALELUT_DATA, 0); ++ ++ amvdec_write_dos(core, HEVC_DECODE_SIZE, 0); ++ ++ amvdec_write_dos(core, HEVC_PARSER_CMD_WRITE, BIT(16)); ++ for (i = 0; i < ARRAY_SIZE(vdec_hevc_parser_cmd); ++i) ++ amvdec_write_dos(core, HEVC_PARSER_CMD_WRITE, ++ vdec_hevc_parser_cmd[i]); ++ ++ amvdec_write_dos(core, HEVC_PARSER_CMD_SKIP_0, PARSER_CMD_SKIP_CFG_0); ++ amvdec_write_dos(core, HEVC_PARSER_CMD_SKIP_1, PARSER_CMD_SKIP_CFG_1); ++ amvdec_write_dos(core, HEVC_PARSER_CMD_SKIP_2, PARSER_CMD_SKIP_CFG_2); ++ amvdec_write_dos(core, HEVC_PARSER_IF_CONTROL, ++ BIT(5) | BIT(2) | BIT(0)); ++ ++ amvdec_write_dos(core, HEVCD_IPP_TOP_CNTL, BIT(0)); ++ amvdec_write_dos(core, HEVCD_IPP_TOP_CNTL, BIT(1)); ++ ++ amvdec_write_dos(core, HEVC_WAIT_FLAG, 1); ++ ++ /* clear mailbox interrupt */ ++ amvdec_write_dos(core, HEVC_ASSIST_MBOX1_CLR_REG, 1); ++ /* enable mailbox interrupt */ ++ amvdec_write_dos(core, HEVC_ASSIST_MBOX1_MASK, 1); ++ /* disable PSCALE for hardware sharing */ ++ amvdec_write_dos(core, HEVC_PSCALE_CTRL, 0); ++ /* Let the uCode do all the parsing */ ++ amvdec_write_dos(core, NAL_SEARCH_CTL, 0xc); ++ ++ amvdec_write_dos(core, DECODE_STOP_POS, 0); ++ amvdec_write_dos(core, HEVC_DECODE_MODE, DECODE_MODE_SINGLE); ++ amvdec_write_dos(core, HEVC_DECODE_MODE2, 0); ++ ++ /* AUX buffers */ ++ hevc->aux_vaddr = dma_alloc_coherent(core->dev, SIZE_AUX, ++ &hevc->aux_paddr, GFP_KERNEL); ++ if (!hevc->aux_vaddr) { ++ dev_err(core->dev, "Failed to request HEVC AUX\n"); ++ ret = -ENOMEM; ++ goto free_hevc; ++ } ++ ++ amvdec_write_dos(core, HEVC_AUX_ADR, hevc->aux_paddr); ++ amvdec_write_dos(core, HEVC_AUX_DATA_SIZE, ++ (((SIZE_AUX) >> 4) << 16) | 0); ++ mutex_init(&hevc->lock); ++ sess->priv = hevc; ++ ++ return 0; ++ ++free_hevc: ++ kfree(hevc); ++ return ret; ++} ++ ++static void codec_hevc_flush_output(struct amvdec_session *sess) ++{ ++ struct codec_hevc *hevc = sess->priv; ++ struct hevc_frame *tmp; ++ ++ while (!list_empty(&hevc->ref_frames_list)) { ++ tmp = codec_hevc_get_lowest_poc_frame(hevc); ++ amvdec_dst_buf_done(sess, tmp->vbuf, V4L2_FIELD_NONE); ++ list_del(&tmp->list); ++ kfree(tmp); ++ hevc->frames_num--; ++ } ++} ++ ++static int codec_hevc_stop(struct amvdec_session *sess) ++{ ++ struct codec_hevc *hevc = sess->priv; ++ struct amvdec_core *core = sess->core; ++ ++ mutex_lock(&hevc->lock); ++ codec_hevc_flush_output(sess); ++ ++ if (hevc->workspace_vaddr) ++ dma_free_coherent(core->dev, SIZE_WORKSPACE, ++ hevc->workspace_vaddr, ++ hevc->workspace_paddr); ++ ++ if (hevc->aux_vaddr) ++ dma_free_coherent(core->dev, SIZE_AUX, ++ hevc->aux_vaddr, hevc->aux_paddr); ++ ++ codec_hevc_free_fbc_buffers(sess, &hevc->common); ++ mutex_unlock(&hevc->lock); ++ mutex_destroy(&hevc->lock); ++ ++ return 0; ++} ++ ++static struct hevc_frame * ++codec_hevc_get_frame_by_poc(struct codec_hevc *hevc, u32 poc) ++{ ++ struct hevc_frame *tmp; ++ ++ list_for_each_entry(tmp, &hevc->ref_frames_list, list) { ++ if (tmp->poc == poc) ++ return tmp; ++ } ++ ++ return NULL; ++} ++ ++static struct hevc_frame * ++codec_hevc_prepare_new_frame(struct amvdec_session *sess) ++{ ++ struct amvdec_core *core = sess->core; ++ struct hevc_frame *new_frame = NULL; ++ struct codec_hevc *hevc = sess->priv; ++ struct vb2_v4l2_buffer *vbuf; ++ union rpm_param *params = &hevc->rpm_param; ++ ++ new_frame = kzalloc(sizeof(*new_frame), GFP_KERNEL); ++ if (!new_frame) ++ return NULL; ++ ++ vbuf = v4l2_m2m_dst_buf_remove(sess->m2m_ctx); ++ if (!vbuf) { ++ dev_err(sess->core->dev, "No dst buffer available\n"); ++ return NULL; ++ } ++ ++ new_frame->vbuf = vbuf; ++ new_frame->referenced = 1; ++ new_frame->poc = hevc->curr_poc; ++ new_frame->cur_slice_type = params->p.slice_type; ++ new_frame->num_reorder_pic = params->p.sps_num_reorder_pics_0; ++ new_frame->offset = amvdec_read_dos(core, HEVC_SHIFT_BYTE_COUNT); ++ ++ list_add_tail(&new_frame->list, &hevc->ref_frames_list); ++ hevc->frames_num++; ++ ++ return new_frame; ++} ++ ++static void ++codec_hevc_set_sao(struct amvdec_session *sess, struct hevc_frame *frame) ++{ ++ struct amvdec_core *core = sess->core; ++ struct codec_hevc *hevc = sess->priv; ++ struct vb2_buffer *vb = &frame->vbuf->vb2_buf; ++ union rpm_param *param = &hevc->rpm_param; ++ u32 pic_height_cu = ++ (hevc->height + hevc->lcu_size - 1) / hevc->lcu_size; ++ u32 sao_mem_unit = (hevc->lcu_size == 16 ? 9 : ++ hevc->lcu_size == 32 ? 14 : 24) << 4; ++ u32 sao_vb_size = (sao_mem_unit + (2 << 4)) * pic_height_cu; ++ u32 misc_flag0 = param->p.misc_flag0; ++ dma_addr_t buf_y_paddr; ++ dma_addr_t buf_u_v_paddr; ++ u32 slice_deblocking_filter_disabled_flag; ++ u32 val, val_2; ++ ++ val = (amvdec_read_dos(core, HEVC_SAO_CTRL0) & ~0xf) | ++ ilog2(hevc->lcu_size); ++ amvdec_write_dos(core, HEVC_SAO_CTRL0, val); ++ ++ amvdec_write_dos(core, HEVC_SAO_PIC_SIZE, ++ hevc->width | (hevc->height << 16)); ++ amvdec_write_dos(core, HEVC_SAO_PIC_SIZE_LCU, ++ (hevc->lcu_x_num - 1) | (hevc->lcu_y_num - 1) << 16); ++ ++ if (codec_hevc_use_downsample(sess->pixfmt_cap, hevc->is_10bit) || ++ codec_hevc_use_mmu(core->platform->revision, sess->pixfmt_cap, ++ hevc->is_10bit)) ++ buf_y_paddr = ++ hevc->common.fbc_buffer_paddr[vb->index]; ++ else ++ buf_y_paddr = ++ vb2_dma_contig_plane_dma_addr(vb, 0); ++ ++ if (codec_hevc_use_fbc(sess->pixfmt_cap, hevc->is_10bit)) { ++ val = amvdec_read_dos(core, HEVC_SAO_CTRL5) & ~0xff0000; ++ amvdec_write_dos(core, HEVC_SAO_CTRL5, val); ++ amvdec_write_dos(core, HEVC_CM_BODY_START_ADDR, buf_y_paddr); ++ } ++ ++ if (sess->pixfmt_cap == V4L2_PIX_FMT_NV12M) { ++ buf_y_paddr = ++ vb2_dma_contig_plane_dma_addr(vb, 0); ++ buf_u_v_paddr = ++ vb2_dma_contig_plane_dma_addr(vb, 1); ++ amvdec_write_dos(core, HEVC_SAO_Y_START_ADDR, buf_y_paddr); ++ amvdec_write_dos(core, HEVC_SAO_C_START_ADDR, buf_u_v_paddr); ++ amvdec_write_dos(core, HEVC_SAO_Y_WPTR, buf_y_paddr); ++ amvdec_write_dos(core, HEVC_SAO_C_WPTR, buf_u_v_paddr); ++ } ++ ++ if (codec_hevc_use_mmu(core->platform->revision, sess->pixfmt_cap, ++ hevc->is_10bit)) { ++ dma_addr_t header_adr = vb2_dma_contig_plane_dma_addr(vb, 0); ++ if (codec_hevc_use_downsample(sess->pixfmt_cap, hevc->is_10bit)) ++ header_adr = hevc->common.mmu_header_paddr[vb->index]; ++ amvdec_write_dos(core, HEVC_CM_HEADER_START_ADDR, header_adr); ++ /* use HEVC_CM_HEADER_START_ADDR */ ++ amvdec_write_dos_bits(core, HEVC_SAO_CTRL5, BIT(10)); ++ amvdec_write_dos_bits(core, HEVC_SAO_CTRL9, BIT(0)); ++ } ++ ++ amvdec_write_dos(core, HEVC_SAO_Y_LENGTH, ++ amvdec_get_output_size(sess)); ++ amvdec_write_dos(core, HEVC_SAO_C_LENGTH, ++ (amvdec_get_output_size(sess) / 2)); ++ ++ if (frame->cur_slice_idx == 0) { ++ if (core->platform->revision >= VDEC_REVISION_G12A) { ++ if (core->platform->revision >= VDEC_REVISION_SM1) ++ val = 0xfc << 8; ++ else ++ val = 0x54 << 8; ++ ++ /* enable first, compressed write */ ++ if (codec_hevc_use_fbc(sess->pixfmt_cap, ++ hevc->is_10bit)) ++ val |= BIT(8); ++ ++ /* enable second, uncompressed write */ ++ if (sess->pixfmt_cap == V4L2_PIX_FMT_NV12M) ++ val |= BIT(9); ++ ++ /* dblk pipeline mode=1 for performance */ ++ if (hevc->width >= 1280) ++ val |= BIT(4); ++ ++ amvdec_write_dos(core, HEVC_DBLK_CFGB, val); ++ amvdec_write_dos(core, HEVC_DBLK_STS1 + 16, BIT(28)); ++ } ++ ++ amvdec_write_dos(core, HEVC_DBLK_CFG2, ++ hevc->width | (hevc->height << 16)); ++ ++ val = 0; ++ if ((misc_flag0 >> PCM_ENABLE_FLAG_BIT) & 0x1) ++ val |= ((misc_flag0 >> ++ PCM_LOOP_FILTER_DISABLED_FLAG_BIT) & 0x1) << 3; ++ ++ val |= (param->p.pps_cb_qp_offset & 0x1f) << 4; ++ val |= (param->p.pps_cr_qp_offset & 0x1f) << 9; ++ val |= (hevc->lcu_size == 64) ? 0 : ++ ((hevc->lcu_size == 32) ? 1 : 2); ++ amvdec_write_dos(core, HEVC_DBLK_CFG1, val); ++ } ++ ++ val = amvdec_read_dos(core, HEVC_SAO_CTRL1) & ~0x3ff3; ++ val |= 0xff0; /* Set endianness for 2-bytes swaps (nv12) */ ++ if (core->platform->revision < VDEC_REVISION_G12A) { ++ if (!codec_hevc_use_fbc(sess->pixfmt_cap, hevc->is_10bit)) ++ val |= BIT(0); /* disable cm compression */ ++ /* TOFIX: Handle Amlogic Framebuffer compression */ ++ } ++ ++ amvdec_write_dos(core, HEVC_SAO_CTRL1, val); ++ ++ if (!codec_hevc_use_fbc(sess->pixfmt_cap, hevc->is_10bit)) { ++ /* no downscale for NV12 */ ++ val = amvdec_read_dos(core, HEVC_SAO_CTRL5) & ~0xff0000; ++ amvdec_write_dos(core, HEVC_SAO_CTRL5, val); ++ } ++ ++ val = amvdec_read_dos(core, HEVCD_IPP_AXIIF_CONFIG) & ~0x30; ++ val |= 0xf; ++ amvdec_write_dos(core, HEVCD_IPP_AXIIF_CONFIG, val); ++ ++ val = 0; ++ val_2 = amvdec_read_dos(core, HEVC_SAO_CTRL0); ++ val_2 &= (~0x300); ++ ++ slice_deblocking_filter_disabled_flag = (misc_flag0 >> ++ SLICE_DEBLOCKING_FILTER_DISABLED_FLAG_BIT) & 0x1; ++ if ((misc_flag0 & (1 << DEBLOCKING_FILTER_OVERRIDE_ENABLED_FLAG_BIT)) ++ && (misc_flag0 & (1 << DEBLOCKING_FILTER_OVERRIDE_FLAG_BIT))) { ++ val |= slice_deblocking_filter_disabled_flag << 2; ++ ++ if (!slice_deblocking_filter_disabled_flag) { ++ val |= (param->p.slice_beta_offset_div2 & 0xf) << 3; ++ val |= (param->p.slice_tc_offset_div2 & 0xf) << 7; ++ } ++ } else { ++ val |= ++ ((misc_flag0 >> ++ PPS_DEBLOCKING_FILTER_DISABLED_FLAG_BIT) & 0x1) << 2; ++ ++ if (((misc_flag0 >> PPS_DEBLOCKING_FILTER_DISABLED_FLAG_BIT) & ++ 0x1) == 0) { ++ val |= (param->p.pps_beta_offset_div2 & 0xf) << 3; ++ val |= (param->p.pps_tc_offset_div2 & 0xf) << 7; ++ } ++ } ++ if ((misc_flag0 & (1 << PPS_LOOP_FILTER_ACROSS_SLICES_ENABLED_FLAG_BIT)) ++ && ((misc_flag0 & (1 << SLICE_SAO_LUMA_FLAG_BIT)) ++ || (misc_flag0 & (1 << SLICE_SAO_CHROMA_FLAG_BIT)) ++ || (!slice_deblocking_filter_disabled_flag))) { ++ val |= ++ ((misc_flag0 >> ++ SLICE_LOOP_FILTER_ACROSS_SLICES_ENABLED_FLAG_BIT) ++ & 0x1) << 1; ++ val_2 |= ++ ((misc_flag0 >> ++ SLICE_LOOP_FILTER_ACROSS_SLICES_ENABLED_FLAG_BIT) ++ & 0x1) << 9; ++ } else { ++ val |= ++ ((misc_flag0 >> ++ PPS_LOOP_FILTER_ACROSS_SLICES_ENABLED_FLAG_BIT) ++ & 0x1) << 1; ++ val_2 |= ++ ((misc_flag0 >> ++ PPS_LOOP_FILTER_ACROSS_SLICES_ENABLED_FLAG_BIT) ++ & 0x1) << 9; ++ } ++ ++ amvdec_write_dos(core, HEVC_DBLK_CFG9, val); ++ amvdec_write_dos(core, HEVC_SAO_CTRL0, val_2); ++ ++ amvdec_write_dos(core, HEVC_sao_mem_unit, sao_mem_unit); ++ amvdec_write_dos(core, HEVC_SAO_ABV, ++ hevc->workspace_paddr + SAO_ABV_OFFSET); ++ amvdec_write_dos(core, HEVC_sao_vb_size, sao_vb_size); ++ amvdec_write_dos(core, HEVC_SAO_VB, ++ hevc->workspace_paddr + SAO_VB_OFFSET); ++} ++ ++static dma_addr_t codec_hevc_get_frame_mv_paddr(struct codec_hevc *hevc, ++ struct hevc_frame *frame) ++{ ++ return hevc->workspace_paddr + MPRED_MV_OFFSET + ++ (frame->vbuf->vb2_buf.index * MPRED_MV_BUF_SIZE); ++} ++ ++static void ++codec_hevc_set_mpred_ctrl(struct amvdec_core *core, struct codec_hevc *hevc) ++{ ++ union rpm_param *param = &hevc->rpm_param; ++ u32 slice_type = param->p.slice_type; ++ u32 lcu_size_log2 = ilog2(hevc->lcu_size); ++ u32 val; ++ ++ val = slice_type | ++ MPRED_CTRL0_ABOVE_EN | ++ MPRED_CTRL0_MV_WR_EN | ++ MPRED_CTRL0_BUF_LINEAR | ++ (lcu_size_log2 << 16) | ++ (3 << 20) | /* cu_size_log2 */ ++ (param->p.log2_parallel_merge_level << 24); ++ ++ if (slice_type != I_SLICE) ++ val |= MPRED_CTRL0_MV_RD_EN; ++ ++ if (param->p.collocated_from_l0_flag) ++ val |= MPRED_CTRL0_COL_FROM_L0; ++ ++ if (param->p.slice_temporal_mvp_enable_flag) ++ val |= MPRED_CTRL0_TMVP; ++ ++ if (hevc->ldc_flag) ++ val |= MPRED_CTRL0_LDC; ++ ++ if (param->p.dependent_slice_segment_flag) ++ val |= MPRED_CTRL0_NEW_SLI_SEG; ++ ++ if (param->p.slice_segment_address == 0) ++ val |= MPRED_CTRL0_NEW_PIC | ++ MPRED_CTRL0_NEW_TILE; ++ ++ amvdec_write_dos(core, HEVC_MPRED_CTRL0, val); ++ ++ val = (5 - param->p.five_minus_max_num_merge_cand) | ++ (AMVP_MAX_NUM_CANDS << 4) | ++ (AMVP_MAX_NUM_CANDS_MEM << 8) | ++ (NUM_CHROMA_MODE << 12) | ++ (DM_CHROMA_IDX << 16); ++ amvdec_write_dos(core, HEVC_MPRED_CTRL1, val); ++} ++ ++static void codec_hevc_set_mpred_mv(struct amvdec_core *core, ++ struct codec_hevc *hevc, ++ struct hevc_frame *frame, ++ struct hevc_frame *col_frame) ++{ ++ union rpm_param *param = &hevc->rpm_param; ++ u32 lcu_size_log2 = ilog2(hevc->lcu_size); ++ u32 mv_mem_unit = lcu_size_log2 == 6 ? 0x200 : ++ lcu_size_log2 == 5 ? 0x80 : 0x20; ++ dma_addr_t col_mv_rd_start_addr, col_mv_rd_ptr, col_mv_rd_end_addr; ++ dma_addr_t mpred_mv_wr_ptr; ++ u32 val; ++ ++ val = amvdec_read_dos(core, HEVC_MPRED_CURR_LCU); ++ ++ col_mv_rd_start_addr = codec_hevc_get_frame_mv_paddr(hevc, col_frame); ++ mpred_mv_wr_ptr = codec_hevc_get_frame_mv_paddr(hevc, frame) + ++ (hevc->slice_addr * mv_mem_unit); ++ col_mv_rd_ptr = col_mv_rd_start_addr + ++ (hevc->slice_addr * mv_mem_unit); ++ col_mv_rd_end_addr = col_mv_rd_start_addr + ++ (hevc->lcu_total * mv_mem_unit); ++ ++ amvdec_write_dos(core, HEVC_MPRED_MV_WR_START_ADDR, ++ codec_hevc_get_frame_mv_paddr(hevc, frame)); ++ amvdec_write_dos(core, HEVC_MPRED_MV_RD_START_ADDR, ++ col_mv_rd_start_addr); ++ ++ if (param->p.slice_segment_address == 0) { ++ amvdec_write_dos(core, HEVC_MPRED_ABV_START_ADDR, ++ hevc->workspace_paddr + MPRED_ABV_OFFSET); ++ amvdec_write_dos(core, HEVC_MPRED_MV_WPTR, mpred_mv_wr_ptr); ++ amvdec_write_dos(core, HEVC_MPRED_MV_RPTR, ++ col_mv_rd_start_addr); ++ } else { ++ amvdec_write_dos(core, HEVC_MPRED_MV_RPTR, col_mv_rd_ptr); ++ } ++ ++ amvdec_write_dos(core, HEVC_MPRED_MV_RD_END_ADDR, col_mv_rd_end_addr); ++} ++ ++/* Update motion prediction with the current slice */ ++static void codec_hevc_set_mpred(struct amvdec_session *sess, ++ struct hevc_frame *frame, ++ struct hevc_frame *col_frame) ++{ ++ struct amvdec_core *core = sess->core; ++ struct codec_hevc *hevc = sess->priv; ++ u32 *ref_num = frame->ref_num; ++ u32 *ref_poc_l0 = frame->ref_poc_list[0][frame->cur_slice_idx]; ++ u32 *ref_poc_l1 = frame->ref_poc_list[1][frame->cur_slice_idx]; ++ u32 val; ++ int i; ++ ++ codec_hevc_set_mpred_ctrl(core, hevc); ++ codec_hevc_set_mpred_mv(core, hevc, frame, col_frame); ++ ++ amvdec_write_dos(core, HEVC_MPRED_PIC_SIZE, ++ hevc->width | (hevc->height << 16)); ++ ++ val = ((hevc->lcu_x_num - 1) | (hevc->lcu_y_num - 1) << 16); ++ amvdec_write_dos(core, HEVC_MPRED_PIC_SIZE_LCU, val); ++ ++ amvdec_write_dos(core, HEVC_MPRED_REF_NUM, ++ (ref_num[1] << 8) | ref_num[0]); ++ amvdec_write_dos(core, HEVC_MPRED_REF_EN_L0, (1 << ref_num[0]) - 1); ++ amvdec_write_dos(core, HEVC_MPRED_REF_EN_L1, (1 << ref_num[1]) - 1); ++ ++ amvdec_write_dos(core, HEVC_MPRED_CUR_POC, hevc->curr_poc); ++ amvdec_write_dos(core, HEVC_MPRED_COL_POC, hevc->col_poc); ++ ++ for (i = 0; i < MAX_REF_ACTIVE; ++i) { ++ amvdec_write_dos(core, HEVC_MPRED_L0_REF00_POC + i * 4, ++ ref_poc_l0[i]); ++ amvdec_write_dos(core, HEVC_MPRED_L1_REF00_POC + i * 4, ++ ref_poc_l1[i]); ++ } ++} ++ ++/* motion compensation reference cache controller */ ++static void codec_hevc_set_mcrcc(struct amvdec_session *sess) ++{ ++ struct amvdec_core *core = sess->core; ++ struct codec_hevc *hevc = sess->priv; ++ u32 val, val_2; ++ int l0_cnt = 0; ++ int l1_cnt = 0x7fff; ++ ++ if (!codec_hevc_use_fbc(sess->pixfmt_cap, hevc->is_10bit)) { ++ l0_cnt = hevc->cur_frame->ref_num[0]; ++ l1_cnt = hevc->cur_frame->ref_num[1]; ++ } ++ ++ if (hevc->cur_frame->cur_slice_type == I_SLICE) { ++ amvdec_write_dos(core, HEVCD_MCRCC_CTL1, 0); ++ return; ++ } ++ ++ if (hevc->cur_frame->cur_slice_type == P_SLICE) { ++ amvdec_write_dos(core, HEVCD_MPP_ANC_CANVAS_ACCCONFIG_ADDR, ++ BIT(1)); ++ val = amvdec_read_dos(core, HEVCD_MPP_ANC_CANVAS_DATA_ADDR); ++ val &= 0xffff; ++ val |= (val << 16); ++ amvdec_write_dos(core, HEVCD_MCRCC_CTL2, val); ++ ++ if (l0_cnt == 1) { ++ amvdec_write_dos(core, HEVCD_MCRCC_CTL3, val); ++ } else { ++ val = amvdec_read_dos(core, ++ HEVCD_MPP_ANC_CANVAS_DATA_ADDR); ++ val &= 0xffff; ++ val |= (val << 16); ++ amvdec_write_dos(core, HEVCD_MCRCC_CTL3, val); ++ } ++ } else { /* B_SLICE */ ++ amvdec_write_dos(core, HEVCD_MPP_ANC_CANVAS_ACCCONFIG_ADDR, 0); ++ val = amvdec_read_dos(core, HEVCD_MPP_ANC_CANVAS_DATA_ADDR); ++ val &= 0xffff; ++ val |= (val << 16); ++ amvdec_write_dos(core, HEVCD_MCRCC_CTL2, val); ++ ++ amvdec_write_dos(core, HEVCD_MPP_ANC_CANVAS_ACCCONFIG_ADDR, ++ BIT(12) | BIT(1)); ++ val_2 = amvdec_read_dos(core, HEVCD_MPP_ANC_CANVAS_DATA_ADDR); ++ val_2 &= 0xffff; ++ val_2 |= (val_2 << 16); ++ if (val == val_2 && l1_cnt > 1) { ++ val_2 = amvdec_read_dos(core, ++ HEVCD_MPP_ANC_CANVAS_DATA_ADDR); ++ val_2 &= 0xffff; ++ val_2 |= (val_2 << 16); ++ } ++ amvdec_write_dos(core, HEVCD_MCRCC_CTL3, val); ++ } ++ ++ /* enable mcrcc progressive-mode */ ++ amvdec_write_dos(core, HEVCD_MCRCC_CTL1, 0xff0); ++} ++ ++static void codec_hevc_set_ref_list(struct amvdec_session *sess, ++ u32 ref_num, u32 *ref_poc_list) ++{ ++ struct codec_hevc *hevc = sess->priv; ++ struct hevc_frame *ref_frame; ++ struct amvdec_core *core = sess->core; ++ int i; ++ u32 buf_id_y; ++ u32 buf_id_uv; ++ ++ for (i = 0; i < ref_num; i++) { ++ ref_frame = codec_hevc_get_frame_by_poc(hevc, ref_poc_list[i]); ++ ++ if (!ref_frame) { ++ dev_warn(core->dev, "Couldn't find ref. frame %u\n", ++ ref_poc_list[i]); ++ continue; ++ } ++ ++ if (codec_hevc_use_fbc(sess->pixfmt_cap, hevc->is_10bit)) { ++ buf_id_y = buf_id_uv = ref_frame->vbuf->vb2_buf.index; ++ } else { ++ buf_id_y = ref_frame->vbuf->vb2_buf.index * 2; ++ buf_id_uv = buf_id_y + 1; ++ } ++ ++ amvdec_write_dos(core, HEVCD_MPP_ANC_CANVAS_DATA_ADDR, ++ (buf_id_uv << 16) | ++ (buf_id_uv << 8) | ++ buf_id_y); ++ } ++} ++ ++static void codec_hevc_set_mc(struct amvdec_session *sess, ++ struct hevc_frame *frame) ++{ ++ struct amvdec_core *core = sess->core; ++ ++ if (frame->cur_slice_type == I_SLICE) ++ return; ++ ++ amvdec_write_dos(core, HEVCD_MPP_ANC_CANVAS_ACCCONFIG_ADDR, 1); ++ codec_hevc_set_ref_list(sess, frame->ref_num[0], ++ frame->ref_poc_list[0][frame->cur_slice_idx]); ++ ++ if (frame->cur_slice_type == P_SLICE) ++ return; ++ ++ amvdec_write_dos(core, HEVCD_MPP_ANC_CANVAS_ACCCONFIG_ADDR, ++ BIT(12) | BIT(0)); ++ codec_hevc_set_ref_list(sess, frame->ref_num[1], ++ frame->ref_poc_list[1][frame->cur_slice_idx]); ++} ++ ++static void codec_hevc_update_col_frame(struct codec_hevc *hevc) ++{ ++ struct hevc_frame *cur_frame = hevc->cur_frame; ++ union rpm_param *param = &hevc->rpm_param; ++ u32 list_no = 0; ++ u32 col_ref = param->p.collocated_ref_idx; ++ u32 col_from_l0 = param->p.collocated_from_l0_flag; ++ u32 cur_slice_idx = cur_frame->cur_slice_idx; ++ ++ if (cur_frame->cur_slice_type == B_SLICE) ++ list_no = 1 - col_from_l0; ++ ++ if (col_ref >= cur_frame->ref_num[list_no]) ++ hevc->col_poc = INVALID_POC; ++ else ++ hevc->col_poc = cur_frame->ref_poc_list[list_no] ++ [cur_slice_idx] ++ [col_ref]; ++ ++ if (cur_frame->cur_slice_type == I_SLICE) ++ goto end; ++ ++ if (hevc->col_poc != INVALID_POC) ++ hevc->col_frame = codec_hevc_get_frame_by_poc(hevc, ++ hevc->col_poc); ++ else ++ hevc->col_frame = hevc->cur_frame; ++ ++end: ++ if (!hevc->col_frame) ++ hevc->col_frame = hevc->cur_frame; ++} ++ ++static void codec_hevc_update_pocs(struct amvdec_session *sess) ++{ ++ struct codec_hevc *hevc = sess->priv; ++ union rpm_param *param = &hevc->rpm_param; ++ u32 nal_unit_type = param->p.m_nalUnitType; ++ u32 temporal_id = param->p.m_temporalId & 0x7; ++ int max_poc_lsb = ++ 1 << (param->p.log2_max_pic_order_cnt_lsb_minus4 + 4); ++ int prev_poc_lsb; ++ int prev_poc_msb; ++ int poc_msb; ++ int poc_lsb = param->p.POClsb; ++ ++ if (nal_unit_type == NAL_UNIT_CODED_SLICE_IDR || ++ nal_unit_type == NAL_UNIT_CODED_SLICE_IDR_N_LP) { ++ hevc->curr_poc = 0; ++ if ((temporal_id - 1) == 0) ++ hevc->prev_tid0_poc = hevc->curr_poc; ++ ++ return; ++ } ++ ++ prev_poc_lsb = hevc->prev_tid0_poc % max_poc_lsb; ++ prev_poc_msb = hevc->prev_tid0_poc - prev_poc_lsb; ++ ++ if ((poc_lsb < prev_poc_lsb) && ++ ((prev_poc_lsb - poc_lsb) >= (max_poc_lsb / 2))) ++ poc_msb = prev_poc_msb + max_poc_lsb; ++ else if ((poc_lsb > prev_poc_lsb) && ++ ((poc_lsb - prev_poc_lsb) > (max_poc_lsb / 2))) ++ poc_msb = prev_poc_msb - max_poc_lsb; ++ else ++ poc_msb = prev_poc_msb; ++ ++ if (nal_unit_type == NAL_UNIT_CODED_SLICE_BLA || ++ nal_unit_type == NAL_UNIT_CODED_SLICE_BLANT || ++ nal_unit_type == NAL_UNIT_CODED_SLICE_BLA_N_LP) ++ poc_msb = 0; ++ ++ hevc->curr_poc = (poc_msb + poc_lsb); ++ if ((temporal_id - 1) == 0) ++ hevc->prev_tid0_poc = hevc->curr_poc; ++} ++ ++static void codec_hevc_process_segment_header(struct amvdec_session *sess) ++{ ++ struct codec_hevc *hevc = sess->priv; ++ union rpm_param *param = &hevc->rpm_param; ++ ++ if (param->p.first_slice_segment_in_pic_flag == 0) { ++ hevc->slice_segment_addr = param->p.slice_segment_address; ++ if (!param->p.dependent_slice_segment_flag) ++ hevc->slice_addr = hevc->slice_segment_addr; ++ } else { ++ hevc->slice_segment_addr = 0; ++ hevc->slice_addr = 0; ++ } ++ ++ codec_hevc_update_pocs(sess); ++} ++ ++static int codec_hevc_process_segment(struct amvdec_session *sess) ++{ ++ struct codec_hevc *hevc = sess->priv; ++ struct amvdec_core *core = sess->core; ++ union rpm_param *param = &hevc->rpm_param; ++ u32 slice_segment_address = param->p.slice_segment_address; ++ ++ /* First slice: new frame */ ++ if (slice_segment_address == 0) { ++ codec_hevc_update_referenced(hevc); ++ codec_hevc_output_frames(sess); ++ ++ hevc->cur_frame = codec_hevc_prepare_new_frame(sess); ++ if (!hevc->cur_frame) ++ return -1; ++ } else { ++ hevc->cur_frame->cur_slice_idx++; ++ } ++ ++ codec_hevc_update_frame_refs(sess, hevc->cur_frame); ++ codec_hevc_update_col_frame(hevc); ++ codec_hevc_update_ldc_flag(hevc); ++ if (codec_hevc_use_mmu(core->platform->revision, sess->pixfmt_cap, ++ hevc->is_10bit)) ++ codec_hevc_fill_mmu_map(sess, &hevc->common, ++ &hevc->cur_frame->vbuf->vb2_buf, ++ hevc->is_10bit); ++ codec_hevc_set_mc(sess, hevc->cur_frame); ++ codec_hevc_set_mcrcc(sess); ++ codec_hevc_set_mpred(sess, hevc->cur_frame, hevc->col_frame); ++ codec_hevc_set_sao(sess, hevc->cur_frame); ++ ++ amvdec_write_dos_bits(core, HEVC_WAIT_FLAG, BIT(1)); ++ amvdec_write_dos(core, HEVC_DEC_STATUS_REG, ++ HEVC_CODED_SLICE_SEGMENT_DAT); ++ ++ /* Interrupt the firmware's processor */ ++ amvdec_write_dos(core, HEVC_MCPU_INTR_REQ, AMRISC_MAIN_REQ); ++ ++ return 0; ++} ++ ++static int codec_hevc_process_rpm(struct codec_hevc *hevc) ++{ ++ union rpm_param *param = &hevc->rpm_param; ++ int src_changed = 0; ++ u32 dst_width, dst_height; ++ u32 lcu_size; ++ u32 is_10bit = 0; ++ ++ if (param->p.slice_segment_address || ++ !param->p.pic_width_in_luma_samples || ++ !param->p.pic_height_in_luma_samples) ++ return 0; ++ ++ if (param->p.bit_depth) ++ is_10bit = 1; ++ ++ hevc->width = param->p.pic_width_in_luma_samples; ++ hevc->height = param->p.pic_height_in_luma_samples; ++ dst_width = hevc->width; ++ dst_height = hevc->height; ++ ++ lcu_size = 1 << (param->p.log2_min_coding_block_size_minus3 + ++ 3 + param->p.log2_diff_max_min_coding_block_size); ++ ++ hevc->lcu_x_num = (hevc->width + lcu_size - 1) / lcu_size; ++ hevc->lcu_y_num = (hevc->height + lcu_size - 1) / lcu_size; ++ hevc->lcu_total = hevc->lcu_x_num * hevc->lcu_y_num; ++ ++ if (param->p.conformance_window_flag) { ++ u32 sub_width = 1, sub_height = 1; ++ ++ switch (param->p.chroma_format_idc) { ++ case 1: ++ sub_height = 2; /* fallthrough */ ++ case 2: ++ sub_width = 2; ++ break; ++ } ++ ++ dst_width -= sub_width * ++ (param->p.conf_win_left_offset + ++ param->p.conf_win_right_offset); ++ dst_height -= sub_height * ++ (param->p.conf_win_top_offset + ++ param->p.conf_win_bottom_offset); ++ } ++ ++ if (dst_width != hevc->dst_width || ++ dst_height != hevc->dst_height || ++ lcu_size != hevc->lcu_size || ++ is_10bit != hevc->is_10bit) ++ src_changed = 1; ++ ++ hevc->dst_width = dst_width; ++ hevc->dst_height = dst_height; ++ hevc->lcu_size = lcu_size; ++ hevc->is_10bit = is_10bit; ++ ++ return src_changed; ++} ++ ++/* ++ * The RPM section within the workspace contains ++ * many information regarding the parsed bitstream ++ */ ++static void codec_hevc_fetch_rpm(struct amvdec_session *sess) ++{ ++ struct codec_hevc *hevc = sess->priv; ++ u16 *rpm_vaddr = hevc->workspace_vaddr + RPM_OFFSET; ++ int i, j; ++ ++ for (i = 0; i < RPM_SIZE; i += 4) ++ for (j = 0; j < 4; j++) ++ hevc->rpm_param.l.data[i + j] = rpm_vaddr[i + 3 - j]; ++} ++ ++static void codec_hevc_resume(struct amvdec_session *sess) ++{ ++ struct codec_hevc *hevc = sess->priv; ++ ++ if (codec_hevc_setup_buffers(sess, &hevc->common, hevc->is_10bit)) { ++ amvdec_abort(sess); ++ return; ++ } ++ ++ codec_hevc_setup_decode_head(sess, hevc->is_10bit); ++ codec_hevc_process_segment_header(sess); ++ if (codec_hevc_process_segment(sess)) ++ amvdec_abort(sess); ++} ++ ++static irqreturn_t codec_hevc_threaded_isr(struct amvdec_session *sess) ++{ ++ struct amvdec_core *core = sess->core; ++ struct codec_hevc *hevc = sess->priv; ++ u32 dec_status = amvdec_read_dos(core, HEVC_DEC_STATUS_REG); ++ ++ if (!hevc) ++ return IRQ_HANDLED; ++ ++ mutex_lock(&hevc->lock); ++ if (dec_status != HEVC_SLICE_SEGMENT_DONE) { ++ dev_err(core->dev_dec, "Unrecognized dec_status: %08X\n", ++ dec_status); ++ amvdec_abort(sess); ++ goto unlock; ++ } ++ ++ sess->keyframe_found = 1; ++ codec_hevc_fetch_rpm(sess); ++ if (codec_hevc_process_rpm(hevc)) { ++ amvdec_src_change(sess, hevc->dst_width, hevc->dst_height, 16, ++ hevc->is_10bit ? 10 : 8); ++ goto unlock; ++ } ++ ++ codec_hevc_process_segment_header(sess); ++ if (codec_hevc_process_segment(sess)) ++ amvdec_abort(sess); ++ ++unlock: ++ mutex_unlock(&hevc->lock); ++ return IRQ_HANDLED; ++} ++ ++static irqreturn_t codec_hevc_isr(struct amvdec_session *sess) ++{ ++ return IRQ_WAKE_THREAD; ++} ++ ++struct amvdec_codec_ops codec_hevc_ops = { ++ .start = codec_hevc_start, ++ .stop = codec_hevc_stop, ++ .isr = codec_hevc_isr, ++ .threaded_isr = codec_hevc_threaded_isr, ++ .num_pending_bufs = codec_hevc_num_pending_bufs, ++ .drain = codec_hevc_flush_output, ++ .resume = codec_hevc_resume, ++}; +diff --git a/drivers/staging/media/meson/vdec/codec_hevc.h b/drivers/staging/media/meson/vdec/codec_hevc.h +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/drivers/staging/media/meson/vdec/codec_hevc.h +@@ -0,0 +1,13 @@ ++/* SPDX-License-Identifier: GPL-2.0+ */ ++/* ++ * Copyright (C) 2018 Maxime Jourdan ++ */ ++ ++#ifndef __MESON_VDEC_CODEC_HEVC_H_ ++#define __MESON_VDEC_CODEC_HEVC_H_ ++ ++#include "vdec.h" ++ ++extern struct amvdec_codec_ops codec_hevc_ops; ++ ++#endif +diff --git a/drivers/staging/media/meson/vdec/esparser.c b/drivers/staging/media/meson/vdec/esparser.c +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/meson/vdec/esparser.c ++++ b/drivers/staging/media/meson/vdec/esparser.c +@@ -308,7 +308,7 @@ esparser_queue(struct amvdec_session *sess, struct vb2_v4l2_buffer *vbuf) + * they could pause when there is no capture buffer available and + * resume on this notification. + */ +- if (sess->fmt_out->pixfmt == V4L2_PIX_FMT_VP9) { ++ if (sess->fmt_out->pixfmt == V4L2_PIX_FMT_VP9 || sess->fmt_out->pixfmt ==V4L2_PIX_FMT_HEVC) { + if (codec_ops->num_pending_bufs) + num_dst_bufs = codec_ops->num_pending_bufs(sess); + +diff --git a/drivers/staging/media/meson/vdec/hevc_regs.h b/drivers/staging/media/meson/vdec/hevc_regs.h +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/meson/vdec/hevc_regs.h ++++ b/drivers/staging/media/meson/vdec/hevc_regs.h +@@ -205,6 +205,7 @@ + #define HEVC_CM_HEADER_START_ADDR 0xd8a0 + #define HEVC_CM_HEADER_LENGTH 0xd8a4 + #define HEVC_CM_HEADER_OFFSET 0xd8ac ++#define HEVC_SAO_CTRL9 0xd8b4 + #define HEVC_SAO_MMU_VH0_ADDR 0xd8e8 + #define HEVC_SAO_MMU_VH1_ADDR 0xd8ec + +diff --git a/drivers/staging/media/meson/vdec/vdec_platform.c b/drivers/staging/media/meson/vdec/vdec_platform.c +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/meson/vdec/vdec_platform.c ++++ b/drivers/staging/media/meson/vdec/vdec_platform.c +@@ -11,6 +11,7 @@ + #include "vdec_hevc.h" + #include "codec_mpeg12.h" + #include "codec_h264.h" ++#include "codec_hevc.h" + #include "codec_vp9.h" + + static const struct amvdec_format vdec_formats_gxbb[] = { +@@ -64,6 +65,18 @@ static const struct amvdec_format vdec_formats_gxl[] = { + .pixfmts_cap = { V4L2_PIX_FMT_NV12M, 0 }, + .flags = V4L2_FMT_FLAG_COMPRESSED | + V4L2_FMT_FLAG_DYN_RESOLUTION, ++ }, { ++ .pixfmt = V4L2_PIX_FMT_HEVC, ++ .min_buffers = 4, ++ .max_buffers = 24, ++ .max_width = 3840, ++ .max_height = 2160, ++ .vdec_ops = &vdec_hevc_ops, ++ .codec_ops = &codec_hevc_ops, ++ .firmware_path = "meson/vdec/gxl_hevc.bin", ++ .pixfmts_cap = { V4L2_PIX_FMT_NV12M, 0 }, ++ .flags = V4L2_FMT_FLAG_COMPRESSED | ++ V4L2_FMT_FLAG_DYN_RESOLUTION, + }, { + .pixfmt = V4L2_PIX_FMT_H264, + .min_buffers = 2, +@@ -152,6 +165,18 @@ static const struct amvdec_format vdec_formats_gxm[] = { + .pixfmts_cap = { V4L2_PIX_FMT_NV12M, 0 }, + .flags = V4L2_FMT_FLAG_COMPRESSED | + V4L2_FMT_FLAG_DYN_RESOLUTION, ++ }, { ++ .pixfmt = V4L2_PIX_FMT_HEVC, ++ .min_buffers = 4, ++ .max_buffers = 24, ++ .max_width = 3840, ++ .max_height = 2160, ++ .vdec_ops = &vdec_hevc_ops, ++ .codec_ops = &codec_hevc_ops, ++ .firmware_path = "meson/vdec/gxl_hevc.bin", ++ .pixfmts_cap = { V4L2_PIX_FMT_NV12M, 0 }, ++ .flags = V4L2_FMT_FLAG_COMPRESSED | ++ V4L2_FMT_FLAG_DYN_RESOLUTION, + }, { + .pixfmt = V4L2_PIX_FMT_H264, + .min_buffers = 2, +@@ -203,6 +228,18 @@ static const struct amvdec_format vdec_formats_g12a[] = { + .flags = V4L2_FMT_FLAG_COMPRESSED | + V4L2_FMT_FLAG_DYN_RESOLUTION, + }, { ++ .pixfmt = V4L2_PIX_FMT_HEVC, ++ .min_buffers = 4, ++ .max_buffers = 24, ++ .max_width = 3840, ++ .max_height = 2160, ++ .vdec_ops = &vdec_hevc_ops, ++ .codec_ops = &codec_hevc_ops, ++ .firmware_path = "meson/vdec/g12a_hevc_mmu.bin", ++ .pixfmts_cap = { V4L2_PIX_FMT_NV12M, 0 }, ++ .flags = V4L2_FMT_FLAG_COMPRESSED | ++ V4L2_FMT_FLAG_DYN_RESOLUTION, ++ },{ + .pixfmt = V4L2_PIX_FMT_H264, + .min_buffers = 2, + .max_buffers = 24, +@@ -252,6 +289,18 @@ static const struct amvdec_format vdec_formats_sm1[] = { + .pixfmts_cap = { V4L2_PIX_FMT_NV12M, 0 }, + .flags = V4L2_FMT_FLAG_COMPRESSED | + V4L2_FMT_FLAG_DYN_RESOLUTION, ++ }, { ++ .pixfmt = V4L2_PIX_FMT_HEVC, ++ .min_buffers = 4, ++ .max_buffers = 24, ++ .max_width = 3840, ++ .max_height = 2160, ++ .vdec_ops = &vdec_hevc_ops, ++ .codec_ops = &codec_hevc_ops, ++ .firmware_path = "meson/vdec/sm1_hevc_mmu.bin", ++ .pixfmts_cap = { V4L2_PIX_FMT_NV12M, 0 }, ++ .flags = V4L2_FMT_FLAG_COMPRESSED | ++ V4L2_FMT_FLAG_DYN_RESOLUTION, + }, { + .pixfmt = V4L2_PIX_FMT_H264, + .min_buffers = 2, +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-meson-vdec-add-handling-to-HEVC-decoder-.patch b/patch/kernel/archive/meson64-6.13/general-meson-vdec-add-handling-to-HEVC-decoder-.patch new file mode 100644 index 000000000..0db5d1468 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-meson-vdec-add-handling-to-HEVC-decoder-.patch @@ -0,0 +1,157 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: benjamin545 +Date: Mon, 2 Aug 2021 15:18:40 -0400 +Subject: WIP: drivers: meson: vdec: add handling to HEVC decoder to show + frames when ready + +..rather than when no longer referenced + +the HEVC decode driver would not show the next frame until it was no longer referenced, +this would cause a backup of frames that were ready to render but held up by one or more +frames that were still referenced. The decoded picture buffer would fill up and stall +playback as no new frames could be placed in the decoded picture buffer. +--- + drivers/staging/media/meson/vdec/codec_hevc.c | 52 ++++++---- + 1 file changed, 34 insertions(+), 18 deletions(-) + +diff --git a/drivers/staging/media/meson/vdec/codec_hevc.c b/drivers/staging/media/meson/vdec/codec_hevc.c +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/meson/vdec/codec_hevc.c ++++ b/drivers/staging/media/meson/vdec/codec_hevc.c +@@ -223,6 +223,7 @@ struct hevc_frame { + u32 poc; + + int referenced; ++ int show; + u32 num_reorder_pic; + + u32 cur_slice_idx; +@@ -448,9 +449,11 @@ static void codec_hevc_update_referenced(struct codec_hevc *hevc) + ((1 << (RPS_USED_BIT - 1)) - 1); + if (param->p.CUR_RPS[i] & (1 << (RPS_USED_BIT - 1))) { + poc_tmp = curr_poc - +- ((1 << (RPS_USED_BIT - 1)) - delt); +- } else ++ ((1 << (RPS_USED_BIT - 1)) - delt); ++ } else { + poc_tmp = curr_poc + delt; ++ } ++ + if (poc_tmp == frame->poc) { + is_referenced = 1; + break; +@@ -462,13 +465,13 @@ static void codec_hevc_update_referenced(struct codec_hevc *hevc) + } + + static struct hevc_frame * +-codec_hevc_get_lowest_poc_frame(struct codec_hevc *hevc) ++codec_hevc_get_next_ready_frame(struct codec_hevc *hevc) + { + struct hevc_frame *tmp, *ret = NULL; + u32 poc = INT_MAX; + + list_for_each_entry(tmp, &hevc->ref_frames_list, list) { +- if (tmp->poc < poc) { ++ if ((tmp->poc < poc) && tmp->show) { + ret = tmp; + poc = tmp->poc; + } +@@ -478,28 +481,35 @@ codec_hevc_get_lowest_poc_frame(struct codec_hevc *hevc) + } + + /* Try to output as many frames as possible */ +-static void codec_hevc_output_frames(struct amvdec_session *sess) ++static void codec_hevc_show_frames(struct amvdec_session *sess) + { +- struct hevc_frame *tmp; ++ struct hevc_frame *tmp, *n; + struct codec_hevc *hevc = sess->priv; + +- while ((tmp = codec_hevc_get_lowest_poc_frame(hevc))) { ++ while ((tmp = codec_hevc_get_next_ready_frame(hevc))) { + if (hevc->curr_poc && +- (tmp->referenced || +- tmp->num_reorder_pic >= hevc->frames_num)) ++ (hevc->frames_num <= tmp->num_reorder_pic)) + break; + + dev_dbg(sess->core->dev, "DONE frame poc %u; vbuf %u\n", + tmp->poc, tmp->vbuf->vb2_buf.index); + amvdec_dst_buf_done_offset(sess, tmp->vbuf, tmp->offset, + V4L2_FIELD_NONE, false); ++ ++ tmp->show = 0; ++ hevc->frames_num--; ++ } ++ ++ /* clean output frame buffer */ ++ list_for_each_entry_safe(tmp, n, &hevc->ref_frames_list, list) { ++ if (tmp->referenced || tmp->show) ++ continue; ++ + list_del(&tmp->list); + kfree(tmp); +- hevc->frames_num--; + } + } + +- + static int + codec_hevc_setup_workspace(struct amvdec_session *sess, + struct codec_hevc *hevc) +@@ -650,14 +660,17 @@ static int codec_hevc_start(struct amvdec_session *sess) + static void codec_hevc_flush_output(struct amvdec_session *sess) + { + struct codec_hevc *hevc = sess->priv; +- struct hevc_frame *tmp; ++ struct hevc_frame *tmp, *n; + +- while (!list_empty(&hevc->ref_frames_list)) { +- tmp = codec_hevc_get_lowest_poc_frame(hevc); ++ while ((tmp = codec_hevc_get_next_ready_frame(hevc))) { + amvdec_dst_buf_done(sess, tmp->vbuf, V4L2_FIELD_NONE); ++ tmp->show = 0; ++ hevc->frames_num--; ++ } ++ ++ list_for_each_entry_safe(tmp, n, &hevc->ref_frames_list, list) { + list_del(&tmp->list); + kfree(tmp); +- hevc->frames_num--; + } + } + +@@ -719,6 +732,7 @@ codec_hevc_prepare_new_frame(struct amvdec_session *sess) + + new_frame->vbuf = vbuf; + new_frame->referenced = 1; ++ new_frame->show = 1; + new_frame->poc = hevc->curr_poc; + new_frame->cur_slice_type = params->p.slice_type; + new_frame->num_reorder_pic = params->p.sps_num_reorder_pics_0; +@@ -1267,7 +1281,7 @@ static int codec_hevc_process_segment(struct amvdec_session *sess) + /* First slice: new frame */ + if (slice_segment_address == 0) { + codec_hevc_update_referenced(hevc); +- codec_hevc_output_frames(sess); ++ codec_hevc_show_frames(sess); + + hevc->cur_frame = codec_hevc_prepare_new_frame(sess); + if (!hevc->cur_frame) +@@ -1370,9 +1384,11 @@ static void codec_hevc_fetch_rpm(struct amvdec_session *sess) + u16 *rpm_vaddr = hevc->workspace_vaddr + RPM_OFFSET; + int i, j; + +- for (i = 0; i < RPM_SIZE; i += 4) ++ for (i = 0; i < RPM_SIZE; i += 4) { + for (j = 0; j < 4; j++) +- hevc->rpm_param.l.data[i + j] = rpm_vaddr[i + 3 - j]; ++ hevc->rpm_param.l.data[i + j] = ++ rpm_vaddr[i + 3 - j]; ++ } + } + + static void codec_hevc_resume(struct amvdec_session *sess) +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-meson-vdec-check-if-parser-has-really-parser.patch b/patch/kernel/archive/meson64-6.13/general-meson-vdec-check-if-parser-has-really-parser.patch new file mode 100644 index 000000000..068d55ce7 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-meson-vdec-check-if-parser-has-really-parser.patch @@ -0,0 +1,51 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Neil Armstrong +Date: Mon, 22 Nov 2021 09:15:21 +0000 +Subject: WIP: drivers: meson: vdec: check if parser has really parser before + marking input buffer as error + +Signed-off-by: Neil Armstrong +--- + drivers/staging/media/meson/vdec/esparser.c | 14 +++++++--- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/drivers/staging/media/meson/vdec/esparser.c b/drivers/staging/media/meson/vdec/esparser.c +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/meson/vdec/esparser.c ++++ b/drivers/staging/media/meson/vdec/esparser.c +@@ -299,6 +299,7 @@ esparser_queue(struct amvdec_session *sess, struct vb2_v4l2_buffer *vbuf) + u32 num_dst_bufs = 0; + u32 offset; + u32 pad_size; ++ u32 wp, wp2; + + /* + * When max ref frame is held by VP9, this should be -= 3 to prevent a +@@ -352,15 +353,20 @@ esparser_queue(struct amvdec_session *sess, struct vb2_v4l2_buffer *vbuf) + } + + pad_size = esparser_pad_start_code(core, vb, payload_size); ++ wp = amvdec_read_parser(core, PARSER_VIDEO_WP); + ret = esparser_write_data(core, phy, payload_size + pad_size); ++ wp2 = amvdec_read_parser(core, PARSER_VIDEO_WP); + + if (ret <= 0) { +- dev_warn(core->dev, "esparser: input parsing error\n"); +- amvdec_remove_ts(sess, vb->timestamp); +- v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR); + amvdec_write_parser(core, PARSER_FETCH_CMD, 0); + +- return 0; ++ if (ret < 0 || wp2 == wp) { ++ dev_err(core->dev, "esparser: input parsing error ret %d (%x <=> %x)\n", ret, wp, wp2); ++ amvdec_remove_ts(sess, vb->timestamp); ++ v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR); ++ ++ return 0; ++ } + } + + atomic_inc(&sess->esparser_queued_bufs); +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-meson-vdec-improve-mmu-and-fbc-handling-.patch b/patch/kernel/archive/meson64-6.13/general-meson-vdec-improve-mmu-and-fbc-handling-.patch new file mode 100644 index 000000000..916ce5967 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-meson-vdec-improve-mmu-and-fbc-handling-.patch @@ -0,0 +1,587 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: benjamin545 +Date: Thu, 15 Jul 2021 16:32:39 -0400 +Subject: WIP: drivers: meson: vdec: improve mmu and fbc handling and add 10 + bit handling + +Unknown patch. From LibreELEC? +--- + drivers/staging/media/meson/vdec/codec_h264.c | 3 +- + drivers/staging/media/meson/vdec/codec_hevc_common.c | 164 ++++++---- + drivers/staging/media/meson/vdec/codec_hevc_common.h | 3 +- + drivers/staging/media/meson/vdec/codec_vp9.c | 36 +- + drivers/staging/media/meson/vdec/esparser.c | 1 + + drivers/staging/media/meson/vdec/vdec.h | 1 + + drivers/staging/media/meson/vdec/vdec_helpers.c | 46 ++- + drivers/staging/media/meson/vdec/vdec_helpers.h | 10 +- + 8 files changed, 163 insertions(+), 101 deletions(-) + +diff --git a/drivers/staging/media/meson/vdec/codec_h264.c b/drivers/staging/media/meson/vdec/codec_h264.c +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/meson/vdec/codec_h264.c ++++ b/drivers/staging/media/meson/vdec/codec_h264.c +@@ -353,7 +353,8 @@ static void codec_h264_src_change(struct amvdec_session *sess) + frame_width, frame_height, crop_right, crop_bottom); + + codec_h264_set_par(sess); +- amvdec_src_change(sess, frame_width, frame_height, h264->max_refs + 5); ++ amvdec_src_change(sess, frame_width, frame_height, ++ h264->max_refs + 5, 8); + } + + /* +diff --git a/drivers/staging/media/meson/vdec/codec_hevc_common.c b/drivers/staging/media/meson/vdec/codec_hevc_common.c +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/meson/vdec/codec_hevc_common.c ++++ b/drivers/staging/media/meson/vdec/codec_hevc_common.c +@@ -30,8 +30,11 @@ const u16 vdec_hevc_parser_cmd[] = { + void codec_hevc_setup_decode_head(struct amvdec_session *sess, int is_10bit) + { + struct amvdec_core *core = sess->core; +- u32 body_size = amvdec_am21c_body_size(sess->width, sess->height); +- u32 head_size = amvdec_am21c_head_size(sess->width, sess->height); ++ u32 use_mmu = codec_hevc_use_mmu(core->platform->revision, ++ sess->pixfmt_cap, is_10bit); ++ u32 body_size = amvdec_amfbc_body_size(sess->width, sess->height, ++ is_10bit, use_mmu); ++ u32 head_size = amvdec_amfbc_head_size(sess->width, sess->height); + + if (!codec_hevc_use_fbc(sess->pixfmt_cap, is_10bit)) { + /* Enable 2-plane reference read mode */ +@@ -39,9 +42,17 @@ void codec_hevc_setup_decode_head(struct amvdec_session *sess, int is_10bit) + return; + } + ++ /* enable mem saving mode for 8-bit */ ++ if (!is_10bit) ++ amvdec_write_dos_bits(core, HEVC_SAO_CTRL5, BIT(9)); ++ else ++ amvdec_clear_dos_bits(core, HEVC_SAO_CTRL5, BIT(9)); ++ + if (codec_hevc_use_mmu(core->platform->revision, + sess->pixfmt_cap, is_10bit)) + amvdec_write_dos(core, HEVCD_MPP_DECOMP_CTL1, BIT(4)); ++ else if (!is_10bit) ++ amvdec_write_dos(core, HEVCD_MPP_DECOMP_CTL1, BIT(3)); + else + amvdec_write_dos(core, HEVCD_MPP_DECOMP_CTL1, 0); + +@@ -73,7 +84,7 @@ static void codec_hevc_setup_buffers_gxbb(struct amvdec_session *sess, + + idx = vb->index; + +- if (codec_hevc_use_downsample(sess->pixfmt_cap, is_10bit)) ++ if (codec_hevc_use_fbc(sess->pixfmt_cap, is_10bit)) + buf_y_paddr = comm->fbc_buffer_paddr[idx]; + else + buf_y_paddr = vb2_dma_contig_plane_dma_addr(vb, 0); +@@ -114,8 +125,8 @@ static void codec_hevc_setup_buffers_gxl(struct amvdec_session *sess, + { + struct amvdec_core *core = sess->core; + struct v4l2_m2m_buffer *buf; +- u32 revision = core->platform->revision; + u32 pixfmt_cap = sess->pixfmt_cap; ++ const u32 revision = core->platform->revision; + int i; + + amvdec_write_dos(core, HEVCD_MPP_ANC2AXI_TBL_CONF_ADDR, +@@ -127,12 +138,14 @@ static void codec_hevc_setup_buffers_gxl(struct amvdec_session *sess, + dma_addr_t buf_uv_paddr = 0; + u32 idx = vb->index; + +- if (codec_hevc_use_mmu(revision, pixfmt_cap, is_10bit)) +- buf_y_paddr = comm->mmu_header_paddr[idx]; +- else if (codec_hevc_use_downsample(pixfmt_cap, is_10bit)) +- buf_y_paddr = comm->fbc_buffer_paddr[idx]; +- else +- buf_y_paddr = vb2_dma_contig_plane_dma_addr(vb, 0); ++ if (codec_hevc_use_downsample(pixfmt_cap, is_10bit)) { ++ if (codec_hevc_use_mmu(revision, pixfmt_cap, is_10bit)) ++ buf_y_paddr = comm->mmu_header_paddr[idx]; ++ else ++ buf_y_paddr = comm->fbc_buffer_paddr[idx]; ++ } else { ++ buf_y_paddr = vb2_dma_contig_plane_dma_addr(vb, 0); ++ } + + amvdec_write_dos(core, HEVCD_MPP_ANC2AXI_TBL_DATA, + buf_y_paddr >> 5); +@@ -150,60 +163,67 @@ static void codec_hevc_setup_buffers_gxl(struct amvdec_session *sess, + amvdec_write_dos(core, HEVCD_MPP_ANC_CANVAS_DATA_ADDR, 0); + } + +-void codec_hevc_free_fbc_buffers(struct amvdec_session *sess, ++void codec_hevc_free_mmu_headers(struct amvdec_session *sess, + struct codec_hevc_common *comm) + { + struct device *dev = sess->core->dev; +- u32 am21_size = amvdec_am21c_size(sess->width, sess->height); + int i; + + for (i = 0; i < MAX_REF_PIC_NUM; ++i) { +- if (comm->fbc_buffer_vaddr[i]) { +- dma_free_coherent(dev, am21_size, +- comm->fbc_buffer_vaddr[i], +- comm->fbc_buffer_paddr[i]); +- comm->fbc_buffer_vaddr[i] = NULL; ++ if (comm->mmu_header_vaddr[i]) { ++ dma_free_coherent(dev, MMU_COMPRESS_HEADER_SIZE, ++ comm->mmu_header_vaddr[i], ++ comm->mmu_header_paddr[i]); ++ comm->mmu_header_vaddr[i] = NULL; + } + } + } +-EXPORT_SYMBOL_GPL(codec_hevc_free_fbc_buffers); ++EXPORT_SYMBOL_GPL(codec_hevc_free_mmu_headers); + +-static int codec_hevc_alloc_fbc_buffers(struct amvdec_session *sess, ++static int codec_hevc_alloc_mmu_headers(struct amvdec_session *sess, + struct codec_hevc_common *comm) + { + struct device *dev = sess->core->dev; + struct v4l2_m2m_buffer *buf; +- u32 am21_size = amvdec_am21c_size(sess->width, sess->height); + + v4l2_m2m_for_each_dst_buf(sess->m2m_ctx, buf) { + u32 idx = buf->vb.vb2_buf.index; + dma_addr_t paddr; +- void *vaddr = dma_alloc_coherent(dev, am21_size, &paddr, +- GFP_KERNEL); ++ void *vaddr = dma_alloc_coherent(dev, MMU_COMPRESS_HEADER_SIZE, ++ &paddr, GFP_KERNEL); + if (!vaddr) { +- codec_hevc_free_fbc_buffers(sess, comm); ++ codec_hevc_free_mmu_headers(sess, comm); + return -ENOMEM; + } + +- comm->fbc_buffer_vaddr[idx] = vaddr; +- comm->fbc_buffer_paddr[idx] = paddr; ++ comm->mmu_header_vaddr[idx] = vaddr; ++ comm->mmu_header_paddr[idx] = paddr; + } + + return 0; + } + +-void codec_hevc_free_mmu_headers(struct amvdec_session *sess, ++void codec_hevc_free_fbc_buffers(struct amvdec_session *sess, + struct codec_hevc_common *comm) + { + struct device *dev = sess->core->dev; ++ u32 use_mmu; ++ u32 am21_size; + int i; + ++ use_mmu = codec_hevc_use_mmu(sess->core->platform->revision, ++ sess->pixfmt_cap, ++ sess->bitdepth == 10 ? 1 : 0); ++ ++ am21_size = amvdec_amfbc_size(sess->width, sess->height, ++ sess->bitdepth == 10 ? 1 : 0, use_mmu); ++ + for (i = 0; i < MAX_REF_PIC_NUM; ++i) { +- if (comm->mmu_header_vaddr[i]) { +- dma_free_coherent(dev, MMU_COMPRESS_HEADER_SIZE, +- comm->mmu_header_vaddr[i], +- comm->mmu_header_paddr[i]); +- comm->mmu_header_vaddr[i] = NULL; ++ if (comm->fbc_buffer_vaddr[i]) { ++ dma_free_coherent(dev, am21_size, ++ comm->fbc_buffer_vaddr[i], ++ comm->fbc_buffer_paddr[i]); ++ comm->fbc_buffer_vaddr[i] = NULL; + } + } + +@@ -213,33 +233,49 @@ void codec_hevc_free_mmu_headers(struct amvdec_session *sess, + comm->mmu_map_paddr); + comm->mmu_map_vaddr = NULL; + } ++ ++ codec_hevc_free_mmu_headers(sess, comm); + } +-EXPORT_SYMBOL_GPL(codec_hevc_free_mmu_headers); ++EXPORT_SYMBOL_GPL(codec_hevc_free_fbc_buffers); + +-static int codec_hevc_alloc_mmu_headers(struct amvdec_session *sess, ++static int codec_hevc_alloc_fbc_buffers(struct amvdec_session *sess, + struct codec_hevc_common *comm) + { + struct device *dev = sess->core->dev; + struct v4l2_m2m_buffer *buf; ++ u32 use_mmu; ++ u32 am21_size; ++ const u32 revision = sess->core->platform->revision; ++ const u32 is_10bit = sess->bitdepth == 10 ? 1 : 0; ++ int ret; + +- comm->mmu_map_vaddr = dma_alloc_coherent(dev, MMU_MAP_SIZE, +- &comm->mmu_map_paddr, +- GFP_KERNEL); +- if (!comm->mmu_map_vaddr) +- return -ENOMEM; ++ use_mmu = codec_hevc_use_mmu(revision, sess->pixfmt_cap, ++ is_10bit); ++ ++ am21_size = amvdec_amfbc_size(sess->width, sess->height, ++ is_10bit, use_mmu); + + v4l2_m2m_for_each_dst_buf(sess->m2m_ctx, buf) { + u32 idx = buf->vb.vb2_buf.index; + dma_addr_t paddr; +- void *vaddr = dma_alloc_coherent(dev, MMU_COMPRESS_HEADER_SIZE, +- &paddr, GFP_KERNEL); ++ void *vaddr = dma_alloc_coherent(dev, am21_size, &paddr, ++ GFP_KERNEL); + if (!vaddr) { +- codec_hevc_free_mmu_headers(sess, comm); ++ codec_hevc_free_fbc_buffers(sess, comm); + return -ENOMEM; + } + +- comm->mmu_header_vaddr[idx] = vaddr; +- comm->mmu_header_paddr[idx] = paddr; ++ comm->fbc_buffer_vaddr[idx] = vaddr; ++ comm->fbc_buffer_paddr[idx] = paddr; ++ } ++ ++ if (codec_hevc_use_mmu(revision, sess->pixfmt_cap, is_10bit) && ++ codec_hevc_use_downsample(sess->pixfmt_cap, is_10bit)) { ++ ret = codec_hevc_alloc_mmu_headers(sess, comm); ++ if (ret) { ++ codec_hevc_free_fbc_buffers(sess, comm); ++ return ret; ++ } + } + + return 0; +@@ -250,21 +286,24 @@ int codec_hevc_setup_buffers(struct amvdec_session *sess, + int is_10bit) + { + struct amvdec_core *core = sess->core; ++ struct device *dev = core->dev; + int ret; + +- if (codec_hevc_use_downsample(sess->pixfmt_cap, is_10bit)) { +- ret = codec_hevc_alloc_fbc_buffers(sess, comm); +- if (ret) +- return ret; ++ if (codec_hevc_use_mmu(core->platform->revision, ++ sess->pixfmt_cap, is_10bit)) { ++ comm->mmu_map_vaddr = dma_alloc_coherent(dev, MMU_MAP_SIZE, ++ &comm->mmu_map_paddr, ++ GFP_KERNEL); ++ if (!comm->mmu_map_vaddr) ++ return -ENOMEM; + } + + if (codec_hevc_use_mmu(core->platform->revision, +- sess->pixfmt_cap, is_10bit)) { +- ret = codec_hevc_alloc_mmu_headers(sess, comm); +- if (ret) { +- codec_hevc_free_fbc_buffers(sess, comm); +- return ret; +- } ++ sess->pixfmt_cap, is_10bit) || ++ codec_hevc_use_downsample(sess->pixfmt_cap, is_10bit)) { ++ ret = codec_hevc_alloc_fbc_buffers(sess, comm); ++ if (ret) ++ return ret; + } + + if (core->platform->revision == VDEC_REVISION_GXBB) +@@ -278,19 +317,24 @@ EXPORT_SYMBOL_GPL(codec_hevc_setup_buffers); + + void codec_hevc_fill_mmu_map(struct amvdec_session *sess, + struct codec_hevc_common *comm, +- struct vb2_buffer *vb) ++ struct vb2_buffer *vb, ++ u32 is_10bit) + { +- u32 size = amvdec_am21c_size(sess->width, sess->height); +- u32 nb_pages = size / PAGE_SIZE; ++ u32 use_mmu; ++ u32 size; ++ u32 nb_pages; + u32 *mmu_map = comm->mmu_map_vaddr; + u32 first_page; + u32 i; + +- if (sess->pixfmt_cap == V4L2_PIX_FMT_NV12M) +- first_page = comm->fbc_buffer_paddr[vb->index] >> PAGE_SHIFT; +- else +- first_page = vb2_dma_contig_plane_dma_addr(vb, 0) >> PAGE_SHIFT; ++ use_mmu = codec_hevc_use_mmu(sess->core->platform->revision, ++ sess->pixfmt_cap, is_10bit); ++ ++ size = amvdec_amfbc_size(sess->width, sess->height, is_10bit, ++ use_mmu); + ++ nb_pages = size / PAGE_SIZE; ++ first_page = comm->fbc_buffer_paddr[vb->index] >> PAGE_SHIFT; + for (i = 0; i < nb_pages; ++i) + mmu_map[i] = first_page + i; + } +diff --git a/drivers/staging/media/meson/vdec/codec_hevc_common.h b/drivers/staging/media/meson/vdec/codec_hevc_common.h +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/meson/vdec/codec_hevc_common.h ++++ b/drivers/staging/media/meson/vdec/codec_hevc_common.h +@@ -64,6 +64,7 @@ int codec_hevc_setup_buffers(struct amvdec_session *sess, + + void codec_hevc_fill_mmu_map(struct amvdec_session *sess, + struct codec_hevc_common *comm, +- struct vb2_buffer *vb); ++ struct vb2_buffer *vb, ++ u32 is_10bit); + + #endif +diff --git a/drivers/staging/media/meson/vdec/codec_vp9.c b/drivers/staging/media/meson/vdec/codec_vp9.c +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/meson/vdec/codec_vp9.c ++++ b/drivers/staging/media/meson/vdec/codec_vp9.c +@@ -458,12 +458,6 @@ struct codec_vp9 { + struct list_head ref_frames_list; + u32 frames_num; + +- /* In case of downsampling (decoding with FBC but outputting in NV12M), +- * we need to allocate additional buffers for FBC. +- */ +- void *fbc_buffer_vaddr[MAX_REF_PIC_NUM]; +- dma_addr_t fbc_buffer_paddr[MAX_REF_PIC_NUM]; +- + int ref_frame_map[REF_FRAMES]; + int next_ref_frame_map[REF_FRAMES]; + struct vp9_frame *frame_refs[REFS_PER_FRAME]; +@@ -901,11 +895,8 @@ static void codec_vp9_set_sao(struct amvdec_session *sess, + buf_y_paddr = + vb2_dma_contig_plane_dma_addr(vb, 0); + +- if (codec_hevc_use_fbc(sess->pixfmt_cap, vp9->is_10bit)) { +- val = amvdec_read_dos(core, HEVC_SAO_CTRL5) & ~0xff0200; +- amvdec_write_dos(core, HEVC_SAO_CTRL5, val); +- amvdec_write_dos(core, HEVC_CM_BODY_START_ADDR, buf_y_paddr); +- } ++ if (codec_hevc_use_fbc(sess->pixfmt_cap, vp9->is_10bit)) ++ amvdec_write_dos(core, HEVC_CM_BODY_START_ADDR, buf_y_paddr); + + if (sess->pixfmt_cap == V4L2_PIX_FMT_NV12M) { + buf_y_paddr = +@@ -920,8 +911,12 @@ static void codec_vp9_set_sao(struct amvdec_session *sess, + + if (codec_hevc_use_mmu(core->platform->revision, sess->pixfmt_cap, + vp9->is_10bit)) { +- amvdec_write_dos(core, HEVC_CM_HEADER_START_ADDR, +- vp9->common.mmu_header_paddr[vb->index]); ++ dma_addr_t header_adr; ++ if (codec_hevc_use_downsample(sess->pixfmt_cap, vp9->is_10bit)) ++ header_adr = vp9->common.mmu_header_paddr[vb->index]; ++ else ++ header_adr = vb2_dma_contig_plane_dma_addr(vb, 0); ++ amvdec_write_dos(core, HEVC_CM_HEADER_START_ADDR, header_adr); + /* use HEVC_CM_HEADER_START_ADDR */ + amvdec_write_dos_bits(core, HEVC_SAO_CTRL5, BIT(10)); + } +@@ -1148,9 +1143,13 @@ static void codec_vp9_set_mc(struct amvdec_session *sess, + { + struct amvdec_core *core = sess->core; + u32 scale = 0; ++ u32 use_mmu; + u32 sz; + int i; + ++ use_mmu = codec_hevc_use_mmu(core->platform->revision, ++ sess->pixfmt_cap, vp9->is_10bit); ++ + amvdec_write_dos(core, HEVCD_MPP_ANC_CANVAS_ACCCONFIG_ADDR, 1); + codec_vp9_set_refs(sess, vp9); + amvdec_write_dos(core, HEVCD_MPP_ANC_CANVAS_ACCCONFIG_ADDR, +@@ -1166,8 +1165,9 @@ static void codec_vp9_set_mc(struct amvdec_session *sess, + vp9->frame_refs[i]->height != vp9->height) + scale = 1; + +- sz = amvdec_am21c_body_size(vp9->frame_refs[i]->width, +- vp9->frame_refs[i]->height); ++ sz = amvdec_amfbc_body_size(vp9->frame_refs[i]->width, ++ vp9->frame_refs[i]->height, ++ vp9->is_10bit, use_mmu); + + amvdec_write_dos(core, VP9D_MPP_REFINFO_DATA, + vp9->frame_refs[i]->width); +@@ -1283,7 +1283,8 @@ static void codec_vp9_process_frame(struct amvdec_session *sess) + if (codec_hevc_use_mmu(core->platform->revision, sess->pixfmt_cap, + vp9->is_10bit)) + codec_hevc_fill_mmu_map(sess, &vp9->common, +- &vp9->cur_frame->vbuf->vb2_buf); ++ &vp9->cur_frame->vbuf->vb2_buf, ++ vp9->is_10bit); + + intra_only = param->p.show_frame ? 0 : param->p.intra_only; + +@@ -2130,7 +2131,8 @@ static irqreturn_t codec_vp9_threaded_isr(struct amvdec_session *sess) + + codec_vp9_fetch_rpm(sess); + if (codec_vp9_process_rpm(vp9)) { +- amvdec_src_change(sess, vp9->width, vp9->height, 16); ++ amvdec_src_change(sess, vp9->width, vp9->height, 16, ++ vp9->is_10bit ? 10 : 8); + + /* No frame is actually processed */ + vp9->cur_frame = NULL; +diff --git a/drivers/staging/media/meson/vdec/esparser.c b/drivers/staging/media/meson/vdec/esparser.c +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/meson/vdec/esparser.c ++++ b/drivers/staging/media/meson/vdec/esparser.c +@@ -319,6 +319,7 @@ esparser_queue(struct amvdec_session *sess, struct vb2_v4l2_buffer *vbuf) + if (esparser_vififo_get_free_space(sess) < payload_size || + atomic_read(&sess->esparser_queued_bufs) >= num_dst_bufs) + return -EAGAIN; ++ + } else if (esparser_vififo_get_free_space(sess) < payload_size) { + return -EAGAIN; + } +diff --git a/drivers/staging/media/meson/vdec/vdec.h b/drivers/staging/media/meson/vdec/vdec.h +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/meson/vdec/vdec.h ++++ b/drivers/staging/media/meson/vdec/vdec.h +@@ -243,6 +243,7 @@ struct amvdec_session { + u32 width; + u32 height; + u32 colorspace; ++ u32 bitdepth; + u8 ycbcr_enc; + u8 quantization; + u8 xfer_func; +diff --git a/drivers/staging/media/meson/vdec/vdec_helpers.c b/drivers/staging/media/meson/vdec/vdec_helpers.c +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/meson/vdec/vdec_helpers.c ++++ b/drivers/staging/media/meson/vdec/vdec_helpers.c +@@ -50,32 +50,40 @@ void amvdec_write_parser(struct amvdec_core *core, u32 reg, u32 val) + } + EXPORT_SYMBOL_GPL(amvdec_write_parser); + +-/* 4 KiB per 64x32 block */ +-u32 amvdec_am21c_body_size(u32 width, u32 height) ++/* AMFBC body is made out of 64x32 blocks with varying block size */ ++u32 amvdec_amfbc_body_size(u32 width, u32 height, u32 is_10bit, u32 use_mmu) + { + u32 width_64 = ALIGN(width, 64) / 64; + u32 height_32 = ALIGN(height, 32) / 32; ++ u32 blk_size = 4096; + +- return SZ_4K * width_64 * height_32; ++ if (!is_10bit) { ++ if (use_mmu) ++ blk_size = 3200; ++ else ++ blk_size = 3072; ++ } ++ ++ return blk_size * width_64 * height_32; + } +-EXPORT_SYMBOL_GPL(amvdec_am21c_body_size); ++EXPORT_SYMBOL_GPL(amvdec_amfbc_body_size); + + /* 32 bytes per 128x64 block */ +-u32 amvdec_am21c_head_size(u32 width, u32 height) ++u32 amvdec_amfbc_head_size(u32 width, u32 height) + { + u32 width_128 = ALIGN(width, 128) / 128; + u32 height_64 = ALIGN(height, 64) / 64; + + return 32 * width_128 * height_64; + } +-EXPORT_SYMBOL_GPL(amvdec_am21c_head_size); ++EXPORT_SYMBOL_GPL(amvdec_amfbc_head_size); + +-u32 amvdec_am21c_size(u32 width, u32 height) ++u32 amvdec_amfbc_size(u32 width, u32 height, u32 is_10bit, u32 use_mmu) + { +- return ALIGN(amvdec_am21c_body_size(width, height) + +- amvdec_am21c_head_size(width, height), SZ_64K); ++ return ALIGN(amvdec_amfbc_body_size(width, height, is_10bit, use_mmu) + ++ amvdec_amfbc_head_size(width, height), SZ_64K); + } +-EXPORT_SYMBOL_GPL(amvdec_am21c_size); ++EXPORT_SYMBOL_GPL(amvdec_amfbc_size); + + static int canvas_alloc(struct amvdec_session *sess, u8 *canvas_id) + { +@@ -440,7 +448,7 @@ void amvdec_set_par_from_dar(struct amvdec_session *sess, + EXPORT_SYMBOL_GPL(amvdec_set_par_from_dar); + + void amvdec_src_change(struct amvdec_session *sess, u32 width, +- u32 height, u32 dpb_size) ++ u32 height, u32 dpb_size, u32 bitdepth) + { + static const struct v4l2_event ev = { + .type = V4L2_EVENT_SOURCE_CHANGE, +@@ -448,25 +456,27 @@ void amvdec_src_change(struct amvdec_session *sess, u32 width, + + v4l2_ctrl_s_ctrl(sess->ctrl_min_buf_capture, dpb_size); + ++ sess->bitdepth = bitdepth; ++ + /* + * Check if the capture queue is already configured well for our +- * usecase. If so, keep decoding with it and do not send the event ++ * usecase. If so, keep decoding with it. + */ + if (sess->streamon_cap && + sess->width == width && + sess->height == height && + dpb_size <= sess->num_dst_bufs) { + sess->fmt_out->codec_ops->resume(sess); +- return; +- } ++ } else { ++ sess->status = STATUS_NEEDS_RESUME; ++ sess->changed_format = 0; ++ } + +- sess->changed_format = 0; + sess->width = width; + sess->height = height; +- sess->status = STATUS_NEEDS_RESUME; + +- dev_dbg(sess->core->dev, "Res. changed (%ux%u), DPB size %u\n", +- width, height, dpb_size); ++ dev_dbg(sess->core->dev, "Res. changed (%ux%u), DPB %u, bitdepth %u\n", ++ width, height, dpb_size, bitdepth); + v4l2_event_queue_fh(&sess->fh, &ev); + } + EXPORT_SYMBOL_GPL(amvdec_src_change); +diff --git a/drivers/staging/media/meson/vdec/vdec_helpers.h b/drivers/staging/media/meson/vdec/vdec_helpers.h +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/meson/vdec/vdec_helpers.h ++++ b/drivers/staging/media/meson/vdec/vdec_helpers.h +@@ -27,9 +27,10 @@ void amvdec_clear_dos_bits(struct amvdec_core *core, u32 reg, u32 val); + u32 amvdec_read_parser(struct amvdec_core *core, u32 reg); + void amvdec_write_parser(struct amvdec_core *core, u32 reg, u32 val); + +-u32 amvdec_am21c_body_size(u32 width, u32 height); +-u32 amvdec_am21c_head_size(u32 width, u32 height); +-u32 amvdec_am21c_size(u32 width, u32 height); ++/* Helpers for the Amlogic compressed framebuffer format */ ++u32 amvdec_amfbc_body_size(u32 width, u32 height, u32 is_10bit, u32 use_mmu); ++u32 amvdec_amfbc_head_size(u32 width, u32 height); ++u32 amvdec_amfbc_size(u32 width, u32 height, u32 is_10bit, u32 use_mmu); + + /** + * amvdec_dst_buf_done_idx() - Signal that a buffer is done decoding +@@ -77,9 +78,10 @@ void amvdec_set_par_from_dar(struct amvdec_session *sess, + * @width: picture width detected by the hardware + * @height: picture height detected by the hardware + * @dpb_size: Decoded Picture Buffer size (= amount of buffers for decoding) ++ * @bitdepth: Bit depth (usually 10 or 8) of the coded content + */ + void amvdec_src_change(struct amvdec_session *sess, u32 width, +- u32 height, u32 dpb_size); ++ u32 height, u32 dpb_size, u32 bitdepth); + + /** + * amvdec_abort() - Abort the current decoding session +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-meson64-overlays.patch b/patch/kernel/archive/meson64-6.13/general-meson64-overlays.patch new file mode 100644 index 000000000..43c434b22 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-meson64-overlays.patch @@ -0,0 +1,27 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Zhang Ning <832666+zhangn1985@users.noreply.github.com> +Date: Thu, 19 Sep 2019 16:20:31 +0800 +Subject: general: meson64 overlays + +Signed-off-by: Zhang Ning <832666+zhangn1985@users.noreply.github.com> +--- + scripts/Makefile.lib | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib +index 111111111111..222222222222 100644 +--- a/scripts/Makefile.lib ++++ b/scripts/Makefile.lib +@@ -75,6 +75,9 @@ always-y += $(hostprogs-always-y) $(hostprogs-always-m) + userprogs += $(userprogs-always-y) $(userprogs-always-m) + always-y += $(userprogs-always-y) $(userprogs-always-m) + ++# Overlay targets ++extra-y += $(dtbo-y) $(scr-y) $(dtbotxt-y) ++ + # Add subdir path + + ifneq ($(obj),.) +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-si2168-fix-cmd-timeout.patch b/patch/kernel/archive/meson64-6.13/general-si2168-fix-cmd-timeout.patch new file mode 100644 index 000000000..5712b3ac8 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-si2168-fix-cmd-timeout.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Koumes +Date: Sat, 1 Jun 2019 21:20:26 +0000 +Subject: si2168: fix cmd timeout + +Some demuxer si2168 commands may take 130-140 ms. +(DVB-T/T2 tuner MyGica T230C v2). +Details: https://github.com/CoreELEC/CoreELEC/pull/208 +--- + drivers/media/dvb-frontends/si2168.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c +index 111111111111..222222222222 100644 +--- a/drivers/media/dvb-frontends/si2168.c ++++ b/drivers/media/dvb-frontends/si2168.c +@@ -40,7 +40,7 @@ static int si2168_cmd_execute(struct i2c_client *client, struct si2168_cmd *cmd) + + if (cmd->rlen) { + /* wait cmd execution terminate */ +- #define TIMEOUT 70 ++ #define TIMEOUT 200 + timeout = jiffies + msecs_to_jiffies(TIMEOUT); + while (!time_after(jiffies, timeout)) { + ret = i2c_master_recv(client, cmd->args, cmd->rlen); +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-soc-0001-soc-amlogic-meson-gx-socinfo-move-common-code-to-hea.patch b/patch/kernel/archive/meson64-6.13/general-soc-0001-soc-amlogic-meson-gx-socinfo-move-common-code-to-hea.patch new file mode 100644 index 000000000..676805b8c --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-soc-0001-soc-amlogic-meson-gx-socinfo-move-common-code-to-hea.patch @@ -0,0 +1,359 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Viacheslav Bocharov +Date: Mon, 18 Nov 2024 15:36:06 +0300 +Subject: soc: amlogic: meson-gx-socinfo: move common code to header file + +Move common constants and inline functions from meson-gx-socinfo driver +to header file. Create new structures for store meson64 cpu_id and chip_id. + +Signed-off-by: Viacheslav Bocharov +--- + drivers/soc/amlogic/meson-gx-socinfo-internal.h | 132 ++++++++ + drivers/soc/amlogic/meson-gx-socinfo.c | 150 +--------- + 2 files changed, 147 insertions(+), 135 deletions(-) + +diff --git a/drivers/soc/amlogic/meson-gx-socinfo-internal.h b/drivers/soc/amlogic/meson-gx-socinfo-internal.h +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/drivers/soc/amlogic/meson-gx-socinfo-internal.h +@@ -0,0 +1,132 @@ ++/* SPDX-License-Identifier: GPL-2.0+ */ ++/* ++ * Copyright (c) 2017 BayLibre, SAS ++ * Copyright (c) 2024 JetHome ++ * Author: Neil Armstrong ++ * Author: Viacheslav Bocharov ++ * ++ */ ++ ++#ifndef _MESON_GX_SOCINFO_INTERNAL_H_ ++#define _MESON_GX_SOCINFO_INTERNAL_H_ ++ ++#include ++ ++#define AO_SEC_SD_CFG8 0xe0 ++#define AO_SEC_SOCINFO_OFFSET AO_SEC_SD_CFG8 ++ ++union meson_cpu_id { ++ struct { // cpu_id v1 ++ u32 layout_ver:4; ++ u32 reserved:4; ++ u32 chip_rev:8; ++ u32 pack_id:8; ++ u32 major_id:8; ++ } v1; ++ struct { // cpu_id v2 ++ u32 major_id:8; ++ u32 chip_rev:8; ++ u32 pack_id:8; ++ u32 reserved:4; ++ u32 layout_ver:4; ++ } v2; ++ u32 raw; ++}; ++ ++struct meson_sm_chip_id { ++ u32 version; ++ union meson_cpu_id cpu_id; ++ u8 serial[12]; ++}; ++ ++static const struct meson_gx_soc_id { ++ const char *name; ++ unsigned int id; ++} soc_ids[] = { ++ { "GXBB", 0x1f }, ++ { "GXTVBB", 0x20 }, ++ { "GXL", 0x21 }, ++ { "GXM", 0x22 }, ++ { "TXL", 0x23 }, ++ { "TXLX", 0x24 }, ++ { "AXG", 0x25 }, ++ { "GXLX", 0x26 }, ++ { "TXHD", 0x27 }, ++ { "G12A", 0x28 }, ++ { "G12B", 0x29 }, ++ { "SM1", 0x2b }, ++ { "A1", 0x2c }, ++ { "T7", 0x36 }, ++ { "S4", 0x37 }, ++ { "A5", 0x3c }, ++ { "C3", 0x3d }, ++ { "A4", 0x40 }, ++}; ++ ++static const struct meson_gx_package_id { ++ const char *name; ++ unsigned int major_id; ++ unsigned int pack_id; ++ unsigned int pack_mask; ++} soc_packages[] = { ++ { "S905", 0x1f, 0, 0x20 }, /* pack_id != 0x20 */ ++ { "S905H", 0x1f, 0x3, 0xf }, /* pack_id & 0xf == 0x3 */ ++ { "S905M", 0x1f, 0x20, 0xf0 }, /* pack_id == 0x20 */ ++ { "S905D", 0x21, 0, 0xf0 }, ++ { "S905X", 0x21, 0x80, 0xf0 }, ++ { "S905W", 0x21, 0xa0, 0xf0 }, ++ { "S905L", 0x21, 0xc0, 0xf0 }, ++ { "S905M2", 0x21, 0xe0, 0xf0 }, ++ { "S805X", 0x21, 0x30, 0xf0 }, ++ { "S805Y", 0x21, 0xb0, 0xf0 }, ++ { "S912", 0x22, 0, 0x0 }, /* Only S912 is known for GXM */ ++ { "962X", 0x24, 0x10, 0xf0 }, ++ { "962E", 0x24, 0x20, 0xf0 }, ++ { "A113X", 0x25, 0x37, 0xff }, ++ { "A113X", 0x25, 0x43, 0xff }, ++ { "A113D", 0x25, 0x22, 0xff }, ++ { "S905L", 0x26, 0, 0x0 }, ++ { "S905D2", 0x28, 0x10, 0xf0 }, ++ { "S905Y2", 0x28, 0x30, 0xf0 }, ++ { "S905X2", 0x28, 0x40, 0xf0 }, ++ { "A311D", 0x29, 0x10, 0xf0 }, ++ { "S922X", 0x29, 0x40, 0xf0 }, ++ { "S905D3", 0x2b, 0x4, 0xf5 }, ++ { "S905X3", 0x2b, 0x5, 0xf5 }, ++ { "S905X3", 0x2b, 0x10, 0x3f }, ++ { "S905D3", 0x2b, 0x30, 0x3f }, ++ { "A113L", 0x2c, 0x0, 0xf8 }, ++ { "S805X2", 0x37, 0x2, 0xf }, ++ { "C308L", 0x3d, 0x1, 0xf }, ++ { "A311D2", 0x36, 0x1, 0xf }, ++ { "A113X2", 0x3c, 0x1, 0xf }, ++ { "A113L2", 0x40, 0x1, 0xf }, ++}; ++ ++static inline const char *socinfo_v1_to_package_id(union meson_cpu_id socinfo) ++{ ++ int i; ++ ++ for (i = 0 ; i < ARRAY_SIZE(soc_packages) ; ++i) { ++ if (soc_packages[i].major_id == socinfo.v1.major_id && ++ soc_packages[i].pack_id == ++ (socinfo.v1.pack_id & soc_packages[i].pack_mask)) ++ return soc_packages[i].name; ++ } ++ ++ return "Unknown"; ++} ++ ++static inline const char *socinfo_v1_to_soc_id(union meson_cpu_id socinfo) ++{ ++ int i; ++ ++ for (i = 0 ; i < ARRAY_SIZE(soc_ids) ; ++i) { ++ if (soc_ids[i].id == socinfo.v1.major_id) ++ return soc_ids[i].name; ++ } ++ ++ return "Unknown"; ++} ++ ++#endif /* _MESON_GX_SOCINFO_INTERNAL_H_ */ +diff --git a/drivers/soc/amlogic/meson-gx-socinfo.c b/drivers/soc/amlogic/meson-gx-socinfo.c +index 111111111111..222222222222 100644 +--- a/drivers/soc/amlogic/meson-gx-socinfo.c ++++ b/drivers/soc/amlogic/meson-gx-socinfo.c +@@ -1,8 +1,8 @@ ++// SPDX-License-Identifier: GPL-2.0+ + /* + * Copyright (c) 2017 BayLibre, SAS + * Author: Neil Armstrong + * +- * SPDX-License-Identifier: GPL-2.0+ + */ + + #include +@@ -12,130 +12,10 @@ + #include + #include + #include +-#include + #include + #include + +-#define AO_SEC_SD_CFG8 0xe0 +-#define AO_SEC_SOCINFO_OFFSET AO_SEC_SD_CFG8 +- +-#define SOCINFO_MAJOR GENMASK(31, 24) +-#define SOCINFO_PACK GENMASK(23, 16) +-#define SOCINFO_MINOR GENMASK(15, 8) +-#define SOCINFO_MISC GENMASK(7, 0) +- +-static const struct meson_gx_soc_id { +- const char *name; +- unsigned int id; +-} soc_ids[] = { +- { "GXBB", 0x1f }, +- { "GXTVBB", 0x20 }, +- { "GXL", 0x21 }, +- { "GXM", 0x22 }, +- { "TXL", 0x23 }, +- { "TXLX", 0x24 }, +- { "AXG", 0x25 }, +- { "GXLX", 0x26 }, +- { "TXHD", 0x27 }, +- { "G12A", 0x28 }, +- { "G12B", 0x29 }, +- { "SM1", 0x2b }, +- { "A1", 0x2c }, +- { "T7", 0x36 }, +- { "S4", 0x37 }, +- { "A5", 0x3c }, +- { "C3", 0x3d }, +- { "A4", 0x40 }, +-}; +- +-static const struct meson_gx_package_id { +- const char *name; +- unsigned int major_id; +- unsigned int pack_id; +- unsigned int pack_mask; +-} soc_packages[] = { +- { "S905", 0x1f, 0, 0x20 }, /* pack_id != 0x20 */ +- { "S905H", 0x1f, 0x3, 0xf }, /* pack_id & 0xf == 0x3 */ +- { "S905M", 0x1f, 0x20, 0xf0 }, /* pack_id == 0x20 */ +- { "S905D", 0x21, 0, 0xf0 }, +- { "S905X", 0x21, 0x80, 0xf0 }, +- { "S905W", 0x21, 0xa0, 0xf0 }, +- { "S905L", 0x21, 0xc0, 0xf0 }, +- { "S905M2", 0x21, 0xe0, 0xf0 }, +- { "S805X", 0x21, 0x30, 0xf0 }, +- { "S805Y", 0x21, 0xb0, 0xf0 }, +- { "S912", 0x22, 0, 0x0 }, /* Only S912 is known for GXM */ +- { "962X", 0x24, 0x10, 0xf0 }, +- { "962E", 0x24, 0x20, 0xf0 }, +- { "A113X", 0x25, 0x37, 0xff }, +- { "A113X", 0x25, 0x43, 0xff }, +- { "A113D", 0x25, 0x22, 0xff }, +- { "S905L", 0x26, 0, 0x0 }, +- { "S905D2", 0x28, 0x10, 0xf0 }, +- { "S905Y2", 0x28, 0x30, 0xf0 }, +- { "S905X2", 0x28, 0x40, 0xf0 }, +- { "A311D", 0x29, 0x10, 0xf0 }, +- { "S922X", 0x29, 0x40, 0xf0 }, +- { "S905D3", 0x2b, 0x4, 0xf5 }, +- { "S905X3", 0x2b, 0x5, 0xf5 }, +- { "S905X3", 0x2b, 0x10, 0x3f }, +- { "S905D3", 0x2b, 0x30, 0x3f }, +- { "A113L", 0x2c, 0x0, 0xf8 }, +- { "S805X2", 0x37, 0x2, 0xf }, +- { "C308L", 0x3d, 0x1, 0xf }, +- { "A311D2", 0x36, 0x1, 0xf }, +- { "A113X2", 0x3c, 0x1, 0xf }, +- { "A113L2", 0x40, 0x1, 0xf }, +-}; +- +-static inline unsigned int socinfo_to_major(u32 socinfo) +-{ +- return FIELD_GET(SOCINFO_MAJOR, socinfo); +-} +- +-static inline unsigned int socinfo_to_minor(u32 socinfo) +-{ +- return FIELD_GET(SOCINFO_MINOR, socinfo); +-} +- +-static inline unsigned int socinfo_to_pack(u32 socinfo) +-{ +- return FIELD_GET(SOCINFO_PACK, socinfo); +-} +- +-static inline unsigned int socinfo_to_misc(u32 socinfo) +-{ +- return FIELD_GET(SOCINFO_MISC, socinfo); +-} +- +-static const char *socinfo_to_package_id(u32 socinfo) +-{ +- unsigned int pack = socinfo_to_pack(socinfo); +- unsigned int major = socinfo_to_major(socinfo); +- int i; +- +- for (i = 0 ; i < ARRAY_SIZE(soc_packages) ; ++i) { +- if (soc_packages[i].major_id == major && +- soc_packages[i].pack_id == +- (pack & soc_packages[i].pack_mask)) +- return soc_packages[i].name; +- } +- +- return "Unknown"; +-} +- +-static const char *socinfo_to_soc_id(u32 socinfo) +-{ +- unsigned int id = socinfo_to_major(socinfo); +- int i; +- +- for (i = 0 ; i < ARRAY_SIZE(soc_ids) ; ++i) { +- if (soc_ids[i].id == id) +- return soc_ids[i].name; +- } +- +- return "Unknown"; +-} ++#include "meson-gx-socinfo-internal.h" + + static int __init meson_gx_socinfo_init(void) + { +@@ -143,7 +23,7 @@ static int __init meson_gx_socinfo_init(void) + struct soc_device *soc_dev; + struct device_node *np; + struct regmap *regmap; +- unsigned int socinfo; ++ union meson_cpu_id socinfo; + struct device *dev; + int ret; + +@@ -172,11 +52,11 @@ static int __init meson_gx_socinfo_init(void) + return -ENODEV; + } + +- ret = regmap_read(regmap, AO_SEC_SOCINFO_OFFSET, &socinfo); ++ ret = regmap_read(regmap, AO_SEC_SOCINFO_OFFSET, &socinfo.raw); + if (ret < 0) + return ret; + +- if (!socinfo) { ++ if (!socinfo.raw) { + pr_err("%s: invalid chipid value\n", __func__); + return -EINVAL; + } +@@ -187,13 +67,13 @@ static int __init meson_gx_socinfo_init(void) + + soc_dev_attr->family = "Amlogic Meson"; + soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%x:%x - %x:%x", +- socinfo_to_major(socinfo), +- socinfo_to_minor(socinfo), +- socinfo_to_pack(socinfo), +- socinfo_to_misc(socinfo)); ++ socinfo.v1.major_id, ++ socinfo.v1.chip_rev, ++ socinfo.v1.pack_id, ++ (socinfo.v1.reserved<<4) + socinfo.v1.layout_ver); + soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%s (%s)", +- socinfo_to_soc_id(socinfo), +- socinfo_to_package_id(socinfo)); ++ socinfo_v1_to_soc_id(socinfo), ++ socinfo_v1_to_package_id(socinfo)); + + soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR(soc_dev)) { +@@ -206,10 +86,10 @@ static int __init meson_gx_socinfo_init(void) + + dev_info(dev, "Amlogic Meson %s Revision %x:%x (%x:%x) Detected\n", + soc_dev_attr->soc_id, +- socinfo_to_major(socinfo), +- socinfo_to_minor(socinfo), +- socinfo_to_pack(socinfo), +- socinfo_to_misc(socinfo)); ++ socinfo.v1.major_id, ++ socinfo.v1.chip_rev, ++ socinfo.v1.pack_id, ++ (socinfo.v1.reserved<<4) + socinfo.v1.layout_ver); + + return 0; + } +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-soc-0002-soc-amlogic-meson-gx-socinfo-sm-Add-Amlogic-secure-m.patch b/patch/kernel/archive/meson64-6.13/general-soc-0002-soc-amlogic-meson-gx-socinfo-sm-Add-Amlogic-secure-m.patch new file mode 100644 index 000000000..8d45c0f9f --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-soc-0002-soc-amlogic-meson-gx-socinfo-sm-Add-Amlogic-secure-m.patch @@ -0,0 +1,277 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Viacheslav Bocharov +Date: Mon, 18 Nov 2024 15:36:49 +0300 +Subject: soc: amlogic: meson-gx-socinfo-sm: Add Amlogic secure-monitor SoC + Information driver + +Amlogic SoCs have a SoC information secure-monitor call for SoC type, +package type, revision information and chipid. +This patchs adds support for secure-monitor call decoding and exposing +with the SoC bus infrastructure in addition to the previous SoC +Information driver. + +- rpardini: hack to fix "initialization of 'void (*)(struct platform_device *)' from incompatible pointer type 'int (*)(struct platform_device *)'" + +Signed-off-by: Viacheslav Bocharov +--- + drivers/soc/amlogic/Kconfig | 10 + + drivers/soc/amlogic/Makefile | 1 + + drivers/soc/amlogic/meson-gx-socinfo-internal.h | 14 +- + drivers/soc/amlogic/meson-gx-socinfo-sm.c | 190 ++++++++++ + 4 files changed, 211 insertions(+), 4 deletions(-) + +diff --git a/drivers/soc/amlogic/Kconfig b/drivers/soc/amlogic/Kconfig +index 111111111111..222222222222 100644 +--- a/drivers/soc/amlogic/Kconfig ++++ b/drivers/soc/amlogic/Kconfig +@@ -26,6 +26,16 @@ config MESON_GX_SOCINFO + Say yes to support decoding of Amlogic Meson GX SoC family + information about the type, package and version. + ++config MESON_GX_SOCINFO_SM ++ bool "Amlogic Meson GX SoC Information driver via Secure Monitor" ++ depends on (ARM64 && ARCH_MESON || COMPILE_TEST) && MESON_SM=y ++ default ARCH_MESON && MESON_SM ++ select SOC_BUS ++ help ++ Say yes to support decoding of Amlogic Meson GX SoC family ++ information about the type, package and version via secure ++ monitor call. ++ + config MESON_MX_SOCINFO + bool "Amlogic Meson MX SoC Information driver" + depends on (ARM && ARCH_MESON) || COMPILE_TEST +diff --git a/drivers/soc/amlogic/Makefile b/drivers/soc/amlogic/Makefile +index 111111111111..222222222222 100644 +--- a/drivers/soc/amlogic/Makefile ++++ b/drivers/soc/amlogic/Makefile +@@ -2,4 +2,5 @@ + obj-$(CONFIG_MESON_CANVAS) += meson-canvas.o + obj-$(CONFIG_MESON_CLK_MEASURE) += meson-clk-measure.o + obj-$(CONFIG_MESON_GX_SOCINFO) += meson-gx-socinfo.o ++obj-$(CONFIG_MESON_GX_SOCINFO_SM) += meson-gx-socinfo-sm.o + obj-$(CONFIG_MESON_MX_SOCINFO) += meson-mx-socinfo.o +diff --git a/drivers/soc/amlogic/meson-gx-socinfo-internal.h b/drivers/soc/amlogic/meson-gx-socinfo-internal.h +index 111111111111..222222222222 100644 +--- a/drivers/soc/amlogic/meson-gx-socinfo-internal.h ++++ b/drivers/soc/amlogic/meson-gx-socinfo-internal.h +@@ -33,10 +33,16 @@ union meson_cpu_id { + u32 raw; + }; + +-struct meson_sm_chip_id { +- u32 version; +- union meson_cpu_id cpu_id; +- u8 serial[12]; ++union meson_sm_chip_id { ++ struct { // cpu_id v2 ++ u32 version; ++ union meson_cpu_id cpu_id; ++ u8 serial[12]; ++ } v2; ++ struct { // raw ++ u32 version; ++ u8 buf[12 + sizeof(union meson_cpu_id)]; ++ } raw; + }; + + static const struct meson_gx_soc_id { +diff --git a/drivers/soc/amlogic/meson-gx-socinfo-sm.c b/drivers/soc/amlogic/meson-gx-socinfo-sm.c +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/drivers/soc/amlogic/meson-gx-socinfo-sm.c +@@ -0,0 +1,190 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * Copyright (c) 2017 BayLibre, SAS ++ * Copyright (c) 2024 JetHome ++ * Author: Neil Armstrong ++ * Author: Viacheslav Bocharov ++ * ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++ ++#include "meson-gx-socinfo-internal.h" ++ ++static char *socinfo_get_chipid(struct device *dev, struct meson_sm_firmware *fw, ++ union meson_cpu_id *socinfo) ++{ ++ char *buf; ++ union meson_sm_chip_id *id_buf; ++ int ret; ++ ++ id_buf = kzalloc(sizeof(union meson_sm_chip_id)+1, GFP_KERNEL); ++ if (!id_buf) ++ return NULL; ++ ++ ret = meson_sm_call_read(fw, id_buf, sizeof(union meson_sm_chip_id), SM_GET_CHIP_ID, ++ 2, 0, 0, 0, 0); ++ if (ret < 0) { ++ kfree(id_buf); ++ return NULL; ++ } ++ dev_info(dev, "got sm version call %i\n", id_buf->raw.version); ++ ++ if (id_buf->raw.version != 2) { ++ ++ u8 tmp; ++ /** ++ * Legacy 12-byte chip ID read out, transform data ++ * to expected order format ++ */ ++ memmove((void *)&id_buf->v2.serial, (void *)&id_buf->raw.buf, 12); ++ for (int i = 0; i < 6; i++) { ++ tmp = id_buf->v2.serial[i]; ++ id_buf->v2.serial[i] = id_buf->v2.serial[11 - i]; ++ id_buf->v2.serial[11 - i] = tmp; ++ } ++ id_buf->v2.cpu_id.v2.major_id = socinfo->v1.major_id; ++ id_buf->v2.cpu_id.v2.pack_id = socinfo->v1.pack_id; ++ id_buf->v2.cpu_id.v2.chip_rev = socinfo->v1.chip_rev; ++ id_buf->v2.cpu_id.v2.reserved = socinfo->v1.reserved; ++ id_buf->v2.cpu_id.v2.layout_ver = socinfo->v1.layout_ver; ++ } else { ++ /** ++ * rewrite socinfo from regmap with value from secure monitor call ++ */ ++ socinfo->v1.major_id = id_buf->v2.cpu_id.v2.major_id; ++ socinfo->v1.pack_id = id_buf->v2.cpu_id.v2.pack_id; ++ socinfo->v1.chip_rev = id_buf->v2.cpu_id.v2.chip_rev; ++ socinfo->v1.reserved = id_buf->v2.cpu_id.v2.reserved; ++ socinfo->v1.layout_ver = id_buf->v2.cpu_id.v2.layout_ver; ++ } ++ ++ buf = devm_kasprintf(dev, GFP_KERNEL, "%4phN%12phN", &(id_buf->v2.cpu_id), ++ &(id_buf->v2.serial)); ++ ++ kfree(id_buf); ++ ++ return buf; ++} ++ ++static int meson_gx_socinfo_sm_probe(struct platform_device *pdev) ++{ ++ struct soc_device_attribute *soc_dev_attr; ++ struct soc_device *soc_dev; ++ struct device_node *sm_np; ++ struct meson_sm_firmware *fw; ++ struct regmap *regmap; ++ union meson_cpu_id socinfo; ++ struct device *dev; ++ int ret; ++ ++ /* check if chip-id is available */ ++ if (!of_property_read_bool(pdev->dev.of_node, "amlogic,has-chip-id")) ++ return -ENODEV; ++ ++ /* node should be a syscon */ ++ regmap = syscon_node_to_regmap(pdev->dev.of_node); ++ if (IS_ERR(regmap)) ++ return dev_err_probe(&pdev->dev, PTR_ERR(regmap), "failed to get regmap\n"); ++ ++ sm_np = of_parse_phandle(pdev->dev.of_node, "secure-monitor", 0); ++ if (!sm_np) { ++ dev_err(&pdev->dev, "no secure-monitor node found\n"); ++ return -EINVAL; ++ } ++ ++ fw = meson_sm_get(sm_np); ++ of_node_put(sm_np); ++ if (!fw) { ++ dev_dbg(&pdev->dev, "secure-monitor device not ready, probe later\n"); ++ return -EPROBE_DEFER; ++ } ++ ++ ret = regmap_read(regmap, AO_SEC_SOCINFO_OFFSET, &socinfo.raw); ++ if (ret < 0) ++ return ret; ++ ++ if (!socinfo.raw) { ++ dev_err(&pdev->dev, "invalid regmap chipid value\n"); ++ return -EINVAL; ++ } ++ ++ soc_dev_attr = devm_kzalloc(&pdev->dev, sizeof(*soc_dev_attr), ++ GFP_KERNEL); ++ if (!soc_dev_attr) ++ return -ENOMEM; ++ ++ soc_dev_attr->serial_number = socinfo_get_chipid(&pdev->dev, fw, &socinfo); ++ ++ soc_dev_attr->family = "Amlogic Meson"; ++ soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%x:%x - %x:%x", ++ socinfo.v1.major_id, ++ socinfo.v1.chip_rev, ++ socinfo.v1.pack_id, ++ (socinfo.v1.reserved<<4) + socinfo.v1.layout_ver); ++ soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%s (%s)", ++ socinfo_v1_to_soc_id(socinfo), ++ socinfo_v1_to_package_id(socinfo)); ++ ++ soc_dev = soc_device_register(soc_dev_attr); ++ ++ ++ if (IS_ERR(soc_dev)) { ++ kfree(soc_dev_attr->revision); ++ kfree_const(soc_dev_attr->soc_id); ++ return PTR_ERR(soc_dev); ++ } ++ ++ dev = soc_device_to_device(soc_dev); ++ platform_set_drvdata(pdev, soc_dev); ++ ++ dev_info(dev, "Amlogic Meson %s Revision %x:%x (%x:%x) Detected (SM)\n", ++ soc_dev_attr->soc_id, ++ socinfo.v1.major_id, ++ socinfo.v1.chip_rev, ++ socinfo.v1.pack_id, ++ (socinfo.v1.reserved<<4) + socinfo.v1.layout_ver); ++ ++ return PTR_ERR_OR_ZERO(dev); ++} ++ ++ ++static void meson_gx_socinfo_sm_remove(struct platform_device *pdev) ++{ ++ struct soc_device *soc_dev = platform_get_drvdata(pdev); ++ ++ soc_device_unregister(soc_dev); ++ // return 0; ++} ++ ++static const struct of_device_id meson_gx_socinfo_match[] = { ++ { .compatible = "amlogic,meson-gx-ao-secure", }, ++ { /* sentinel */ }, ++}; ++MODULE_DEVICE_TABLE(of, meson_gx_socinfo_match); ++ ++static struct platform_driver meson_gx_socinfo_driver = { ++ .probe = meson_gx_socinfo_sm_probe, ++ .remove = meson_gx_socinfo_sm_remove, ++ .driver = { ++ .name = "meson-gx-socinfo-sm", ++ .of_match_table = meson_gx_socinfo_match, ++ }, ++}; ++ ++ ++module_platform_driver(meson_gx_socinfo_driver); ++ ++MODULE_AUTHOR("Viacheslav Bocharov "); ++MODULE_DESCRIPTION("Amlogic Meson GX SOC SM driver"); ++MODULE_LICENSE("GPL"); +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-soc-0003-dt-bindings-arm-amlogic-amlogic-meson-gx-ao-secure-a.patch b/patch/kernel/archive/meson64-6.13/general-soc-0003-dt-bindings-arm-amlogic-amlogic-meson-gx-ao-secure-a.patch new file mode 100644 index 000000000..71f842c1d --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-soc-0003-dt-bindings-arm-amlogic-amlogic-meson-gx-ao-secure-a.patch @@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Viacheslav Bocharov +Date: Tue, 4 Jun 2024 17:54:53 +0300 +Subject: dt-bindings: arm: amlogic: amlogic,meson-gx-ao-secure: add + secure-monitor property + +Add secure-monitor property to schema for meson-gx-socinfo-sm driver. + +Signed-off-by: Viacheslav Bocharov +--- + Documentation/devicetree/bindings/arm/amlogic/amlogic,meson-gx-ao-secure.yaml | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/Documentation/devicetree/bindings/arm/amlogic/amlogic,meson-gx-ao-secure.yaml b/Documentation/devicetree/bindings/arm/amlogic/amlogic,meson-gx-ao-secure.yaml +index 111111111111..222222222222 100644 +--- a/Documentation/devicetree/bindings/arm/amlogic/amlogic,meson-gx-ao-secure.yaml ++++ b/Documentation/devicetree/bindings/arm/amlogic/amlogic,meson-gx-ao-secure.yaml +@@ -40,6 +40,10 @@ properties: + reg: + maxItems: 1 + ++ secure-monitor: ++ description: phandle to the secure-monitor node ++ $ref: /schemas/types.yaml#/definitions/phandle ++ + amlogic,has-chip-id: + description: | + A firmware register encodes the SoC type, package and revision +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-soc-0004-arm64-dts-meson-add-dts-links-to-secure-monitor-for-.patch b/patch/kernel/archive/meson64-6.13/general-soc-0004-arm64-dts-meson-add-dts-links-to-secure-monitor-for-.patch new file mode 100644 index 000000000..04055b61b --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-soc-0004-arm64-dts-meson-add-dts-links-to-secure-monitor-for-.patch @@ -0,0 +1,68 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Viacheslav Bocharov +Date: Thu, 14 Mar 2024 09:59:54 +0300 +Subject: arm64: dts: meson: add dts links to secure-monitor for soc driver in + a1, axg, gx, g12 + +Add links to secure-monitor in soc driver section for A1, AXG, GX, G12 +Amlogic family for use with meson-socinfo-sm driver. + +Signed-off-by: Viacheslav Bocharov +--- + arch/arm64/boot/dts/amlogic/meson-a1.dtsi | 1 + + arch/arm64/boot/dts/amlogic/meson-axg.dtsi | 1 + + arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi | 1 + + arch/arm64/boot/dts/amlogic/meson-gx.dtsi | 1 + + 4 files changed, 4 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-a1.dtsi b/arch/arm64/boot/dts/amlogic/meson-a1.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-a1.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-a1.dtsi +@@ -420,6 +420,7 @@ hwrng: rng@5118 { + sec_AO: ao-secure@5a20 { + compatible = "amlogic,meson-gx-ao-secure", "syscon"; + reg = <0x0 0x5a20 0x0 0x140>; ++ secure-monitor = <&sm>; + amlogic,has-chip-id; + }; + +diff --git a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi +@@ -1690,6 +1690,7 @@ mux { + sec_AO: ao-secure@140 { + compatible = "amlogic,meson-gx-ao-secure", "syscon"; + reg = <0x0 0x140 0x0 0x140>; ++ secure-monitor = <&sm>; + amlogic,has-chip-id; + }; + +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +@@ -2056,6 +2056,7 @@ cec_AO: cec@100 { + sec_AO: ao-secure@140 { + compatible = "amlogic,meson-gx-ao-secure", "syscon"; + reg = <0x0 0x140 0x0 0x140>; ++ secure-monitor = <&sm>; + amlogic,has-chip-id; + }; + +diff --git a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi +@@ -471,6 +471,7 @@ cec_AO: cec@100 { + sec_AO: ao-secure@140 { + compatible = "amlogic,meson-gx-ao-secure", "syscon"; + reg = <0x0 0x140 0x0 0x140>; ++ secure-monitor = <&sm>; + amlogic,has-chip-id; + }; + +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-sound-soc-remove-mono-channel-as-it-curren.patch b/patch/kernel/archive/meson64-6.13/general-sound-soc-remove-mono-channel-as-it-curren.patch new file mode 100644 index 000000000..90f716b22 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-sound-soc-remove-mono-channel-as-it-curren.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: ckkim +Date: Thu, 20 Feb 2020 18:52:57 +0900 +Subject: ODROID-N2: sound/soc: remove mono channel as it currently doesn't + work hdmi output. + +Change-Id: I4d43b802815779687ade974f049f2b0517a411d1 +Signed-off-by: ckkim +--- + sound/soc/meson/axg-frddr.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/sound/soc/meson/axg-frddr.c b/sound/soc/meson/axg-frddr.c +index 111111111111..222222222222 100644 +--- a/sound/soc/meson/axg-frddr.c ++++ b/sound/soc/meson/axg-frddr.c +@@ -108,7 +108,7 @@ static struct snd_soc_dai_driver axg_frddr_dai_drv = { + .name = "FRDDR", + .playback = { + .stream_name = "Playback", +- .channels_min = 1, ++ .channels_min = 2, + .channels_max = AXG_FIFO_CH_MAX, + .rates = SNDRV_PCM_RATE_CONTINUOUS, + .rate_min = 5515, +@@ -185,7 +185,7 @@ static struct snd_soc_dai_driver g12a_frddr_dai_drv = { + .name = "FRDDR", + .playback = { + .stream_name = "Playback", +- .channels_min = 1, ++ .channels_min = 2, + .channels_max = AXG_FIFO_CH_MAX, + .rates = SNDRV_PCM_RATE_CONTINUOUS, + .rate_min = 5515, +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-spi-nor-add-support-for-XT25F128B.patch b/patch/kernel/archive/meson64-6.13/general-spi-nor-add-support-for-XT25F128B.patch new file mode 100644 index 000000000..a248b620d --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-spi-nor-add-support-for-XT25F128B.patch @@ -0,0 +1,96 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Andreas Rammhold +Date: Thu, 28 Jan 2021 09:43:36 +0000 +Subject: spi-nor: add support for XT25F128B & XT25Q64 + +This adds support for the XT25F128B as found on the RockPi4b SBC. +- Ricardo Pardini 23/jan/2023: add XT25Q64 SPI NOR chip + - found on HK's vendor tree: https://github.com/hardkernel/linux/blame/05e3dc1688758bd401e0f7cdd9809a3f9251f7c1/drivers/mtd/spi-nor/spi-nor.c#L1024-L1026 +- Ricardo pardini 14/jan/2024: convert to new SNOR_ID format + - I just followed the lead Paolo used in rockchip64's 6.7 + +Signed-off-by: Andreas Rammhold +Signed-off-by: Ricardo Pardini + +This continues the efforts done in [1] & [2] that went stale. I've +tested this patch on my RockPi4b which only has the xt25f128b (and not +the xt25f32b as also propsed in [2]). I have tried to obtain a copy of +the datasheets but was unable to find them. Not sure whre you would get +them. + +While [1] was already for the new spi-nor layout it was missing the bits +in the core.{c,h} files. + +[1]: https://patchwork.ozlabs.org/project/linux-mtd/patch/CAMgqO2y9MYDj6antOaWLBRKU8vGEwqCB-Y1TkXTSWsmsed+W6A@mail.gmail.com/ +[2]: https://patchwork.ozlabs.org/project/linux-mtd/patch/20200206171941.GA2398@makrotopia.org/ +--- + drivers/mtd/spi-nor/Makefile | 1 + + drivers/mtd/spi-nor/core.c | 1 + + drivers/mtd/spi-nor/core.h | 1 + + drivers/mtd/spi-nor/xtx.c | 19 ++++++++++ + 4 files changed, 22 insertions(+) + +diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile +index 111111111111..222222222222 100644 +--- a/drivers/mtd/spi-nor/Makefile ++++ b/drivers/mtd/spi-nor/Makefile +@@ -14,6 +14,7 @@ spi-nor-objs += spansion.o + spi-nor-objs += sst.o + spi-nor-objs += winbond.o + spi-nor-objs += xmc.o ++spi-nor-objs += xtx.o + spi-nor-$(CONFIG_DEBUG_FS) += debugfs.o + obj-$(CONFIG_MTD_SPI_NOR) += spi-nor.o + +diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c +index 111111111111..222222222222 100644 +--- a/drivers/mtd/spi-nor/core.c ++++ b/drivers/mtd/spi-nor/core.c +@@ -1977,6 +1977,7 @@ static const struct spi_nor_manufacturer *manufacturers[] = { + &spi_nor_sst, + &spi_nor_winbond, + &spi_nor_xmc, ++ &spi_nor_xtx, + }; + + static const struct flash_info spi_nor_generic_flash = { +diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h +index 111111111111..222222222222 100644 +--- a/drivers/mtd/spi-nor/core.h ++++ b/drivers/mtd/spi-nor/core.h +@@ -593,6 +593,7 @@ extern const struct spi_nor_manufacturer spi_nor_spansion; + extern const struct spi_nor_manufacturer spi_nor_sst; + extern const struct spi_nor_manufacturer spi_nor_winbond; + extern const struct spi_nor_manufacturer spi_nor_xmc; ++extern const struct spi_nor_manufacturer spi_nor_xtx; + + extern const struct attribute_group *spi_nor_sysfs_groups[]; + +diff --git a/drivers/mtd/spi-nor/xtx.c b/drivers/mtd/spi-nor/xtx.c +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/drivers/mtd/spi-nor/xtx.c +@@ -0,0 +1,19 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++ ++#include "core.h" ++ ++static const struct flash_info xtx_parts[] = { ++ /* XTX (Shenzhen Xin Tian Xia Tech) */ ++ // { "xt25f128b", INFO(0x0b4018, 0, 64 * 1024, 256) }, ++ { "xt25f128b", SNOR_ID(0x0b, 0x40, 0x18) }, ++ // { "XT25Q64", INFO(0x0b6017, 0, 64 * 1024, 128) }, ++ { "XT25Q64", SNOR_ID(0x0b, 0x60, 0x17) }, ++}; ++ ++const struct spi_nor_manufacturer spi_nor_xtx = { ++ .name = "xtx", ++ .parts = xtx_parts, ++ .nparts = ARRAY_SIZE(xtx_parts), ++}; +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/general-usb-core-improve-handling-of-hubs-with-no-ports.patch b/patch/kernel/archive/meson64-6.13/general-usb-core-improve-handling-of-hubs-with-no-ports.patch new file mode 100644 index 000000000..9b12a4079 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/general-usb-core-improve-handling-of-hubs-with-no-ports.patch @@ -0,0 +1,53 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Wed, 23 Feb 2022 02:21:19 +0000 +Subject: usb: core: improve handling of hubs with no ports + +I get the "hub doesn't have any ports" error message on a system with +Amlogic S905W SoC. Seems the SoC has internal USB 3.0 supports but +is crippled with regard to USB 3.0 ports. +Maybe we shouldn't consider this scenario an error. So let's change +the message to info level, but otherwise keep the handling of the +scenario as it is today. With the patch it looks like this on my +system. + +dwc2 c9100000.usb: supply vusb_d not found, using dummy regulator +dwc2 c9100000.usb: supply vusb_a not found, using dummy regulator +dwc2 c9100000.usb: EPs: 7, dedicated fifos, 712 entries in SPRAM +xhci-hcd xhci-hcd.0.auto: xHCI Host Controller +xhci-hcd xhci-hcd.0.auto: new USB bus registered, assigned bus number 1 +xhci-hcd xhci-hcd.0.auto: hcc params 0x0228f664 hci version 0x100 quirks 0x0000000002010010 +xhci-hcd xhci-hcd.0.auto: irq 49, io mem 0xc9000000 +hub 1-0:1.0: USB hub found +hub 1-0:1.0: 2 ports detected +xhci-hcd xhci-hcd.0.auto: xHCI Host Controller +xhci-hcd xhci-hcd.0.auto: new USB bus registered, assigned bus number 2 +xhci-hcd xhci-hcd.0.auto: Host supports USB 3.0 SuperSpeed +usb usb2: We don't know the algorithms for LPM for this host, disabling LPM. +hub 2-0:1.0: USB hub found +hub 2-0:1.0: hub has no ports, exiting + +Signed-off-by: Heiner Kallweit +--- + drivers/usb/core/hub.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c +index 111111111111..222222222222 100644 +--- a/drivers/usb/core/hub.c ++++ b/drivers/usb/core/hub.c +@@ -1475,9 +1475,8 @@ static int hub_configure(struct usb_hub *hub, + ret = -ENODEV; + goto fail; + } else if (hub->descriptor->bNbrPorts == 0) { +- message = "hub doesn't have any ports!"; +- ret = -ENODEV; +- goto fail; ++ dev_info(hub_dev, "hub has no ports, exiting\n"); ++ return -ENODEV; + } + + /* +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/hwmon-emc2305-fixups-for-driver.patch b/patch/kernel/archive/meson64-6.13/hwmon-emc2305-fixups-for-driver.patch new file mode 100644 index 000000000..14cbdd500 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/hwmon-emc2305-fixups-for-driver.patch @@ -0,0 +1,212 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Patrick Yavitz +Date: Tue, 10 Oct 2023 18:54:22 -0400 +Subject: hwmon: emc2305: fixups for driver + +BPI-CM4 fan control + +hwmon: emc2305: fixups for driver +The driver had a number of issues, checkpatch warnings/errors, +and other limitations, so fix these up to make it usable. +hwmon: emc2305: Change OF properties pwm-min & pwm-max to u8 +hwmon: emc2305: Add calls to initialize cooling maps +https://github.com/raspberrypi/linux/commits/233096b8a9023f7e02960543c85447d46af81e81/drivers/hwmon/emc2305.c + +Tested-on: CM4-IO-BASE-B: https://www.waveshare.com/wiki/CM4-IO-BASE-B +Signed-off-by: Phil Elwell +Signed-off-by: Dave Stevenson +Signed-off-by: Patrick Yavitz +--- + drivers/hwmon/emc2305.c | 96 +++++++++- + 1 file changed, 88 insertions(+), 8 deletions(-) + +diff --git a/drivers/hwmon/emc2305.c b/drivers/hwmon/emc2305.c +index 111111111111..222222222222 100644 +--- a/drivers/hwmon/emc2305.c ++++ b/drivers/hwmon/emc2305.c +@@ -12,12 +12,13 @@ + #include + #include + ++#define EMC2305_REG_FAN_STATUS 0x24 ++#define EMC2305_REG_FAN_STALL_STATUS 0x25 + #define EMC2305_REG_DRIVE_FAIL_STATUS 0x27 + #define EMC2305_REG_VENDOR 0xfe + #define EMC2305_FAN_MAX 0xff + #define EMC2305_FAN_MIN 0x00 + #define EMC2305_FAN_MAX_STATE 10 +-#define EMC2305_DEVICE 0x34 + #define EMC2305_VENDOR 0x5d + #define EMC2305_REG_PRODUCT_ID 0xfd + #define EMC2305_TACH_REGS_UNUSE_BITS 3 +@@ -36,6 +37,7 @@ + #define EMC2305_RPM_FACTOR 3932160 + + #define EMC2305_REG_FAN_DRIVE(n) (0x30 + 0x10 * (n)) ++#define EMC2305_REG_FAN_CFG(n) (0x32 + 0x10 * (n)) + #define EMC2305_REG_FAN_MIN_DRIVE(n) (0x38 + 0x10 * (n)) + #define EMC2305_REG_FAN_TACH(n) (0x3e + 0x10 * (n)) + +@@ -55,6 +57,16 @@ static const struct i2c_device_id emc2305_ids[] = { + }; + MODULE_DEVICE_TABLE(i2c, emc2305_ids); + ++static const struct of_device_id emc2305_dt_ids[] = { ++ { .compatible = "smsc,emc2305" }, ++ { .compatible = "microchip,emc2305" }, ++ { .compatible = "microchip,emc2303" }, ++ { .compatible = "microchip,emc2302" }, ++ { .compatible = "microchip,emc2301" }, ++ { } ++}; ++MODULE_DEVICE_TABLE(of, emc2305_dt_ids); ++ + /** + * struct emc2305_cdev_data - device-specific cooling device state + * @cdev: cooling device +@@ -100,6 +112,7 @@ struct emc2305_data { + u8 pwm_num; + bool pwm_separate; + u8 pwm_min[EMC2305_PWM_MAX]; ++ u8 pwm_max; + struct emc2305_cdev_data cdev_data[EMC2305_PWM_MAX]; + }; + +@@ -272,7 +285,7 @@ static int emc2305_set_pwm(struct device *dev, long val, int channel) + struct i2c_client *client = data->client; + int ret; + +- if (val < data->pwm_min[channel] || val > EMC2305_FAN_MAX) ++ if (val < data->pwm_min[channel] || val > data->pwm_max) + return -EINVAL; + + ret = i2c_smbus_write_byte_data(client, EMC2305_REG_FAN_DRIVE(channel), val); +@@ -283,6 +296,49 @@ static int emc2305_set_pwm(struct device *dev, long val, int channel) + return 0; + } + ++static int emc2305_get_tz_of(struct device *dev) ++{ ++ struct device_node *np = dev->of_node; ++ struct emc2305_data *data = dev_get_drvdata(dev); ++ int ret = 0; ++ u8 val; ++ int i; ++ ++ /* OF parameters are optional - overwrite default setting ++ * if some of them are provided. ++ */ ++ ++ ret = of_property_read_u8(np, "emc2305,cooling-levels", &val); ++ if (!ret) ++ data->max_state = val; ++ else if (ret != -EINVAL) ++ return ret; ++ ++ ret = of_property_read_u8(np, "emc2305,pwm-max", &val); ++ if (!ret) ++ data->pwm_max = val; ++ else if (ret != -EINVAL) ++ return ret; ++ ++ ret = of_property_read_u8(np, "emc2305,pwm-min", &val); ++ if (!ret) ++ for (i = 0; i < EMC2305_PWM_MAX; i++) ++ data->pwm_min[i] = val; ++ else if (ret != -EINVAL) ++ return ret; ++ ++ /* Not defined or 0 means one thermal zone over all cooling devices. ++ * Otherwise - separated thermal zones for each PWM channel. ++ */ ++ ret = of_property_read_u8(np, "emc2305,pwm-channel", &val); ++ if (!ret) ++ data->pwm_separate = (val != 0); ++ else if (ret != -EINVAL) ++ return ret; ++ ++ return 0; ++} ++ + static int emc2305_set_single_tz(struct device *dev, int idx) + { + struct emc2305_data *data = dev_get_drvdata(dev); +@@ -292,9 +348,17 @@ static int emc2305_set_single_tz(struct device *dev, int idx) + cdev_idx = (idx) ? idx - 1 : 0; + pwm = data->pwm_min[cdev_idx]; + +- data->cdev_data[cdev_idx].cdev = +- thermal_cooling_device_register(emc2305_fan_name[idx], data, +- &emc2305_cooling_ops); ++ if (dev->of_node) ++ data->cdev_data[cdev_idx].cdev = ++ devm_thermal_of_cooling_device_register(dev, dev->of_node, ++ emc2305_fan_name[idx], ++ data, ++ &emc2305_cooling_ops); ++ else ++ data->cdev_data[cdev_idx].cdev = ++ thermal_cooling_device_register(emc2305_fan_name[idx], ++ data, ++ &emc2305_cooling_ops); + + if (IS_ERR(data->cdev_data[cdev_idx].cdev)) { + dev_err(dev, "Failed to register cooling device %s\n", emc2305_fan_name[idx]); +@@ -347,9 +411,11 @@ static void emc2305_unset_tz(struct device *dev) + int i; + + /* Unregister cooling device. */ +- for (i = 0; i < EMC2305_PWM_MAX; i++) +- if (data->cdev_data[i].cdev) +- thermal_cooling_device_unregister(data->cdev_data[i].cdev); ++ if (!dev->of_node) { ++ for (i = 0; i < EMC2305_PWM_MAX; i++) ++ if (data->cdev_data[i].cdev) ++ thermal_cooling_device_unregister(data->cdev_data[i].cdev); ++ } + } + + static umode_t +@@ -571,11 +637,18 @@ static int emc2305_probe(struct i2c_client *client) + data->pwm_separate = pdata->pwm_separate; + for (i = 0; i < EMC2305_PWM_MAX; i++) + data->pwm_min[i] = pdata->pwm_min[i]; ++ data->pwm_max = EMC2305_FAN_MAX; + } else { + data->max_state = EMC2305_FAN_MAX_STATE; + data->pwm_separate = false; + for (i = 0; i < EMC2305_PWM_MAX; i++) + data->pwm_min[i] = EMC2305_FAN_MIN; ++ data->pwm_max = EMC2305_FAN_MAX; ++ if (dev->of_node) { ++ ret = emc2305_get_tz_of(dev); ++ if (ret < 0) ++ return ret; ++ } + } + + data->hwmon_dev = devm_hwmon_device_register_with_info(dev, "emc2305", data, +@@ -596,6 +669,12 @@ static int emc2305_probe(struct i2c_client *client) + return ret; + } + ++ /* Acknowledge any existing faults. Stops the device responding on the ++ * SMBus alert address. ++ */ ++ i2c_smbus_read_byte_data(client, EMC2305_REG_FAN_STALL_STATUS); ++ i2c_smbus_read_byte_data(client, EMC2305_REG_FAN_STATUS); ++ + return 0; + } + +@@ -610,6 +689,7 @@ static void emc2305_remove(struct i2c_client *client) + static struct i2c_driver emc2305_driver = { + .driver = { + .name = "emc2305", ++ .of_match_table = emc2305_dt_ids, + }, + .probe = emc2305_probe, + .remove = emc2305_remove, +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/jethome-0001-Fix-meson64-add-gpio-irq-patch-from-https-lkml.org-l.patch b/patch/kernel/archive/meson64-6.13/jethome-0001-Fix-meson64-add-gpio-irq-patch-from-https-lkml.org-l.patch new file mode 100644 index 000000000..46783aef7 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/jethome-0001-Fix-meson64-add-gpio-irq-patch-from-https-lkml.org-l.patch @@ -0,0 +1,100 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: usera +Date: Mon, 12 Apr 2021 16:16:42 +0200 +Subject: Fix:meson64: add gpio irq (patch from + https://lkml.org/lkml/2020/11/27/8) + +Signed-off-by: Vyacheslav Bocharov +--- + drivers/pinctrl/meson/pinctrl-meson.c | 41 ++++++++++ + drivers/pinctrl/meson/pinctrl-meson.h | 1 + + 2 files changed, 42 insertions(+) + +diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c +index 111111111111..222222222222 100644 +--- a/drivers/pinctrl/meson/pinctrl-meson.c ++++ b/drivers/pinctrl/meson/pinctrl-meson.c +@@ -51,6 +51,7 @@ + #include + #include + #include ++#include + + #include "../core.h" + #include "../pinctrl-utils.h" +@@ -602,6 +603,40 @@ static int meson_gpio_get(struct gpio_chip *chip, unsigned gpio) + return !!(val & BIT(bit)); + } + ++static int meson_gpio_to_irq(struct gpio_chip *chip, unsigned int gpio) ++{ ++ struct meson_pinctrl *pc = gpiochip_get_data(chip); ++ const struct meson_bank *bank; ++ struct irq_fwspec fwspec; ++ int hwirq; ++ ++ if (meson_get_bank(pc, gpio, &bank)) ++ return -EINVAL; ++ ++ if (bank->irq_first < 0) { ++ dev_warn(pc->dev, "no support irq for pin[%d]\n", gpio); ++ return -EINVAL; ++ } ++ if (!pc->of_irq) { ++ dev_err(pc->dev, "invalid device node of gpio INTC\n"); ++ return -EINVAL; ++ } ++ ++ hwirq = gpio - bank->first + bank->irq_first; ++ printk("gpio irq setup: hwirq: 0x%X irqfirst: 0x%X irqlast: 0x%X pin[%d]\n", hwirq, bank->irq_first, bank->irq_last, gpio); ++ if (hwirq > bank->irq_last) ++ { ++ dev_warn(pc->dev, "no more irq for pin[%d]\n", gpio); ++ return -EINVAL; ++ } ++ fwspec.fwnode = of_node_to_fwnode(pc->of_irq); ++ fwspec.param_count = 2; ++ fwspec.param[0] = hwirq; ++ fwspec.param[1] = IRQ_TYPE_NONE; ++ ++ return irq_create_fwspec_mapping(&fwspec); ++} ++ + static int meson_gpiolib_register(struct meson_pinctrl *pc) + { + int ret; +@@ -617,6 +652,7 @@ static int meson_gpiolib_register(struct meson_pinctrl *pc) + pc->chip.direction_output = meson_gpio_direction_output; + pc->chip.get = meson_gpio_get; + pc->chip.set = meson_gpio_set; ++ pc->chip.to_irq = meson_gpio_to_irq; + pc->chip.base = -1; + pc->chip.ngpio = pc->data->num_pins; + pc->chip.can_sleep = false; +@@ -680,6 +716,11 @@ static int meson_pinctrl_parse_dt(struct meson_pinctrl *pc) + pc->fwnode = gpiochip_node_get_first(pc->dev); + gpio_np = to_of_node(pc->fwnode); + ++ pc->of_irq = of_find_compatible_node(NULL, ++ NULL, "amlogic,meson-gpio-intc"); ++ if (!pc->of_irq) ++ pc->of_irq = of_find_compatible_node(NULL, ++ NULL, "amlogic,meson-gpio-intc-ext"); + pc->reg_mux = meson_map_resource(pc, gpio_np, "mux"); + if (IS_ERR_OR_NULL(pc->reg_mux)) { + dev_err(pc->dev, "mux registers not found\n"); +diff --git a/drivers/pinctrl/meson/pinctrl-meson.h b/drivers/pinctrl/meson/pinctrl-meson.h +index 111111111111..222222222222 100644 +--- a/drivers/pinctrl/meson/pinctrl-meson.h ++++ b/drivers/pinctrl/meson/pinctrl-meson.h +@@ -134,6 +134,7 @@ struct meson_pinctrl { + struct regmap *reg_ds; + struct gpio_chip chip; + struct fwnode_handle *fwnode; ++ struct device_node *of_irq; + }; + + #define FUNCTION(fn) \ +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/jethome-0002-arm64-dts-jethub-j1xx-add-eeprom-node.patch b/patch/kernel/archive/meson64-6.13/jethome-0002-arm64-dts-jethub-j1xx-add-eeprom-node.patch new file mode 100644 index 000000000..c9f14793d --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/jethome-0002-arm64-dts-jethub-j1xx-add-eeprom-node.patch @@ -0,0 +1,54 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Viacheslav Bocharov +Date: Fri, 20 Oct 2023 14:06:58 +0300 +Subject: arm64: dts: jethub-j1xx: add eeprom node + +Add node for eeprom on baseboard in JetHub D1+ device +--- + arch/arm64/boot/dts/amlogic/meson-axg-jethome-jethub-j110-rev-2.dts | 12 ++++++++++ + arch/arm64/boot/dts/amlogic/meson-axg-jethome-jethub-j110-rev-3.dts | 12 ++++++++++ + 2 files changed, 24 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-axg-jethome-jethub-j110-rev-2.dts b/arch/arm64/boot/dts/amlogic/meson-axg-jethome-jethub-j110-rev-2.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-axg-jethome-jethub-j110-rev-2.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-axg-jethome-jethub-j110-rev-2.dts +@@ -47,3 +47,15 @@ eeprompd: eeprom@56 { + vcc-supply = <&vddao_3v3>; + }; + }; ++ ++&i2c_AO { ++ /* EEPROM on base board */ ++ eeprompd: eeprom@56 { ++ compatible = "atmel,24c64"; ++ reg = <0x56>; ++ pagesize = <0x20>; ++ label = "eeprompd"; ++ address-width = <0x10>; ++ vcc-supply = <&vddao_3v3>; ++ }; ++}; +diff --git a/arch/arm64/boot/dts/amlogic/meson-axg-jethome-jethub-j110-rev-3.dts b/arch/arm64/boot/dts/amlogic/meson-axg-jethome-jethub-j110-rev-3.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-axg-jethome-jethub-j110-rev-3.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-axg-jethome-jethub-j110-rev-3.dts +@@ -37,3 +37,15 @@ eeprompd: eeprom@56 { + vcc-supply = <&vddao_3v3>; + }; + }; ++ ++&i2c_AO { ++ /* EEPROM on base board */ ++ eeprompd: eeprom@56 { ++ compatible = "atmel,24c64"; ++ reg = <0x56>; ++ pagesize = <0x20>; ++ label = "eeprompd"; ++ address-width = <0x10>; ++ vcc-supply = <&vddao_3v3>; ++ }; ++}; +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/jethome-0003-arm64-dts-meson-add-dts-links-to-secure-monitor-for-jethub.patch.disabled b/patch/kernel/archive/meson64-6.13/jethome-0003-arm64-dts-meson-add-dts-links-to-secure-monitor-for-jethub.patch.disabled new file mode 100644 index 000000000..a05a9a4e0 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/jethome-0003-arm64-dts-meson-add-dts-links-to-secure-monitor-for-jethub.patch.disabled @@ -0,0 +1,39 @@ +From 728157ef8e377f74289dc7397c2de4b3b6416ccc Mon Sep 17 00:00:00 2001 +From: Viacheslav Bocharov +Date: Thu, 22 Feb 2024 12:02:20 +0300 +Subject: [PATCH 5/5] arm64: dts: meson: add dts links to secure-monitor for + JetHub devices + +Signed-off-by: Viacheslav Bocharov +--- + .../arm64/boot/dts/amlogic/meson-axg-jethome-jethub-j1xx.dtsi | 4 ++++ + .../boot/dts/amlogic/meson-gxl-s905w-jethome-jethub-j80.dts | 4 ++++ + 2 files changed, 8 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-axg-jethome-jethub-j1xx.dtsi b/arch/arm64/boot/dts/amlogic/meson-axg-jethome-jethub-j1xx.dtsi +index db605f3a22b4..f3e679030788 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-axg-jethome-jethub-j1xx.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-axg-jethome-jethub-j1xx.dtsi +@@ -348,3 +348,7 @@ &cpu2 { + &cpu3 { + #cooling-cells = <2>; + }; ++ ++&sec_AO { ++ secure-monitor = <&sm>; ++}; +diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-s905w-jethome-jethub-j80.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-s905w-jethome-jethub-j80.dts +index a18d6d241a5a..d75ba28d5e62 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-gxl-s905w-jethome-jethub-j80.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s905w-jethome-jethub-j80.dts +@@ -245,3 +245,7 @@ pcf8563: rtc@51 { + status = "okay"; + }; + }; ++ ++&sec_AO { ++ secure-monitor = <&sm>; ++}; +-- +2.43.2 + diff --git a/patch/kernel/archive/meson64-6.13/kernel-6.8-tools-cgroup-makefile.patch b/patch/kernel/archive/meson64-6.13/kernel-6.8-tools-cgroup-makefile.patch new file mode 100644 index 000000000..02f1e527e --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/kernel-6.8-tools-cgroup-makefile.patch @@ -0,0 +1,41 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: ColorfulRhino <131405023+ColorfulRhino@users.noreply.github.com> +Date: Sat, 30 Mar 2024 21:09:12 +0100 +Subject: [ARCHEOLOGY] meson-s4t7: Fix custom_kernel_config: hash modification + has to happen inside the first function call + +> X-Git-Archeology: > recovered message: > Will be ignored on second time the function is called +> X-Git-Archeology: - Revision 6ced5cc02637fb6dbc980aa77fcdc77f2ccf5067: https://github.com/armbian/build/commit/6ced5cc02637fb6dbc980aa77fcdc77f2ccf5067 +> X-Git-Archeology: Date: Sat, 30 Mar 2024 21:09:12 +0100 +> X-Git-Archeology: From: ColorfulRhino <131405023+ColorfulRhino@users.noreply.github.com> +> X-Git-Archeology: Subject: meson-s4t7: Fix custom_kernel_config: hash modification has to happen inside the first function call +> X-Git-Archeology: +> X-Git-Archeology: - Revision caf0529240948df416b015aeea8c23e420a55ce6: https://github.com/armbian/build/commit/caf0529240948df416b015aeea8c23e420a55ce6 +> X-Git-Archeology: Date: Sun, 31 Mar 2024 18:21:26 -0400 +> X-Git-Archeology: From: Barry Lind (SteeManMI) +> X-Git-Archeology: Subject: Bump meson64 edge from 6.7 to 6.8 +> X-Git-Archeology: +--- + tools/cgroup/Makefile | 11 ++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/tools/cgroup/Makefile b/tools/cgroup/Makefile +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/tools/cgroup/Makefile +@@ -0,0 +1,11 @@ ++# SPDX-License-Identifier: GPL-2.0 ++# Makefile for cgroup tools ++ ++CFLAGS = -Wall -Wextra ++ ++all: cgroup_event_listener ++%: %.c ++ $(CC) $(CFLAGS) -o $@ $^ ++ ++clean: ++ $(RM) cgroup_event_listener +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/meson-g12a-pinctrl-add-missing-ir-options.patch b/patch/kernel/archive/meson64-6.13/meson-g12a-pinctrl-add-missing-ir-options.patch new file mode 100644 index 000000000..956c347df --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/meson-g12a-pinctrl-add-missing-ir-options.patch @@ -0,0 +1,91 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Yuntian Zhang +Date: Mon, 25 Jul 2022 15:31:31 +0800 +Subject: pinctrl: meson-g12a: add missing ir options + +Those pins are defined in S905Y2 and A311D reference manuals. + +Signed-off-by: Yuntian Zhang +--- + arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi | 16 ++++++++++ + drivers/pinctrl/meson/pinctrl-meson-g12a.c | 9 ++++++ + 2 files changed, 25 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +@@ -568,6 +568,14 @@ mux { + }; + }; + ++ remote_input_pins: remote-input { ++ mux { ++ groups = "remote_input"; ++ function = "remote_input"; ++ bias-disable; ++ }; ++ }; ++ + mclk0_a_pins: mclk0-a { + mux { + groups = "mclk0_a"; +@@ -1542,6 +1550,14 @@ mux { + bias-disable; + }; + }; ++ ++ remote_out_ao_pins: remote-out { ++ mux { ++ groups = "remote_ao_out"; ++ function = "remote_ao_out"; ++ bias-disable; ++ }; ++ }; + }; + }; + +diff --git a/drivers/pinctrl/meson/pinctrl-meson-g12a.c b/drivers/pinctrl/meson/pinctrl-meson-g12a.c +index 111111111111..222222222222 100644 +--- a/drivers/pinctrl/meson/pinctrl-meson-g12a.c ++++ b/drivers/pinctrl/meson/pinctrl-meson-g12a.c +@@ -216,6 +216,9 @@ static const unsigned int i2c3_sck_h_pins[] = { GPIOH_1 }; + static const unsigned int i2c3_sda_a_pins[] = { GPIOA_14 }; + static const unsigned int i2c3_sck_a_pins[] = { GPIOA_15 }; + ++/* ir_in */ ++static const unsigned int remote_input_pins[] = { GPIOA_15 }; ++ + /* uart_a */ + static const unsigned int uart_a_tx_pins[] = { GPIOX_12 }; + static const unsigned int uart_a_rx_pins[] = { GPIOX_13 }; +@@ -737,6 +740,7 @@ static const struct meson_pmx_group meson_g12a_periphs_groups[] = { + /* bank GPIOA */ + GROUP(i2c3_sda_a, 2), + GROUP(i2c3_sck_a, 2), ++ GROUP(remote_input, 1), + GROUP(pdm_din0_a, 1), + GROUP(pdm_din1_a, 1), + GROUP(pdm_din2_a, 1), +@@ -1022,6 +1026,10 @@ static const char * const i2c3_groups[] = { + "i2c3_sda_a", "i2c3_sck_a", + }; + ++static const char * const remote_input_groups[] = { ++ "remote_input", ++}; ++ + static const char * const uart_a_groups[] = { + "uart_a_tx", "uart_a_rx", "uart_a_cts", "uart_a_rts", + }; +@@ -1266,6 +1274,7 @@ static const struct meson_pmx_func meson_g12a_periphs_functions[] = { + FUNCTION(i2c1), + FUNCTION(i2c2), + FUNCTION(i2c3), ++ FUNCTION(remote_input), + FUNCTION(uart_a), + FUNCTION(uart_b), + FUNCTION(uart_c), +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/meson-g12a-radxa-zero-gpio-pin-names.patch b/patch/kernel/archive/meson64-6.13/meson-g12a-radxa-zero-gpio-pin-names.patch new file mode 100644 index 000000000..c545fad30 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/meson-g12a-radxa-zero-gpio-pin-names.patch @@ -0,0 +1,54 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Sergey Ko +Date: Wed, 11 Dec 2024 14:06:34 -0600 +Subject: [ARCHEOLOGY] add Radxa Zero GPIO names to support libgpiod (#7563) + +> X-Git-Archeology: - Revision fb63c78e7f05f18013d7c0c54d3935018761968f: https://github.com/armbian/build/commit/fb63c78e7f05f18013d7c0c54d3935018761968f +> X-Git-Archeology: Date: Wed, 11 Dec 2024 14:06:34 -0600 +> X-Git-Archeology: From: Sergey Ko +> X-Git-Archeology: Subject: add Radxa Zero GPIO names to support libgpiod (#7563) +> X-Git-Archeology: +--- + arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts | 26 ++++++++++ + 1 file changed, 26 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts b/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-g12a-radxa-zero.dts +@@ -294,6 +294,32 @@ &frddr_c { + status = "okay"; + }; + ++/* ++pin-8, pin-36 are mapped referring to: /include/dt-bindings/gpio/meson-g12a-gpio.h ++left as is for future tests ++*/ ++/*CHIP0*/ ++&gpio { ++ gpio-line-names = ++ /*00*/ "", "", "", "", "", "", "", "", "", "", ++ /*10*/ "", "", "", "", "", "", "", "", "", "", ++ /*20*/ "19 [GPIOH_4]", "21 [GPIOH_5]", "24 [GPIOH_6]", "23 [GPIOH_7]", "36 [GPIOH_8]", "", "", "", "", "", ++ /*30*/ "", "", "", "", "", "", "", "", "", "", ++ /*40*/ "", "", "", "", "", "", "", "", "22 [GPIOC_7]", "", ++ /*50*/ "", "", "", "", "", "", "", "", "", "", ++ /*60*/ "", "", "", "3 [GPIOA_14]", "", "", "", "", "", "", ++ /*70*/ "", "", "", "18 [GPIOX_8]", "12 [GPIOX_9]", "16 [GPIOX_10]", "13 [GPIOX_11]", "", "", "", ++ /*80*/ "", "", "", "", ""; ++}; ++ ++/*CHIP1*/ ++&gpio_ao { ++ gpio-line-names = ++ /*00*/ "8 [GPIOAO_0]", "10 [GPIOAO_1]", "11,28 [GPIOAO_2]", "7,27 [GPIOAO_3]", "32 [GPIOAO_4]", ++ /*05*/ "5 [GPIOA_15]", "", "", "35 [GPIOAO_8]", "37 [GPIOAO_9]", ++ /*10*/ "", "40 [GPIOAO_11]", "", "", ""; ++}; ++ + &hdmi_tx { + status = "okay"; + pinctrl-0 = <&hdmitx_hpd_pins>, <&hdmitx_ddc_pins>; +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/meson-g12b-pinctrl-Add-missing-pinmux-for-pwm.patch b/patch/kernel/archive/meson64-6.13/meson-g12b-pinctrl-Add-missing-pinmux-for-pwm.patch new file mode 100644 index 000000000..b3de0ee70 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/meson-g12b-pinctrl-Add-missing-pinmux-for-pwm.patch @@ -0,0 +1,125 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Yuntian Zhang +Date: Thu, 13 Jan 2022 21:34:10 +0800 +Subject: pinctrl: meson: Add several missing pinmux for pwm functions + +The following pin definitions are mentioned in A311D Quick +Reference Manual and S922X Public Datasheet, but not in S905Y2 +Quick Reference Manual, so adding them to meson-g12b family. + +They are currently exposed in Radxa Zero 2's GPIO header. + +Signed-off-by: Yuntian Zhang +--- + arch/arm64/boot/dts/amlogic/meson-g12b.dtsi | 34 ++++++++++ + drivers/pinctrl/meson/pinctrl-meson-g12a.c | 14 +++- + 2 files changed, 45 insertions(+), 3 deletions(-) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12b.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-g12b.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-g12b.dtsi +@@ -149,3 +149,37 @@ &pmu { + &npu { + power-domains = <&pwrc PWRC_G12A_NNA_ID>; + }; ++ ++&periphs_pinctrl { ++ pwm_b_h_pins: pwm-b-h { ++ mux { ++ groups = "pwm_b_h"; ++ function = "pwm_b"; ++ bias-disable; ++ }; ++ }; ++ ++ pwm_b_z_pins: pwm-b-z { ++ mux { ++ groups = "pwm_b_z"; ++ function = "pwm_b"; ++ bias-disable; ++ }; ++ }; ++ ++ pwm_c_z_pins: pwm-c-z { ++ mux { ++ groups = "pwm_c_z"; ++ function = "pwm_c"; ++ bias-disable; ++ }; ++ }; ++ ++ pwm_d_z_pins: pwm-d-z { ++ mux { ++ groups = "pwm_d_z"; ++ function = "pwm_d"; ++ bias-disable; ++ }; ++ }; ++}; +diff --git a/drivers/pinctrl/meson/pinctrl-meson-g12a.c b/drivers/pinctrl/meson/pinctrl-meson-g12a.c +index 111111111111..222222222222 100644 +--- a/drivers/pinctrl/meson/pinctrl-meson-g12a.c ++++ b/drivers/pinctrl/meson/pinctrl-meson-g12a.c +@@ -271,17 +271,21 @@ static const unsigned int eth_act_led_pins[] = { GPIOZ_15 }; + static const unsigned int pwm_a_pins[] = { GPIOX_6 }; + + /* pwm_b */ ++static const unsigned int pwm_b_h_pins[] = { GPIOH_7 }; + static const unsigned int pwm_b_x7_pins[] = { GPIOX_7 }; + static const unsigned int pwm_b_x19_pins[] = { GPIOX_19 }; ++static const unsigned int pwm_b_z_pins[] = { GPIOZ_0 }; + + /* pwm_c */ + static const unsigned int pwm_c_c_pins[] = { GPIOC_4 }; + static const unsigned int pwm_c_x5_pins[] = { GPIOX_5 }; + static const unsigned int pwm_c_x8_pins[] = { GPIOX_8 }; ++static const unsigned int pwm_c_z_pins[] = { GPIOZ_1 }; + + /* pwm_d */ + static const unsigned int pwm_d_x3_pins[] = { GPIOX_3 }; + static const unsigned int pwm_d_x6_pins[] = { GPIOX_6 }; ++static const unsigned int pwm_d_z_pins[] = { GPIOZ_2 }; + + /* pwm_e */ + static const unsigned int pwm_e_pins[] = { GPIOX_16 }; +@@ -594,6 +598,9 @@ static const struct meson_pmx_group meson_g12a_periphs_groups[] = { + GROUP(bt565_a_din5, 2), + GROUP(bt565_a_din6, 2), + GROUP(bt565_a_din7, 2), ++ GROUP(pwm_b_z, 5), ++ GROUP(pwm_c_z, 5), ++ GROUP(pwm_d_z, 2), + GROUP(tsin_b_valid_z, 3), + GROUP(tsin_b_sop_z, 3), + GROUP(tsin_b_din0_z, 3), +@@ -726,6 +733,7 @@ static const struct meson_pmx_group meson_g12a_periphs_groups[] = { + GROUP(uart_c_rts, 2), + GROUP(iso7816_clk_h, 1), + GROUP(iso7816_data_h, 1), ++ GROUP(pwm_b_h, 5), + GROUP(pwm_f_h, 4), + GROUP(cec_ao_a_h, 4), + GROUP(cec_ao_b_h, 5), +@@ -1066,15 +1074,15 @@ static const char * const pwm_a_groups[] = { + }; + + static const char * const pwm_b_groups[] = { +- "pwm_b_x7", "pwm_b_x19", ++ "pwm_b_h", "pwm_b_x7", "pwm_b_x19", "pwm_b_z", + }; + + static const char * const pwm_c_groups[] = { +- "pwm_c_c", "pwm_c_x5", "pwm_c_x8", ++ "pwm_c_c", "pwm_c_x5", "pwm_c_x8", "pwm_c_z", + }; + + static const char * const pwm_d_groups[] = { +- "pwm_d_x3", "pwm_d_x6", ++ "pwm_d_x3", "pwm_d_x6", "pwm_d_z", + }; + + static const char * const pwm_e_groups[] = { +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/meson-gx-dts-add-support-for-GX-PM-and-VRTC.patch b/patch/kernel/archive/meson64-6.13/meson-gx-dts-add-support-for-GX-PM-and-VRTC.patch new file mode 100644 index 000000000..21d766775 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/meson-gx-dts-add-support-for-GX-PM-and-VRTC.patch @@ -0,0 +1,40 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Neil Armstrong +Date: Thu, 3 Nov 2016 15:29:25 +0100 +Subject: HACK: arm64: dts: meson: add support for GX PM and Virtual RTC + +Signed-off-by: Neil Armstrong +--- + arch/arm64/boot/dts/amlogic/meson-gx.dtsi | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi +@@ -223,6 +223,10 @@ sm: secure-monitor { + }; + }; + ++ system-suspend { ++ compatible = "amlogic,meson-gx-pm"; ++ }; ++ + efuse: efuse { + compatible = "amlogic,meson-gx-efuse", "amlogic,meson-gxbb-efuse"; + #address-cells = <1>; +@@ -461,6 +465,11 @@ clkc_AO: clock-controller { + }; + }; + ++ vrtc: rtc@a8 { ++ compatible = "amlogic,meson-vrtc"; ++ reg = <0x0 0x000a8 0x0 0x4>; ++ }; ++ + cec_AO: cec@100 { + compatible = "amlogic,meson-gx-ao-cec"; + reg = <0x0 0x00100 0x0 0x14>; +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/meson-gxbb-dts-i2cX-missing-pins.patch b/patch/kernel/archive/meson64-6.13/meson-gxbb-dts-i2cX-missing-pins.patch new file mode 100644 index 000000000..f73c17ed0 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/meson-gxbb-dts-i2cX-missing-pins.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martin Ayotte +Date: Wed, 5 Dec 2018 17:35:05 -0500 +Subject: fix i2cA and i2cB miossing pins + +- c80617d145039a32b53e9f0908353aaea3d368a6: 1544111688: Martin Ayotte : 'add i2c_B missing pins' +--- + arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi +@@ -339,6 +339,8 @@ &hwrng { + + &i2c_A { + clocks = <&clkc CLKID_I2C>; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c_a_pins>; + }; + + &i2c_AO { +@@ -347,6 +349,8 @@ &i2c_AO { + + &i2c_B { + clocks = <&clkc CLKID_I2C>; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c_b_pins>; + }; + + &i2c_C { +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/meson-gxbb-vdec-add-HEVC-support-to-GXBB.patch b/patch/kernel/archive/meson64-6.13/meson-gxbb-vdec-add-HEVC-support-to-GXBB.patch new file mode 100644 index 000000000..4d0717675 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/meson-gxbb-vdec-add-HEVC-support-to-GXBB.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Christian Hewitt +Date: Sun, 21 Nov 2021 19:12:07 +0000 +Subject: WIP: drivers: meson: vdec: add HEVC support to GXBB + +It's not clear whether the GXL firmware is the same one used with GXBB +but let's try it and see! + +Signed-off-by: Christian Hewitt +--- + drivers/staging/media/meson/vdec/vdec_platform.c | 12 ++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/drivers/staging/media/meson/vdec/vdec_platform.c b/drivers/staging/media/meson/vdec/vdec_platform.c +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/meson/vdec/vdec_platform.c ++++ b/drivers/staging/media/meson/vdec/vdec_platform.c +@@ -16,6 +16,18 @@ + + static const struct amvdec_format vdec_formats_gxbb[] = { + { ++ .pixfmt = V4L2_PIX_FMT_HEVC, ++ .min_buffers = 4, ++ .max_buffers = 24, ++ .max_width = 3840, ++ .max_height = 2160, ++ .vdec_ops = &vdec_hevc_ops, ++ .codec_ops = &codec_hevc_ops, ++ .firmware_path = "meson/vdec/gxl_hevc.bin", ++ .pixfmts_cap = { V4L2_PIX_FMT_NV12M, 0 }, ++ .flags = V4L2_FMT_FLAG_COMPRESSED | ++ V4L2_FMT_FLAG_DYN_RESOLUTION, ++ }, { + .pixfmt = V4L2_PIX_FMT_H264, + .min_buffers = 2, + .max_buffers = 24, +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/meson-gxl-gxm-arm64-dts-meson-set-p212-p23x-q20x-SDIO-to-100MH.patch b/patch/kernel/archive/meson64-6.13/meson-gxl-gxm-arm64-dts-meson-set-p212-p23x-q20x-SDIO-to-100MH.patch new file mode 100644 index 000000000..9d1c1ebdd --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/meson-gxl-gxm-arm64-dts-meson-set-p212-p23x-q20x-SDIO-to-100MH.patch @@ -0,0 +1,125 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Christian Hewitt +Date: Tue, 18 Jan 2022 15:09:12 +0000 +Subject: WIP: arm64: dts: meson: set p212/p23x/q20x SDIO to 100MHz + add UHS + SDIO capabilities + +WIP: arm64: dts: meson: add UHS SDIO capabilities to p212/p23x/q20x + +Add UHS capabilities to the SDIO node to enable 100MHz speeds. + +Signed-off-by: Christian Hewitt + +WIP: arm64: dts: meson: set p212/p23x/q20x SDIO to 100MHz + +Amlogic datasheets describe 50MHz max-frequency for SDIO on GXL/GXM but +real-world tests on an assortment of GXL and GXM boards show noteable +increases in throughput when max-frequency is 100MHz, so let's use it. + +Before results from a p231 device: + +Connecting to host 192.168.0.1, port 5201 +Reverse mode, remote host 192.168.0.1 is sending +[ 5] local 192.168.0.41 port 42550 connected to 192.168.0.1 port 5201 +[ ID] Interval Transfer Bitrate +[ 5] 0.00-1.00 sec 8.84 MBytes 74.2 Mbits/sec +[ 5] 1.00-2.00 sec 9.60 MBytes 80.5 Mbits/sec +[ 5] 2.00-3.00 sec 9.07 MBytes 76.1 Mbits/sec +[ 5] 3.00-4.00 sec 9.14 MBytes 76.6 Mbits/sec +[ 5] 4.00-5.00 sec 9.26 MBytes 77.7 Mbits/sec +[ 5] 5.00-6.00 sec 9.08 MBytes 76.2 Mbits/sec +[ 5] 6.00-7.00 sec 9.11 MBytes 76.4 Mbits/sec +[ 5] 7.00-8.00 sec 8.65 MBytes 72.5 Mbits/sec +[ 5] 8.00-9.00 sec 9.24 MBytes 77.5 Mbits/sec +[ 5] 9.00-10.00 sec 8.57 MBytes 71.9 Mbits/sec +- - - - - - - - - - - - - - - - - - - - - - - - - +[ ID] Interval Transfer Bitrate Retr +[ 5] 0.00-10.27 sec 94.1 MBytes 76.8 Mbits/sec 0 sender +[ 5] 0.00-10.00 sec 90.6 MBytes 76.0 Mbits/sec receiver + +clock: 50000000 Hz +actual clock: 50000000 Hz +vdd: 21 (3.3 ~ 3.4 V) +bus mode: 2 (push-pull) +chip select: 0 (don't care) +power mode: 2 (on) +bus width: 2 (4 bits) +timing spec: 2 (sd high-speed) +signal voltage: 1 (1.80 V) +driver type: 0 (driver type B) + +After results from a p231 device: + +Connecting to host 192.168.0.1, port 5201 +Reverse mode, remote host 192.168.0.1 is sending +[ 5] local 192.168.0.41 port 58534 connected to 192.168.0.1 port 5201 +[ ID] Interval Transfer Bitrate +[ 5] 0.00-1.00 sec 12.6 MBytes 106 Mbits/sec +[ 5] 1.00-2.00 sec 13.0 MBytes 109 Mbits/sec +[ 5] 2.00-3.00 sec 12.8 MBytes 107 Mbits/sec +[ 5] 3.00-4.00 sec 13.2 MBytes 111 Mbits/sec +[ 5] 4.00-5.00 sec 12.4 MBytes 104 Mbits/sec +[ 5] 5.00-6.00 sec 11.2 MBytes 93.9 Mbits/sec +[ 5] 6.00-7.00 sec 12.3 MBytes 103 Mbits/sec +[ 5] 7.00-8.00 sec 12.3 MBytes 103 Mbits/sec +[ 5] 8.00-9.00 sec 12.5 MBytes 105 Mbits/sec +[ 5] 9.00-10.00 sec 12.3 MBytes 103 Mbits/sec +- - - - - - - - - - - - - - - - - - - - - - - - - +[ ID] Interval Transfer Bitrate Retr +[ 5] 0.00-10.22 sec 127 MBytes 104 Mbits/sec 0 sender +[ 5] 0.00-10.00 sec 125 MBytes 105 Mbits/sec receiver + +clock: 100000000 Hz +actual clock: 100000000 Hz +vdd: 21 (3.3 ~ 3.4 V) +bus mode: 2 (push-pull) +chip select: 0 (don't care) +power mode: 2 (on) +bus width: 2 (4 bits) +timing spec: 6 (sd uhs SDR104) +signal voltage: 1 (1.80 V) +driver type: 0 (driver type B) + +Signed-off-by: Christian Hewitt +--- + arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi | 6 +++++- + arch/arm64/boot/dts/amlogic/meson-gxl-s905x-p212.dtsi | 6 +++++- + 2 files changed, 10 insertions(+), 2 deletions(-) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi +@@ -260,7 +260,11 @@ &sd_emmc_a { + + bus-width = <4>; + cap-sd-highspeed; +- max-frequency = <50000000>; ++ sd-uhs-sdr12; ++ sd-uhs-sdr25; ++ sd-uhs-sdr50; ++ sd-uhs-sdr104; ++ max-frequency = <100000000>; + + non-removable; + disable-wp; +diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-p212.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-p212.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-p212.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-p212.dtsi +@@ -121,7 +121,11 @@ &sd_emmc_a { + + bus-width = <4>; + cap-sd-highspeed; +- max-frequency = <50000000>; ++ sd-uhs-sdr12; ++ sd-uhs-sdr25; ++ sd-uhs-sdr50; ++ sd-uhs-sdr104; ++ max-frequency = <100000000>; + + non-removable; + disable-wp; +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/meson-gxm-vdec-add-VP9-support-to-GXM.patch b/patch/kernel/archive/meson64-6.13/meson-gxm-vdec-add-VP9-support-to-GXM.patch new file mode 100644 index 000000000..ec4275418 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/meson-gxm-vdec-add-VP9-support-to-GXM.patch @@ -0,0 +1,43 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Christian Hewitt +Date: Thu, 25 Nov 2021 11:31:43 +0000 +Subject: drivers: meson: vdec: add VP9 support to GXM + +VP9 support for GXM appears to have been missed from the original +codec submission [0] but it works well, so let's add support. + +[0] https://github.com/torvalds/linux/commit/00c43088aa680989407b6afbda295f67b3f123f1 + +Signed-off-by: Christian Hewitt +--- + drivers/staging/media/meson/vdec/vdec_platform.c | 14 +++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +diff --git a/drivers/staging/media/meson/vdec/vdec_platform.c b/drivers/staging/media/meson/vdec/vdec_platform.c +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/meson/vdec/vdec_platform.c ++++ b/drivers/staging/media/meson/vdec/vdec_platform.c +@@ -27,7 +27,19 @@ static const struct amvdec_format vdec_formats_gxbb[] = { + .pixfmts_cap = { V4L2_PIX_FMT_NV12M, 0 }, + .flags = V4L2_FMT_FLAG_COMPRESSED | + V4L2_FMT_FLAG_DYN_RESOLUTION, +- }, { ++ }, { ++ .pixfmt = V4L2_PIX_FMT_VP9, ++ .min_buffers = 16, ++ .max_buffers = 24, ++ .max_width = 3840, ++ .max_height = 2160, ++ .vdec_ops = &vdec_hevc_ops, ++ .codec_ops = &codec_vp9_ops, ++ .firmware_path = "meson/vdec/gxl_vp9.bin", ++ .pixfmts_cap = { V4L2_PIX_FMT_NV12M, 0 }, ++ .flags = V4L2_FMT_FLAG_COMPRESSED | ++ V4L2_FMT_FLAG_DYN_RESOLUTION, ++ }, { + .pixfmt = V4L2_PIX_FMT_H264, + .min_buffers = 2, + .max_buffers = 24, +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/meson-sm1-dts-add-higher-clocks.patch b/patch/kernel/archive/meson64-6.13/meson-sm1-dts-add-higher-clocks.patch new file mode 100644 index 000000000..fd5af09cf --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/meson-sm1-dts-add-higher-clocks.patch @@ -0,0 +1,34 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Igor Pecovnik +Date: Tue, 4 Aug 2020 22:51:56 +0200 +Subject: Add higher clocks for SM1 family + +Signed-off-by: Igor Pecovnik +--- + arch/arm64/boot/dts/amlogic/meson-sm1.dtsi | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/arch/arm64/boot/dts/amlogic/meson-sm1.dtsi b/arch/arm64/boot/dts/amlogic/meson-sm1.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-sm1.dtsi ++++ b/arch/arm64/boot/dts/amlogic/meson-sm1.dtsi +@@ -136,6 +136,16 @@ opp-1908000000 { + opp-hz = /bits/ 64 <1908000000>; + opp-microvolt = <950000>; + }; ++ ++ opp-2016000000 { ++ opp-hz = /bits/ 64 <2016000000>; ++ opp-microvolt = <1000000>; ++ }; ++ ++ opp-2100000000 { ++ opp-hz = /bits/ 64 <2100000000>; ++ opp-microvolt = <1022000>; ++ }; + }; + }; + +-- +Armbian + diff --git a/patch/kernel/archive/meson64-6.13/overlay/Makefile b/patch/kernel/archive/meson64-6.13/overlay/Makefile new file mode 100644 index 000000000..1d8d9cbc0 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/Makefile @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: GPL-2.0 +dtbo-$(CONFIG_ARCH_MESON) += \ + meson-i2cA.dtbo \ + meson-i2cB.dtbo \ + meson-uartA.dtbo \ + meson-uartC.dtbo \ + meson-w1-gpio.dtbo \ + meson-w1AB-gpio.dtbo \ + meson-g12-gxl-cma-pool-896MB.dtbo \ + meson-g12-pwm-gpiox-5-fan.dtbo \ + meson-g12a-radxa-zero-gpio-8-led.dtbo \ + meson-g12a-radxa-zero-gpio-10-led.dtbo \ + meson-g12a-radxa-zero-i2c-ao-m0-gpioao-2-gpioao-3.dtbo \ + meson-g12a-radxa-zero-i2c-ee-m1-gpioh-6-gpioh-7.dtbo \ + meson-g12a-radxa-zero-i2c-ee-m1-gpiox-10-gpiox-11.dtbo \ + meson-g12a-radxa-zero-i2c-ee-m3-gpioa-14-gpioa-15.dtbo \ + meson-g12a-radxa-zero-pwm-c-on-gpiox-8.dtbo \ + meson-g12a-radxa-zero-pwmao-a-on-gpioao-11.dtbo \ + meson-g12a-radxa-zero-spi-spidev.dtbo \ + meson-g12a-radxa-zero-uart-ao-a-on-gpioao-0-gpioao-1.dtbo \ + meson-g12a-radxa-zero-uart-ao-b-on-gpioao-2-gpioao-3.dtbo \ + meson-g12a-radxa-zero-uart-ao-b-on-gpioao-8-gpioao-9.dtbo \ + meson-g12a-radxa-zero-uart-ee-c.dtbo \ + meson-g12b-bananapi-cm4-i2c2.dtbo \ + meson-g12b-bananapi-cm4-pwm-gpioh-5-fan.dtbo \ + meson-g12b-bananapi-cm4-wifi-freq-200mhz.dtbo \ + meson-g12b-bananapi-m2s-rtl8822cs.dtbo \ + meson-g12b-odroid-n2-spi.dtbo \ + meson-g12b-waveshare-cm4-io-base-usb.dtbo \ + meson-sm1-bananapi-m5-rtl8822cs.dtbo \ + meson-sm1-bananapi-uartA.dtbo \ + meson-sm1-bananapi-uartA_cts_rts.dtbo \ + meson-sm1-bananapi-uartAO_B.dtbo \ + meson-sm1-jethome-jethub-j200-spi.dtbo \ + meson-sm1-odroid-c4-i2c0.dtbo \ + meson-sm1-odroid-c4-i2c1.dtbo + +scr-$(CONFIG_ARCH_MESON) += \ + meson-fixup.scr + +dtbotxt-$(CONFIG_ARCH_MESON) += \ + README.meson-overlays + +dtb-y += $(dtbo-y) $(scr-y) $(dtbotxt-y) + +clean-files := *.dtbo *.scr diff --git a/patch/kernel/archive/meson64-6.13/overlay/README.meson-overlays b/patch/kernel/archive/meson64-6.13/overlay/README.meson-overlays new file mode 100644 index 000000000..e5f810a62 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/README.meson-overlays @@ -0,0 +1,31 @@ +This document describes overlays provided in the kernel packages +For generic Armbian overlays documentation please see +https://docs.armbian.com/User-Guide_Allwinner_overlays/ + +### Platform: + +meson (Amlogic) + +### Provided overlays: + +- i2c8 +- meson-sm1-odroid-c4-i2c0 +- meson-sm1-odroid-c4-i2c1 + +### Overlay details: + +### i2c8 + +Activates TWI/I2C bus 8 + +I2C8 pins (SCL, SDA): GPIO1-C4, GPIO1-C5 + +### meson-sm1-odroid-c4-i2c0 + +Activates i2c2 bus over GPIOX-17(D3/SDA) and GPIOX-18(D5/SCL) +Aliased to i2c0 for hardkernel odroid-c4 compatibility + +### meson-sm1-odroid-c4-i2c1 + +Activates i2c3 bus over GPIOA-14(D27/SDA) and GPIOA-15(D28/SCL) +Aliased to i2c1 for hardkernel odroid-c4 compatibility diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-fixup.scr-cmd b/patch/kernel/archive/meson64-6.13/overlay/meson-fixup.scr-cmd new file mode 100644 index 000000000..d4c39e20a --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-fixup.scr-cmd @@ -0,0 +1,4 @@ +# overlays fixup script +# implements (or rather substitutes) overlay arguments functionality +# using u-boot scripting, environment variables and "fdt" command + diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12-gxl-cma-pool-896MB.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12-gxl-cma-pool-896MB.dtso new file mode 100644 index 000000000..f8c476b04 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12-gxl-cma-pool-896MB.dtso @@ -0,0 +1,19 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "amlogic,g12a", "amlogic,g12b", "amlogic,meson-gxl"; + + fragment@0 { + target-path = "/reserved-memory"; + __overlay__ { + linux,cma { + compatible = "shared-dma-pool"; + reusable; + size = <0x0 0x38000000>; + alignment = <0x0 0x400000>; + linux,cma-default; + }; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12-pwm-gpiox-5-fan.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12-pwm-gpiox-5-fan.dtso new file mode 100644 index 000000000..2042c7fed --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12-pwm-gpiox-5-fan.dtso @@ -0,0 +1,43 @@ +/dts-v1/; +/plugin/; + +#include +#include +#include + +/ { + compatible = "amlogic,a311d", "amlogic,g12a", "amlogic,g12b", "amlogic,sm1"; + + fragment@0 { + target-path = "/"; + __overlay__ { + fan: gpio-fan { + compatible = "gpio-fan"; + gpios = <&gpio GPIOX_5 GPIO_ACTIVE_HIGH>; + gpio-fan,speed-map = <0 0>, <5000 1>; + #cooling-cells = <2>; + }; + }; + }; + + fragment@1 { + target = <&cpu_thermal>; + polling-delay = <2000>; + __overlay__ { + trips { + cpu_active: cpu-active { + temperature = <55000>; + hysteresis = <10000>; + type = "active"; + }; + }; + + cooling-maps { + map { + trip = <&cpu_active>; + cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-gpio-10-led.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-gpio-10-led.dtso new file mode 100644 index 000000000..d76430328 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-gpio-10-led.dtso @@ -0,0 +1,26 @@ +/dts-v1/; +/plugin/; + +#include +#include + +/ { + compatible = "radxa,zero", "amlogic,g12a"; + + fragment@0 { + target-path = "/"; + __overlay__ { + + leds { + compatible = "gpio-leds"; + + led-green { + label = "radxa-zero:green"; + gpios = <&gpio_ao GPIOAO_10 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "heartbeat"; + default-state = "on"; + }; + }; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-gpio-8-led.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-gpio-8-led.dtso new file mode 100644 index 000000000..9b294e97f --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-gpio-8-led.dtso @@ -0,0 +1,26 @@ +/dts-v1/; +/plugin/; + +#include +#include + +/ { + compatible = "radxa,zero", "amlogic,g12a"; + + fragment@0 { + target-path = "/"; + __overlay__ { + + leds { + compatible = "gpio-leds"; + + led-green { + label = "radxa-zero:green"; + gpios = <&gpio_ao GPIOAO_8 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "heartbeat"; + default-state = "on"; + }; + }; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-i2c-ao-m0-gpioao-2-gpioao-3.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-i2c-ao-m0-gpioao-2-gpioao-3.dtso new file mode 100644 index 000000000..3f241cb60 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-i2c-ao-m0-gpioao-2-gpioao-3.dtso @@ -0,0 +1,15 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "radxa,zero", "amlogic,g12a"; + + fragment@0 { + target = <&i2c_AO>; + __overlay__ { + status = "okay"; + pinctrl-0 = <&i2c_ao_sck_pins &i2c_ao_sda_pins>; + pinctrl-names = "default"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-i2c-ee-m1-gpioh-6-gpioh-7.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-i2c-ee-m1-gpioh-6-gpioh-7.dtso new file mode 100644 index 000000000..a68284bf6 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-i2c-ee-m1-gpioh-6-gpioh-7.dtso @@ -0,0 +1,15 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "radxa,zero", "amlogic,g12a"; + + fragment@0 { + target = <&i2c1>; + __overlay__ { + status = "okay"; + pinctrl-0 = <&i2c1_sda_h6_pins &i2c1_sck_h7_pins>; + pinctrl-names = "default"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-i2c-ee-m1-gpiox-10-gpiox-11.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-i2c-ee-m1-gpiox-10-gpiox-11.dtso new file mode 100644 index 000000000..eb9c402fb --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-i2c-ee-m1-gpiox-10-gpiox-11.dtso @@ -0,0 +1,15 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "radxa,zero", "amlogic,g12a"; + + fragment@0 { + target = <&i2c1>; + __overlay__ { + status = "okay"; + pinctrl-0 = <&i2c1_sda_x_pins &i2c1_sck_x_pins>; + pinctrl-names = "default"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-i2c-ee-m3-gpioa-14-gpioa-15.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-i2c-ee-m3-gpioa-14-gpioa-15.dtso new file mode 100644 index 000000000..12a7bc4d4 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-i2c-ee-m3-gpioa-14-gpioa-15.dtso @@ -0,0 +1,15 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "radxa,zero", "amlogic,g12a"; + + fragment@0 { + target = <&i2c3>; + __overlay__ { + status = "okay"; + pinctrl-0 = <&i2c3_sck_a_pins &i2c3_sda_a_pins>; + pinctrl-names = "default"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-pwm-c-on-gpiox-8.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-pwm-c-on-gpiox-8.dtso new file mode 100644 index 000000000..14ca6c196 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-pwm-c-on-gpiox-8.dtso @@ -0,0 +1,17 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "radxa,zero", "amlogic,g12a"; + + fragment@0 { + target = <&pwm_cd>; + __overlay__ { + status = "okay"; + pinctrl-0 = <&pwm_c_x8_pins>; + pinctrl-names = "default"; + clocks = <&xtal>; + clock-names = "clkin2"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-pwmao-a-on-gpioao-11.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-pwmao-a-on-gpioao-11.dtso new file mode 100644 index 000000000..6edbe6222 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-pwmao-a-on-gpioao-11.dtso @@ -0,0 +1,17 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "radxa,zero", "amlogic,g12a"; + + fragment@0 { + target = <&pwm_AO_ab>; + __overlay__ { + status = "okay"; + pinctrl-0 = <&pwm_ao_a_pins>; + pinctrl-names = "default"; + clocks = <&xtal>; + clock-names = "clkin3"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-spi-spidev.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-spi-spidev.dtso new file mode 100644 index 000000000..3d49a512e --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-spi-spidev.dtso @@ -0,0 +1,38 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "radxa,zero", "amlogic,g12a"; + + fragment@0 { + target = <&spicc0>; + __overlay__ { + pinctrl-0 = <&spicc0_x_pins &spicc0_ss0_x_pins>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + spidev@0 { + compatible = "armbian,spi-dev"; + status = "disabled"; + reg = <0>; + spi-max-frequency = <10000000>; + }; + }; + }; + + fragment@1 { + target = <&spicc1>; + __overlay__ { + pinctrl-0 = <&spicc1_pins &spicc1_ss0_pins>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + spidev@0 { + compatible = "armbian,spi-dev"; + status = "disabled"; + reg = <0>; + spi-max-frequency = <10000000>; + }; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-uart-ao-a-on-gpioao-0-gpioao-1.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-uart-ao-a-on-gpioao-0-gpioao-1.dtso new file mode 100644 index 000000000..350448d20 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-uart-ao-a-on-gpioao-0-gpioao-1.dtso @@ -0,0 +1,15 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "radxa,zero", "amlogic,g12a"; + + fragment@0 { + target = <&uart_AO>; + __overlay__ { + status = "okay"; + pinctrl-0 = <&uart_ao_a_pins>; + pinctrl-names = "default"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-uart-ao-b-on-gpioao-2-gpioao-3.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-uart-ao-b-on-gpioao-2-gpioao-3.dtso new file mode 100644 index 000000000..26790de42 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-uart-ao-b-on-gpioao-2-gpioao-3.dtso @@ -0,0 +1,15 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "radxa,zero", "amlogic,g12a"; + + fragment@0 { + target = <&uart_AO_B>; + __overlay__ { + status = "okay"; + pinctrl-0 = <&uart_ao_b_2_3_pins>; + pinctrl-names = "default"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-uart-ao-b-on-gpioao-8-gpioao-9.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-uart-ao-b-on-gpioao-8-gpioao-9.dtso new file mode 100644 index 000000000..ff3e52285 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-uart-ao-b-on-gpioao-8-gpioao-9.dtso @@ -0,0 +1,15 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "radxa,zero", "amlogic,g12a"; + + fragment@0 { + target = <&uart_AO_B>; + __overlay__ { + status = "okay"; + pinctrl-0 = <&uart_ao_b_8_9_pins>; + pinctrl-names = "default"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-uart-ee-c.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-uart-ee-c.dtso new file mode 100644 index 000000000..afcf79eea --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12a-radxa-zero-uart-ee-c.dtso @@ -0,0 +1,15 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "radxa,zero", "amlogic,g12a"; + + fragment@0 { + target = <&uart_C>; + __overlay__ { + status = "okay"; + pinctrl-0 = <&uart_c_pins &uart_c_cts_rts_pins>; + pinctrl-names = "default"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12b-bananapi-cm4-i2c2.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12b-bananapi-cm4-i2c2.dtso new file mode 100644 index 000000000..b0fbeee3d --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12b-bananapi-cm4-i2c2.dtso @@ -0,0 +1,20 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "bananapi,bpi-cm4io", "bananapi,bpi-cm4", "amlogic,a311d", "amlogic,g12b"; + + fragment@0 { + target = <&i2c2>; + __overlay__ { + status = "okay"; + }; + }; + + fragment@1 { + target = <&uart_A>; + __overlay__ { + status = "disabled"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12b-bananapi-cm4-pwm-gpioh-5-fan.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12b-bananapi-cm4-pwm-gpioh-5-fan.dtso new file mode 100644 index 000000000..db8d326c8 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12b-bananapi-cm4-pwm-gpioh-5-fan.dtso @@ -0,0 +1,63 @@ +/dts-v1/; +/plugin/; + +#include +#include +#include + +/ { + compatible = "bananapi,bpi-cm4io", "bananapi,bpi-cm4", "amlogic,a311d", "amlogic,g12b"; + + fragment@0 { + target-path = "/"; + __overlay__ { + fan: gpio-fan { + compatible = "gpio-fan"; + gpios = <&gpio GPIOH_5 GPIO_ACTIVE_HIGH>; + gpio-fan,speed-map = <0 0>, <5000 1>; + #cooling-cells = <2>; + }; + }; + }; + + fragment@1 { + target = <&cpu_thermal>; + polling-delay = <2000>; + __overlay__ { + trips { + cpu_active: cpu-active { + temperature = <55000>; + hysteresis = <10000>; + type = "active"; + }; + }; + + cooling-maps { + map { + trip = <&cpu_active>; + cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + }; + + fragment@2 { + target = <&ddr_thermal>; + __overlay__ { + trips { + ddr_active: ddr-active { + temperature = <55000>; + hysteresis = <10000>; + type = "active"; + }; + }; + + cooling-maps { + map { + trip = <&ddr_active>; + cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12b-bananapi-cm4-wifi-freq-200mhz.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12b-bananapi-cm4-wifi-freq-200mhz.dtso new file mode 100644 index 000000000..71fbdcd9a --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12b-bananapi-cm4-wifi-freq-200mhz.dtso @@ -0,0 +1,22 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "bananapi,bpi-cm4io", "bananapi,bpi-cm4", "amlogic,a311d", "amlogic,g12b"; + + fragment@0 { + target-path = "/"; + __overlay__ { + sdio-pwrseq { + post-power-on-delay-ms = <200>; + }; + }; + }; + + fragment@1 { + target = <&sd_emmc_a>; + __overlay__ { + max-frequency = <200000000>; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12b-bananapi-m2s-rtl8822cs.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12b-bananapi-m2s-rtl8822cs.dtso new file mode 100644 index 000000000..f037f8ec4 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12b-bananapi-m2s-rtl8822cs.dtso @@ -0,0 +1,22 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "bananapi,bpi-m2s", "amlogic,a311d", "amlogic,g12b"; + + /* RTL8822CS SDIO WIFI */ + fragment@0 { + target = <&sd_emmc_a>; + __overlay__ { + status = "okay"; + }; + }; + + /* RTL8822CS BLUETOOTH */ + fragment@1 { + target = <&uart_A>; + __overlay__ { + status = "okay"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12b-odroid-n2-spi.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12b-odroid-n2-spi.dtso new file mode 100644 index 000000000..658afb1fb --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12b-odroid-n2-spi.dtso @@ -0,0 +1,23 @@ +/dts-v1/; +/plugin/; + +#include +#include +#include + +/ { + fragment@0 { + target = <&sd_emmc_c>; + __overlay__ { + pinctrl-0 = <&emmc_ctrl_pins>, <&emmc_data_4b_pins>, <&emmc_ds_pins>; + bus-width = <4>; + }; + }; + + fragment@1 { + target = <&spifc>; + __overlay__ { + status = "okay"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-g12b-waveshare-cm4-io-base-usb.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-g12b-waveshare-cm4-io-base-usb.dtso new file mode 100644 index 000000000..051611326 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-g12b-waveshare-cm4-io-base-usb.dtso @@ -0,0 +1,20 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "bananapi,bpi-cm4io", "bananapi,bpi-cm4", "amlogic,a311d", "amlogic,g12b"; + + fragment@0 { + target-path = "/"; + __overlay__ { + model = "Waveshare CM4-IO Baseboard with BPI-CM4 Module"; + }; + }; + + fragment@1 { + target = <&usb>; + __overlay__ { + dr_mode = "host"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-i2cA.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-i2cA.dtso new file mode 100644 index 000000000..bfb72feb7 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-i2cA.dtso @@ -0,0 +1,17 @@ +/dts-v1/; + +/ { + compatible = "amlogic,meson-gxbb"; + fragment@0 { + target-path = "/aliases"; + __overlay__ { + i2cA = "/soc/bus@c1100000/i2c@8500"; + }; + }; + fragment@1 { + target-path = "/soc/bus@c1100000/i2c@8500"; + __overlay__ { + status = "okay"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-i2cB.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-i2cB.dtso new file mode 100644 index 000000000..d75867bce --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-i2cB.dtso @@ -0,0 +1,17 @@ +/dts-v1/; + +/ { + compatible = "amlogic,meson-gxbb"; + fragment@0 { + target-path = "/aliases"; + __overlay__ { + i2cA = "/soc/bus@c1100000/i2c@87c0"; + }; + }; + fragment@1 { + target-path = "/soc/bus@c1100000/i2c@87c0"; + __overlay__ { + status = "okay"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-bananapi-m5-rtl8822cs.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-bananapi-m5-rtl8822cs.dtso new file mode 100644 index 000000000..44323e6da --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-bananapi-m5-rtl8822cs.dtso @@ -0,0 +1,22 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "bananapi,bpi-m5", "amlogic,sm1"; + + /* RTL8822CS SDIO WIFI */ + fragment@0 { + target = <&sd_emmc_a>; + __overlay__ { + status = "okay"; + }; + }; + + /* RTL8822CS BLUETOOTH */ + fragment@1 { + target = <&uart_A>; + __overlay__ { + status = "okay"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-bananapi-uartA.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-bananapi-uartA.dtso new file mode 100644 index 000000000..ea2f40178 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-bananapi-uartA.dtso @@ -0,0 +1,15 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "bananapi,bpi-m5", "bananapi,bpi-m2-pro", "amlogic,sm1"; + + fragment@0 { + target = <&uart_A>; + + __overlay__ { + status = "okay"; + }; + }; +}; + diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-bananapi-uartAO_B.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-bananapi-uartAO_B.dtso new file mode 100644 index 000000000..efac8a514 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-bananapi-uartAO_B.dtso @@ -0,0 +1,14 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "bananapi,bpi-m5", "bananapi,bpi-m2-pro", "amlogic,sm1"; + + fragment@0 { + target = <&uart_AO_B>; + + __overlay__ { + status = "okay"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-bananapi-uartA_cts_rts.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-bananapi-uartA_cts_rts.dtso new file mode 100644 index 000000000..40276d8e5 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-bananapi-uartA_cts_rts.dtso @@ -0,0 +1,17 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "bananapi,bpi-m5", "bananapi,bpi-m2-pro", "amlogic,sm1"; + + fragment@0 { + target = <&uart_A>; + + __overlay__ { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&uart_a_cts_rts_pins>; + }; + }; +}; + diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-jethome-jethub-j200-spi.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-jethome-jethub-j200-spi.dtso new file mode 100644 index 000000000..eab65a157 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-jethome-jethub-j200-spi.dtso @@ -0,0 +1,19 @@ +/dts-v1/; +/plugin/; + +/ { + fragment@0 { + target = <&sd_emmc_c>; + __overlay__ { + pinctrl-0 = <&emmc_ctrl_pins>, <&emmc_data_4b_pins>, <&emmc_ds_pins>; + bus-width = <4>; + }; + }; + + fragment@1 { + target = <&spifc>; + __overlay__ { + status = "okay"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-odroid-c4-i2c0.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-odroid-c4-i2c0.dtso new file mode 100644 index 000000000..84d0db355 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-odroid-c4-i2c0.dtso @@ -0,0 +1,24 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "hardkernel,odroid-c4", "amlogic,sm1"; + + fragment@0 { + target-path = "/aliases"; + __overlay__ { + i2c0 = "/soc/bus@ffd00000/i2c@1d000"; + }; + }; + + fragment@1 { + target = <&i2c2>; + __overlay__ { + status = "okay"; + clock-frequency = <100000>; + pinctrl-0 = <&i2c2_sck_x_pins &i2c2_sda_x_pins>; + pinctrl-names = "default"; + }; + }; + +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-odroid-c4-i2c1.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-odroid-c4-i2c1.dtso new file mode 100644 index 000000000..1074ebf2e --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-sm1-odroid-c4-i2c1.dtso @@ -0,0 +1,24 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "hardkernel,odroid-c4", "amlogic,sm1"; + + fragment@0 { + target-path = "/aliases"; + __overlay__ { + i2c1 = "/soc/bus@ffd00000/i2c@1c000"; + }; + }; + + fragment@1 { + target = <&i2c3>; + __overlay__ { + status = "okay"; + clock-frequency = <100000>; + pinctrl-0 = <&i2c3_sck_a_pins &i2c3_sda_a_pins>; + pinctrl-names = "default"; + }; + }; + +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-uartA.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-uartA.dtso new file mode 100644 index 000000000..3aecd60aa --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-uartA.dtso @@ -0,0 +1,11 @@ +/dts-v1/; + +/ { + compatible = "amlogic,meson-gxbb"; + fragment@0 { + target-path = "/soc/bus@c1100000/serial@84c0"; + __overlay__ { + status = "okay"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-uartC.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-uartC.dtso new file mode 100644 index 000000000..2b40ee4c0 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-uartC.dtso @@ -0,0 +1,11 @@ +/dts-v1/; + +/ { + compatible = "amlogic,meson-gxbb"; + fragment@0 { + target-path = "/soc/bus@c1100000/serial@8700"; + __overlay__ { + status = "okay"; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-w1-gpio.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-w1-gpio.dtso new file mode 100644 index 000000000..ac76a4f20 --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-w1-gpio.dtso @@ -0,0 +1,20 @@ +// Definitions for w1-gpio module (without external pullup) +/dts-v1/; +/plugin/; + +/ { + compatible = "amlogic,meson-gxbb"; + + fragment@0 { + target-path = "/"; + __overlay__ { + + w1: onewire@0 { + compatible = "w1-gpio"; + pinctrl-names = "default"; + gpios = <&gpio 91 6>; // GPIOY_16 + status = "okay"; + }; + }; + }; +}; diff --git a/patch/kernel/archive/meson64-6.13/overlay/meson-w1AB-gpio.dtso b/patch/kernel/archive/meson64-6.13/overlay/meson-w1AB-gpio.dtso new file mode 100644 index 000000000..f6b0d7eff --- /dev/null +++ b/patch/kernel/archive/meson64-6.13/overlay/meson-w1AB-gpio.dtso @@ -0,0 +1,32 @@ +// Definitions for w1-gpio module (without external pullup) +/dts-v1/; +/plugin/; + +/ { + compatible = "amlogic,meson-gxbb"; + + fragment@0 { + target-path = "/"; + __overlay__ { + + w1a: onewire@0 { + compatible = "w1-gpio"; + pinctrl-names = "default"; + gpios = <&gpio 91 6>; // GPIOY_16 + status = "okay"; + }; + }; + }; + fragment@1 { + target-path = "/"; + __overlay__ { + + w1b: onewire@1 { + compatible = "w1-gpio"; + pinctrl-names = "default"; + gpios = <&gpio 90 6>; // GPIOY_15 + status = "okay"; + }; + }; + }; +};