root@OpenWrt:~# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/18040000.gpio, 18040000.gpio:
gpio-11 ( |tp-link:green:usb1 ) out lo
gpio-12 ( |tp-link:green:usb2 ) out lo
gpio-13 ( |tp-link:green:wlan2g) out hi
gpio-14 ( |tp-link:green:system) out lo
gpio-15 ( |tp-link:green:qss ) out hi
gpio-16 ( |gpio-keys ) in hi
gpio-17 ( |gpio-keys ) in lo
gpio-18 ( |tp-link:ext:lna0 ) out hi
gpio-19 ( |tp-link:ext:lna1 ) out hi
gpio-21 ( |tp-link:power:usb2 ) out hi
gpio-22 ( |tp-link:power:usb1 ) out hi
gpiochip1: GPIOs 496-511, parent: pci/0000:00:00.0, ath9k-phy1:
gpio-496 ( |tp-link:green:wlan5g) out lo
root@OpenWrt:~# echo 0 > /sys/class/gpio/gpio22/value
-ash: can't create /sys/class/gpio/gpio22/value: nonexistent directory
root@OpenWrt:~# echo 0 > /sys/class/gpio/gpio21/value
-ash: can't create /sys/class/gpio/gpio21/value: nonexistent directory
root@OpenWrt:~# cat /sys/kernel/debug/gpio
To turn off USB1: echo 0 > /sys/class/gpio/tp-link:power:usb1/value To turn off USB2: echo 0 > /sys/class/gpio/tp-link:power:usb2/value
To turn on USB1: echo 1 > /sys/class/gpio/tp-link:power:usb1/value To turn on USB2: echo 1 > /sys/class/gpio/tp-link:power:usb2/value
Enjoy.
EDIT:
For gracefully shutting down USB power, I recommend adding these lines before and after the actual power cycle - to unbind and to bind the usb device, which is in essence "ejecting the usb before powering off and inserting the usb before powering on":
This will save the routers internal USB hub from errors and softbrick, as it happened to me today when I was testing my new script. Reboot fixed it, but the whole idea of this USB power command is to save time, and not to reboot (for example, a 4G dongle power cycle is faster than a full reboot). Besides, the softbrick of USB hub is not detected by any scripts, so essentially the process stops.