LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v5 00/10] Atmel System Timer cleanups
@ 2015-03-12 12:07 Alexandre Belloni
  2015-03-12 12:07 ` [PATCH v5 01/10] ARM: at91/dt: declare atmel,at91rm9200-st as a syscon Alexandre Belloni
                   ` (11 more replies)
  0 siblings, 12 replies; 28+ messages in thread
From: Alexandre Belloni @ 2015-03-12 12:07 UTC (permalink / raw)
  To: Nicolas Ferre, Daniel Lezcano
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog, Alexandre Belloni

This patch set cleans up the system timer driver.

The main goal is to get rid of the mach/ headers dependency. At the same time,
it introduces proper probing and locking (using a regmap) for the watchdog
driver.

This is based on 4.0-rc1 and will have two merge conflicts with my cleanup #1 in
mach-at91/at91rm9200.c

It also needs this patch to probe the watchdog properly:
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/327274.html

Changes in v5:
 - Documented the watchdog compatible
 - Switched to simple-mfd to probe the system timer subnodes
 - Selected ATMEL_ST from mach-at91/Kconfig instead of using def_bool SOC_AT91RM9200
 - Reordered the atmel-st probe cleanup and its move to driver/clocksource
 - Added a patch to replace setup_irq by request_irq
 - Merged the reset handling in the watchdog timer as we are using the watchdog
   anyway to reset the board.
 - Used a simple space after a #define for registers

Changes in v4:
 - Added MODULE_* metadata in at91rm9200-reset
 - Proper copyright in at91rm9200-reset
 - Use BIT() in atmel-st.h
 - changed MODULE_ALIAS in at91rm9200_wdt.c

Changes in v3:
 - stop using an mfd and get the syscon directly from the watchdog driver
 - introduce a proper reset driver to handle reset

Changes in v2:
 - cleaned up more includes in the watchdog driver
 - stop using if OF when selecting CLKSRC_OF
 - stop initializing .owner


Alexandre Belloni (10):
  ARM: at91/dt: declare atmel,at91rm9200-st as a syscon
  mfd: syscon: Add atmel system timer registers definition
  watchdog: at91rm9200: use the system timer syscon
  watchdog: at91rm9200: implement restart handler
  ARM: at91: at91rm9200: remove deprecated arm_pm_restart
  ARM: at91: properly initialize timer
  ARM: at91: time: move the system timer driver to drivers/clocksource
  clocksource: atmel-st: use syscon/regmap
  clocksource: atmel-st: remove mach/hardware dependency
  ARM: at91: remove useless include

 .../devicetree/bindings/arm/atmel-at91.txt         |   4 +-
 arch/arm/boot/dts/at91rm9200.dtsi                  |   6 +-
 arch/arm/mach-at91/Kconfig                         |   1 +
 arch/arm/mach-at91/Makefile                        |   2 +-
 arch/arm/mach-at91/at91rm9200.c                    |  19 ----
 arch/arm/mach-at91/generic.h                       |   3 -
 arch/arm/mach-at91/include/mach/at91_st.h          |  61 -----------
 drivers/clocksource/Kconfig                        |   4 +
 drivers/clocksource/Makefile                       |   1 +
 .../clocksource/timer-atmel-st.c                   | 115 ++++++++-------------
 drivers/watchdog/Kconfig                           |   2 +-
 drivers/watchdog/at91rm9200_wdt.c                  |  61 +++++++++--
 include/linux/mfd/syscon/atmel-st.h                |  49 +++++++++
 13 files changed, 164 insertions(+), 164 deletions(-)
 delete mode 100644 arch/arm/mach-at91/include/mach/at91_st.h
 rename arch/arm/mach-at91/at91rm9200_time.c => drivers/clocksource/timer-atmel-st.c (74%)
 create mode 100644 include/linux/mfd/syscon/atmel-st.h

-- 
2.1.0


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

* [PATCH v5 01/10] ARM: at91/dt: declare atmel,at91rm9200-st as a syscon
  2015-03-12 12:07 [PATCH v5 00/10] Atmel System Timer cleanups Alexandre Belloni
@ 2015-03-12 12:07 ` Alexandre Belloni
  2015-03-12 12:07 ` [PATCH v5 02/10] mfd: syscon: Add atmel system timer registers definition Alexandre Belloni
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Alexandre Belloni @ 2015-03-12 12:07 UTC (permalink / raw)
  To: Nicolas Ferre, Daniel Lezcano
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog, Alexandre Belloni

The system timer register range is used to handle three different
functionalities: Periodic Interval Timer, Real Time Timer and watchdog. Declare
it as a syscon to be able to get a regmap.
Also declare it as a simple-mfd and its watchdog subnode.

Finally, document the watchdog compatible string.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

fixup! ARM: at91/dt: declare atmel,at91rm9200-st as a syscon
---
 Documentation/devicetree/bindings/arm/atmel-at91.txt | 4 +++-
 arch/arm/boot/dts/at91rm9200.dtsi                    | 6 +++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/atmel-at91.txt b/Documentation/devicetree/bindings/arm/atmel-at91.txt
index ad319f84f560..2e99b5b57350 100644
--- a/Documentation/devicetree/bindings/arm/atmel-at91.txt
+++ b/Documentation/devicetree/bindings/arm/atmel-at91.txt
@@ -46,10 +46,12 @@ PIT Timer required properties:
   shared across all System Controller members.
 
 System Timer (ST) required properties:
-- compatible: Should be "atmel,at91rm9200-st"
+- compatible: Should be "atmel,at91rm9200-st", "syscon", "simple-mfd"
 - reg: Should contain registers location and length
 - interrupts: Should contain interrupt for the ST which is the IRQ line
   shared across all System Controller members.
+Its subnodes can be:
+- watchdog: compatible should be "atmel,at91rm9200-wdt"
 
 TC/TCLIB Timer required properties:
 - compatible: Should be "atmel,<chip>-tcb".
