usb, ohci, pci: add DM support for PCI-based OHCI USB controller
authorHeiko Schocher <hs@denx.de>
Tue, 16 Jul 2019 08:49:07 +0000 (10:49 +0200)
committerMarek Vasut <marex@denx.de>
Thu, 8 Aug 2019 09:35:02 +0000 (11:35 +0200)
add new DM based PCI driver ohci-pci for PCI-based
OHCI USB support.

Signed-off-by: Heiko Schocher <hs@denx.de>
drivers/usb/host/Kconfig
drivers/usb/host/Makefile
drivers/usb/host/ohci-pci.c [new file with mode: 0644]

index ac68aa2d276414fa04c76fa14f12d5f9ad73d9ac..42046c8062b4c1110859f48e8cb7fb9940bbc92f 100644 (file)
@@ -236,6 +236,13 @@ config USB_OHCI_HCD
          based system where you're not sure, the "lspci -v" entry will list the
          right "prog-if" for your USB controller(s):  EHCI, OHCI, or UHCI.
 
+config USB_OHCI_PCI
+       bool "Support for PCI-based OHCI USB controller"
+       depends on DM_USB
+       default n
+       help
+         Enables support for the PCI-based OHCI controller.
+
 if USB_OHCI_HCD
 
 config USB_OHCI_GENERIC
index 6aa574f6f712c579e7c20b61a55f0d00e9398238..dd13528475cd0f538006ec95a8a97ab45926bdb9 100644 (file)
@@ -16,6 +16,7 @@ obj-$(CONFIG_USB_R8A66597_HCD) += r8a66597-hcd.o
 obj-$(CONFIG_USB_SL811HS) += sl811-hcd.o
 obj-$(CONFIG_USB_OHCI_EP93XX) += ohci-ep93xx.o
 obj-$(CONFIG_USB_OHCI_LPC32XX) += ohci-lpc32xx.o
+obj-$(CONFIG_USB_OHCI_PCI) += ohci-pci.o
 obj-$(CONFIG_USB_OHCI_GENERIC) += ohci-generic.o
 
 # echi
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
new file mode 100644 (file)
index 0000000..4c1c778
--- /dev/null
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2019
+ * Heiko Schocher, DENX Software Engineering, hs@denx.de.
+ *
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <pci.h>
+#include <usb.h>
+#include <asm/io.h>
+
+#include "ohci.h"
+
+static int ohci_pci_probe(struct udevice *dev)
+{
+       struct ohci_regs *regs;
+
+       regs = dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
+       return ohci_register(dev, regs);
+}
+
+static int ohci_pci_remove(struct udevice *dev)
+{
+       return ohci_deregister(dev);
+}
+
+static const struct udevice_id ohci_pci_ids[] = {
+       { .compatible = "ohci-pci" },
+       { }
+};
+
+U_BOOT_DRIVER(ohci_pci) = {
+       .name   = "ohci_pci",
+       .id     = UCLASS_USB,
+       .probe = ohci_pci_probe,
+       .remove = ohci_pci_remove,
+       .of_match = ohci_pci_ids,
+       .ops    = &ohci_usb_ops,
+       .platdata_auto_alloc_size = sizeof(struct usb_platdata),
+       .priv_auto_alloc_size = sizeof(ohci_t),
+       .flags  = DM_FLAG_ALLOC_PRIV_DMA,
+};
+
+static struct pci_device_id ohci_pci_supported[] = {
+       { PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_OHCI, ~0) },
+       {},
+};
+
+U_BOOT_PCI_DEVICE(ohci_pci, ohci_pci_supported);