You are not logged in.

#1 2018-01-27 21:44:13

Kabir
Member
From: India
Registered: 2016-12-06
Posts: 59

How to turn on /off a usb port on the fly

Hi,

Im trying to see if its possible to turn off / on a single usb port on demand and while its in use, so that I dont have to unplug / plug the device. The port is 1-10 with ID 1131:1810

~❯ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 03f0:2f4a Hewlett-Packard 
Bus 001 Device 003: ID 03f0:134a Hewlett-Packard Optical Mouse
Bus 001 Device 005: ID 1131:1810 Integrated System Solution Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

dmesg:

[13274.583531] usb 1-10: USB disconnect, device number 4
[13600.226176] usb 1-10: new full-speed USB device number 5 using xhci_hcd
[13600.375608] hid-generic 0003:1131:1810.0005: hiddev1,hidraw3: USB HID v1.11 Device [ISSC Simple HID Device ] on usb-0000:00:14.0-10/input0
[13990.225274] WARNING! power/level is deprecated; use power/control instead

According to https://www.kernel.org/doc/Documentatio … gement.txt power/control only accepts "on" and "auto" as arguments. So in my case Im connecting a speaker to the usb for charging it. How can I check if its usbfs file is open or if it even has one? I want to be able to tell the kernel when to start considering the device idle so I can autosuspend it by passing in auto to /sys/bus/usb/drivers/usb/1-10/power/control. Any ideas how I can achieve this?

Thanks for your time!

Offline

#2 2018-01-27 22:13:17

red-lichtie
Member
Registered: 2015-03-08
Posts: 47

Re: How to turn on /off a usb port on the fly

Set the suspend delay to 0 "echo 0 > /sys/bus/usb/drivers/usb/1-10/power/autosuspend_delay_ms" and the power mode to auto.

This is assuming that the driver supports suspend.


Doing it the Linux way since 1997 and Arch way since 2015 (and loving it!)
Platforms: Intel, ARMv6 (Raspberry Pi), ARMv7 (BeagleBone Black)
Languages: C, C++, ASM, Pascal & Java

Offline

#3 2018-01-28 13:33:51

Kabir
Member
From: India
Registered: 2016-12-06
Posts: 59

Re: How to turn on /off a usb port on the fly

That does suspend the usb port but only after I remove and reconnect the device. Is it possible to suspend while the device is connected and then wake up the device again whenever needed, because editing the autosuspend_delay_ms and control files did not wake it up without a reboot.

Thanks!

Offline

#4 2018-01-28 14:39:04

seth
Member
Registered: 2012-09-03
Posts: 32,129

Re: How to turn on /off a usb port on the fly

I'm not 100% sure but it rather sounds as if you want to unbind the port and not suspend it?
https://zedt.eu/tech/linux/restarting-u … em-centos/

Online

Board footer

Powered by FluxBB