devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: omap: Support ext_wakeup configuration
@ 2016-04-04 15:56 Marcin Niestroj
       [not found] ` <1459785403-1725-1-git-send-email-m.niestroj-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Marcin Niestroj @ 2016-04-04 15:56 UTC (permalink / raw)
  To: rtc-linux-/JYPxA39Uh5TLH3MbocFFw, devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: Rob Herring, Pawel Moll, Alessandro Zummo, Alexandre Belloni,
	Keerthy, Tony Lindgren, Marcin Niestroj

Support configuration of ext_wakeup sources. This patch makes it
possible to enable ext_wakeup and set it's polarity, depending on board
configuration. AM335x's dedicated PMIC (tps65217) uses ext_wakeup to
notify about power-button presses. Handling power-button presses enables
to recover from RTC-only power states correctly.

Signed-off-by: Marcin Niestroj <m.niestroj-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org>
---
 Documentation/devicetree/bindings/rtc/rtc-omap.txt | 24 ++++++++++-
 drivers/rtc/rtc-omap.c                             | 46 +++++++++++++++++++++-
 2 files changed, 68 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/rtc/rtc-omap.txt b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
index bf7d11a..1c05311b 100644
--- a/Documentation/devicetree/bindings/rtc/rtc-omap.txt
+++ b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
@@ -18,8 +18,20 @@ Optional properties:
   through pmic_power_en
 - clocks: Any internal or external clocks feeding in to rtc
 - clock-names: Corresponding names of the clocks
+- ti,ext-wakeup-en: Enables ext_wakeup[n] sources. Value determines which
+		    ext_wakeup is enabled by bitwise OR of corresponding bits.
+		    Examples:
+		     <1> - enabled ext_wakeup[0],
+		     <2> - enabled ext_wakeup[1],
+		     <3> - enabled ext_wakeup[0] and enabled ext_wakeup[1],
+		     ...
+- ti,ext-wakeup-pol: Sets polarity of ext_wakeup[n] sources, similarly as
+		     above. Set bit means active-low, unset bit means
+		     active-high. Examples:
+		      <1> - only ext_wakeup0 is active-low
+		      <3> - only ext_wakeup0 and ext_wakeup1 are active-low
 
-Example:
+Examples:
 
 rtc@1c23000 {
 	compatible = "ti,da830-rtc";
@@ -31,3 +43,13 @@ rtc@1c23000 {
 	clocks = <&clk_32k_rtc>, <&clk_32768_ck>;
 	clock-names = "ext-clk", "int-clk";
 };
+
+rtc@44e3e000 {
+	compatible = "ti,am3352-rtc", "ti,da830-rtc";
+	reg = <0x44e3e000 0x1000>;
+	interrupts = <75
+		      76>;
+	system-power-controller;
+	ti,ext-wakeup-en = <1>;
+	ti,ext-wakeup-pol = <1>;
+};
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index ec2e9c5..1a46f5d 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -114,7 +114,11 @@
 #define OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN	BIT(1)
 
 /* OMAP_RTC_PMIC bit fields: */
-#define OMAP_RTC_PMIC_POWER_EN_EN	BIT(16)
+#define OMAP_RTC_PMIC_POWER_EN_EN		BIT(16)
+#define OMAP_RTC_PMIC_EXT_WAKEUP_EN(x)		(x)
+#define OMAP_RTC_PMIC_EXT_WAKEUP_POL(x)		((x) << 4)
+#define OMAP_RTC_PMIC_EXT_WAKEUP_EN_MASK	0x0F
+#define OMAP_RTC_PMIC_EXT_WAKEUP_POL_MASK	0xF0
 
 /* OMAP_RTC_KICKER values */
 #define	KICK0_VALUE			0x83e70b13
@@ -533,6 +537,11 @@ static int omap_rtc_probe(struct platform_device *pdev)
 	const struct platform_device_id *id_entry;
 	const struct of_device_id *of_id;
 	int ret;
+	u32 ext_wakeup_en;
+	u32 ext_wakeup_pol;
+	bool has_ext_wakeup_en;
+	bool has_ext_wakeup_pol;
+	u32 val;
 
 	rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
 	if (!rtc)
@@ -544,6 +553,30 @@ static int omap_rtc_probe(struct platform_device *pdev)
 		rtc->is_pmic_controller = rtc->type->has_pmic_mode &&
 				of_property_read_bool(pdev->dev.of_node,
 						"system-power-controller");
+		if (of_property_read_u32(pdev->dev.of_node,
+						"ti,ext-wakeup-en",
+						&ext_wakeup_en) >= 0) {
+			if (ext_wakeup_en < BIT(4))
+				has_ext_wakeup_en = true;
+			else
+				dev_err(&pdev->dev,
+					"wrong ext-wakeup-en value\n");
+		} else {
+			dev_err(&pdev->dev,
+				"no ext-wakeup-en\n");
+		}
+		if (of_property_read_u32(pdev->dev.of_node,
+						"ti,ext-wakeup-pol",
+						&ext_wakeup_pol) >= 0) {
+			if (ext_wakeup_pol < BIT(4))
+				has_ext_wakeup_pol = true;
+			else
+				dev_err(&pdev->dev,
+					"wrong ext-wakeup-pol value\n");
+		} else {
+			dev_err(&pdev->dev,
+				"no ext-wakeup-pol\n");
+		}
 	} else {
 		id_entry = platform_get_device_id(pdev);
 		rtc->type = (void *)id_entry->driver_data;
@@ -650,6 +683,17 @@ static int omap_rtc_probe(struct platform_device *pdev)
 			  reg | OMAP_RTC_OSC_SEL_32KCLK_SRC);
 	}
 
+	if (has_ext_wakeup_en || has_ext_wakeup_pol) {
+		val = rtc_readl(rtc, OMAP_RTC_PMIC_REG);
+		if (has_ext_wakeup_en)
+			val = (val & ~OMAP_RTC_PMIC_EXT_WAKEUP_EN_MASK)
+				| OMAP_RTC_PMIC_EXT_WAKEUP_EN(ext_wakeup_en);
+		if (has_ext_wakeup_pol)
+			val = (val & ~OMAP_RTC_PMIC_EXT_WAKEUP_POL_MASK)
+				| OMAP_RTC_PMIC_EXT_WAKEUP_POL(ext_wakeup_pol);
+		rtc_writel(rtc, OMAP_RTC_PMIC_REG, val);
+	}
+
 	rtc->type->lock(rtc);
 
 	device_init_wakeup(&pdev->dev, true);
-- 
2.8.0

--
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] 15+ messages in thread

* Re: [PATCH] rtc: omap: Support ext_wakeup configuration
       [not found] ` <1459785403-1725-1-git-send-email-m.niestroj-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org>
