devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] rtc: snvs: add poweroff function
@ 2014-09-25  2:13 Robin Gong
  2014-09-26  1:24 ` Shawn Guo
  0 siblings, 1 reply; 3+ messages in thread
From: Robin Gong @ 2014-09-25  2:13 UTC (permalink / raw)
  To: robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, a.zummo-BfzFCNDTiLLj+vYz1yj4TQ,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A,
	shawn.guo-KZfg59tc24xl57MIdRCFDg, kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
	LW-bxm8fMRDkQLDiMYJYoSAnRvVK+yQ3ZXh
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On i.mx6 chips, PMIC_ON_REQ can be pulled by snvs LPCR. That can be
used poweroff system if PMIC_ON_REQ connected with external PMIC or
power control circuit.Power up again if PMIC_ON_REQ pulled high.

Signed-off-by: Robin Gong <b38343-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
---
 Documentation/devicetree/bindings/crypto/fsl-sec4.txt |  4 ++++
 drivers/rtc/rtc-snvs.c                                | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/Documentation/devicetree/bindings/crypto/fsl-sec4.txt b/Documentation/devicetree/bindings/crypto/fsl-sec4.txt
index e402277..00d67f2 100644
--- a/Documentation/devicetree/bindings/crypto/fsl-sec4.txt
+++ b/Documentation/devicetree/bindings/crypto/fsl-sec4.txt
@@ -363,11 +363,15 @@ Secure Non-Volatile Storage (SNVS) Low Power (LP) RTC Node
       Value type: <prop-encoded-array>
       Definition: A standard property.  Specifies the physical
           address and length of the SNVS LP configuration registers.
+  - fsl,poweroff
+      Usage: opertional, recommend if PMIC_ON_REQ connected with external
+	PMIC or power control circuit.
 
 EXAMPLE
 	sec_mon_rtc_lp@314000 {
 		compatible = "fsl,sec-v4.0-mon-rtc-lp";
 		reg = <0x34 0x58>;
+		fsl,poweroff;
 	};
 
 =====================================================================
diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c
index fa384fe..ef32541 100644
--- a/drivers/rtc/rtc-snvs.c
+++ b/drivers/rtc/rtc-snvs.c
@@ -29,6 +29,8 @@
 #define SNVS_LPCR_SRTC_ENV	(1 << 0)
 #define SNVS_LPCR_LPTA_EN	(1 << 1)
 #define SNVS_LPCR_LPWUI_EN	(1 << 3)
+#define SNVS_LPCR_DP		(1 << 5)
+#define SNVS_LPCR_TOP		(1 << 6)
 #define SNVS_LPSR_LPTA		(1 << 0)
 
 #define SNVS_LPPGDR_INIT	0x41736166
@@ -41,6 +43,8 @@ struct snvs_rtc_data {
 	spinlock_t lock;
 };
 
+static void __iomem *snvs_base;
+
 static u32 rtc_read_lp_counter(void __iomem *ioaddr)
 {
 	u64 read1, read2;
@@ -241,8 +245,17 @@ static irqreturn_t snvs_rtc_irq_handler(int irq, void *dev_id)
 	return events ? IRQ_HANDLED : IRQ_NONE;
 }
 
+static void snvs_poweroff(void)
+{
+	u32 value;
+
+	value = readl(snvs_base + SNVS_LPCR);
+	writel(value | SNVS_LPCR_DP | SNVS_LPCR_TOP, snvs_base + SNVS_LPCR);
+}
+
 static int snvs_rtc_probe(struct platform_device *pdev)
 {
+	struct device_node *np = pdev->dev.of_node;
 	struct snvs_rtc_data *data;
 	struct resource *res;
 	int ret;
@@ -260,6 +273,11 @@ static int snvs_rtc_probe(struct platform_device *pdev)
 	if (data->irq < 0)
 		return data->irq;
 
+	if (np && of_get_property(np, "fsl,poweroff", NULL)) {
+		snvs_base = data->ioaddr;
+		pm_power_off = snvs_poweroff;
+	}
+
 	platform_set_drvdata(pdev, data);
 
 	spin_lock_init(&data->lock);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] rtc: snvs: add poweroff function
  2014-09-25  2:13 [PATCH v1] rtc: snvs: add poweroff function Robin Gong
@ 2014-09-26  1:24 ` Shawn Guo
  2014-09-26  2:21   ` Robin Gong
  0 siblings, 1 reply; 3+ messages in thread
From: Shawn Guo @ 2014-09-26  1:24 UTC (permalink / raw)
  To: Robin Gong
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak, a.zummo,
	grant.likely, kernel, LW, linux-arm-kernel, devicetree,
	linux-kernel

On Thu, Sep 25, 2014 at 10:13:53AM +0800, Robin Gong wrote:
> On i.mx6 chips, PMIC_ON_REQ can be pulled by snvs LPCR. That can be
> used poweroff system if PMIC_ON_REQ connected with external PMIC or
> power control circuit.Power up again if PMIC_ON_REQ pulled high.
> 
> Signed-off-by: Robin Gong <b38343@freescale.com>

I'm not sure it's a good idea to plug poweroff support into RTC driver.
If RTC driver is built out, poweroff function is gone too.

Shawn

> ---
>  Documentation/devicetree/bindings/crypto/fsl-sec4.txt |  4 ++++
>  drivers/rtc/rtc-snvs.c                                | 18 ++++++++++++++++++
>  2 files changed, 22 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/crypto/fsl-sec4.txt b/Documentation/devicetree/bindings/crypto/fsl-sec4.txt
> index e402277..00d67f2 100644
> --- a/Documentation/devicetree/bindings/crypto/fsl-sec4.txt
> +++ b/Documentation/devicetree/bindings/crypto/fsl-sec4.txt
> @@ -363,11 +363,15 @@ Secure Non-Volatile Storage (SNVS) Low Power (LP) RTC Node
>        Value type: <prop-encoded-array>
>        Definition: A standard property.  Specifies the physical
>            address and length of the SNVS LP configuration registers.
> +  - fsl,poweroff
> +      Usage: opertional, recommend if PMIC_ON_REQ connected with external
> +	PMIC or power control circuit.
>  
>  EXAMPLE
>  	sec_mon_rtc_lp@314000 {
>  		compatible = "fsl,sec-v4.0-mon-rtc-lp";
>  		reg = <0x34 0x58>;
> +		fsl,poweroff;
>  	};
>  
>  =====================================================================
> diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c
> index fa384fe..ef32541 100644
> --- a/drivers/rtc/rtc-snvs.c
> +++ b/drivers/rtc/rtc-snvs.c
> @@ -29,6 +29,8 @@
>  #define SNVS_LPCR_SRTC_ENV	(1 << 0)
>  #define SNVS_LPCR_LPTA_EN	(1 << 1)
>  #define SNVS_LPCR_LPWUI_EN	(1 << 3)
> +#define SNVS_LPCR_DP		(1 << 5)
> +#define SNVS_LPCR_TOP		(1 << 6)
>  #define SNVS_LPSR_LPTA		(1 << 0)
>  
>  #define SNVS_LPPGDR_INIT	0x41736166
> @@ -41,6 +43,8 @@ struct snvs_rtc_data {
>  	spinlock_t lock;
>  };
>  
> +static void __iomem *snvs_base;
> +
>  static u32 rtc_read_lp_counter(void __iomem *ioaddr)
>  {
>  	u64 read1, read2;
> @@ -241,8 +245,17 @@ static irqreturn_t snvs_rtc_irq_handler(int irq, void *dev_id)
>  	return events ? IRQ_HANDLED : IRQ_NONE;
>  }
>  
> +static void snvs_poweroff(void)
> +{
> +	u32 value;
> +
> +	value = readl(snvs_base + SNVS_LPCR);
> +	writel(value | SNVS_LPCR_DP | SNVS_LPCR_TOP, snvs_base + SNVS_LPCR);
> +}
> +
>  static int snvs_rtc_probe(struct platform_device *pdev)
>  {
> +	struct device_node *np = pdev->dev.of_node;
>  	struct snvs_rtc_data *data;
>  	struct resource *res;
>  	int ret;
> @@ -260,6 +273,11 @@ static int snvs_rtc_probe(struct platform_device *pdev)
>  	if (data->irq < 0)
>  		return data->irq;
>  
> +	if (np && of_get_property(np, "fsl,poweroff", NULL)) {
> +		snvs_base = data->ioaddr;
> +		pm_power_off = snvs_poweroff;
> +	}
> +
>  	platform_set_drvdata(pdev, data);
>  
>  	spin_lock_init(&data->lock);
> -- 
> 1.9.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] rtc: snvs: add poweroff function
  2014-09-26  1:24 ` Shawn Guo
