Search code examples
linux-kernelusbembedded-linuxhid

Minimal Linux kernel options to enable hid input


I need to handle a HID device (a barcode reader) with a custom Linux (v5.8).

I have a modulerized kernel which works as expected with other USB peripherals (storage and serial are known to work), but I seem unable to scan this device.

Plugging it into a desktop (Linux Mint "Ulyana", if it matters) I get a normal enumeration:

[525428.367216] usb 1-11: new full-speed USB device number 9 using xhci_hcd
[525428.517071] usb 1-11: New USB device found, idVendor=05e0, idProduct=1200, bcdDevice= 1.00
[525428.517077] usb 1-11: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[525428.517080] usb 1-11: Product: Symbol Bar Code Scanner
[525428.517083] usb 1-11: Manufacturer: Symbol Technologies, Inc, 2008
[525428.517086] usb 1-11: SerialNumber: S/N:0641F625A3A943949AF00BAB171ABFE2 Rev:PAACFS00-001-R023
[525428.519932] input: Symbol Technologies, Inc, 2008 Symbol Bar Code Scanner as /devices/pci0000:00/0000:00:14.0/usb1/1-11/1-11:1.0/0003:05E0:1200.0005/input/input32
[525428.579736] hid-generic 0003:05E0:1200.0005: input,hidraw4: USB HID v1.10 Keyboard [Symbol Technologies, Inc, 2008 Symbol Bar Code Scanner] on usb-0000:00:14.0-11/input0

While on my target I see no sign of the new peripheral; lsusb displays just the root HUB even when I manually modprobe (what I think are) the relevant modules:

# lsusb
Bus 001 Device 001: ID 1d6b:0002
# lsmod
Module                  Size  Used by    Not tainted
usbhid                 23296  0 
usbmon                 19424  0 
mt7603e                38048  0 
mt76                   31648  1 mt7603e
mac80211              380000  2 mt7603e,mt76
sha256_generic          2240  0 
libsha256               8480  1 sha256_generic
ehci_platform           4704  0 
cfg80211              236736  3 mt7603e,mt76,mac80211
ehci_hcd               37936  1 ehci_platform
rfkill                  8544  1 cfg80211
usbcore               143456  4 usbhid,usbmon,ehci_platform,ehci_hcd
libarc4                  832  1 mac80211
mtk_eth                30208  0 
usb_common              2768  3 usbmon,ehci_platform,usbcore

I am obviously missing something, but I seem unable to understand what. What should I cross-check?

Note: please feel free to ask for relevant details, I did not put too many things here just to avoid cluttering but I'm fully prepared to give all info deemed useful.


Solution

  • It turns out OHCI driver is needed to handle low speed peripherals even if they're connected to USB2 (EHCI) controller.

    Actually MT7628 has a "secondary" OHCI controller not even advertised in Data Sheet.

    This means that, on top of selecting CONFIG_USB_OHCI_HCD=m and CONFIG_USB_OHCI_HCD_PLATFORM=m also the following patch is needed:

    diff --git a/arch/mips/boot/dts/ralink/mt7628a.dtsi b/arch/mips/boot/dts/ralink/mt7628a.dtsi
    index bf6b6a459bd6..b4ac008fdfdf 100644
    --- a/arch/mips/boot/dts/ralink/mt7628a.dtsi
    +++ b/arch/mips/boot/dts/ralink/mt7628a.dtsi
    @@ -323,6 +323,17 @@ ehci@101c0000 {
            interrupts = <18>;
        };
     
    +   ohci@101c1000 {
    +       compatible = "generic-ohci";
    +       reg = <0x101c1000 0x1000>;
    +
    +       phys = <&usb_phy>;
    +       phy-names = "usb";
    +
    +       interrupt-parent = <&intc>;
    +       interrupts = <18>;
    +   };
    +
        ethernet: ethernet@10100000 {
            compatible = "ralink,rt5350-eth";
            reg = <0x10100000 0x10000>;
    

    Note address 101c1000 is nowhere mentioned in MT7628 programming manual and it's "one cell away" (0x1000) from standard (and documented) EHCI controller cell (at 101c0000).

    I assume similar situation is also true for other SoCs because USB standard mandates to "hand over" low speed devices to a legacy USB1 controller.

    I hope this will spare a lot of headache to whoever will stumble in the same problem.