[U-Boot] [PATCH] usb: add support of generic OHCI devices

This driver is meant to be used with any OHCI-compatible host controller in case if there's no need for platform-specific glue such as setup of controller or PHY's power mode via GPIOs etc.
Signed-off-by: Alexey Brodkin abrodkin@synopsys.com Cc: Simon Glass sjg@chromium.org Cc: Marek Vasut marex@denx.de --- drivers/usb/host/Kconfig | 8 ++++++++ drivers/usb/host/Makefile | 1 + drivers/usb/host/ohci-generic.c | 45 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 drivers/usb/host/ohci-generic.c
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 0096a2f..39f7185 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -26,6 +26,14 @@ config USB_XHCI_UNIPHIER
endif
+config USB_OHCI_GENERIC + bool "Support for generic OHCI USB controller" + depends on OF_CONTROL + depends on DM_USB + default n + ---help--- + Enables support for generic OHCI controller. + config USB_EHCI_HCD bool "EHCI HCD (USB 2.0) support" ---help--- diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 0b4b458..6183b80 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -21,6 +21,7 @@ obj-$(CONFIG_USB_OHCI_S3C24XX) += ohci-s3c24xx.o 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
# echi obj-$(CONFIG_USB_EHCI) += ehci-hcd.o diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c new file mode 100644 index 0000000..f3307f4 --- /dev/null +++ b/drivers/usb/host/ohci-generic.c @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2015 Alexey Brodkin abrodkin@synopsys.com + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <dm.h> +#include "ohci.h" + +#if !defined(CONFIG_USB_OHCI_NEW) +# error "Generic OHCI driver requires CONFIG_USB_OHCI_NEW" +#endif + +struct generic_ohci { + ohci_t ohci; +}; + +static int ohci_usb_probe(struct udevice *dev) +{ + struct ohci_regs *regs = (struct ohci_regs *)dev_get_addr(dev); + + return ohci_register(dev, regs); +} + +static int ohci_usb_remove(struct udevice *dev) +{ + return ohci_deregister(dev); +} + +static const struct udevice_id ohci_usb_ids[] = { + { .compatible = "generic-ohci" }, + { } +}; + +U_BOOT_DRIVER(ohci_generic) = { + .name = "ohci_generic", + .id = UCLASS_USB, + .of_match = ohci_usb_ids, + .probe = ohci_usb_probe, + .remove = ohci_usb_remove, + .ops = &ohci_usb_ops, + .priv_auto_alloc_size = sizeof(struct generic_ohci), + .flags = DM_FLAG_ALLOC_PRIV_DMA, +};

On Monday, December 14, 2015 at 03:18:50 PM, Alexey Brodkin wrote:
This driver is meant to be used with any OHCI-compatible host controller in case if there's no need for platform-specific glue such as setup of controller or PHY's power mode via GPIOs etc.
Signed-off-by: Alexey Brodkin abrodkin@synopsys.com Cc: Simon Glass sjg@chromium.org Cc: Marek Vasut marex@denx.de
drivers/usb/host/Kconfig | 8 ++++++++ drivers/usb/host/Makefile | 1 + drivers/usb/host/ohci-generic.c | 45 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 drivers/usb/host/ohci-generic.c
Applied, thanks.
btw. I am a bit worried about the compatible string, are those strings used somewhere besides this driver ?
Best regards, Marek Vasut

