From: Thierry Reding <thierry.reding@gmail.com>
To: JC Kuo <jckuo@nvidia.com>
Cc: gregkh@linuxfoundation.org, robh@kernel.org,
jonathanh@nvidia.com, kishon@ti.com, linux-tegra@vger.kernel.org,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org, nkristam@nvidia.com
Subject: Re: [PATCH v2 11/12] usb: host: xhci-tegra: unlink power domain devices
Date: Mon, 31 Aug 2020 14:42:14 +0200 [thread overview]
Message-ID: <20200831124214.GG1689119@ulmo> (raw)
In-Reply-To: <20200831044043.1561074-12-jckuo@nvidia.com>
[-- Attachment #1: Type: text/plain, Size: 4522 bytes --]
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@nvidia.com>
> ---
> 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-08-31 12:42 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-31 4:40 [PATCH v2 00/12] Tegra XHCI controller ELPG support JC Kuo
2020-08-31 4:40 ` [PATCH v2 01/12] clk: tegra: Add PLLE HW power sequencer control JC Kuo
2020-08-31 4:40 ` [PATCH v2 02/12] clk: tegra: don't enable PLLE HW sequencer at init JC Kuo
2020-08-31 4:40 ` [PATCH v2 03/12] phy: tegra: xusb: t210: rearrange UPHY init JC Kuo
2020-08-31 11:42 ` Thierry Reding
2020-09-04 9:10 ` JC Kuo
2020-08-31 4:40 ` [PATCH v2 04/12] phy: tegra: xusb: t210: add lane_iddq operations JC Kuo
2020-08-31 11:53 ` Thierry Reding
2020-09-07 2:26 ` JC Kuo
2020-08-31 4:40 ` [PATCH v2 05/12] phy: tegra: xusb: add sleepwalk and suspend/resume JC Kuo
2020-08-31 11:58 ` Thierry Reding
2020-09-07 2:34 ` JC Kuo
2020-08-31 4:40 ` [PATCH v2 06/12] soc/tegra: pmc: provide usb sleepwalk register map JC Kuo
2020-08-31 12:09 ` Thierry Reding
2020-09-07 3:07 ` JC Kuo
2020-08-31 4:40 ` [PATCH v2 07/12] arm64: tegra210: XUSB PADCTL add "nvidia,pmc" prop JC Kuo
2020-08-31 4:40 ` [PATCH v2 08/12] phy: tegra: xusb: t210: support wake and sleepwalk JC Kuo
2020-08-31 12:37 ` Thierry Reding
2020-09-08 1:14 ` JC Kuo
2020-09-01 15:14 ` kernel test robot
2020-08-31 4:40 ` [PATCH v2 09/12] phy: tegra: xusb: t186: " JC Kuo
2020-08-31 12:38 ` Thierry Reding
2020-09-01 16:51 ` kernel test robot
2020-08-31 4:40 ` [PATCH v2 10/12] arm64: tegra210/tegra186/tegra194: XUSB PADCTL irq JC Kuo
2020-08-31 4:40 ` [PATCH v2 11/12] usb: host: xhci-tegra: unlink power domain devices JC Kuo
2020-08-31 12:42 ` Thierry Reding [this message]
2020-09-08 2:19 ` JC Kuo
2020-08-31 4:40 ` [PATCH v2 12/12] xhci: tegra: enable ELPG for runtime/system PM JC Kuo
2020-08-31 12:50 ` Thierry Reding
2020-09-08 2:29 ` JC Kuo
2020-09-01 20:33 ` Dmitry Osipenko
2020-09-08 2:42 ` JC Kuo
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=20200831124214.GG1689119@ulmo \
--to=thierry.reding@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jckuo@nvidia.com \
--cc=jonathanh@nvidia.com \
--cc=kishon@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nkristam@nvidia.com \
--cc=robh@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).