From a81ddf97e5cb242f9e6b2e97289380003268bb4a Mon Sep 17 00:00:00 2001 From: Paolo Sabatino Date: Sat, 4 May 2024 15:18:28 +0200 Subject: [PATCH] rockchip: add usb reset props in kernel for rk322x --- .../archive/rockchip-6.6/armbian.series | 1 + .../rk322x-usb-reset-props.patch | 75 +++++++++++++++++++ patch/kernel/archive/rockchip-6.6/series.conf | 1 + .../archive/rockchip-6.8/armbian.series | 6 +- .../rk322x-usb-reset-props.patch | 75 +++++++++++++++++++ patch/kernel/archive/rockchip-6.8/series.conf | 6 +- 6 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 patch/kernel/archive/rockchip-6.6/patches.armbian/rk322x-usb-reset-props.patch create mode 100644 patch/kernel/archive/rockchip-6.8/patches.armbian/rk322x-usb-reset-props.patch diff --git a/patch/kernel/archive/rockchip-6.6/armbian.series b/patch/kernel/archive/rockchip-6.6/armbian.series index 3fd63480c9..afd8f3b903 100644 --- a/patch/kernel/archive/rockchip-6.6/armbian.series +++ b/patch/kernel/archive/rockchip-6.6/armbian.series @@ -45,6 +45,7 @@ patches.armbian/rk322x-dmc-driver-03-dfi-driver.patch patches.armbian/rk322x-dmc-driver-04-driver.patch patches.armbian/rk322x-dwc2-no-clock-gating.patch + patches.armbian/rk322x-usb-reset-props.patch patches.armbian/wifi-ath9k-no-bulk-EP3-EP4.patch patches.armbian/wifi-brcmfmac-add-bcm43342.patch patches.armbian/wifi-brcmfmac-ap6330-firmware.patch diff --git a/patch/kernel/archive/rockchip-6.6/patches.armbian/rk322x-usb-reset-props.patch b/patch/kernel/archive/rockchip-6.6/patches.armbian/rk322x-usb-reset-props.patch new file mode 100644 index 0000000000..81deaa758e --- /dev/null +++ b/patch/kernel/archive/rockchip-6.6/patches.armbian/rk322x-usb-reset-props.patch @@ -0,0 +1,75 @@ +From 6668d12fd4a628299ffbf89794b6f7f67416e3fa Mon Sep 17 00:00:00 2001 +From: Paolo Sabatino +Date: Sat, 4 May 2024 15:12:43 +0200 +Subject: [PATCH] add reset props to usb otg/ehci ports + +usb resets are needed in case u-boot does its own reset +of the devices, otherwise ports are left in a +non-functional state. Also fixes occasional missing +device detection on the OTG port. + +In any case, when reset are present, the iddig filter +wait time always times out, so we comment it as it +looks unnecessary (the port works fine, the device is +always detected also in case of timeout) +--- + arch/arm/boot/dts/rockchip/rk322x.dtsi | 8 ++++++++ + drivers/usb/dwc2/core.c | 2 +- + 2 files changed, 9 insertions(+), 1 deletion(-) + +diff --git a/arch/arm/boot/dts/rockchip/rk322x.dtsi b/arch/arm/boot/dts/rockchip/rk322x.dtsi +index 03d9baddcbab..17c5f0a8fcf3 100644 +--- a/arch/arm/boot/dts/rockchip/rk322x.dtsi ++++ b/arch/arm/boot/dts/rockchip/rk322x.dtsi +@@ -807,6 +807,8 @@ usb_otg: usb@30040000 { + g-tx-fifo-size = <256 128 128 64 32 16>; + phys = <&u2phy0_otg>; + phy-names = "usb2-phy"; ++ resets = <&cru SRST_USBOTG>; ++ reset-names = "dwc2"; + status = "disabled"; + }; + +@@ -817,6 +819,8 @@ usb_host0_ehci: usb@30080000 { + clocks = <&cru HCLK_HOST0>, <&u2phy0>; + phys = <&u2phy0_host>; + phy-names = "usb"; ++ resets = <&cru SRST_USBHOST0>; ++ reset-names = "ehci"; + status = "disabled"; + }; + +@@ -837,6 +841,8 @@ usb_host1_ehci: usb@300c0000 { + clocks = <&cru HCLK_HOST1>, <&u2phy1>; + phys = <&u2phy1_otg>; + phy-names = "usb"; ++ resets = <&cru SRST_USBHOST1>; ++ reset-names = "ehci"; + status = "disabled"; + }; + +@@ -857,6 +863,8 @@ usb_host2_ehci: usb@30100000 { + clocks = <&cru HCLK_HOST2>, <&u2phy1>; + phys = <&u2phy1_host>; + phy-names = "usb"; ++ resets = <&cru SRST_USBHOST2>; ++ reset-names = "ehci"; + status = "disabled"; + }; + +diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c +index 5635e4d7ec88..1e20aabc2033 100644 +--- a/drivers/usb/dwc2/core.c ++++ b/drivers/usb/dwc2/core.c +@@ -413,7 +413,7 @@ int dwc2_core_reset(struct dwc2_hsotg *hsotg, bool skip_wait) + + if (!(gotgctl & GOTGCTL_CONID_B) || + (gusbcfg & GUSBCFG_FORCEHOSTMODE)) { +- wait_for_host_mode = true; ++ wait_for_host_mode = false; + } + } + +-- +2.34.1 + diff --git a/patch/kernel/archive/rockchip-6.6/series.conf b/patch/kernel/archive/rockchip-6.6/series.conf index 7f86f25b0d..13e491c12e 100644 --- a/patch/kernel/archive/rockchip-6.6/series.conf +++ b/patch/kernel/archive/rockchip-6.6/series.conf @@ -55,6 +55,7 @@ patches.armbian/rk322x-dmc-driver-03-dfi-driver.patch patches.armbian/rk322x-dmc-driver-04-driver.patch patches.armbian/rk322x-dwc2-no-clock-gating.patch + patches.armbian/rk322x-usb-reset-props.patch patches.armbian/wifi-ath9k-no-bulk-EP3-EP4.patch patches.armbian/wifi-brcmfmac-add-bcm43342.patch patches.armbian/wifi-brcmfmac-ap6330-firmware.patch diff --git a/patch/kernel/archive/rockchip-6.8/armbian.series b/patch/kernel/archive/rockchip-6.8/armbian.series index 022bc576b6..afd8f3b903 100644 --- a/patch/kernel/archive/rockchip-6.8/armbian.series +++ b/patch/kernel/archive/rockchip-6.8/armbian.series @@ -29,6 +29,9 @@ patches.armbian/general-add-overlay-compilation-support.patch patches.armbian/general-add-overlay-configfs.patch patches.armbian/general-add-restart-handler-for-act8846.patch + patches.armbian/general-dwc2-fix-wait-peripheral.patch + patches.armbian/general-dwc2-fix-wait-time.patch + patches.armbian/general-dwc2-nak-gadget.patch patches.armbian/general-fix-reboot-from-kwiboo.patch patches.armbian/general-linux-export-mm-trace-rss-stats.patch patches.armbian/general-rk322x-gpio-ir-driver.patch @@ -37,11 +40,12 @@ patches.armbian/ir-keymap-xt-q8l-v10.patch patches.armbian/misc-tinkerboard-spi-interface.patch patches.armbian/mmc-tinkerboard-sdmmc-reboot-fix.patch - patches.armbian/rk322x-dwc2-no-clock-gating.patch patches.armbian/rk322x-dmc-driver-01-sipv2-calls.patch patches.armbian/rk322x-dmc-driver-02-sip-constants.patch patches.armbian/rk322x-dmc-driver-03-dfi-driver.patch patches.armbian/rk322x-dmc-driver-04-driver.patch + patches.armbian/rk322x-dwc2-no-clock-gating.patch + patches.armbian/rk322x-usb-reset-props.patch patches.armbian/wifi-ath9k-no-bulk-EP3-EP4.patch patches.armbian/wifi-brcmfmac-add-bcm43342.patch patches.armbian/wifi-brcmfmac-ap6330-firmware.patch diff --git a/patch/kernel/archive/rockchip-6.8/patches.armbian/rk322x-usb-reset-props.patch b/patch/kernel/archive/rockchip-6.8/patches.armbian/rk322x-usb-reset-props.patch new file mode 100644 index 0000000000..81deaa758e --- /dev/null +++ b/patch/kernel/archive/rockchip-6.8/patches.armbian/rk322x-usb-reset-props.patch @@ -0,0 +1,75 @@ +From 6668d12fd4a628299ffbf89794b6f7f67416e3fa Mon Sep 17 00:00:00 2001 +From: Paolo Sabatino +Date: Sat, 4 May 2024 15:12:43 +0200 +Subject: [PATCH] add reset props to usb otg/ehci ports + +usb resets are needed in case u-boot does its own reset +of the devices, otherwise ports are left in a +non-functional state. Also fixes occasional missing +device detection on the OTG port. + +In any case, when reset are present, the iddig filter +wait time always times out, so we comment it as it +looks unnecessary (the port works fine, the device is +always detected also in case of timeout) +--- + arch/arm/boot/dts/rockchip/rk322x.dtsi | 8 ++++++++ + drivers/usb/dwc2/core.c | 2 +- + 2 files changed, 9 insertions(+), 1 deletion(-) + +diff --git a/arch/arm/boot/dts/rockchip/rk322x.dtsi b/arch/arm/boot/dts/rockchip/rk322x.dtsi +index 03d9baddcbab..17c5f0a8fcf3 100644 +--- a/arch/arm/boot/dts/rockchip/rk322x.dtsi ++++ b/arch/arm/boot/dts/rockchip/rk322x.dtsi +@@ -807,6 +807,8 @@ usb_otg: usb@30040000 { + g-tx-fifo-size = <256 128 128 64 32 16>; + phys = <&u2phy0_otg>; + phy-names = "usb2-phy"; ++ resets = <&cru SRST_USBOTG>; ++ reset-names = "dwc2"; + status = "disabled"; + }; + +@@ -817,6 +819,8 @@ usb_host0_ehci: usb@30080000 { + clocks = <&cru HCLK_HOST0>, <&u2phy0>; + phys = <&u2phy0_host>; + phy-names = "usb"; ++ resets = <&cru SRST_USBHOST0>; ++ reset-names = "ehci"; + status = "disabled"; + }; + +@@ -837,6 +841,8 @@ usb_host1_ehci: usb@300c0000 { + clocks = <&cru HCLK_HOST1>, <&u2phy1>; + phys = <&u2phy1_otg>; + phy-names = "usb"; ++ resets = <&cru SRST_USBHOST1>; ++ reset-names = "ehci"; + status = "disabled"; + }; + +@@ -857,6 +863,8 @@ usb_host2_ehci: usb@30100000 { + clocks = <&cru HCLK_HOST2>, <&u2phy1>; + phys = <&u2phy1_host>; + phy-names = "usb"; ++ resets = <&cru SRST_USBHOST2>; ++ reset-names = "ehci"; + status = "disabled"; + }; + +diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c +index 5635e4d7ec88..1e20aabc2033 100644 +--- a/drivers/usb/dwc2/core.c ++++ b/drivers/usb/dwc2/core.c +@@ -413,7 +413,7 @@ int dwc2_core_reset(struct dwc2_hsotg *hsotg, bool skip_wait) + + if (!(gotgctl & GOTGCTL_CONID_B) || + (gusbcfg & GUSBCFG_FORCEHOSTMODE)) { +- wait_for_host_mode = true; ++ wait_for_host_mode = false; + } + } + +-- +2.34.1 + diff --git a/patch/kernel/archive/rockchip-6.8/series.conf b/patch/kernel/archive/rockchip-6.8/series.conf index 7283ce7a57..530f1fbbb0 100644 --- a/patch/kernel/archive/rockchip-6.8/series.conf +++ b/patch/kernel/archive/rockchip-6.8/series.conf @@ -38,6 +38,9 @@ patches.armbian/general-add-overlay-compilation-support.patch patches.armbian/general-add-overlay-configfs.patch patches.armbian/general-add-restart-handler-for-act8846.patch + patches.armbian/general-dwc2-fix-wait-peripheral.patch + patches.armbian/general-dwc2-fix-wait-time.patch + patches.armbian/general-dwc2-nak-gadget.patch patches.armbian/general-fix-reboot-from-kwiboo.patch patches.armbian/general-linux-export-mm-trace-rss-stats.patch patches.armbian/general-rk322x-gpio-ir-driver.patch @@ -46,11 +49,12 @@ patches.armbian/ir-keymap-xt-q8l-v10.patch patches.armbian/misc-tinkerboard-spi-interface.patch patches.armbian/mmc-tinkerboard-sdmmc-reboot-fix.patch - patches.armbian/rk322x-dwc2-no-clock-gating.patch patches.armbian/rk322x-dmc-driver-01-sipv2-calls.patch patches.armbian/rk322x-dmc-driver-02-sip-constants.patch patches.armbian/rk322x-dmc-driver-03-dfi-driver.patch patches.armbian/rk322x-dmc-driver-04-driver.patch + patches.armbian/rk322x-dwc2-no-clock-gating.patch + patches.armbian/rk322x-usb-reset-props.patch patches.armbian/wifi-ath9k-no-bulk-EP3-EP4.patch patches.armbian/wifi-brcmfmac-add-bcm43342.patch patches.armbian/wifi-brcmfmac-ap6330-firmware.patch