@ 2016-04-04 22:40   ` Tony Lindgren
       [not found]     ` <20160404224046.GA17042-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Tony Lindgren @ 2016-04-04 22:40 UTC (permalink / raw)
  To: Marcin Niestroj
  Cc: rtc-linux-/JYPxA39Uh5TLH3MbocFFw,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Pawel Moll,
	Alessandro Zummo, Alexandre Belloni, Keerthy,
	linux-omap-u79uwXL29TY76Z2rM5mHXA

Hi,

* Marcin Niestroj <m.niestroj-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org> [160404 08:57]:
> Support configuration of ext_wakeup sources. This patch makes it
> possible to enable ext_wakeup and set it's polarity, depending on board
> configuration. AM335x's dedicated PMIC (tps65217) uses ext_wakeup to
> notify about power-button presses. Handling power-button presses enables
> to recover from RTC-only power states correctly.

I suggest you just set this pin up as a minimal gpiochip. That way
we can use the standard binding :) And if we get lucky, this pin can
also trigger during runtime.

Regards,

Tony
--
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	[flat|nested] 15+ messages in thread

* Re: [PATCH] rtc: omap: Support ext_wakeup configuration
       [not found]     ` <20160404224046.GA17042-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
@ 2016-04-08 10:40       ` Grygorii Strashko
       [not found]         ` <57078A89.3080809-l0cyMroinI0@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Grygorii Strashko @ 2016-04-08 10:40 UTC (permalink / raw)
  To: Tony Lindgren, Marcin Niestroj
  Cc: rtc-linux-/JYPxA39Uh5TLH3MbocFFw,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Pawel Moll,
	Alessandro Zummo, Alexandre Belloni, Keerthy,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Dave Gerlach, Menon, Nishanth

Hi Tony,

On 04/05/2016 01:40 AM, Tony Lindgren wrote:
> Hi,
> 
> * Marcin Niestroj <m.niestroj-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org> [160404 08:57]:
>> Support configuration of ext_wakeup sources. This patch makes it
>> possible to enable ext_wakeup and set it's polarity, depending on board
>> configuration. AM335x's dedicated PMIC (tps65217) uses ext_wakeup to
>> notify about power-button presses. Handling power-button presses enables
>> to recover from RTC-only power states correctly.
> 
> I suggest you just set this pin up as a minimal gpiochip. That way
> we can use the standard binding :) And if we get lucky, this pin can
> also trigger during runtime.
> 

Following my comments on v2 of this patch I propose to rollback to
this version of the patch.

It seems doesn't fit in gpiochip, it's more likely irqchip, but since
rtc can't generate IRQ there are nor reasons for these genetic
experiments and RTC's specific bindings looks more suitable, at least for me.


-- 
regards,
-grygorii
--
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	[flat|nested] 15+ messages in thread

* Re: [PATCH] rtc: omap: Support ext_wakeup configuration
       [not found]         ` <57078A89.3080809-l0cyMroinI0@public.gmane.org>
@ 2016-04-08 15:14           ` Tony Lindgren
       [not found]             ` <20160408151408.GS16484-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Tony Lindgren @ 2016-04-08 15:14 UTC (permalink / raw)
  To: Grygorii Strashko
  Cc: Marcin Niestroj, rtc-linux-/JYPxA39Uh5TLH3MbocFFw,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Pawel Moll,
	Alessandro Zummo, Alexandre Belloni, Keerthy,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Dave Gerlach, Menon, Nishanth

* Grygorii Strashko <grygorii.strashko-l0cyMroinI0@public.gmane.org> [160408 03:41]:
> Hi Tony,
> 
> On 04/05/2016 01:40 AM, Tony Lindgren wrote:
> > Hi,
> > 
> > * Marcin Niestroj <m.niestroj-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org> [160404 08:57]:
> >> Support configuration of ext_wakeup sources. This patch makes it
> >> possible to enable ext_wakeup and set it's polarity, depending on board
> >> configuration. AM335x's dedicated PMIC (tps65217) uses ext_wakeup to
> >> notify about power-button presses. Handling power-button presses enables
> >> to recover from RTC-only power states correctly.
> > 
> > I suggest you just set this pin up as a minimal gpiochip. That way
> > we can use the standard binding :) And if we get lucky, this pin can
> > also trigger during runtime.
> > 
> 
> Following my comments on v2 of this patch I propose to rollback to
> this version of the patch.
> 
> It seems doesn't fit in gpiochip, it's more likely irqchip, but since
> rtc can't generate IRQ there are nor reasons for these genetic
> experiments and RTC's specific bindings looks more suitable, at least for me.

Hmm well gpiochips typically are irqchip too. IMO the generic binding
here sounds like "gpio-wakeup" as it's an input with polarity and with
an optional interrupt.

Plain irqchip would work too in this case if there are no other GPIO
specific features. Some other RTCs may have more GPIO like features.

In any case, setting the ext_wakeup up as an irqchip means that the
RTC controller can be used as a dedicated wakeirq with Linux :)

Are you guys sure there's no wake pin events during runtime? AFAIK
the RTCs just typically produce an interrupt when programmed to
do so, they don't know the state of the SoC.

Regards,

Tony
--
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	[flat|nested] 15+ messages in thread

