Cubox-i4 Pro: Disable USB port power

Hi. Im using ArchlinuxArm, is there a way to disable the power of one of the USB ports? I think this needs something on the hardware side to take out the 5v.


The USB port regulators are controlled by gpio’s and in the mainline kernel are defined as.

        v_usb2: regulator-v-usb2 {
                compatible = "regulator-fixed";
                gpio = <&gpio1 0 GPIO_ACTIVE_HIGH>;
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_cubox_i_usbh1_vbus>;
                regulator-max-microvolt = <5000000>;
                regulator-min-microvolt = <5000000>;
                regulator-name = "v_usb2";
                vin-supply = <&v_5v0>;

        v_usb1: regulator-v-usb1 {
                compatible = "regulator-fixed";
                gpio = <&gpio3 22 GPIO_ACTIVE_HIGH>;
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_cubox_i_usbotg_vbus>;
                regulator-max-microvolt = <5000000>;
                regulator-min-microvolt = <5000000>;
                regulator-name = "v_usb1";
                vin-supply = <&v_5v0>;

There is no existing kernel mechanism to control these regulators from userspace. In our BSP builds we use a patch to the userspace consumer regulator platform driver to make it device-tree enabled. meta-solidrun-arm-imx8/0006-regulator-userspace-consumer-add-DT-support.patch at kirkstone-imx8m · SolidRun/meta-solidrun-arm-imx8 · GitHub

Then you need to patch the device-tree to add a node to expose the control. This is the patch we use for our iMX8MP platforms, but it could easily be adapted to the iMX6 Cubox-i device-tree

+	power-usb-port1 {
+        	compatible = "reg-userspace-consumer";
+        	regulator-name = "usb-port1-pwr-consumer";
+		regulator-boot-on;
+		regulator-supplies = "vcc";
+        	vcc-supply = <&reg_usb1_host_vbus>;
+        	comment = "USB Port1 vbus power switch";
+    	};

Thanks @jnettlet !

This is all new to me. Let me put what you just wrote into simple actionable steps so I can tackle one by one.
In order:

  1. Patch the Kernel with the code you linked (as is, no modifications?)
  2. Patch the device tree.

You mentioned should be trivial to adapt the device tree patch to IMX6, but I do not know where to look at to adapt it (unless the patch you gave me was already fitted for IMX6).


Which kernel version are you using? I can probably write you a patch series to incorporate this pretty quickly. That is unless you want to give it a try.

The device-tree file would be, arch/arm/boot/dts/imx6qdl-cubox-i.dtsi

That would be awesome. Im not really interested in Kernel development, just want to be able to completely shut down my 3D printer connected to the Cubox without having to turn the box off :slight_smile:

My uname -a output is:
Linux alarm 6.2.8-1-ARCH #1 SMP PREEMPT Wed Mar 22 21:10:24 MDT 2023 armv7l GNU/Linux

Im using ArchlinuxArm.

Dont know if the patch you make is possible to merge upstream, would be a nice addition to Arch.


Does your 3d printer power itself off if the USB-port is not powered? Or do you just mean the controller for your 3d printer?

This patch won’t be mainlined, it was already attempted years ago and the mainline stance is that userspace should not be handling regulators. It is annoying but that is the status of things.

Yeah, the controller stays powered. And also in the same 5v rail has a fan that just keeps spinning.

My work around was to also shut the cubox, but having to unplug-plug to start is annoying.

Hmmm…so 6.2 has added this commit.

commit 5c51d4afcf3fd36159713556402e16cfab794ae9
Author: Zev Weiss <>
Date:   Mon Oct 31 16:37:04 2022 -0700

    regulator: userspace-consumer: Handle regulator-output DT nodes

I will need to see if we can leverage this to maybe mainline patches. Otherwise the patch I am using will need to be adapted to work with this new code. This may make things easier or more difficult, I will need to do some testing first.

Looks like you are having fun!

Thanks a lot!

Hi @jnettlet , any news?