mbox series

[v11,0/5] usb: xhci: Add support for Renesas USB controllers

Message ID 20200430101019.1130956-1-vkoul@kernel.org
Headers show
Series usb: xhci: Add support for Renesas USB controllers | expand

Message

Vinod Koul April 30, 2020, 10:10 a.m. UTC
This series add support for Renesas USB controllers uPD720201 and uPD720202.
These require firmware to be loaded and in case devices have ROM those can
also be programmed if empty. If ROM is programmed, it runs from ROM as well.

This includes patches from Christian which supported these controllers w/o
ROM and later my patches for ROM support and debugfs hook for rom erase and
export of xhci-pci functions.

Changes in v10:
  - update xhci->quirks and use that in remove function
  - remove error return renesas_verify_fw_version()
  - remove renesas_download_rom() and modify renesas_fw_download_image() for
  reuse
Changes in v10:
  remove renesas_xhci_pci_probe and call renesas_xhci_check_request_fw and
  also cleanup exit code along with it.

Changes in v9:
 Make fw load a sync call and have single instance of probe execute,
   elimating probe/remove races
 Add quirk for renesas and use that for loading

Changes in v8:
 Fix compile error reported by Kbuild-bot by making usb_hcd_pci_probe() take
 const struct hc_driver * as argument

Changes in v7:
 Make a single module which removes issues with module loading
 Keep the renesas code in renesas file
 Add hc_driver as argument for usb_hcd_pci_probe and modify hdc drivers to
   pass this and not use driver_data
 Use driver data for fw name
 Remove code to check if we need to load firmware or not
 remove multiple fw version support, we can do that with symlink in
   userspace

Changes in v6:
 Move the renesas code into a separate driver which invokes xhci-pci functions.

Changes in v5:
 Added a debugfs rom erase patch, helps in debugging
 Squashed patch 1 & 2 as requested by Mathias

Changes in v4:
 Rollback the delay values as we got device failures

Changes in v3:
  Dropped patch 2 as discussed with Christian
  Removed aligned 8 bytes check
  Change order for firmware search from highest version to lowest
  Added entry for new firmware for device 0x14 as well
  Add tested by Christian

Changes in v2:
  used macros for timeout count and delay
  removed renesas_fw_alive_check
  cleaned renesas_fw_callback
  removed recurion for renesas_fw_download
  added MODULE_FIRMWARE
  added comment for multiple fw order

Christian Lamparter (1):
  usb: renesas-xhci: Add the renesas xhci driver

Vinod Koul (4):
  usb: hci: add hc_driver as argument for usb_hcd_pci_probe
  usb: xhci: Add support for Renesas controller with memory
  usb: renesas-xhci: Add ROM loader for uPD720201
  usb: xhci: provide a debugfs hook for erasing rom

 drivers/usb/core/hcd-pci.c          |   7 +-
 drivers/usb/host/Makefile           |   3 +-
 drivers/usb/host/ehci-pci.c         |   6 +-
 drivers/usb/host/ohci-pci.c         |   9 +-
 drivers/usb/host/uhci-pci.c         |   8 +-
 drivers/usb/host/xhci-pci-renesas.c | 674 ++++++++++++++++++++++++++++
 drivers/usb/host/xhci-pci.c         |  47 +-
 drivers/usb/host/xhci-pci.h         |  16 +
 drivers/usb/host/xhci.h             |   1 +
 include/linux/usb/hcd.h             |   3 +-
 10 files changed, 751 insertions(+), 23 deletions(-)
 create mode 100644 drivers/usb/host/xhci-pci-renesas.c
 create mode 100644 drivers/usb/host/xhci-pci.h

Comments

Mathias Nyman April 30, 2020, 2:36 p.m. UTC | #1
On 30.4.2020 13.10, Vinod Koul wrote:
> From: Christian Lamparter <chunkeey@googlemail.com>
> 
> This add a new driver for renesas xhci which is basically a firmware
> loader for uPD720201 and uPD720202 w/o ROM. It uses xhci-pci driver for
> most of the work.
> 
> This is added in Makefile before the xhci-pci driver so that it first
> get probed for renesas devices before the xhci-pci driver has a chance
> to claim any device.

Most of the above is no longer correct