* Re: [PATCH] rtc: omap: Support ext_wakeup configuration
       [not found]             ` <20160408151408.GS16484-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
@ 2016-04-08 17:16               ` Grygorii Strashko
       [not found]                 ` <5707E764.7050204-l0cyMroinI0@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Grygorii Strashko @ 2016-04-08 17:16 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Marcin Niestroj, rtc-linux-/JYPxA39Uh5TLH3MbocFFw,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Pawel Moll,
	Alessandro Zummo, Alexandre Belloni, Keerthy,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Dave Gerlach, Menon, Nishanth

On 04/08/2016 06:14 PM, Tony Lindgren wrote:
> * Grygorii Strashko <grygorii.strashko-l0cyMroinI0@public.gmane.org> [160408 03:41]:
>> Hi Tony,
>>
>> On 04/05/2016 01:40 AM, Tony Lindgren wrote:
>>> Hi,
>>>
>>> * Marcin Niestroj <m.niestroj-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org> [160404 08:57]:
>>>> Support configuration of ext_wakeup sources. This patch makes it
>>>> possible to enable ext_wakeup and set it's polarity, depending on board
>>>> configuration. AM335x's dedicated PMIC (tps65217) uses ext_wakeup to
>>>> notify about power-button presses. Handling power-button presses enables
>>>> to recover from RTC-only power states correctly.
>>>
>>> I suggest you just set this pin up as a minimal gpiochip. That way
>>> we can use the standard binding :) And if we get lucky, this pin can
>>> also trigger during runtime.
>>>
>>
>> Following my comments on v2 of this patch I propose to rollback to
>> this version of the patch.
>>
>> It seems doesn't fit in gpiochip, it's more likely irqchip, but since
>> rtc can't generate IRQ there are nor reasons for these genetic
>> experiments and RTC's specific bindings looks more suitable, at least for me.
> 
> Hmm well gpiochips typically are irqchip too. IMO the generic binding
> here sounds like "gpio-wakeup" as it's an input with polarity and with
> an optional interrupt.
> 
> Plain irqchip would work too in this case if there are no other GPIO
> specific features. Some other RTCs may have more GPIO like features.
> 
> In any case, setting the ext_wakeup up as an irqchip means that the
> RTC controller can be used as a dedicated wakeirq with Linux :)

It can't :( It can't generate IRQ when state of ext_wakeup line has 
been changed.

> 
> Are you guys sure there's no wake pin events during runtime? AFAIK
> the RTCs just typically produce an interrupt when programmed to
> do so, they don't know the state of the SoC.
> 

I do not think that It can be fit in gpiochip or irqchip -
in my opinion right way is to proceed with bindings proposed by 
Marcin in this patch v1.

But, probably, it could fit in pinctrl:
- this is pin's configuration
- this is one-time configuration
- or - configuration which can be applied before suspend
  and resorted after suspend.

if you still wanna try some generic framework.

-- 
regards,
-grygorii
--
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	[flat|nested] 15+ messages in thread

* Re: [PATCH] rtc: omap: Support ext_wakeup configuration
       [not found]                 ` <5707E764.7050204-l0cyMroinI0@public.gmane.org>
@ 2016-04-08 17:51                   ` Tony Lindgren
       [not found]                     ` <20160408175114.GX16484-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
  2016-04-12 17:25                   ` Marcin Niestroj
  1 sibling, 1 reply; 15+ messages in thread
From: Tony Lindgren @ 2016-04-08 17:51 UTC (permalink / raw)
  To: Grygorii Strashko
  Cc: Marcin Niestroj, rtc-linux-/JYPxA39Uh5TLH3MbocFFw,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Pawel Moll,
	Alessandro Zummo, Alexandre Belloni, Keerthy,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Dave Gerlach, Menon, Nishanth

* Grygorii Strashko <grygorii.strashko-l0cyMroinI0@public.gmane.org> [160408 10:17]:
> On 04/08/2016 06:14 PM, Tony Lindgren wrote:
> > * Grygorii Strashko <grygorii.strashko-l0cyMroinI0@public.gmane.org> [160408 03:41]:
> >> Hi Tony,
> >>
> >> On 04/05/2016 01:40 AM, Tony Lindgren wrote:
> >>> Hi,
> >>>
> >>> * Marcin Niestroj <m.niestroj-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org> [160404 08:57]:
> >>>> Support configuration of ext_wakeup sources. This patch makes it
> >>>> possible to enable ext_wakeup and set it's polarity, depending on board
> >>>> configuration. AM335x's dedicated PMIC (tps65217) uses ext_wakeup to
> >>>> notify about power-button presses. Handling power-button presses enables
> >>>> to recover from RTC-only power states correctly.
> >>>
> >>> I suggest you just set this pin up as a minimal gpiochip. That way
> >>> we can use the standard binding :) And if we get lucky, this pin can
> >>> also trigger during runtime.
> >>>
> >>
> >> Following my comments on v2 of this patch I propose to rollback to
> >> this version of the patch.
> >>
> >> It seems doesn't fit in gpiochip, it's more likely irqchip, but since
> >> rtc can't generate IRQ there are nor reasons for these genetic
> >> experiments and RTC's specific bindings looks more suitable, at least for me.
> > 
> > Hmm well gpiochips typically are irqchip too. IMO the generic binding
> > here sounds like "gpio-wakeup" as it's an input with polarity and with
> > an optional interrupt.
> > 
> > Plain irqchip would work too in this case if there are no other GPIO
> > specific features. Some other RTCs may have more GPIO like features.
> > 
> > In any case, setting the ext_wakeup up as an irqchip means that the
> > RTC controller can be used as a dedicated wakeirq with Linux :)
> 
> It can't :( It can't generate IRQ when state of ext_wakeup line has 
> been changed.

Hmm to me it certainly seems it should be capable of generating and RTC
interrupt as we have EXT_WAKEUP_STATUS register containing four bits,
one for each wakeup line.

We also have EXT_WAKEUP_DB_EN for debounce, EXT_WAKEUP_POL for polarity,
and EXT_WAKEUP_EN to enable in addition to status.. These certainly make
it look like a gpiochip or irqchip.

> > Are you guys sure there's no wake pin events during runtime? AFAIK
> > the RTCs just typically produce an interrupt when programmed to
> > do so, they don't know the state of the SoC.
> > 
> 
> I do not think that It can be fit in gpiochip or irqchip -
> in my opinion right way is to proceed with bindings proposed by 
> Marcin in this patch v1.
> 
> But, probably, it could fit in pinctrl:
> - this is pin's configuration
> - this is one-time configuration
> - or - configuration which can be applied before suspend
>   and resorted after suspend.
> 
> if you still wanna try some generic framework.

Yeah the pin certainly should be configured by pinctrl if it is
muxable.

However, the functionality of the pin is clearly tied to the RTC
driver. My guess the reason it does not generate interrupts is that
it's status needs to be cleared each time it triggers? That fits the
irq mask/unmask for generic wakeirq like we do for the padconf.

Sounds like some experiments and reasoning is needed :) I guess the
first test to run is tools/testing/selftests/timers/rtctest.c to
make sure the RTC interrupts trigger properly.

Regards,

Tony
--
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	[flat|nested] 15+ messages in thread

* Re: [PATCH] rtc: omap: Support ext_wakeup configuration
       [not found]                     ` <20160408175114.GX16484-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
