Re: [U-Boot] [PATCH] usb: xhci: Add Renesas R-Car xHCI driver

2017-10-22 Thread Simon Glass
Hi Bin,

On 9 October 2017 at 09:16, Bin Meng  wrote:
> Hi Marek,
>
> On Mon, Oct 9, 2017 at 2:34 AM, Marek Vasut  wrote:
>> Add firmware V3, firmware loader and XHCI glue for the Renesas R-Car
>> Gen3 SoCs XHCI controller. Thus far only the R-Car Gen3 R8A7795 ES2.0+
>> and R8A7796 are supported.
>>
>> Signed-off-by: Marek Vasut 
>> Cc: Nobuhiro Iwamatsu 
>> ---
>>  Licenses/r8a779x_usb3.txt|  26 ++
>>  drivers/usb/host/Kconfig |   8 +
>>  drivers/usb/host/Makefile|   1 +
>>  drivers/usb/host/xhci-rcar-r8a779x_usb3_v3.h | 643 
>> +++
>>  drivers/usb/host/xhci-rcar.c | 161 +++
>>  5 files changed, 839 insertions(+)
>>  create mode 100644 Licenses/r8a779x_usb3.txt
>>  create mode 100644 drivers/usb/host/xhci-rcar-r8a779x_usb3_v3.h
>>  create mode 100644 drivers/usb/host/xhci-rcar.c
>>

>> +   0x000201bc, 0xcc74, 0x00011014, 0x00011076,
>> +   0x32dc, 0x79cf
>> +};
>> +
>
> +Simon,
>
> Can we use binman here to include the firmware image file directly
> into the u-boot image?

Yes I think so. We really need binman to add the DT offset into the
image. I'm going to take a look at that soon.

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] usb: xhci: Add Renesas R-Car xHCI driver

2017-10-09 Thread Marek Vasut
On 10/09/2017 09:16 AM, Bin Meng wrote:

[...]

>> +++ b/Licenses/r8a779x_usb3.txt
>> @@ -0,0 +1,26 @@
>> +Copyright (c) 2014, Renesas Electronics Corporation
>> +All rights reserved.
>> +
>> +Redistribution and use in binary form, without modification, are permitted
>> +provided that the following conditions are met:
>> +
>> +1. Redistribution in binary form must reproduce the above copyright notice,
>> +   this list of conditions and the following disclaimer in the documentation
>> +   and/or other materials provided with the distribution.
>> +2. The name of Renesas Electronics Corporation may not be used to endorse or
>> +   promote products derived from this software without specific prior 
>> written
>> +   permission.
>> +3. Reverse engineering, decompilation, or disassembly of this software is
>> +   not permitted.
>> +
>> +THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS ELECTRONICS CORPORATION 
>> DISCLAIMS
>> +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
>> IMPLIED
>> +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND
>> +NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL RENESAS ELECTRONICS
>> +CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
>> EXEMPLARY,
>> +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
>> +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
>> +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
>> +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
>> +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
>> +POSSIBILITY OF SUCH DAMAGE.
> 
> Is there any SPDX form of this license?