@ 2014-09-26  2:21   ` Robin Gong
  0 siblings, 0 replies; 3+ messages in thread
From: Robin Gong @ 2014-09-26  2:21 UTC (permalink / raw)
  To: Shawn Guo
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak, a.zummo,
	grant.likely, kernel, LW, linux-arm-kernel, devicetree,
	linux-kernel

On Fri, Sep 26, 2014 at 09:24:11AM +0800, Shawn Guo wrote:
> On Thu, Sep 25, 2014 at 10:13:53AM +0800, Robin Gong wrote:
> > On i.mx6 chips, PMIC_ON_REQ can be pulled by snvs LPCR. That can be
> > used poweroff system if PMIC_ON_REQ connected with external PMIC or
> > power control circuit.Power up again if PMIC_ON_REQ pulled high.
> > 
> > Signed-off-by: Robin Gong <b38343@freescale.com>
> 
> I'm not sure it's a good idea to plug poweroff support into RTC driver.
> If RTC driver is built out, poweroff function is gone too.
> 
> Shawn
>
Yes, that's true since there is no real SNVS driver, only snvs-rtc and
snvs-caam driver. I'll pick up the patch about the driver which located
in drivers/power/reset.
> > ---
> >  Documentation/devicetree/bindings/crypto/fsl-sec4.txt |  4 ++++
> >  drivers/rtc/rtc-snvs.c                                | 18 ++++++++++++++++++
> >  2 files changed, 22 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/crypto/fsl-sec4.txt b/Documentation/devicetree/bindings/crypto/fsl-sec4.txt
> > index e402277..00d67f2 100644
> > --- a/Documentation/devicetree/bindings/crypto/fsl-sec4.txt
> > +++ b/Documentation/devicetree/bindings/crypto/fsl-sec4.txt
> > @@ -363,11 +363,15 @@ Secure Non-Volatile Storage (SNVS) Low Power (LP) RTC Node
> >        Value type: <prop-encoded-array>
> >        Definition: A standard property.  Specifies the physical
> >            address and length of the SNVS LP configuration registers.
> > +  - fsl,poweroff
> > +      Usage: opertional, recommend if PMIC_ON_REQ connected with external
> > +	PMIC or power control circuit.
> >  
> >  EXAMPLE
> >  	sec_mon_rtc_lp@314000 {
> >  		compatible = "fsl,sec-v4.0-mon-rtc-lp";
> >  		reg = <0x34 0x58>;
> > +		fsl,poweroff;
> >  	};
> >  
> >  =====================================================================
> > diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c
> > index fa384fe..ef32541 100644
> > --- a/drivers/rtc/rtc-snvs.c
> > +++ b/drivers/rtc/rtc-snvs.c
> > @@ -29,6 +29,8 @@
> >  #define SNVS_LPCR_SRTC_ENV	(1 << 0)
> >  #define SNVS_LPCR_LPTA_EN	(1 << 1)
> >  #define SNVS_LPCR_LPWUI_EN	(1 << 3)
> > +#define SNVS_LPCR_DP		(1 << 5)
> > +#define SNVS_LPCR_TOP		(1 << 6)
> >  #define SNVS_LPSR_LPTA		(1 << 0)
> >  
> >  #define SNVS_LPPGDR_INIT	0x41736166
> > @@ -41,6 +43,8 @@ struct snvs_rtc_data {
> >  	spinlock_t lock;
> >  };
> >  
> > +static void __iomem *snvs_base;
> > +
> >  static u32 rtc_read_lp_counter(void __iomem *ioaddr)
> >  {
> >  	u64 read1, read2;
> > @@ -241,8 +245,17 @@ static irqreturn_t snvs_rtc_irq_handler(int irq, void *dev_id)
> >  	return events ? IRQ_HANDLED : IRQ_NONE;
> >  }
> >  
> > +static void snvs_poweroff(void)
> > +{
> > +	u32 value;
> > +
> > +	value = readl(snvs_base + SNVS_LPCR);
> > +	writel(value | SNVS_LPCR_DP | SNVS_LPCR_TOP, snvs_base + SNVS_LPCR);
> > +}
> > +
> >  static int snvs_rtc_probe(struct platform_device *pdev)
> >  {
> > +	struct device_node *np = pdev->dev.of_node;
> >  	struct snvs_rtc_data *data;
> >  	struct resource *res;
> >  	int ret;
> > @@ -260,6 +273,11 @@ static int snvs_rtc_probe(struct platform_device *pdev)
> >  	if (data->irq < 0)
> >  		return data->irq;
> >  
> > +	if (np && of_get_property(np, "fsl,poweroff", NULL)) {
> > +		snvs_base = data->ioaddr;
> > +		pm_power_off = snvs_poweroff;
> > +	}
> > +
> >  	platform_set_drvdata(pdev, data);
> >  
> >  	spin_lock_init(&data->lock);
> > -- 
> > 1.9.1
> > 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-26  2:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-25  2:13 [PATCH v1] rtc: snvs: add poweroff function Robin Gong
2014-09-26  1:24 ` Shawn Guo
2014-09-26  2:21   ` Robin Gong

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).