@ 2016-04-09 16:42                       ` Tony Lindgren
  0 siblings, 0 replies; 15+ messages in thread
From: Tony Lindgren @ 2016-04-09 16:42 UTC (permalink / raw)
  To: Grygorii Strashko
  Cc: Marcin Niestroj, rtc-linux-/JYPxA39Uh5TLH3MbocFFw,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Pawel Moll,
	Alessandro Zummo, Alexandre Belloni, Keerthy,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Dave Gerlach, Menon, Nishanth

* Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> [160408 10:52]:
> * Grygorii Strashko <grygorii.strashko-l0cyMroinI0@public.gmane.org> [160408 10:17]:
> > 
> > It can't :( It can't generate IRQ when state of ext_wakeup line has 
> > been changed.
> 
> Hmm to me it certainly seems it should be capable of generating and RTC
> interrupt as we have EXT_WAKEUP_STATUS register containing four bits,
> one for each wakeup line.

So I played a bit with RTC last night and the RTC_PMIC_REG options..
And I came to the same conclusion as Grygorii pretty much. It looks
like an interrupt, except it can't generate any interrupts. Sorry
for not believing it earlier. It might still be a good idea to
confirm this with some hardware folks at TI, maybe newer versions
could add support for an interrupt.

The EXT_WAKEUP configuration only seems to affect pmic_pwr_enable
pin if configured right. Depending on the PMIC, we could use a
shared interrupt for handling the ext wakeup line changes in the
RTC driver.

The ext wakeup lines are not really GPIOs either as we can't
monitor the wakeup line states, they are just trigger and then
hold the state until cleared.

If we ever need to provide the state of the wakeup lines to the
other drivers, we could still use GPIO, input, or pinctrl. All
these allow adding interrupt support for the cases that allow
sharing the interrupt with PMIC.

I guess we should just pick the framework that already has support
for configuring the debounce time for a pin.

Regards,

Tony
--
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	[flat|nested] 15+ messages in thread

* Re: [PATCH] rtc: omap: Support ext_wakeup configuration
       [not found]                 ` <5707E764.7050204-l0cyMroinI0@public.gmane.org>
  2016-04-08 17:51                   ` Tony Lindgren
@ 2016-04-12 17:25                   ` Marcin Niestroj
       [not found]                     ` <570D2F79.9040202-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org>
  1 sibling, 1 reply; 15+ messages in thread
From: Marcin Niestroj @ 2016-04-12 17:25 UTC (permalink / raw)
  To: Grygorii Strashko, Tony Lindgren
  Cc: rtc-linux-/JYPxA39Uh5TLH3MbocFFw,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Pawel Moll,
	Alessandro Zummo, Alexandre Belloni, Keerthy,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Dave Gerlach, Menon, Nishanth

Hi,

On 08.04.2016 19:16, Grygorii Strashko wrote:
> On 04/08/2016 06:14 PM, Tony Lindgren wrote:
>> * Grygorii Strashko <grygorii.strashko-l0cyMroinI0@public.gmane.org> [160408 03:41]:
>>> Hi Tony,
>>>
>>> On 04/05/2016 01:40 AM, Tony Lindgren wrote:
>>>> Hi,
>>>>
>>>> * Marcin Niestroj <m.niestroj-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org> [160404 08:57]:
>>>>> Support configuration of ext_wakeup sources. This patch makes it
>>>>> possible to enable ext_wakeup and set it's polarity, depending on board
>>>>> configuration. AM335x's dedicated PMIC (tps65217) uses ext_wakeup to
>>>>> notify about power-button presses. Handling power-button presses enables
>>>>> to recover from RTC-only power states correctly.
>>>>
>>>> I suggest you just set this pin up as a minimal gpiochip. That way
>>>> we can use the standard binding :) And if we get lucky, this pin can
>>>> also trigger during runtime.
>>>>
>>>
>>> Following my comments on v2 of this patch I propose to rollback to
>>> this version of the patch.
>>>
>>> It seems doesn't fit in gpiochip, it's more likely irqchip, but since
>>> rtc can't generate IRQ there are nor reasons for these genetic
>>> experiments and RTC's specific bindings looks more suitable, at least for me.
>>
>> Hmm well gpiochips typically are irqchip too. IMO the generic binding
>> here sounds like "gpio-wakeup" as it's an input with polarity and with
>> an optional interrupt.
>>
>> Plain irqchip would work too in this case if there are no other GPIO
>> specific features. Some other RTCs may have more GPIO like features.
>>
>> In any case, setting the ext_wakeup up as an irqchip means that the
>> RTC controller can be used as a dedicated wakeirq with Linux :)
>
> It can't :( It can't generate IRQ when state of ext_wakeup line has
> been changed.
>
>>
>> Are you guys sure there's no wake pin events during runtime? AFAIK
>> the RTCs just typically produce an interrupt when programmed to
>> do so, they don't know the state of the SoC.
>>
>
> I do not think that It can be fit in gpiochip or irqchip -
> in my opinion right way is to proceed with bindings proposed by
> Marcin in this patch v1.
>
> But, probably, it could fit in pinctrl:
> - this is pin's configuration
> - this is one-time configuration
> - or - configuration which can be applied before suspend
>    and resorted after suspend.
>
> if you still wanna try some generic framework.
>

pinctrl bindings looks ok for our use case (enable/disable input,
configure debounce), except I don't see any way to pass polarity
(active low/high) to the driver.

-- 
Marcin Niestroj
--
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	[flat|nested] 15+ messages in thread

* Re: [PATCH] rtc: omap: Support ext_wakeup configuration
       [not found]                     ` <570D2F79.9040202-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org>
@ 2016-04-15 16:46                       ` Grygorii Strashko
       [not found]                         ` <57111AF4.6070505-l0cyMroinI0@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Grygorii Strashko @ 2016-04-15 16:46 UTC (permalink / raw)
  To: Marcin Niestroj, Tony Lindgren
  Cc: rtc-linux-/JYPxA39Uh5TLH3MbocFFw,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Pawel Moll,
	Alessandro Zummo, Alexandre Belloni, Keerthy,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Dave Gerlach, Menon, Nishanth