> 
> This patch adds a firmware loader for the uPD720201K8-711-BAC-A
> and uPD720202K8-711-BAA-A variant. Both of these chips are listed
> in Renesas' R19UH0078EJ0500 Rev.5.00 "User's Manual: Hardware" as
> devices which need the firmware loader on page 2 in order to
> work as they "do not support the External ROM".
> 
> The "Firmware Download Sequence" is describe in chapter
> "7.1 FW Download Interface" R19UH0078EJ0500 Rev.5.00 page 131.
> 
> The firmware "K2013080.mem" is available from a USB3.0 Host to
> PCIe Adapter (PP2U-E card) "Firmware download" archive. An
> alternative version can be sourced from Netgear's WNDR4700 GPL
> archives.
> 
> The release notes of the PP2U-E's "Firmware Download" ver 2.0.1.3
> (2012-06-15) state that the firmware is for the following devices:
>  - uPD720201 ES 2.0 sample whose revision ID is 2.
>  - uPD720201 ES 2.1 sample & CS sample & Mass product, ID is 3.
>  - uPD720202 ES 2.0 sample & CS sample & Mass product, ID is 2.
> 
> Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> [vkoul: fixed comments:
> 	used macros for timeout count and delay
> 	removed renesas_fw_alive_check
> 	cleaned renesas_fw_callback
> 	removed recursion for renesas_fw_download
> 	add register defines and field names
> 	move to a separate file
> 	make fw loader as sync probe so that we execute in probe and
>         prevent race]
> Signed-off-by: Vinod Koul <vkoul@kernel.org>
> ---
>  drivers/usb/host/Makefile           |   3 +-
>  drivers/usb/host/xhci-pci-renesas.c | 361 ++++++++++++++++++++++++++++
>  drivers/usb/host/xhci-pci.h         |  16 ++
>  3 files changed, 379 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/usb/host/xhci-pci-renesas.c
>  create mode 100644 drivers/usb/host/xhci-pci.h
> 
> diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
> index b191361257cc..c3a79f626393 100644
> --- a/drivers/usb/host/Makefile
> +++ b/drivers/usb/host/Makefile
> @@ -70,7 +70,8 @@ obj-$(CONFIG_USB_OHCI_HCD_DAVINCI)	+= ohci-da8xx.o
>  obj-$(CONFIG_USB_UHCI_HCD)	+= uhci-hcd.o
>  obj-$(CONFIG_USB_FHCI_HCD)	+= fhci.o
>  obj-$(CONFIG_USB_XHCI_HCD)	+= xhci-hcd.o
> -obj-$(CONFIG_USB_XHCI_PCI)	+= xhci-pci.o
> +usb-xhci-pci-objs		:= xhci-pci.o xhci-pci-renesas.o
> +obj-$(CONFIG_USB_XHCI_PCI)	+= usb-xhci-pci.o

I don't think it's a good idea to rename the xhci-pci module to usb-xhci-pci

does

xhci-pci-y			:= xhci-pci.o xhci-pci-renesas.o
obj-$(CONFIG_USB_XHCI_PCI)	+= xhci-pci.o

cause some kbuild issues?

-Mathias
Vinod Koul April 30, 2020, 3:26 p.m. UTC | #2
On 30-04-20, 16:53, Greg Kroah-Hartman wrote:
> On Thu, Apr 30, 2020 at 08:16:41PM +0530, Vinod Koul wrote:
> > > > diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
> > > > index b191361257cc..c3a79f626393 100644
> > > > --- a/drivers/usb/host/Makefile
> > > > +++ b/drivers/usb/host/Makefile
> > > > @@ -70,7 +70,8 @@ obj-$(CONFIG_USB_OHCI_HCD_DAVINCI)	+= ohci-da8xx.o
> > > >  obj-$(CONFIG_USB_UHCI_HCD)	+= uhci-hcd.o
> > > >  obj-$(CONFIG_USB_FHCI_HCD)	+= fhci.o
> > > >  obj-$(CONFIG_USB_XHCI_HCD)	+= xhci-hcd.o
> > > > -obj-$(CONFIG_USB_XHCI_PCI)	+= xhci-pci.o
> > > > +usb-xhci-pci-objs		:= xhci-pci.o xhci-pci-renesas.o
> > > > +obj-$(CONFIG_USB_XHCI_PCI)	+= usb-xhci-pci.o
> > > 
> > > I don't think it's a good idea to rename the xhci-pci module to usb-xhci-pci
> > > 
> > > does
> > > 
> > > xhci-pci-y			:= xhci-pci.o xhci-pci-renesas.o
> > > obj-$(CONFIG_USB_XHCI_PCI)	+= xhci-pci.o
> > > 
> > > cause some kbuild issues?
> > 
> > Yes with this version I get the warning:
> > make[4]: Circular drivers/usb/host/xhci-pci.o <- drivers/usb/host/xhci-pci.o dependency dropped.
> > 
> > I don't speak enough Kbuild, but I guess it does make sense that we have
> > xhci-pci.o as target for both xhci-pci.o xhci-pci-renesas.o! That was
> > the reason for adding usb tag to this to resolve the conflict.
> > 
> > I am okay for any other mechanism which can work well here. Btw what
> > issues do you foresee with adding usb tag to module name.
> 
> It will break all sorts of things.  Happens every time we rename
> modules, let's not do it unless we absolutely have to.

Hmm that is interesting, am not sure why though :)

Anyway, I have fixed it up and was able to make both as modules and
export two symbols for xhci-pci.ko to use :)

Makefile change looks like:

+obj-$(CONFIG_USB_XHCI_PCI)     += xhci-pci.o xhci-pci-renesas.o

Thanks