linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Zhao Chenhui <chenhui.zhao@freescale.com>
To: Scott Wood <scottwood@freescale.com>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 4/5] fsl_pmc: Add API to enable device as wakeup event source
Date: Mon, 4 Jun 2012 19:36:09 +0800	[thread overview]
Message-ID: <20120604113609.GC20676@localhost.localdomain> (raw)
In-Reply-To: <4FC93D74.3090200@freescale.com>

On Fri, Jun 01, 2012 at 05:08:52PM -0500, Scott Wood wrote:
> On 05/11/2012 06:53 AM, Zhao Chenhui wrote:
> > Add APIs for setting wakeup source and lossless Ethernet in low power modes.
> > These APIs can be used by wake-on-packet feature.
> > 
> > Signed-off-by: Dave Liu <daveliu@freescale.com>
> > Signed-off-by: Li Yang <leoli@freescale.com>
> > Signed-off-by: Jin Qing <b24347@freescale.com>
> > Signed-off-by: Zhao Chenhui <chenhui.zhao@freescale.com>
> > ---
> >  arch/powerpc/sysdev/fsl_pmc.c |   71 ++++++++++++++++++++++++++++++++++++++++-
> >  arch/powerpc/sysdev/fsl_soc.h |    9 +++++
> >  2 files changed, 79 insertions(+), 1 deletions(-)
> > 
> > diff --git a/arch/powerpc/sysdev/fsl_pmc.c b/arch/powerpc/sysdev/fsl_pmc.c
> > index 1dc6e9e..c1170f7 100644
> > --- a/arch/powerpc/sysdev/fsl_pmc.c
> > +++ b/arch/powerpc/sysdev/fsl_pmc.c
> > @@ -34,6 +34,7 @@ struct pmc_regs {
> >  	__be32 powmgtcsr;
> >  #define POWMGTCSR_SLP		0x00020000
> >  #define POWMGTCSR_DPSLP		0x00100000
> > +#define POWMGTCSR_LOSSLESS	0x00400000
> >  	__be32 res3[2];
> >  	__be32 pmcdr;
> >  };
> > @@ -43,6 +44,74 @@ static unsigned int pmc_flag;
> >  
> >  #define PMC_SLEEP	0x1
> >  #define PMC_DEEP_SLEEP	0x2
> > +#define PMC_LOSSLESS	0x4
> > +
> > +/**
> > + * mpc85xx_pmc_set_wake - enable devices as wakeup event source
> > + * @pdev: platform device affected
> > + * @enable: True to enable event generation; false to disable
> > + *
> > + * This enables the device as a wakeup event source, or disables it.
> > + *
> > + * RETURN VALUE:
> > + * 0 is returned on success
> > + * -EINVAL is returned if device is not supposed to wake up the system
> > + * Error code depending on the platform is returned if both the platform and
> > + * the native mechanism fail to enable the generation of wake-up events
> > + */
> > +int mpc85xx_pmc_set_wake(struct platform_device *pdev, bool enable)
> 
> Why does it have to be a platform_device?  Would a bare device_node work
> here?  If it's for stuff like device_may_wakeup() that could be in a
> platform_device wrapper function.

It does not have to be a platform_device. I think it can be a struct device.

> 
> Where does this get called from?  I don't see an example user in this
> patchset.

It will be used by a gianfar related patch. I plan to submit that patch
after these patches accepted.