On 04/12/2016 08:25 PM, Marcin Niestroj wrote:
> Hi,
> 
> On 08.04.2016 19:16, Grygorii Strashko wrote:
>> On 04/08/2016 06:14 PM, Tony Lindgren wrote:
>>> * Grygorii Strashko <grygorii.strashko-l0cyMroinI0@public.gmane.org> [160408 03:41]:
>>>> Hi Tony,
>>>>
>>>> On 04/05/2016 01:40 AM, Tony Lindgren wrote:
>>>>> Hi,
>>>>>
>>>>> * Marcin Niestroj <m.niestroj-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org> [160404 08:57]:
>>>>>> Support configuration of ext_wakeup sources. This patch makes it
>>>>>> possible to enable ext_wakeup and set it's polarity, depending on 
>>>>>> board
>>>>>> configuration. AM335x's dedicated PMIC (tps65217) uses ext_wakeup to
>>>>>> notify about power-button presses. Handling power-button presses 
>>>>>> enables
>>>>>> to recover from RTC-only power states correctly.
>>>>>
>>>>> I suggest you just set this pin up as a minimal gpiochip. That way
>>>>> we can use the standard binding :) And if we get lucky, this pin can
>>>>> also trigger during runtime.
>>>>>
>>>>
>>>> Following my comments on v2 of this patch I propose to rollback to
>>>> this version of the patch.
>>>>
>>>> It seems doesn't fit in gpiochip, it's more likely irqchip, but since
>>>> rtc can't generate IRQ there are nor reasons for these genetic
>>>> experiments and RTC's specific bindings looks more suitable, at 
>>>> least for me.
>>>
>>> Hmm well gpiochips typically are irqchip too. IMO the generic binding
>>> here sounds like "gpio-wakeup" as it's an input with polarity and with
>>> an optional interrupt.
>>>
>>> Plain irqchip would work too in this case if there are no other GPIO
>>> specific features. Some other RTCs may have more GPIO like features.
>>>
>>> In any case, setting the ext_wakeup up as an irqchip means that the
>>> RTC controller can be used as a dedicated wakeirq with Linux :)
>>
>> It can't :( It can't generate IRQ when state of ext_wakeup line has
>> been changed.
>>
>>>
>>> Are you guys sure there's no wake pin events during runtime? AFAIK
>>> the RTCs just typically produce an interrupt when programmed to
>>> do so, they don't know the state of the SoC.
>>>
>>
>> I do not think that It can be fit in gpiochip or irqchip -
>> in my opinion right way is to proceed with bindings proposed by
>> Marcin in this patch v1.
>>
>> But, probably, it could fit in pinctrl:
>> - this is pin's configuration
>> - this is one-time configuration
>> - or - configuration which can be applied before suspend
>>    and resorted after suspend.
>>
>> if you still wanna try some generic framework.
>>
> 
> pinctrl bindings looks ok for our use case (enable/disable input,
> configure debounce), except I don't see any way to pass polarity
> (active low/high) to the driver.
> 

Below code is just a POC that pinctrl can be used here.
It does one time configuration at boot, but more sates can be added
- sleep, poweroff:

diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index 13ac882..9580c82 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -1248,11 +1248,40 @@
 
                rtc: rtc@48838000 {
                        compatible = "ti,am3352-rtc";
-                       reg = <0x48838000 0x100>;
+                       reg = <0x48838000 0x98>;
                        interrupts = <GIC_SPI 217 IRQ_TYPE_LEVEL_HIGH>,
                                     <GIC_SPI 217 IRQ_TYPE_LEVEL_HIGH>;
                        ti,hwmods = "rtcss";
                        clocks = <&sys_32k_ck>;
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+                       ranges;
+                       
+                       rtc_pmx: pinmux@48838098 {
+                               compatible = "pinctrl-single";
+                               reg = <0x48838098 0x8>;
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+                               pinctrl-single,register-width = <32>;
+                               pinctrl-single,function-mask = <0x007fffff>;
+
+                               pinctrl-names = "default"/*, "sleep"*/;
+                               pinctrl-0 = <&rtc_default>;
+/*                             pinctrl-1 = <&rtc_sleep>;*/
+
+                               rtc_default: rtc_default {
+                                       pinctrl-single,pins = <
+                                               0x0 0x000B0111
+                                               0x4 0x00000004
+                                       >;
+                               };
+/*                             rtc_sleep: rtc_sleep {
+                                       pinctrl-single,pins = <
+                                               0x0 0x00000000
+                                               0x4 0x00000000
+                                       >;
+                               };*/
+                       };
                };
 
                /* OCP2SCP1 */
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index ec2e9c5..28c67a4 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -428,8 +428,10 @@ static void omap_rtc_power_off(void)
 
        rtc->type->unlock(rtc);
        /* enable pmic_power_en control */
+/*
        val = rtc_readl(rtc, OMAP_RTC_PMIC_REG);
        rtc_writel(rtc, OMAP_RTC_PMIC_REG, val | OMAP_RTC_PMIC_POWER_EN_EN);
+*/
 
        /* set alarm two seconds from now */
        omap_rtc_read_time_raw(rtc, &tm);
@@ -650,6 +652,8 @@ static int omap_rtc_probe(struct platform_device *pdev)
                          reg | OMAP_RTC_OSC_SEL_32KCLK_SRC);
        }
 
+       of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
+
        rtc->type->lock(rtc);
 
        device_init_wakeup(&pdev->dev, true);
 

-- 
regards,
-grygorii
--
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] 15+ messages in thread

* Re: [PATCH] rtc: omap: Support ext_wakeup configuration
       [not found]                         ` <57111AF4.6070505-l0cyMroinI0@public.gmane.org>
@ 2016-04-15 16:52                           ` Nishanth Menon
       [not found]                             ` <57111C5A.7070606-l0cyMroinI0@public.gmane.org>
  2016-04-26  7:39                           ` Marcin Niestroj
  1 sibling, 1 reply; 15+ messages in thread
From: Nishanth Menon @ 2016-04-15 16:52 UTC (permalink / raw)
  To: Grygorii Strashko, Marcin Niestroj, Tony Lindgren
  Cc: rtc-linux-/JYPxA39Uh5TLH3MbocFFw,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Pawel Moll,
	Alessandro Zummo, Alexandre Belloni, Keerthy,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Dave Gerlach

On 04/15/2016 11:46 AM, Grygorii Strashko wrote:
[...]
> diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
> index 13ac882..9580c82 100644
> --- a/arch/arm/boot/dts/dra7.dtsi

I see this is an example of what could be done on am335x - but lets
not do this on dra7/am57xx please?


-- 
Regards,
Nishanth Menon
--
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	[flat|nested] 15+ messages in thread

* Re: [PATCH] rtc: omap: Support ext_wakeup configuration
       [not found]                             ` <57111C5A.7070606-l0cyMroinI0@public.gmane.org>
@ 2016-04-15 17:18                               ` Grygorii Strashko
  0 siblings, 0 replies; 15+ messages in thread
From: Grygorii Strashko @ 2016-04-15 17:18 UTC (permalink / raw)
  To: Nishanth Menon, Marcin Niestroj, Tony Lindgren
  Cc: rtc-linux-/JYPxA39Uh5TLH3MbocFFw,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Pawel Moll,
	Alessandro Zummo, Alexandre Belloni, Keerthy,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Dave Gerlach


Hi Nishanth,

On 04/15/2016 07:52 PM, Nishanth Menon wrote:
> On 04/15/2016 11:46 AM, Grygorii Strashko wrote:
> [...]
>> diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
>> index 13ac882..9580c82 100644
>> --- a/arch/arm/boot/dts/dra7.dtsi
>
> I see this is an example of what could be done on am335x - but lets
> not do this on dra7/am57xx please?
>
>