Hi Marek,
On Wed, 2015-12-16 at 01:44 +0100, Marek Vasut wrote:
On Monday, December 14, 2015 at 03:18:50 PM, Alexey Brodkin wrote:
This driver is meant to be used with any OHCI-compatible host controller in case if there's no need for platform-specific glue such as setup of controller or PHY's power mode via GPIOs etc.
Signed-off-by: Alexey Brodkin abrodkin@synopsys.com Cc: Simon Glass sjg@chromium.org Cc: Marek Vasut marex@denx.de
drivers/usb/host/Kconfig | 8 ++++++++ drivers/usb/host/Makefile | 1 + drivers/usb/host/ohci-generic.c | 45 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 drivers/usb/host/ohci-generic.c
Applied, thanks.
btw. I am a bit worried about the compatible string, are those strings used somewhere besides this driver ?
Well U-Boot we already may see that: ------------------->8-------------------- $ git grep generic-ohci arch/arm/dts/sun4i-a10.dtsi:650: compatible = "allwinner,sun4i-a10-ohci", "generic-ohci"; arch/arm/dts/sun4i-a10.dtsi:692: compatible = "allwinner,sun4i-a10-ohci", "generic-ohci"; arch/arm/dts/sun5i.dtsi:456: compatible = "allwinner,sun5i-a13-ohci", "generic-ohci"; arch/arm/dts/sun6i-a31.dtsi:564: compatible = "allwinner,sun6i-a31-ohci", "generic-ohci"; arch/arm/dts/sun6i-a31.dtsi:586: compatible = "allwinner,sun6i-a31-ohci", "generic-ohci"; arch/arm/dts/sun6i-a31.dtsi:597: compatible = "allwinner,sun6i-a31-ohci", "generic-ohci"; arch/arm/dts/sun7i-a20.dtsi:738: compatible = "allwinner,sun7i-a20-ohci", "generic-ohci"; arch/arm/dts/sun7i-a20.dtsi:780: compatible = "allwinner,sun7i-a20-ohci", "generic-ohci"; arch/arm/dts/sun8i-a23-a33.dtsi:347: compatible = "allwinner,sun8i-a23-ohci", "generic-ohci"; arch/arm/dts/sun8i-h3.dtsi:406: compatible = "allwinner,sun8i-h3-ohci", "generic-ohci"; arch/arm/dts/sun8i-h3.dtsi:429: compatible = "allwinner,sun8i-h3-ohci", "generic-ohci"; arch/arm/dts/sun8i-h3.dtsi:452: compatible = "allwinner,sun8i-h3-ohci", "generic-ohci"; arch/arm/dts/sun9i-a80.dtsi:365: compatible = "allwinner,sun9i-a80-ohci", "generic-ohci"; arch/arm/dts/sun9i-a80.dtsi:423: compatible = "allwinner,sun9i-a80-ohci", "generic-ohci"; ------------------->8--------------------
Even though Sunxi might not work without additional things done in ohci-sunxi.c.
And in Linux kernel we see more usages: ------------------->8-------------------- $ git grep generic-ohci arch arch/arc/boot/dts/axs10x_mb.dtsi:59: compatible = "generic-ohci"; arch/arm/boot/dts/hisi-x5hd2.dtsi:462: compatible = "generic-ohci"; arch/arm/boot/dts/sun4i-a10.dtsi:703: compatible = "allwinner,sun4i-a10-ohci", "generic-ohci"; arch/arm/boot/dts/sun4i-a10.dtsi:753: compatible = "allwinner,sun4i-a10-ohci", "generic-ohci"; arch/arm/boot/dts/sun5i.dtsi:474: compatible = "allwinner,sun5i-a13-ohci", "generic-ohci"; arch/arm/boot/dts/sun6i-a31.dtsi:596: compatible = "allwinner,sun6i-a31-ohci", "generic-ohci"; arch/arm/boot/dts/sun6i-a31.dtsi:618: compatible = "allwinner,sun6i-a31-ohci", "generic-ohci"; arch/arm/boot/dts/sun6i-a31.dtsi:629: compatible = "allwinner,sun6i-a31-ohci", "generic-ohci"; arch/arm/boot/dts/sun7i-a20.dtsi:787: compatible = "allwinner,sun7i-a20-ohci", "generic-ohci"; arch/arm/boot/dts/sun7i-a20.dtsi:837: compatible = "allwinner,sun7i-a20-ohci", "generic-ohci"; arch/arm/boot/dts/sun8i-a23-a33.dtsi:337: compatible = "allwinner,sun8i-a23-ohci", "generic-ohci"; arch/arm/boot/dts/sun9i-a80.dtsi:377: compatible = "allwinner,sun9i-a80-ohci", "generic-ohci"; arch/arm/boot/dts/sun9i-a80.dtsi:435: compatible = "allwinner,sun9i-a80-ohci", "generic-ohci"; arch/arm64/boot/dts/arm/juno-base.dtsi:156: compatible = "generic-ohci"; arch/mips/boot/dts/brcm/bcm3384_viper.dtsi:99: compatible = "brcm,bcm3384-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm3384_zephyr.dtsi:117: compatible = "brcm,bcm3384-ohci", "generic -ohci"; arch/mips/boot/dts/brcm/bcm6368.dtsi:84: compatible = "brcm,bcm6368-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7125.dtsi:131: compatible = "brcm,bcm7125-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7346.dtsi:252: compatible = "brcm,bcm7346-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7346.dtsi:271: compatible = "brcm,bcm7346-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7346.dtsi:290: compatible = "brcm,bcm7346-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7346.dtsi:309: compatible = "brcm,bcm7346-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7358.dtsi:236: compatible = "brcm,bcm7358-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7360.dtsi:236: compatible = "brcm,bcm7360-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7362.dtsi:232: compatible = "brcm,bcm7362-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7420.dtsi:157: compatible = "brcm,bcm7420-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7420.dtsi:175: compatible = "brcm,bcm7420-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7425.dtsi:159: compatible = "brcm,bcm7425-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7425.dtsi:178: compatible = "brcm,bcm7425-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7425.dtsi:197: compatible = "brcm,bcm7425-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7425.dtsi:216: compatible = "brcm,bcm7425-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7435.dtsi:173: compatible = "brcm,bcm7435-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7435.dtsi:192: compatible = "brcm,bcm7435-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7435.dtsi:211: compatible = "brcm,bcm7435-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7435.dtsi:230: compatible = "brcm,bcm7435-ohci", "generic-ohci"; arch/powerpc/boot/dts/akebono.dts:144: compatible = "ibm,476gtr-ohci", "generic-ohci"; arch/powerpc/boot/dts/akebono.dts:151: compatible = "ibm,476gtr-ohci", "generic-ohci"; ------------------->8--------------------
Note here some boards use pure "generic-ohci" compatibility string.
And essentially I created that patch intentionally, I'm about to send a patch for Synopsys AXS103 board which will use this driver.
-Alexey

