* [PATCH 0/2] soc: amlogic: ee-pwrc: cleanup init state
@ 2019-09-25 19:12 Kevin Hilman
2019-09-25 19:12 ` [PATCH 1/2] soc: amlogic: ee-pwrc: rename get_power Kevin Hilman
2019-09-25 19:12 ` [PATCH 2/2] soc: amlogic: ee-pwrc: ensure driver state maches HW state Kevin Hilman
0 siblings, 2 replies; 4+ messages in thread
From: Kevin Hilman @ 2019-09-25 19:12 UTC (permalink / raw)
To: linux-amlogic, Neil Armstrong; +Cc: linux-arm-kernel, linux-pm
Cleanup the PM domain init state and ensure that the driver state
matches the HW state for all domains.
Tested on meson-sm1-sei610.
Kevin Hilman (2):
soc: amlogic: ee-pwrc: rename get_power
soc: amlogic: ee-pwrc: ensure driver state maches HW state
drivers/soc/amlogic/meson-ee-pwrc.c | 58 ++++++++++++-----------------
1 file changed, 23 insertions(+), 35 deletions(-)
--
2.22.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] soc: amlogic: ee-pwrc: rename get_power
2019-09-25 19:12 [PATCH 0/2] soc: amlogic: ee-pwrc: cleanup init state Kevin Hilman
@ 2019-09-25 19:12 ` Kevin Hilman
2019-09-25 19:12 ` [PATCH 2/2] soc: amlogic: ee-pwrc: ensure driver state maches HW state Kevin Hilman
1 sibling, 0 replies; 4+ messages in thread
From: Kevin Hilman @ 2019-09-25 19:12 UTC (permalink / raw)
To: linux-amlogic, Neil Armstrong; +Cc: linux-arm-kernel, linux-pm
The function named _get_power() is misleading since it returns true
if the power is off. Rename to _is_off() for better readability.
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
---
drivers/soc/amlogic/meson-ee-pwrc.c | 34 ++++++++++++++---------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/soc/amlogic/meson-ee-pwrc.c b/drivers/soc/amlogic/meson-ee-pwrc.c
index 5823f5b67d16..dcce8e694a07 100644
--- a/drivers/soc/amlogic/meson-ee-pwrc.c
+++ b/drivers/soc/amlogic/meson-ee-pwrc.c
@@ -56,7 +56,7 @@ struct meson_ee_pwrc_domain_desc {
struct meson_ee_pwrc_top_domain *top_pd;
unsigned int mem_pd_count;
struct meson_ee_pwrc_mem_domain *mem_pd;
- bool (*get_power)(struct meson_ee_pwrc_domain *pwrc_domain);
+ bool (*is_off)(struct meson_ee_pwrc_domain *pwrc_domain);
};
struct meson_ee_pwrc_domain_data {
@@ -173,7 +173,7 @@ static struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_audio[] = {
{ HHI_AUDIO_MEM_PD_REG0, GENMASK(27, 26) },
};
-#define VPU_PD(__name, __top_pd, __mem, __get_power, __resets, __clks) \
+#define VPU_PD(__name, __top_pd, __mem, __is_off, __resets, __clks) \
{ \
.name = __name, \
.reset_names_count = __resets, \
@@ -181,40 +181,40 @@ static struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_audio[] = {
.top_pd = __top_pd, \
.mem_pd_count = ARRAY_SIZE(__mem), \
.mem_pd = __mem, \
- .get_power = __get_power, \
+ .is_off = __is_off, \
}
-#define TOP_PD(__name, __top_pd, __mem, __get_power) \
+#define TOP_PD(__name, __top_pd, __mem, __is_off) \
{ \
.name = __name, \
.top_pd = __top_pd, \
.mem_pd_count = ARRAY_SIZE(__mem), \
.mem_pd = __mem, \
- .get_power = __get_power, \
+ .is_off = __is_off, \
}
#define MEM_PD(__name, __mem) \
TOP_PD(__name, NULL, __mem, NULL)
-static bool pwrc_ee_get_power(struct meson_ee_pwrc_domain *pwrc_domain);
+static bool pwrc_ee_is_off(struct meson_ee_pwrc_domain *pwrc_domain);
static struct meson_ee_pwrc_domain_desc g12a_pwrc_domains[] = {
[PWRC_G12A_VPU_ID] = VPU_PD("VPU", &g12a_pwrc_vpu, g12a_pwrc_mem_vpu,
- pwrc_ee_get_power, 11, 2),
+ pwrc_ee_is_off, 11, 2),
[PWRC_G12A_ETH_ID] = MEM_PD("ETH", g12a_pwrc_mem_eth),
};
static struct meson_ee_pwrc_domain_desc sm1_pwrc_domains[] = {
[PWRC_SM1_VPU_ID] = VPU_PD("VPU", &sm1_pwrc_vpu, sm1_pwrc_mem_vpu,
- pwrc_ee_get_power, 11, 2),
+ pwrc_ee_is_off, 11, 2),
[PWRC_SM1_NNA_ID] = TOP_PD("NNA", &sm1_pwrc_nna, sm1_pwrc_mem_nna,
- pwrc_ee_get_power),
+ pwrc_ee_is_off),
[PWRC_SM1_USB_ID] = TOP_PD("USB", &sm1_pwrc_usb, sm1_pwrc_mem_usb,
- pwrc_ee_get_power),
+ pwrc_ee_is_off),
[PWRC_SM1_PCIE_ID] = TOP_PD("PCI", &sm1_pwrc_pci, sm1_pwrc_mem_pcie,
- pwrc_ee_get_power),
+ pwrc_ee_is_off),
[PWRC_SM1_GE2D_ID] = TOP_PD("GE2D", &sm1_pwrc_ge2d, sm1_pwrc_mem_ge2d,
- pwrc_ee_get_power),
+ pwrc_ee_is_off),
[PWRC_SM1_AUDIO_ID] = MEM_PD("AUDIO", sm1_pwrc_mem_audio),
[PWRC_SM1_ETH_ID] = MEM_PD("ETH", g12a_pwrc_mem_eth),
};
@@ -237,7 +237,7 @@ struct meson_ee_pwrc {
struct genpd_onecell_data xlate;
};
-static bool pwrc_ee_get_power(struct meson_ee_pwrc_domain *pwrc_domain)
+static bool pwrc_ee_is_off(struct meson_ee_pwrc_domain *pwrc_domain)
{
u32 reg;
@@ -367,7 +367,7 @@ static int meson_ee_pwrc_init_domain(struct platform_device *pdev,
* we need to power the domain off, otherwise the internal clocks
* prepare/enable counters won't be in sync.
*/
- if (dom->num_clks && dom->desc.get_power && !dom->desc.get_power(dom)) {
+ if (dom->num_clks && dom->desc.is_off && !dom->desc.is_off(dom)) {
int ret = clk_bulk_prepare_enable(dom->num_clks, dom->clks);
if (ret)
return ret;
@@ -375,8 +375,8 @@ static int meson_ee_pwrc_init_domain(struct platform_device *pdev,
pm_genpd_init(&dom->base, &pm_domain_always_on_gov, false);
} else
pm_genpd_init(&dom->base, NULL,
- (dom->desc.get_power ?
- dom->desc.get_power(dom) : true));
+ (dom->desc.is_off ?
+ dom->desc.is_off(dom) : true));
return 0;
}
@@ -454,7 +454,7 @@ static void meson_ee_pwrc_shutdown(struct platform_device *pdev)
for (i = 0 ; i < pwrc->xlate.num_domains ; ++i) {
struct meson_ee_pwrc_domain *dom = &pwrc->domains[i];
- if (dom->desc.get_power && !dom->desc.get_power(dom))
+ if (dom->desc.is_off && !dom->desc.is_off(dom))
meson_ee_pwrc_off(&dom->base);
}
}
--
2.22.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] soc: amlogic: ee-pwrc: ensure driver state maches HW state
2019-09-25 19:12 [PATCH 0/2] soc: amlogic: ee-pwrc: cleanup init state Kevin Hilman
2019-09-25 19:12 ` [PATCH 1/2] soc: amlogic: ee-pwrc: rename get_power Kevin Hilman
@ 2019-09-25 19:12 ` Kevin Hilman
2019-09-25 21:25 ` Kevin Hilman
1 sibling, 1 reply; 4+ messages in thread
From: Kevin Hilman @ 2019-09-25 19:12 UTC (permalink / raw)
To: linux-amlogic, Neil Armstrong; +Cc: linux-arm-kernel, linux-pm
During init, ensure that the driver on/off state as well as clock
state matches the hardware state by calling drivers on/off functions
based on whether the HW state is on/off.
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
---
drivers/soc/amlogic/meson-ee-pwrc.c | 30 +++++++++--------------------
1 file changed, 9 insertions(+), 21 deletions(-)
diff --git a/drivers/soc/amlogic/meson-ee-pwrc.c b/drivers/soc/amlogic/meson-ee-pwrc.c
index dcce8e694a07..2cb5341aedfa 100644
--- a/drivers/soc/amlogic/meson-ee-pwrc.c
+++ b/drivers/soc/amlogic/meson-ee-pwrc.c
@@ -323,6 +323,8 @@ static int meson_ee_pwrc_init_domain(struct platform_device *pdev,
struct meson_ee_pwrc *pwrc,
struct meson_ee_pwrc_domain *dom)
{
+ bool is_off;
+
dom->pwrc = pwrc;
dom->num_rstc = dom->desc.reset_names_count;
dom->num_clks = dom->desc.clk_names_count;
@@ -356,27 +358,13 @@ static int meson_ee_pwrc_init_domain(struct platform_device *pdev,
dom->base.power_on = meson_ee_pwrc_on;
dom->base.power_off = meson_ee_pwrc_off;
- /*
- * TOFIX: This is a special case for the VPU power domain, which can
- * be enabled previously by the bootloader. In this case the VPU
- * pipeline may be functional but no driver maybe never attach
- * to this power domain, and if the domain is disabled it could
- * cause system errors. This is why the pm_domain_always_on_gov
- * is used here.
- * For the same reason, the clocks should be enabled in case
- * we need to power the domain off, otherwise the internal clocks
- * prepare/enable counters won't be in sync.
- */
- if (dom->num_clks && dom->desc.is_off && !dom->desc.is_off(dom)) {
- int ret = clk_bulk_prepare_enable(dom->num_clks, dom->clks);
- if (ret)
- return ret;
-
- pm_genpd_init(&dom->base, &pm_domain_always_on_gov, false);
- } else
- pm_genpd_init(&dom->base, NULL,
- (dom->desc.is_off ?
- dom->desc.is_off(dom) : true));
+ /* Ensure that driver state matches HW state */
+ is_off = dom->desc.is_off ? dom->desc.is_off(dom) : true;
+ if (is_off)
+ meson_ee_pwrc_off(&dom->base);
+ else
+ meson_ee_pwrc_on(&dom->base);
+ pm_genpd_init(&dom->base, NULL, is_off);
return 0;
}
--
2.22.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] soc: amlogic: ee-pwrc: ensure driver state maches HW state
2019-09-25 19:12 ` [PATCH 2/2] soc: amlogic: ee-pwrc: ensure driver state maches HW state Kevin Hilman
@ 2019-09-25 21:25 ` Kevin Hilman
0 siblings, 0 replies; 4+ messages in thread
From: Kevin Hilman @ 2019-09-25 21:25 UTC (permalink / raw)
To: linux-amlogic, Neil Armstrong; +Cc: linux-arm-kernel, linux-pm
Kevin Hilman <khilman@baylibre.com> writes:
> During init, ensure that the driver on/off state as well as clock
> state matches the hardware state by calling drivers on/off functions
> based on whether the HW state is on/off.
>
> Signed-off-by: Kevin Hilman <khilman@baylibre.com>
> ---
> drivers/soc/amlogic/meson-ee-pwrc.c | 30 +++++++++--------------------
> 1 file changed, 9 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/soc/amlogic/meson-ee-pwrc.c b/drivers/soc/amlogic/meson-ee-pwrc.c
> index dcce8e694a07..2cb5341aedfa 100644
> --- a/drivers/soc/amlogic/meson-ee-pwrc.c
> +++ b/drivers/soc/amlogic/meson-ee-pwrc.c
> @@ -323,6 +323,8 @@ static int meson_ee_pwrc_init_domain(struct platform_device *pdev,
> struct meson_ee_pwrc *pwrc,
> struct meson_ee_pwrc_domain *dom)
> {
> + bool is_off;
> +
> dom->pwrc = pwrc;
> dom->num_rstc = dom->desc.reset_names_count;
> dom->num_clks = dom->desc.clk_names_count;
> @@ -356,27 +358,13 @@ static int meson_ee_pwrc_init_domain(struct platform_device *pdev,
> dom->base.power_on = meson_ee_pwrc_on;
> dom->base.power_off = meson_ee_pwrc_off;
>
> - /*
> - * TOFIX: This is a special case for the VPU power domain, which can
> - * be enabled previously by the bootloader. In this case the VPU
> - * pipeline may be functional but no driver maybe never attach
> - * to this power domain, and if the domain is disabled it could
> - * cause system errors. This is why the pm_domain_always_on_gov
> - * is used here.
> - * For the same reason, the clocks should be enabled in case
> - * we need to power the domain off, otherwise the internal clocks
> - * prepare/enable counters won't be in sync.
> - */
> - if (dom->num_clks && dom->desc.is_off && !dom->desc.is_off(dom)) {
> - int ret = clk_bulk_prepare_enable(dom->num_clks, dom->clks);
> - if (ret)
> - return ret;
> -
> - pm_genpd_init(&dom->base, &pm_domain_always_on_gov, false);
> - } else
> - pm_genpd_init(&dom->base, NULL,
> - (dom->desc.is_off ?
> - dom->desc.is_off(dom) : true));
> + /* Ensure that driver state matches HW state */
> + is_off = dom->desc.is_off ? dom->desc.is_off(dom) : true;
> + if (is_off)
> + meson_ee_pwrc_off(&dom->base);
Neil pointed out off-list that this isn't quite right.
This _off() call can potentially try to disable clocks that have never
been enabled (by the clock fwk) resulting in noisy warnings.
I'll send a v2 which always calls _on() and then optionall calls _off().
That will ensure that the drivers notion of the clock state also matches
the HW state.
Kevin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-09-25 21:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-25 19:12 [PATCH 0/2] soc: amlogic: ee-pwrc: cleanup init state Kevin Hilman
2019-09-25 19:12 ` [PATCH 1/2] soc: amlogic: ee-pwrc: rename get_power Kevin Hilman
2019-09-25 19:12 ` [PATCH 2/2] soc: amlogic: ee-pwrc: ensure driver state maches HW state Kevin Hilman
2019-09-25 21:25 ` Kevin Hilman
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).