Re: [PATCH V2 2/3] usb: xhci: tegra: Add runtime PM support

From: Thierry Reding
Date: Fri Apr 27 2018 - 06:10:26 EST


On Thu, Apr 26, 2018 at 03:59:09PM +0100, Jon Hunter wrote:
> Add runtime PM support to the Tegra XHCI driver and move the function
> calls to enable/disable the clocks, regulators and PHY into the runtime
> PM callbacks.
>
> Signed-off-by: Jon Hunter <jonathanh@xxxxxxxxxx>
> ---
>
> Changes since V1:
> - Re-worked change to handle case where runtime PM is disabled.
>
> drivers/usb/host/xhci-tegra.c | 89 ++++++++++++++++++++++++++++++-------------
> 1 file changed, 63 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
> index 02b0b24faa58..85f2381883ad 100644
> --- a/drivers/usb/host/xhci-tegra.c
> +++ b/drivers/usb/host/xhci-tegra.c
> @@ -18,6 +18,7 @@
> #include <linux/phy/tegra/xusb.h>
> #include <linux/platform_device.h>
> #include <linux/pm.h>
> +#include <linux/pm_runtime.h>
> #include <linux/regulator/consumer.h>
> #include <linux/reset.h>
> #include <linux/slab.h>
> @@ -761,6 +762,50 @@ static void tegra_xusb_phy_disable(struct tegra_xusb *tegra)
> }
> }
>
> +static int tegra_xusb_runtime_suspend(struct device *dev)
> +{
> + struct tegra_xusb *tegra = dev_get_drvdata(dev);
> +
> + tegra_xusb_phy_disable(tegra);
> + regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies);
> + tegra_xusb_clk_disable(tegra);
> +
> + return 0;
> +}
> +
> +static int tegra_xusb_runtime_resume(struct device *dev)
> +{
> + struct tegra_xusb *tegra = dev_get_drvdata(dev);
> + int err;
> +
> + err = tegra_xusb_clk_enable(tegra);
> + if (err) {
> + dev_err(dev, "failed to enable clocks: %d\n", err);
> + return err;
> + }
> +
> + err = regulator_bulk_enable(tegra->soc->num_supplies, tegra->supplies);
> + if (err) {
> + dev_err(dev, "failed to enable regulators: %d\n", err);
> + goto disable_clk;
> + }
> +
> + err = tegra_xusb_phy_enable(tegra);
> + if (err < 0) {
> + dev_err(dev, "failed to enable PHYs: %d\n", err);
> + goto disable_regulator;
> + }
> +
> + return 0;
> +
> +disable_regulator:
> + regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies);
> +disable_clk:
> + tegra_xusb_clk_disable(tegra);
> + return err;
> +}
> +
> +

There's an extra blank line here. Other than that, this looks very nice.

Reviewed-by: Thierry Reding <treding@xxxxxxxxxx>
Acked-by: Thierry Reding <treding@xxxxxxxxxx>

Attachment: signature.asc
Description: PGP signature