On Wednesday, December 16, 2015 at 04:40:25 PM, Alexey Brodkin wrote:
Hi Marek,
On Wed, 2015-12-16 at 01:44 +0100, Marek Vasut wrote:
On Monday, December 14, 2015 at 03:18:50 PM, Alexey Brodkin wrote:
This driver is meant to be used with any OHCI-compatible host controller in case if there's no need for platform-specific glue such as setup of controller or PHY's power mode via GPIOs etc.
Signed-off-by: Alexey Brodkin abrodkin@synopsys.com Cc: Simon Glass sjg@chromium.org Cc: Marek Vasut marex@denx.de
drivers/usb/host/Kconfig | 8 ++++++++ drivers/usb/host/Makefile | 1 + drivers/usb/host/ohci-generic.c | 45
+++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+)
create mode 100644 drivers/usb/host/ohci-generic.c
Applied, thanks.
btw. I am a bit worried about the compatible string, are those strings used somewhere besides this driver ?
Well U-Boot we already may see that: ------------------->8-------------------- $ git grep generic-ohci arch/arm/dts/sun4i-a10.dtsi:650: compatible = "allwinner,sun4i-a10-ohci", "generic-ohci"; arch/arm/dts/sun4i-a10.dtsi:692: compatible = "allwinner,sun4i-a10-ohci", "generic-ohci"; arch/arm/dts/sun5i.dtsi:456: compatible = "allwinner,sun5i-a13-ohci", "generic-ohci"; arch/arm/dts/sun6i-a31.dtsi:564: compatible = "allwinner,sun6i-a31-ohci", "generic-ohci"; arch/arm/dts/sun6i-a31.dtsi:586: compatible = "allwinner,sun6i-a31-ohci", "generic-ohci"; arch/arm/dts/sun6i-a31.dtsi:597: compatible = "allwinner,sun6i-a31-ohci", "generic-ohci"; arch/arm/dts/sun7i-a20.dtsi:738: compatible = "allwinner,sun7i-a20-ohci", "generic-ohci"; arch/arm/dts/sun7i-a20.dtsi:780: compatible = "allwinner,sun7i-a20-ohci", "generic-ohci"; arch/arm/dts/sun8i-a23-a33.dtsi:347: compatible = "allwinner,sun8i-a23-ohci", "generic-ohci"; arch/arm/dts/sun8i-h3.dtsi:406: compatible = "allwinner,sun8i-h3-ohci", "generic-ohci"; arch/arm/dts/sun8i-h3.dtsi:429: compatible = "allwinner,sun8i-h3-ohci", "generic-ohci"; arch/arm/dts/sun8i-h3.dtsi:452: compatible = "allwinner,sun8i-h3-ohci", "generic-ohci"; arch/arm/dts/sun9i-a80.dtsi:365: compatible = "allwinner,sun9i-a80-ohci", "generic-ohci"; arch/arm/dts/sun9i-a80.dtsi:423: compatible = "allwinner,sun9i-a80-ohci", "generic-ohci"; ------------------->8--------------------
Even though Sunxi might not work without additional things done in ohci-sunxi.c.
And in Linux kernel we see more usages: ------------------->8-------------------- $ git grep generic-ohci arch arch/arc/boot/dts/axs10x_mb.dtsi:59: compatible = "generic-ohci"; arch/arm/boot/dts/hisi-x5hd2.dtsi:462: compatible = "generic-ohci"; arch/arm/boot/dts/sun4i-a10.dtsi:703: compatible = "allwinner,sun4i-a10-ohci", "generic-ohci"; arch/arm/boot/dts/sun4i-a10.dtsi:753: compatible = "allwinner,sun4i-a10-ohci", "generic-ohci"; arch/arm/boot/dts/sun5i.dtsi:474: compatible = "allwinner,sun5i-a13-ohci", "generic-ohci"; arch/arm/boot/dts/sun6i-a31.dtsi:596: compatible = "allwinner,sun6i-a31-ohci", "generic-ohci"; arch/arm/boot/dts/sun6i-a31.dtsi:618: compatible = "allwinner,sun6i-a31-ohci", "generic-ohci"; arch/arm/boot/dts/sun6i-a31.dtsi:629: compatible = "allwinner,sun6i-a31-ohci", "generic-ohci"; arch/arm/boot/dts/sun7i-a20.dtsi:787: compatible = "allwinner,sun7i-a20-ohci", "generic-ohci"; arch/arm/boot/dts/sun7i-a20.dtsi:837: compatible = "allwinner,sun7i-a20-ohci", "generic-ohci"; arch/arm/boot/dts/sun8i-a23-a33.dtsi:337: compatible = "allwinner,sun8i-a23-ohci", "generic-ohci"; arch/arm/boot/dts/sun9i-a80.dtsi:377: compatible = "allwinner,sun9i-a80-ohci", "generic-ohci"; arch/arm/boot/dts/sun9i-a80.dtsi:435: compatible = "allwinner,sun9i-a80-ohci", "generic-ohci"; arch/arm64/boot/dts/arm/juno-base.dtsi:156: compatible = "generic-ohci"; arch/mips/boot/dts/brcm/bcm3384_viper.dtsi:99: compatible = "brcm,bcm3384-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm3384_zephyr.dtsi:117: compatible = "brcm,bcm3384-ohci", "generic -ohci"; arch/mips/boot/dts/brcm/bcm6368.dtsi:84: compatible = "brcm,bcm6368-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7125.dtsi:131: compatible = "brcm,bcm7125-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7346.dtsi:252: compatible = "brcm,bcm7346-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7346.dtsi:271: compatible = "brcm,bcm7346-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7346.dtsi:290: compatible = "brcm,bcm7346-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7346.dtsi:309: compatible = "brcm,bcm7346-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7358.dtsi:236: compatible = "brcm,bcm7358-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7360.dtsi:236: compatible = "brcm,bcm7360-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7362.dtsi:232: compatible = "brcm,bcm7362-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7420.dtsi:157: compatible = "brcm,bcm7420-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7420.dtsi:175: compatible = "brcm,bcm7420-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7425.dtsi:159: compatible = "brcm,bcm7425-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7425.dtsi:178: compatible = "brcm,bcm7425-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7425.dtsi:197: compatible = "brcm,bcm7425-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7425.dtsi:216: compatible = "brcm,bcm7425-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7435.dtsi:173: compatible = "brcm,bcm7435-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7435.dtsi:192: compatible = "brcm,bcm7435-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7435.dtsi:211: compatible = "brcm,bcm7435-ohci", "generic-ohci"; arch/mips/boot/dts/brcm/bcm7435.dtsi:230: compatible = "brcm,bcm7435-ohci", "generic-ohci"; arch/powerpc/boot/dts/akebono.dts:144: compatible = "ibm,476gtr-ohci", "generic-ohci"; arch/powerpc/boot/dts/akebono.dts:151: compatible = "ibm,476gtr-ohci", "generic-ohci"; ------------------->8--------------------
Note here some boards use pure "generic-ohci" compatibility string.
And essentially I created that patch intentionally, I'm about to send a patch for Synopsys AXS103 board which will use this driver.
I was more interested if something outside of U-Boot uses that compat string.

