Add generic PM domain support for Tegra SoCs
Subsystems (12)
v2 cover Add generic PM domain support for Tegra SoCs
Hi,
This is the v2 of Tegra generic PM domain support. The v1 is the RFC series[1].
Patch 1 adds the new function of_reset_control_get_by_index().
Patch 2 - 5 add the MC flush operations for Tegra30/Tegra114/Tegra124.
Patch 6 is a PLLD fix for Tegra114.
Patch 7 is based on Thierry's proof-of-concept work and adds necessary changes to support DT parsing and power sequence.
Patch 8 - 11 add the power domain nodes into DT.
Patch 12 - 17 are the clean up for the legacy powergate API.
TODO:
* The GR3D is broken on ToT now. Have to verify it with this series after we fix it properly.
v2:
* Add support for Tegra30/Tegra114
* Address Alex's comments
[1] http://www.spinics.net/lists/linux-tegra/msg21012.html
Thanks,
Vince
Thierry Reding (1):
soc: tegra: pmc: Add generic PM domain support
Vince Hsu (16):
reset: add of_reset_control_get_by_index()
memory: tegra: add mc flush support
memory: tegra: add flush operation for Tegra30 memory clients
memory: tegra: add flush operation for Tegra114 memory clients
memory: tegra: add flush operation for Tegra124 memory clients
clk: tegra: remove TEGRA_PLL_USE_LOCK for PLLD/PLLD2
ARM: tegra: add PM domain device nodes to Tegra30 DT
ARM: tegra: add PM domain device nodes to Tegra114 DT
ARM: tegra: add PM domain device nodes to Tegra124 DT
ARM: tegra: add GPU power supply to Jetson TK1 DT drm/tegra: dc: remove the power sequence from driver
PCI: tegra: remove the power sequence from driver
ata: ahci_tegra: remove power sequence from driver drm/tegra: remove GR3D power sequence from driver
ARM: tegra: select PM_GENERIC_DOMAINS
soc/tegra: remove lagacy powergate APIs
arch/arm/boot/dts/tegra114.dtsi | 43 +- arch/arm/boot/dts/tegra124-jetson-tk1.dts | 4 + arch/arm/boot/dts/tegra124.dtsi | 86 +++- arch/arm/boot/dts/tegra30.dtsi | 45 +- arch/arm/mach-tegra/Kconfig | 1 + drivers/ata/ahci_tegra.c | 11 - drivers/clk/tegra/clk-tegra114.c | 6 +- drivers/gpu/drm/tegra/dc.c | 46 +- drivers/gpu/drm/tegra/gr3d.c | 32 +- drivers/memory/tegra/mc.c | 122 ++++++ drivers/memory/tegra/mc.h | 5 + drivers/memory/tegra/tegra114.c | 106 ++++- drivers/memory/tegra/tegra124.c | 38 +- drivers/memory/tegra/tegra30.c | 80 +++- drivers/pci/host/pci-tegra.c | 22 +- drivers/reset/core.c | 44 +- drivers/soc/tegra/pmc.c | 657 +++++++++++++++++++++++++--- include/dt-bindings/power/tegra-powergate.h | 30 ++ include/linux/reset.h | 9 + include/soc/tegra/mc.h | 46 +- include/soc/tegra/pmc.h | 22 - 21 files changed, 1255 insertions(+), 200 deletions(-) create mode 100644 include/dt-bindings/power/tegra-powergate.h
Signature · 1 line
2.1.4
PATCH v2 1/17 reset: add of_reset_control_get_by_index()
Add of_reset_control_get_by_index() to allow the drivers to get reset device without knowing its name.
---
v2: minor changes according to Alex's comments
drivers/reset/core.c | 44 +++++++++++++++++++++++++++++--------------- include/linux/reset.h | 9 +++++++++ 2 files changed, 38 insertions(+), 15 deletions(-)
drivers/reset/core.c +29 -15
@@ -140,28 +140,15 @@ int reset_control_status(struct reset_control *rstc) }EXPORT_SYMBOL_GPL (reset_control_status); -/** -* of_reset_control_get - Lookup and obtain a reference to a reset controller. -* @node: device to be reset by the controller -* @id: reset line name -* -* Returns a struct reset_control or IS_ERR() condition containing errno. -* -* Use of id names is optional. -*/ -struct reset_control *of_reset_control_get (struct device_node *node, -const char *id) +struct reset_control *__of_reset_control_get (struct device_node *node, +int index) {struct reset_control *rstc =ERR_PTR (-EPROBE_DEFER );struct reset_controller_dev *r, *rcdev;struct of_phandle_args args; -int index =0 ;int rstc_id;int ret; -if (id) - index =of_property_match_string (node, -"reset-names" , id); ret =of_parse_phandle_with_args (node,"resets" ,"#reset-cells" , index, &args);if (ret)
@@ -202,6 +189,33 @@ struct reset_control *of_reset_control_get(struct device_node *node,return rstc; } + +struct reset_control *of_reset_control_get_by_index (struct device_node *node, +int index) +{ +return __of_reset_control_get (node, index); +} +EXPORT_SYMBOL_GPL (of_reset_control_get_by_index); + +/** +* of_reset_control_get - Lookup and obtain a reference to a reset controller. +* @node: device to be reset by the controller +* @id: reset line name +* +* Returns a struct reset_control or IS_ERR() condition containing errno. +* +* Use of id names is optional. +*/ +struct reset_control *of_reset_control_get (struct device_node *node, +const char *id) +{ +int index =0 ; + +if (id) + index =of_property_match_string (node, +"reset-names" , id); +return __of_reset_control_get (node, index); +}EXPORT_SYMBOL_GPL (of_reset_control_get);/**
include/linux/reset.h +9 -0
@@ -38,6 +38,9 @@ static inline struct reset_control *devm_reset_control_get_optional(struct reset_control *of_reset_control_get (struct device_node *node,const char *id); +struct reset_control *of_reset_control_get_by_index ( +struct device_node *node,int index); +#else static inline int reset_control_reset (struct reset_control *rstc)
@@ -92,6 +95,12 @@ static inline struct reset_control *of_reset_control_get(return ERR_PTR (-ENOSYS ); } +static inline struct reset_control *of_reset_control_get_by_index ( +struct device_node *node,int index) +{ +return ERR_PTR (-ENOSYS ); +} +#endif /* CONFIG_RESET_CONTROLLER */ #endif
Signature · 1 line
2.1.4
Philipp Zabel
maintainerRe: [PATCH v2 01/17] reset: add of_reset_control_get_by_index()
Hi Vince,
Am Donnerstag, den 12.03.2015, 20:15 +0800 schrieb Vince Hsu:
Quoted 2 lines
Add
of_reset_control_get_by_index()to allow the drivers to get reset device without knowing its name.
I see this is useful in the case of PM domain drivers that just need to trigger a list of resets in whatever order.
Quoted 20 lines
Signed-off-by Vince Hsu <[email protected]>---
v2: minor changes according to Alex's commentsdrivers/reset/core.c | 44 +++++++++++++++++++++++++++++--------------- include/linux/reset.h | 9 +++++++++ 2 files changed, 38 insertions(+), 15 deletions(-)drivers/reset/core.c +0
-3@@ -140,28 +140,15 @@ int reset_control_status(struct reset_control *rstc) }EXPORT_SYMBOL_GPL (reset_control_status); -/** -* of_reset_control_get - Lookup and obtain a reference to a reset controller. -* @node: device to be reset by the controller
drivers/reset/core.c int reset_control_status(struct reset_control *rstc) · line 144
Quoted 10 lines
drivers/reset/core.c +2
-8-* @id: reset line name -* -* Returns a struct reset_control or IS_ERR() condition containing errno. -* -* Use of id names is optional. -*/ -struct reset_control *of_reset_control_get (struct device_node *node, -const char *id) +struct reset_control *__of_reset_control_get (struct device_node *node, +int index)
static
Quoted 15 lines
drivers/reset/core.c +0
-4{struct reset_control *rstc =ERR_PTR (-EPROBE_DEFER );struct reset_controller_dev *r, *rcdev;struct of_phandle_args args; -int index =0 ;int rstc_id;int ret; -if (id) - index =of_property_match_string (node, -"reset-names" , id); ret =of_parse_phandle_with_args (node,"resets" ,"#reset-cells" , index, &args);if (ret)
drivers/reset/core.c struct reset_control *of_reset_control_get(struct device_node *node, · line 198
Quoted 10 lines
drivers/reset/core.c +7
-0@@ -202,6 +189,33 @@ struct reset_control *of_reset_control_get(struct device_node *node,return rstc; } + +struct reset_control *of_reset_control_get_by_index (struct device_node *node, +int index) +{ +return __of_reset_control_get (node, index); +} +EXPORT_SYMBOL_GPL (of_reset_control_get_by_index);
This function is missing a kerneldoc comment, and please add a note that this is only to be used if the order of the resets doesn't matter.
Actually, I see no reason not to just merge __of_reset_control_get into of_reset_control_get_by_index and then just call that from of_reset_control_get.
Quoted 10 lines
drivers/reset/core.c +10
-0+/** +* of_reset_control_get - Lookup and obtain a reference to a reset controller. +* @node: device to be reset by the controller +* @id: reset line name +* +* Returns a struct reset_control or IS_ERR() condition containing errno. +* +* Use of id names is optional. +*/ +struct reset_control *of_reset_control_get(struct device_node *node,
drivers/reset/core.c struct reset_control *of_reset_control_get(struct device_node *node, · line 219
Quoted 10 lines
drivers/reset/core.c +9
-0+ const char *id) +{ +int index =0 ; + +if (id) + index =of_property_match_string (node, +"reset-names" , id); +return __of_reset_control_get (node, index); +}EXPORT_SYMBOL_GPL (of_reset_control_get);
[...]
regards
Philipp
Re: [PATCH v2 01/17] reset: add of_reset_control_get_by_index()
Hi Philipp,
Quoted 7 lines · Philipp Zabel
Hi Vince,
Am Donnerstag, den 12.03.2015, 20:15 +0800 schrieb Vince Hsu:
Quoted 2 lines
Add
of_reset_control_get_by_index()to allow the drivers to get reset device without knowing its name.I see this is useful in the case of PM domain drivers that just need to trigger a list of resets in whatever order.
Yep.
Quoted 18 lines
Quoted 18 lines
Signed-off-by Vince Hsu <[email protected]>---
v2: minor changes according to Alex's commentsdrivers/reset/core.c | 44 +++++++++++++++++++++++++++++--------------- include/linux/reset.h | 9 +++++++++ 2 files changed, 38 insertions(+), 15 deletions(-)drivers/reset/core.c +0
-0@@ -140,28 +140,15 @@ int reset_control_status(struct reset_control *rstc) }EXPORT_SYMBOL_GPL (reset_control_status);
Quoted 14 lines
drivers/reset/core.c int reset_control_status(struct reset_control *rstc) · line 144
Quoted 13 lines
drivers/reset/core.c +2
-11-/** -* of_reset_control_get - Lookup and obtain a reference to a reset controller. -* @node: device to be reset by the controller -* @id: reset line name -* -* Returns a struct reset_control or IS_ERR() condition containing errno. -* -* Use of id names is optional. -*/ -struct reset_control *of_reset_control_get (struct device_node *node, -const char *id) +struct reset_control *__of_reset_control_get (struct device_node *node, +int index)static
Will merge to of_reset_control_get_by_index.
Quoted 17 lines
Quoted 17 lines
drivers/reset/core.c +0
-4{struct reset_control *rstc =ERR_PTR (-EPROBE_DEFER );struct reset_controller_dev *r, *rcdev;struct of_phandle_args args; -int index =0 ;int rstc_id;int ret; -if (id) - index =of_property_match_string (node, -"reset-names" , id); ret =of_parse_phandle_with_args (node,"resets" ,"#reset-cells" , index, &args);if (ret)@@ -202,6 +189,33 @@ struct reset_control *of_reset_control_get(struct device_node *node,
Quoted 11 lines
drivers/reset/core.c struct reset_control *of_reset_control_get(struct device_node *node, · line 198
Quoted 9 lines
drivers/reset/core.c +7
-0return rstc; } + +struct reset_control *of_reset_control_get_by_index (struct device_node *node, +int index) +{ +return __of_reset_control_get (node, index); +} +EXPORT_SYMBOL_GPL (of_reset_control_get_by_index);This function is missing a kerneldoc comment, and please add a note that this is only to be used if the order of the resets doesn't matter.
Will add comment.
Quoted 4 lines
Actually, I see no reason not to just merge
__of_reset_control_getintoof_reset_control_get_by_indexand then just call that fromof_reset_control_get.
Indeed. Will fix.
Thanks for the review. :)
Vince
Quoted 26 lines
Quoted 11 lines
drivers/reset/core.c +10
-0+/** +* of_reset_control_get - Lookup and obtain a reference to a reset controller. +* @node: device to be reset by the controller +* @id: reset line name +* +* Returns a struct reset_control or IS_ERR() condition containing errno. +* +* Use of id names is optional. +*/ +struct reset_control *of_reset_control_get(struct device_node *node,drivers/reset/core.c struct reset_control *of_reset_control_get(struct device_node *node, · line 219
Quoted 10 lines
drivers/reset/core.c +9
-0+ const char *id) +{ +int index =0 ; + +if (id) + index =of_property_match_string (node, +"reset-names" , id); +return __of_reset_control_get (node, index); +}EXPORT_SYMBOL_GPL (of_reset_control_get);[...]
regards
Philipp
PATCH v2 2/17 memory: tegra: add mc flush support
In reply to Vince HsuThe flush operation of memory clients is needed for various IP blocks in the Tegra SoCs to perform a clean reset. Also add a mutex in struct tegra_mc for mc flush operations.
---
v2: make indentition and name changes according to Alex's comments
add mutex lock in struct tegra_mc for mc flush operations
drivers/memory/tegra/mc.c | 122 ++++++++++++++++++++++++++++++++++++++++ drivers/memory/tegra/tegra114.c | 2 +- drivers/memory/tegra/tegra124.c | 2 +- drivers/memory/tegra/tegra30.c | 2 +- include/soc/tegra/mc.h | 46 ++++++++++++++- 5 files changed, 169 insertions(+), 5 deletions(-)
drivers/memory/tegra/mc.c +122 -0
@@ -11,6 +11,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/slab.h>
@@ -62,6 +63,118 @@ static const struct of_device_id tegra_mc_of_match[] = { };MODULE_DEVICE_TABLE (of, tegra_mc_of_match); +static struct tegra_mc_swgroup *tegra_mc_get_swgroup (struct tegra_mc *mc, +unsigned int swgroup) +{ +struct tegra_mc_swgroup *sg; + +list_for_each_entry (sg, &mc->swgroups, head) { +if (sg->id == swgroup) +return sg; + } + +return NULL ; +} + +static struct tegra_mc_swgroup *tegra_mc_add_swgroup (struct tegra_mc *mc, +unsigned int swgroup) +{ +struct tegra_mc_swgroup *sg; + + sg =devm_kzalloc (mc->dev,sizeof (*sg),GFP_KERNEL ); +if (!sg) +return ERR_PTR (-ENOMEM ); + + sg->id = swgroup; + sg->mc = mc; +list_add_tail (&sg->head, &mc->swgroups); +INIT_LIST_HEAD (&sg->clients); + +return sg; +} + +struct tegra_mc_swgroup *tegra_mc_find_swgroup (struct device_node *node, +int index) +{ +struct of_phandle_args args; +struct platform_device *pdev; +struct tegra_mc *mc; +int ret; + + ret =of_parse_phandle_with_fixed_args (node,"nvidia,swgroup" , +1 , index, &args); +if (ret) +return ERR_PTR (ret); + + pdev =of_find_device_by_node (args.np); +if (!pdev) +return NULL ; + + mc =platform_get_drvdata (pdev); +if (!mc) +return NULL ; + +return tegra_mc_get_swgroup (mc, args.args[0 ]); +} +EXPORT_SYMBOL (tegra_mc_find_swgroup); + +static int __tegra_mc_flush_op (struct tegra_mc_swgroup *sg,tegra_mc_op op) +{ +struct tegra_mc *mc; +const struct tegra_mc_hotreset *client; +int i; + + mc = sg->mc; + client = mc->soc->hotresets; + +for (i =0 ; i < mc->soc->num_hotresets; i++, client++) { +if (sg->id == client->swgroup) +return op (mc, client); + } + +return -EINVAL ; + +} + +#define tegra_mc_flush_op (sg, op) \ + ((!sg || !sg->mc || !sg->mc->soc->ops || \ + !sg->mc->soc->ops->op) ? \ + -EINVAL : __tegra_mc_flush_op(sg, sg->mc->soc->ops->op)) + +int tegra_mc_flush (struct tegra_mc_swgroup *sg) +{ +return tegra_mc_flush_op (sg, flush); +} +EXPORT_SYMBOL (tegra_mc_flush); + +int tegra_mc_flush_done (struct tegra_mc_swgroup *sg) +{ +return tegra_mc_flush_op (sg, flush_done); +} +EXPORT_SYMBOL (tegra_mc_flush_done); + +static int tegra_mc_build_swgroup (struct tegra_mc *mc) +{ +int i; + +for (i =0 ; i < mc->soc->num_clients; i++) { +struct tegra_mc_swgroup *sg; + + sg =tegra_mc_get_swgroup (mc, mc->soc->clients[i].swgroup); + +if (!sg) { + sg =tegra_mc_add_swgroup (mc, + mc->soc->clients[i].swgroup); +if (IS_ERR (sg)) +return PTR_ERR (sg); + } + +list_add_tail (&mc->soc->clients[i].head, &sg->clients); + } + +return 0 ; +} +static int tegra_mc_setup_latency_allowance (struct tegra_mc *mc) {unsigned long long tick;
@@ -229,6 +342,13 @@ static int tegra_mc_probe(struct platform_device *pdev)/* length of MC tick in nanoseconds */ mc->tick =30 ; +INIT_LIST_HEAD (&mc->swgroups); + err =tegra_mc_build_swgroup (mc); +if (err) { +dev_err (&pdev->dev,"failed to build swgroup: %d\n" , err); +return err; + } + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); mc->regs =devm_ioremap_resource (&pdev->dev, res);if (IS_ERR (mc->regs))
@@ -271,6 +391,8 @@ static int tegra_mc_probe(struct platform_device *pdev)return err; } +mutex_init (&mc->lock); + value =MC_INT_DECERR_MTS |MC_INT_SECERR_SEC |MC_INT_DECERR_VPR |MC_INT_INVALID_APB_ASID_UPDATE |MC_INT_INVALID_SMMU_PAGE | MC_INT_ARBITRATION_EMEM | MC_INT_SECURITY_VIOLATION |
drivers/memory/tegra/tegra114.c +1 -1
@@ -15,7 +15,7 @@#include "mc.h" -static const struct tegra_mc_client tegra114_mc_clients[] = { +static struct tegra_mc_client tegra114_mc_clients[] = { { .id =0x00 , .name ="ptcr" ,
drivers/memory/tegra/tegra124.c +1 -1
@@ -15,7 +15,7 @@#include "mc.h" -static const struct tegra_mc_client tegra124_mc_clients[] = { +static struct tegra_mc_client tegra124_mc_clients[] = { { .id =0x00 , .name ="ptcr" ,
drivers/memory/tegra/tegra30.c +1 -1
@@ -15,7 +15,7 @@#include "mc.h" -static const struct tegra_mc_client tegra30_mc_clients[] = { +static struct tegra_mc_client tegra30_mc_clients[] = { { .id =0x00 , .name ="ptcr" ,
include/soc/tegra/mc.h +44 -2
72 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 3/17 memory: tegra: add flush operation for Tegra30 memory clients
In reply to Vince HsuThis patch adds the hot reset register table and flush related callback functions for Tegra30.
--- drivers/memory/tegra/tegra30.c | 78 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+)
drivers/memory/tegra/tegra30.c +78 -0
@@ -6,6 +6,8 @@* published by the Free Software Foundation. */ +#include <linux/delay.h> +#include <linux/device.h> #include <linux/of.h> #include <linux/mm.h>
@@ -936,6 +938,79 @@ static const struct tegra_smmu_swgroup tegra30_swgroups[] = { { .swgroup = TEGRA_SWGROUP_ISP, .reg = 0x258 }, }; +static struct tegra_mc_hotreset tegra30_mc_hotreset[] = { + {TEGRA_SWGROUP_AFI ,0x200 ,0x204 ,0 }, + {TEGRA_SWGROUP_AVPC ,0x200 ,0x204 ,1 }, + {TEGRA_SWGROUP_DC ,0x200 ,0x204 ,2 }, + {TEGRA_SWGROUP_DCB ,0x200 ,0x204 ,3 }, + {TEGRA_SWGROUP_EPP ,0x200 ,0x204 ,4 }, + {TEGRA_SWGROUP_G2 ,0x200 ,0x204 ,5 }, + {TEGRA_SWGROUP_HC ,0x200 ,0x204 ,6 }, + {TEGRA_SWGROUP_HDA ,0x200 ,0x204 ,7 }, + {TEGRA_SWGROUP_ISP ,0x200 ,0x204 ,8 }, + {TEGRA_SWGROUP_MPCORE ,0x200 ,0x204 ,9 }, + {TEGRA_SWGROUP_MPCORELP ,0x200 ,0x204 ,10 }, + {TEGRA_SWGROUP_MPE ,0x200 ,0x204 ,11 }, + {TEGRA_SWGROUP_NV ,0x200 ,0x204 ,12 }, + {TEGRA_SWGROUP_NV2 ,0x200 ,0x204 ,13 }, + {TEGRA_SWGROUP_PPCS ,0x200 ,0x204 ,14 }, + {TEGRA_SWGROUP_VDE ,0x200 ,0x204 ,16 }, + {TEGRA_SWGROUP_VI ,0x200 ,0x204 ,17 }, +}; + +static int tegra30_mc_flush (struct tegra_mc *mc, +const struct tegra_mc_hotreset *hotreset) +{ +u32 val; + +if (!mc || !hotreset) +return -EINVAL ; + +mutex_lock (&mc->lock); + + val =mc_readl (mc, hotreset->ctrl); + val |=BIT (hotreset->bit); +mc_writel (mc, val, hotreset->ctrl); +mc_readl (mc, hotreset->ctrl); + +mutex_unlock (&mc->lock); + +/* poll till the flush is done */ +do { +udelay (10 ); + val =mc_readl (mc, hotreset->status); + }while (!(val &BIT (hotreset->bit))); + +dev_dbg (mc->dev,"%s bit %d\n" , __func__, hotreset->bit); +return 0 ; +} + +static int tegra30_mc_flush_done (struct tegra_mc *mc, +const struct tegra_mc_hotreset *hotreset) +{ +u32 val; + +if (!mc || !hotreset) +return -EINVAL ; + +mutex_lock (&mc->lock); + + val =mc_readl (mc, hotreset->ctrl); + val &= ~BIT (hotreset->bit); +mc_writel (mc, val, hotreset->ctrl); +mc_readl (mc, hotreset->ctrl); + +mutex_unlock (&mc->lock); + +dev_dbg (mc->dev,"%s bit %d\n" , __func__, hotreset->bit); +return 0 ; +} + +static const struct tegra_mc_ops tegra30_mc_ops = { + .flush = tegra30_mc_flush, + .flush_done = tegra30_mc_flush_done, +}; +static void tegra30_flush_dcache (struct page *page,unsigned long offset,size_t size) {
@@ -967,4 +1042,7 @@ const struct tegra_mc_soc tegra30_mc_soc = { .num_address_bits = 32, .atom_size = 16, .smmu = &tegra30_smmu_soc, + .hotresets = tegra30_mc_hotreset, + .num_hotresets = ARRAY_SIZE(tegra30_mc_hotreset), + .ops = &tegra30_mc_ops, };
Signature · 1 line
2.1.4
PATCH v2 4/17 memory: tegra: add flush operation for Tegra114 memory clients
In reply to Vince HsuThis patch adds the hot reset register table and flush related callback functions for Tegra114.
--- drivers/memory/tegra/mc.h | 5 ++ drivers/memory/tegra/tegra114.c | 104 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+)
drivers/memory/tegra/mc.h +5 -0
@@ -25,6 +25,11 @@ static inline void mc_writel(struct tegra_mc *mc, u32 value,writel (value, mc->regs + offset); } +int tegra114_mc_flush (struct tegra_mc *mc, +const struct tegra_mc_hotreset *hotreset); +int tegra114_mc_flush_done (struct tegra_mc *mc, +const struct tegra_mc_hotreset *hotreset); +#ifdef CONFIG_ARCH_TEGRA_3x_SOCextern const struct tegra_mc_soc tegra30_mc_soc;#endif
drivers/memory/tegra/tegra114.c +104 -0
120 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 5/17 memory: tegra: add flush operation for Tegra124 memory clients
In reply to Vince HsuThis patch adds the hot reset register table and flush related callback functions for Tegra124.
---
v2: move the drop of tegra124_mc_clients' const to patch #2
move mc flush operations to tegra114
drivers/memory/tegra/tegra124.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
drivers/memory/tegra/tegra124.c +36 -0
@@ -959,7 +959,40 @@ static const struct tegra_smmu_swgroup tegra124_swgroups[] = { { .swgroup = TEGRA_SWGROUP_VI, .reg = 0x280 }, }; +static struct tegra_mc_hotreset tegra124_mc_hotreset[] = { + {TEGRA_SWGROUP_AFI, 0x200, 0x204, 0}, + {TEGRA_SWGROUP_AVPC, 0x200, 0x204, 1}, + {TEGRA_SWGROUP_DC, 0x200, 0x204, 2}, + {TEGRA_SWGROUP_DCB, 0x200, 0x204, 3}, + {TEGRA_SWGROUP_HC, 0x200, 0x204, 6}, + {TEGRA_SWGROUP_HDA, 0x200, 0x204, 7}, + {TEGRA_SWGROUP_ISP2, 0x200, 0x204, 8}, + {TEGRA_SWGROUP_MPCORE, 0x200, 0x204, 9}, + {TEGRA_SWGROUP_MPCORELP, 0x200, 0x204, 10}, + {TEGRA_SWGROUP_MSENC, 0x200, 0x204, 11}, + {TEGRA_SWGROUP_PPCS, 0x200, 0x204, 14}, + {TEGRA_SWGROUP_SATA, 0x200, 0x204, 15}, + {TEGRA_SWGROUP_VDE, 0x200, 0x204, 16}, + {TEGRA_SWGROUP_VI, 0x200, 0x204, 17}, + {TEGRA_SWGROUP_VIC, 0x200, 0x204, 18}, + {TEGRA_SWGROUP_XUSB_HOST, 0x200, 0x204, 19}, + {TEGRA_SWGROUP_XUSB_DEV, 0x200, 0x204, 20}, + {TEGRA_SWGROUP_TSEC, 0x200, 0x204, 22}, + {TEGRA_SWGROUP_SDMMC1A, 0x200, 0x204, 29}, + {TEGRA_SWGROUP_SDMMC2A, 0x200, 0x204, 30}, + {TEGRA_SWGROUP_SDMMC3A, 0x200, 0x204, 31}, + {TEGRA_SWGROUP_SDMMC4A, 0x970, 0x974, 0}, + {TEGRA_SWGROUP_ISP2B, 0x970, 0x974, 1}, + {TEGRA_SWGROUP_GPU, 0x970, 0x974, 2}, +}; + #ifdef CONFIG_ARCH_TEGRA_124_SOC + +static const struct tegra_mc_ops tegra124_mc_ops = { + .flush = tegra114_mc_flush, + .flush_done = tegra114_mc_flush_done, +}; + static void tegra124_flush_dcache(struct page *page, unsigned long offset, size_t size) {
@@ -991,5 +1024,8 @@ const struct tegra_mc_soc tegra124_mc_soc = { .num_address_bits = 34, .atom_size = 32, .smmu = &tegra124_smmu_soc, + .hotresets = tegra124_mc_hotreset, + .num_hotresets = ARRAY_SIZE(tegra124_mc_hotreset), + .ops = &tegra124_mc_ops, };#endif /* CONFIG_ARCH_TEGRA_124_SOC */
Signature · 1 line
2.1.4
PATCH v2 6/17 clk: tegra: remove TEGRA_PLL_USE_LOCK for PLLD/PLLD2
In reply to Vince HsuTegra114 has a HW bug that the PLLD/PLLD2 lock bit cannot be asserted when the DIS power domain is during up-powergating process but the clamp to this domain is not removed yet. That causes a timeout and aborts the power sequence, although the PLLD/PLLD2 has already locked. To remove the false alarm, we don't use the lock for PLLD/PLLD2. Just wait 1ms and treat the clocks as locked.
--- drivers/clk/tegra/clk-tegra114.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/clk/tegra/clk-tegra114.c +2 -4
@@ -456,8 +456,7 @@ static struct tegra_clk_pll_params pll_d_params = { .lock_delay = 1000, .div_nmp = &pllp_nmp, .freq_table = pll_d_freq_table, - .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON | - TEGRA_PLL_USE_LOCK, + .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON, };static struct tegra_clk_pll_params pll_d2_params = {
@@ -474,8 +473,7 @@ static struct tegra_clk_pll_params pll_d2_params = { .lock_delay = 1000, .div_nmp = &pllp_nmp, .freq_table = pll_d_freq_table, - .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON | - TEGRA_PLL_USE_LOCK, + .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON, };static struct pdiv_map pllu_p[] = {
Signature · 1 line
2.1.4
PATCH v2 7/17 soc: tegra: pmc: Add generic PM domain support
In reply to Vince HsuFrom: Thierry Reding <[email protected]>
The PM domains are populated from DT, and the PM domain consumer devices are also bound to their relevant PM domains by DT.
---
v2: revise comment in tegra_powergate_remove_clamping()
address Alex's comments
drivers/soc/tegra/pmc.c | 589 +++++++++++++++++++++++++++- include/dt-bindings/power/tegra-powergate.h | 30 ++ 2 files changed, 617 insertions(+), 2 deletions(-) create mode 100644 include/dt-bindings/power/tegra-powergate.h
drivers/soc/tegra/pmc.c +587 -2
@@ -27,15 +27,20 @@#include <linux/init.h> #include <linux/io.h> #include <linux/of.h> +#include <linux/of_platform.h> #include <linux/of_address.h> #include <linux/platform_device.h> +#include <linux/pm_domain.h> #include <linux/reboot.h> +#include <linux/regulator/consumer.h> #include <linux/reset.h> +#include <linux/sched.h> #include <linux/seq_file.h> #include <linux/spinlock.h> #include <soc/tegra/common.h> #include <soc/tegra/fuse.h> +#include <soc/tegra/mc.h> #include <soc/tegra/pmc.h> #define PMC_CNTRL 0x0
@@ -99,6 +104,30 @@#define GPU_RG_CNTRL 0x2d4 +#define MAX_CLK_NUM 5 +#define MAX_RESET_NUM 5 +#define MAX_SWGROUP_NUM 5 + +struct tegra_powergate { +struct generic_pm_domain base; +struct tegra_pmc *pmc; +unsigned int id; +const char *name; +struct list_head head; +struct device_node *of_node; +struct clk *clk[MAX_CLK_NUM ]; +struct reset_control *reset[MAX_RESET_NUM ]; +struct tegra_mc_swgroup *swgroup[MAX_SWGROUP_NUM ]; +bool is_vdd; +struct regulator *vdd; +}; + +static inline struct tegra_powergate * +to_powergate (struct generic_pm_domain *domain) +{ + return container_of(domain, struct tegra_powergate, base); +} +struct tegra_pmc_soc {unsigned int num_powergates;const char *const *powergates;
@@ -107,12 +136,15 @@ struct tegra_pmc_soc {bool has_tsense_reset;bool has_gpu_clamps; +bool is_legacy_powergate; };/** * struct tegra_pmc - NVIDIA Tegra PMC +* @dev: pointer to parent device * @base: pointer to I/O remapped register region * @clk: pointer to pclk clock +* @soc: SoC-specific data * @rate: currently configured rate of pclk * @suspend_mode: lowest suspend mode available * @cpu_good_time: CPU power good time (in microseconds)
@@ -126,7 +158,9 @@ struct tegra_pmc_soc {* @cpu_pwr_good_en: CPU power good signal is enabled * @lp0_vec_phys: physical base address of the LP0 warm boot code * @lp0_vec_size: size of the LP0 warm boot code +* @powergates: list of power gates * @powergates_lock: mutex for power gate register access +* @nb: bus notifier for generic power domains */ struct tegra_pmc {struct device *dev;
@@ -150,7 +184,12 @@ struct tegra_pmc {u32 lp0_vec_phys;u32 lp0_vec_size; +struct tegra_powergate *powergates;struct mutex powergates_lock; +struct notifier_block nb; + +struct list_head powergate_list; +int power_domain_num; };static struct tegra_pmc *pmc = &(struct tegra_pmc ) {
@@ -236,6 +275,8 @@ int tegra_powergate_is_powered(int id)/** * tegra_powergate_remove_clamping() - remove power clamps for partition * @id: partition ID +* +* TODO: make this function static once we get rid of all outside callers */ int tegra_powergate_remove_clamping (int id) {
@@ -256,8 +297,8 @@ int tegra_powergate_remove_clamping(int id) }/* -* Tegra 2 has a bug where PCIE and VDE clamping masks are -* swapped relatively to the partition ids +* PCIE and VDE clamping bits are swapped relatively to the partition +* ids */ if (id ==TEGRA_POWERGATE_VDEC ) mask = (1 <<TEGRA_POWERGATE_PCIE );
@@ -373,6 +414,8 @@ int tegra_pmc_cpu_remove_clamping(int cpuid)if (id <0 )return id; +usleep_range (10 ,20 ); + return tegra_powergate_remove_clamping(id); }#endif /* CONFIG_SMP */
@@ -407,6 +450,307 @@ void tegra_pmc_restart(enum reboot_mode mode, const char *cmd)tegra_pmc_writel (value,0 ); } +static bool tegra_pmc_powergate_is_powered (struct tegra_powergate *powergate) +{ +u32 status =tegra_pmc_readl (PWRGATE_STATUS ); + +if (!powergate->is_vdd) +return (status &BIT (powergate->id)) !=0 ; + +if (IS_ERR (powergate->vdd)) +return false; +else +return regulator_is_enabled (powergate->vdd); +} + +static int tegra_pmc_powergate_set (struct tegra_powergate *powergate, +bool new_state) +{ +u32 status, mask = new_state ?BIT (powergate->id) :0 ; +bool state = false; +unsigned long timeout; +int err = -ETIMEDOUT ; + + +mutex_lock (&pmc->powergates_lock); + +/* check the current state of the partition */ + status =tegra_pmc_readl (PWRGATE_STATUS ); + state = !!(status &BIT (powergate->id)); + +/* nothing to do */ +if (new_state == state) { +mutex_unlock (&pmc->powergates_lock); +return 0 ; + } + +/* toggle partition state and wait for state change to finish */ +tegra_pmc_writel (PWRGATE_TOGGLE_START | powergate->id,PWRGATE_TOGGLE ); + + timeout = jiffies +msecs_to_jiffies (50 ); +while (time_before (jiffies, timeout)) { + status =tegra_pmc_readl (PWRGATE_STATUS ); +if ((status &BIT (powergate->id)) == mask) { + err =0 ; +break ; + } + +usleep_range (10 ,20 ); + } + +mutex_unlock (&pmc->powergates_lock); + +return err; +} + +static int tegra_pmc_powergate_enable_clocks ( +struct tegra_powergate *powergate) +{ +int i, err; + +for (i =0 ; i <MAX_CLK_NUM ; i++) { +if (!powergate->clk[i]) +break ; + + err =clk_prepare_enable (powergate->clk[i]); +if (err) + goto out; + } + +return 0 ; + +out: +while (i--) +clk_disable_unprepare (powergate->clk[i]); +return err; +} + +static void tegra_pmc_powergate_disable_clocks ( +struct tegra_powergate *powergate) +{ +int i; + +for (i =0 ; i <MAX_CLK_NUM ; i++) { +if (!powergate->clk[i]) +break ; + +clk_disable_unprepare (powergate->clk[i]); + } +} + +static int tegra_pmc_powergate_mc_flush (struct tegra_powergate *powergate) +{ +int i, err; + +for (i =0 ; i <MAX_SWGROUP_NUM ; i++) { +if (!powergate->swgroup[i]) +break ; + + err =tegra_mc_flush (powergate->swgroup[i]); +if (err) +return err; + } + +return 0 ; +} + +static int tegra_pmc_powergate_mc_flush_done (struct tegra_powergate *powergate) +{ +int i, err; + +for (i =0 ; i <MAX_SWGROUP_NUM ; i++) { +if (!powergate->swgroup[i]) +break ; + + err =tegra_mc_flush_done (powergate->swgroup[i]); +if (err) +return err; + } + +return 0 ; + +} + +static int tegra_pmc_powergate_reset_assert ( +struct tegra_powergate *powergate) +{ +int i, err; + +for (i =0 ; i <MAX_RESET_NUM ; i++) { +if (!powergate->reset[i]) +break ; + + err =reset_control_assert (powergate->reset[i]); +if (err) +return err; + } + +return 0 ; +} + +static int tegra_pmc_powergate_reset_deassert ( +struct tegra_powergate *powergate) +{ +int i, err; + +for (i =0 ; i <MAX_RESET_NUM ; i++) { +if (!powergate->reset[i]) +break ; + + err =reset_control_deassert (powergate->reset[i]); +if (err) +return err; + } + +return 0 ; +} + +static int tegra_powergate_get_regulator (struct tegra_powergate *powergate) +{ +struct platform_device *pdev; + +if (!powergate->is_vdd) +return -EINVAL ; + +if (powergate->vdd && !IS_ERR (powergate->vdd)) +return 0 ; + + pdev =of_find_device_by_node (powergate->of_node); +if (!pdev) +return -EINVAL ; + + powergate->vdd =devm_regulator_get_optional (&pdev->dev,"vdd" ); +if (IS_ERR (powergate->vdd)) +return -EINVAL ; + +return 0 ; +} + +static int tegra_pmc_powergate_power_on (struct generic_pm_domain *domain) +{ +struct tegra_powergate *powergate =to_powergate (domain); +struct tegra_pmc *pmc = powergate->pmc; +int err; + +dev_dbg (pmc->dev,"> %s(domain=%p)\n" , __func__, domain); +dev_dbg (pmc->dev," name: %s\n" , domain->name); + +if (powergate->is_vdd) { + err =tegra_powergate_get_regulator (powergate); +if (!err) + err =regulator_enable (powergate->vdd); + }else { + err =tegra_pmc_powergate_set (powergate, true); + } +if (err <0 ) + goto out; +udelay (10 ); + +if (pmc->soc->is_legacy_powergate) { + err =tegra_pmc_powergate_reset_assert (powergate); +if (err) + goto out; +udelay (10 ); + } + +/* +* Some PCIe PLLs depend on external power supplies, and the power +* supplies are enabled in driver. So we don't touch PCIe clocks +* here. Refer to: +* Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt +*/ +if (powergate->id !=TEGRA_POWERGATE_PCIE ) { + err =tegra_pmc_powergate_enable_clocks (powergate); +if (err) + goto out; +udelay (10 ); + } + + err =tegra_powergate_remove_clamping (powergate->id); +if (err) + goto out; +udelay (10 ); + + err =tegra_pmc_powergate_reset_deassert (powergate); +if (err) + goto out; +udelay (10 ); + + err =tegra_pmc_powergate_mc_flush_done (powergate); +if (err) + goto out; +udelay (10 ); + +if (powergate->id !=TEGRA_POWERGATE_PCIE ) +tegra_pmc_powergate_disable_clocks (powergate); + +return 0 ; + +out: +dev_dbg (pmc->dev,"< %s() = %d\n" , __func__, err); +return err; +} + +static int tegra_pmc_powergate_power_off (struct generic_pm_domain *domain) +{ +struct tegra_powergate *powergate =to_powergate (domain); +struct tegra_pmc *pmc = powergate->pmc; +int err; + +dev_dbg (pmc->dev,"> %s(domain=%p)\n" , __func__, domain); +dev_dbg (pmc->dev," name: %s\n" , domain->name); + +/* never turn off these partitions */ +switch (powergate->id) { +case TEGRA_POWERGATE_CPU : +case TEGRA_POWERGATE_CPU1 : +case TEGRA_POWERGATE_CPU2 : +case TEGRA_POWERGATE_CPU3 : +case TEGRA_POWERGATE_CPU0 : +case TEGRA_POWERGATE_C0NC : +case TEGRA_POWERGATE_IRAM : +dev_dbg (pmc->dev,"not disabling always-on partition %s\n" , + domain->name); + err = -EINVAL ; + goto out; + } + +if (!pmc->soc->is_legacy_powergate) { + err =tegra_pmc_powergate_enable_clocks (powergate); +if (err) + goto out; +udelay (10 ); + + err =tegra_pmc_powergate_mc_flush (powergate); +if (err) + goto out; +udelay (10 ); + } + + err =tegra_pmc_powergate_reset_assert (powergate); +if (err) + goto out; +udelay (10 ); + +if (!pmc->soc->is_legacy_powergate) { +tegra_pmc_powergate_disable_clocks (powergate); +udelay (10 ); + } + +if (powergate->vdd) + err =regulator_disable (powergate->vdd); +else + err =tegra_pmc_powergate_set (powergate, false); +if (err) + goto out; + +return 0 ; + +out: +dev_dbg (pmc->dev,"< %s() = %d\n" , __func__, err); +return err; +} +static int powergate_show (struct seq_file *s,void *data) {unsigned int i;
@@ -449,6 +793,234 @@ static int tegra_powergate_debugfs_init(void)return 0 ; } +static struct generic_pm_domain * +tegra_powergate_of_xlate (struct of_phandle_args *args,void *data) +{ +struct tegra_pmc *pmc = data; +struct tegra_powergate *powergate; + +dev_dbg (pmc->dev,"> %s(args=%p, data=%p)\n" , __func__, args, data); + +list_for_each_entry (powergate, &pmc->powergate_list, head) { +if (!powergate->base.name) +continue ; + +if (powergate->id == args->args[0 ]) { +dev_dbg (pmc->dev,"< %s() = %p\n" , __func__, powergate); +return &powergate->base; + } + } + +dev_dbg (pmc->dev,"< %s() = -ENOENT\n" , __func__); +return ERR_PTR (-ENOENT ); +} + +static int tegra_powergate_of_get_clks (struct tegra_powergate *powergate) +{ +struct clk *clk; +int i, err; + +for (i =0 ; i <MAX_CLK_NUM ; i++) { + clk =of_clk_get (powergate->of_node, i); +if (IS_ERR (clk)) { +if (PTR_ERR (clk) == -ENOENT ) +break ; +else + goto err_clks; + } + + powergate->clk[i] = clk; + } + +return 0 ; + +err_clks: + err =PTR_ERR (clk); +while (--i >=0 ) +clk_put (powergate->clk[i]); +return err; +} + +static int tegra_powergate_of_get_resets (struct tegra_powergate *powergate) +{ +struct reset_control *reset; +int i; + +for (i =0 ; i <MAX_RESET_NUM ; i++) { + reset =of_reset_control_get_by_index (powergate->of_node, i); +if (IS_ERR (reset)) { +if (PTR_ERR (reset) == -ENOENT ) +break ; +else +return PTR_ERR (reset); + } + + powergate->reset[i] = reset; + } + +return 0 ; +} + +static int tegra_powergate_of_get_swgroups (struct tegra_powergate *powergate) +{ +struct tegra_mc_swgroup *sg; +int i; + +for (i =0 ; i <MAX_SWGROUP_NUM ; i++) { + sg =tegra_mc_find_swgroup (powergate->of_node, i); +if (IS_ERR_OR_NULL (sg)) { +if (PTR_ERR (sg) == -ENOENT ) +break ; +else +return -EINVAL ; + } + + powergate->swgroup[i] = sg; + } + +return 0 ; +} + +static int tegra_pmc_powergate_init_powerdomain (struct tegra_pmc *pmc) +{ +struct device_node *np; + +for_each_compatible_node (np,NULL ,"nvidia,power-domains" ) { +struct tegra_powergate *powergate; +const char *name; +int err; +u32 id; +bool off; + + err =of_property_read_string (np,"name" , &name); +if (err) { +dev_err (pmc->dev,"no significant name for domain\n" ); +return err; + } + + err =of_property_read_u32 (np,"domain" , &id); +if (err) { +dev_err (pmc->dev,"no powergate ID for domain\n" ); +return err; + } + + powergate =devm_kzalloc (pmc->dev,sizeof (*powergate), +GFP_KERNEL ); +if (!powergate) { +dev_err (pmc->dev,"failed to allocate memory for domain %s\n" , + name); +return -ENOMEM ; + } + +if (of_property_read_bool (np,"external-power-rail" )) { + powergate->is_vdd = true; + err =tegra_powergate_get_regulator (powergate); +if (err) { +/* +* The regulator might not be ready yet, so just +* give a warning instead of failing the whole +* init. +*/ +dev_warn (pmc->dev,"couldn't locate regulator\n" ); + } + } + + powergate->of_node = np; + powergate->name = name; + powergate->id = id; + powergate->base.name =kstrdup (powergate->name,GFP_KERNEL ); + powergate->base.power_off = tegra_pmc_powergate_power_off; + powergate->base.power_on = tegra_pmc_powergate_power_on; + powergate->pmc = pmc; + + err =tegra_powergate_of_get_clks (powergate); +if (err) +return err; + + err =tegra_powergate_of_get_resets (powergate); +if (err) +return err; + + err =tegra_powergate_of_get_swgroups (powergate); +if (err) +return err; + +list_add_tail (&powergate->head, &pmc->powergate_list); + +if ((powergate->is_vdd && !IS_ERR (powergate->vdd)) || + !powergate->is_vdd) +tegra_pmc_powergate_power_off (&powergate->base); + + off = !tegra_pmc_powergate_is_powered (powergate); +pm_genpd_init (&powergate->base,NULL , off); + + pmc->power_domain_num++; + +dev_info (pmc->dev,"added power domain %s\n" , powergate->name); + } + +dev_info (pmc->dev,"%d power domains added\n" , pmc->power_domain_num); +return 0 ; +} + +static int tegra_pmc_powergate_init_subdomain (struct tegra_pmc *pmc) +{ +struct tegra_powergate *powergate; + +list_for_each_entry (powergate, &pmc->powergate_list, head) { +struct device_node *pdn; +struct tegra_powergate *parent =NULL ; +struct tegra_powergate *temp; +int err; + + pdn =of_parse_phandle (powergate->of_node,"depend-on" ,0 ); +if (!pdn) +continue ; + +list_for_each_entry (temp, &pmc->powergate_list, head) { +if (temp->of_node == pdn) { + parent = temp; +break ; + } + } + +if (!parent) +return -EINVAL ; + + err =pm_genpd_add_subdomain_names (parent->name, + powergate->name); +if (err) +return err; + } + +return 0 ; +} + +static int tegra_powergate_init (struct tegra_pmc *pmc) +{ +struct device_node *np = pmc->dev->of_node; +int err =0 ; + +dev_dbg (pmc->dev,"> %s(pmc=%p)\n" , __func__, pmc); + +INIT_LIST_HEAD (&pmc->powergate_list); + err =tegra_pmc_powergate_init_powerdomain (pmc); +if (err) + goto out; + + err =tegra_pmc_powergate_init_subdomain (pmc); +if (err <0 ) +return err; + + err =__of_genpd_add_provider (np, tegra_powergate_of_xlate, pmc); +if (err <0 ) +return err; + +out: +dev_dbg (pmc->dev,"< %s() = %d\n" , __func__, err); +return err; +} +static int tegra_io_rail_prepare (int id,unsigned long *request,unsigned long *status,unsigned int *bit) {
@@ -806,6 +1378,8 @@ static int tegra_pmc_probe(struct platform_device *pdev)struct resource *res;int err; +dev_dbg (&pdev->dev,"> %s(pdev=%p)\n" , __func__, pdev); + err =tegra_pmc_parse_dt (pmc, pdev->dev.of_node);if (err <0 )return err;
@@ -831,12 +1405,19 @@ static int tegra_pmc_probe(struct platform_device *pdev)tegra_pmc_init_tsense_reset (pmc); +if (IS_ENABLED (CONFIG_PM_GENERIC_DOMAINS )) { + err =tegra_powergate_init (pmc); +if (err <0 ) +return err; + } +if (IS_ENABLED (CONFIG_DEBUG_FS )) { err =tegra_powergate_debugfs_init ();if (err <0 )return err; } +dev_dbg (&pdev->dev,"< %s()\n" , __func__);return 0 ; }
@@ -876,6 +1457,7 @@ static const struct tegra_pmc_soc tegra20_pmc_soc = { .cpu_powergates = NULL, .has_tsense_reset = false, .has_gpu_clamps = false, + .is_legacy_powergate = true, };static const char *const tegra30_powergates[] = {
@@ -909,6 +1491,7 @@ static const struct tegra_pmc_soc tegra30_pmc_soc = { .cpu_powergates = tegra30_cpu_powergates, .has_tsense_reset = true, .has_gpu_clamps = false, + .is_legacy_powergate = true, };static const char *const tegra114_powergates[] = {
@@ -946,6 +1529,7 @@ static const struct tegra_pmc_soc tegra114_pmc_soc = { .cpu_powergates = tegra114_cpu_powergates, .has_tsense_reset = true, .has_gpu_clamps = false, + .is_legacy_powergate = false, };static const char *const tegra124_powergates[] = {
@@ -989,6 +1573,7 @@ static const struct tegra_pmc_soc tegra124_pmc_soc = { .cpu_powergates = tegra124_cpu_powergates, .has_tsense_reset = true, .has_gpu_clamps = true, + .is_legacy_powergate = false, };static const struct of_device_id tegra_pmc_match[] = {
include/dt-bindings/power/tegra-powergate.h new file +30 -0
@@ -0,0 +1,30 @@ +#ifndef _DT_BINDINGS_POWER_TEGRA_POWERGATE_H +#define _DT_BINDINGS_POWER_TEGRA_POWERGATE_H + +#define TEGRA_POWERGATE_CPU 0 +#define TEGRA_POWERGATE_3D 1 +#define TEGRA_POWERGATE_VENC 2 +#define TEGRA_POWERGATE_PCIE 3 +#define TEGRA_POWERGATE_VDEC 4 +#define TEGRA_POWERGATE_L2 5 +#define TEGRA_POWERGATE_MPE 6 +#define TEGRA_POWERGATE_HEG 7 +#define TEGRA_POWERGATE_SATA 8 +#define TEGRA_POWERGATE_CPU1 9 +#define TEGRA_POWERGATE_CPU2 10 +#define TEGRA_POWERGATE_CPU3 11 +#define TEGRA_POWERGATE_CELP 12 +#define TEGRA_POWERGATE_3D1 13 +#define TEGRA_POWERGATE_CPU0 14 +#define TEGRA_POWERGATE_C0NC 15 +#define TEGRA_POWERGATE_C1NC 16 +#define TEGRA_POWERGATE_SOR 17 +#define TEGRA_POWERGATE_DIS 18 +#define TEGRA_POWERGATE_DISB 19 +#define TEGRA_POWERGATE_XUSBA 20 +#define TEGRA_POWERGATE_XUSBB 21 +#define TEGRA_POWERGATE_XUSBC 22 +#define TEGRA_POWERGATE_VIC 23 +#define TEGRA_POWERGATE_IRAM 24 + +#endif
Signature · 1 line
2.1.4
Re: [PATCH v2 07/17] soc: tegra: pmc: Add generic PM domain support
Hi Vince,
Quoted 11 lines · Vince Hsu
From: Thierry Reding <[email protected]>
The PM domains are populated from DT, and the PM domain consumer devices are also bound to their relevant PM domains by DT.
Signed-off-by Thierry Reding <[email protected]>[vinceh: make changes based on Thierry and Peter's suggestions]Signed-off-by Vince Hsu <[email protected]>---
v2: revise comment integra_powergate_remove_clamping()
address Alex's comments
Sorry for the late review..., somehow I just noticed this while reviewing some other PM domain support.
It's nice to see this migrating to PM domains. Some comments below...
[...]
Quoted 20 lines
/**
* structtegra_pmc- NVIDIA Tegra PMC
+ * @dev: pointer to parent device
* @base: pointer to I/O remapped register region
* @clk: pointer to pclk clock
+ * @soc: SoC-specific data
* @rate: currently configured rate of pclk
* @suspend_mode: lowest suspend mode available
* @cpu_good_time: CPU power good time (in microseconds)drivers/soc/tegra/pmc.c +2
-0@@ -126,7 +158,9 @@ struct tegra_pmc_soc {* @cpu_pwr_good_en: CPU power good signal is enabled * @lp0_vec_phys: physical base address of the LP0 warm boot code * @lp0_vec_size: size of the LP0 warm boot code +* @powergates: list of power gates * @powergates_lock: mutex for power gate register access +* @nb: bus notifier for generic power domains */ struct tegra_pmc {struct device *dev;
drivers/soc/tegra/pmc.c struct tegra_pmc { · line 189
Quoted 6 lines
drivers/soc/tegra/pmc.c +2
-0@@ -150,7 +184,12 @@ struct tegra_pmc {u32 lp0_vec_phys;u32 lp0_vec_size; +struct tegra_powergate *powergates;struct mutex powergates_lock; +struct notifier_block nb;
I don't see these notifiers used anywhere in this series. What is the
intended use here? There have been some other discussions about how to
do this more generically for PM domains[1], so I'd prefer not to see this in SoC specific PM domains. In this case, it appears unused, so should be fine to drop (for now.)
[...]
Quoted 13 lines
drivers/soc/tegra/pmc.c +13
-0+static int tegra_pmc_powergate_power_off (struct generic_pm_domain *domain) +{ +struct tegra_powergate *powergate =to_powergate (domain); +struct tegra_pmc *pmc = powergate->pmc; +int err; + +dev_dbg (pmc->dev,"> %s(domain=%p)\n" , __func__, domain); +dev_dbg (pmc->dev," name: %s\n" , domain->name); + +/* never turn off these partitions */ +switch (powergate->id) { +case TEGRA_POWERGATE_CPU : +case TEGRA_POWERGATE_CPU1 :
drivers/soc/tegra/pmc.c void tegra_pmc_restart(enum reboot_mode mode, const char *cmd) · line 716
Quoted 10 lines
drivers/soc/tegra/pmc.c +10
-0+case TEGRA_POWERGATE_CPU2 : +case TEGRA_POWERGATE_CPU3 : +case TEGRA_POWERGATE_CPU0 : +case TEGRA_POWERGATE_C0NC : +case TEGRA_POWERGATE_IRAM : +dev_dbg (pmc->dev,"not disabling always-on partition %s\n" , + domain->name); + err = -EINVAL ; + goto out; + }
You're re-inventing the per-device QoS flag: PM_QOS_FLAG_NO_POWER_OFF which could be used here to prevent ->power_off from ever being called.
Alternately, if this really a static configuraion, why even register the ->power_off hook for these domains in the first place?
[...]
drivers/soc/tegra/pmc.c static int tegra_powergate_debugfs_init(void) · line 978
Quoted 13 lines
drivers/soc/tegra/pmc.c +13
-0+static int tegra_pmc_powergate_init_subdomain (struct tegra_pmc *pmc) +{ +struct tegra_powergate *powergate; + +list_for_each_entry (powergate, &pmc->powergate_list, head) { +struct device_node *pdn; +struct tegra_powergate *parent =NULL ; +struct tegra_powergate *temp; +int err; + + pdn =of_parse_phandle (powergate->of_node,"depend-on" ,0 ); +if (!pdn) +continue ;
I'm not really following the need for the "depend-on" property here.
Looking at the example .dtsi files in this series, it seems to me what is being described is nested hardware power domains, which genpd already supports. Any reason you're not using that build-in support?
[...]
drivers/soc/tegra/pmc.c static int tegra_pmc_probe(struct platform_device *pdev) · line 1412
Quoted 9 lines
drivers/soc/tegra/pmc.c +5
-0@@ -831,12 +1405,19 @@ static int tegra_pmc_probe(struct platform_device *pdev)tegra_pmc_init_tsense_reset (pmc); +if (IS_ENABLED (CONFIG_PM_GENERIC_DOMAINS )) { + err =tegra_powergate_init (pmc); +if (err <0 ) +return err; + }
On many SoCs there's some special handling for the !CONFIG_PM case here such that all the PM domains are enabled by default in case they are not enabled by the bootloader.
drivers/soc/tegra/pmc.c static int tegra_pmc_probe(struct platform_device *pdev) · line 1422
Quoted 9 lines
drivers/soc/tegra/pmc.c +1
-0if (IS_ENABLED (CONFIG_DEBUG_FS )) { err =tegra_powergate_debugfs_init ();if (err <0 )return err; } +dev_dbg (&pdev->dev,"< %s()\n" , __func__);return 0 ; }
Kevin
[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-November/299345.html
Re: [PATCH v2 07/17] soc: tegra: pmc: Add generic PM domain support
Quoted 3 lines · Kevin Hilman
Hi Vince,
Vince Hsu <[email protected]> writes:
[...]
Quoted 27 lines
Quoted 13 lines
drivers/soc/tegra/pmc.c +13
-0+static int tegra_pmc_powergate_power_off (struct generic_pm_domain *domain) +{ +struct tegra_powergate *powergate =to_powergate (domain); +struct tegra_pmc *pmc = powergate->pmc; +int err; + +dev_dbg (pmc->dev,"> %s(domain=%p)\n" , __func__, domain); +dev_dbg (pmc->dev," name: %s\n" , domain->name); + +/* never turn off these partitions */ +switch (powergate->id) { +case TEGRA_POWERGATE_CPU : +case TEGRA_POWERGATE_CPU1 :drivers/soc/tegra/pmc.c void tegra_pmc_restart(enum reboot_mode mode, const char *cmd) · line 716
Quoted 10 lines
drivers/soc/tegra/pmc.c +10
-0+case TEGRA_POWERGATE_CPU2 : +case TEGRA_POWERGATE_CPU3 : +case TEGRA_POWERGATE_CPU0 : +case TEGRA_POWERGATE_C0NC : +case TEGRA_POWERGATE_IRAM : +dev_dbg (pmc->dev,"not disabling always-on partition %s\n" , + domain->name); + err = -EINVAL ; + goto out; + }You're re-inventing the per-device QoS flag:
PM_QOS_FLAG_NO_POWER_OFFwhich could be used here to prevent ->power_off from ever being called.
Quoted 2 lines
Alternately, if this really a static configuraion, why even register the ->power_off hook for these domains in the first place?
This isn't really a static configuration. The problem here is that there is code elsewhere to deal with these domains. The CPU power partitions for example are dealt with in the cpuidle code (or PSCI firmware). What complicates this even further is that we have an existing custom API for enabling/disabling power partitions (cpuidle uses that API).
Although, thinking about it some more, it seems that for the purposes of power domains perhaps we should just not consider these power partitions at all (i.e. not even register them).
[...]
Quoted 4 lines
Quoted 4 lines
drivers/soc/tegra/pmc.c +0
-0@@ -831,12 +1405,19 @@ static int tegra_pmc_probe(struct platform_device *pdev)tegra_pmc_init_tsense_reset (pmc);
Quoted 9 lines
drivers/soc/tegra/pmc.c static int tegra_pmc_probe(struct platform_device *pdev) · line 1412
Quoted 5 lines
drivers/soc/tegra/pmc.c +5
-0+if (IS_ENABLED (CONFIG_PM_GENERIC_DOMAINS )) { + err =tegra_powergate_init (pmc); +if (err <0 ) +return err; + }On many SoCs there's some special handling for the !CONFIG_PM case here such that all the PM domains are enabled by default in case they are not enabled by the bootloader.
Yeah, I think we'll need something like that for backwards-compatibility with the old API. Converting to power domains should be done in the same step as stubbing out the old API, and then to prevent devices using some old DTBs to fail we'd need to enable all domains that are currently controlled by existing drivers using the custom API.
So we don't only need this fallback for !PM_GENERIC_DOMAINS but also for cases where we detect a DTB that's missing the nodes to describe the domains.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150408/dc5841c0/attachment.sig>
PATCH v2 8/17 ARM: tegra: add PM domain device nodes to Tegra30 DT
In reply to Vince HsuAlso bind the PM domain provider and consumer together.
--- arch/arm/boot/dts/tegra30.dtsi | 45 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)
arch/arm/boot/dts/tegra30.dtsi +44 -1
@@ -2,6 +2,7 @@ #include <dt-bindings/gpio/tegra-gpio.h> #include <dt-bindings/memory/tegra30-mc.h> #include <dt-bindings/pinctrl/pinctrl-tegra.h> +#include <dt-bindings/power/tegra-powergate.h> #include <dt-bindings/interrupt-controller/arm-gic.h> #include "skeleton.dtsi"
@@ -36,6 +37,7 @@ 0x82000000 0 0x20000000 0x20000000 0 0x08000000 /* non-prefetchable memory */ 0xc2000000 0 0x28000000 0x28000000 0 0x18000000>; /* prefetchable memory */ + power-domains = <&pmc TEGRA_POWERGATE_PCIE>; clocks = <&tegra_car TEGRA30_CLK_PCIE>, <&tegra_car TEGRA30_CLK_AFI>, <&tegra_car TEGRA30_CLK_PLL_E>,
@@ -149,6 +151,14 @@ gr3d at 54180000 { compatible = "nvidia,tegra30-gr3d"; reg = <0x54180000 0x00040000>; + /* + * Actually the gr3d has two power domains, but the + * generic power domain doesn't support multiple + * domain provider for one device yet. So we claim + * the gr3d is powered by the domain 3D1 here, and + * let the 3D1 depend on 3D below. + */ + power-domains = <&pmc TEGRA_POWERGATE_3D1>; clocks = <&tegra_car TEGRA30_CLK_GR3D &tegra_car TEGRA30_CLK_GR3D2>; clock-names = "3d", "3d2";
@@ -613,11 +623,44 @@ status = "disabled"; }; - pmc at 7000e400 { + pmc: pmc at 7000e400 { compatible = "nvidia,tegra30-pmc"; reg = <0x7000e400 0x400>; clocks = <&tegra_car TEGRA30_CLK_PCLK>, <&clk32k_in>; clock-names = "pclk", "clk32k_in"; + #power-domain-cells = <1>; + }; + + gr3dpd: gr3d-power-domain { + compatible = "nvidia,power-domains"; + name = "gr3d-power-domain"; + domain = <TEGRA_POWERGATE_3D>; + clocks = <&tegra_car TEGRA30_CLK_GR3D>; + resets = <&tegra_car 24>; + nvidia,swgroup = <&mc TEGRA_SWGROUP_NV>; + }; + + gr3d2-power-domain { + compatible = "nvidia,power-domains"; + name = "gr3d2-power-domain"; + domain = <TEGRA_POWERGATE_3D1>; + clocks = <&tegra_car TEGRA30_CLK_GR3D2>; + resets = <&tegra_car 98>; + nvidia,swgroup = <&mc TEGRA_SWGROUP_NV2>; + depend-on = <&gr3dpd>; + }; + + pcie-power-domain { + compatible = "nvidia,power-domains"; + name = "pcie-power-domain"; + domain = <TEGRA_POWERGATE_PCIE>; + clocks = <&tegra_car TEGRA30_CLK_AFI>, + <&tegra_car TEGRA30_CLK_PCIE>, + <&tegra_car TEGRA30_CLK_CML0>; + resets = <&tegra_car 70>, + <&tegra_car 72>, + <&tegra_car 74>; + nvidia,swgroup = <&mc TEGRA_SWGROUP_AFI>; }; mc: memory-controller at 7000f000 {
Signature · 1 line
2.1.4
PATCH v2 9/17 ARM: tegra: add PM domain device nodes to Tegra114 DT
In reply to Vince HsuAlso bind the PM domain provider and consumer together.
--- arch/arm/boot/dts/tegra114.dtsi | 43 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-)
arch/arm/boot/dts/tegra114.dtsi +42 -1
@@ -2,6 +2,7 @@ #include <dt-bindings/gpio/tegra-gpio.h> #include <dt-bindings/memory/tegra114-mc.h> #include <dt-bindings/pinctrl/pinctrl-tegra.h> +#include <dt-bindings/power/tegra-powergate.h> #include <dt-bindings/interrupt-controller/arm-gic.h> #include "skeleton.dtsi"
@@ -36,6 +37,7 @@ gr3d at 54180000 { compatible = "nvidia,tegra114-gr3d", "nvidia,tegra20-gr3d"; reg = <0x54180000 0x00040000>; + power-domains = <&pmc TEGRA_POWERGATE_3D>; clocks = <&tegra_car TEGRA114_CLK_GR3D>; resets = <&tegra_car 24>; reset-names = "3d";
@@ -45,6 +47,7 @@ compatible = "nvidia,tegra114-dc", "nvidia,tegra20-dc"; reg = <0x54200000 0x00040000>; interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>; + power-domains = <&pmc TEGRA_POWERGATE_DIS>; clocks = <&tegra_car TEGRA114_CLK_DISP1>, <&tegra_car TEGRA114_CLK_PLL_P>; clock-names = "dc", "parent";
@@ -64,6 +67,7 @@ compatible = "nvidia,tegra114-dc", "nvidia,tegra20-dc"; reg = <0x54240000 0x00040000>; interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>; + power-domains = <&pmc TEGRA_POWERGATE_DISB>; clocks = <&tegra_car TEGRA114_CLK_DISP2>, <&tegra_car TEGRA114_CLK_PLL_P>; clock-names = "dc", "parent";
@@ -487,11 +491,48 @@ status = "disabled"; }; - pmc at 7000e400 { + pmc: pmc at 7000e400 { compatible = "nvidia,tegra114-pmc"; reg = <0x7000e400 0x400>; clocks = <&tegra_car TEGRA114_CLK_PCLK>, <&clk32k_in>; clock-names = "pclk", "clk32k_in"; + #power-domain-cells = <1>; + }; + + dcpd: dc-power-domain { + compatible = "nvidia,power-domains"; + name = "dc-power-domain"; + domain = <TEGRA_POWERGATE_DIS>; + clocks = <&tegra_car TEGRA114_CLK_DISP1>, + <&tegra_car TEGRA114_CLK_DSIA>, + <&tegra_car TEGRA114_CLK_DSIB>, + <&tegra_car TEGRA114_CLK_MIPI_CAL>; + resets = <&tegra_car 27>, + <&tegra_car 48>, + <&tegra_car 82>, + <&tegra_car 56>; + nvidia,swgroup = <&mc TEGRA_SWGROUP_DC>; + }; + + dcb-power-domain { + compatible = "nvidia,power-domains"; + name = "dcb-power-domain"; + domain = <TEGRA_POWERGATE_DISB>; + clocks = <&tegra_car TEGRA114_CLK_DISP2>, + <&tegra_car TEGRA114_CLK_HDMI>; + resets = <&tegra_car 26>, + <&tegra_car 51>; + nvidia,swgroup = <&mc TEGRA_SWGROUP_DCB>; + depend-on = <&dcpd>; + }; + + gr3d-power-domain { + compatible = "nvidia,power-domains"; + name = "gr3d-power-domain"; + domain = <TEGRA_POWERGATE_3D>; + clocks = <&tegra_car TEGRA114_CLK_GR3D>; + resets = <&tegra_car 24>; + nvidia,swgroup = <&mc TEGRA_SWGROUP_NV>; }; fuse at 7000f800 {
Signature · 1 line
2.1.4
PATCH v2 10/17 ARM: tegra: add PM domain device nodes to Tegra124 DT
In reply to Vince HsuAlso bind the PM domain provider and consumer together.
--- arch/arm/boot/dts/tegra124.dtsi | 86 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-)
arch/arm/boot/dts/tegra124.dtsi +85 -1
@@ -3,6 +3,7 @@ #include <dt-bindings/memory/tegra124-mc.h> #include <dt-bindings/pinctrl/pinctrl-tegra.h> #include <dt-bindings/pinctrl/pinctrl-tegra-xusb.h> +#include <dt-bindings/power/tegra-powergate.h> #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/thermal/tegra124-soctherm.h>
@@ -39,6 +40,8 @@ 0x82000000 0 0x13000000 0x0 0x13000000 0 0x0d000000 /* non-prefetchable memory (208 MiB) */ 0xc2000000 0 0x20000000 0x0 0x20000000 0 0x20000000>; /* prefetchable memory (512 MiB) */ + power-domains = <&pmc TEGRA_POWERGATE_PCIE>; + clocks = <&tegra_car TEGRA124_CLK_PCIE>, <&tegra_car TEGRA124_CLK_AFI>, <&tegra_car TEGRA124_CLK_PLL_E>,
@@ -98,6 +101,7 @@ compatible = "nvidia,tegra124-dc"; reg = <0x0 0x54200000 0x0 0x00040000>; interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>; + power-domains = <&pmc TEGRA_POWERGATE_DIS>; clocks = <&tegra_car TEGRA124_CLK_DISP1>, <&tegra_car TEGRA124_CLK_PLL_P>; clock-names = "dc", "parent";
@@ -113,6 +117,7 @@ compatible = "nvidia,tegra124-dc"; reg = <0x0 0x54240000 0x0 0x00040000>; interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>; + power-domains = <&pmc TEGRA_POWERGATE_DISB>; clocks = <&tegra_car TEGRA124_CLK_DISP2>, <&tegra_car TEGRA124_CLK_PLL_P>; clock-names = "dc", "parent";
@@ -140,6 +145,7 @@ compatible = "nvidia,tegra124-sor"; reg = <0x0 0x54540000 0x0 0x00040000>; interrupts = <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>; + power-domains = <&pmc TEGRA_POWERGATE_SOR>; clocks = <&tegra_car TEGRA124_CLK_SOR0>, <&tegra_car TEGRA124_CLK_PLL_D_OUT0>, <&tegra_car TEGRA124_CLK_PLL_DP>,
@@ -182,6 +188,7 @@ interrupts = <GIC_SPI 157 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 158 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "stall", "nonstall"; + power-domains = <&pmc TEGRA_POWERGATE_3D>; clocks = <&tegra_car TEGRA124_CLK_GPU>, <&tegra_car TEGRA124_CLK_PLL_P_OUT5>; clock-names = "gpu", "pwr";
@@ -542,11 +549,86 @@ clocks = <&tegra_car TEGRA124_CLK_RTC>; }; - pmc at 0,7000e400 { + pmc: pmc at 0,7000e400 { compatible = "nvidia,tegra124-pmc"; reg = <0x0 0x7000e400 0x0 0x400>; clocks = <&tegra_car TEGRA124_CLK_PCLK>, <&clk32k_in>; clock-names = "pclk", "clk32k_in"; + #power-domain-cells = <1>; + }; + + dcpd: dc-power-domain { + compatible = "nvidia,power-domains"; + name = "dc-power-domain"; + domain = <TEGRA_POWERGATE_DIS>; + clocks = <&tegra_car TEGRA124_CLK_DISP1>; + resets = <&tegra_car 27>; + nvidia,swgroup = <&mc TEGRA_SWGROUP_DC>; + depend-on = <&sorpd>; + }; + + dcb-power-domain { + compatible = "nvidia,power-domains"; + name = "dcb-power-domain"; + domain = <TEGRA_POWERGATE_DISB>; + clocks = <&tegra_car TEGRA124_CLK_DISP2>; + resets = <&tegra_car 26>; + nvidia,swgroup = <&mc TEGRA_SWGROUP_DCB>; + depend-on = <&dcpd>; + }; + + pcie-power-domain { + compatible = "nvidia,power-domains"; + name = "pcie-power-domain"; + domain = <TEGRA_POWERGATE_PCIE>; + clocks = <&tegra_car TEGRA124_CLK_PCIE>, + <&tegra_car TEGRA124_CLK_AFI>, + <&tegra_car TEGRA124_CLK_CML0>; + resets = <&tegra_car 70>, + <&tegra_car 72>, + <&tegra_car 74>; + nvidia,swgroup = <&mc TEGRA_SWGROUP_AFI>; + }; + + sorpd: sor-power-domain { + compatible = "nvidia,power-domains"; + name = "sor-power-domain"; + domain = <TEGRA_POWERGATE_SOR>; + clocks = <&tegra_car TEGRA124_CLK_SOR0>, + <&tegra_car TEGRA124_CLK_DSIA>, + <&tegra_car TEGRA124_CLK_DSIB>, + <&tegra_car TEGRA124_CLK_HDMI>, + <&tegra_car TEGRA124_CLK_MIPI_CAL>, + <&tegra_car TEGRA124_CLK_DPAUX>; + resets = <&tegra_car 182>, + <&tegra_car 48>, + <&tegra_car 82>, + <&tegra_car 51>, + <&tegra_car 56>; + }; + + gpu-power-domain { + compatible = "nvidia,power-domains"; + name = "gpu-power-domain"; + domain = <TEGRA_POWERGATE_3D>; + clocks = <&tegra_car TEGRA124_CLK_GPU>, + <&tegra_car TEGRA124_CLK_PLL_P_OUT5>; + resets = <&tegra_car 184>; + external-power-rail; + nvidia,swgroup = <&mc TEGRA_SWGROUP_GPU>; + }; + + sata-power-domain { + compatible = "nvidia,power-domains"; + name = "sata-power-domain"; + domain = <TEGRA_POWERGATE_SATA>; + clocks = <&tegra_car TEGRA124_CLK_SATA>, + <&tegra_car TEGRA124_CLK_SATA_OOB>, + <&tegra_car TEGRA124_CLK_CML1>; + resets = <&tegra_car 124>, + <&tegra_car 123>, + <&tegra_car 129>; + nvidia,swgroup = <&mc TEGRA_SWGROUP_SATA>; }; fuse at 0,7000f800 {
@@ -588,6 +670,8 @@ <&tegra_car 129>; reset-names = "sata", "sata-oob", "sata-cold"; + power-domains = <&pmc TEGRA_POWERGATE_SATA>; + phys = <&padctl TEGRA_XUSB_PADCTL_SATA>; phy-names = "sata-phy";
Signature · 1 line
2.1.4
PATCH v2 11/17 ARM: tegra: add GPU power supply to Jetson TK1 DT
In reply to Vince HsuAdd power supply information which is board dependent for GK20A.
--- arch/arm/boot/dts/tegra124-jetson-tk1.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/boot/dts/tegra124-jetson-tk1.dts +4 -0
@@ -1682,6 +1682,10 @@ }; }; + gpu-power-domain { + vdd-supply = <&vdd_gpu>; + }; + /* Serial ATA */ sata at 0,70020000 { status = "okay";
Signature · 1 line
2.1.4
PATCH v2 12/17 drm/tegra: dc: remove the power sequence from driver
In reply to Vince HsuWe have the generic PM domain support for Tegra SoCs now. So remove the duplicated power sequence here.
--- drivers/gpu/drm/tegra/dc.c | 46 +++++++++++----------------------------------- 1 file changed, 11 insertions(+), 35 deletions(-)
drivers/gpu/drm/tegra/dc.c +11 -35
@@ -28,7 +28,6 @@ struct tegra_dc_soc_info {bool supports_cursor;bool supports_block_linear;unsigned int pitch_align; -bool has_powergate; };struct tegra_plane {
@@ -1786,7 +1785,6 @@ static const struct tegra_dc_soc_info tegra20_dc_soc_info = { .supports_cursor = false, .supports_block_linear = false, .pitch_align = 8, - .has_powergate = false, };static const struct tegra_dc_soc_info tegra30_dc_soc_info = {
@@ -1795,7 +1793,6 @@ static const struct tegra_dc_soc_info tegra30_dc_soc_info = { .supports_cursor = false, .supports_block_linear = false, .pitch_align = 8, - .has_powergate = false, };static const struct tegra_dc_soc_info tegra114_dc_soc_info = {
@@ -1804,7 +1801,6 @@ static const struct tegra_dc_soc_info tegra114_dc_soc_info = { .supports_cursor = false, .supports_block_linear = false, .pitch_align = 64, - .has_powergate = true, };static const struct tegra_dc_soc_info tegra124_dc_soc_info = {
@@ -1813,7 +1809,6 @@ static const struct tegra_dc_soc_info tegra124_dc_soc_info = { .supports_cursor = true, .supports_block_linear = true, .pitch_align = 64, - .has_powergate = true, };static const struct of_device_id tegra_dc_of_match[] = {
@@ -1906,33 +1901,18 @@ static int tegra_dc_probe(struct platform_device *pdev)return PTR_ERR (dc->rst); } -if (dc->soc->has_powergate) { -if (dc->pipe ==0 ) - dc->powergate =TEGRA_POWERGATE_DIS ; -else - dc->powergate =TEGRA_POWERGATE_DISB ; - - err =tegra_powergate_sequence_power_up (dc->powergate, dc->clk, - dc->rst); -if (err <0 ) { -dev_err (&pdev->dev,"failed to power partition: %d\n" , - err); -return err; - } - }else { - err =clk_prepare_enable (dc->clk); -if (err <0 ) { -dev_err (&pdev->dev,"failed to enable clock: %d\n" , - err); -return err; - } + err =clk_prepare_enable (dc->clk); +if (err <0 ) { +dev_err (&pdev->dev,"failed to enable clock: %d\n" , + err); +return err; + } - err =reset_control_deassert (dc->rst); -if (err <0 ) { -dev_err (&pdev->dev,"failed to deassert reset: %d\n" , - err); -return err; - } + err =reset_control_deassert (dc->rst); +if (err <0 ) { +dev_err (&pdev->dev,"failed to deassert reset: %d\n" , + err); +return err; } regs =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
@@ -1987,10 +1967,6 @@ static int tegra_dc_remove(struct platform_device *pdev) }reset_control_assert (dc->rst); - -if (dc->soc->has_powergate) -tegra_powergate_power_off (dc->powergate); -clk_disable_unprepare (dc->clk);return 0 ;
Signature · 1 line
2.1.4
PATCH v2 13/17 PCI: tegra: remove the power sequence from driver
In reply to Vince HsuWe have the generic PM domain support for Tegra SoCs now. So remove the duplicated power sequence here.
---
v2: enable pex clock when powering on
drivers/pci/host/pci-tegra.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-)
drivers/pci/host/pci-tegra.c +3 -19
@@ -931,12 +931,6 @@ static void tegra_pcie_power_off(struct tegra_pcie *pcie)if (err <0 )dev_warn (pcie->dev,"failed to power off PHY: %d\n" , err); -reset_control_assert (pcie->pcie_xrst); -reset_control_assert (pcie->afi_rst); -reset_control_assert (pcie->pex_rst); - -tegra_powergate_power_off (TEGRA_POWERGATE_PCIE ); - err =regulator_bulk_disable (pcie->num_supplies, pcie->supplies);if (err <0 )dev_warn (pcie->dev,"failed to disable regulators: %d\n" , err);
@@ -947,27 +941,17 @@ static int tegra_pcie_power_on(struct tegra_pcie *pcie)const struct tegra_pcie_soc_data *soc = pcie->soc_data;int err; -reset_control_assert (pcie->pcie_xrst); -reset_control_assert (pcie->afi_rst); -reset_control_assert (pcie->pex_rst); - -tegra_powergate_power_off (TEGRA_POWERGATE_PCIE ); -/* enable regulators */ err =regulator_bulk_enable (pcie->num_supplies, pcie->supplies);if (err <0 )dev_err (pcie->dev,"failed to enable regulators: %d\n" , err); - err =tegra_powergate_sequence_power_up (TEGRA_POWERGATE_PCIE , - pcie->pex_clk, - pcie->pex_rst); -if (err) { -dev_err (pcie->dev,"powerup sequence failed: %d\n" , err); + err =clk_prepare_enable (pcie->pex_clk); +if (err <0 ) { +dev_err (pcie->dev,"failed to enable PEX clock: %d\n" , err);return err; } -reset_control_deassert (pcie->afi_rst); - err =clk_prepare_enable (pcie->afi_clk);if (err <0 ) {dev_err (pcie->dev,"failed to enable AFI clock: %d\n" , err);
Signature · 1 line
2.1.4
PATCH v2 14/17 ata: ahci_tegra: remove power sequence from driver
In reply to Vince HsuWe have the generic PM domain support for Tegra SoCs now. So remove the duplicated sequence here.
--- drivers/ata/ahci_tegra.c | 11 ----------- 1 file changed, 11 deletions(-)
drivers/ata/ahci_tegra.c +0 -11
@@ -120,12 +120,6 @@ static int tegra_ahci_power_on(struct ahci_host_priv *hpriv)if (ret)return ret; - ret =tegra_powergate_sequence_power_up (TEGRA_POWERGATE_SATA , - tegra->sata_clk, - tegra->sata_rst); -if (ret) - goto disable_regulators; -reset_control_assert (tegra->sata_oob_rst);reset_control_assert (tegra->sata_cold_rst);
@@ -140,10 +134,6 @@ static int tegra_ahci_power_on(struct ahci_host_priv *hpriv) disable_power:clk_disable_unprepare (tegra->sata_clk); - -tegra_powergate_power_off (TEGRA_POWERGATE_SATA ); - -disable_regulators:regulator_bulk_disable (ARRAY_SIZE (tegra->supplies), tegra->supplies);return ret;
@@ -160,7 +150,6 @@ static void tegra_ahci_power_off(struct ahci_host_priv *hpriv)reset_control_assert (tegra->sata_cold_rst);clk_disable_unprepare (tegra->sata_clk); -tegra_powergate_power_off (TEGRA_POWERGATE_SATA );regulator_bulk_disable (ARRAY_SIZE (tegra->supplies), tegra->supplies); }
Signature · 1 line
2.1.4
Re: [PATCH v2 14/17] ata: ahci_tegra: remove power sequence from driver
Quoted 4 lines · Vince Hsu
We have the generic PM domain support for Tegra SoCs now. So remove the duplicated sequence here.
Signed-off-by Vince Hsu <[email protected]>
Can you please repost this patch w/ Hans de Goede <[email protected]> cc'd? Just reposting the patch as a reply to itself w/ the cc added should do.
Thanks.
Signature · 1 line
tejun
Re: [PATCH v2 14/17] ata: ahci_tegra: remove power sequence from driver
Cc'd Hans.
Thanks,
Vince
Quoted 5 lines · Tejun Heo
Quoted 4 lines · Vince Hsu
We have the generic PM domain support for Tegra SoCs now. So remove the duplicated sequence here.
Signed-off-by Vince Hsu <[email protected]>
Quoted 8 lines
Can you please repost this patch w/ Hans de Goede <[email protected]> cc'd? Just reposting the patch as a reply to itself w/ the cc added should do.
Thanks.
From
afff7ff2011f2c3f159726ffddeaeec8f62f013eMon Sep 17 00:00:00 2001
From: Vince Hsu <[email protected]>
Date: Wed, 14 Jan 2015 11:01:06 +0800
Subject: [PATCH v2 14/17] ata: ahci_tegra: remove power sequence from driver
X-NVConfidentiality: public
We have the generic PM domain support for Tegra SoCs now. So remove the duplicated sequence here.
--- drivers/ata/ahci_tegra.c | 11 ----------- 1 file changed, 11 deletions(-)
drivers/ata/ahci_tegra.c +0 -11
@@ -120,12 +120,6 @@ static int tegra_ahci_power_on(struct ahci_host_priv *hpriv)if (ret)return ret; - ret =tegra_powergate_sequence_power_up (TEGRA_POWERGATE_SATA , - tegra->sata_clk, - tegra->sata_rst); -if (ret) - goto disable_regulators; -reset_control_assert (tegra->sata_oob_rst);reset_control_assert (tegra->sata_cold_rst);
@@ -140,10 +134,6 @@ static int tegra_ahci_power_on(struct ahci_host_priv *hpriv) disable_power:clk_disable_unprepare (tegra->sata_clk); - -tegra_powergate_power_off (TEGRA_POWERGATE_SATA ); - -disable_regulators:regulator_bulk_disable (ARRAY_SIZE (tegra->supplies), tegra->supplies);return ret;
@@ -160,7 +150,6 @@ static void tegra_ahci_power_off(struct ahci_host_priv *hpriv)reset_control_assert (tegra->sata_cold_rst);clk_disable_unprepare (tegra->sata_clk); -tegra_powergate_power_off (TEGRA_POWERGATE_SATA );regulator_bulk_disable (ARRAY_SIZE (tegra->supplies), tegra->supplies); }
Signature · 1 line
2.1.4
Hans de Goede
Acked-byRe: [PATCH v2 14/17] ata: ahci_tegra: remove power sequence from driver
Hi,
Quoted 17 lines · Vince Hsu
Cc'd Hans.
Thanks,
VinceQuoted 11 lines · Tejun Heo
Quoted 4 lines · Vince Hsu
We have the generic PM domain support for Tegra SoCs now. So remove the duplicated sequence here.
Signed-off-by Vince Hsu <[email protected]>Can you please repost this patch w/ Hans de Goede <[email protected]> cc'd? Just reposting the patch as a reply to itself w/ the cc added should do.
Thanks.
Patch looks good to me:
Regards,
Hans
PATCH v2 15/17 drm/tegra: remove GR3D power sequence from driver
In reply to Vince HsuWe have the generic PM domain support for Tegra SoCs now. So remove the duplicated power sequence here.
--- drivers/gpu/drm/tegra/gr3d.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/gpu/drm/tegra/gr3d.c +16 -16
@@ -281,21 +281,17 @@ static int gr3d_probe(struct platform_device *pdev) } } - err =tegra_powergate_sequence_power_up (TEGRA_POWERGATE_3D , gr3d->clk, - gr3d->rst); -if (err <0 ) { -dev_err (&pdev->dev,"failed to power up 3D unit\n" ); + err =clk_prepare_enable (gr3d->clk); +if (err) { +dev_err (&pdev->dev,"failed to enable clk\n" );return err; }if (gr3d->clk_secondary) { - err =tegra_powergate_sequence_power_up (TEGRA_POWERGATE_3D1 , - gr3d->clk_secondary, - gr3d->rst_secondary); -if (err <0 ) { -dev_err (&pdev->dev, -"failed to power up secondary 3D unit\n" ); -return err; + err =clk_prepare_enable (gr3d->clk_secondary); +if (err) { +dev_err (&pdev->dev,"failed to enable secondary clk\n" ); + goto err_clk_sec; } }
@@ -313,7 +309,7 @@ static int gr3d_probe(struct platform_device *pdev)if (err <0 ) {dev_err (&pdev->dev,"failed to register host1x client: %d\n" , err); -return err; + goto err_host1x; }/* initialize address register map */
@@ -323,6 +319,13 @@ static int gr3d_probe(struct platform_device *pdev)platform_set_drvdata (pdev, gr3d);return 0 ; + +err_clk_sec: +clk_disable_unprepare (gr3d->clk); +err_host1x: +clk_disable_unprepare (gr3d->clk_secondary); + +return err; }static int gr3d_remove (struct platform_device *pdev)
@@ -337,12 +340,9 @@ static int gr3d_remove(struct platform_device *pdev)return err; } -if (gr3d->clk_secondary) { -tegra_powergate_power_off (TEGRA_POWERGATE_3D1 ); +if (gr3d->clk_secondary)clk_disable_unprepare (gr3d->clk_secondary); - } -tegra_powergate_power_off (TEGRA_POWERGATE_3D );clk_disable_unprepare (gr3d->clk);return 0 ;
Signature · 1 line
2.1.4
PATCH v2 16/17 ARM: tegra: select PM_GENERIC_DOMAINS
In reply to Vince HsuWe have added generic power domain support for Tegra SoCs. So now the option PM_GENERIC_DOMAINS must be enabled by default to have proper power sequence.
--- arch/arm/mach-tegra/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-tegra/Kconfig +1 -0
@@ -8,6 +8,7 @@ menuconfig ARCH_TEGRA select HAVE_ARM_SCU if SMP select HAVE_ARM_TWD if SMP select PINCTRL + select PM_GENERIC_DOMAINS if PM select ARCH_HAS_RESET_CONTROLLER select RESET_CONTROLLER select SOC_BUS
Signature · 1 line
2.1.4
PATCH v2 17/17 soc/tegra: remove lagacy powergate APIs
In reply to Vince HsuWe switch to generic power domain now. So remove the legacy functions.
--- drivers/soc/tegra/pmc.c | 68 ------------------------------------------------- include/soc/tegra/pmc.h | 22 ---------------- 2 files changed, 90 deletions(-)
drivers/soc/tegra/pmc.c +0 -68
@@ -233,31 +233,6 @@ static int tegra_powergate_set(int id, bool new_state) }/** -* tegra_powergate_power_on() - power on partition -* @id: partition ID -*/ -int tegra_powergate_power_on (int id) -{ -if (!pmc->soc || id <0 || id >= pmc->soc->num_powergates) -return -EINVAL ; - -return tegra_powergate_set (id, true); -} - -/** -* tegra_powergate_power_off() - power off partition -* @id: partition ID -*/ -int tegra_powergate_power_off (int id) -{ -if (!pmc->soc || id <0 || id >= pmc->soc->num_powergates) -return -EINVAL ; - -return tegra_powergate_set (id, false); -} -EXPORT_SYMBOL (tegra_powergate_power_off); - -/** * tegra_powergate_is_powered() - check if partition is powered * @id: partition ID */
@@ -313,49 +288,6 @@ int tegra_powergate_remove_clamping(int id) }EXPORT_SYMBOL (tegra_powergate_remove_clamping); -/** -* tegra_powergate_sequence_power_up() - power up partition -* @id: partition ID -* @clk: clock for partition -* @rst: reset for partition -* -* Must be called with clk disabled, and returns with clk enabled. -*/ -int tegra_powergate_sequence_power_up (int id,struct clk *clk, -struct reset_control *rst) -{ -int ret; - -reset_control_assert (rst); - - ret =tegra_powergate_power_on (id); -if (ret) - goto err_power; - - ret =clk_prepare_enable (clk); -if (ret) - goto err_clk; - -usleep_range (10 ,20 ); - - ret =tegra_powergate_remove_clamping (id); -if (ret) - goto err_clamp; - -usleep_range (10 ,20 ); -reset_control_deassert (rst); - -return 0 ; - -err_clamp: -clk_disable_unprepare (clk); -err_clk: -tegra_powergate_power_off (id); -err_power: -return ret; -} -EXPORT_SYMBOL (tegra_powergate_sequence_power_up); -#ifdef CONFIG_SMP /** * tegra_get_cpu_powergate_id() - convert from CPU ID to partition ID
include/soc/tegra/pmc.h +0 -22
@@ -106,14 +106,8 @@ int tegra_pmc_cpu_remove_clamping(int cpuid);#ifdef CONFIG_ARCH_TEGRA int tegra_powergate_is_powered (int id); -int tegra_powergate_power_on (int id); -int tegra_powergate_power_off (int id);int tegra_powergate_remove_clamping (int id); -/* Must be called with clk disabled, and returns with clk enabled */ -int tegra_powergate_sequence_power_up (int id,struct clk *clk, -struct reset_control *rst); -int tegra_io_rail_power_on (int id);int tegra_io_rail_power_off (int id);#else
@@ -122,27 +116,11 @@ static inline int tegra_powergate_is_powered(int id)return -ENOSYS ; } -static inline int tegra_powergate_power_on (int id) -{ -return -ENOSYS ; -} - -static inline int tegra_powergate_power_off (int id) -{ -return -ENOSYS ; -} -static inline int tegra_powergate_remove_clamping (int id) {return -ENOSYS ; } -static inline int tegra_powergate_sequence_power_up (int id,struct clk *clk, -struct reset_control *rst) -{ -return -ENOSYS ; -} -static inline int tegra_io_rail_power_on (int id) {return -ENOSYS ;
Signature · 1 line
2.1.4
Re: [PATCH v2 17/17] soc/tegra: remove lagacy powergate APIs
Quoted 7 lines · Vince Hsu
We switch to generic power domain now. So remove the legacy functions.
Signed-off-by Vince Hsu <[email protected]>--- drivers/soc/tegra/pmc.c | 68 ------------------------------------------------- include/soc/tegra/pmc.h | 22 ---------------- 2 files changed, 90 deletions(-)
I don't think we can do this. What if somebody updates their kernel but not the DTB? In that case they'll end up with drivers that don't enable power partitions but at the same time the powergate driver won't enable them either because it is missing the corresponding nodes in the DTB.
What we'll have to do is probably keep the code that enables the power partitions and make it conditional on the power domains somehow. Is there a way to determine at runtime whether a device has been attached to a power domain?
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150312/c7f4acbc/attachment.sig>
Re: [PATCH v2 17/17] soc/tegra: remove lagacy powergate APIs
Hi,
Quoted 10 lines · Thierry Reding
* PGP Signed by an unknown key
Quoted 7 lines · Vince Hsu
We switch to generic power domain now. So remove the legacy functions.
Signed-off-by Vince Hsu <[email protected]>--- drivers/soc/tegra/pmc.c | 68 ------------------------------------------------- include/soc/tegra/pmc.h | 22 ---------------- 2 files changed, 90 deletions(-)
Quoted 4 lines
I don't think we can do this. What if somebody updates their kernel but not the DTB? In that case they'll end up with drivers that don't enable power partitions but at the same time the powergate driver won't enable them either because it is missing the corresponding nodes in the DTB.
You're right.
Quoted 6 lines
What we'll have to do is probably keep the code that enables the power partitions and make it conditional on the power domains somehow. Is there a way to determine at runtime whether a device has been attached to a power domain?
Yes, we can check if a power domain is bound to the GPD by DT in the legacy powergate code.
Thanks,
Vince
Re: [PATCH v2 17/17] soc/tegra: remove lagacy powergate APIs
In reply to Thierry RedingQuoted 16 lines · Thierry Reding
* PGP Signed by an unknown key
Quoted 7 lines · Vince Hsu
We switch to generic power domain now. So remove the legacy functions.
Signed-off-by Vince Hsu <[email protected]>--- drivers/soc/tegra/pmc.c | 68 ------------------------------------------------- include/soc/tegra/pmc.h | 22 ---------------- 2 files changed, 90 deletions(-)I don't think we can do this. What if somebody updates their kernel but not the DTB? In that case they'll end up with drivers that don't enable power partitions but at the same time the powergate driver won't enable them either because it is missing the corresponding nodes in the DTB.
Quoted 4 lines
What we'll have to do is probably keep the code that enables the power partitions and make it conditional on the power domains somehow. Is there a way to determine at runtime whether a device has been attached to a power domain?
Or use DT overlays to 'load' a hardcoded overlay for the specific SoC?
Cheers,
Peter.