* [rtc-linux] [PATCH 04/23] Documentation: dt: rtc: at91rm9200: add clocks property
2015-07-31 9:39 [rtc-linux] [PATCH 00/23] ARM: at91: Properly handle slow clock Alexandre Belloni
@ 2015-07-31 9:39 ` Alexandre Belloni
2015-07-31 9:39 ` [rtc-linux] [PATCH 15/23] rtc: at91rm9200: get and use slow clock Alexandre Belloni
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Alexandre Belloni @ 2015-07-31 9:39 UTC (permalink / raw)
To: Nicolas Ferre
Cc: Boris Brezillon, Maxime Ripard, Jean-Christophe Plagniol-Villard,
linux-arm-kernel, linux-kernel, Alexandre Belloni,
Alessandro Zummo, rtc-linux
The RTC needs an input clock, it is the slow clock. It is required as it
will not function without it.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: rtc-linux@googlegroups.com
Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.txt b/Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.txt
index 34c1505774bf..5d3791e789c6 100644
--- a/Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.txt
+++ b/Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.txt
@@ -5,6 +5,7 @@ Required properties:
- reg: physical base address of the controller and length of memory mapped
region.
- interrupts: rtc alarm/event interrupt
+- clocks: phandle to input clock.
Example:
@@ -12,4 +13,5 @@ rtc@fffffe00 {
compatible = "atmel,at91rm9200-rtc";
reg = <0xfffffe00 0x100>;
interrupts = <1 4 7>;
+ clocks = <&clk32k>;
};
--
2.1.4
--
--
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@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply related [flat|nested] 6+ messages in thread* [rtc-linux] [PATCH 15/23] rtc: at91rm9200: get and use slow clock
2015-07-31 9:39 [rtc-linux] [PATCH 00/23] ARM: at91: Properly handle slow clock Alexandre Belloni
2015-07-31 9:39 ` [rtc-linux] [PATCH 04/23] Documentation: dt: rtc: at91rm9200: add clocks property Alexandre Belloni
@ 2015-07-31 9:39 ` Alexandre Belloni
2015-07-31 9:59 ` [rtc-linux] Re: [PATCH 00/23] ARM: at91: Properly handle " Boris Brezillon
2015-07-31 15:21 ` Alexandre Belloni
3 siblings, 0 replies; 6+ messages in thread
From: Alexandre Belloni @ 2015-07-31 9:39 UTC (permalink / raw)
To: Nicolas Ferre
Cc: Boris Brezillon, Maxime Ripard, Jean-Christophe Plagniol-Villard,
linux-arm-kernel, linux-kernel, Alexandre Belloni,
Alessandro Zummo, rtc-linux
Commit dca1a4b5ff6e ("clk: at91: keep slow clk enabled to prevent system
hang") added a workaround for the slow clock as it is not properly handled
by its users.
Get and use the slow clock as it is necessary for the at91rm9200 rtc.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: rtc-linux@googlegroups.com
drivers/rtc/rtc-at91rm9200.c | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
index 35efd3f75b18..8093d9e50619 100644
--- a/drivers/rtc/rtc-at91rm9200.c
+++ b/drivers/rtc/rtc-at91rm9200.c
@@ -24,6 +24,7 @@
#include <linux/time.h>
#include <linux/rtc.h>
#include <linux/bcd.h>
+#include <linux/clk.h>
#include <linux/interrupt.h>
#include <linux/spinlock.h>
#include <linux/ioctl.h>
@@ -59,6 +60,7 @@ static bool suspended;
static DEFINE_SPINLOCK(suspended_lock);
static unsigned long cached_events;
static u32 at91_rtc_imr;
+static struct clk *sclk;
static void at91_rtc_write_ier(u32 mask)
{
@@ -407,6 +409,16 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
return -ENOMEM;
}
+ sclk = devm_clk_get(&pdev->dev, NULL);
+ if (IS_ERR(sclk))
+ return PTR_ERR(sclk);
+
+ ret = clk_prepare_enable(sclk);
+ if (ret) {
+ dev_err(&pdev->dev, "Could not enable slow clock\n");
+ return ret;
+ }
+
at91_rtc_write(AT91_RTC_CR, 0);
at91_rtc_write(AT91_RTC_MR, 0); /* 24 hour mode */
@@ -420,7 +432,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
"at91_rtc", pdev);
if (ret) {
dev_err(&pdev->dev, "IRQ %d already in use.\n", irq);
- return ret;
+ goto err_clk;
}
/* cpu init code should really have flagged this device as
@@ -431,8 +443,10 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
&at91_rtc_ops, THIS_MODULE);
- if (IS_ERR(rtc))
- return PTR_ERR(rtc);
+ if (IS_ERR(rtc)) {
+ ret = PTR_ERR(rtc);
+ goto err_clk;
+ }
platform_set_drvdata(pdev, rtc);
/* enable SECEV interrupt in order to initialize at91_rtc_upd_rdy
@@ -442,6 +456,11 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
dev_info(&pdev->dev, "AT91 Real Time Clock driver.\n");
return 0;
+
+err_clk:
+ clk_disable_unprepare(sclk);
+
+ return ret;
}
/*
@@ -454,6 +473,8 @@ static int __exit at91_rtc_remove(struct platform_device *pdev)
AT91_RTC_SECEV | AT91_RTC_TIMEV |
AT91_RTC_CALEV);
+ clk_disable_unprepare(sclk);
+
return 0;
}
--
2.1.4
--
--
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@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply related [flat|nested] 6+ messages in thread* [rtc-linux] Re: [PATCH 00/23] ARM: at91: Properly handle slow clock
2015-07-31 9:39 [rtc-linux] [PATCH 00/23] ARM: at91: Properly handle slow clock Alexandre Belloni
2015-07-31 9:39 ` [rtc-linux] [PATCH 04/23] Documentation: dt: rtc: at91rm9200: add clocks property Alexandre Belloni
2015-07-31 9:39 ` [rtc-linux] [PATCH 15/23] rtc: at91rm9200: get and use slow clock Alexandre Belloni
@ 2015-07-31 9:59 ` Boris Brezillon
2015-07-31 10:20 ` Alexandre Belloni
2015-07-31 15:21 ` Alexandre Belloni
3 siblings, 1 reply; 6+ messages in thread
From: Boris Brezillon @ 2015-07-31 9:59 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Nicolas Ferre, Maxime Ripard, Jean-Christophe Plagniol-Villard,
linux-arm-kernel, linux-kernel, Alessandro Zummo, Arnd Bergmann,
Daniel Lezcano, Dmitry Eremin-Solenikov, Greg Kroah-Hartman,
linux-clk, linux-pm, linux-pwm, linux-watchdog, Michael Turquette,
rtc-linux, Sebastian Reichel, Stephen Boyd, Thierry Reding,
Thomas Gleixner, Wim Van Sebroeck
Hi Alexandre,
On Fri, 31 Jul 2015 11:39:36 +0200
Alexandre Belloni <alexandre.belloni@free-electrons.com> wrote:
> Hi,
>
> It was discovered that all the slow clock user were not properly claiming it.
> This can end up in a system hang because the last registered user is releasing
> it, and it gets disabled.
>
> commit dca1a4b5ff6e ("clk: at91: keep slow clk enabled to prevent system hang")
> was a workaround. This series is adding the slow clock to the necessary drivers
> to avoid the issue and then removes that workaround.
>
> The Documentation updates and DT patches should probably go through the AT91
> tree this cycle to avoid breakage.
>
> Then the other patches can go through each subsystem tree. They are trivial
> enough to also go in this cycle.
>
> The final clk patch depends on the other ones and may be taken for the next
> cycle to avoid synchronization issues.
>
> I've thrown in a cleanup for at91-reset as it avoids adding support for that
> clock to the platform data initialization
I would have squashed commit 5 to 14 into a single patch, but apart
from that it looks good to me.
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Thanks,
Boris
>
> Changes in v2:
> - statisticize the global in the atmel-st change
> - merge at91_reset_of_probe() in at91_reset_probe()
> - added patches from Boris for the TCB
> - added the slow clock to the TCB
>
> Cc: Alessandro Zummo <a.zummo@towertech.it>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-clk@vger.kernel.org
> Cc: linux-pm@vger.kernel.org
> Cc: linux-pwm@vger.kernel.org
> Cc: linux-watchdog@vger.kernel.org
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: rtc-linux@googlegroups.com
> Cc: Sebastian Reichel <sre@kernel.org>
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Wim Van Sebroeck <wim@iguana.be>
>
> Alexandre Belloni (20):
> Documentation: dt: atmel-at91: add clocks to system timer, rstc and
> shdwc
> Documentation: watchdog: at91sam9_wdt: add clocks property
> Documentation: dt: rtc: at91rm9200: add clocks property
> ARM: at91/dt: at91rm9200: use slow clock where necessary
> ARM: at91/dt: at91sam9260: use slow clock where necessary
> ARM: at91/dt: at91sam9261: use slow clock where necessary
> ARM: at91/dt: at91sam9263: use slow clock where necessary
> ARM: at91/dt: at91sam9g45: use slow clock where necessary
> ARM: at91/dt: at91sam9n12: use slow clock where necessary
> ARM: at91/dt: at91sam9rl: use slow clock where necessary
> ARM: at91/dt: at91sam9x5: use slow clock where necessary
> ARM: at91/dt: sama5d3: use slow clock where necessary
> ARM: at91/dt: sama5d4: use slow clock where necessary
> rtc: at91rm9200: get and use slow clock
> watchdog: at91sam9: get and use slow clock
> power/reset: at91-reset: remove useless at91_reset_platform_probe()
> power/reset: at91-reset: get and use slow clock
> power/reset: at91-poweroff: get and use slow clock
> clocksource: atmel-st: get and use slow clock
> clk: at91: Revert "keep slow clk enabled to prevent system hang"
>
> Boris Brezillon (3):
> Documentation: dt: atmel-at91: add slow clock to tcb
> clocksource: tcb_clksrc: fix setup_clkevents error path
> misc: atmel_tclib: get and use slow clock
>
> .../devicetree/bindings/arm/atmel-at91.txt | 13 +++--
> .../bindings/rtc/atmel,at91rm9200-rtc.txt | 2 +
> .../devicetree/bindings/watchdog/atmel-wdt.txt | 2 +
> arch/arm/boot/dts/at91rm9200.dtsi | 10 ++--
> arch/arm/boot/dts/at91sam9260.dtsi | 11 +++--
> arch/arm/boot/dts/at91sam9261.dtsi | 7 ++-
> arch/arm/boot/dts/at91sam9263.dtsi | 7 ++-
> arch/arm/boot/dts/at91sam9g45.dtsi | 12 +++--
> arch/arm/boot/dts/at91sam9n12.dtsi | 12 +++--
> arch/arm/boot/dts/at91sam9rl.dtsi | 8 ++-
> arch/arm/boot/dts/at91sam9x5.dtsi | 12 +++--
> arch/arm/boot/dts/sama5d3.dtsi | 8 ++-
> arch/arm/boot/dts/sama5d3_tcb1.dtsi | 4 +-
> arch/arm/boot/dts/sama5d4.dtsi | 12 +++--
> drivers/clk/at91/clk-slow.c | 27 ----------
> drivers/clocksource/tcb_clksrc.c | 10 +++-
> drivers/clocksource/timer-atmel-st.c | 31 ++++++++----
> drivers/misc/atmel_tclib.c | 4 ++
> drivers/power/reset/at91-poweroff.c | 13 +++++
> drivers/power/reset/at91-reset.c | 57 ++++++----------------
> drivers/pwm/pwm-atmel-tcb.c | 23 ++++++---
> drivers/rtc/rtc-at91rm9200.c | 27 ++++++++--
> drivers/watchdog/at91sam9_wdt.c | 22 ++++++++-
> include/linux/atmel_tc.h | 1 +
> 24 files changed, 206 insertions(+), 129 deletions(-)
>
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
--
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@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 6+ messages in thread* [rtc-linux] Re: [PATCH 00/23] ARM: at91: Properly handle slow clock
2015-07-31 9:59 ` [rtc-linux] Re: [PATCH 00/23] ARM: at91: Properly handle " Boris Brezillon
@ 2015-07-31 10:20 ` Alexandre Belloni
0 siblings, 0 replies; 6+ messages in thread
From: Alexandre Belloni @ 2015-07-31 10:20 UTC (permalink / raw)
To: Boris Brezillon
Cc: Nicolas Ferre, Maxime Ripard, Jean-Christophe Plagniol-Villard,
linux-arm-kernel, linux-kernel, Alessandro Zummo, Arnd Bergmann,
Daniel Lezcano, Dmitry Eremin-Solenikov, Greg Kroah-Hartman,
linux-clk, linux-pm, linux-pwm, linux-watchdog, Michael Turquette,
rtc-linux, Sebastian Reichel, Stephen Boyd, Thierry Reding,
Thomas Gleixner, Wim Van Sebroeck
Hi,
On 31/07/2015 at 11:59:03 +0200, Boris Brezillon wrote :
> I would have squashed commit 5 to 14 into a single patch, but apart
> from that it looks good to me.
>
I wanted to clearly list were the slow clock was needed for each soc. It
actually allowed me to find one that was missing.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
--
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@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [rtc-linux] Re: [PATCH 00/23] ARM: at91: Properly handle slow clock
2015-07-31 9:39 [rtc-linux] [PATCH 00/23] ARM: at91: Properly handle slow clock Alexandre Belloni
` (2 preceding siblings ...)
2015-07-31 9:59 ` [rtc-linux] Re: [PATCH 00/23] ARM: at91: Properly handle " Boris Brezillon
@ 2015-07-31 15:21 ` Alexandre Belloni
3 siblings, 0 replies; 6+ messages in thread
From: Alexandre Belloni @ 2015-07-31 15:21 UTC (permalink / raw)
To: Nicolas Ferre
Cc: Boris Brezillon, Maxime Ripard, Jean-Christophe Plagniol-Villard,
linux-arm-kernel, linux-kernel, Alessandro Zummo, Arnd Bergmann,
Daniel Lezcano, Dmitry Eremin-Solenikov, Greg Kroah-Hartman,
linux-clk, linux-pm, linux-pwm, linux-watchdog, Michael Turquette,
rtc-linux, Sebastian Reichel, Stephen Boyd, Thierry Reding,
Thomas Gleixner, Wim Van Sebroeck
Hi,
I realize now that I forgot to add the v2 tag in the subject lines. This
is really v2 :)
On 31/07/2015 at 11:39:36 +0200, Alexandre Belloni wrote :
> Hi,
>
> It was discovered that all the slow clock user were not properly claiming it.
> This can end up in a system hang because the last registered user is releasing
> it, and it gets disabled.
>
> commit dca1a4b5ff6e ("clk: at91: keep slow clk enabled to prevent system hang")
> was a workaround. This series is adding the slow clock to the necessary drivers
> to avoid the issue and then removes that workaround.
>
> The Documentation updates and DT patches should probably go through the AT91
> tree this cycle to avoid breakage.
>
> Then the other patches can go through each subsystem tree. They are trivial
> enough to also go in this cycle.
>
> The final clk patch depends on the other ones and may be taken for the next
> cycle to avoid synchronization issues.
>
> I've thrown in a cleanup for at91-reset as it avoids adding support for that
> clock to the platform data initialization
>
> Changes in v2:
> - statisticize the global in the atmel-st change
> - merge at91_reset_of_probe() in at91_reset_probe()
> - added patches from Boris for the TCB
> - added the slow clock to the TCB
>
> Cc: Alessandro Zummo <a.zummo@towertech.it>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-clk@vger.kernel.org
> Cc: linux-pm@vger.kernel.org
> Cc: linux-pwm@vger.kernel.org
> Cc: linux-watchdog@vger.kernel.org
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: rtc-linux@googlegroups.com
> Cc: Sebastian Reichel <sre@kernel.org>
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Wim Van Sebroeck <wim@iguana.be>
>
> Alexandre Belloni (20):
> Documentation: dt: atmel-at91: add clocks to system timer, rstc and
> shdwc
> Documentation: watchdog: at91sam9_wdt: add clocks property
> Documentation: dt: rtc: at91rm9200: add clocks property
> ARM: at91/dt: at91rm9200: use slow clock where necessary
> ARM: at91/dt: at91sam9260: use slow clock where necessary
> ARM: at91/dt: at91sam9261: use slow clock where necessary
> ARM: at91/dt: at91sam9263: use slow clock where necessary
> ARM: at91/dt: at91sam9g45: use slow clock where necessary
> ARM: at91/dt: at91sam9n12: use slow clock where necessary
> ARM: at91/dt: at91sam9rl: use slow clock where necessary
> ARM: at91/dt: at91sam9x5: use slow clock where necessary
> ARM: at91/dt: sama5d3: use slow clock where necessary
> ARM: at91/dt: sama5d4: use slow clock where necessary
> rtc: at91rm9200: get and use slow clock
> watchdog: at91sam9: get and use slow clock
> power/reset: at91-reset: remove useless at91_reset_platform_probe()
> power/reset: at91-reset: get and use slow clock
> power/reset: at91-poweroff: get and use slow clock
> clocksource: atmel-st: get and use slow clock
> clk: at91: Revert "keep slow clk enabled to prevent system hang"
>
> Boris Brezillon (3):
> Documentation: dt: atmel-at91: add slow clock to tcb
> clocksource: tcb_clksrc: fix setup_clkevents error path
> misc: atmel_tclib: get and use slow clock
>
> .../devicetree/bindings/arm/atmel-at91.txt | 13 +++--
> .../bindings/rtc/atmel,at91rm9200-rtc.txt | 2 +
> .../devicetree/bindings/watchdog/atmel-wdt.txt | 2 +
> arch/arm/boot/dts/at91rm9200.dtsi | 10 ++--
> arch/arm/boot/dts/at91sam9260.dtsi | 11 +++--
> arch/arm/boot/dts/at91sam9261.dtsi | 7 ++-
> arch/arm/boot/dts/at91sam9263.dtsi | 7 ++-
> arch/arm/boot/dts/at91sam9g45.dtsi | 12 +++--
> arch/arm/boot/dts/at91sam9n12.dtsi | 12 +++--
> arch/arm/boot/dts/at91sam9rl.dtsi | 8 ++-
> arch/arm/boot/dts/at91sam9x5.dtsi | 12 +++--
> arch/arm/boot/dts/sama5d3.dtsi | 8 ++-
> arch/arm/boot/dts/sama5d3_tcb1.dtsi | 4 +-
> arch/arm/boot/dts/sama5d4.dtsi | 12 +++--
> drivers/clk/at91/clk-slow.c | 27 ----------
> drivers/clocksource/tcb_clksrc.c | 10 +++-
> drivers/clocksource/timer-atmel-st.c | 31 ++++++++----
> drivers/misc/atmel_tclib.c | 4 ++
> drivers/power/reset/at91-poweroff.c | 13 +++++
> drivers/power/reset/at91-reset.c | 57 ++++++----------------
> drivers/pwm/pwm-atmel-tcb.c | 23 ++++++---
> drivers/rtc/rtc-at91rm9200.c | 27 ++++++++--
> drivers/watchdog/at91sam9_wdt.c | 22 ++++++++-
> include/linux/atmel_tc.h | 1 +
> 24 files changed, 206 insertions(+), 129 deletions(-)
>
> --
> 2.1.4
>
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
--
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@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 6+ messages in thread