Hi Marek,
On Wed, 2015-12-16 at 16:44 +0100, Marek Vasut wrote:
On Wednesday, December 16, 2015 at 04:40:25 PM, Alexey Brodkin wrote:
Hi Marek,
On Wed, 2015-12-16 at 01:44 +0100, Marek Vasut wrote:
On Monday, December 14, 2015 at 03:18:50 PM, Alexey Brodkin wrote:
And essentially I created that patch intentionally, I'm about to send a patch for Synopsys AXS103 board which will use this driver.
I was more interested if something outside of U-Boot uses that compat string.
So then did I answer your question?
-Alexey

On Wednesday, December 16, 2015 at 04:45:05 PM, Alexey Brodkin wrote:
Hi Marek,
On Wed, 2015-12-16 at 16:44 +0100, Marek Vasut wrote:
On Wednesday, December 16, 2015 at 04:40:25 PM, Alexey Brodkin wrote:
Hi Marek,
On Wed, 2015-12-16 at 01:44 +0100, Marek Vasut wrote:
On Monday, December 14, 2015 at 03:18:50 PM, Alexey Brodkin wrote:
And essentially I created that patch intentionally, I'm about to send a patch for Synopsys AXS103 board which will use this driver.
I was more interested if something outside of U-Boot uses that compat string.
So then did I answer your question?
Ah, yes you did, sorry. I missed the linux kernel dt grep.
Best regards, Marek Vasut
participants (2)
-
Alexey Brodkin
-
Marek Vasut