Don't panic. It's just an example ;)
Late Friday is here, and it was the first available board.

Sry, that I made you worry. ;)

-- 
regards,
-grygorii
--
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	[flat|nested] 15+ messages in thread

* Re: [PATCH] rtc: omap: Support ext_wakeup configuration
       [not found]                         ` <57111AF4.6070505-l0cyMroinI0@public.gmane.org>
  2016-04-15 16:52                           ` Nishanth Menon
@ 2016-04-26  7:39                           ` Marcin Niestroj
       [not found]                             ` <fe6ab23a-5f0d-a317-14d9-f538c3ad4052-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org>
  1 sibling, 1 reply; 15+ messages in thread
From: Marcin Niestroj @ 2016-04-26  7:39 UTC (permalink / raw)
  To: Grygorii Strashko, Tony Lindgren
  Cc: rtc-linux-/JYPxA39Uh5TLH3MbocFFw,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Pawel Moll,
	Alessandro Zummo, Alexandre Belloni, Keerthy,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Dave Gerlach, Menon, Nishanth

Hi,

On 15.04.2016 18:46, Grygorii Strashko wrote:
> On 04/12/2016 08:25 PM, Marcin Niestroj wrote:
>> Hi,
>>
>> On 08.04.2016 19:16, Grygorii Strashko wrote:
>>> On 04/08/2016 06:14 PM, Tony Lindgren wrote:
>>>> * Grygorii Strashko <grygorii.strashko-l0cyMroinI0@public.gmane.org> [160408 03:41]:
>>>>> Hi Tony,
>>>>>
>>>>> On 04/05/2016 01:40 AM, Tony Lindgren wrote:
>>>>>> Hi,
>>>>>>
>>>>>> * Marcin Niestroj <m.niestroj-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org> [160404 08:57]:
>>>>>>> Support configuration of ext_wakeup sources. This patch makes it
>>>>>>> possible to enable ext_wakeup and set it's polarity, depending on
>>>>>>> board
>>>>>>> configuration. AM335x's dedicated PMIC (tps65217) uses ext_wakeup to
>>>>>>> notify about power-button presses. Handling power-button presses
>>>>>>> enables
>>>>>>> to recover from RTC-only power states correctly.
>>>>>>
>>>>>> I suggest you just set this pin up as a minimal gpiochip. That way
>>>>>> we can use the standard binding :) And if we get lucky, this pin can
>>>>>> also trigger during runtime.
>>>>>>
>>>>>
>>>>> Following my comments on v2 of this patch I propose to rollback to
>>>>> this version of the patch.
>>>>>
>>>>> It seems doesn't fit in gpiochip, it's more likely irqchip, but since
>>>>> rtc can't generate IRQ there are nor reasons for these genetic
>>>>> experiments and RTC's specific bindings looks more suitable, at
>>>>> least for me.
>>>>
>>>> Hmm well gpiochips typically are irqchip too. IMO the generic binding
>>>> here sounds like "gpio-wakeup" as it's an input with polarity and with
>>>> an optional interrupt.
>>>>
>>>> Plain irqchip would work too in this case if there are no other GPIO
>>>> specific features. Some other RTCs may have more GPIO like features.
>>>>
>>>> In any case, setting the ext_wakeup up as an irqchip means that the
>>>> RTC controller can be used as a dedicated wakeirq with Linux :)
>>>
>>> It can't :( It can't generate IRQ when state of ext_wakeup line has
>>> been changed.
>>>
>>>>
>>>> Are you guys sure there's no wake pin events during runtime? AFAIK
>>>> the RTCs just typically produce an interrupt when programmed to
>>>> do so, they don't know the state of the SoC.
>>>>
>>>
>>> I do not think that It can be fit in gpiochip or irqchip -
>>> in my opinion right way is to proceed with bindings proposed by
>>> Marcin in this patch v1.
>>>
>>> But, probably, it could fit in pinctrl:
>>> - this is pin's configuration
>>> - this is one-time configuration
>>> - or - configuration which can be applied before suspend
>>>    and resorted after suspend.
>>>
>>> if you still wanna try some generic framework.
>>>
>>
>> pinctrl bindings looks ok for our use case (enable/disable input,
>> configure debounce), except I don't see any way to pass polarity
>> (active low/high) to the driver.
>>
>
> Below code is just a POC that pinctrl can be used here.
> It does one time configuration at boot, but more sates can be added
> - sleep, poweroff:
>
> diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
> index 13ac882..9580c82 100644
> --- a/arch/arm/boot/dts/dra7.dtsi
> +++ b/arch/arm/boot/dts/dra7.dtsi
> @@ -1248,11 +1248,40 @@
>
>                 rtc: rtc@48838000 {
>                         compatible = "ti,am3352-rtc";
> -                       reg = <0x48838000 0x100>;
> +                       reg = <0x48838000 0x98>;
>                         interrupts = <GIC_SPI 217 IRQ_TYPE_LEVEL_HIGH>,
>                                      <GIC_SPI 217 IRQ_TYPE_LEVEL_HIGH>;
>                         ti,hwmods = "rtcss";
>                         clocks = <&sys_32k_ck>;
> +                       #address-cells = <1>;
> +                       #size-cells = <1>;
> +                       ranges;
> +
> +                       rtc_pmx: pinmux@48838098 {
> +                               compatible = "pinctrl-single";
> +                               reg = <0x48838098 0x8>;
> +                               #address-cells = <1>;
> +                               #size-cells = <0>;
> +                               pinctrl-single,register-width = <32>;
> +                               pinctrl-single,function-mask = <0x007fffff>;
> +
> +                               pinctrl-names = "default"/*, "sleep"*/;
> +                               pinctrl-0 = <&rtc_default>;
> +/*                             pinctrl-1 = <&rtc_sleep>;*/
> +
> +                               rtc_default: rtc_default {
> +                                       pinctrl-single,pins = <
> +                                               0x0 0x000B0111
> +                                               0x4 0x00000004
> +                                       >;
> +                               };
> +/*                             rtc_sleep: rtc_sleep {
> +                                       pinctrl-single,pins = <
> +                                               0x0 0x00000000
> +                                               0x4 0x00000000
> +                                       >;
> +                               };*/
> +                       };
>                 };
>
>                 /* OCP2SCP1 */
> diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
> index ec2e9c5..28c67a4 100644
> --- a/drivers/rtc/rtc-omap.c
> +++ b/drivers/rtc/rtc-omap.c
> @@ -428,8 +428,10 @@ static void omap_rtc_power_off(void)
>
>         rtc->type->unlock(rtc);
>         /* enable pmic_power_en control */
> +/*
>         val = rtc_readl(rtc, OMAP_RTC_PMIC_REG);
>         rtc_writel(rtc, OMAP_RTC_PMIC_REG, val | OMAP_RTC_PMIC_POWER_EN_EN);
> +*/
>
>         /* set alarm two seconds from now */
>         omap_rtc_read_time_raw(rtc, &tm);
> @@ -650,6 +652,8 @@ static int omap_rtc_probe(struct platform_device *pdev)
>                           reg | OMAP_RTC_OSC_SEL_32KCLK_SRC);
>         }
>
> +       of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
> +
>         rtc->type->lock(rtc);
>
>         device_init_wakeup(&pdev->dev, true);
>
>

