All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 3/4] usb: xhci-dwc3: Add support for clocks/resets
Date: Wed, 21 Apr 2021 11:37:00 +0100	[thread overview]
Message-ID: <20210421113700.37eebbd8@slackpad.fritz.box> (raw)
In-Reply-To: <20210417142059.45337-4-samuel@sholland.org>

On Sat, 17 Apr 2021 09:20:58 -0500
Samuel Holland <samuel@sholland.org> wrote:

> Some platforms, like the Allwinner H6, do not have a separate glue layer
> around the dwc3. Instead, they rely on the clocks/resets/phys referenced
> from the dwc3 DT node itself. Add support for enabling the clocks/resets
> referenced from the dwc3 DT node.
> 
> Signed-off-by: Samuel Holland <samuel@sholland.org>

Looks good, and even if they are redundancies with the other kind of
binding, it should not hurt to have it in, to cover our DTs.

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

Cheers,
Andre

> ---
>  drivers/usb/host/xhci-dwc3.c | 56 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 56 insertions(+)
> 
> diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c
> index 3e0ae80cec..5b12d1358e 100644
> --- a/drivers/usb/host/xhci-dwc3.c
> +++ b/drivers/usb/host/xhci-dwc3.c
> @@ -7,10 +7,12 @@
>   * Author: Ramneek Mehresh<ramneek.mehresh@freescale.com>
>   */
>  
> +#include <clk.h>
>  #include <common.h>
>  #include <dm.h>
>  #include <generic-phy.h>
>  #include <log.h>
> +#include <reset.h>
>  #include <usb.h>
>  #include <dwc3-uboot.h>
>  #include <linux/delay.h>
> @@ -21,7 +23,9 @@
>  #include <linux/usb/otg.h>
>  
>  struct xhci_dwc3_plat {
> +	struct clk_bulk clks;
>  	struct phy_bulk phys;
> +	struct reset_ctl_bulk resets;
>  };
>  
>  void dwc3_set_mode(struct dwc3 *dwc3_reg, u32 mode)
> @@ -111,6 +115,46 @@ void dwc3_set_fladj(struct dwc3 *dwc3_reg, u32 val)
>  }
>  
>  #if CONFIG_IS_ENABLED(DM_USB)
> +static int xhci_dwc3_reset_init(struct udevice *dev,
> +				struct xhci_dwc3_plat *plat)
> +{
> +	int ret;
> +
> +	ret = reset_get_bulk(dev, &plat->resets);
> +	if (ret == -ENOTSUPP || ret == -ENOENT)
> +		return 0;
> +	else if (ret)
> +		return ret;
> +
> +	ret = reset_deassert_bulk(&plat->resets);
> +	if (ret) {
> +		reset_release_bulk(&plat->resets);
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
> +static int xhci_dwc3_clk_init(struct udevice *dev,
> +			      struct xhci_dwc3_plat *plat)
> +{
> +	int ret;
> +
> +	ret = clk_get_bulk(dev, &plat->clks);
> +	if (ret == -ENOSYS || ret == -ENOENT)
> +		return 0;
> +	if (ret)
> +		return ret;
> +
> +	ret = clk_enable_bulk(&plat->clks);
> +	if (ret) {
> +		clk_release_bulk(&plat->clks);
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
>  static int xhci_dwc3_probe(struct udevice *dev)
>  {
>  	struct xhci_hcor *hcor;
> @@ -122,6 +166,14 @@ static int xhci_dwc3_probe(struct udevice *dev)
>  	u32 reg;
>  	int ret;
>  
> +	ret = xhci_dwc3_reset_init(dev, plat);
> +	if (ret)
> +		return ret;
> +
> +	ret = xhci_dwc3_clk_init(dev, plat);
> +	if (ret)
> +		return ret;
> +
>  	hccr = (struct xhci_hccr *)((uintptr_t)dev_remap_addr(dev));
>  	hcor = (struct xhci_hcor *)((uintptr_t)hccr +
>  			HC_LENGTH(xhci_readl(&(hccr)->cr_capbase)));
> @@ -171,6 +223,10 @@ static int xhci_dwc3_remove(struct udevice *dev)
>  
>  	dwc3_shutdown_phy(dev, &plat->phys);
>  
> +	clk_release_bulk(&plat->clks);
> +
> +	reset_release_bulk(&plat->resets);
> +
>  	return xhci_deregister(dev);
>  }
>  

  reply	other threads:[~2021-04-21 10:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-17 14:20 [PATCH v2 0/4] Allwinner H6 USB3 support Samuel Holland
2021-04-17 14:20 ` [PATCH v2 1/4] phy: sun50i-usb3: Add a driver for the H6 USB3 PHY Samuel Holland
2021-04-17 14:20 ` [PATCH v2 2/4] usb: xhci-pci: Move reset logic out of XHCI core Samuel Holland
2021-04-21 10:36   ` Andre Przywara
2021-04-21 13:36     ` Samuel Holland
2021-04-21 14:58       ` Andre Przywara
2021-07-05  8:04   ` Bin Meng
2021-07-05  8:19     ` Marek Vasut
2021-07-05  8:38       ` Bin Meng
2021-07-05  9:06         ` Andre Przywara
2021-07-05  9:18           ` Bin Meng
2021-07-05 10:45             ` Marek Vasut
2021-07-05 12:12               ` Andre Przywara
2021-07-05  9:20         ` Marek Vasut
2021-04-17 14:20 ` [PATCH v2 3/4] usb: xhci-dwc3: Add support for clocks/resets Samuel Holland
2021-04-21 10:37   ` Andre Przywara [this message]
2021-04-17 14:20 ` [PATCH v2 4/4] configs: Enable USB3 on Allwinner H6 boards Samuel Holland
2021-04-21 10:37   ` Andre Przywara
2021-04-21 10:43 ` [PATCH v2 0/4] Allwinner H6 USB3 support Andre Przywara
2021-04-21 10:53   ` Marek Vasut
2021-07-04 23:09     ` Andre Przywara
2021-07-05  1:18       ` Bin Meng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210421113700.37eebbd8@slackpad.fritz.box \
    --to=andre.przywara@arm.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.