mbox series

[v4,0/2] Add driver for EHCI in Sunplus SP7021

Message ID 1651220876-26705-1-git-send-email-vincent.sunplus@gmail.com
Headers show
Series Add driver for EHCI in Sunplus SP7021 | expand

Message

Vincent Shih April 29, 2022, 8:27 a.m. UTC
This is a patch series for EHCI driver for Sunplus SP7021 SoC.

Sunplus SP7021 is an ARM Cortex A7 (4 cores) based SoC. It integrates
many peripherals (ex: UART, I2C, SPI, SDIO, eMMC, USB, SD Card and
etc.) into a single chip. It is designed for industrial control.

Refer to:
https://sunplus-tibbo.atlassian.net/wiki/spaces/doc/overview
https://tibbo.com/store/plus1.html

Vincent Shih (2):
  usb: host: ehci-sunplus: Add driver for ehci in Sunplus SP7021
  dt-bindings: usb: Add bindings doc for Sunplus EHCI driver

 .../bindings/usb/sunplus,sp7021-usb-ehci.yaml      |  79 ++++++
 MAINTAINERS                                        |   7 +
 drivers/usb/host/Kconfig                           |  11 +
 drivers/usb/host/Makefile                          |   1 +
 drivers/usb/host/ehci-sunplus.c                    | 289 +++++++++++++++++++++
 5 files changed, 387 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/sunplus,sp7021-usb-ehci.yaml
 create mode 100644 drivers/usb/host/ehci-sunplus.c

Comments

Alan Stern April 30, 2022, 1:26 a.m. UTC | #1
On Fri, Apr 29, 2022 at 04:27:55PM +0800, Vincent Shih wrote:
> Add driver for ehci in Sunplus SP7021
> 
> Signed-off-by: Vincent Shih <vincent.sunplus@gmail.com>
> ---

> diff --git a/drivers/usb/host/ehci-sunplus.c b/drivers/usb/host/ehci-sunplus.c
> new file mode 100644
> index 0000000..4d8e20d
> --- /dev/null
> +++ b/drivers/usb/host/ehci-sunplus.c

> +static struct usb_ehci_pdata usb_ehci_pdata = {
> +	.has_tt = 1,
> +	.has_synopsys_hc_bug = 1,
> +	.big_endian_desc = 1,
> +	.big_endian_mmio = 1,
> +	.power_on = sp_ehci_platform_power_on,
> +	.power_suspend = sp_ehci_platform_power_off,
> +	.power_off = sp_ehci_platform_power_off,
> +
> +};
> +
> +static int ehci_sunplus_reset(struct usb_hcd *hcd)
> +{
> +	struct platform_device *pdev = to_platform_device(hcd->self.controller);
> +	struct usb_ehci_pdata *pdata = pdev->dev.platform_data;
> +	struct ehci_hcd *ehci = hcd_to_ehci(hcd);
> +	int retval;
> +
> +	hcd->has_tt = pdata->has_tt;
> +	ehci->has_synopsys_hc_bug = pdata->has_synopsys_hc_bug;
> +	ehci->big_endian_desc = pdata->big_endian_desc;
> +	ehci->big_endian_mmio = pdata->big_endian_mmio;

By the way, you don't need to add all this pdata stuff.  You can just 
set hcd->has_tt, ehci->has_synopsys_hc_bug, ehci_big_endian_desc, and 
ehci->big_endian_mmio directly, since you already know what their values 
should be.

It looks like you simply copied the code from the ehci-platform driver.  
But that driver has to handle many different kinds of platform devices, 
so it needs to be told about their individual differences, whereas your 
driver only has to handle one kind.

In fact, there's no obvious reason why you didn't just use the 
ehci-platform driver instead of writing your own driver.  
That's the sort of thing you need to explain the patch description.

Alan Stern