I made few changes to the POC you provided.

In below code we check reg resource size in order to know if we
should update RTC_PMIC or it is pinctrl responsibility. It's a little
hack, but we make sure, that every device with not modified device-tree
will work as previously. If we want to add support for ext_wakeup, we
just change reg resouce size in device-tree in order to not overlap
requested memory regions in rtc-omap and pinctrl.

I used am335x-chilisom instead of dra7 and updated
pinctrl-single,funcion-mask so the EXT_WAKEUP_STATUS is always cleared
after boot.

So the question now is: is this acceptable? Do we want to continue with
this approach?

diff --git a/arch/arm/boot/dts/am335x-chilisom.dtsi 
b/arch/arm/boot/dts/am335x-chilisom.dtsi
index bc0880d..525ed4f 100644
--- a/arch/arm/boot/dts/am335x-chilisom.dtsi
+++ b/arch/arm/boot/dts/am335x-chilisom.dtsi
@@ -124,6 +124,31 @@

  &rtc {
         system-power-controller;
+
+       reg = <0x44e3e000 0x98>;
+       #address-cells = <1>;
+       #size-cells = <1>; 

+       ranges; 

+ 

+       rtc_pinmux: pinmux@0x44e3e098 { 

+               compatible = "pinctrl-single"; 

+               reg = <0x44e3e098 0x8>; 

+               #address-cells = <1>; 

+               #size-cells = <1>; 

+ 

+               pinctrl-single,register-width = <32>; 

+               pinctrl-single,function-mask = <0x10fff>; 

+ 

+               pinctrl-names = "default"; 

+               pinctrl-0 = <&rtc_pins_default>; 

+ 

+               rtc_pins_default: rtc_pins_default { 

+                       pinctrl-single,pins = < 

+                               0x0 0x00010011 

+                               0x4 0x00000000 

+                       >; 

+               }; 

+       }; 

  }; 

 

  /* NAND Flash */
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index ec2e9c5..db2512c 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -134,6 +134,7 @@ struct omap_rtc_device_type {
  struct omap_rtc {
         struct rtc_device *rtc;
         void __iomem *base;
+       resource_size_t res_size;
         struct clk *clk;
         int irq_alarm;
         int irq_timer;
@@ -428,8 +429,11 @@ static void omap_rtc_power_off(void)

         rtc->type->unlock(rtc);
         /* enable pmic_power_en control */
-       val = rtc_readl(rtc, OMAP_RTC_PMIC_REG);
-       rtc_writel(rtc, OMAP_RTC_PMIC_REG, val | OMAP_RTC_PMIC_POWER_EN_EN);
+       if (rtc->res_size > OMAP_RTC_PMIC_REG) {
+               val = rtc_readl(rtc, OMAP_RTC_PMIC_REG);
+               rtc_writel(rtc, OMAP_RTC_PMIC_REG,
+                       val | OMAP_RTC_PMIC_POWER_EN_EN);
+       }

         /* set alarm two seconds from now */
         omap_rtc_read_time_raw(rtc, &tm);
@@ -567,6 +571,7 @@ static int omap_rtc_probe(struct platform_device *pdev)
                 clk_prepare_enable(rtc->clk);

         res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       rtc->res_size = resource_size(res);
         rtc->base = devm_ioremap_resource(&pdev->dev, res);
         if (IS_ERR(rtc->base))
                 return PTR_ERR(rtc->base);
@@ -681,6 +686,9 @@ static int omap_rtc_probe(struct platform_device *pdev)
                 }
         }

+       /* handle pinmux nodes which configure ext_wakeup inputs */
+       of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
+
         return 0;

  err:

-- 
Marcin Niestroj
--
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] 15+ messages in thread

* Re: [PATCH] rtc: omap: Support ext_wakeup configuration
       [not found]                             ` <fe6ab23a-5f0d-a317-14d9-f538c3ad4052-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org>
@ 2016-04-26 15:39                               ` Tony Lindgren
       [not found]                                 ` <20160426153948.GR5995-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Tony Lindgren @ 2016-04-26 15:39 UTC (permalink / raw)
  To: Marcin Niestroj
  Cc: Grygorii Strashko, rtc-linux-/JYPxA39Uh5TLH3MbocFFw,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Pawel Moll,
	Alessandro Zummo, Alexandre Belloni, Keerthy,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Dave Gerlach, Menon, Nishanth

* Marcin Niestroj <m.niestroj-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org> [160426 00:40]:
> In below code we check reg resource size in order to know if we
> should update RTC_PMIC or it is pinctrl responsibility. It's a little
> hack, but we make sure, that every device with not modified device-tree
> will work as previously. If we want to add support for ext_wakeup, we
> just change reg resouce size in device-tree in order to not overlap
> requested memory regions in rtc-omap and pinctrl.
> 
> I used am335x-chilisom instead of dra7 and updated
> pinctrl-single,funcion-mask so the EXT_WAKEUP_STATUS is always cleared
> after boot.
> 
> So the question now is: is this acceptable? Do we want to continue with
> this approach?

Well the concern I have here is that we not use pinctrl-single
as a separate driver if any of the registers are shared with
the RTC driver. If the registers are shared, the pinctrl
functionality should be implemented in the RTC driver.

The pinctrl driver can also implement a chained IRQ later
on for consumer device drivers to use with the wakeirq API.
Maybe eventually we'll have real chained interrupt for the
RTC to use from Linux side of the C-M3 driver.

Regards,

Tony
--
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	[flat|nested] 15+ messages in thread

* Re: [PATCH] rtc: omap: Support ext_wakeup configuration
       [not found]                                 ` <20160426153948.GR5995-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
@ 2016-06-15  8:37                                   ` Marcin Niestroj
       [not found]                                     ` <65595642-33fb-368b-f47f-8e62b885c0a2-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Marcin Niestroj @ 2016-06-15  8:37 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Grygorii Strashko, rtc-linux-/JYPxA39Uh5TLH3MbocFFw,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Pawel Moll,
	Alessandro Zummo, Alexandre Belloni, Keerthy,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Dave Gerlach, Menon, Nishanth

