Indeed, it looks like How do you reset a USB device from the command line? but here you want to reset the host not the device. I don't think you can reset just one port, or at least that any such API is available from the kernel.
But you might reset the same way as the device (unbind/bind) the whole USB host bus or the controller.
Sadly, usbreset from usbutils does only allow to pass a USB bus device name (usb1, usb2, etc.) and controller requires resetting non USB buses (PCI, etc.).
For the USB bus reset the process left my USB bus in a bad state (I was able to recover by resetting the whole controller via ssh as my keyboard and mouse were on this usb1 bus) but here it is as it is supposed to work:
check lsusb output and if your port/device is on bus 1 (usb1), then
echo "usb1" | sudo tee /sys/bus/usb/drivers/usb/unbind; echo "usb1" | sudo tee /sys/bus/usb/drivers/usb/bind
As told previously, it left me without any device on this bus, though that might be a bug with my kernel.
To reset the whole controller (I only had one for my two USB buses), I checked lspci, where I had:
00:14.0 USB controller: Intel Corporation 200 Series/Z370 Chipset Family USB 3.0 xHCI Controller
then I did
echo "0000:00:14.0" | sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind ; echo "0000:00:14.0" | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind
You might have to change the xhci_hcd depending on the USB version your controller is (ehci_hcd, etc.).
Edit: my answer was for an Intel platform where USB is PCI, but you are on Raspberry, ARM. I don't have a Raspberry, but on a Rockchip RK3399 platform (Helios64) USB controllers are for USB2 or below on /sys/bus/platform/devices/ehci-platform and /sys/bus/platform/drivers/ohci-platform/, and for USB3 /sys/bus/platform/drivers/xhci-hcd/. In this directories you will find symlinks like xhci-hcd.0.auto, fe3a0000.usb, etc that you can echo to these directories unbun and bind files.
And inside these symlinks you will find folders telling the USB buses they control /sys/bus/platform/drivers/ohci-platform/fe3a0000.usb/ has usb4 in it.
lsusb
Bus 002 Device 005: ID 0bda:8156 Realtek Semiconductor Corp. USB 10/100/1G/2.5G LAN
Bus 002 Device 006: ID 0480:b207 Toshiba America Inc Canvio Ready
Bus 002 Device 008: ID 0bc2:231a Seagate RSS LLC Expansion Portable
Bus 002 Device 007: ID 1058:2621 Western Digital Technologies, Inc. Elements 2621
Bus 002 Device 004: ID 0bda:0411 Realtek Semiconductor Corp. Hub
Bus 002 Device 003: ID 0bda:0411 Realtek Semiconductor Corp. Hub
Bus 002 Device 002: ID 2109:0815 VIA Labs, Inc. USB3.0 Hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 006: ID 0463:ffff MGE UPS Systems UPS
Bus 001 Device 005: ID 0bda:5411 Realtek Semiconductor Corp. RTS5411 Hub
Bus 001 Device 003: ID 0bda:5411 Realtek Semiconductor Corp. RTS5411 Hub
Bus 001 Device 002: ID 2109:2815 VIA Labs, Inc. USB2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
ls /sys/bus/platform/drivers/xhci-hcd/ -l
total 0
--w------- 1 root root 4096 29 mai 17:18 bind
--w------- 1 root root 4096 29 mai 16:58 uevent
--w------- 1 root root 4096 29 mai 17:18 unbind
lrwxrwxrwx 1 root root 0 29 mai 16:58 xhci-hcd.0.auto -> ../../../../devices/platform/usb@fe900000/fe900000.usb/xhci-hcd.0.auto
lrwxrwxrwx 1 root root 0 29 mai 17:19 xhci-hcd.5.auto -> ../../../../devices/platform/usb@fe800000/fe800000.usb/xhci-hcd.5.auto
ls /sys/bus/platform/drivers/xhci-hcd/xhci-hcd.5.auto/ -l
total 0
lrwxrwxrwx 1 root root 0 29 mai 17:18 driver -> ../../../../../bus/platform/drivers/xhci-hcd
-rw-r--r-- 1 root root 4096 29 mai 16:59 driver_override
-r--r--r-- 1 root root 4096 29 mai 16:59 modalias
drwxr-xr-x 2 root root 0 29 mai 16:59 power
lrwxrwxrwx 1 root root 0 29 mai 16:59 software_node -> ../../../../../kernel/software_nodes/node1
lrwxrwxrwx 1 root root 0 29 mai 16:59 subsystem -> ../../../../../bus/platform
-rw-r--r-- 1 root root 4096 29 mai 16:59 uevent
drwxr-xr-x 5 root root 0 29 mai 17:18 usb5
drwxr-xr-x 5 root root 0 29 mai 17:18 usb6
So, to reset USB bus 5 controller:
echo "xhci-hcd.5.auto" | sudo tee /sys/bus/platform/drivers/xhci-hcd/unbind && echo "xhci-hcd.5.auto" | sudo tee /sys/bus/platform//drivers/xhci-hcd/bind
weirdly the bind fails with my kernel... the first time, so I have to bind twice. Ie first bind gives:
mai 29 17:18:05 helios64 kernel: xhci-hcd xhci-hcd.5.auto: xHCI Host Controller
mai 29 17:18:05 helios64 kernel: xhci-hcd xhci-hcd.5.auto: new USB bus registered, assigned bus number 5
mai 29 17:18:05 helios64 kernel: xhci-hcd xhci-hcd.5.auto: Host halt failed, -110
mai 29 17:18:05 helios64 kernel: xhci-hcd xhci-hcd.5.auto: can't setup: -110
mai 29 17:18:05 helios64 kernel: xhci-hcd xhci-hcd.5.auto: USB bus 5 deregistered
mai 29 17:18:05 helios64 kernel: xhci-hcd xhci-hcd.5.auto: probe with driver xhci-hcd failed with error -110
the second gives:
mai 29 17:18:08 helios64 kernel: xhci-hcd xhci-hcd.5.auto: xHCI Host Controller
mai 29 17:18:08 helios64 kernel: xhci-hcd xhci-hcd.5.auto: new USB bus registered, assigned bus number 5
mai 29 17:18:08 helios64 kernel: xhci-hcd xhci-hcd.5.auto: hcc params 0x0220fe64 hci version 0x110 quirks 0x0000808002000010
mai 29 17:18:08 helios64 kernel: xhci-hcd xhci-hcd.5.auto: irq 95, io mem 0xfe800000
mai 29 17:18:08 helios64 kernel: xhci-hcd xhci-hcd.5.auto: xHCI Host Controller
mai 29 17:18:08 helios64 kernel: xhci-hcd xhci-hcd.5.auto: new USB bus registered, assigned bus number 6
mai 29 17:18:08 helios64 kernel: xhci-hcd xhci-hcd.5.auto: Host supports USB 3.0 SuperSpeed
mai 29 17:18:08 helios64 kernel: usb usb5: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 6.12
mai 29 17:18:08 helios64 kernel: usb usb5: New USB device strings: Mfr=3, Product=2, SerialNumber=1
mai 29 17:18:08 helios64 kernel: usb usb5: Product: xHCI Host Controller
mai 29 17:18:08 helios64 kernel: usb usb5: Manufacturer: Linux 6.12.22-current-rockchip64 xhci-hcd
mai 29 17:18:08 helios64 kernel: usb usb5: SerialNumber: xhci-hcd.5.auto
mai 29 17:18:08 helios64 kernel: hub 5-0:1.0: USB hub found
mai 29 17:18:08 helios64 kernel: hub 5-0:1.0: 1 port detected
mai 29 17:18:08 helios64 kernel: usb usb6: We don't know the algorithms for LPM for this host, disabling LPM.
mai 29 17:18:08 helios64 kernel: rockchip-i2s ff8a0000.i2s: Could not register PCM
mai 29 17:18:08 helios64 kernel: usb usb6: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 6.12
mai 29 17:18:08 helios64 kernel: usb usb6: New USB device strings: Mfr=3, Product=2, SerialNumber=1
mai 29 17:18:08 helios64 kernel: usb usb6: Product: xHCI Host Controller
mai 29 17:18:08 helios64 kernel: usb usb6: Manufacturer: Linux 6.12.22-current-rockchip64 xhci-hcd
mai 29 17:18:08 helios64 kernel: usb usb6: SerialNumber: xhci-hcd.5.auto
mai 29 17:18:08 helios64 kernel: hub 6-0:1.0: USB hub found
mai 29 17:18:08 helios64 kernel: hub 6-0:1.0: 1 port detected
mai 29 17:18:08 helios64 kernel: rockchip-i2s ff8a0000.i2s: Could not register PCM
I tried adding a sleep between unbind and bind, it does not change the behavior, so it must be a bug in the kernel driver.