2023-04-21 22:14:00

by Lorenz Brun

[permalink] [raw]
Subject: [PATCH v2] arm64: dts: rockchip: fix USB regulator on ROCK64

Currently the ROCK64 device tree specifies two regulators, vcc_host_5v
and vcc_host1_5v for USB VBUS on the device. Both of those are however
specified with RK_PA2 as the GPIO enabling them, causing the following
error when booting:

rockchip-pinctrl pinctrl: pin gpio0-2 already requested by vcc-host-5v-regulator; cannot claim for vcc-host1-5v-regulator
rockchip-pinctrl pinctrl: pin-2 (vcc-host1-5v-regulator) status -22
rockchip-pinctrl pinctrl: could not request pin 2 (gpio0-2) from group usb20-host-drv on device rockchip-pinctrl
reg-fixed-voltage vcc-host1-5v-regulator: Error applying setting, reverse things back

Looking at the schematic, there are in fact three USB regulators,
vcc_host_5v, vcc_host1_5v and vcc_otg_v5. But the enable signal for all
three is driven by Q2604 which is in turn driven by GPIO_A2/PA2.

Since these three regulators are not controllable separately, I removed
the second one which was causing the error and added labels for all
rails to the single regulator.

Signed-off-by: Lorenz Brun <[email protected]>
---
v1 -> v2: add labels for all rails, change description to match
---
arch/arm64/boot/dts/rockchip/rk3328-rock64.dts | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts b/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts
index f69a38f42d2d..5d608e2776e9 100644
--- a/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts
@@ -37,7 +37,8 @@ vcc_sd: sdmmc-regulator {
vin-supply = <&vcc_io>;
};

