[U-Boot] [PATCH v1 0/5] usb, ohci-hcd: add usb ohci pci DM driver

add DM support for USB OHCI over PCI. Therefore first add some small fixes to get usb ohci-hcd driver working again with mpc85xx.
Base for the patchset is: 6070ef409c - Merge branch '2019-07-12-master-imports'
Travis build see: https://travis-ci.org/hsdenx/u-boot-test/builds/559243960
Heiko Schocher (5): usb, ohci-hdc: fix warning 'ohci_pci_ids' defined but not used usb, ohci: fix ohci swap register access usb, ohci-hcd: set OHCI_USE_NPS if DM_PCI usb, ohci: add warning if none on pci found usb, ohci, pci: add DM support for PCI-based OHCI USB controller
drivers/usb/host/Kconfig | 7 +++++ drivers/usb/host/Makefile | 1 + drivers/usb/host/ohci-hcd.c | 12 ++++++--- drivers/usb/host/ohci-pci.c | 52 +++++++++++++++++++++++++++++++++++++ drivers/usb/host/ohci.h | 4 +-- 5 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 drivers/usb/host/ohci-pci.c

var ohci_pci_ids is only used if DM_USB is not enabled. So define this varaible only if !CONFIG_IS_ENABLED(DM_USB)
Signed-off-by: Heiko Schocher hs@denx.de
---
drivers/usb/host/ohci-hcd.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 2b0df88f49..bd498da096 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -64,6 +64,7 @@ #define OHCI_CONTROL_INIT \ (OHCI_CTRL_CBSR & 0x3) | OHCI_CTRL_IE | OHCI_CTRL_PLE
+#if !CONFIG_IS_ENABLED(DM_USB) #ifdef CONFIG_PCI_OHCI static struct pci_device_id ohci_pci_ids[] = { {0x10b9, 0x5237}, /* ULI1575 PCI OHCI module ids */ @@ -73,6 +74,7 @@ static struct pci_device_id ohci_pci_ids[] = { {0, 0} }; #endif +#endif
#ifdef CONFIG_PCI_EHCI_DEVNO static struct pci_device_id ehci_pci_ids[] = {

commit 57faca19a82f ("drivers: USB: OHCI: allow compilation for 64-bit targets") broke ohci support for the mpc85xx based socrates board, as it removed volatile keyword from ohci_readl/writel.
Fix this so usb works again on socrates board.
Signed-off-by: Heiko Schocher hs@denx.de ---
drivers/usb/host/ohci.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h index f9f02cb09c..9b264bd92a 100644 --- a/drivers/usb/host/ohci.h +++ b/drivers/usb/host/ohci.h @@ -14,8 +14,8 @@ #include <asm/io.h>
#ifdef CONFIG_SYS_OHCI_SWAP_REG_ACCESS -# define ohci_readl(a) __swap_32(readl(a)) -# define ohci_writel(v, a) writel(__swap_32(v), a) +# define ohci_readl(a) __swap_32(in_be32((u32 *)a)) +# define ohci_writel(a, b) out_be32((u32 *)b, __swap_32(a)) #else # define ohci_readl(a) readl(a) # define ohci_writel(v, a) writel(v, a)

set OHCI_USE_NPS if DM_PCI is enabled.
Signed-off-by: Heiko Schocher hs@denx.de ---
drivers/usb/host/ohci-hcd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index bd498da096..23ea2af5d7 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -50,8 +50,9 @@ #endif
#if defined(CONFIG_CPU_ARM920T) || \ - defined(CONFIG_PCI_OHCI) || \ - defined(CONFIG_SYS_OHCI_USE_NPS) + defined(CONFIG_PCI_OHCI) || \ + defined(CONFIG_DM_PCI) || \ + defined(CONFIG_SYS_OHCI_USE_NPS) # define OHCI_USE_NPS /* force NoPowerSwitching mode */ #endif

Signed-off-by: Heiko Schocher hs@denx.de ---
drivers/usb/host/ohci-hcd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 23ea2af5d7..58aa824ec0 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -2047,8 +2047,11 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller) pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &base); printf("OHCI regs address 0x%08x\n", base); gohci.regs = (struct ohci_regs *)base; - } else + } else { + printf("%s: OHCI devnr: %d not found\n", __func__, + CONFIG_PCI_OHCI_DEVNO); return -1; + } #else gohci.regs = (struct ohci_regs *)CONFIG_SYS_USB_OHCI_REGS_BASE; #endif

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 | 7 +++++ drivers/usb/host/Makefile | 1 + drivers/usb/host/ohci-pci.c | 52 +++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 drivers/usb/host/ohci-pci.c
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index b1188bcbf5..96954d1673 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -235,6 +235,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 diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 6aa574f6f7..dd13528475 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -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 index 0000000000..4c1c778672 --- /dev/null +++ b/drivers/usb/host/ohci-pci.c @@ -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);

On 7/16/19 10:49 AM, Heiko Schocher wrote:
add DM support for USB OHCI over PCI. Therefore first add some small fixes to get usb ohci-hcd driver working again with mpc85xx.
Base for the patchset is: 6070ef409c - Merge branch '2019-07-12-master-imports'
Applied all, thanks.
participants (2)
-
Heiko Schocher
-
Marek Vasut