diff --git a/arch/arm/boot/dts/at91rm9200.dtsi b/arch/arm/boot/dts/at91rm9200.dtsi
index 21c2b504f977..b777d21b8a7c 100644
--- a/arch/arm/boot/dts/at91rm9200.dtsi
+++ b/arch/arm/boot/dts/at91rm9200.dtsi
@@ -356,9 +356,13 @@
 			};
 
 			st: timer@fffffd00 {
-				compatible = "atmel,at91rm9200-st";
+				compatible = "atmel,at91rm9200-st", "syscon", "simple-mfd";
 				reg = <0xfffffd00 0x100>;
 				interrupts = <1 IRQ_TYPE_LEVEL_HIGH 7>;
+
+				watchdog {
+					compatible = "atmel,at91rm9200-wdt";
+				};
 			};
 
 			rtc: rtc@fffffe00 {
-- 
2.1.0


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

* [PATCH v5 02/10] mfd: syscon: Add atmel system timer registers definition
  2015-03-12 12:07 [PATCH v5 00/10] Atmel System Timer cleanups Alexandre Belloni
  2015-03-12 12:07 ` [PATCH v5 01/10] ARM: at91/dt: declare atmel,at91rm9200-st as a syscon Alexandre Belloni
@ 2015-03-12 12:07 ` Alexandre Belloni
  2015-03-13  8:03   ` Lee Jones
  2015-03-12 12:07 ` [PATCH v5 03/10] watchdog: at91rm9200: use the system timer syscon Alexandre Belloni
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 28+ messages in thread
From: Alexandre Belloni @ 2015-03-12 12:07 UTC (permalink / raw)
  To: Nicolas Ferre, Daniel Lezcano
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog, Alexandre Belloni

AT91RM920 has a memory range reserved for timer and watchdog configuration.
Expose those registers so that drivers can make use of the system timer syscon
declared in at91 DTs.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
---
 include/linux/mfd/syscon/atmel-st.h | 49 +++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 include/linux/mfd/syscon/atmel-st.h

diff --git a/include/linux/mfd/syscon/atmel-st.h b/include/linux/mfd/syscon/atmel-st.h
new file mode 100644
index 000000000000..8acf1ec1fa32
--- /dev/null
+++ b/include/linux/mfd/syscon/atmel-st.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2005 Ivan Kokshaysky
+ * Copyright (C) SAN People
+ *
+ * System Timer (ST) - System peripherals registers.
+ * Based on AT91RM9200 datasheet revision E.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef _LINUX_MFD_SYSCON_ATMEL_ST_H
+#define _LINUX_MFD_SYSCON_ATMEL_ST_H
+
+#include <linux/bitops.h>
+
+#define AT91_ST_CR	0x00	/* Control Register */
+#define		AT91_ST_WDRST	BIT(0)	/* Watchdog Timer Restart */
+
+#define AT91_ST_PIMR	0x04	/* Period Interval Mode Register */
+#define		AT91_ST_PIV	0xffff	/* Period Interval Value */
+
+#define AT91_ST_WDMR	0x08	/* Watchdog Mode Register */
+#define		AT91_ST_WDV	0xffff	/* Watchdog Counter Value */
+#define		AT91_ST_RSTEN	BIT(16)	/* Reset Enable */
+#define		AT91_ST_EXTEN	BIT(17)	/* External Signal Assertion Enable */
+
+#define AT91_ST_RTMR	0x0c	/* Real-time Mode Register */
+#define		AT91_ST_RTPRES	0xffff	/* Real-time Prescalar Value */
+
+#define AT91_ST_SR	0x10	/* Status Register */
+#define		AT91_ST_PITS	BIT(0)	/* Period Interval Timer Status */
+#define		AT91_ST_WDOVF	BIT(1)	/* Watchdog Overflow */
+#define		AT91_ST_RTTINC	BIT(2)	/* Real-time Timer Increment */
+#define		AT91_ST_ALMS	BIT(3)	/* Alarm Status */
+
+#define AT91_ST_IER	0x14	/* Interrupt Enable Register */
+#define AT91_ST_IDR	0x18	/* Interrupt Disable Register */
+#define AT91_ST_IMR	0x1c	/* Interrupt Mask Register */
+
+#define AT91_ST_RTAR	0x20	/* Real-time Alarm Register */
+#define		AT91_ST_ALMV	0xfffff	/* Alarm Value */
+
+#define AT91_ST_CRTR	0x24	/* Current Real-time Register */
+#define		AT91_ST_CRTV	0xfffff	/* Current Real-Time Value */
+
+#endif /* _LINUX_MFD_SYSCON_ATMEL_ST_H */
-- 
2.1.0


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

* [PATCH v5 03/10] watchdog: at91rm9200: use the system timer syscon
  2015-03-12 12:07 [PATCH v5 00/10] Atmel System Timer cleanups Alexandre Belloni
  2015-03-12 12:07 ` [PATCH v5 01/10] ARM: at91/dt: declare atmel,at91rm9200-st as a syscon Alexandre Belloni
  2015-03-12 12:07 ` [PATCH v5 02/10] mfd: syscon: Add atmel system timer registers definition Alexandre Belloni
@ 2015-03-12 12:07 ` Alexandre Belloni
  2015-03-12 16:19   ` Guenter Roeck
  2015-03-12 12:07 ` [PATCH v5 04/10] watchdog: at91rm9200: implement restart handler Alexandre Belloni
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 28+ messages in thread
From: Alexandre Belloni @ 2015-03-12 12:07 UTC (permalink / raw)
  To: Nicolas Ferre, Daniel Lezcano
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog, Alexandre Belloni

Use a syscon regmap to access the system timer registers.

Also, rename the driver atmel_st_watchdog to stop conflicting with
at91sam9_wdt.c

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/watchdog/Kconfig          |  2 +-
 drivers/watchdog/at91rm9200_wdt.c | 29 ++++++++++++++++++++++-------
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 16f202350997..ce4f3a7f95fd 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -154,7 +154,7 @@ config ARM_SP805_WATCHDOG
 
 config AT91RM9200_WATCHDOG
 	tristate "AT91RM9200 watchdog"
-	depends on SOC_AT91RM9200
+	depends on SOC_AT91RM9200 && MFD_SYSCON
 	help
 	  Watchdog timer embedded into AT91RM9200 chips. This will reboot your
 	  system when the timeout is reached.
diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c
index d244112d5b6f..e6fa87d85de3 100644
--- a/drivers/watchdog/at91rm9200_wdt.c
+++ b/drivers/watchdog/at91rm9200_wdt.c
@@ -17,22 +17,25 @@
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
+#include <linux/mfd/syscon.h>
+#include <linux/mfd/syscon/atmel-st.h>
 #include <linux/miscdevice.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/platform_device.h>
+#include <linux/regmap.h>
 #include <linux/types.h>
 #include <linux/watchdog.h>
 #include <linux/uaccess.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
-#include <mach/at91_st.h>
 
 #define WDT_DEFAULT_TIME	5	/* seconds */
 #define WDT_MAX_TIME		256	/* seconds */
 
 static int wdt_time = WDT_DEFAULT_TIME;
 static bool nowayout = WATCHDOG_NOWAYOUT;
+static struct regmap *regmap_st;
 
 module_param(wdt_time, int, 0);
 MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="
@@ -55,7 +58,7 @@ static unsigned long at91wdt_busy;
  */
 static inline void at91_wdt_stop(void)
 {
-	at91_st_write(AT91_ST_WDMR, AT91_ST_EXTEN);
+	regmap_write(regmap_st, AT91_ST_WDMR, AT91_ST_EXTEN);
 }
 
 /*
@@ -63,9 +66,9 @@ static inline void at91_wdt_stop(void)
  */
 static inline void at91_wdt_start(void)
 {
-	at91_st_write(AT91_ST_WDMR, AT91_ST_EXTEN | AT91_ST_RSTEN |
+	regmap_write(regmap_st, AT91_ST_WDMR, AT91_ST_EXTEN | AT91_ST_RSTEN |
 				(((65536 * wdt_time) >> 8) & AT91_ST_WDV));
-	at91_st_write(AT91_ST_CR, AT91_ST_WDRST);
+	regmap_write(regmap_st, AT91_ST_CR, AT91_ST_WDRST);
 }
 
 /*
@@ -73,7 +76,7 @@ static inline void at91_wdt_start(void)
  */
 static inline void at91_wdt_reload(void)
 {
-	at91_st_write(AT91_ST_CR, AT91_ST_WDRST);
+	regmap_write(regmap_st, AT91_ST_CR, AT91_ST_WDRST);
 }
 
 /* ......................................................................... */
@@ -203,12 +206,24 @@ static struct miscdevice at91wdt_miscdev = {
 
 static int at91wdt_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
+	struct device *parent;
 	int res;
 
 	if (at91wdt_miscdev.parent)
 		return -EBUSY;
 	at91wdt_miscdev.parent = &pdev->dev;
 
+	parent = dev->parent;
+	if (!parent) {
+		dev_err(dev, "no parent\n");
+		return -ENODEV;
+	}
+
+	regmap_st = syscon_node_to_regmap(parent->of_node);
+	if (!regmap_st)
+		return -ENODEV;
+
 	res = misc_register(&at91wdt_miscdev);
 	if (res)
 		return res;
@@ -267,7 +282,7 @@ static struct platform_driver at91wdt_driver = {
 	.suspend	= at91wdt_suspend,
 	.resume		= at91wdt_resume,
 	.driver		= {
-		.name	= "at91_wdt",
+		.name	= "atmel_st_watchdog",
 		.of_match_table = at91_wdt_dt_ids,
 	},
 };
@@ -296,4 +311,4 @@ module_exit(at91_wdt_exit);
 MODULE_AUTHOR("Andrew Victor");
 MODULE_DESCRIPTION("Watchdog driver for Atmel AT91RM9200");
 MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:at91_wdt");
+MODULE_ALIAS("platform:atmel_st_watchdog");
-- 
2.1.0


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

* [PATCH v5 04/10] watchdog: at91rm9200: implement restart handler
  2015-03-12 12:07 [PATCH v5 00/10] Atmel System Timer cleanups Alexandre Belloni
                   ` (2 preceding siblings ...)
  2015-03-12 12:07 ` [PATCH v5 03/10] watchdog: at91rm9200: use the system timer syscon Alexandre Belloni
@ 2015-03-12 12:07 ` Alexandre Belloni
  2015-03-12 16:22   ` Guenter Roeck
  2015-03-12 12:07 ` [PATCH v5 05/10] ARM: at91: at91rm9200: remove deprecated arm_pm_restart Alexandre Belloni
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 28+ messages in thread
From: Alexandre Belloni @ 2015-03-12 12:07 UTC (permalink / raw)
  To: Nicolas Ferre, Daniel Lezcano
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog, Alexandre Belloni

Restarting the at91rm9200 is done through programming the watchdog and waiting
for it to reset.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/watchdog/at91rm9200_wdt.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c
index e6fa87d85de3..41cecb55766c 100644
--- a/drivers/watchdog/at91rm9200_wdt.c
+++ b/drivers/watchdog/at91rm9200_wdt.c
@@ -12,6 +12,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/bitops.h>
+#include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
 #include <linux/init.h>
@@ -23,6 +24,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/platform_device.h>
+#include <linux/reboot.h>
 #include <linux/regmap.h>
 #include <linux/types.h>
 #include <linux/watchdog.h>
@@ -53,6 +55,27 @@ static unsigned long at91wdt_busy;
 
 /* ......................................................................... */
 
+static int at91rm9200_restart(struct notifier_block *this,
+					unsigned long mode, void *cmd)
+{
+	/*
+	 * Perform a hardware reset with the use of the Watchdog timer.
+	 */
+	regmap_write(regmap_st, AT91_ST_WDMR,
+		     AT91_ST_RSTEN | AT91_ST_EXTEN | 1);
+	regmap_write(regmap_st, AT91_ST_CR, AT91_ST_WDRST);
+
+	mdelay(2000);
+
+	pr_emerg("Unable to restart system\n");
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block at91rm9200_restart_nb = {
+	.notifier_call = at91rm9200_restart,
+	.priority = 192,
+};
+
 /*
  * Disable the watchdog.
  */
@@ -228,6 +251,10 @@ static int at91wdt_probe(struct platform_device *pdev)
 	if (res)
 		return res;
 
+	res = register_restart_handler(&at91rm9200_restart_nb);
+	if (res)
+		dev_warn(dev, "failed to register restart handler\n");
+
 	pr_info("AT91 Watchdog Timer enabled (%d seconds%s)\n",
 		wdt_time, nowayout ? ", nowayout" : "");
 	return 0;
@@ -235,8 +262,13 @@ static int at91wdt_probe(struct platform_device *pdev)
 
 static int at91wdt_remove(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	int res;
 
+	res = unregister_restart_handler(&at91rm9200_restart_nb);
+	if (res)
+		dev_warn(dev, "failed to unregister restart handler\n");
+
 	res = misc_deregister(&at91wdt_miscdev);
 	if (!res)
 		at91wdt_miscdev.parent = NULL;
-- 
2.1.0


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

* [PATCH v5 05/10] ARM: at91: at91rm9200: remove deprecated arm_pm_restart
  2015-03-12 12:07 [PATCH v5 00/10] Atmel System Timer cleanups Alexandre Belloni
                   ` (3 preceding siblings ...)
  2015-03-12 12:07 ` [PATCH v5 04/10] watchdog: at91rm9200: implement restart handler Alexandre Belloni
@ 2015-03-12 12:07 ` Alexandre Belloni
  2015-03-12 12:07 ` [PATCH v5 06/10] ARM: at91: properly initialize timer Alexandre Belloni
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Alexandre Belloni @ 2015-03-12 12:07 UTC (permalink / raw)
  To: Nicolas Ferre, Daniel Lezcano
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog, Alexandre Belloni

Now that a proper driver is available, remove at91rm9200_restart.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/mach-at91/at91rm9200.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
index 8fcfb70f7124..2386d08d65e8 100644
--- a/arch/arm/mach-at91/at91rm9200.c
+++ b/arch/arm/mach-at91/at91rm9200.c
@@ -24,19 +24,8 @@
 #include <asm/mach/irq.h>
 #include <asm/system_misc.h>
 
-#include <mach/at91_st.h>
-
 #include "generic.h"
 
-static void at91rm9200_restart(enum reboot_mode reboot_mode, const char *cmd)
-{
-	/*
-	 * Perform a hardware reset with the use of the Watchdog timer.
-	 */
-	at91_st_write(AT91_ST_WDMR, AT91_ST_RSTEN | AT91_ST_EXTEN | 1);
-	at91_st_write(AT91_ST_CR, AT91_ST_WDRST);
-}
-
 static void __init at91rm9200_dt_timer_init(void)
 {
 	of_clk_init(NULL);
@@ -48,7 +37,6 @@ static void __init at91rm9200_dt_device_init(void)
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 
 	arm_pm_idle = at91rm9200_idle;
-	arm_pm_restart = at91rm9200_restart;
 	at91rm9200_pm_init();
 }
 
-- 
2.1.0


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

* [PATCH v5 06/10] ARM: at91: properly initialize timer
  2015-03-12 12:07 [PATCH v5 00/10] Atmel System Timer cleanups Alexandre Belloni
                   ` (4 preceding siblings ...)
  2015-03-12 12:07 ` [PATCH v5 05/10] ARM: at91: at91rm9200: remove deprecated arm_pm_restart Alexandre Belloni
@ 2015-03-12 12:07 ` Alexandre Belloni
  2015-03-12 12:07 ` [PATCH v5 07/10] ARM: at91: time: move the system timer driver to drivers/clocksource Alexandre Belloni
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Alexandre Belloni @ 2015-03-12 12:07 UTC (permalink / raw)
  To: Nicolas Ferre, Daniel Lezcano
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog, Alexandre Belloni

Use clocksource_of_init to initialize the system timer instead of relying on a
custom function.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-at91/at91rm9200.c      | 7 -------
 arch/arm/mach-at91/at91rm9200_time.c | 4 +++-
 arch/arm/mach-at91/generic.h         | 3 ---
 3 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
index 2386d08d65e8..5efb075294e5 100644
--- a/arch/arm/mach-at91/at91rm9200.c
+++ b/arch/arm/mach-at91/at91rm9200.c
@@ -26,12 +26,6 @@
 
 #include "generic.h"
 
-static void __init at91rm9200_dt_timer_init(void)
-{
-	of_clk_init(NULL);
-	at91rm9200_timer_init();
-}
-
 static void __init at91rm9200_dt_device_init(void)
 {
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
@@ -48,7 +42,6 @@ static const char *at91rm9200_dt_board_compat[] __initconst = {
 };
 
 DT_MACHINE_START(at91rm9200_dt, "Atmel AT91RM9200")
-	.init_time      = at91rm9200_dt_timer_init,
 	.map_io		= at91_map_io,
 	.init_machine	= at91rm9200_dt_device_init,
 	.dt_compat	= at91rm9200_dt_board_compat,
diff --git a/arch/arm/mach-at91/at91rm9200_time.c b/arch/arm/mach-at91/at91rm9200_time.c
index b00d09555f2b..7d062ab32674 100644
--- a/arch/arm/mach-at91/at91rm9200_time.c
+++ b/arch/arm/mach-at91/at91rm9200_time.c
@@ -222,7 +222,7 @@ err:
 /*
  * ST (system timer) module supports both clockevents and clocksource.
  */
-void __init at91rm9200_timer_init(void)
+static void __init atmel_st_timer_init(struct device_node *node)
 {
 	/* For device tree enabled device: initialize here */
 	of_at91rm9200_st_init();
@@ -249,3 +249,5 @@ void __init at91rm9200_timer_init(void)
 	/* register clocksource */
 	clocksource_register_hz(&clk32k, AT91_SLOW_CLOCK);
 }
+CLOCKSOURCE_OF_DECLARE(atmel_st_timer, "atmel,at91rm9200-st",
+		       atmel_st_timer_init);
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index 583369ffc284..6c953bff13d6 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -18,9 +18,6 @@
 extern void __init at91_map_io(void);
 extern void __init at91_alt_map_io(void);
 
- /* Timer */
-extern void at91rm9200_timer_init(void);
-
 /* idle */
 extern void at91rm9200_idle(void);
 extern void at91sam9_idle(void);
-- 
2.1.0


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

* [PATCH v5 07/10] ARM: at91: time: move the system timer driver to drivers/clocksource
  2015-03-12 12:07 [PATCH v5 00/10] Atmel System Timer cleanups Alexandre Belloni
                   ` (5 preceding siblings ...)
  2015-03-12 12:07 ` [PATCH v5 06/10] ARM: at91: properly initialize timer Alexandre Belloni
@ 2015-03-12 12:07 ` Alexandre Belloni
  2015-03-13 10:14   ` Daniel Lezcano
  2015-03-12 12:07 ` [PATCH v5 08/10] clocksource: atmel-st: use syscon/regmap Alexandre Belloni
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 28+ messages in thread
From: Alexandre Belloni @ 2015-03-12 12:07 UTC (permalink / raw)
  To: Nicolas Ferre, Daniel Lezcano
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog, Alexandre Belloni

Import at91rm9200_time.c from mach-at91 as timer-atmel-st.c. Further cleanup is
required to get rid of the mach-at91 headers.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 arch/arm/mach-at91/Kconfig                                            | 1 +
 arch/arm/mach-at91/Makefile                                           | 2 +-
 drivers/clocksource/Kconfig                                           | 4 ++++
 drivers/clocksource/Makefile                                          | 1 +
 .../at91rm9200_time.c => drivers/clocksource/timer-atmel-st.c         | 0
 5 files changed, 7 insertions(+), 1 deletion(-)
 rename arch/arm/mach-at91/at91rm9200_time.c => drivers/clocksource/timer-atmel-st.c (100%)

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index c74a44324e5b..dabce086fa47 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -77,6 +77,7 @@ if SOC_SAM_V4_V5
 config SOC_AT91RM9200
 	bool "AT91RM9200"
 	select ATMEL_AIC_IRQ
+	select ATMEL_ST
 	select COMMON_CLK_AT91
 	select CPU_ARM920T
 	select GENERIC_CLOCKEVENTS
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 827fdbcce1c7..963c29169242 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -7,7 +7,7 @@ obj-y		:= setup.o
 obj-$(CONFIG_SOC_AT91SAM9)	+= sam9_smc.o
 
 # CPU-specific support
-obj-$(CONFIG_SOC_AT91RM9200)	+= at91rm9200.o at91rm9200_time.o
+obj-$(CONFIG_SOC_AT91RM9200)	+= at91rm9200.o
 obj-$(CONFIG_SOC_AT91SAM9)	+= at91sam9.o
 obj-$(CONFIG_SOC_SAMA5)		+= sama5.o
 
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 1c2506f68122..6c45f504baff 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -138,6 +138,10 @@ config ATMEL_PIT
 	select CLKSRC_OF if OF
 	def_bool SOC_AT91SAM9 || SOC_SAMA5
 
+config ATMEL_ST
+	bool
+	select CLKSRC_OF
+
 config CLKSRC_METAG_GENERIC
 	def_bool y if METAG
 	help
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 752d5c70b0ef..5b85f6adb258 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -1,5 +1,6 @@
 obj-$(CONFIG_CLKSRC_OF)	+= clksrc-of.o
 obj-$(CONFIG_ATMEL_PIT)		+= timer-atmel-pit.o
+obj-$(CONFIG_ATMEL_ST)		+= timer-atmel-st.o
 obj-$(CONFIG_ATMEL_TCB_CLKSRC)	+= tcb_clksrc.o
 obj-$(CONFIG_X86_PM_TIMER)	+= acpi_pm.o
 obj-$(CONFIG_SCx200HR_TIMER)	+= scx200_hrt.o
diff --git a/arch/arm/mach-at91/at91rm9200_time.c b/drivers/clocksource/timer-atmel-st.c
similarity index 100%
rename from arch/arm/mach-at91/at91rm9200_time.c
rename to drivers/clocksource/timer-atmel-st.c
-- 
2.1.0


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

* [PATCH v5 08/10] clocksource: atmel-st: use syscon/regmap
  2015-03-12 12:07 [PATCH v5 00/10] Atmel System Timer cleanups Alexandre Belloni
                   ` (6 preceding siblings ...)
  2015-03-12 12:07 ` [PATCH v5 07/10] ARM: at91: time: move the system timer driver to drivers/clocksource Alexandre Belloni
@ 2015-03-12 12:07 ` Alexandre Belloni
  2015-03-13 10:17   ` Daniel Lezcano
  2015-03-12 12:07 ` [PATCH v5 09/10] clocksource: atmel-st: remove mach/hardware dependency Alexandre Belloni
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 28+ messages in thread
From: Alexandre Belloni @ 2015-03-12 12:07 UTC (permalink / raw)
  To: Nicolas Ferre, Daniel Lezcano
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog, Alexandre Belloni

The register range from the system timer is also used by the watchdog driver.
Use a regmap to handle concurrent accesses.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 drivers/clocksource/timer-atmel-st.c | 94 ++++++++++++++----------------------
 1 file changed, 35 insertions(+), 59 deletions(-)

diff --git a/drivers/clocksource/timer-atmel-st.c b/drivers/clocksource/timer-atmel-st.c
index 7d062ab32674..674ef2519d6b 100644
--- a/drivers/clocksource/timer-atmel-st.c
+++ b/drivers/clocksource/timer-atmel-st.c
@@ -24,18 +24,19 @@
 #include <linux/irq.h>
 #include <linux/clockchips.h>
 #include <linux/export.h>
-#include <linux/of.h>
-#include <linux/of_address.h>
+#include <linux/mfd/syscon.h>
+#include <linux/mfd/syscon/atmel-st.h>
 #include <linux/of_irq.h>
+#include <linux/regmap.h>
 
 #include <asm/mach/time.h>
 
-#include <mach/at91_st.h>
 #include <mach/hardware.h>
 
 static unsigned long last_crtr;
 static u32 irqmask;
 static struct clock_event_device clkevt;
+static struct regmap *regmap_st;
 
 #define RM9200_TIMER_LATCH	((AT91_SLOW_CLOCK + HZ/2) / HZ)
 
@@ -46,11 +47,11 @@ static struct clock_event_device clkevt;
  */
 static inline unsigned long read_CRTR(void)
 {
-	unsigned long x1, x2;
+	unsigned int x1, x2;
 
-	x1 = at91_st_read(AT91_ST_CRTR);
+	regmap_read(regmap_st, AT91_ST_CRTR, &x1);
 	do {
-		x2 = at91_st_read(AT91_ST_CRTR);
+		regmap_read(regmap_st, AT91_ST_CRTR, &x2);
 		if (x1 == x2)
 			break;
 		x1 = x2;
@@ -63,7 +64,10 @@ static inline unsigned long read_CRTR(void)
  */
 static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id)
 {
-	u32	sr = at91_st_read(AT91_ST_SR) & irqmask;
+	u32 sr;
+
+	regmap_read(regmap_st, AT91_ST_SR, &sr);
+	sr &= irqmask;
 
 	/*
 	 * irqs should be disabled here, but as the irq is shared they are only
@@ -115,23 +119,25 @@ static struct clocksource clk32k = {
 static void
 clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev)
 {
+	unsigned int val;
+
 	/* Disable and flush pending timer interrupts */
-	at91_st_write(AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS);
-	at91_st_read(AT91_ST_SR);
+	regmap_write(regmap_st, AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS);
+	regmap_read(regmap_st, AT91_ST_SR, &val);
 
 	last_crtr = read_CRTR();
 	switch (mode) {
 	case CLOCK_EVT_MODE_PERIODIC:
 		/* PIT for periodic irqs; fixed rate of 1/HZ */
 		irqmask = AT91_ST_PITS;
-		at91_st_write(AT91_ST_PIMR, RM9200_TIMER_LATCH);
+		regmap_write(regmap_st, AT91_ST_PIMR, RM9200_TIMER_LATCH);
 		break;
 	case CLOCK_EVT_MODE_ONESHOT:
 		/* ALM for oneshot irqs, set by next_event()
 		 * before 32 seconds have passed
 		 */
 		irqmask = AT91_ST_ALMS;
-		at91_st_write(AT91_ST_RTAR, last_crtr);
+		regmap_write(regmap_st, AT91_ST_RTAR, last_crtr);
 		break;
 	case CLOCK_EVT_MODE_SHUTDOWN:
 	case CLOCK_EVT_MODE_UNUSED:
@@ -139,7 +145,7 @@ clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev)
 		irqmask = 0;
 		break;
 	}
-	at91_st_write(AT91_ST_IER, irqmask);
+	regmap_write(regmap_st, AT91_ST_IER, irqmask);
 }
 
 static int
@@ -147,6 +153,7 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev)
 {
 	u32		alm;
 	int		status = 0;
+	unsigned int	val;
 
 	BUG_ON(delta < 2);
 
@@ -162,12 +169,12 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev)
 	alm = read_CRTR();
 
 	/* Cancel any pending alarm; flush any pending IRQ */
-	at91_st_write(AT91_ST_RTAR, alm);
-	at91_st_read(AT91_ST_SR);
+	regmap_write(regmap_st, AT91_ST_RTAR, alm);
+	regmap_read(regmap_st, AT91_ST_SR, &val);
 
 	/* Schedule alarm by writing RTAR. */
 	alm += delta;
-	at91_st_write(AT91_ST_RTAR, alm);
+	regmap_write(regmap_st, AT91_ST_RTAR, alm);
 
 	return status;
 }
@@ -180,57 +187,26 @@ static struct clock_event_device clkevt = {
 	.set_mode	= clkevt32k_mode,
 };
 
-void __iomem *at91_st_base;
-EXPORT_SYMBOL_GPL(at91_st_base);
-
-static const struct of_device_id at91rm9200_st_timer_ids[] = {
-	{ .compatible = "atmel,at91rm9200-st" },
-	{ /* sentinel */ }
-};
-
-static int __init of_at91rm9200_st_init(void)
-{
-	struct device_node *np;
-	int ret;
-
-	np = of_find_matching_node(NULL, at91rm9200_st_timer_ids);
-	if (!np)
-		goto err;
-
-	at91_st_base = of_iomap(np, 0);
-	if (!at91_st_base)
-		goto node_err;
-
-	/* Get the interrupts property */
-	ret = irq_of_parse_and_map(np, 0);
-	if (!ret)
-		goto ioremap_err;
-	at91rm9200_timer_irq.irq = ret;
-
-	of_node_put(np);
-
-	return 0;
-
-ioremap_err:
-	iounmap(at91_st_base);
-node_err:
-	of_node_put(np);
-err:
-	return -EINVAL;
-}
-
 /*
  * ST (system timer) module supports both clockevents and clocksource.
  */
 static void __init atmel_st_timer_init(struct device_node *node)
 {
-	/* For device tree enabled device: initialize here */
-	of_at91rm9200_st_init();
+	unsigned int val;
+
+	regmap_st = syscon_node_to_regmap(node);
+	if (IS_ERR(regmap_st))
+		panic(pr_fmt("Unable to get regmap\n"));
 
 	/* Disable all timer interrupts, and clear any pending ones */
-	at91_st_write(AT91_ST_IDR,
+	regmap_write(regmap_st, AT91_ST_IDR,
 		AT91_ST_PITS | AT91_ST_WDOVF | AT91_ST_RTTINC | AT91_ST_ALMS);
-	at91_st_read(AT91_ST_SR);
+	regmap_read(regmap_st, AT91_ST_SR, &val);
+
+	/* Get the interrupts property */
+	at91rm9200_timer_irq.irq  = irq_of_parse_and_map(node, 0);
+	if (!at91rm9200_timer_irq.irq)
+		panic(pr_fmt("Unable to get IRQ from DT\n"));
 
 	/* Make IRQs happen for the system timer */
 	setup_irq(at91rm9200_timer_irq.irq, &at91rm9200_timer_irq);
@@ -239,7 +215,7 @@ static void __init atmel_st_timer_init(struct device_node *node)
 	 * directly for the clocksource and all clockevents, after adjusting
 	 * its prescaler from the 1 Hz default.
 	 */
-	at91_st_write(AT91_ST_RTMR, 1);
+	regmap_write(regmap_st, AT91_ST_RTMR, 1);
 
 	/* Setup timer clockevent, with minimum of two ticks (important!!) */
 	clkevt.cpumask = cpumask_of(0);
-- 
2.1.0


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

* [PATCH v5 09/10] clocksource: atmel-st: remove mach/hardware dependency
  2015-03-12 12:07 [PATCH v5 00/10] Atmel System Timer cleanups Alexandre Belloni
                   ` (7 preceding siblings ...)
  2015-03-12 12:07 ` [PATCH v5 08/10] clocksource: atmel-st: use syscon/regmap Alexandre Belloni
@ 2015-03-12 12:07 ` Alexandre Belloni
  2015-03-13 10:21   ` Daniel Lezcano
  2015-03-13 10:54   ` [PATCH v6 " Alexandre Belloni
  2015-03-12 12:07 ` [PATCH v5 10/10] ARM: at91: remove useless include Alexandre Belloni
                   ` (2 subsequent siblings)
  11 siblings, 2 replies; 28+ messages in thread
From: Alexandre Belloni @ 2015-03-12 12:07 UTC (permalink / raw)
  To: Nicolas Ferre, Daniel Lezcano
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog, Alexandre Belloni

Remove the mach/hardware dependency to prepare the driver for multiplatform
support.
Also switch from setup_irq() to request_irq()

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/clocksource/timer-atmel-st.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/clocksource/timer-atmel-st.c b/drivers/clocksource/timer-atmel-st.c
index 674ef2519d6b..91d6cbb7a56b 100644
--- a/drivers/clocksource/timer-atmel-st.c
+++ b/drivers/clocksource/timer-atmel-st.c
@@ -31,13 +31,12 @@
 
 #include <asm/mach/time.h>
 
-#include <mach/hardware.h>
-
 static unsigned long last_crtr;
 static u32 irqmask;
 static struct clock_event_device clkevt;
 static struct regmap *regmap_st;
 
+#define AT91_SLOW_CLOCK		32768
 #define RM9200_TIMER_LATCH	((AT91_SLOW_CLOCK + HZ/2) / HZ)
 
 /*
@@ -96,13 +95,6 @@ static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id)
 	return IRQ_NONE;
 }
 
-static struct irqaction at91rm9200_timer_irq = {
-	.name		= "at91_tick",
-	.flags		= IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
-	.handler	= at91rm9200_timer_interrupt,
-	.irq		= NR_IRQS_LEGACY + AT91_ID_SYS,
-};
-
 static cycle_t read_clk32k(struct clocksource *cs)
 {
 	return read_CRTR();
@@ -193,6 +185,7 @@ static struct clock_event_device clkevt = {
 static void __init atmel_st_timer_init(struct device_node *node)
 {
 	unsigned int val;
+	int irq, ret;
 
 	regmap_st = syscon_node_to_regmap(node);
 	if (IS_ERR(regmap_st))
@@ -204,12 +197,16 @@ static void __init atmel_st_timer_init(struct device_node *node)
 	regmap_read(regmap_st, AT91_ST_SR, &val);
 
 	/* Get the interrupts property */
-	at91rm9200_timer_irq.irq  = irq_of_parse_and_map(node, 0);
-	if (!at91rm9200_timer_irq.irq)
+	irq  = irq_of_parse_and_map(node, 0);
+	if (!irq)
 		panic(pr_fmt("Unable to get IRQ from DT\n"));
 
 	/* Make IRQs happen for the system timer */
-	setup_irq(at91rm9200_timer_irq.irq, &at91rm9200_timer_irq);
+	ret = request_irq(irq, at91rm9200_timer_interrupt,
+			  IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
+			  "at91_tick", regmap_st);
+	if (ret)
+		panic(pr_fmt("Unable to setup IRQ\n"));
 
 	/* The 32KiHz "Slow Clock" (tick every 30517.58 nanoseconds) is used
 	 * directly for the clocksource and all clockevents, after adjusting
-- 
2.1.0


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

* [PATCH v5 10/10] ARM: at91: remove useless include
  2015-03-12 12:07 [PATCH v5 00/10] Atmel System Timer cleanups Alexandre Belloni
                   ` (8 preceding siblings ...)
  2015-03-12 12:07 ` [PATCH v5 09/10] clocksource: atmel-st: remove mach/hardware dependency Alexandre Belloni
@ 2015-03-12 12:07 ` Alexandre Belloni
  2015-03-13 10:22   ` Daniel Lezcano
  2015-03-12 14:04 ` [PATCH v5 00/10] Atmel System Timer cleanups Nicolas Ferre
  2015-03-13 10:23 ` Daniel Lezcano
  11 siblings, 1 reply; 28+ messages in thread
From: Alexandre Belloni @ 2015-03-12 12:07 UTC (permalink / raw)
  To: Nicolas Ferre, Daniel Lezcano
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog, Alexandre Belloni

Both drivers using the system timer are now converted to an MFD. mach/at91_st.h
is now useless.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 arch/arm/mach-at91/include/mach/at91_st.h | 61 -------------------------------
 1 file changed, 61 deletions(-)
 delete mode 100644 arch/arm/mach-at91/include/mach/at91_st.h

diff --git a/arch/arm/mach-at91/include/mach/at91_st.h b/arch/arm/mach-at91/include/mach/at91_st.h
deleted file mode 100644
index 67fdbd13c3ed..000000000000
--- a/arch/arm/mach-at91/include/mach/at91_st.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * arch/arm/mach-at91/include/mach/at91_st.h
- *
- * Copyright (C) 2005 Ivan Kokshaysky
- * Copyright (C) SAN People
- *
- * System Timer (ST) - System peripherals registers.
- * Based on AT91RM9200 datasheet revision E.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef AT91_ST_H
-#define AT91_ST_H
-
-#ifndef __ASSEMBLY__
-extern void __iomem *at91_st_base;
-
-#define at91_st_read(field) \
-	__raw_readl(at91_st_base + field)
-
-#define at91_st_write(field, value) \
-	__raw_writel(value, at91_st_base + field)
-#else
-.extern at91_st_base
-#endif
-
-#define	AT91_ST_CR		0x00			/* Control Register */
-#define 	AT91_ST_WDRST		(1 << 0)		/* Watchdog Timer Restart */
-
-#define	AT91_ST_PIMR		0x04			/* Period Interval Mode Register */
-#define		AT91_ST_PIV		(0xffff <<  0)		/* Period Interval Value */
-
-#define	AT91_ST_WDMR		0x08			/* Watchdog Mode Register */
-#define		AT91_ST_WDV		(0xffff <<  0)		/* Watchdog Counter Value */
-#define		AT91_ST_RSTEN		(1	<< 16)		/* Reset Enable */
-#define		AT91_ST_EXTEN		(1	<< 17)		/* External Signal Assertion Enable */
-
-#define	AT91_ST_RTMR		0x0c			/* Real-time Mode Register */
-#define		AT91_ST_RTPRES		(0xffff <<  0)		/* Real-time Prescalar Value */
-
-#define	AT91_ST_SR		0x10			/* Status Register */
-#define		AT91_ST_PITS		(1 << 0)		/* Period Interval Timer Status */
-#define		AT91_ST_WDOVF		(1 << 1) 		/* Watchdog Overflow */
-#define		AT91_ST_RTTINC		(1 << 2) 		/* Real-time Timer Increment */
-#define		AT91_ST_ALMS		(1 << 3) 		/* Alarm Status */
-
-#define	AT91_ST_IER		0x14			/* Interrupt Enable Register */
-#define	AT91_ST_IDR		0x18			/* Interrupt Disable Register */
-#define	AT91_ST_IMR		0x1c			/* Interrupt Mask Register */
-
-#define	AT91_ST_RTAR		0x20			/* Real-time Alarm Register */
-#define		AT91_ST_ALMV		(0xfffff << 0)		/* Alarm Value */
-
-#define	AT91_ST_CRTR		0x24			/* Current Real-time Register */
-#define		AT91_ST_CRTV		(0xfffff << 0)		/* Current Real-Time Value */
-
-#endif
-- 
2.1.0


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

* Re: [PATCH v5 00/10] Atmel System Timer cleanups
  2015-03-12 12:07 [PATCH v5 00/10] Atmel System Timer cleanups Alexandre Belloni
                   ` (9 preceding siblings ...)
  2015-03-12 12:07 ` [PATCH v5 10/10] ARM: at91: remove useless include Alexandre Belloni
@ 2015-03-12 14:04 ` Nicolas Ferre
  2015-03-13 10:23 ` Daniel Lezcano
  11 siblings, 0 replies; 28+ messages in thread
From: Nicolas Ferre @ 2015-03-12 14:04 UTC (permalink / raw)
  To: Alexandre Belloni, Daniel Lezcano
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog

Le 12/03/2015 13:07, Alexandre Belloni a écrit :
> This patch set cleans up the system timer driver.
> 
> The main goal is to get rid of the mach/ headers dependency. At the same time,
> it introduces proper probing and locking (using a regmap) for the watchdog
> driver.
> 
> This is based on 4.0-rc1 and will have two merge conflicts with my cleanup #1 in
> mach-at91/at91rm9200.c
> 
> It also needs this patch to probe the watchdog properly:
> http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/327274.html
> 
> Changes in v5:
>  - Documented the watchdog compatible
>  - Switched to simple-mfd to probe the system timer subnodes
>  - Selected ATMEL_ST from mach-at91/Kconfig instead of using def_bool SOC_AT91RM9200
>  - Reordered the atmel-st probe cleanup and its move to driver/clocksource
>  - Added a patch to replace setup_irq by request_irq
>  - Merged the reset handling in the watchdog timer as we are using the watchdog
>    anyway to reset the board.
>  - Used a simple space after a #define for registers
> 
> Changes in v4:
>  - Added MODULE_* metadata in at91rm9200-reset
>  - Proper copyright in at91rm9200-reset
>  - Use BIT() in atmel-st.h
>  - changed MODULE_ALIAS in at91rm9200_wdt.c
> 
> Changes in v3:
>  - stop using an mfd and get the syscon directly from the watchdog driver
>  - introduce a proper reset driver to handle reset
> 
> Changes in v2:
>  - cleaned up more includes in the watchdog driver
>  - stop using if OF when selecting CLKSRC_OF
>  - stop initializing .owner
> 
> 
> Alexandre Belloni (10):
>   ARM: at91/dt: declare atmel,at91rm9200-st as a syscon
>   mfd: syscon: Add atmel system timer registers definition
>   watchdog: at91rm9200: use the system timer syscon
>   watchdog: at91rm9200: implement restart handler
>   ARM: at91: at91rm9200: remove deprecated arm_pm_restart
>   ARM: at91: properly initialize timer
>   ARM: at91: time: move the system timer driver to drivers/clocksource
>   clocksource: atmel-st: use syscon/regmap
>   clocksource: atmel-st: remove mach/hardware dependency
>   ARM: at91: remove useless include

I'm okay with the whole series:
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

But anyway, I'm waiting for a couple of more Ack.

Thanks, bye.

>  .../devicetree/bindings/arm/atmel-at91.txt         |   4 +-
>  arch/arm/boot/dts/at91rm9200.dtsi                  |   6 +-
>  arch/arm/mach-at91/Kconfig                         |   1 +
>  arch/arm/mach-at91/Makefile                        |   2 +-
>  arch/arm/mach-at91/at91rm9200.c                    |  19 ----
>  arch/arm/mach-at91/generic.h                       |   3 -
>  arch/arm/mach-at91/include/mach/at91_st.h          |  61 -----------
>  drivers/clocksource/Kconfig                        |   4 +
>  drivers/clocksource/Makefile                       |   1 +
>  .../clocksource/timer-atmel-st.c                   | 115 ++++++++-------------
>  drivers/watchdog/Kconfig                           |   2 +-
>  drivers/watchdog/at91rm9200_wdt.c                  |  61 +++++++++--
>  include/linux/mfd/syscon/atmel-st.h                |  49 +++++++++
>  13 files changed, 164 insertions(+), 164 deletions(-)
>  delete mode 100644 arch/arm/mach-at91/include/mach/at91_st.h
>  rename arch/arm/mach-at91/at91rm9200_time.c => drivers/clocksource/timer-atmel-st.c (74%)
>  create mode 100644 include/linux/mfd/syscon/atmel-st.h
> 


-- 
Nicolas Ferre

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

* Re: [PATCH v5 03/10] watchdog: at91rm9200: use the system timer syscon
  2015-03-12 12:07 ` [PATCH v5 03/10] watchdog: at91rm9200: use the system timer syscon Alexandre Belloni
@ 2015-03-12 16:19   ` Guenter Roeck
  0 siblings, 0 replies; 28+ messages in thread
From: Guenter Roeck @ 2015-03-12 16:19 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Nicolas Ferre, Daniel Lezcano, Boris Brezillon,
	Jean-Christophe Plagniol-Villard, Wim Van Sebroeck, linux-kernel,
	linux-arm-kernel, linux-watchdog

On Thu, Mar 12, 2015 at 01:07:27PM +0100, Alexandre Belloni wrote:
> Use a syscon regmap to access the system timer registers.
> 
> Also, rename the driver atmel_st_watchdog to stop conflicting with
> at91sam9_wdt.c
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/watchdog/Kconfig          |  2 +-
>  drivers/watchdog/at91rm9200_wdt.c | 29 ++++++++++++++++++++++-------
>  2 files changed, 23 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> index 16f202350997..ce4f3a7f95fd 100644
> --- a/drivers/watchdog/Kconfig
> +++ b/drivers/watchdog/Kconfig
> @@ -154,7 +154,7 @@ config ARM_SP805_WATCHDOG
>  
>  config AT91RM9200_WATCHDOG
>  	tristate "AT91RM9200 watchdog"
> -	depends on SOC_AT91RM9200
> +	depends on SOC_AT91RM9200 && MFD_SYSCON
>  	help
>  	  Watchdog timer embedded into AT91RM9200 chips. This will reboot your
>  	  system when the timeout is reached.
> diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c
> index d244112d5b6f..e6fa87d85de3 100644
> --- a/drivers/watchdog/at91rm9200_wdt.c
> +++ b/drivers/watchdog/at91rm9200_wdt.c
> @@ -17,22 +17,25 @@
>  #include <linux/init.h>
>  #include <linux/io.h>
>  #include <linux/kernel.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/mfd/syscon/atmel-st.h>
>  #include <linux/miscdevice.h>
>  #include <linux/module.h>
>  #include <linux/moduleparam.h>
>  #include <linux/platform_device.h>
> +#include <linux/regmap.h>
>  #include <linux/types.h>
>  #include <linux/watchdog.h>
>  #include <linux/uaccess.h>
>  #include <linux/of.h>
>  #include <linux/of_device.h>
> -#include <mach/at91_st.h>
>  
>  #define WDT_DEFAULT_TIME	5	/* seconds */
>  #define WDT_MAX_TIME		256	/* seconds */
>  
>  static int wdt_time = WDT_DEFAULT_TIME;
>  static bool nowayout = WATCHDOG_NOWAYOUT;
> +static struct regmap *regmap_st;
>  
>  module_param(wdt_time, int, 0);
>  MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="
> @@ -55,7 +58,7 @@ static unsigned long at91wdt_busy;
>   */
>  static inline void at91_wdt_stop(void)
>  {
> -	at91_st_write(AT91_ST_WDMR, AT91_ST_EXTEN);
> +	regmap_write(regmap_st, AT91_ST_WDMR, AT91_ST_EXTEN);
>  }
>  
>  /*
> @@ -63,9 +66,9 @@ static inline void at91_wdt_stop(void)
>   */
>  static inline void at91_wdt_start(void)
>  {
> -	at91_st_write(AT91_ST_WDMR, AT91_ST_EXTEN | AT91_ST_RSTEN |
> +	regmap_write(regmap_st, AT91_ST_WDMR, AT91_ST_EXTEN | AT91_ST_RSTEN |
>  				(((65536 * wdt_time) >> 8) & AT91_ST_WDV));
> -	at91_st_write(AT91_ST_CR, AT91_ST_WDRST);
> +	regmap_write(regmap_st, AT91_ST_CR, AT91_ST_WDRST);
>  }
>  
>  /*
> @@ -73,7 +76,7 @@ static inline void at91_wdt_start(void)
>   */
>  static inline void at91_wdt_reload(void)
>  {
> -	at91_st_write(AT91_ST_CR, AT91_ST_WDRST);
> +	regmap_write(regmap_st, AT91_ST_CR, AT91_ST_WDRST);
>  }
>  
>  /* ......................................................................... */
> @@ -203,12 +206,24 @@ static struct miscdevice at91wdt_miscdev = {
>  
>  static int at91wdt_probe(struct platform_device *pdev)
>  {
> +	struct device *dev = &pdev->dev;
> +	struct device *parent;
>  	int res;
>  
>  	if (at91wdt_miscdev.parent)
>  		return -EBUSY;
>  	at91wdt_miscdev.parent = &pdev->dev;
>  
> +	parent = dev->parent;
> +	if (!parent) {
> +		dev_err(dev, "no parent\n");
> +		return -ENODEV;
> +	}
> +
> +	regmap_st = syscon_node_to_regmap(parent->of_node);
> +	if (!regmap_st)
> +		return -ENODEV;
> +
>  	res = misc_register(&at91wdt_miscdev);
>  	if (res)
>  		return res;
> @@ -267,7 +282,7 @@ static struct platform_driver at91wdt_driver = {
>  	.suspend	= at91wdt_suspend,
>  	.resume		= at91wdt_resume,
>  	.driver		= {
> -		.name	= "at91_wdt",
> +		.name	= "atmel_st_watchdog",
>  		.of_match_table = at91_wdt_dt_ids,
>  	},
>  };
> @@ -296,4 +311,4 @@ module_exit(at91_wdt_exit);
>  MODULE_AUTHOR("Andrew Victor");
>  MODULE_DESCRIPTION("Watchdog driver for Atmel AT91RM9200");
>  MODULE_LICENSE("GPL");
> -MODULE_ALIAS("platform:at91_wdt");
> +MODULE_ALIAS("platform:atmel_st_watchdog");
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v5 04/10] watchdog: at91rm9200: implement restart handler
  2015-03-12 12:07 ` [PATCH v5 04/10] watchdog: at91rm9200: implement restart handler Alexandre Belloni
@ 2015-03-12 16:22   ` Guenter Roeck
  0 siblings, 0 replies; 28+ messages in thread
From: Guenter Roeck @ 2015-03-12 16:22 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Nicolas Ferre, Daniel Lezcano, Boris Brezillon,
	Jean-Christophe Plagniol-Villard, Wim Van Sebroeck, linux-kernel,
	linux-arm-kernel, linux-watchdog

On Thu, Mar 12, 2015 at 01:07:28PM +0100, Alexandre Belloni wrote:
> Restarting the at91rm9200 is done through programming the watchdog and waiting
> for it to reset.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

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

* Re: [PATCH v5 02/10] mfd: syscon: Add atmel system timer registers definition
  2015-03-12 12:07 ` [PATCH v5 02/10] mfd: syscon: Add atmel system timer registers definition Alexandre Belloni
@ 2015-03-13  8:03   ` Lee Jones
  2015-03-13 10:40     ` Alexandre Belloni
  0 siblings, 1 reply; 28+ messages in thread
From: Lee Jones @ 2015-03-13  8:03 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Nicolas Ferre, Daniel Lezcano, Boris Brezillon, linux-watchdog,
	linux-kernel, Wim Van Sebroeck, Guenter Roeck,
	Jean-Christophe Plagniol-Villard, linux-arm-kernel

On Thu, 12 Mar 2015, Alexandre Belloni wrote:

> AT91RM920 has a memory range reserved for timer and watchdog configuration.
> Expose those registers so that drivers can make use of the system timer syscon
> declared in at91 DTs.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> ---
>  include/linux/mfd/syscon/atmel-st.h | 49 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 49 insertions(+)
>  create mode 100644 include/linux/mfd/syscon/atmel-st.h

Applied, thanks.

> diff --git a/include/linux/mfd/syscon/atmel-st.h b/include/linux/mfd/syscon/atmel-st.h
> new file mode 100644
> index 000000000000..8acf1ec1fa32
> --- /dev/null
> +++ b/include/linux/mfd/syscon/atmel-st.h
> @@ -0,0 +1,49 @@
> +/*
> + * Copyright (C) 2005 Ivan Kokshaysky
> + * Copyright (C) SAN People
> + *
> + * System Timer (ST) - System peripherals registers.
> + * Based on AT91RM9200 datasheet revision E.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#ifndef _LINUX_MFD_SYSCON_ATMEL_ST_H
> +#define _LINUX_MFD_SYSCON_ATMEL_ST_H
> +
> +#include <linux/bitops.h>
> +
> +#define AT91_ST_CR	0x00	/* Control Register */
> +#define		AT91_ST_WDRST	BIT(0)	/* Watchdog Timer Restart */
> +
> +#define AT91_ST_PIMR	0x04	/* Period Interval Mode Register */
> +#define		AT91_ST_PIV	0xffff	/* Period Interval Value */
> +
> +#define AT91_ST_WDMR	0x08	/* Watchdog Mode Register */
> +#define		AT91_ST_WDV	0xffff	/* Watchdog Counter Value */
> +#define		AT91_ST_RSTEN	BIT(16)	/* Reset Enable */
> +#define		AT91_ST_EXTEN	BIT(17)	/* External Signal Assertion Enable */
> +
> +#define AT91_ST_RTMR	0x0c	/* Real-time Mode Register */
> +#define		AT91_ST_RTPRES	0xffff	/* Real-time Prescalar Value */
> +
> +#define AT91_ST_SR	0x10	/* Status Register */
> +#define		AT91_ST_PITS	BIT(0)	/* Period Interval Timer Status */
> +#define		AT91_ST_WDOVF	BIT(1)	/* Watchdog Overflow */
> +#define		AT91_ST_RTTINC	BIT(2)	/* Real-time Timer Increment */
> +#define		AT91_ST_ALMS	BIT(3)	/* Alarm Status */
> +
> +#define AT91_ST_IER	0x14	/* Interrupt Enable Register */
> +#define AT91_ST_IDR	0x18	/* Interrupt Disable Register */
> +#define AT91_ST_IMR	0x1c	/* Interrupt Mask Register */
> +
> +#define AT91_ST_RTAR	0x20	/* Real-time Alarm Register */
> +#define		AT91_ST_ALMV	0xfffff	/* Alarm Value */
> +
> +#define AT91_ST_CRTR	0x24	/* Current Real-time Register */
> +#define		AT91_ST_CRTV	0xfffff	/* Current Real-Time Value */
> +
> +#endif /* _LINUX_MFD_SYSCON_ATMEL_ST_H */

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v5 07/10] ARM: at91: time: move the system timer driver to drivers/clocksource
  2015-03-12 12:07 ` [PATCH v5 07/10] ARM: at91: time: move the system timer driver to drivers/clocksource Alexandre Belloni
@ 2015-03-13 10:14   ` Daniel Lezcano
  0 siblings, 0 replies; 28+ messages in thread
From: Daniel Lezcano @ 2015-03-13 10:14 UTC (permalink / raw)
  To: Alexandre Belloni, Nicolas Ferre
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog

On 03/12/2015 01:07 PM, Alexandre Belloni wrote:
> Import at91rm9200_time.c from mach-at91 as timer-atmel-st.c. Further cleanup is
> required to get rid of the mach-at91 headers.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>

It would have make more sense to remove the mach headers first and then 
move the code in the clocksource directory, but anyway ... :)

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>

> ---
>   arch/arm/mach-at91/Kconfig                                            | 1 +
>   arch/arm/mach-at91/Makefile                                           | 2 +-
>   drivers/clocksource/Kconfig                                           | 4 ++++
>   drivers/clocksource/Makefile                                          | 1 +
>   .../at91rm9200_time.c => drivers/clocksource/timer-atmel-st.c         | 0
>   5 files changed, 7 insertions(+), 1 deletion(-)
>   rename arch/arm/mach-at91/at91rm9200_time.c => drivers/clocksource/timer-atmel-st.c (100%)
>
> diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
> index c74a44324e5b..dabce086fa47 100644
> --- a/arch/arm/mach-at91/Kconfig
> +++ b/arch/arm/mach-at91/Kconfig
> @@ -77,6 +77,7 @@ if SOC_SAM_V4_V5
>   config SOC_AT91RM9200
>   	bool "AT91RM9200"
>   	select ATMEL_AIC_IRQ
> +	select ATMEL_ST
>   	select COMMON_CLK_AT91
>   	select CPU_ARM920T
>   	select GENERIC_CLOCKEVENTS
> diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
> index 827fdbcce1c7..963c29169242 100644
> --- a/arch/arm/mach-at91/Makefile
> +++ b/arch/arm/mach-at91/Makefile
> @@ -7,7 +7,7 @@ obj-y		:= setup.o
>   obj-$(CONFIG_SOC_AT91SAM9)	+= sam9_smc.o
>
>   # CPU-specific support
> -obj-$(CONFIG_SOC_AT91RM9200)	+= at91rm9200.o at91rm9200_time.o
> +obj-$(CONFIG_SOC_AT91RM9200)	+= at91rm9200.o
>   obj-$(CONFIG_SOC_AT91SAM9)	+= at91sam9.o
>   obj-$(CONFIG_SOC_SAMA5)		+= sama5.o
>
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index 1c2506f68122..6c45f504baff 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -138,6 +138,10 @@ config ATMEL_PIT
>   	select CLKSRC_OF if OF
>   	def_bool SOC_AT91SAM9 || SOC_SAMA5
>
> +config ATMEL_ST
> +	bool
> +	select CLKSRC_OF
> +
>   config CLKSRC_METAG_GENERIC
>   	def_bool y if METAG
>   	help
> diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> index 752d5c70b0ef..5b85f6adb258 100644
> --- a/drivers/clocksource/Makefile
> +++ b/drivers/clocksource/Makefile
> @@ -1,5 +1,6 @@
>   obj-$(CONFIG_CLKSRC_OF)	+= clksrc-of.o
>   obj-$(CONFIG_ATMEL_PIT)		+= timer-atmel-pit.o
> +obj-$(CONFIG_ATMEL_ST)		+= timer-atmel-st.o
>   obj-$(CONFIG_ATMEL_TCB_CLKSRC)	+= tcb_clksrc.o
>   obj-$(CONFIG_X86_PM_TIMER)	+= acpi_pm.o
>   obj-$(CONFIG_SCx200HR_TIMER)	+= scx200_hrt.o
> diff --git a/arch/arm/mach-at91/at91rm9200_time.c b/drivers/clocksource/timer-atmel-st.c
> similarity index 100%
> rename from arch/arm/mach-at91/at91rm9200_time.c
> rename to drivers/clocksource/timer-atmel-st.c
>


-- 
  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

* Re: [PATCH v5 08/10] clocksource: atmel-st: use syscon/regmap
  2015-03-12 12:07 ` [PATCH v5 08/10] clocksource: atmel-st: use syscon/regmap Alexandre Belloni
@ 2015-03-13 10:17   ` Daniel Lezcano
  0 siblings, 0 replies; 28+ messages in thread
From: Daniel Lezcano @ 2015-03-13 10:17 UTC (permalink / raw)
  To: Alexandre Belloni, Nicolas Ferre
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog

On 03/12/2015 01:07 PM, Alexandre Belloni wrote:
> The register range from the system timer is also used by the watchdog driver.
> Use a regmap to handle concurrent accesses.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>

> ---
>   drivers/clocksource/timer-atmel-st.c | 94 ++++++++++++++----------------------
>   1 file changed, 35 insertions(+), 59 deletions(-)
>
> diff --git a/drivers/clocksource/timer-atmel-st.c b/drivers/clocksource/timer-atmel-st.c
> index 7d062ab32674..674ef2519d6b 100644
> --- a/drivers/clocksource/timer-atmel-st.c
> +++ b/drivers/clocksource/timer-atmel-st.c
> @@ -24,18 +24,19 @@
>   #include <linux/irq.h>
>   #include <linux/clockchips.h>
>   #include <linux/export.h>
> -#include <linux/of.h>
> -#include <linux/of_address.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/mfd/syscon/atmel-st.h>
>   #include <linux/of_irq.h>
> +#include <linux/regmap.h>
>
>   #include <asm/mach/time.h>
>
> -#include <mach/at91_st.h>
>   #include <mach/hardware.h>
>
>   static unsigned long last_crtr;
>   static u32 irqmask;
>   static struct clock_event_device clkevt;
> +static struct regmap *regmap_st;
>
>   #define RM9200_TIMER_LATCH	((AT91_SLOW_CLOCK + HZ/2) / HZ)
>
> @@ -46,11 +47,11 @@ static struct clock_event_device clkevt;
>    */
>   static inline unsigned long read_CRTR(void)
>   {
> -	unsigned long x1, x2;
> +	unsigned int x1, x2;
>
> -	x1 = at91_st_read(AT91_ST_CRTR);
> +	regmap_read(regmap_st, AT91_ST_CRTR, &x1);
>   	do {
> -		x2 = at91_st_read(AT91_ST_CRTR);
> +		regmap_read(regmap_st, AT91_ST_CRTR, &x2);
>   		if (x1 == x2)
>   			break;
>   		x1 = x2;
> @@ -63,7 +64,10 @@ static inline unsigned long read_CRTR(void)
>    */
>   static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id)
>   {
> -	u32	sr = at91_st_read(AT91_ST_SR) & irqmask;
> +	u32 sr;
> +
> +	regmap_read(regmap_st, AT91_ST_SR, &sr);
> +	sr &= irqmask;
>
>   	/*
>   	 * irqs should be disabled here, but as the irq is shared they are only
> @@ -115,23 +119,25 @@ static struct clocksource clk32k = {
>   static void
>   clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev)
>   {
> +	unsigned int val;
> +
>   	/* Disable and flush pending timer interrupts */
> -	at91_st_write(AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS);
> -	at91_st_read(AT91_ST_SR);
> +	regmap_write(regmap_st, AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS);
> +	regmap_read(regmap_st, AT91_ST_SR, &val);
>
>   	last_crtr = read_CRTR();
>   	switch (mode) {
>   	case CLOCK_EVT_MODE_PERIODIC:
>   		/* PIT for periodic irqs; fixed rate of 1/HZ */
>   		irqmask = AT91_ST_PITS;
> -		at91_st_write(AT91_ST_PIMR, RM9200_TIMER_LATCH);
> +		regmap_write(regmap_st, AT91_ST_PIMR, RM9200_TIMER_LATCH);
>   		break;
>   	case CLOCK_EVT_MODE_ONESHOT:
>   		/* ALM for oneshot irqs, set by next_event()
>   		 * before 32 seconds have passed
>   		 */
>   		irqmask = AT91_ST_ALMS;
> -		at91_st_write(AT91_ST_RTAR, last_crtr);
> +		regmap_write(regmap_st, AT91_ST_RTAR, last_crtr);
>   		break;
>   	case CLOCK_EVT_MODE_SHUTDOWN:
>   	case CLOCK_EVT_MODE_UNUSED:
> @@ -139,7 +145,7 @@ clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev)
>   		irqmask = 0;
>   		break;
>   	}
> -	at91_st_write(AT91_ST_IER, irqmask);
> +	regmap_write(regmap_st, AT91_ST_IER, irqmask);
>   }
>
>   static int
> @@ -147,6 +153,7 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev)
>   {
>   	u32		alm;
>   	int		status = 0;
> +	unsigned int	val;
>
>   	BUG_ON(delta < 2);
>
> @@ -162,12 +169,12 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev)
>   	alm = read_CRTR();
>
>   	/* Cancel any pending alarm; flush any pending IRQ */
> -	at91_st_write(AT91_ST_RTAR, alm);
> -	at91_st_read(AT91_ST_SR);
> +	regmap_write(regmap_st, AT91_ST_RTAR, alm);
> +	regmap_read(regmap_st, AT91_ST_SR, &val);
>
>   	/* Schedule alarm by writing RTAR. */
>   	alm += delta;
> -	at91_st_write(AT91_ST_RTAR, alm);
> +	regmap_write(regmap_st, AT91_ST_RTAR, alm);
>
>   	return status;
>   }
> @@ -180,57 +187,26 @@ static struct clock_event_device clkevt = {
>   	.set_mode	= clkevt32k_mode,
>   };
>
> -void __iomem *at91_st_base;
> -EXPORT_SYMBOL_GPL(at91_st_base);
> -
> -static const struct of_device_id at91rm9200_st_timer_ids[] = {
> -	{ .compatible = "atmel,at91rm9200-st" },
> -	{ /* sentinel */ }
> -};
> -
> -static int __init of_at91rm9200_st_init(void)
> -{
> -	struct device_node *np;
> -	int ret;
> -
> -	np = of_find_matching_node(NULL, at91rm9200_st_timer_ids);
> -	if (!np)
> -		goto err;
> -
> -	at91_st_base = of_iomap(np, 0);
> -	if (!at91_st_base)
> -		goto node_err;
> -
> -	/* Get the interrupts property */
> -	ret = irq_of_parse_and_map(np, 0);
> -	if (!ret)
> -		goto ioremap_err;
> -	at91rm9200_timer_irq.irq = ret;
> -
> -	of_node_put(np);
> -
> -	return 0;
> -
> -ioremap_err:
> -	iounmap(at91_st_base);
> -node_err:
> -	of_node_put(np);
> -err:
> -	return -EINVAL;
> -}
> -
>   /*
>    * ST (system timer) module supports both clockevents and clocksource.
>    */
>   static void __init atmel_st_timer_init(struct device_node *node)
>   {
> -	/* For device tree enabled device: initialize here */
> -	of_at91rm9200_st_init();
> +	unsigned int val;
> +
> +	regmap_st = syscon_node_to_regmap(node);
> +	if (IS_ERR(regmap_st))
> +		panic(pr_fmt("Unable to get regmap\n"));
>
>   	/* Disable all timer interrupts, and clear any pending ones */
> -	at91_st_write(AT91_ST_IDR,
> +	regmap_write(regmap_st, AT91_ST_IDR,
>   		AT91_ST_PITS | AT91_ST_WDOVF | AT91_ST_RTTINC | AT91_ST_ALMS);
> -	at91_st_read(AT91_ST_SR);
> +	regmap_read(regmap_st, AT91_ST_SR, &val);
> +
> +	/* Get the interrupts property */
> +	at91rm9200_timer_irq.irq  = irq_of_parse_and_map(node, 0);
> +	if (!at91rm9200_timer_irq.irq)
> +		panic(pr_fmt("Unable to get IRQ from DT\n"));
>
>   	/* Make IRQs happen for the system timer */
>   	setup_irq(at91rm9200_timer_irq.irq, &at91rm9200_timer_irq);
> @@ -239,7 +215,7 @@ static void __init atmel_st_timer_init(struct device_node *node)
>   	 * directly for the clocksource and all clockevents, after adjusting
>   	 * its prescaler from the 1 Hz default.
>   	 */
> -	at91_st_write(AT91_ST_RTMR, 1);
> +	regmap_write(regmap_st, AT91_ST_RTMR, 1);
>
>   	/* Setup timer clockevent, with minimum of two ticks (important!!) */
>   	clkevt.cpumask = cpumask_of(0);
>


-- 
  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

* Re: [PATCH v5 09/10] clocksource: atmel-st: remove mach/hardware dependency
  2015-03-12 12:07 ` [PATCH v5 09/10] clocksource: atmel-st: remove mach/hardware dependency Alexandre Belloni
@ 2015-03-13 10:21   ` Daniel Lezcano
  2015-03-13 10:44     ` Alexandre Belloni
  2015-03-13 10:54   ` [PATCH v6 " Alexandre Belloni
  1 sibling, 1 reply; 28+ messages in thread
From: Daniel Lezcano @ 2015-03-13 10:21 UTC (permalink / raw)
  To: Alexandre Belloni, Nicolas Ferre
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog

On 03/12/2015 01:07 PM, Alexandre Belloni wrote:
> Remove the mach/hardware dependency to prepare the driver for multiplatform
> support.
> Also switch from setup_irq() to request_irq()
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
>   drivers/clocksource/timer-atmel-st.c | 21 +++++++++------------
>   1 file changed, 9 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/clocksource/timer-atmel-st.c b/drivers/clocksource/timer-atmel-st.c
> index 674ef2519d6b..91d6cbb7a56b 100644
> --- a/drivers/clocksource/timer-atmel-st.c
> +++ b/drivers/clocksource/timer-atmel-st.c
> @@ -31,13 +31,12 @@
>
>   #include <asm/mach/time.h>

Couldn't the header above be removed ?

Other than that:

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>

> -#include <mach/hardware.h>
> -
>   static unsigned long last_crtr;
>   static u32 irqmask;
>   static struct clock_event_device clkevt;
>   static struct regmap *regmap_st;
>
> +#define AT91_SLOW_CLOCK		32768
>   #define RM9200_TIMER_LATCH	((AT91_SLOW_CLOCK + HZ/2) / HZ)
>
>   /*
> @@ -96,13 +95,6 @@ static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id)
>   	return IRQ_NONE;
>   }
>
> -static struct irqaction at91rm9200_timer_irq = {
> -	.name		= "at91_tick",
> -	.flags		= IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
> -	.handler	= at91rm9200_timer_interrupt,
> -	.irq		= NR_IRQS_LEGACY + AT91_ID_SYS,
> -};
> -
>   static cycle_t read_clk32k(struct clocksource *cs)
>   {
>   	return read_CRTR();
> @@ -193,6 +185,7 @@ static struct clock_event_device clkevt = {
>   static void __init atmel_st_timer_init(struct device_node *node)
>   {
>   	unsigned int val;
> +	int irq, ret;
>
>   	regmap_st = syscon_node_to_regmap(node);
>   	if (IS_ERR(regmap_st))
> @@ -204,12 +197,16 @@ static void __init atmel_st_timer_init(struct device_node *node)
>   	regmap_read(regmap_st, AT91_ST_SR, &val);
>
>   	/* Get the interrupts property */
> -	at91rm9200_timer_irq.irq  = irq_of_parse_and_map(node, 0);
> -	if (!at91rm9200_timer_irq.irq)
> +	irq  = irq_of_parse_and_map(node, 0);
> +	if (!irq)
>   		panic(pr_fmt("Unable to get IRQ from DT\n"));
>
>   	/* Make IRQs happen for the system timer */
> -	setup_irq(at91rm9200_timer_irq.irq, &at91rm9200_timer_irq);
> +	ret = request_irq(irq, at91rm9200_timer_interrupt,
> +			  IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
> +			  "at91_tick", regmap_st);
> +	if (ret)
> +		panic(pr_fmt("Unable to setup IRQ\n"));
>
>   	/* The 32KiHz "Slow Clock" (tick every 30517.58 nanoseconds) is used
>   	 * directly for the clocksource and all clockevents, after adjusting
>


-- 
  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

* Re: [PATCH v5 10/10] ARM: at91: remove useless include
  2015-03-12 12:07 ` [PATCH v5 10/10] ARM: at91: remove useless include Alexandre Belloni
@ 2015-03-13 10:22   ` Daniel Lezcano
  0 siblings, 0 replies; 28+ messages in thread
From: Daniel Lezcano @ 2015-03-13 10:22 UTC (permalink / raw)
  To: Alexandre Belloni, Nicolas Ferre
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog

On 03/12/2015 01:07 PM, Alexandre Belloni wrote:
> Both drivers using the system timer are now converted to an MFD. mach/at91_st.h
> is now useless.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>

> ---
>   arch/arm/mach-at91/include/mach/at91_st.h | 61 -------------------------------
>   1 file changed, 61 deletions(-)
>   delete mode 100644 arch/arm/mach-at91/include/mach/at91_st.h
>
> diff --git a/arch/arm/mach-at91/include/mach/at91_st.h b/arch/arm/mach-at91/include/mach/at91_st.h
> deleted file mode 100644
> index 67fdbd13c3ed..000000000000
> --- a/arch/arm/mach-at91/include/mach/at91_st.h
> +++ /dev/null
> @@ -1,61 +0,0 @@
> -/*
> - * arch/arm/mach-at91/include/mach/at91_st.h
> - *
> - * Copyright (C) 2005 Ivan Kokshaysky
> - * Copyright (C) SAN People
> - *
> - * System Timer (ST) - System peripherals registers.
> - * Based on AT91RM9200 datasheet revision E.
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - */
> -
> -#ifndef AT91_ST_H
> -#define AT91_ST_H
> -
> -#ifndef __ASSEMBLY__
> -extern void __iomem *at91_st_base;
> -
> -#define at91_st_read(field) \
> -	__raw_readl(at91_st_base + field)
> -
> -#define at91_st_write(field, value) \
> -	__raw_writel(value, at91_st_base + field)
> -#else
> -.extern at91_st_base
> -#endif
> -
> -#define	AT91_ST_CR		0x00			/* Control Register */
> -#define 	AT91_ST_WDRST		(1 << 0)		/* Watchdog Timer Restart */
> -
> -#define	AT91_ST_PIMR		0x04			/* Period Interval Mode Register */
> -#define		AT91_ST_PIV		(0xffff <<  0)		/* Period Interval Value */
> -
> -#define	AT91_ST_WDMR		0x08			/* Watchdog Mode Register */
> -#define		AT91_ST_WDV		(0xffff <<  0)		/* Watchdog Counter Value */
> -#define		AT91_ST_RSTEN		(1	<< 16)		/* Reset Enable */
> -#define		AT91_ST_EXTEN		(1	<< 17)		/* External Signal Assertion Enable */
> -
> -#define	AT91_ST_RTMR		0x0c			/* Real-time Mode Register */
> -#define		AT91_ST_RTPRES		(0xffff <<  0)		/* Real-time Prescalar Value */
> -
> -#define	AT91_ST_SR		0x10			/* Status Register */
> -#define		AT91_ST_PITS		(1 << 0)		/* Period Interval Timer Status */
> -#define		AT91_ST_WDOVF		(1 << 1) 		/* Watchdog Overflow */
> -#define		AT91_ST_RTTINC		(1 << 2) 		/* Real-time Timer Increment */
> -#define		AT91_ST_ALMS		(1 << 3) 		/* Alarm Status */
> -
> -#define	AT91_ST_IER		0x14			/* Interrupt Enable Register */
> -#define	AT91_ST_IDR		0x18			/* Interrupt Disable Register */
> -#define	AT91_ST_IMR		0x1c			/* Interrupt Mask Register */
> -
> -#define	AT91_ST_RTAR		0x20			/* Real-time Alarm Register */
> -#define		AT91_ST_ALMV		(0xfffff << 0)		/* Alarm Value */
> -
> -#define	AT91_ST_CRTR		0x24			/* Current Real-time Register */
> -#define		AT91_ST_CRTV		(0xfffff << 0)		/* Current Real-Time Value */
> -
> -#endif
>


-- 
  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

* Re: [PATCH v5 00/10] Atmel System Timer cleanups
  2015-03-12 12:07 [PATCH v5 00/10] Atmel System Timer cleanups Alexandre Belloni
                   ` (10 preceding siblings ...)
  2015-03-12 14:04 ` [PATCH v5 00/10] Atmel System Timer cleanups Nicolas Ferre
@ 2015-03-13 10:23 ` Daniel Lezcano
  2015-03-13 10:33   ` Alexandre Belloni
  11 siblings, 1 reply; 28+ messages in thread
From: Daniel Lezcano @ 2015-03-13 10:23 UTC (permalink / raw)
  To: Alexandre Belloni, Nicolas Ferre
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog

On 03/12/2015 01:07 PM, Alexandre Belloni wrote:
> This patch set cleans up the system timer driver.
>
> The main goal is to get rid of the mach/ headers dependency. At the same time,
> it introduces proper probing and locking (using a regmap) for the watchdog
> driver.
>
> This is based on 4.0-rc1 and will have two merge conflicts with my cleanup #1 in
> mach-at91/at91rm9200.c
>
> It also needs this patch to probe the watchdog properly:
> http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/327274.html


Hi Alexandre,

through which tree do you want this patchset to be merged ?

Thanks
   -- Daniel

> Changes in v5:
>   - Documented the watchdog compatible
>   - Switched to simple-mfd to probe the system timer subnodes
>   - Selected ATMEL_ST from mach-at91/Kconfig instead of using def_bool SOC_AT91RM9200
>   - Reordered the atmel-st probe cleanup and its move to driver/clocksource
>   - Added a patch to replace setup_irq by request_irq
>   - Merged the reset handling in the watchdog timer as we are using the watchdog
>     anyway to reset the board.
>   - Used a simple space after a #define for registers
>
> Changes in v4:
>   - Added MODULE_* metadata in at91rm9200-reset
>   - Proper copyright in at91rm9200-reset
>   - Use BIT() in atmel-st.h
>   - changed MODULE_ALIAS in at91rm9200_wdt.c
>
> Changes in v3:
>   - stop using an mfd and get the syscon directly from the watchdog driver
>   - introduce a proper reset driver to handle reset
>
> Changes in v2:
>   - cleaned up more includes in the watchdog driver
>   - stop using if OF when selecting CLKSRC_OF
>   - stop initializing .owner
>
>
> Alexandre Belloni (10):
>    ARM: at91/dt: declare atmel,at91rm9200-st as a syscon
>    mfd: syscon: Add atmel system timer registers definition
>    watchdog: at91rm9200: use the system timer syscon
>    watchdog: at91rm9200: implement restart handler
>    ARM: at91: at91rm9200: remove deprecated arm_pm_restart
>    ARM: at91: properly initialize timer
>    ARM: at91: time: move the system timer driver to drivers/clocksource
>    clocksource: atmel-st: use syscon/regmap
>    clocksource: atmel-st: remove mach/hardware dependency
>    ARM: at91: remove useless include
>
>   .../devicetree/bindings/arm/atmel-at91.txt         |   4 +-
>   arch/arm/boot/dts/at91rm9200.dtsi                  |   6 +-
>   arch/arm/mach-at91/Kconfig                         |   1 +
>   arch/arm/mach-at91/Makefile                        |   2 +-
>   arch/arm/mach-at91/at91rm9200.c                    |  19 ----
>   arch/arm/mach-at91/generic.h                       |   3 -
>   arch/arm/mach-at91/include/mach/at91_st.h          |  61 -----------
>   drivers/clocksource/Kconfig                        |   4 +
>   drivers/clocksource/Makefile                       |   1 +
>   .../clocksource/timer-atmel-st.c                   | 115 ++++++++-------------
>   drivers/watchdog/Kconfig                           |   2 +-
>   drivers/watchdog/at91rm9200_wdt.c                  |  61 +++++++++--
>   include/linux/mfd/syscon/atmel-st.h                |  49 +++++++++
>   13 files changed, 164 insertions(+), 164 deletions(-)
>   delete mode 100644 arch/arm/mach-at91/include/mach/at91_st.h
>   rename arch/arm/mach-at91/at91rm9200_time.c => drivers/clocksource/timer-atmel-st.c (74%)
>   create mode 100644 include/linux/mfd/syscon/atmel-st.h
>


-- 
  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

* Re: [PATCH v5 00/10] Atmel System Timer cleanups
  2015-03-13 10:23 ` Daniel Lezcano
@ 2015-03-13 10:33   ` Alexandre Belloni
  2015-03-13 10:33     ` Daniel Lezcano
  0 siblings, 1 reply; 28+ messages in thread
From: Alexandre Belloni @ 2015-03-13 10:33 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Nicolas Ferre, Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog

On 13/03/2015 at 11:23:05 +0100, Daniel Lezcano wrote :
> On 03/12/2015 01:07 PM, Alexandre Belloni wrote:
> >This patch set cleans up the system timer driver.
> >
> >The main goal is to get rid of the mach/ headers dependency. At the same time,
> >it introduces proper probing and locking (using a regmap) for the watchdog
> >driver.
> >
> >This is based on 4.0-rc1 and will have two merge conflicts with my cleanup #1 in
> >mach-at91/at91rm9200.c
> >
> >It also needs this patch to probe the watchdog properly:
> >http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/327274.html
> 
> 
> Hi Alexandre,
> 
> through which tree do you want this patchset to be merged ?
> 

I'd say through the at91 tree as I have another series that depend on
that one


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* Re: [PATCH v5 00/10] Atmel System Timer cleanups
  2015-03-13 10:33   ` Alexandre Belloni
@ 2015-03-13 10:33     ` Daniel Lezcano
  2015-03-13 16:36       ` Nicolas Ferre
  0 siblings, 1 reply; 28+ messages in thread
From: Daniel Lezcano @ 2015-03-13 10:33 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Nicolas Ferre, Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog

On 03/13/2015 11:33 AM, Alexandre Belloni wrote:
> On 13/03/2015 at 11:23:05 +0100, Daniel Lezcano wrote :
>> On 03/12/2015 01:07 PM, Alexandre Belloni wrote:
>>> This patch set cleans up the system timer driver.
>>>
>>> The main goal is to get rid of the mach/ headers dependency. At the same time,
>>> it introduces proper probing and locking (using a regmap) for the watchdog
>>> driver.
>>>
>>> This is based on 4.0-rc1 and will have two merge conflicts with my cleanup #1 in
>>> mach-at91/at91rm9200.c
>>>
>>> It also needs this patch to probe the watchdog properly:
>>> http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/327274.html
>>
>>
>> Hi Alexandre,
>>
>> through which tree do you want this patchset to be merged ?
>>
>
> I'd say through the at91 tree as I have another series that depend on
> that one

Ok.


-- 
  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

* Re: [PATCH v5 02/10] mfd: syscon: Add atmel system timer registers definition
  2015-03-13  8:03   ` Lee Jones
@ 2015-03-13 10:40     ` Alexandre Belloni
  2015-03-13 16:52       ` Nicolas Ferre
  0 siblings, 1 reply; 28+ messages in thread
From: Alexandre Belloni @ 2015-03-13 10:40 UTC (permalink / raw)
  To: Lee Jones
  Cc: Nicolas Ferre, Daniel Lezcano, Boris Brezillon, linux-watchdog,
	linux-kernel, Wim Van Sebroeck, Guenter Roeck,
	Jean-Christophe Plagniol-Villard, linux-arm-kernel

Hi,

On 13/03/2015 at 08:03:15 +0000, Lee Jones wrote :
> On Thu, 12 Mar 2015, Alexandre Belloni wrote:
> 
> > AT91RM920 has a memory range reserved for timer and watchdog configuration.
> > Expose those registers so that drivers can make use of the system timer syscon
> > declared in at91 DTs.
> > 
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> > Acked-by: Lee Jones <lee.jones@linaro.org>
> > ---
> >  include/linux/mfd/syscon/atmel-st.h | 49 +++++++++++++++++++++++++++++++++++++
> >  1 file changed, 49 insertions(+)
> >  create mode 100644 include/linux/mfd/syscon/atmel-st.h
> 
> Applied, thanks.
> 

Actually, I was thinking this could go through the at91 to avoid
depending on your branch.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* Re: [PATCH v5 09/10] clocksource: atmel-st: remove mach/hardware dependency
  2015-03-13 10:21   ` Daniel Lezcano
@ 2015-03-13 10:44     ` Alexandre Belloni
  0 siblings, 0 replies; 28+ messages in thread
From: Alexandre Belloni @ 2015-03-13 10:44 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Nicolas Ferre, Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, Guenter Roeck, linux-kernel, linux-arm-kernel,
	linux-watchdog

On 13/03/2015 at 11:21:35 +0100, Daniel Lezcano wrote :
> On 03/12/2015 01:07 PM, Alexandre Belloni wrote:
> >Remove the mach/hardware dependency to prepare the driver for multiplatform
> >support.
> >Also switch from setup_irq() to request_irq()
> >
> >Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> >---
> >  drivers/clocksource/timer-atmel-st.c | 21 +++++++++------------
> >  1 file changed, 9 insertions(+), 12 deletions(-)
> >
> >diff --git a/drivers/clocksource/timer-atmel-st.c b/drivers/clocksource/timer-atmel-st.c
> >index 674ef2519d6b..91d6cbb7a56b 100644
> >--- a/drivers/clocksource/timer-atmel-st.c
> >+++ b/drivers/clocksource/timer-atmel-st.c
> >@@ -31,13 +31,12 @@
> >
> >  #include <asm/mach/time.h>
> 
> Couldn't the header above be removed ?
> 

Indeed, it can but that is starting to be further cleanup than I
intended ;)

I'll send a v6 of that patch for Nicolas to pick.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [PATCH v6 09/10] clocksource: atmel-st: remove mach/hardware dependency
  2015-03-12 12:07 ` [PATCH v5 09/10] clocksource: atmel-st: remove mach/hardware dependency Alexandre Belloni
  2015-03-13 10:21   ` Daniel Lezcano
@ 2015-03-13 10:54   ` Alexandre Belloni
  1 sibling, 0 replies; 28+ messages in thread
From: Alexandre Belloni @ 2015-03-13 10:54 UTC (permalink / raw)
  To: Nicolas Ferre, Daniel Lezcano
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard, linux-kernel,
	linux-arm-kernel, Alexandre Belloni

Remove the mach/hardware dependency to prepare the driver for multiplatform
support.
Also switch from setup_irq() to request_irq()

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/clocksource/timer-atmel-st.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/clocksource/timer-atmel-st.c b/drivers/clocksource/timer-atmel-st.c
index 674ef2519d6b..1692e17e096b 100644
--- a/drivers/clocksource/timer-atmel-st.c
+++ b/drivers/clocksource/timer-atmel-st.c
@@ -29,15 +29,12 @@
 #include <linux/of_irq.h>
 #include <linux/regmap.h>
 
-#include <asm/mach/time.h>
-
-#include <mach/hardware.h>
-
 static unsigned long last_crtr;
 static u32 irqmask;
 static struct clock_event_device clkevt;
 static struct regmap *regmap_st;
 
+#define AT91_SLOW_CLOCK		32768
 #define RM9200_TIMER_LATCH	((AT91_SLOW_CLOCK + HZ/2) / HZ)
 
 /*
@@ -96,13 +93,6 @@ static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id)
 	return IRQ_NONE;
 }
 
-static struct irqaction at91rm9200_timer_irq = {
-	.name		= "at91_tick",
-	.flags		= IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
-	.handler	= at91rm9200_timer_interrupt,
-	.irq		= NR_IRQS_LEGACY + AT91_ID_SYS,
-};
-
 static cycle_t read_clk32k(struct clocksource *cs)
 {
 	return read_CRTR();
@@ -193,6 +183,7 @@ static struct clock_event_device clkevt = {
 static void __init atmel_st_timer_init(struct device_node *node)
 {
 	unsigned int val;
+	int irq, ret;
 
 	regmap_st = syscon_node_to_regmap(node);
 	if (IS_ERR(regmap_st))
@@ -204,12 +195,16 @@ static void __init atmel_st_timer_init(struct device_node *node)
 	regmap_read(regmap_st, AT91_ST_SR, &val);
 
 	/* Get the interrupts property */
-	at91rm9200_timer_irq.irq  = irq_of_parse_and_map(node, 0);
-	if (!at91rm9200_timer_irq.irq)
+	irq  = irq_of_parse_and_map(node, 0);
+	if (!irq)
 		panic(pr_fmt("Unable to get IRQ from DT\n"));
 
 	/* Make IRQs happen for the system timer */
-	setup_irq(at91rm9200_timer_irq.irq, &at91rm9200_timer_irq);
+	ret = request_irq(irq, at91rm9200_timer_interrupt,
+			  IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
+			  "at91_tick", regmap_st);
+	if (ret)
+		panic(pr_fmt("Unable to setup IRQ\n"));
 
 	/* The 32KiHz "Slow Clock" (tick every 30517.58 nanoseconds) is used
 	 * directly for the clocksource and all clockevents, after adjusting
-- 
2.1.0


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

* Re: [PATCH v5 00/10] Atmel System Timer cleanups
  2015-03-13 10:33     ` Daniel Lezcano
@ 2015-03-13 16:36       ` Nicolas Ferre
  0 siblings, 0 replies; 28+ messages in thread
From: Nicolas Ferre @ 2015-03-13 16:36 UTC (permalink / raw)
  To: Daniel Lezcano, Alexandre Belloni, Guenter Roeck, Lee Jones
  Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
	Wim Van Sebroeck, linux-kernel, linux-arm-kernel, linux-watchdog

Le 13/03/2015 11:33, Daniel Lezcano a écrit :
> On 03/13/2015 11:33 AM, Alexandre Belloni wrote:
>> On 13/03/2015 at 11:23:05 +0100, Daniel Lezcano wrote :
>>> On 03/12/2015 01:07 PM, Alexandre Belloni wrote:
>>>> This patch set cleans up the system timer driver.
>>>>
>>>> The main goal is to get rid of the mach/ headers dependency. At the same time,
>>>> it introduces proper probing and locking (using a regmap) for the watchdog
>>>> driver.
>>>>
>>>> This is based on 4.0-rc1 and will have two merge conflicts with my cleanup #1 in
>>>> mach-at91/at91rm9200.c
>>>>
>>>> It also needs this patch to probe the watchdog properly:
>>>> http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/327274.html
>>>
>>>
>>> Hi Alexandre,
>>>
>>> through which tree do you want this patchset to be merged ?
>>>
>>
>> I'd say through the at91 tree as I have another series that depend on
>> that one
> 
> Ok.

Absolutely. To the whole series:
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

And I stack it on at91-4.1-cleanup right now.

Bye,
-- 
Nicolas Ferre

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

* Re: [PATCH v5 02/10] mfd: syscon: Add atmel system timer registers definition
  2015-03-13 10:40     ` Alexandre Belloni
@ 2015-03-13 16:52       ` Nicolas Ferre
  2015-03-16  8:17         ` Lee Jones
  0 siblings, 1 reply; 28+ messages in thread
From: Nicolas Ferre @ 2015-03-13 16:52 UTC (permalink / raw)
  To: Alexandre Belloni, Lee Jones
  Cc: Daniel Lezcano, Boris Brezillon, linux-watchdog, linux-kernel,
	Wim Van Sebroeck, Guenter Roeck,
	Jean-Christophe Plagniol-Villard, linux-arm-kernel

Le 13/03/2015 11:40, Alexandre Belloni a écrit :
> Hi,
> 
> On 13/03/2015 at 08:03:15 +0000, Lee Jones wrote :
>> On Thu, 12 Mar 2015, Alexandre Belloni wrote:
>>
>>> AT91RM920 has a memory range reserved for timer and watchdog configuration.
>>> Expose those registers so that drivers can make use of the system timer syscon
>>> declared in at91 DTs.
>>>
>>> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
>>> Acked-by: Lee Jones <lee.jones@linaro.org>
>>> ---
>>>  include/linux/mfd/syscon/atmel-st.h | 49 +++++++++++++++++++++++++++++++++++++
>>>  1 file changed, 49 insertions(+)
>>>  create mode 100644 include/linux/mfd/syscon/atmel-st.h
>>
>> Applied, thanks.

> Actually, I was thinking this could go through the at91 to avoid
> depending on your branch.

Lee,

I was planning to take the whole series with me to limit the number of
merge conflicts and dependencies.
Do you mind if I take this patch with the other AT91 cleanup patches
through the arm-soc tree?
If you are okay, can you remove this patch already applied on your tree?

Thanks, bye.
-- 
Nicolas Ferre

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

* Re: [PATCH v5 02/10] mfd: syscon: Add atmel system timer registers definition
  2015-03-13 16:52       ` Nicolas Ferre
@ 2015-03-16  8:17         ` Lee Jones
  0 siblings, 0 replies; 28+ messages in thread
From: Lee Jones @ 2015-03-16  8:17 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Alexandre Belloni, Daniel Lezcano, Boris Brezillon,
	linux-watchdog, linux-kernel, Wim Van Sebroeck, Guenter Roeck,
	Jean-Christophe Plagniol-Villard, linux-arm-kernel

On Fri, 13 Mar 2015, Nicolas Ferre wrote:

> Le 13/03/2015 11:40, Alexandre Belloni a écrit :
> > Hi,
> > 
> > On 13/03/2015 at 08:03:15 +0000, Lee Jones wrote :
> >> On Thu, 12 Mar 2015, Alexandre Belloni wrote:
> >>
> >>> AT91RM920 has a memory range reserved for timer and watchdog configuration.
> >>> Expose those registers so that drivers can make use of the system timer syscon
> >>> declared in at91 DTs.
> >>>
> >>> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> >>> Acked-by: Lee Jones <lee.jones@linaro.org>
> >>> ---
> >>>  include/linux/mfd/syscon/atmel-st.h | 49 +++++++++++++++++++++++++++++++++++++
> >>>  1 file changed, 49 insertions(+)
> >>>  create mode 100644 include/linux/mfd/syscon/atmel-st.h
> >>
> >> Applied, thanks.
> 
> > Actually, I was thinking this could go through the at91 to avoid
> > depending on your branch.
> 
> Lee,
> 
> I was planning to take the whole series with me to limit the number of
> merge conflicts and dependencies.
> Do you mind if I take this patch with the other AT91 cleanup patches
> through the arm-soc tree?
> If you are okay, can you remove this patch already applied on your tree?

Yes, no problem.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

end of thread, other threads:[~2015-03-16  8:17 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-12 12:07 [PATCH v5 00/10] Atmel System Timer cleanups Alexandre Belloni
2015-03-12 12:07 ` [PATCH v5 01/10] ARM: at91/dt: declare atmel,at91rm9200-st as a syscon Alexandre Belloni
2015-03-12 12:07 ` [PATCH v5 02/10] mfd: syscon: Add atmel system timer registers definition Alexandre Belloni
2015-03-13  8:03   ` Lee Jones
2015-03-13 10:40     ` Alexandre Belloni
2015-03-13 16:52       ` Nicolas Ferre
2015-03-16  8:17         ` Lee Jones
2015-03-12 12:07 ` [PATCH v5 03/10] watchdog: at91rm9200: use the system timer syscon Alexandre Belloni
2015-03-12 16:19   ` Guenter Roeck
2015-03-12 12:07 ` [PATCH v5 04/10] watchdog: at91rm9200: implement restart handler Alexandre Belloni
2015-03-12 16:22   ` Guenter Roeck
2015-03-12 12:07 ` [PATCH v5 05/10] ARM: at91: at91rm9200: remove deprecated arm_pm_restart Alexandre Belloni
2015-03-12 12:07 ` [PATCH v5 06/10] ARM: at91: properly initialize timer Alexandre Belloni
2015-03-12 12:07 ` [PATCH v5 07/10] ARM: at91: time: move the system timer driver to drivers/clocksource Alexandre Belloni
2015-03-13 10:14   ` Daniel Lezcano
2015-03-12 12:07 ` [PATCH v5 08/10] clocksource: atmel-st: use syscon/regmap Alexandre Belloni
2015-03-13 10:17   ` Daniel Lezcano
2015-03-12 12:07 ` [PATCH v5 09/10] clocksource: atmel-st: remove mach/hardware dependency Alexandre Belloni
2015-03-13 10:21   ` Daniel Lezcano
2015-03-13 10:44     ` Alexandre Belloni
2015-03-13 10:54   ` [PATCH v6 " Alexandre Belloni
2015-03-12 12:07 ` [PATCH v5 10/10] ARM: at91: remove useless include Alexandre Belloni
2015-03-13 10:22   ` Daniel Lezcano
2015-03-12 14:04 ` [PATCH v5 00/10] Atmel System Timer cleanups Nicolas Ferre
2015-03-13 10:23 ` Daniel Lezcano
2015-03-13 10:33   ` Alexandre Belloni
2015-03-13 10:33     ` Daniel Lezcano
2015-03-13 16:36       ` Nicolas Ferre

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