Re: [PATCH v2 11/12] usb: host: xhci-tegra: unlink power domain devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 31, 2020 at 12:40:42PM +0800, JC Kuo wrote:
> This commit unlinks xhci-tegra platform device with ss/host power
> domain devices. Reasons for this change is - at elpg entry, phy
> sleepwalk and wake configuration need to be done before powering
> down ss/host partitions, and phy need be powered off after powering
> down ss/host partitions. Sequence looks like roughly below:
> 
>   tegra_xusb_enter_elpg() -> xhci_suspend()
>                           -> enable phy sleepwalk and wake if needed
>                           -> power down ss/host partitions
>                           -> power down phy
> 
> If ss/host power domains are linked to xhci-tegra platform device, we
> are not able to perform the sequence like above.
> 
> This commit introduces:
>   1. tegra_xusb_unpowergate_partitions() to power up ss and host
>      partitions together. If ss/host power domain devices are
>      available, it invokes pm_runtime_get_sync() to request power
>      driver to power up partitions; If power domain devices are not
>      available, tegra_powergate_sequence_power_up() will be used to
>      power up partitions.
> 
>   2. tegra_xusb_powergate_partitions() to power down ss and host
>      partitions together. If ss/host power domain devices are
>      available, it invokes pm_runtime_put_sync() to request power
>      driver to power down partitions; If power domain devices are not
>      available, tegra_powergate_power_off() will be used to power down
>      partitions.
> 
> Signed-off-by: JC Kuo <jckuo@xxxxxxxxxx>
> ---
>  drivers/usb/host/xhci-tegra.c | 202 +++++++++++++++++++---------------
>  1 file changed, 111 insertions(+), 91 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
> index 934be1686352..ce6526c2caf6 100644
> --- a/drivers/usb/host/xhci-tegra.c
> +++ b/drivers/usb/host/xhci-tegra.c
> @@ -249,8 +249,6 @@ struct tegra_xusb {
>  
>  	struct device *genpd_dev_host;
>  	struct device *genpd_dev_ss;
> -	struct device_link *genpd_dl_host;
> -	struct device_link *genpd_dl_ss;
>  
>  	struct phy **phys;
>  	unsigned int num_phys;
> @@ -814,36 +812,12 @@ 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);
> -
> -	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;
> -	}
> -
>  	return 0;
> -
> -disable_clk:
> -	tegra_xusb_clk_disable(tegra);
> -	return err;
>  }
>  
>  #ifdef CONFIG_PM_SLEEP
> @@ -1019,10 +993,6 @@ static int tegra_xusb_load_firmware(struct tegra_xusb *tegra)
>  static void tegra_xusb_powerdomain_remove(struct device *dev,
>  					  struct tegra_xusb *tegra)
>  {
> -	if (tegra->genpd_dl_ss)
> -		device_link_del(tegra->genpd_dl_ss);
> -	if (tegra->genpd_dl_host)
> -		device_link_del(tegra->genpd_dl_host);
>  	if (!IS_ERR_OR_NULL(tegra->genpd_dev_ss))
>  		dev_pm_domain_detach(tegra->genpd_dev_ss, true);
>  	if (!IS_ERR_OR_NULL(tegra->genpd_dev_host))
> @@ -1048,20 +1018,88 @@ static int tegra_xusb_powerdomain_init(struct device *dev,
>  		return err;
>  	}
>  
> -	tegra->genpd_dl_host = device_link_add(dev, tegra->genpd_dev_host,
> -					       DL_FLAG_PM_RUNTIME |
> -					       DL_FLAG_STATELESS);
> -	if (!tegra->genpd_dl_host) {
> -		dev_err(dev, "adding host device link failed!\n");
> -		return -ENODEV;
> +	return 0;
> +}
> +
> +static int tegra_xusb_unpowergate_partitions(struct tegra_xusb *tegra)
> +{
> +	struct device *dev = tegra->dev;
> +	bool use_genpd;
> +	int rc;
> +
> +	use_genpd = of_property_read_bool(dev->of_node, "power-domains");

I don't think that's technically correct. Just because a "power-domains"
property exists in DT doesn't mean any power domains are necessarily
attached to the device. I think you'll need to check for something like

	if (dev->pm_domain)

here.

Thierry

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux