Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: OHCI: Add quirk for LS7A OHCI controller (rev 0x02)

The OHCI controller (rev 0x02) under LS7A PCI host has a hardware flaw.
MMIO register with offset 0x60/0x64 is treated as legacy PS2-compatible
keyboard/mouse interface, which confuse the OHCI controller. Since OHCI
only use a 4KB BAR resource indeed, the LS7A OHCI controller's 32KB BAR
is wrapped around (the second 4KB BAR space is the same as the first 4KB
internally). So we can add an 4KB offset (0x1000) to the OHCI registers
(from the PCI BAR resource) as a quirk.

Cc: stable <stable@kernel.org>
Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Mingcong Bai <baimingcong@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Link: https://lore.kernel.org/r/20250328040059.3672979-1-chenhuacai@loongson.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Huacai Chen and committed by
Greg Kroah-Hartman
bcb60d43 38d6e60b

+23
+23
drivers/usb/host/ohci-pci.c
··· 165 165 return 0; 166 166 } 167 167 168 + static int ohci_quirk_loongson(struct usb_hcd *hcd) 169 + { 170 + struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 171 + 172 + /* 173 + * Loongson's LS7A OHCI controller (rev 0x02) has a 174 + * flaw. MMIO register with offset 0x60/64 is treated 175 + * as legacy PS2-compatible keyboard/mouse interface. 176 + * Since OHCI only use 4KB BAR resource, LS7A OHCI's 177 + * 32KB BAR is wrapped around (the 2nd 4KB BAR space 178 + * is the same as the 1st 4KB internally). So add 4KB 179 + * offset (0x1000) to the OHCI registers as a quirk. 180 + */ 181 + if (pdev->revision == 0x2) 182 + hcd->regs += SZ_4K; /* SZ_4K = 0x1000 */ 183 + 184 + return 0; 185 + } 186 + 168 187 static int ohci_quirk_qemu(struct usb_hcd *hcd) 169 188 { 170 189 struct ohci_hcd *ohci = hcd_to_ohci(hcd); ··· 242 223 { 243 224 PCI_DEVICE(PCI_VENDOR_ID_ATI, 0x4399), 244 225 .driver_data = (unsigned long)ohci_quirk_amd700, 226 + }, 227 + { 228 + PCI_DEVICE(PCI_VENDOR_ID_LOONGSON, 0x7a24), 229 + .driver_data = (unsigned long)ohci_quirk_loongson, 245 230 }, 246 231 { 247 232 .vendor = PCI_VENDOR_ID_APPLE,