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

Marek Vasut marek.vasut at gmail.com
Mon Oct 9 11:52:11 UTC 2017


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       0x00000001
>> +#define RCAR_USB3_DL_CTRL_FW_SUCCESS   0x00000010
>> +#define RCAR_USB3_DL_CTRL_FW_SET_DATA0 0x00000100
>> +
>> +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");
>> +               goto err_fw;
>> +       }
>> +
>> +       ret = xhci_register(dev, ctx->hcd, hcor);
>> +       if (ret) {
>> +               dev_err(dev, "Failed to register xHCI\n");
>> +               goto err_fw;
>> +       }
>> +
>> +       return 0;
>> +
>> +err_fw:
>> +       clk_disable(&plat->clk);
>> +err_clk:
>> +       clk_free(&plat->clk);
>> +       return ret;
>> +}
>> +
>> +static int xhci_rcar_deregister(struct udevice *dev)
>> +{
>> +       struct rcar_xhci_platdata *plat = dev_get_platdata(dev);
>> +
>> +       clk_disable(&plat->clk);
>> +       clk_free(&plat->clk);
>> +
> 
> Missing xhci_deregister() call here.
True, thanks

-- 
Best regards,
Marek Vasut


More information about the U-Boot mailing list