> 
> > +{
> > +	int ret = 0;
> > +	struct device_node *clk_np;
> > +	u32 *prop;
> > +	u32 pmcdr_mask;
> > +
> > +	if (!pmc_regs) {
> > +		pr_err("%s: PMC is unavailable\n", __func__);
> > +		return -ENODEV;
> > +	}
> > +
> > +	if (enable && !device_may_wakeup(&pdev->dev))
> > +		return -EINVAL;
> 
> Who is setting can_wakeup for these devices?

The device driver is responsible to set can_wakeup.

> 
> > +	clk_np = of_parse_phandle(pdev->dev.of_node, "fsl,pmc-handle", 0);
> > +	if (!clk_np)
> > +		return -EINVAL;
> > +
> > +	prop = (u32 *)of_get_property(clk_np, "fsl,pmcdr-mask", NULL);
> 
> Don't cast the const away.

OK.

> 
> > +	if (!prop) {
> > +		ret = -EINVAL;
> > +		goto out;
> > +	}
> > +	pmcdr_mask = be32_to_cpup(prop);
> > +
> > +	if (enable)
> > +		/* clear to enable clock in low power mode */
> > +		clrbits32(&pmc_regs->pmcdr, pmcdr_mask);
> > +	else
> > +		setbits32(&pmc_regs->pmcdr, pmcdr_mask);
> 
> What is the default PMCDR if this function is never called?  Should init
> to all bits set on PM driver probe (or maybe limit it to defined bits
> only, though that's a little harder to do generically).
> 
> -Scot

The default PMCDR is defined separately by individual chip.
I agree with you. I will have a try.

-Chenhui

  reply	other threads:[~2012-06-04 11:35 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-11 11:53 [PATCH v5 1/5] powerpc/85xx: implement hardware timebase sync Zhao Chenhui
2012-05-11 11:53 ` [PATCH v5 2/5] powerpc/85xx: add HOTPLUG_CPU support Zhao Chenhui
2012-06-01 21:27   ` Scott Wood
2012-06-04 11:04     ` Zhao Chenhui
2012-06-04 16:32       ` Scott Wood
2012-06-05 11:18         ` Zhao Chenhui
2012-06-05 16:15           ` Scott Wood
2012-06-06  9:59             ` Zhao Chenhui
2012-06-06 18:19               ` Scott Wood
2012-05-11 11:53 ` [PATCH v5 3/5] powerpc/85xx: add sleep and deep sleep support Zhao Chenhui
2012-06-01 21:54   ` Scott Wood
2012-06-04 11:12     ` Zhao Chenhui
2012-06-04 22:58       ` Scott Wood
2012-06-05 11:35         ` Zhao Chenhui
2012-06-05 16:13           ` Scott Wood
2012-05-11 11:53 ` [PATCH v5 4/5] fsl_pmc: Add API to enable device as wakeup event source Zhao Chenhui
2012-06-01 22:08   ` Scott Wood
2012-06-04 11:36     ` Zhao Chenhui [this message]
2012-06-04 23:02       ` Scott Wood
2012-06-05  4:08         ` Li Yang-R58472
2012-06-05 16:11           ` Scott Wood
2012-06-05 16:49             ` Li Yang-R58472
2012-06-05 18:05               ` Scott Wood
2012-06-06  4:06                 ` Li Yang
2012-06-06 18:29                   ` Scott Wood
2012-06-07  4:10                     ` Li Yang
2012-05-11 11:53 ` [PATCH v5 5/5] powerpc/85xx: add support to JOG feature using cpufreq interface Zhao Chenhui
2012-06-01 23:30   ` Scott Wood
2012-06-05 10:59     ` Zhao Chenhui
2012-06-05 15:58       ` Scott Wood
2012-06-06 10:19         ` Zhao Chenhui
2012-05-29  7:30 ` [PATCH v5 1/5] powerpc/85xx: implement hardware timebase sync Li Yang
2012-05-29 12:20 ` [linuxppc-release] " Zhao Chenhui-B35336
2012-06-01 15:40 ` Scott Wood
2012-06-05  9:08   ` Zhao Chenhui
2012-06-05 16:07     ` Scott Wood
2012-06-06  9:31       ` Zhao Chenhui
2012-06-06 18:26         ` Scott Wood
2012-06-07  4:07           ` Zhao Chenhui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120604113609.GC20676@localhost.localdomain \
    --to=chenhui.zhao@freescale.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=scottwood@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).