Hi,

Sorry for such delay in response. Please see my comments/questions on
using pinctrl below.

On 26.04.2016 17:39, Tony Lindgren wrote:
> * Marcin Niestroj <m.niestroj-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org> [160426 00:40]:
>> In below code we check reg resource size in order to know if we
>> should update RTC_PMIC or it is pinctrl responsibility. It's a little
>> hack, but we make sure, that every device with not modified device-tree
>> will work as previously. If we want to add support for ext_wakeup, we
>> just change reg resouce size in device-tree in order to not overlap
>> requested memory regions in rtc-omap and pinctrl.
>>
>> I used am335x-chilisom instead of dra7 and updated
>> pinctrl-single,funcion-mask so the EXT_WAKEUP_STATUS is always cleared
>> after boot.
>>
>> So the question now is: is this acceptable? Do we want to continue with
>> this approach?
>
> Well the concern I have here is that we not use pinctrl-single
> as a separate driver if any of the registers are shared with
> the RTC driver. If the registers are shared, the pinctrl
> functionality should be implemented in the RTC driver.

We can use pinctrl generic params for:
  * enable wakeup inputs - with 'input-enable'
  * input debounce enable/configuration - with 'input-debounce'

However I don't see any generic way for setting wakeup input polarity.
So I guess we should add some driver specific devicetree binding to
handle hat. I also didn't find any other driver that implements it.

In case of pinctrl-single we have just written custom register values to
set polarity.

So the question is: how should we proceed? Is pinctrl still and option?
If yes, what is your idea about configuring input polarity?

>
> The pinctrl driver can also implement a chained IRQ later
> on for consumer device drivers to use with the wakeirq API.
> Maybe eventually we'll have real chained interrupt for the
> RTC to use from Linux side of the C-M3 driver.
>
> Regards,
>
> Tony
>


-- 
Marcin Niestroj

-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

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

* Re: [PATCH] rtc: omap: Support ext_wakeup configuration
       [not found]                                     ` <65595642-33fb-368b-f47f-8e62b885c0a2-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org>
@ 2016-06-15 10:56                                       ` Tony Lindgren
  0 siblings, 0 replies; 15+ messages in thread
From: Tony Lindgren @ 2016-06-15 10:56 UTC (permalink / raw)
  To: Marcin Niestroj
  Cc: Grygorii Strashko, rtc-linux-/JYPxA39Uh5TLH3MbocFFw,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Pawel Moll,
	Alessandro Zummo, Alexandre Belloni, Keerthy,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Dave Gerlach, Menon, Nishanth

* Marcin Niestroj <m.niestroj-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org> [160615 01:40]:
> Hi,
> 
> Sorry for such delay in response. Please see my comments/questions on
> using pinctrl below.
> 
> On 26.04.2016 17:39, Tony Lindgren wrote:
> > * Marcin Niestroj <m.niestroj-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org> [160426 00:40]:
> > > In below code we check reg resource size in order to know if we
> > > should update RTC_PMIC or it is pinctrl responsibility. It's a little
> > > hack, but we make sure, that every device with not modified device-tree
> > > will work as previously. If we want to add support for ext_wakeup, we
> > > just change reg resouce size in device-tree in order to not overlap
> > > requested memory regions in rtc-omap and pinctrl.
> > > 
> > > I used am335x-chilisom instead of dra7 and updated
> > > pinctrl-single,funcion-mask so the EXT_WAKEUP_STATUS is always cleared
> > > after boot.
> > > 
> > > So the question now is: is this acceptable? Do we want to continue with
> > > this approach?
> > 
> > Well the concern I have here is that we not use pinctrl-single
> > as a separate driver if any of the registers are shared with
> > the RTC driver. If the registers are shared, the pinctrl
> > functionality should be implemented in the RTC driver.
> 
> We can use pinctrl generic params for:
>  * enable wakeup inputs - with 'input-enable'
>  * input debounce enable/configuration - with 'input-debounce'
> 
> However I don't see any generic way for setting wakeup input polarity.
> So I guess we should add some driver specific devicetree binding to
> handle hat. I also didn't find any other driver that implements it.
> 
> In case of pinctrl-single we have just written custom register values to
> set polarity.
> 
> So the question is: how should we proceed? Is pinctrl still and option?
> If yes, what is your idea about configuring input polarity?

At least I don't have any better ideas. You can define the values
in the driver specific binding, I'd use something like GPIO_ACTIVE_LOW
even though it's a broken GPIO and broken interrupt :)

Regards,

Tony
--
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	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-06-15 10:56 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-04 15:56 [PATCH] rtc: omap: Support ext_wakeup configuration Marcin Niestroj
     [not found] ` <1459785403-1725-1-git-send-email-m.niestroj-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org>
2016-04-04 22:40   ` Tony Lindgren
     [not found]     ` <20160404224046.GA17042-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-04-08 10:40       ` Grygorii Strashko
     [not found]         ` <57078A89.3080809-l0cyMroinI0@public.gmane.org>
2016-04-08 15:14           ` Tony Lindgren
     [not found]             ` <20160408151408.GS16484-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-04-08 17:16               ` Grygorii Strashko
     [not found]                 ` <5707E764.7050204-l0cyMroinI0@public.gmane.org>
2016-04-08 17:51                   ` Tony Lindgren
     [not found]                     ` <20160408175114.GX16484-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-04-09 16:42                       ` Tony Lindgren
2016-04-12 17:25                   ` Marcin Niestroj
     [not found]                     ` <570D2F79.9040202-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org>
2016-04-15 16:46                       ` Grygorii Strashko
     [not found]                         ` <57111AF4.6070505-l0cyMroinI0@public.gmane.org>
2016-04-15 16:52                           ` Nishanth Menon
     [not found]                             ` <57111C5A.7070606-l0cyMroinI0@public.gmane.org>
2016-04-15 17:18                               ` Grygorii Strashko
2016-04-26  7:39                           ` Marcin Niestroj
     [not found]                             ` <fe6ab23a-5f0d-a317-14d9-f538c3ad4052-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org>
2016-04-26 15:39                               ` Tony Lindgren
     [not found]                                 ` <20160426153948.GR5995-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2016-06-15  8:37                                   ` Marcin Niestroj
     [not found]                                     ` <65595642-33fb-368b-f47f-8e62b885c0a2-z3quKL4iOrmQ6ZAhV5LmOA@public.gmane.org>
2016-06-15 10:56                                       ` Tony Lindgren

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