Hi.
I have a problem with usb power.
[root@alarm gpio]# echo 17 > /sys/class/gpio/export
-bash: echo: write error: Device or resource busy
Can I drive the USB_EN gpio?
I have a 3.7.1 kernel and an arch linux distro.
The original distro (the one on the SD bought on the site) did not have the support to wi-fi
Anyone have any suggestions please?
Cristian
I'm trying to understand what drives the pin. Could it be the voltage regulator driver.
This version of the kernel uses DeviceTree:
arch/arm/boot/dts/imx23-olinuxino.dts
In the bottom of file:
regulators {
compatible = "simple-bus";
reg_usb0_vbus: usb0_vbus {
compatible = "regulator-fixed";
regulator-name = "usb0_vbus";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
enable-active-high;
startup-delay-us = <300>; /* LAN9215 requires a POR of 200us minimum */
gpio = <&gpio0 17 0>;
};
};
and in the kernel config I have CONFIG_REGULATOR_FIXED_VOLTAGE=y.
So, I hope to turn vbus off by sysfs but /sys/class/regulator/regulator.1/power is empty.
Reading the kernel docs, Documentation/devicetree/bindings/regulator/fixed-regulator.txt, I understand fixed like "not variable" but I should be able to turn off.
If this is right... how?
Maybe your answer is here : https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-regulator
Thanks, this help me but I have neither state nor status files :(
I tried a work around building voltage sensor fixed as module and managed to free the gpio.
Now, echo 17 > /sys/class/gpio/export work fine!! (and I'm be able to switch vbus power)
Few minutes later, however, I realized that I can not use it because the wi-fi is connected to vbus and not to 3.3VIO as in the schematic.
I will use a relay... :-\
Just for information, I have found that similar thing happen with led control: CONFIG_LEDS_GPIO=y and some CONFIG_LEDS_TRIGGERS*. By this kernel support, led can be controlled with something like "echo heartbeat > /sys/class/leds/green/trigger" to get it to blink.
Cristian C.
Found this thread via google, so thought it might help someone else...
Quote from: ciarez on May 07, 2013, 07:35:48 PM
Hi.
I have a problem with usb power.
[root@alarm gpio]# echo 17 > /sys/class/gpio/export
-bash: echo: write error: Device or resource busy
Can I drive the USB_EN gpio?
The reason the device/resource is busy is because gpio17 is claimed by the USB power regulator, which at least on my olinuxino micro is called usb0_vbus.4, found in
/sys/class/regulator. To turn it off, you send the regulator name to the unbind file in its driver folder:
echo -n "usb0_vbus.4" > /sys/bus/platform/drivers/reg-fixed-voltage/unbind
Once you do that, you can
echo 17 > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio17/direction
echo 0 > /sys/class/gpio/gpio17/value
and turn off the USB power via the USB_EN GPIO.
It does not appear necessary to re-bind the regulator driver. Echoing a 1 to gpio17/value is sufficient to turn USB power back on which automatically reloads drivers for whatever is attached (assuming that works when physically plugging/unplugging devices).
Rebinding the driver requires unexporting the gpio and echoing the bus name to the bind file:
echo 17 > /sys/class/gpio/unexport
echo -n "usb0_vbus.4" > /sys/bus/platform/drivers/reg-fixed-voltage/bind
This unfortunately causes the USB power to be off regardless of the previous setting of gpio17.
Maybe in a few months somebody can chime in and tell us how to enable power to the USB using the usb0_vbus driver?
Maybe this is obvious, but turning bus power on and off this way doesn't affect USB devices that are plugged into a powered hub. This turns on and off USB power only - the data links are unaffected.