Add small OHCI PCI driver for USB 1.1 OHCI controllers on PCI bus. This driver matches only on PCI class (serial-ohci) and requires DM-USB ; any sort of deprecated legacy usage is not supported.
Signed-off-by: Marek Vasut <marek.vasut+rene...@gmail.com> --- drivers/usb/host/Kconfig | 6 ++++ drivers/usb/host/Makefile | 1 + drivers/usb/host/ohci-pci.c | 55 +++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 drivers/usb/host/ohci-pci.c diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index a213c918bc..045aa0a3f6 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -224,6 +224,12 @@ config USB_OHCI_GENERIC ---help--- Enables support for generic OHCI controller. +config USB_OHCI_PCI + bool "Support for PCI-based OHCI USB controller" + depends on DM_USB + help + Enables support for the PCI-based OHCI controller. + endif # USB_OHCI_HCD config USB_UHCI_HCD diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index cb8c315a15..b7c94cadcb 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_USB_OHCI_EP93XX) += ohci-ep93xx.o obj-$(CONFIG_USB_OHCI_SUNXI) += ohci-sunxi.o obj-$(CONFIG_USB_OHCI_LPC32XX) += ohci-lpc32xx.o obj-$(CONFIG_USB_OHCI_GENERIC) += ohci-generic.o +obj-$(CONFIG_USB_OHCI_PCI) += ohci-pci.o # echi obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c new file mode 100644 index 0000000000..dd078f008e --- /dev/null +++ b/drivers/usb/host/ohci-pci.c @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2018 Marek Vasut <marek.va...@gmail.com> + */ + +#include <common.h> +#include <dm.h> +#include <errno.h> +#include <pci.h> +#include <usb.h> +#include <asm/io.h> + +#include "ohci.h" + +/* Information about the USB port */ +struct ohci_pci_priv { + ohci_t ohci; +}; + +static int ohci_pci_probe(struct udevice *dev) +{ + struct ohci_regs *regs; + u32 cmd; + + regs = dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, PCI_REGION_MEM); + if (!regs) + return -ENOMEM; + + /* Enable busmaster */ + dm_pci_read_config32(dev, PCI_COMMAND, &cmd); + cmd |= PCI_COMMAND_MASTER; + dm_pci_write_config32(dev, PCI_COMMAND, cmd); + + debug("OHCI-PCI init regs %p\n", regs); + + return ohci_register(dev, regs); +} + +U_BOOT_DRIVER(ohci_pci) = { + .name = "ohci_pci", + .id = UCLASS_USB, + .probe = ohci_pci_probe, + .remove = ohci_deregister, + .ops = &ohci_usb_ops, + .platdata_auto_alloc_size = sizeof(struct usb_platdata), + .priv_auto_alloc_size = sizeof(struct ohci_pci_priv), + .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); -- 2.18.0 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot