2015-08-25 06:01:13

by Eddie Huang (黃智傑)

[permalink] [raw]
Subject: [PATCH v2] soc: mediatek: add scpsys support active_wakeup

Register gpd_dev_ops.active_wakeup function to support keep power
during suspend state. And add flag to each power domain to
decide whether keep power during suspend or not.

Signed-off-by: Chunfeng Yun <[email protected]>
Signed-off-by: Eddie Huang <[email protected]>
Acked-by: Sascha Hauer <[email protected]>

---
Change in v2:
Drop .active_wakeup = false lines in scp_domain_data[] array

---
drivers/soc/mediatek/mtk-scpsys.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c
index 43a79ed..df2f288 100644
--- a/drivers/soc/mediatek/mtk-scpsys.c
+++ b/drivers/soc/mediatek/mtk-scpsys.c
@@ -67,6 +67,7 @@ struct scp_domain_data {
u32 sram_pdn_ack_bits;
u32 bus_prot_mask;
enum clk_id clk_id;
+ bool active_wakeup;
};

static const struct scp_domain_data scp_domain_data[] __initconst = {
@@ -127,6 +128,7 @@ static const struct scp_domain_data scp_domain_data[] __initconst = {
.sram_pdn_bits = GENMASK(11, 8),
.sram_pdn_ack_bits = GENMASK(15, 12),
.clk_id = MT8173_CLK_NONE,
+ .active_wakeup = true,
},
[MT8173_POWER_DOMAIN_MFG_ASYNC] = {
.name = "mfg_async",
@@ -171,6 +173,7 @@ struct scp_domain {
u32 sram_pdn_bits;
u32 sram_pdn_ack_bits;
u32 bus_prot_mask;
+ bool active_wakeup;
};

struct scp {
@@ -370,6 +373,20 @@ out:
return ret;
}

+static bool scpsys_active_wakeup(struct device *dev)
+{
+ struct generic_pm_domain *genpd;
+ struct scp_domain *scpd;
+
+ if (IS_ERR_OR_NULL(dev->pm_domain))
+ return false;
+
+ genpd = pd_to_genpd(dev->pm_domain);
+ scpd = container_of(genpd, struct scp_domain, genpd);
+
+ return scpd->active_wakeup;
+}
+
static int __init scpsys_probe(struct platform_device *pdev)
{
struct genpd_onecell_data *pd_data;
@@ -427,12 +444,14 @@ static int __init scpsys_probe(struct platform_device *pdev)
scpd->sram_pdn_bits = data->sram_pdn_bits;
scpd->sram_pdn_ack_bits = data->sram_pdn_ack_bits;
scpd->bus_prot_mask = data->bus_prot_mask;
+ scpd->active_wakeup = data->active_wakeup;
if (data->clk_id != MT8173_CLK_NONE)
scpd->clk = clk[data->clk_id];

genpd->name = data->name;
genpd->power_off = scpsys_power_off;
genpd->power_on = scpsys_power_on;
+ genpd->dev_ops.active_wakeup = scpsys_active_wakeup;

/*
* Initially turn on all domains to make the domains usable
--
1.9.1


2015-08-25 21:12:11

by Daniel Kurtz

[permalink] [raw]
Subject: Re: [PATCH v2] soc: mediatek: add scpsys support active_wakeup

Hi Eddie,

On Tue, Aug 25, 2015 at 2:00 PM, Eddie Huang <[email protected]> wrote:
> Register gpd_dev_ops.active_wakeup function to support keep power
> during suspend state. And add flag to each power domain to
> decide whether keep power during suspend or not.
>
> Signed-off-by: Chunfeng Yun <[email protected]>
> Signed-off-by: Eddie Huang <[email protected]>
> Acked-by: Sascha Hauer <[email protected]>
>
> ---
> Change in v2:
> Drop .active_wakeup = false lines in scp_domain_data[] array
>
> ---
> drivers/soc/mediatek/mtk-scpsys.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c
> index 43a79ed..df2f288 100644
> --- a/drivers/soc/mediatek/mtk-scpsys.c
> +++ b/drivers/soc/mediatek/mtk-scpsys.c
> @@ -67,6 +67,7 @@ struct scp_domain_data {
> u32 sram_pdn_ack_bits;
> u32 bus_prot_mask;
> enum clk_id clk_id;
> + bool active_wakeup;
> };
>
> static const struct scp_domain_data scp_domain_data[] __initconst = {
> @@ -127,6 +128,7 @@ static const struct scp_domain_data scp_domain_data[] __initconst = {
> .sram_pdn_bits = GENMASK(11, 8),
> .sram_pdn_ack_bits = GENMASK(15, 12),
> .clk_id = MT8173_CLK_NONE,
> + .active_wakeup = true,
> },
> [MT8173_POWER_DOMAIN_MFG_ASYNC] = {
> .name = "mfg_async",
> @@ -171,6 +173,7 @@ struct scp_domain {
> u32 sram_pdn_bits;
> u32 sram_pdn_ack_bits;
> u32 bus_prot_mask;
> + bool active_wakeup;
> };
>
> struct scp {
> @@ -370,6 +373,20 @@ out:
> return ret;
> }
>
> +static bool scpsys_active_wakeup(struct device *dev)
> +{
> + struct generic_pm_domain *genpd;
> + struct scp_domain *scpd;
> +
> + if (IS_ERR_OR_NULL(dev->pm_domain))
> + return false;

Is it really possible to get here w/ pm_domain as an ERR or NULL?
If the power core can ensure this cannot happen, then this function
could be a bit simpler.

Other than that, this patch is:
Reviewed-by: Daniel Kurtz <[email protected]>

-Dan

> +
> + genpd = pd_to_genpd(dev->pm_domain);
> + scpd = container_of(genpd, struct scp_domain, genpd);
> +
> + return scpd->active_wakeup;
> +}

2015-08-26 06:55:14

by Eddie Huang (黃智傑)

[permalink] [raw]
Subject: Re: [PATCH v2] soc: mediatek: add scpsys support active_wakeup

On Wed, 2015-08-26 at 05:11 +0800, Daniel Kurtz wrote:
> Hi Eddie,
>
> On Tue, Aug 25, 2015 at 2:00 PM, Eddie Huang <[email protected]> wrote:
> > Register gpd_dev_ops.active_wakeup function to support keep power
> > during suspend state. And add flag to each power domain to
> > decide whether keep power during suspend or not.
> >
> > Signed-off-by: Chunfeng Yun <[email protected]>
> > Signed-off-by: Eddie Huang <[email protected]>
> > Acked-by: Sascha Hauer <[email protected]>
> >
> > ---
> > Change in v2:
> > Drop .active_wakeup = false lines in scp_domain_data[] array
> >
> > ---
> > drivers/soc/mediatek/mtk-scpsys.c | 19 +++++++++++++++++++
> > 1 file changed, 19 insertions(+)
> >
> > diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c
> > index 43a79ed..df2f288 100644
> > --- a/drivers/soc/mediatek/mtk-scpsys.c
> > +++ b/drivers/soc/mediatek/mtk-scpsys.c
> > @@ -67,6 +67,7 @@ struct scp_domain_data {
> > u32 sram_pdn_ack_bits;
> > u32 bus_prot_mask;
> > enum clk_id clk_id;
> > + bool active_wakeup;
> > };
> >
> > static const struct scp_domain_data scp_domain_data[] __initconst = {
> > @@ -127,6 +128,7 @@ static const struct scp_domain_data scp_domain_data[] __initconst = {
> > .sram_pdn_bits = GENMASK(11, 8),
> > .sram_pdn_ack_bits = GENMASK(15, 12),
> > .clk_id = MT8173_CLK_NONE,
> > + .active_wakeup = true,
> > },
> > [MT8173_POWER_DOMAIN_MFG_ASYNC] = {
> > .name = "mfg_async",
> > @@ -171,6 +173,7 @@ struct scp_domain {
> > u32 sram_pdn_bits;
> > u32 sram_pdn_ack_bits;
> > u32 bus_prot_mask;
> > + bool active_wakeup;
> > };
> >
> > struct scp {
> > @@ -370,6 +373,20 @@ out:
> > return ret;
> > }
> >
> > +static bool scpsys_active_wakeup(struct device *dev)
> > +{
> > + struct generic_pm_domain *genpd;
> > + struct scp_domain *scpd;
> > +
> > + if (IS_ERR_OR_NULL(dev->pm_domain))
> > + return false;
>
> Is it really possible to get here w/ pm_domain as an ERR or NULL?
> If the power core can ensure this cannot happen, then this function
> could be a bit simpler.
>
> Other than that, this patch is:
> Reviewed-by: Daniel Kurtz <[email protected]>
>
> -Dan
>

After checking drivers/base/power/domain.c, I believe check
dev->pm_domain here is redundant, I will remove it.

Eddie
Thanks