Tegra xHCI genpd support
Subsystems (8)
Jon Hunter
maintainercover Tegra xHCI genpd support
This series add genpd support for the Tegra xHCI device that requires more than one power-domain to operate.
This series is making changes to more than one subsystem and at first glance may look like a maintainers nightmare. However, my proposal is this, once reviewed and people are happy ...
1. Patches 1-3 should be merged first. Note there is a dependency between patches 1 and 3 such that 3 can only be merged once 1 has been accepted.
2. Once patches 1-3 are accepted, then 4 and 5 can be merged via the Tegra tree.
Jon Hunter (5):
PM / Domains: Export symbol for genpd_dev_pm_attach_by_name
dt-bindings: usb: xhci-tegra: Add power-domain details
usb: xhci: tegra: Add genpd support
soc/tegra: pmc: Don't power-up XUSB power-domains
arm64: dts: tegra210: Add power-domains for xHCI
.../bindings/usb/nvidia,tegra124-xusb.txt | 8 ++ arch/arm64/boot/dts/nvidia/tegra210.dtsi | 2 + drivers/base/power/domain.c | 1 + drivers/soc/tegra/pmc.c | 16 ---- drivers/usb/host/xhci-tegra.c | 88 +++++++++++++++++++--- 5 files changed, 88 insertions(+), 27 deletions(-)
Signature · 1 line
2.7.4
Jon Hunter
maintainerPATCH 1/5 PM / Domains: Export symbol for genpd_dev_pm_attach_by_name
Export the symbol for genpd_dev_pm_attach_by_name() so that drivers built as modules can call this function.
--- drivers/base/power/domain.c | 1 + 1 file changed, 1 insertion(+)
drivers/base/power/domain.c +1 -0
@@ -2397,6 +2397,7 @@ struct device *genpd_dev_pm_attach_by_name(struct device *dev, char *name)return genpd_dev_pm_attach_by_id (dev, index); } +EXPORT_SYMBOL_GPL (genpd_dev_pm_attach_by_name);static const struct of_device_id idle_state_match[] = { { .compatible ="domain-idle-state" , },
Signature · 1 line
2.7.4
Re: [PATCH 1/5] PM / Domains: Export symbol for genpd_dev_pm_attach_by_name
Quoted 13 lines · Jon Hunter
Export the symbol for
genpd_dev_pm_attach_by_name()so that drivers built as modules can call this function.Signed-off-by Jon Hunter <[email protected]>--- drivers/base/power/domain.c | 1 + 1 file changed, 1 insertion(+)drivers/base/power/domain.c +0
-0
drivers/base/power/domain.c struct device *genpd_dev_pm_attach_by_name(struct device *dev, char *name) · line 2400
Quoted 4 lines
drivers/base/power/domain.c +1
-0@@ -2397,6 +2397,7 @@ struct device *genpd_dev_pm_attach_by_name(struct device *dev, char *name)return genpd_dev_pm_attach_by_id (dev, index); } +EXPORT_SYMBOL_GPL (genpd_dev_pm_attach_by_name);
Driver's shouldn't be calling this function, but instead use dev_pm_domain_attach_by_name().
Is there any problem with that?
[...]
Kind regards
Uffe
Jon Hunter
maintainerRe: [PATCH 1/5] PM / Domains: Export symbol for genpd_dev_pm_attach_by_name
Quoted 15 lines · Ulf Hansson
Quoted 14 lines · Jon Hunter
Export the symbol for
genpd_dev_pm_attach_by_name()so that drivers built as modules can call this function.Signed-off-by Jon Hunter <[email protected]>--- drivers/base/power/domain.c | 1 + 1 file changed, 1 insertion(+)drivers/base/power/domain.c +0
-0@@ -2397,6 +2397,7 @@ struct device *genpd_dev_pm_attach_by_name(struct device *dev, char *name)
Quoted 8 lines
drivers/base/power/domain.c struct device *genpd_dev_pm_attach_by_name(struct device *dev, char *name) · line 2400
Quoted 3 lines
drivers/base/power/domain.c +1
-0return genpd_dev_pm_attach_by_id (dev, index); } +EXPORT_SYMBOL_GPL (genpd_dev_pm_attach_by_name);Driver's shouldn't be calling this function, but instead use
dev_pm_domain_attach_by_name().Is there any problem with that?
No not at all. Yes that works, sorry it had been a while since I looked at this and managed to balls it up. OK, I will drop this and correct the API used by the driver.
Cheers!
Jon
Signature · 1 line
nvpublic
Jon Hunter
maintainerPATCH 2/5 dt-bindings: usb: xhci-tegra: Add power-domain details
In reply to Jon HunterAdd details for power-domains to the Tegra xHCI bindings so that generic power-domains can be used for inconjunction with the xHCI driver.
--- Documentation/devicetree/bindings/usb/nvidia,tegra124-xusb.txt | 8 ++++++++ 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/usb/nvidia,tegra124-xusb.txt +8 -0
@@ -59,6 +59,14 @@ For Tegra210: - avdd-pll-uerefe-supply: PLLE reference PLL power supply. Must supply 1.05 V. - dvdd-pex-pll-supply: PCIe/USB3 PLL power supply. Must supply 1.05 V. - hvdd-pex-pll-e-supply: High-voltage PLLE power supply. Must supply 1.8 V. +- power-domains: A list of PM domain specifiers that reference each power-domain + used by the xHCI controller. This list must comprise of a specifier for the + XUSBA and XUSBC power-domains. See ../power/power_domain.txt and + ../arm/tegra/nvidia,tegra20-pmc.txt for details. +- power-domain-names: A list of names that represent each of the specifiers in + the 'power-domains' property. Must include 'xusb_ss' and 'xusb_host' which + represent the power-domains XUSBA and XUSBC, respectively. See + ../power/power_domain.txt for details. Optional properties: --------------------
Signature · 1 line
2.7.4
Jon Hunter
maintainerPATCH 3/5 usb: xhci: tegra: Add genpd support
In reply to Jon HunterThe generic power-domain framework has been updated to allow devices that require more than one power-domain to create a new device for each power-domain required and then link these new power-domain devices to the consumer device.
Update the Tegra xHCI driver to use the new APIs provided by the generic power-domain framework so we can use the generic power-domain framework for managing the xHCI controllers power-domains. Please note that to maintain backward compatibility with older device-tree blobs these new generic power-domain APIs are only used if the 'power-domains' property is present and otherwise we fall back to using the legacy Tegra APIs for managing the power-domains.
--- drivers/usb/host/xhci-tegra.c | 88 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 11 deletions(-)
drivers/usb/host/xhci-tegra.c +77 -11
@@ -18,6 +18,7 @@#include <linux/phy/tegra/xusb.h> #include <linux/platform_device.h> #include <linux/pm.h> +#include <linux/pm_domain.h> #include <linux/pm_runtime.h> #include <linux/regulator/consumer.h> #include <linux/reset.h>
@@ -194,6 +195,11 @@ struct tegra_xusb {struct reset_control *host_rst;struct reset_control *ss_rst; +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;
@@ -928,6 +934,60 @@ static int tegra_xusb_load_firmware(struct tegra_xusb *tegra)return 0 ; } +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 (tegra->genpd_dev_ss) +dev_pm_domain_detach (tegra->genpd_dev_ss, true); +if (tegra->genpd_dev_host) +dev_pm_domain_detach (tegra->genpd_dev_host, true); +} + +static int tegra_xusb_powerdomain_init (struct device *dev, +struct tegra_xusb *tegra) +{ +int err; + + tegra->genpd_dev_host =genpd_dev_pm_attach_by_name (dev,"xusb_host" ); +if (IS_ERR (tegra->genpd_dev_host)) { + err =PTR_ERR (tegra->genpd_dev_host); +dev_err (dev,"failed to get host pm-domain: %d\n" , err); +return err; + } + + tegra->genpd_dev_ss =genpd_dev_pm_attach_by_name (dev,"xusb_ss" ); +if (IS_ERR (tegra->genpd_dev_ss)) { +tegra_xusb_powerdomain_remove (dev, tegra); + err =PTR_ERR (tegra->genpd_dev_ss); +dev_err (dev,"failed to get superspeed pm-domain: %d\n" , err); +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) { +tegra_xusb_powerdomain_remove (dev, tegra); +dev_err (dev,"adding host device link failed!\n" ); +return -ENODEV ; + } + + tegra->genpd_dl_ss =device_link_add (dev, tegra->genpd_dev_ss, +DL_FLAG_PM_RUNTIME | +DL_FLAG_STATELESS ); +if (!tegra->genpd_dl_ss) { +tegra_xusb_powerdomain_remove (dev, tegra); +dev_err (dev,"adding superspeed device link failed!\n" ); +return -ENODEV ; + } + +return 0 ; +} +static int tegra_xusb_probe (struct platform_device *pdev) {struct tegra_xusb_mbox_msg msg;
@@ -1038,7 +1098,11 @@ static int tegra_xusb_probe(struct platform_device *pdev) goto put_padctl; } -if (!pdev->dev.pm_domain) { +if (of_property_read_bool (pdev->dev.of_node,"power-domains" )) { + err =tegra_xusb_powerdomain_init (&pdev->dev, tegra); +if (err) + goto put_padctl; + }else { tegra->host_rst =devm_reset_control_get (&pdev->dev,"xusb_host" );if (IS_ERR (tegra->host_rst)) {
@@ -1069,9 +1133,10 @@ static int tegra_xusb_probe(struct platform_device *pdev) tegra->host_clk, tegra->host_rst);if (err) { +tegra_powergate_power_off (TEGRA_POWERGATE_XUSBA );dev_err (&pdev->dev,"failed to enable XUSBC domain: %d\n" , err); - goto disable_xusba; + goto put_padctl; } }
@@ -1079,7 +1144,7 @@ static int tegra_xusb_probe(struct platform_device *pdev) sizeof(*tegra->supplies), GFP_KERNEL);if (!tegra->supplies) { err = -ENOMEM ; - goto disable_xusbc; + goto put_powerdomains; }for (i =0 ; i < tegra->soc->num_supplies; i++)
@@ -1089,7 +1154,7 @@ static int tegra_xusb_probe(struct platform_device *pdev) tegra->supplies);if (err) {dev_err (&pdev->dev,"failed to get regulators: %d\n" , err); - goto disable_xusbc; + goto put_powerdomains; }for (i =0 ; i < tegra->soc->num_types; i++)
@@ -1099,7 +1164,7 @@ static int tegra_xusb_probe(struct platform_device *pdev) sizeof(*tegra->phys), GFP_KERNEL);if (!tegra->phys) { err = -ENOMEM ; - goto disable_xusbc; + goto put_powerdomains; }for (i =0 , k =0 ; i < tegra->soc->num_types; i++) {
@@ -1115,7 +1180,7 @@ static int tegra_xusb_probe(struct platform_device *pdev)"failed to get PHY %s: %ld\n" , prop, PTR_ERR(phy)); err =PTR_ERR (phy); - goto disable_xusbc; + goto put_powerdomains; } tegra->phys[k++] = phy;
@@ -1126,7 +1191,7 @@ static int tegra_xusb_probe(struct platform_device *pdev) dev_name(&pdev->dev));if (!tegra->hcd) { err = -ENOMEM ; - goto disable_xusbc; + goto put_powerdomains; }/*
@@ -1222,12 +1287,13 @@ static int tegra_xusb_probe(struct platform_device *pdev) disable_rpm:pm_runtime_disable (&pdev->dev);usb_put_hcd (tegra->hcd); -disable_xusbc: -if (!pdev->dev.pm_domain) +put_powerdomains: +if (of_property_read_bool (pdev->dev.of_node,"power-domains" )) { +tegra_xusb_powerdomain_remove (&pdev->dev, tegra); + }else {tegra_powergate_power_off (TEGRA_POWERGATE_XUSBC ); -disable_xusba: -if (!pdev->dev.pm_domain)tegra_powergate_power_off (TEGRA_POWERGATE_XUSBA ); + } put_padctl:tegra_xusb_padctl_put (tegra->padctl);return err;
Signature · 1 line
2.7.4
Jon Hunter
maintainerPATCH 4/5 soc/tegra: pmc: Don't power-up XUSB power-domains
In reply to Jon HunterNow that the Tegra xHCI driver manages the XUSB power-domains itself, remove the code to power-up the power-domains used by the xHCI device from the PMC driver on boot.
--- drivers/soc/tegra/pmc.c | 16 ---------------- 1 file changed, 16 deletions(-)
drivers/soc/tegra/pmc.c +0 -16
@@ -847,22 +847,6 @@ static void tegra_powergate_add(struct tegra_pmc *pmc, struct device_node *np) goto remove_resets; } -/* -* FIXME: If XHCI is enabled for Tegra, then power-up the XUSB -* host and super-speed partitions. Once the XHCI driver -* manages the partitions itself this code can be removed. Note -* that we don't register these partitions with the genpd core -* to avoid it from powering down the partitions as they appear -* to be unused. -*/ -if (IS_ENABLED (CONFIG_USB_XHCI_TEGRA ) && - (id ==TEGRA_POWERGATE_XUSBA || id ==TEGRA_POWERGATE_XUSBC )) { -if (off) -WARN_ON (tegra_powergate_power_up (pg, true)); - - goto remove_resets; - } - err =pm_genpd_init (&pg->genpd,NULL , off);if (err <0 ) { pr_err("failed to initialise PM domain %s: %d\n", np->name,
Signature · 1 line
2.7.4
Jon Hunter
maintainerPATCH 5/5 arm64: dts: tegra210: Add power-domains for xHCI
In reply to Jon HunterPopulate the power-domain properties for the xHCI device for Tegra210.
--- arch/arm64/boot/dts/nvidia/tegra210.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/nvidia/tegra210.dtsi +2 -0
@@ -879,6 +879,8 @@ resets = <&tegra_car 89>, <&tegra_car 156>, <&tegra_car 143>; reset-names = "xusb_host", "xusb_ss", "xusb_src"; + power-domains = <&pd_xusbhost>, <&pd_xusbss>; + power-domain-names = "xusb_host", "xusb_ss"; nvidia,xusb-padctl = <&padctl>;
Signature · 1 line
2.7.4