Nope :(

>> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
>> index f5f19ed775..cad9af6977 100644
>> --- a/drivers/usb/host/Kconfig
>> +++ b/drivers/usb/host/Kconfig
>> @@ -47,6 +47,14 @@ config USB_XHCI_ROCKCHIP
>> help
>>   Enables support for the on-chip xHCI controller on Rockchip SoCs.
[...]

>> +/* Register Settings */
>> +/* FW Download Control & Status */
>> +#define RCAR_USB3_DL_CTRL_ENABLE   0x0001
>> +#define RCAR_USB3_DL_CTRL_FW_SUCCESS   0x0010
>> +#define RCAR_USB3_DL_CTRL_FW_SET_DATA0 0x0100
>> +
>> +DECLARE_GLOBAL_DATA_PTR;
> 
> This is not needed.

Removed

>> +struct rcar_xhci_platdata {
>> +   fdt_addr_t  hcd_base;
>> +   struct clk  clk;
>> +};
>> +
>> +/**
>> + * Contains pointers to register base addresses
>> + * for the usb controller.
>> + */
>> +struct rcar_xhci {
>> +   struct xhci_ctrl ctrl;  /* Needs to come first in this struct! */
>> +   struct usb_platdata usb_plat;
>> +   struct xhci_hccr *hcd;
>> +};
>> +
>> +static int xhci_rcar_download_fw(struct rcar_xhci *ctx, const u32 *fw_data,
>> +const size_t fw_array_size)
>> +{
>> +   void __iomem *regs = (void __iomem *)ctx->hcd;
>> +   int i, ret;
>> +
>> +   /* Download R-Car USB3.0 firmware */
>> +   setbits_le32(regs + RCAR_USB3_DL_CTRL, RCAR_USB3_DL_CTRL_ENABLE);
>> +
>> +   for (i = 0; i < fw_array_size; i++) {
>> +   writel(fw_data[i], regs + RCAR_USB3_FW_DATA0);
>> +   setbits_le32(regs + RCAR_USB3_DL_CTRL,
>> +RCAR_USB3_DL_CTRL_FW_SET_DATA0);
>> +
>> +   ret = wait_for_bit("xhci-rcar", regs + RCAR_USB3_DL_CTRL,
>> +  RCAR_USB3_DL_CTRL_FW_SET_DATA0, false,
>> +  10, false);
>> +   if (ret)
>> +   break;
>> +   }
>> +
>> +   clrbits_le32(regs + RCAR_USB3_DL_CTRL, RCAR_USB3_DL_CTRL_ENABLE);
>> +
>> +   ret = wait_for_bit("xhci-rcar", regs + RCAR_USB3_DL_CTRL,
>> +  RCAR_USB3_DL_CTRL_FW_SUCCESS, true,
>> +  10, false);
>> +
>> +   return ret;
>> +}
>> +
>> +static int xhci_rcar_probe(struct udevice *dev)
>> +{
>> +   struct rcar_xhci_platdata *plat = dev_get_platdata(dev);
>> +   struct rcar_xhci *ctx = dev_get_priv(dev);
>> +   struct xhci_hcor *hcor;
>> +   int len, ret;
>> +
>> +   ret = clk_get_by_index(dev, 0, &plat->clk);
>> +   if (ret < 0) {
>> +   dev_err(dev, "Failed to get USB3 clock\n");
>> +   return ret;
>> +   }
>> +
>> +   ret = clk_enable(&plat->clk);
>> +   if (ret) {
>> +   dev_err(dev, "Failed to enable USB3 clock\n");
>> +   goto err_clk;
>> +   }
>> +
>> +   ctx->hcd = (struct xhci_hccr *)plat->hcd_base;
>> +   len = HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase));
>> +   hcor = (struct xhci_hcor *)((uintptr_t)ctx->hcd + len);
>> +
>> +   ret = xhci_rcar_download_fw(ctx, firmware_r8a779x_usb3_v3,
>> +   ARRAY_SIZE(firmware_r8a779x_usb3_v3));
>> +   if (ret) {
>> +   dev_err(dev, "Failed to download firmware\n");
>> +   

Re: [U-Boot] [PATCH] usb: xhci: Add Renesas R-Car xHCI driver

2017-10-09 Thread Bin Meng
Hi Marek,

On Mon, Oct 9, 2017 at 2:34 AM, Marek Vasut  wrote:
> Add firmware V3, firmware loader and XHCI glue for the Renesas R-Car
> Gen3 SoCs XHCI controller. Thus far only the R-Car Gen3 R8A7795 ES2.0+
> and R8A7796 are supported.
>
> Signed-off-by: Marek Vasut 
> Cc: Nobuhiro Iwamatsu 
> ---
>  Licenses/r8a779x_usb3.txt|  26 ++
>  drivers/usb/host/Kconfig |   8 +
>  drivers/usb/host/Makefile|   1 +
>  drivers/usb/host/xhci-rcar-r8a779x_usb3_v3.h | 643 
> +++
>  drivers/usb/host/xhci-rcar.c | 161 +++
>  5 files changed, 839 insertions(+)
>  create mode 100644 Licenses/r8a779x_usb3.txt
>  create mode 100644 drivers/usb/host/xhci-rcar-r8a779x_usb3_v3.h
>  create mode 100644 drivers/usb/host/xhci-rcar.c
>
> diff --git a/Licenses/r8a779x_usb3.txt b/Licenses/r8a779x_usb3.txt
> new file mode 100644
> index 00..e2afcc9e81
> --- /dev/null
> +++ b/Licenses/r8a779x_usb3.txt
> @@ -0,0 +1,26 @@
> +Copyright (c) 2014, Renesas Electronics Corporation
> +All rights reserved.
> +
> +Redistribution and use in binary form, without modification, are permitted
> +provided that the following conditions are met:
> +
> +1. Redistribution in binary form must reproduce the above copyright notice,
> +   this list of conditions and the following disclaimer in the documentation
> +   and/or other materials provided with the distribution.
> +2. The name of Renesas Electronics Corporation may not be used to endorse or
> +   promote products derived from this software without specific prior written
> +   permission.
> +3. Reverse engineering, decompilation, or disassembly of this software is
> +   not permitted.
> +
> +THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS ELECTRONICS CORPORATION 
> DISCLAIMS
> +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
> +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND
> +NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL RENESAS ELECTRONICS
> +CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
> EXEMPLARY,
> +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> +POSSIBILITY OF SUCH DAMAGE.

Is there any SPDX form of this license?

> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
> index f5f19ed775..cad9af6977 100644
> --- a/drivers/usb/host/Kconfig
> +++ b/drivers/usb/host/Kconfig
> @@ -47,6 +47,14 @@ config USB_XHCI_ROCKCHIP
> help
>   Enables support for the on-chip xHCI controller on Rockchip SoCs.
>
> +config USB_XHCI_RCAR
> +   bool "Renesas RCar USB 3.0 support"
> +   default y
> +   depends on ARCH_RMOBILE
> +   help
> + Choose this option to add support for USB 3.0 driver on Renesas
> + RCar Gen3 SoCs.
> +
>  config USB_XHCI_STI
> bool "Support for STMicroelectronics STiH407 family on-chip xHCI USB 
> controller"
> depends on ARCH_STI
> diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
> index 83903fcf99..79df888fce 100644
> --- a/drivers/usb/host/Makefile
> +++ b/drivers/usb/host/Makefile
> @@ -59,6 +59,7 @@ obj-$(CONFIG_USB_XHCI_FSL) += xhci-fsl.o
>  obj-$(CONFIG_USB_XHCI_MVEBU) += xhci-mvebu.o
>  obj-$(CONFIG_USB_XHCI_OMAP) += xhci-omap.o
>  obj-$(CONFIG_USB_XHCI_PCI) += xhci-pci.o
> +obj-$(CONFIG_USB_XHCI_RCAR) += xhci-rcar.o
>  obj-$(CONFIG_USB_XHCI_STI) += dwc3-sti-glue.o
>
>  # designware
> diff --git a/drivers/usb/host/xhci-rcar-r8a779x_usb3_v3.h 
> b/drivers/usb/host/xhci-rcar-r8a779x_usb3_v3.h
> new file mode 100644
> index 00..f0f48a3354
> --- /dev/null
> +++ b/drivers/usb/host/xhci-rcar-r8a779x_usb3_v3.h
> @@ -0,0 +1,643 @@
> +/*
> + * Renesas RCar xHCI controller firmware version 3
> + *
> + * Copyright (c) 2014, Renesas Electronics Corporation
> + * All rights reserved.
> + *
> + * Redistribution and use in binary form, without modification, are permitted
> + * provided that the following conditions are met:
> + *
> + * 1. Redistribution in binary form must reproduce the above copyright 
> notice,
> + *this list of conditions and the following disclaimer in the 
> documentation
> + *and/or other materials provided with the distribution.
> + * 2. The name of Renesas Electronics Corporation may not be used to endorse 
> or
> + *promote products derived from this software without specific prior 
> written
> + *permission.
> + * 3. Reverse engineering, decompilation, or disassembly of this software is
> + *not permitted.
> + *
> + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS ELECTRONICS CORPORATION 
> DISCLAIMS
> + * ANY EXPRESS OR IMPLIED WARRANTI

Re: [U-Boot] [PATCH] usb: xhci: Add Renesas R-Car xHCI driver

2017-10-08 Thread Tom Rini
On Sun, Oct 08, 2017 at 08:34:46PM +0200, Marek Vasut wrote:

> Add firmware V3, firmware loader and XHCI glue for the Renesas R-Car
> Gen3 SoCs XHCI controller. Thus far only the R-Car Gen3 R8A7795 ES2.0+
> and R8A7796 are supported.
> 
> Signed-off-by: Marek Vasut 
> Cc: Nobuhiro Iwamatsu 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] usb: xhci: Add Renesas R-Car xHCI driver

2017-10-08 Thread Marek Vasut
Add firmware V3, firmware loader and XHCI glue for the Renesas R-Car
Gen3 SoCs XHCI controller. Thus far only the R-Car Gen3 R8A7795 ES2.0+
and R8A7796 are supported.

Signed-off-by: Marek Vasut 
Cc: Nobuhiro Iwamatsu 
---
 Licenses/r8a779x_usb3.txt|  26 ++
 drivers/usb/host/Kconfig |   8 +
 drivers/usb/host/Makefile|   1 +
 drivers/usb/host/xhci-rcar-r8a779x_usb3_v3.h | 643 +++
 drivers/usb/host/xhci-rcar.c | 161 +++
 5 files changed, 839 insertions(+)
 create mode 100644 Licenses/r8a779x_usb3.txt
 create mode 100644 drivers/usb/host/xhci-rcar-r8a779x_usb3_v3.h
 create mode 100644 drivers/usb/host/xhci-rcar.c

diff --git a/Licenses/r8a779x_usb3.txt b/Licenses/r8a779x_usb3.txt
new file mode 100644
index 00..e2afcc9e81
--- /dev/null
+++ b/Licenses/r8a779x_usb3.txt
@@ -0,0 +1,26 @@
+Copyright (c) 2014, Renesas Electronics Corporation
+All rights reserved.
+
+Redistribution and use in binary form, without modification, are permitted
+provided that the following conditions are met:
+
+1. Redistribution in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+2. The name of Renesas Electronics Corporation may not be used to endorse or
+   promote products derived from this software without specific prior written
+   permission.
+3. Reverse engineering, decompilation, or disassembly of this software is
+   not permitted.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS ELECTRONICS CORPORATION DISCLAIMS
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND
+NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL RENESAS ELECTRONICS
+CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index f5f19ed775..cad9af6977 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -47,6 +47,14 @@ config USB_XHCI_ROCKCHIP
help
  Enables support for the on-chip xHCI controller on Rockchip SoCs.
 
+config USB_XHCI_RCAR
+   bool "Renesas RCar USB 3.0 support"
+   default y
+   depends on ARCH_RMOBILE
+   help
+ Choose this option to add support for USB 3.0 driver on Renesas
+ RCar Gen3 SoCs.
+
 config USB_XHCI_STI
bool "Support for STMicroelectronics STiH407 family on-chip xHCI USB 
controller"
depends on ARCH_STI
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 83903fcf99..79df888fce 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -59,6 +59,7 @@ obj-$(CONFIG_USB_XHCI_FSL) += xhci-fsl.o
 obj-$(CONFIG_USB_XHCI_MVEBU) += xhci-mvebu.o
 obj-$(CONFIG_USB_XHCI_OMAP) += xhci-omap.o
 obj-$(CONFIG_USB_XHCI_PCI) += xhci-pci.o
+obj-$(CONFIG_USB_XHCI_RCAR) += xhci-rcar.o
 obj-$(CONFIG_USB_XHCI_STI) += dwc3-sti-glue.o
 
 # designware
diff --git a/drivers/usb/host/xhci-rcar-r8a779x_usb3_v3.h 
b/drivers/usb/host/xhci-rcar-r8a779x_usb3_v3.h
new file mode 100644
index 00..f0f48a3354
--- /dev/null
+++ b/drivers/usb/host/xhci-rcar-r8a779x_usb3_v3.h
@@ -0,0 +1,643 @@
+/*
+ * Renesas RCar xHCI controller firmware version 3
+ *
+ * Copyright (c) 2014, Renesas Electronics Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in binary form, without modification, are permitted
+ * provided that the following conditions are met:
+ *
+ * 1. Redistribution in binary form must reproduce the above copyright notice,
+ *this list of conditions and the following disclaimer in the documentation
+ *and/or other materials provided with the distribution.
+ * 2. The name of Renesas Electronics Corporation may not be used to endorse or
+ *promote products derived from this software without specific prior 
written
+ *permission.
+ * 3. Reverse engineering, decompilation, or disassembly of this software is
+ *not permitted.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS ELECTRONICS CORPORATION 
DISCLAIMS
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND
+ * NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL RENESAS ELECTRONICS
+ * CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NO