- vcc_host_5v: vcc-host-5v-regulator {
+ // Common enable line for all of the rails mentioned in the labels.
+ vcc_host_5v: vcc_host1_5v: vcc_otg_5v: vcc-host-5v-regulator {
compatible = "regulator-fixed";
gpio = <&gpio0 RK_PA2 GPIO_ACTIVE_LOW>;
pinctrl-names = "default";
@@ -48,17 +49,6 @@ vcc_host_5v: vcc-host-5v-regulator {
vin-supply = <&vcc_sys>;
};

- vcc_host1_5v: vcc_otg_5v: vcc-host1-5v-regulator {
- compatible = "regulator-fixed";
- gpio = <&gpio0 RK_PA2 GPIO_ACTIVE_LOW>;
- pinctrl-names = "default";
- pinctrl-0 = <&usb20_host_drv>;
- regulator-name = "vcc_host1_5v";
- regulator-always-on;
- regulator-boot-on;
- vin-supply = <&vcc_sys>;
- };
-
vcc_sys: vcc-sys {
compatible = "regulator-fixed";
regulator-name = "vcc_sys";
--
2.39.2


2023-04-26 12:07:26

by Diederik de Haas

[permalink] [raw]
Subject: Re: [PATCH v2] arm64: dts: rockchip: fix USB regulator on ROCK64

On Friday, 21 April 2023 23:38:41 CEST Lorenz Brun wrote:
> rockchip-pinctrl pinctrl: pin gpio0-2 already requested by vcc-host-5v-regulator; cannot claim for vcc-host1-5v-regulator
> rockchip-pinctrl pinctrl: pin-2 (vcc-host1-5v-regulator) status -22
> rockchip-pinctrl pinctrl: could not request pin 2 (gpio0-2) from group usb20-host-drv on device rockchip-pinctrl
> reg-fixed-voltage vcc-host1-5v-regulator: Error applying setting, reverse things back

I booted the Debian 6.1.0-8-arm64 kernel (6.1.25-1) on my Rock64 and then
booted that kernel with this patch applied (6.1.25-2) and this is the result:

diederik@rock64-dev:~$ uname -a
Linux rock64-dev 6.1.0-8-arm64 #1 SMP Debian 6.1.25-1 (2023-04-22) aarch64 GNU/Linux
diederik@rock64-dev:~$ su -l
Password:
root@rock64-dev:~# dmesg --level emerg,alert,crit,err
[ 7.296781] rockchip-pinctrl pinctrl: pin gpio0-2 already requested by vcc-host-5v-regulator; cannot claim for vcc-host1-5v-regulator
[ 7.298007] rockchip-pinctrl pinctrl: pin-2 (vcc-host1-5v-regulator) status -22
[ 7.298694] rockchip-pinctrl pinctrl: could not request pin 2 (gpio0-2) from group usb20-host-drv on device rockchip-pinctrl
[ 7.299736] reg-fixed-voltage vcc-host1-5v-regulator: Error applying setting, reverse things back
[ 7.525107] rk_gmac-dwmac ff540000.ethernet: cannot get clock clk_mac_speed

root@rock64-dev:~# dmesg --level emerg,alert,crit,err,warn
[ 5.295285] dw-apb-uart ff130000.serial: forbid DMA for kernel console
[ 7.296781] rockchip-pinctrl pinctrl: pin gpio0-2 already requested by vcc-host-5v-regulator; cannot claim for vcc-host1-5v-regulator
[ 7.298007] rockchip-pinctrl pinctrl: pin-2 (vcc-host1-5v-regulator) status -22
[ 7.298694] rockchip-pinctrl pinctrl: could not request pin 2 (gpio0-2) from group usb20-host-drv on device rockchip-pinctrl
[ 7.299736] reg-fixed-voltage vcc-host1-5v-regulator: Error applying setting, reverse things back
[ 7.312492] dwc2 ff580000.usb: supply vusb_d not found, using dummy regulator
[ 7.313483] dwc2 ff580000.usb: supply vusb_a not found, using dummy regulator
[ 7.525107] rk_gmac-dwmac ff540000.ethernet: cannot get clock clk_mac_speed
[ 12.299438] device-mapper: core: CONFIG_IMA_DISABLE_HTABLE is disabled. Duplicate IMA measurements will not be recorded in the IMA log.
[ 13.244268] systemd-journald[228]: File /var/log/journal/511b5fcdb7574d1f8604d582cf5c5b00/system.journal corrupted or uncleanly shut down, renaming and replacing.
[ 16.537752] dw_wdt ff1a0000.watchdog: No valid TOPs array specified
[ 16.615515] dwhdmi-rockchip ff3c0000.hdmi: supply avdd-0v9 not found, using dummy regulator
[ 16.616532] dwhdmi-rockchip ff3c0000.hdmi: supply avdd-1v8 not found, using dummy regulator
[ 17.177743] rockchip_vdec: module is from the staging directory, the quality is unknown, you have been warned.

root@rock64-dev:~# apt install /home/diederik/linux-image-6.1.0-8-rock64-regulator-arm64-unsigned_6.1.25-2_arm64.deb
...
The following NEW packages will be installed:
linux-image-6.1.0-8-rock64-regulator-arm64-unsigned
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/63.4 MB of archives.
After this operation, 455 MB of additional disk space will be used.
Get:1 /home/diederik/linux-image-6.1.0-8-rock64-regulator-arm64-unsigned_6.1.25-2_arm64.deb linux-image-6.1.0-8-rock64-regulator-arm64-unsigned arm64 6.1.25-2 [63.4 MB]
Selecting previously unselected package linux-image-6.1.0-8-rock64-regulator-arm64-unsigned.
...
/etc/kernel/postinst.d/zz-update-grub:
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.1.0-8-rock64-regulator-arm64
Found initrd image: /boot/initrd.img-6.1.0-8-rock64-regulator-arm64
Found linux image: /boot/vmlinuz-6.1.0-8-arm64
Found initrd image: /boot/initrd.img-6.1.0-8-arm64
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done
N: Download is performed unsandboxed as root as file '/home/diederik/linux-image-6.1.0-8-rock64-regulator-arm64-unsigned_6.1.25-2_arm64.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
root@rock64-dev:~# reboot
root@rock64-dev:~# Connection to rock64-dev closed by remote host.
Connection to rock64-dev closed.

diederik@bagend:~$ ssh rock64-dev
diederik@rock64-dev:~$ uname -a
Linux rock64-dev 6.1.0-8-rock64-regulator-arm64 #1 SMP Debian 6.1.25-2 (2023-04-25) aarch64 GNU/Linux
diederik@rock64-dev:~$ su -l
Password:
root@rock64-dev:~# dmesg --level emerg,alert,crit,err
[ 7.134332] rk_gmac-dwmac ff540000.ethernet: cannot get clock clk_mac_speed

root@rock64-dev:~# dmesg --level emerg,alert,crit,err,warn
[ 5.128440] dw-apb-uart ff130000.serial: forbid DMA for kernel console
[ 6.925949] dwc2 ff580000.usb: supply vusb_d not found, using dummy regulator
[ 6.926983] dwc2 ff580000.usb: supply vusb_a not found, using dummy regulator
[ 7.134332] rk_gmac-dwmac ff540000.ethernet: cannot get clock clk_mac_speed
[ 11.465583] device-mapper: core: CONFIG_IMA_DISABLE_HTABLE is disabled. Duplicate IMA measurements will not be recorded in the IMA log.
[ 12.358406] systemd-journald[231]: File /var/log/journal/511b5fcdb7574d1f8604d582cf5c5b00/system.journal corrupted or uncleanly shut down, renaming and replacing.
[ 14.865704] dwhdmi-rockchip ff3c0000.hdmi: supply avdd-0v9 not found, using dummy regulator
[ 14.866899] dwhdmi-rockchip ff3c0000.hdmi: supply avdd-1v8 not found, using dummy regulator
[ 14.882228] dw_wdt ff1a0000.watchdog: No valid TOPs array specified
[ 15.355843] rockchip_vdec: module is from the staging directory, the quality is unknown, you have been warned.

Everything seems to be working fine, but now with less errors in dmesg, so:

Tested-by: Diederik de Haas <[email protected]>


Attachments:
signature.asc (235.00 B)
This is a digitally signed message part.

2023-04-27 09:58:53

by Heiko Stuebner

[permalink] [raw]
Subject: Re: [PATCH v2] arm64: dts: rockchip: fix USB regulator on ROCK64

On Fri, 21 Apr 2023 23:38:41 +0200, Lorenz Brun wrote:
> Currently the ROCK64 device tree specifies two regulators, vcc_host_5v
> and vcc_host1_5v for USB VBUS on the device. Both of those are however
> specified with RK_PA2 as the GPIO enabling them, causing the following
> error when booting:
>
> rockchip-pinctrl pinctrl: pin gpio0-2 already requested by vcc-host-5v-regulator; cannot claim for vcc-host1-5v-regulator
> rockchip-pinctrl pinctrl: pin-2 (vcc-host1-5v-regulator) status -22
> rockchip-pinctrl pinctrl: could not request pin 2 (gpio0-2) from group usb20-host-drv on device rockchip-pinctrl
> reg-fixed-voltage vcc-host1-5v-regulator: Error applying setting, reverse things back
>
> [...]

Applied, thanks!

[1/1] arm64: dts: rockchip: fix USB regulator on ROCK64
commit: be6f6bc717e135bd5494b4d27f703026dc48b8f0

As fix for 6.4

Best regards,
--
Heiko Stuebner <[email protected]>