0

I would like to find the pci_id of Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p in the output below.

/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 1: Dev 5, If 0, Class=Hub, Driver=hub/4p, 480M
            |__ Port 2: Dev 7, If 0, Class=Hub, Driver=hub/4p, 480M
                |__ Port 1: Dev 10, If 0, Class=Vendor Specific Class, Driver=ftdi_sio, 12M

I can't seem to find any way to map this to any of these three:

lspci -nn | grep USB
00:14.0 USB controller [0c03]: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI [8086:8c31] (rev 05)
00:1a.0 USB controller [0c03]: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #2 [8086:8c2d] (rev 05)
00:1d.0 USB controller [0c03]: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #1 [8086:8c26] (rev 05)
2
  • 1
    You might try udevadm info -a -p /sys/class/tty/ttyUSB0 which goes up the tree showing device and vendor attributes.
    – meuh
    Sep 19, 2018 at 7:48
  • @meuh - another useful weapon for my arsenal, but in the task at hand I actually prefer what I scripted - MUCH easier to parse.
    – tink
    Sep 19, 2018 at 8:33

2 Answers 2

1

If the Debain discover package is available, it will give you the information you are seekiing

# discover --vendor-id --model-id pci | grep USB

1
  • Nice tool I hadn't stumbled upon; but it doesn't tell me which of the three my USB UARTs are connected to.
    – tink
    Sep 19, 2018 at 2:04
1

After some more googling, some thought and a bit of trial & error I came up with this:

#!/bin/bash
[ -h /sys/class/tty/ttyUSB0 ] || exit 1
pci_id=$( /usr/bin/realpath /sys/class/tty/ttyUSB0 | awk -F'/' '{print gensub(/....:(.*)/, "\\1","1",$5)}' )
usb_id=$( lspci -n| awk -v id=$pci_id '$0 ~ id {print $3}' )

which, when run, gives me the desired result for the scenario above:

./get_usb.sh
8086:8c26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.