linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/13] AT91: PIT: Cleanups and move to drivers/clocksource
@ 2014-06-25 13:06 Maxime Ripard
  2014-06-25 13:06 ` [PATCH 01/13] AT91: PIT: Follow the general coding rules Maxime Ripard
                   ` (13 more replies)
  0 siblings, 14 replies; 21+ messages in thread
From: Maxime Ripard @ 2014-06-25 13:06 UTC (permalink / raw)
  To: linux, Nicolas Ferre, Jean-Christophe Plagniol-Villard, Daniel Lezcano
  Cc: Boris Brezillon, Alexandre Belloni, Thomas Petazzoni,
	linux-arm-kernel, linux-kernel, Maxime Ripard

Hi everyone,

This series cleans up the PIT driver in order for it to not depend on
anything in mach-at91 anymore, and in the end move it out of
mach-at91.

Along the way, these patches also do a bit of cleanup.

This has been tested on a G45-EK without DT and an Xplained with DT.

Thanks,
Maxime

Maxime Ripard (13):
  AT91: PIT: Follow the general coding rules
  AT91: generic.h: Add include safe guards
  AT91: PIT: Use of_have_populated_dt instead of CONFIG_OF
  AT91: PIT: Rework probe functions
  AT91: dt: Remove init_time definitions
  AT91: PIT: Use consistent exit path in probe
  AT91: PIT: Use pr_fmt
  AT91: PIT: use request_irq instead of setup_irq
  AT91: PIT: (Almost) remove the global variables
  AT91: soc: Add init_time callback
  AT91: Convert the boards to the init_time callback
  AT91: PIT: Convert to an early_platform_device
  AT91: PIT: Move the driver to drivers/clocksource

 arch/arm/mach-at91/Kconfig              |   3 -
 arch/arm/mach-at91/Makefile             |   1 -
 arch/arm/mach-at91/at91sam9260.c        |  34 +++-
 arch/arm/mach-at91/at91sam9261.c        |  34 +++-
 arch/arm/mach-at91/at91sam9263.c        |  34 +++-
 arch/arm/mach-at91/at91sam926x_time.c   | 294 ------------------------------
 arch/arm/mach-at91/at91sam9g45.c        |  35 +++-
 arch/arm/mach-at91/at91sam9rl.c         |  34 +++-
 arch/arm/mach-at91/board-afeb-9260v1.c  |   2 +-
 arch/arm/mach-at91/board-cam60.c        |   2 +-
 arch/arm/mach-at91/board-cpu9krea.c     |   2 +-
 arch/arm/mach-at91/board-dt-sam9.c      |  10 --
 arch/arm/mach-at91/board-dt-sama5.c     |   9 -
 arch/arm/mach-at91/board-flexibity.c    |   2 +-
 arch/arm/mach-at91/board-foxg20.c       |   2 +-
 arch/arm/mach-at91/board-gsia18s.c      |   2 +-
 arch/arm/mach-at91/board-pcontrol-g20.c |   2 +-
 arch/arm/mach-at91/board-sam9-l9260.c   |   2 +-
 arch/arm/mach-at91/board-sam9260ek.c    |   2 +-
 arch/arm/mach-at91/board-sam9261ek.c    |   4 +-
 arch/arm/mach-at91/board-sam9263ek.c    |   2 +-
 arch/arm/mach-at91/board-sam9g20ek.c    |   4 +-
 arch/arm/mach-at91/board-sam9m10g45ek.c |   2 +-
 arch/arm/mach-at91/board-sam9rlek.c     |   2 +-
 arch/arm/mach-at91/board-snapper9260.c  |   2 +-
 arch/arm/mach-at91/board-stamp9g20.c    |   4 +-
 arch/arm/mach-at91/generic.h            |   8 +-
 arch/arm/mach-at91/setup.c              |   5 +
 arch/arm/mach-at91/soc.h                |   1 +
 drivers/clocksource/Kconfig             |   4 +
 drivers/clocksource/Makefile            |   1 +
 drivers/clocksource/at91sam926x_time.c  | 304 ++++++++++++++++++++++++++++++++
 32 files changed, 506 insertions(+), 343 deletions(-)
 delete mode 100644 arch/arm/mach-at91/at91sam926x_time.c
 create mode 100644 drivers/clocksource/at91sam926x_time.c

-- 
2.0.0


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

* [PATCH 01/13] AT91: PIT: Follow the general coding rules
  2014-06-25 13:06 [PATCH 00/13] AT91: PIT: Cleanups and move to drivers/clocksource Maxime Ripard
@ 2014-06-25 13:06 ` Maxime Ripard
  2014-06-25 13:06 ` [PATCH 02/13] AT91: generic.h: Add include safe guards Maxime Ripard
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Maxime Ripard @ 2014-06-25 13:06 UTC (permalink / raw)
  To: linux, Nicolas Ferre, Jean-Christophe Plagniol-Villard, Daniel Lezcano
  Cc: Boris Brezillon, Alexandre Belloni, Thomas Petazzoni,
	linux-arm-kernel, linux-kernel, Maxime Ripard

Replace all masks and bits definitions by matching calls to BIT and GENMASK.
While we're at it, also fix a few style issues.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 arch/arm/mach-at91/at91sam926x_time.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c
index 0a9e2fc8f796..fd3170b65fbb 100644
--- a/arch/arm/mach-at91/at91sam926x_time.c
+++ b/arch/arm/mach-at91/at91sam926x_time.c
@@ -9,11 +9,12 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+
+#include <linux/clk.h>
+#include <linux/clockchips.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/kernel.h>
-#include <linux/clk.h>
-#include <linux/clockchips.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
@@ -22,17 +23,17 @@
 #include <mach/hardware.h>
 
 #define AT91_PIT_MR		0x00			/* Mode Register */
-#define		AT91_PIT_PITIEN		(1 << 25)		/* Timer Interrupt Enable */
-#define		AT91_PIT_PITEN		(1 << 24)		/* Timer Enabled */
-#define		AT91_PIT_PIV		(0xfffff)		/* Periodic Interval Value */
+#define AT91_PIT_PITIEN			BIT(25)			/* Timer Interrupt Enable */
+#define AT91_PIT_PITEN			BIT(24)			/* Timer Enabled */
+#define AT91_PIT_PIV			GENMASK(19, 0)		/* Periodic Interval Value */
 
 #define AT91_PIT_SR		0x04			/* Status Register */
-#define		AT91_PIT_PITS		(1 << 0)		/* Timer Status */
+#define AT91_PIT_PITS			BIT(0)			/* Timer Status */
 
 #define AT91_PIT_PIVR		0x08			/* Periodic Interval Value Register */
 #define AT91_PIT_PIIR		0x0c			/* Periodic Interval Image Register */
-#define		AT91_PIT_PICNT		(0xfff << 20)		/* Interval Counter */
-#define		AT91_PIT_CPIV		(0xfffff)		/* Inverval Value */
+#define AT91_PIT_PICNT			GENMASK(31, 20)		/* Interval Counter */
+#define AT91_PIT_CPIV			GENMASK(19, 0)		/* Inverval Value */
 
 #define PIT_CPIV(x)	((x) & AT91_PIT_CPIV)
 #define PIT_PICNT(x)	(((x) & AT91_PIT_PICNT) >> 20)
-- 
2.0.0


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

* [PATCH 02/13] AT91: generic.h: Add include safe guards
  2014-06-25 13:06 [PATCH 00/13] AT91: PIT: Cleanups and move to drivers/clocksource Maxime Ripard
  2014-06-25 13:06 ` [PATCH 01/13] AT91: PIT: Follow the general coding rules Maxime Ripard
@ 2014-06-25 13:06 ` Maxime Ripard
  2014-06-25 13:06 ` [PATCH 03/13] AT91: PIT: Use of_have_populated_dt instead of CONFIG_OF Maxime Ripard
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Maxime Ripard @ 2014-06-25 13:06 UTC (permalink / raw)
  To: linux, Nicolas Ferre, Jean-Christophe Plagniol-Villard, Daniel Lezcano
  Cc: Boris Brezillon, Alexandre Belloni, Thomas Petazzoni,
	linux-arm-kernel, linux-kernel, Maxime Ripard

The generic.h header file doesn't have any safe guards against multiple
inclusion. It only worked so far because all the symbols defined in it were
extern, but this is a rather fragile assumption.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 arch/arm/mach-at91/generic.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index 631fa3b8c16d..77d4daeee66a 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -8,6 +8,9 @@
  * published by the Free Software Foundation.
  */
 
+#ifndef _AT91_GENERIC_H
+#define _AT91_GENERIC_H
+
 #include <linux/clkdev.h>
 #include <linux/of.h>
 #include <linux/reboot.h>
@@ -90,3 +93,5 @@ extern int  __init at91_gpio_of_irq_setup(struct device_node *node,
 					  struct device_node *parent);
 
 extern u32 at91_get_extern_irq(void);
+
+#endif /* _AT91_GENERIC_H */
-- 
2.0.0


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

* [PATCH 03/13] AT91: PIT: Use of_have_populated_dt instead of CONFIG_OF
  2014-06-25 13:06 [PATCH 00/13] AT91: PIT: Cleanups and move to drivers/clocksource Maxime Ripard
  2014-06-25 13:06 ` [PATCH 01/13] AT91: PIT: Follow the general coding rules Maxime Ripard
  2014-06-25 13:06 ` [PATCH 02/13] AT91: generic.h: Add include safe guards Maxime Ripard
@ 2014-06-25 13:06 ` Maxime Ripard
  2014-06-25 13:06 ` [PATCH 04/13] AT91: PIT: Rework probe functions Maxime Ripard
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Maxime Ripard @ 2014-06-25 13:06 UTC (permalink / raw)
  To: linux, Nicolas Ferre, Jean-Christophe Plagniol-Villard, Daniel Lezcano
  Cc: Boris Brezillon, Alexandre Belloni, Thomas Petazzoni,
	linux-arm-kernel, linux-kernel, Maxime Ripard

Until now, the machines, even when CONFIG_OF was enabled, were calling
at91sam926x_ioremap_pit to try to map the PIT address using the defined
physical address.

Obviously, with DT, it's not appropriate anymore, and some code was added to
the function to deal with this case.

Unfortunately, this code was conditionned on CONFIG_OF, which can be enabled,
even though no DT was actually used, which would result in such a case, to this
code being executed, without any reason.

Moreover, the logic that was here before to bail out of the function just check
in the DT to see if the PIT node is there, which is the case in all our DTSI.

All this can be made much more straightforward just by using
of_have_populated_dt to bail out.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 arch/arm/mach-at91/at91sam926x_time.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c
index fd3170b65fbb..38490645efea 100644
--- a/arch/arm/mach-at91/at91sam926x_time.c
+++ b/arch/arm/mach-at91/at91sam926x_time.c
@@ -279,15 +279,9 @@ void __init at91sam926x_pit_init(void)
 
 void __init at91sam926x_ioremap_pit(u32 addr)
 {
-#if defined(CONFIG_OF)
-	struct device_node *np =
-		of_find_matching_node(NULL, pit_timer_ids);
-
-	if (np) {
-		of_node_put(np);
+	if (of_have_populated_dt())
 		return;
-	}
-#endif
+
 	pit_base_addr = ioremap(addr, 16);
 
 	if (!pit_base_addr)
-- 
2.0.0


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

* [PATCH 04/13] AT91: PIT: Rework probe functions
  2014-06-25 13:06 [PATCH 00/13] AT91: PIT: Cleanups and move to drivers/clocksource Maxime Ripard
                   ` (2 preceding siblings ...)
  2014-06-25 13:06 ` [PATCH 03/13] AT91: PIT: Use of_have_populated_dt instead of CONFIG_OF Maxime Ripard
@ 2014-06-25 13:06 ` Maxime Ripard
  2014-06-25 13:06 ` [PATCH 05/13] AT91: dt: Remove init_time definitions Maxime Ripard
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Maxime Ripard @ 2014-06-25 13:06 UTC (permalink / raw)
  To: linux, Nicolas Ferre, Jean-Christophe Plagniol-Villard, Daniel Lezcano
  Cc: Boris Brezillon, Alexandre Belloni, Thomas Petazzoni,
	linux-arm-kernel, linux-kernel, Maxime Ripard

The PIT timer driver until now had a single probe function, disregarding wether
it was probed through DT or in the old-style way. This code later on was
calling some DT function to retrieve the proper values for its base address,
interrupts and clocks.

While this was working, it was preventing the usage of CLOCKSOURCE_OF_DECLARE,
and the two different probe path were not as clearly separated as they could
be.

Rework the probe path to take this into account, and switch to
CLOCKSOURCE_OF_DECLARE.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 arch/arm/mach-at91/Kconfig            |   1 +
 arch/arm/mach-at91/at91sam926x_time.c | 108 +++++++++++++++-------------------
 arch/arm/mach-at91/board-dt-sam9.c    |   3 +-
 arch/arm/mach-at91/board-dt-sama5.c   |   3 +-
 4 files changed, 51 insertions(+), 64 deletions(-)

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 45b55e0f0db6..a64412a020d3 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -37,6 +37,7 @@ config AT91_SAM9G45_RESET
 	default !ARCH_AT91X40
 
 config AT91_SAM9_TIME
+	select CLKSRC_OF if OF
 	bool
 
 config HAVE_AT91_SMD
diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c
index 38490645efea..e953197e5a5c 100644
--- a/arch/arm/mach-at91/at91sam926x_time.c
+++ b/arch/arm/mach-at91/at91sam926x_time.c
@@ -19,7 +19,6 @@
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 
-#include <asm/mach/time.h>
 #include <mach/hardware.h>
 
 #define AT91_PIT_MR		0x00			/* Mode Register */
@@ -176,81 +175,21 @@ static struct irqaction at91sam926x_pit_irq = {
 	.name		= "at91_tick",
 	.flags		= IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
 	.handler	= at91sam926x_pit_interrupt,
-	.irq		= NR_IRQS_LEGACY + AT91_ID_SYS,
 };
 
-#ifdef CONFIG_OF
-static struct of_device_id pit_timer_ids[] = {
-	{ .compatible = "atmel,at91sam9260-pit" },
-	{ /* sentinel */ }
-};
-
-static int __init of_at91sam926x_pit_init(void)
-{
-	struct device_node	*np;
-	int			ret;
-
-	np = of_find_matching_node(NULL, pit_timer_ids);
-	if (!np)
-		goto err;
-
-	pit_base_addr = of_iomap(np, 0);
-	if (!pit_base_addr)
-		goto node_err;
-
-	mck = of_clk_get(np, 0);
-
-	/* Get the interrupts property */
-	ret = irq_of_parse_and_map(np, 0);
-	if (!ret) {
-		pr_crit("AT91: PIT: Unable to get IRQ from DT\n");
-		if (!IS_ERR(mck))
-			clk_put(mck);
-		goto ioremap_err;
-	}
-	at91sam926x_pit_irq.irq = ret;
-
-	of_node_put(np);
-
-	return 0;
-
-ioremap_err:
-	iounmap(pit_base_addr);
-node_err:
-	of_node_put(np);
-err:
-	return -EINVAL;
-}
-#else
-static int __init of_at91sam926x_pit_init(void)
-{
-	return -EINVAL;
-}
-#endif
-
 /*
  * Set up both clocksource and clockevent support.
  */
-void __init at91sam926x_pit_init(void)
+static void __init at91sam926x_pit_common_init(void)
 {
 	unsigned long	pit_rate;
 	unsigned	bits;
 	int		ret;
 
-	mck = ERR_PTR(-ENOENT);
-
-	/* For device tree enabled device: initialize here */
-	of_at91sam926x_pit_init();
-
 	/*
 	 * Use our actual MCK to figure out how many MCK/16 ticks per
 	 * 1/HZ period (instead of a compile-time constant LATCH).
 	 */
-	if (IS_ERR(mck))
-		mck = clk_get(NULL, "mck");
-
-	if (IS_ERR(mck))
-		panic("AT91: PIT: Unable to get mck clk\n");
 	pit_rate = clk_get_rate(mck) / 16;
 	pit_cycle = (pit_rate + HZ/2) / HZ;
 	WARN_ON(((pit_cycle - 1) & ~AT91_PIT_PIV) != 0);
@@ -277,6 +216,51 @@ void __init at91sam926x_pit_init(void)
 	clockevents_register_device(&pit_clkevt);
 }
 
+static void __init at91sam926x_pit_dt_init(struct device_node *node)
+{
+	unsigned int irq;
+
+	pit_base_addr = of_iomap(node, 0);
+	if (!pit_base_addr)
+		return;
+
+	mck = of_clk_get(node, 0);
+	if (IS_ERR(mck))
+		/* Fallback on clkdev for !CCF-based boards */
+		mck = clk_get(NULL, "mck");
+
+	if (IS_ERR(mck))
+		panic("AT91: PIT: Unable to get mck clk\n");
+
+	/* Get the interrupts property */
+	irq = irq_of_parse_and_map(node, 0);
+	if (!irq) {
+		pr_crit("AT91: PIT: Unable to get IRQ from DT\n");
+		goto clk_err;
+	}
+
+	at91sam926x_pit_irq.irq = irq;
+
+	at91sam926x_pit_common_init();
+
+clk_err:
+	clk_put(mck);
+	iounmap(pit_base_addr);
+}
+CLOCKSOURCE_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit",
+		       at91sam926x_pit_dt_init);
+
+void __init at91sam926x_pit_init(void)
+{
+	mck = clk_get(NULL, "mck");
+	if (IS_ERR(mck))
+		panic("AT91: PIT: Unable to get mck clk\n");
+
+	at91sam926x_pit_irq.irq = NR_IRQS_LEGACY + AT91_ID_SYS,
+
+	at91sam926x_pit_common_init();
+}
+
 void __init at91sam926x_ioremap_pit(u32 addr)
 {
 	if (of_have_populated_dt())
diff --git a/arch/arm/mach-at91/board-dt-sam9.c b/arch/arm/mach-at91/board-dt-sam9.c
index 575b0be66ca8..a9fcdadfd929 100644
--- a/arch/arm/mach-at91/board-dt-sam9.c
+++ b/arch/arm/mach-at91/board-dt-sam9.c
@@ -14,6 +14,7 @@
 #include <linux/of.h>
 #include <linux/of_irq.h>
 #include <linux/clk-provider.h>
+#include <linux/clocksource.h>
 
 #include <asm/setup.h>
 #include <asm/irq.h>
@@ -31,7 +32,7 @@ static void __init sam9_dt_timer_init(void)
 #if defined(CONFIG_COMMON_CLK)
 	of_clk_init(NULL);
 #endif
-	at91sam926x_pit_init();
+	clocksource_of_init();
 }
 
 static const struct of_device_id irq_of_match[] __initconst = {
diff --git a/arch/arm/mach-at91/board-dt-sama5.c b/arch/arm/mach-at91/board-dt-sama5.c
index 075ec0576ada..c07dd2395f36 100644
--- a/arch/arm/mach-at91/board-dt-sama5.c
+++ b/arch/arm/mach-at91/board-dt-sama5.c
@@ -17,6 +17,7 @@
 #include <linux/of_platform.h>
 #include <linux/phy.h>
 #include <linux/clk-provider.h>
+#include <linux/clocksource.h>
 
 #include <asm/setup.h>
 #include <asm/irq.h>
@@ -32,7 +33,7 @@ static void __init sama5_dt_timer_init(void)
 #if defined(CONFIG_COMMON_CLK)
 	of_clk_init(NULL);
 #endif
-	at91sam926x_pit_init();
+	clocksource_of_init();
 }
 
 static const struct of_device_id irq_of_match[] __initconst = {
-- 
2.0.0


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

* [PATCH 05/13] AT91: dt: Remove init_time definitions
  2014-06-25 13:06 [PATCH 00/13] AT91: PIT: Cleanups and move to drivers/clocksource Maxime Ripard
                   ` (3 preceding siblings ...)
  2014-06-25 13:06 ` [PATCH 04/13] AT91: PIT: Rework probe functions Maxime Ripard
@ 2014-06-25 13:06 ` Maxime Ripard
  2014-06-25 13:06 ` [PATCH 06/13] AT91: PIT: Use consistent exit path in probe Maxime Ripard
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Maxime Ripard @ 2014-06-25 13:06 UTC (permalink / raw)
  To: linux, Nicolas Ferre, Jean-Christophe Plagniol-Villard, Daniel Lezcano
  Cc: Boris Brezillon, Alexandre Belloni, Thomas Petazzoni,
	linux-arm-kernel, linux-kernel, Maxime Ripard

The current AT91 DT boards have a completely generic init_time definition.
Remove them from the machine declaration.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 arch/arm/mach-at91/board-dt-sam9.c  | 11 -----------
 arch/arm/mach-at91/board-dt-sama5.c | 10 ----------
 2 files changed, 21 deletions(-)

diff --git a/arch/arm/mach-at91/board-dt-sam9.c b/arch/arm/mach-at91/board-dt-sam9.c
index a9fcdadfd929..3f80ceb3f444 100644
--- a/arch/arm/mach-at91/board-dt-sam9.c
+++ b/arch/arm/mach-at91/board-dt-sam9.c
@@ -14,7 +14,6 @@
 #include <linux/of.h>
 #include <linux/of_irq.h>
 #include <linux/clk-provider.h>
-#include <linux/clocksource.h>
 
 #include <asm/setup.h>
 #include <asm/irq.h>
@@ -26,15 +25,6 @@
 #include "board.h"
 #include "generic.h"
 
-
-static void __init sam9_dt_timer_init(void)
-{
-#if defined(CONFIG_COMMON_CLK)
-	of_clk_init(NULL);
-#endif
-	clocksource_of_init();
-}
-
 static const struct of_device_id irq_of_match[] __initconst = {
 
 	{ .compatible = "atmel,at91rm9200-aic", .data = at91_aic_of_init },
@@ -53,7 +43,6 @@ static const char *at91_dt_board_compat[] __initdata = {
 
 DT_MACHINE_START(at91sam_dt, "Atmel AT91SAM (Device Tree)")
 	/* Maintainer: Atmel */
-	.init_time	= sam9_dt_timer_init,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= at91_dt_initialize,
diff --git a/arch/arm/mach-at91/board-dt-sama5.c b/arch/arm/mach-at91/board-dt-sama5.c
index c07dd2395f36..030f4b65f449 100644
--- a/arch/arm/mach-at91/board-dt-sama5.c
+++ b/arch/arm/mach-at91/board-dt-sama5.c
@@ -17,7 +17,6 @@
 #include <linux/of_platform.h>
 #include <linux/phy.h>
 #include <linux/clk-provider.h>
-#include <linux/clocksource.h>
 
 #include <asm/setup.h>
 #include <asm/irq.h>
@@ -28,14 +27,6 @@
 #include "at91_aic.h"
 #include "generic.h"
 
-static void __init sama5_dt_timer_init(void)
-{
-#if defined(CONFIG_COMMON_CLK)
-	of_clk_init(NULL);
-#endif
-	clocksource_of_init();
-}
-
 static const struct of_device_id irq_of_match[] __initconst = {
 
 	{ .compatible = "atmel,sama5d3-aic", .data = at91_aic5_of_init },
@@ -81,7 +72,6 @@ static const char *sama5_dt_board_compat[] __initdata = {
 
 DT_MACHINE_START(sama5_dt, "Atmel SAMA5 (Device Tree)")
 	/* Maintainer: Atmel */
-	.init_time	= sama5_dt_timer_init,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic5_handle_irq,
 	.init_early	= at91_dt_initialize,
-- 
2.0.0


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

* [PATCH 06/13] AT91: PIT: Use consistent exit path in probe
  2014-06-25 13:06 [PATCH 00/13] AT91: PIT: Cleanups and move to drivers/clocksource Maxime Ripard
                   ` (4 preceding siblings ...)
  2014-06-25 13:06 ` [PATCH 05/13] AT91: dt: Remove init_time definitions Maxime Ripard
@ 2014-06-25 13:06 ` Maxime Ripard
  2014-06-25 13:06 ` [PATCH 07/13] AT91: PIT: Use pr_fmt Maxime Ripard
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Maxime Ripard @ 2014-06-25 13:06 UTC (permalink / raw)
  To: linux, Nicolas Ferre, Jean-Christophe Plagniol-Villard, Daniel Lezcano
  Cc: Boris Brezillon, Alexandre Belloni, Thomas Petazzoni,
	linux-arm-kernel, linux-kernel, Maxime Ripard

The current probe code is, whenever it fails to retrieve a resource, either
panicing, silently returning, or returning and displaying an error.

Make the code consistent by always panicing whenever it fails to grab any
resource.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 arch/arm/mach-at91/at91sam926x_time.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c
index e953197e5a5c..c2262988f638 100644
--- a/arch/arm/mach-at91/at91sam926x_time.c
+++ b/arch/arm/mach-at91/at91sam926x_time.c
@@ -208,7 +208,7 @@ static void __init at91sam926x_pit_common_init(void)
 	/* Set up irq handler */
 	ret = setup_irq(at91sam926x_pit_irq.irq, &at91sam926x_pit_irq);
 	if (ret)
-		pr_crit("AT91: PIT: Unable to setup IRQ\n");
+		panic("AT91: PIT: Unable to setup IRQ\n");
 
 	/* Set up and register clockevents */
 	pit_clkevt.mult = div_sc(pit_rate, NSEC_PER_SEC, pit_clkevt.shift);
@@ -222,7 +222,7 @@ static void __init at91sam926x_pit_dt_init(struct device_node *node)
 
 	pit_base_addr = of_iomap(node, 0);
 	if (!pit_base_addr)
-		return;
+		panic("AT91: PIT: Could not map PIT address\n");
 
 	mck = of_clk_get(node, 0);
 	if (IS_ERR(mck))
@@ -234,18 +234,12 @@ static void __init at91sam926x_pit_dt_init(struct device_node *node)
 
 	/* Get the interrupts property */
 	irq = irq_of_parse_and_map(node, 0);
-	if (!irq) {
-		pr_crit("AT91: PIT: Unable to get IRQ from DT\n");
-		goto clk_err;
-	}
+	if (!irq)
+		panic("AT91: PIT: Unable to get IRQ from DT\n");
 
 	at91sam926x_pit_irq.irq = irq;
 
 	at91sam926x_pit_common_init();
-
-clk_err:
-	clk_put(mck);
-	iounmap(pit_base_addr);
 }
 CLOCKSOURCE_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit",
 		       at91sam926x_pit_dt_init);
@@ -256,7 +250,7 @@ void __init at91sam926x_pit_init(void)
 	if (IS_ERR(mck))
 		panic("AT91: PIT: Unable to get mck clk\n");
 
-	at91sam926x_pit_irq.irq = NR_IRQS_LEGACY + AT91_ID_SYS,
+	at91sam926x_pit_irq.irq = NR_IRQS_LEGACY + AT91_ID_SYS;
 
 	at91sam926x_pit_common_init();
 }
-- 
2.0.0


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

* [PATCH 07/13] AT91: PIT: Use pr_fmt
  2014-06-25 13:06 [PATCH 00/13] AT91: PIT: Cleanups and move to drivers/clocksource Maxime Ripard
                   ` (5 preceding siblings ...)
  2014-06-25 13:06 ` [PATCH 06/13] AT91: PIT: Use consistent exit path in probe Maxime Ripard
@ 2014-06-25 13:06 ` Maxime Ripard
  2014-06-25 13:06 ` [PATCH 08/13] AT91: PIT: use request_irq instead of setup_irq Maxime Ripard
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Maxime Ripard @ 2014-06-25 13:06 UTC (permalink / raw)
  To: linux, Nicolas Ferre, Jean-Christophe Plagniol-Villard, Daniel Lezcano
  Cc: Boris Brezillon, Alexandre Belloni, Thomas Petazzoni,
	linux-arm-kernel, linux-kernel, Maxime Ripard

All the panic messages hardcode the same prefix. Define the pr_fmt macro to
unify its definition.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 arch/arm/mach-at91/at91sam926x_time.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c
index c2262988f638..5423894bb0fc 100644
--- a/arch/arm/mach-at91/at91sam926x_time.c
+++ b/arch/arm/mach-at91/at91sam926x_time.c
@@ -10,6 +10,8 @@
  * published by the Free Software Foundation.
  */
 
+#define pr_fmt(fmt)	"AT91: PIT: " fmt
+
 #include <linux/clk.h>
 #include <linux/clockchips.h>
 #include <linux/interrupt.h>
@@ -208,7 +210,7 @@ static void __init at91sam926x_pit_common_init(void)
 	/* Set up irq handler */
 	ret = setup_irq(at91sam926x_pit_irq.irq, &at91sam926x_pit_irq);
 	if (ret)
-		panic("AT91: PIT: Unable to setup IRQ\n");
+		panic(pr_fmt("Unable to setup IRQ\n"));
 
 	/* Set up and register clockevents */
 	pit_clkevt.mult = div_sc(pit_rate, NSEC_PER_SEC, pit_clkevt.shift);
@@ -222,7 +224,7 @@ static void __init at91sam926x_pit_dt_init(struct device_node *node)
 
 	pit_base_addr = of_iomap(node, 0);
 	if (!pit_base_addr)
-		panic("AT91: PIT: Could not map PIT address\n");
+		panic(pr_fmt("Could not map PIT address\n"));
 
 	mck = of_clk_get(node, 0);
 	if (IS_ERR(mck))
@@ -230,12 +232,12 @@ static void __init at91sam926x_pit_dt_init(struct device_node *node)
 		mck = clk_get(NULL, "mck");
 
 	if (IS_ERR(mck))
-		panic("AT91: PIT: Unable to get mck clk\n");
+		panic(pr_fmt("Unable to get mck clk\n"));
 
 	/* Get the interrupts property */
 	irq = irq_of_parse_and_map(node, 0);
 	if (!irq)
-		panic("AT91: PIT: Unable to get IRQ from DT\n");
+		panic(pr_fmt("Unable to get IRQ from DT\n"));
 
 	at91sam926x_pit_irq.irq = irq;
 
@@ -248,7 +250,7 @@ void __init at91sam926x_pit_init(void)
 {
 	mck = clk_get(NULL, "mck");
 	if (IS_ERR(mck))
-		panic("AT91: PIT: Unable to get mck clk\n");
+		panic(pr_fmt("Unable to get mck clk\n"));
 
 	at91sam926x_pit_irq.irq = NR_IRQS_LEGACY + AT91_ID_SYS;
 
@@ -263,5 +265,5 @@ void __init at91sam926x_ioremap_pit(u32 addr)
 	pit_base_addr = ioremap(addr, 16);
 
 	if (!pit_base_addr)
-		panic("Impossible to ioremap PIT\n");
+		panic(pr_fmt("Impossible to ioremap PIT\n"));
 }
-- 
2.0.0


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

* [PATCH 08/13] AT91: PIT: use request_irq instead of setup_irq
  2014-06-25 13:06 [PATCH 00/13] AT91: PIT: Cleanups and move to drivers/clocksource Maxime Ripard
                   ` (6 preceding siblings ...)
  2014-06-25 13:06 ` [PATCH 07/13] AT91: PIT: Use pr_fmt Maxime Ripard
@ 2014-06-25 13:06 ` Maxime Ripard
  2014-06-25 13:06 ` [PATCH 09/13] AT91: PIT: (Almost) remove the global variables Maxime Ripard
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Maxime Ripard @ 2014-06-25 13:06 UTC (permalink / raw)
  To: linux, Nicolas Ferre, Jean-Christophe Plagniol-Villard, Daniel Lezcano
  Cc: Boris Brezillon, Alexandre Belloni, Thomas Petazzoni,
	linux-arm-kernel, linux-kernel, Maxime Ripard

We can use the generic request_irq now to register a timer interrupt handler,
instead of the more complex setup_irq.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 arch/arm/mach-at91/at91sam926x_time.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c
index 5423894bb0fc..9678ac391a81 100644
--- a/arch/arm/mach-at91/at91sam926x_time.c
+++ b/arch/arm/mach-at91/at91sam926x_time.c
@@ -173,16 +173,10 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
 	return IRQ_NONE;
 }
 
-static struct irqaction at91sam926x_pit_irq = {
-	.name		= "at91_tick",
-	.flags		= IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
-	.handler	= at91sam926x_pit_interrupt,
-};
-
 /*
  * Set up both clocksource and clockevent support.
  */
-static void __init at91sam926x_pit_common_init(void)
+static void __init at91sam926x_pit_common_init(unsigned int pit_irq)
 {
 	unsigned long	pit_rate;
 	unsigned	bits;
@@ -208,7 +202,9 @@ static void __init at91sam926x_pit_common_init(void)
 	clocksource_register_hz(&pit_clk, pit_rate);
 
 	/* Set up irq handler */
-	ret = setup_irq(at91sam926x_pit_irq.irq, &at91sam926x_pit_irq);
+	ret = request_irq(pit_irq, at91sam926x_pit_interrupt,
+			  IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
+			  "at91_tick", pit_base_addr);
 	if (ret)
 		panic(pr_fmt("Unable to setup IRQ\n"));
 
@@ -239,9 +235,7 @@ static void __init at91sam926x_pit_dt_init(struct device_node *node)
 	if (!irq)
 		panic(pr_fmt("Unable to get IRQ from DT\n"));
 
-	at91sam926x_pit_irq.irq = irq;
-
-	at91sam926x_pit_common_init();
+	at91sam926x_pit_common_init(irq);
 }
 CLOCKSOURCE_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit",
 		       at91sam926x_pit_dt_init);
@@ -252,9 +246,7 @@ void __init at91sam926x_pit_init(void)
 	if (IS_ERR(mck))
 		panic(pr_fmt("Unable to get mck clk\n"));
 
-	at91sam926x_pit_irq.irq = NR_IRQS_LEGACY + AT91_ID_SYS;
-
-	at91sam926x_pit_common_init();
+	at91sam926x_pit_common_init(NR_IRQS_LEGACY + AT91_ID_SYS);
 }
 
 void __init at91sam926x_ioremap_pit(u32 addr)
-- 
2.0.0


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

* [PATCH 09/13] AT91: PIT: (Almost) remove the global variables
  2014-06-25 13:06 [PATCH 00/13] AT91: PIT: Cleanups and move to drivers/clocksource Maxime Ripard
                   ` (7 preceding siblings ...)
  2014-06-25 13:06 ` [PATCH 08/13] AT91: PIT: use request_irq instead of setup_irq Maxime Ripard
@ 2014-06-25 13:06 ` Maxime Ripard
  2014-06-26  5:12   ` Boris BREZILLON
  2014-06-25 13:06 ` [PATCH 10/13] AT91: soc: Add init_time callback Maxime Ripard
                   ` (4 subsequent siblings)
  13 siblings, 1 reply; 21+ messages in thread
From: Maxime Ripard @ 2014-06-25 13:06 UTC (permalink / raw)
  To: linux, Nicolas Ferre, Jean-Christophe Plagniol-Villard, Daniel Lezcano
  Cc: Boris Brezillon, Alexandre Belloni, Thomas Petazzoni,
	linux-arm-kernel, linux-kernel, Maxime Ripard

The timer driver is using some global variables to define some variables it has
to use in most of its functions, like the base address.

Use some container_of calls to have a single dynamic (and local) variable to
hold this content.

The only exception is in the !DT case, where the call chain to
at91sam926x_ioremap_pit and then at91sam926x_pit_init as init_time makes it
hard for the moment to pass the physical address of the timer.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 arch/arm/mach-at91/at91sam926x_time.c | 179 ++++++++++++++++++++--------------
 1 file changed, 108 insertions(+), 71 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c
index 9678ac391a81..f2c463567beb 100644
--- a/arch/arm/mach-at91/at91sam926x_time.c
+++ b/arch/arm/mach-at91/at91sam926x_time.c
@@ -20,6 +20,7 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
+#include <linux/slab.h>
 
 #include <mach/hardware.h>
 
@@ -39,19 +40,35 @@
 #define PIT_CPIV(x)	((x) & AT91_PIT_CPIV)
 #define PIT_PICNT(x)	(((x) & AT91_PIT_PICNT) >> 20)
 
-static u32 pit_cycle;		/* write-once */
-static u32 pit_cnt;		/* access only w/system irq blocked */
-static void __iomem *pit_base_addr __read_mostly;
-static struct clk *mck;
+struct pit_data {
+	struct clock_event_device	clkevt;
+	struct clocksource		clksrc;
 
-static inline unsigned int pit_read(unsigned int reg_offset)
+	void __iomem	*base;
+	u32		cycle;
+	u32		cnt;
+	unsigned int	irq;
+	struct clk	*mck;
+};
+
+static inline struct pit_data *clksrc_to_pit_data(struct clocksource *clksrc)
 {
-	return __raw_readl(pit_base_addr + reg_offset);
+	return container_of(clksrc, struct pit_data, clksrc);
 }
 
-static inline void pit_write(unsigned int reg_offset, unsigned long value)
+static inline struct pit_data *clkevt_to_pit_data(struct clock_event_device *clkevt)
 {
-	__raw_writel(value, pit_base_addr + reg_offset);
+	return container_of(clkevt, struct pit_data, clkevt);
+}
+
+static inline unsigned int pit_read(void __iomem *base, unsigned int reg_offset)
+{
+	return __raw_readl(base + reg_offset);
+}
+
+static inline void pit_write(void __iomem *base, unsigned int reg_offset, unsigned long value)
+{
+	__raw_writel(value, base + reg_offset);
 }
 
 /*
@@ -60,40 +77,35 @@ static inline void pit_write(unsigned int reg_offset, unsigned long value)
  */
 static cycle_t read_pit_clk(struct clocksource *cs)
 {
+	struct pit_data *data = clksrc_to_pit_data(cs);
 	unsigned long flags;
 	u32 elapsed;
 	u32 t;
 
 	raw_local_irq_save(flags);
-	elapsed = pit_cnt;
-	t = pit_read(AT91_PIT_PIIR);
+	elapsed = data->cnt;
+	t = pit_read(data->base, AT91_PIT_PIIR);
 	raw_local_irq_restore(flags);
 
-	elapsed += PIT_PICNT(t) * pit_cycle;
+	elapsed += PIT_PICNT(t) * data->cycle;
 	elapsed += PIT_CPIV(t);
 	return elapsed;
 }
 
-static struct clocksource pit_clk = {
-	.name		= "pit",
-	.rating		= 175,
-	.read		= read_pit_clk,
-	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
-};
-
-
 /*
  * Clockevent device:  interrupts every 1/HZ (== pit_cycles * MCK/16)
  */
 static void
 pit_clkevt_mode(enum clock_event_mode mode, struct clock_event_device *dev)
 {
+	struct pit_data *data = clkevt_to_pit_data(dev);
+
 	switch (mode) {
 	case CLOCK_EVT_MODE_PERIODIC:
 		/* update clocksource counter */
-		pit_cnt += pit_cycle * PIT_PICNT(pit_read(AT91_PIT_PIVR));
-		pit_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN
-				| AT91_PIT_PITIEN);
+		data->cnt += data->cycle * PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR));
+		pit_write(data->base, AT91_PIT_MR,
+			  (data->cycle - 1) | AT91_PIT_PITEN | AT91_PIT_PITIEN);
 		break;
 	case CLOCK_EVT_MODE_ONESHOT:
 		BUG();
@@ -101,7 +113,8 @@ pit_clkevt_mode(enum clock_event_mode mode, struct clock_event_device *dev)
 	case CLOCK_EVT_MODE_SHUTDOWN:
 	case CLOCK_EVT_MODE_UNUSED:
 		/* disable irq, leaving the clocksource active */
-		pit_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN);
+		pit_write(data->base, AT91_PIT_MR,
+			  (data->cycle - 1) | AT91_PIT_PITEN);
 		break;
 	case CLOCK_EVT_MODE_RESUME:
 		break;
@@ -110,44 +123,40 @@ pit_clkevt_mode(enum clock_event_mode mode, struct clock_event_device *dev)
 
 static void at91sam926x_pit_suspend(struct clock_event_device *cedev)
 {
+	struct pit_data *data = clkevt_to_pit_data(cedev);
+
 	/* Disable timer */
-	pit_write(AT91_PIT_MR, 0);
+	pit_write(data->base, AT91_PIT_MR, 0);
 }
 
-static void at91sam926x_pit_reset(void)
+static void at91sam926x_pit_reset(struct pit_data *data)
 {
 	/* Disable timer and irqs */
-	pit_write(AT91_PIT_MR, 0);
+	pit_write(data->base, AT91_PIT_MR, 0);
 
 	/* Clear any pending interrupts, wait for PIT to stop counting */
-	while (PIT_CPIV(pit_read(AT91_PIT_PIVR)) != 0)
+	while (PIT_CPIV(pit_read(data->base, AT91_PIT_PIVR)) != 0)
 		cpu_relax();
 
 	/* Start PIT but don't enable IRQ */
-	pit_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN);
+	pit_write(data->base, AT91_PIT_MR,
+		  (data->cycle - 1) | AT91_PIT_PITEN);
 }
 
 static void at91sam926x_pit_resume(struct clock_event_device *cedev)
 {
-	at91sam926x_pit_reset();
-}
-
-static struct clock_event_device pit_clkevt = {
-	.name		= "pit",
-	.features	= CLOCK_EVT_FEAT_PERIODIC,
-	.shift		= 32,
-	.rating		= 100,
-	.set_mode	= pit_clkevt_mode,
-	.suspend	= at91sam926x_pit_suspend,
-	.resume		= at91sam926x_pit_resume,
-};
+	struct pit_data *data = clkevt_to_pit_data(cedev);
 
+	at91sam926x_pit_reset(data);
+}
 
 /*
  * IRQ handler for the timer.
  */
 static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
 {
+	struct pit_data *data = dev_id;
+
 	/*
 	 * irqs should be disabled here, but as the irq is shared they are only
 	 * guaranteed to be off if the timer irq is registered first.
@@ -155,15 +164,15 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
 	WARN_ON_ONCE(!irqs_disabled());
 
 	/* The PIT interrupt may be disabled, and is shared */
-	if ((pit_clkevt.mode == CLOCK_EVT_MODE_PERIODIC)
-			&& (pit_read(AT91_PIT_SR) & AT91_PIT_PITS)) {
+	if ((data->clkevt.mode == CLOCK_EVT_MODE_PERIODIC) &&
+	    (pit_read(data->base, AT91_PIT_SR) & AT91_PIT_PITS)) {
 		unsigned nr_ticks;
 
 		/* Get number of ticks performed before irq, and ack it */
-		nr_ticks = PIT_PICNT(pit_read(AT91_PIT_PIVR));
+		nr_ticks = PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR));
 		do {
-			pit_cnt += pit_cycle;
-			pit_clkevt.event_handler(&pit_clkevt);
+			data->cnt += data->cycle;
+			data->clkevt.event_handler(&data->clkevt);
 			nr_ticks--;
 		} while (nr_ticks);
 
@@ -176,7 +185,7 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
 /*
  * Set up both clocksource and clockevent support.
  */
-static void __init at91sam926x_pit_common_init(unsigned int pit_irq)
+static void __init at91sam926x_pit_common_init(struct pit_data *data)
 {
 	unsigned long	pit_rate;
 	unsigned	bits;
@@ -186,67 +195,95 @@ static void __init at91sam926x_pit_common_init(unsigned int pit_irq)
 	 * Use our actual MCK to figure out how many MCK/16 ticks per
 	 * 1/HZ period (instead of a compile-time constant LATCH).
 	 */
-	pit_rate = clk_get_rate(mck) / 16;
-	pit_cycle = (pit_rate + HZ/2) / HZ;
-	WARN_ON(((pit_cycle - 1) & ~AT91_PIT_PIV) != 0);
+	pit_rate = clk_get_rate(data->mck) / 16;
+	data->cycle = (pit_rate + HZ/2) / HZ;
+	WARN_ON(((data->cycle - 1) & ~AT91_PIT_PIV) != 0);
 
 	/* Initialize and enable the timer */
-	at91sam926x_pit_reset();
+	at91sam926x_pit_reset(data);
 
 	/*
 	 * Register clocksource.  The high order bits of PIV are unused,
 	 * so this isn't a 32-bit counter unless we get clockevent irqs.
 	 */
-	bits = 12 /* PICNT */ + ilog2(pit_cycle) /* PIV */;
-	pit_clk.mask = CLOCKSOURCE_MASK(bits);
-	clocksource_register_hz(&pit_clk, pit_rate);
+	bits = 12 /* PICNT */ + ilog2(data->cycle) /* PIV */;
+	data->clksrc.mask = CLOCKSOURCE_MASK(bits);
+	data->clksrc.name = "pit";
+	data->clksrc.rating = 175;
+	data->clksrc.read = read_pit_clk,
+	data->clksrc.flags = CLOCK_SOURCE_IS_CONTINUOUS,
+	clocksource_register_hz(&data->clksrc, pit_rate);
 
 	/* Set up irq handler */
-	ret = request_irq(pit_irq, at91sam926x_pit_interrupt,
+	ret = request_irq(data->irq, at91sam926x_pit_interrupt,
 			  IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
-			  "at91_tick", pit_base_addr);
+			  "at91_tick", data);
 	if (ret)
 		panic(pr_fmt("Unable to setup IRQ\n"));
 
 	/* Set up and register clockevents */
-	pit_clkevt.mult = div_sc(pit_rate, NSEC_PER_SEC, pit_clkevt.shift);
-	pit_clkevt.cpumask = cpumask_of(0);
-	clockevents_register_device(&pit_clkevt);
+	data->clkevt.name = "pit";
+	data->clkevt.features = CLOCK_EVT_FEAT_PERIODIC;
+	data->clkevt.shift = 32;
+	data->clkevt.mult = div_sc(pit_rate, NSEC_PER_SEC, data->clkevt.shift);
+	data->clkevt.rating = 100;
+	data->clkevt.cpumask = cpumask_of(0);
+
+	data->clkevt.set_mode = pit_clkevt_mode;
+	data->clkevt.resume = at91sam926x_pit_resume;
+	data->clkevt.suspend = at91sam926x_pit_suspend;
+	clockevents_register_device(&data->clkevt);
 }
 
 static void __init at91sam926x_pit_dt_init(struct device_node *node)
 {
-	unsigned int irq;
+	struct pit_data *data;
 
-	pit_base_addr = of_iomap(node, 0);
-	if (!pit_base_addr)
+	data = kzalloc(sizeof(*data), GFP_KERNEL);
+	if (!data)
+		panic(pr_fmt("Unable to allocate memory\n"));
+
+	data->base = of_iomap(node, 0);
+	if (!data->base)
 		panic(pr_fmt("Could not map PIT address\n"));
 
-	mck = of_clk_get(node, 0);
-	if (IS_ERR(mck))
+	data->mck = of_clk_get(node, 0);
+	if (IS_ERR(data->mck))
 		/* Fallback on clkdev for !CCF-based boards */
-		mck = clk_get(NULL, "mck");
+		data->mck = clk_get(NULL, "mck");
 
-	if (IS_ERR(mck))
+	if (IS_ERR(data->mck))
 		panic(pr_fmt("Unable to get mck clk\n"));
 
 	/* Get the interrupts property */
-	irq = irq_of_parse_and_map(node, 0);
-	if (!irq)
+	data->irq = irq_of_parse_and_map(node, 0);
+	if (!data->irq)
 		panic(pr_fmt("Unable to get IRQ from DT\n"));
 
-	at91sam926x_pit_common_init(irq);
+	at91sam926x_pit_common_init(data);
 }
 CLOCKSOURCE_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit",
 		       at91sam926x_pit_dt_init);
 
+static void __iomem *pit_base_addr;
+
 void __init at91sam926x_pit_init(void)
 {
-	mck = clk_get(NULL, "mck");
-	if (IS_ERR(mck))
+	struct pit_data *data;
+
+	data = kzalloc(sizeof(*data), GFP_KERNEL);
+	if (!data)
+		panic(pr_fmt("Unable to allocate memory\n"));
+
+	data->base = pit_base_addr;
+
+	data->mck = clk_get(NULL, "mck");
+	if (IS_ERR(data->mck))
 		panic(pr_fmt("Unable to get mck clk\n"));
 
-	at91sam926x_pit_common_init(NR_IRQS_LEGACY + AT91_ID_SYS);
+	data->irq = NR_IRQS_LEGACY + AT91_ID_SYS;
+
+	at91sam926x_pit_common_init(data);
 }
 
 void __init at91sam926x_ioremap_pit(u32 addr)
-- 
2.0.0


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

* [PATCH 10/13] AT91: soc: Add init_time callback
  2014-06-25 13:06 [PATCH 00/13] AT91: PIT: Cleanups and move to drivers/clocksource Maxime Ripard
                   ` (8 preceding siblings ...)
  2014-06-25 13:06 ` [PATCH 09/13] AT91: PIT: (Almost) remove the global variables Maxime Ripard
@ 2014-06-25 13:06 ` Maxime Ripard
  2014-06-25 13:06 ` [PATCH 11/13] AT91: Convert the boards to the " Maxime Ripard
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Maxime Ripard @ 2014-06-25 13:06 UTC (permalink / raw)
  To: linux, Nicolas Ferre, Jean-Christophe Plagniol-Villard, Daniel Lezcano
  Cc: Boris Brezillon, Alexandre Belloni, Thomas Petazzoni,
	linux-arm-kernel, linux-kernel, Maxime Ripard

Introduce an init_time callback to the at91_init_soc structure to be able to
tweak the init_time machine callback on a per-soc basis, instead of having to
rely on a global one.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 arch/arm/mach-at91/generic.h | 1 +
 arch/arm/mach-at91/setup.c   | 5 +++++
 arch/arm/mach-at91/soc.h     | 1 +
 3 files changed, 7 insertions(+)

diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index 77d4daeee66a..eb5512c3d717 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -42,6 +42,7 @@ extern void __init at91_sysirq_mask_rtt(u32 rtt_base);
 
 
  /* Timer */
+extern void __init at91_init_time(void);
 extern void at91rm9200_ioremap_st(u32 addr);
 extern void at91rm9200_timer_init(void);
 extern void at91sam926x_ioremap_pit(u32 addr);
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index f7a07a58ebb6..f8bd8d2c8205 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -533,3 +533,8 @@ void __init at91_initialize(unsigned long main_clock)
 
 	pinctrl_provide_dummies();
 }
+
+void __init at91_init_time(void)
+{
+	at91_boot_soc.init_time();
+}
diff --git a/arch/arm/mach-at91/soc.h b/arch/arm/mach-at91/soc.h
index a1e1482c6da8..57b9dda6eb83 100644
--- a/arch/arm/mach-at91/soc.h
+++ b/arch/arm/mach-at91/soc.h
@@ -12,6 +12,7 @@ struct at91_init_soc {
 	void (*ioremap_registers)(void);
 	void (*register_clocks)(void);
 	void (*init)(void);
+	void (*init_time)(void);
 };
 
 extern struct at91_init_soc at91_boot_soc;
-- 
2.0.0


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

* [PATCH 11/13] AT91: Convert the boards to the init_time callback
  2014-06-25 13:06 [PATCH 00/13] AT91: PIT: Cleanups and move to drivers/clocksource Maxime Ripard
                   ` (9 preceding siblings ...)
  2014-06-25 13:06 ` [PATCH 10/13] AT91: soc: Add init_time callback Maxime Ripard
@ 2014-06-25 13:06 ` Maxime Ripard
  2014-06-25 13:06 ` [PATCH 12/13] AT91: PIT: Convert to an early_platform_device Maxime Ripard
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Maxime Ripard @ 2014-06-25 13:06 UTC (permalink / raw)
  To: linux, Nicolas Ferre, Jean-Christophe Plagniol-Villard, Daniel Lezcano
  Cc: Boris Brezillon, Alexandre Belloni, Thomas Petazzoni,
	linux-arm-kernel, linux-kernel, Maxime Ripard

Now that we have the init_time callback in the at91_init_soc structure, convert
all the boards and SoC to this.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 arch/arm/mach-at91/at91sam9260.c        | 6 ++++++
 arch/arm/mach-at91/at91sam9261.c        | 6 ++++++
 arch/arm/mach-at91/at91sam9263.c        | 6 ++++++
 arch/arm/mach-at91/at91sam9g45.c        | 6 ++++++
 arch/arm/mach-at91/at91sam9rl.c         | 6 ++++++
 arch/arm/mach-at91/board-afeb-9260v1.c  | 2 +-
 arch/arm/mach-at91/board-cam60.c        | 2 +-
 arch/arm/mach-at91/board-cpu9krea.c     | 2 +-
 arch/arm/mach-at91/board-flexibity.c    | 2 +-
 arch/arm/mach-at91/board-foxg20.c       | 2 +-
 arch/arm/mach-at91/board-gsia18s.c      | 2 +-
 arch/arm/mach-at91/board-pcontrol-g20.c | 2 +-
 arch/arm/mach-at91/board-sam9-l9260.c   | 2 +-
 arch/arm/mach-at91/board-sam9260ek.c    | 2 +-
 arch/arm/mach-at91/board-sam9261ek.c    | 4 ++--
 arch/arm/mach-at91/board-sam9263ek.c    | 2 +-
 arch/arm/mach-at91/board-sam9g20ek.c    | 4 ++--
 arch/arm/mach-at91/board-sam9m10g45ek.c | 2 +-
 arch/arm/mach-at91/board-sam9rlek.c     | 2 +-
 arch/arm/mach-at91/board-snapper9260.c  | 2 +-
 arch/arm/mach-at91/board-stamp9g20.c    | 4 ++--
 21 files changed, 49 insertions(+), 19 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index c3d22be73b7c..d5141af1947c 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -400,6 +400,11 @@ static unsigned int at91sam9260_default_irq_priority[NR_AIC_IRQS] __initdata = {
 	0,	/* Advanced Interrupt Controller */
 };
 
+static void __init at91sam9260_init_time(void)
+{
+	at91sam926x_pit_init();
+}
+
 AT91_SOC_START(at91sam9260)
 	.map_io = at91sam9260_map_io,
 	.default_irq_priority = at91sam9260_default_irq_priority,
@@ -408,4 +413,5 @@ AT91_SOC_START(at91sam9260)
 	.ioremap_registers = at91sam9260_ioremap_registers,
 	.register_clocks = at91sam9260_register_clocks,
 	.init = at91sam9260_initialize,
+	.init_time = at91sam9260_init_time,
 AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index fb164a5d04a9..5416fe4d5a0b 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -363,6 +363,11 @@ static unsigned int at91sam9261_default_irq_priority[NR_AIC_IRQS] __initdata = {
 	0,	/* Advanced Interrupt Controller */
 };
 
+static void __init at91sam9261_init_time(void)
+{
+	at91sam926x_pit_init();
+}
+
 AT91_SOC_START(at91sam9261)
 	.map_io = at91sam9261_map_io,
 	.default_irq_priority = at91sam9261_default_irq_priority,
@@ -371,4 +376,5 @@ AT91_SOC_START(at91sam9261)
 	.ioremap_registers = at91sam9261_ioremap_registers,
 	.register_clocks = at91sam9261_register_clocks,
 	.init = at91sam9261_initialize,
+	.init_time = at91sam9261_init_time,
 AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index f30290572293..20b46118338c 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -381,6 +381,11 @@ static unsigned int at91sam9263_default_irq_priority[NR_AIC_IRQS] __initdata = {
 	0,	/* Advanced Interrupt Controller (IRQ1) */
 };
 
+static void __init at91sam9263_init_time(void)
+{
+	at91sam926x_pit_init();
+}
+
 AT91_SOC_START(at91sam9263)
 	.map_io = at91sam9263_map_io,
 	.default_irq_priority = at91sam9263_default_irq_priority,
@@ -388,4 +393,5 @@ AT91_SOC_START(at91sam9263)
 	.ioremap_registers = at91sam9263_ioremap_registers,
 	.register_clocks = at91sam9263_register_clocks,
 	.init = at91sam9263_initialize,
+	.init_time = at91sam9263_init_time,
 AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index 9d3d544ac19c..924d362121ef 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -430,6 +430,11 @@ static unsigned int at91sam9g45_default_irq_priority[NR_AIC_IRQS] __initdata = {
 	0,	/* Advanced Interrupt Controller (IRQ0) */
 };
 
+static void __init at91sam9g45_init_time(void)
+{
+	at91sam926x_pit_init();
+}
+
 AT91_SOC_START(at91sam9g45)
 	.map_io = at91sam9g45_map_io,
 	.default_irq_priority = at91sam9g45_default_irq_priority,
@@ -437,4 +442,5 @@ AT91_SOC_START(at91sam9g45)
 	.ioremap_registers = at91sam9g45_ioremap_registers,
 	.register_clocks = at91sam9g45_register_clocks,
 	.init = at91sam9g45_initialize,
+	.init_time = at91sam9g45_init_time,
 AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
index a79960f57e6a..dd4a8deb5b36 100644
--- a/arch/arm/mach-at91/at91sam9rl.c
+++ b/arch/arm/mach-at91/at91sam9rl.c
@@ -373,6 +373,11 @@ static unsigned int at91sam9rl_default_irq_priority[NR_AIC_IRQS] __initdata = {
 	0,	/* Advanced Interrupt Controller */
 };
 
+static void __init at91sam9rl_init_time(void)
+{
+	at91sam926x_pit_init();
+}
+
 AT91_SOC_START(at91sam9rl)
 	.map_io = at91sam9rl_map_io,
 	.default_irq_priority = at91sam9rl_default_irq_priority,
@@ -382,4 +387,5 @@ AT91_SOC_START(at91sam9rl)
 	.register_clocks = at91sam9rl_register_clocks,
 #endif
 	.init = at91sam9rl_initialize,
+	.init_time = at91sam9rl_init_time,
 AT91_SOC_END
diff --git a/arch/arm/mach-at91/board-afeb-9260v1.c b/arch/arm/mach-at91/board-afeb-9260v1.c
index 597c649170aa..afadbcb8f45d 100644
--- a/arch/arm/mach-at91/board-afeb-9260v1.c
+++ b/arch/arm/mach-at91/board-afeb-9260v1.c
@@ -211,7 +211,7 @@ static void __init afeb9260_board_init(void)
 
 MACHINE_START(AFEB9260, "Custom afeb9260 board")
 	/* Maintainer: Sergey Lapin <slapin@ossfans.org> */
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= afeb9260_init_early,
diff --git a/arch/arm/mach-at91/board-cam60.c b/arch/arm/mach-at91/board-cam60.c
index a30502c8d379..731dcb368c3d 100644
--- a/arch/arm/mach-at91/board-cam60.c
+++ b/arch/arm/mach-at91/board-cam60.c
@@ -188,7 +188,7 @@ static void __init cam60_board_init(void)
 
 MACHINE_START(CAM60, "KwikByte CAM60")
 	/* Maintainer: KwikByte */
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= cam60_init_early,
diff --git a/arch/arm/mach-at91/board-cpu9krea.c b/arch/arm/mach-at91/board-cpu9krea.c
index 2037f78c84e7..1e4d221c4a74 100644
--- a/arch/arm/mach-at91/board-cpu9krea.c
+++ b/arch/arm/mach-at91/board-cpu9krea.c
@@ -375,7 +375,7 @@ MACHINE_START(CPUAT9260, "Eukrea CPU9260")
 MACHINE_START(CPUAT9G20, "Eukrea CPU9G20")
 #endif
 	/* Maintainer: Eric Benard - EUKREA Electromatique */
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= cpu9krea_init_early,
diff --git a/arch/arm/mach-at91/board-flexibity.c b/arch/arm/mach-at91/board-flexibity.c
index 68f1ab6bd08f..6f1ca9a02697 100644
--- a/arch/arm/mach-at91/board-flexibity.c
+++ b/arch/arm/mach-at91/board-flexibity.c
@@ -160,7 +160,7 @@ static void __init flexibity_board_init(void)
 
 MACHINE_START(FLEXIBITY, "Flexibity Connect")
 	/* Maintainer: Maxim Osipov */
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= flexibity_init_early,
diff --git a/arch/arm/mach-at91/board-foxg20.c b/arch/arm/mach-at91/board-foxg20.c
index 8b22c60bb238..ec290b6ed9d8 100644
--- a/arch/arm/mach-at91/board-foxg20.c
+++ b/arch/arm/mach-at91/board-foxg20.c
@@ -263,7 +263,7 @@ static void __init foxg20_board_init(void)
 
 MACHINE_START(ACMENETUSFOXG20, "Acme Systems srl FOX Board G20")
 	/* Maintainer: Sergio Tanzilli */
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= foxg20_init_early,
diff --git a/arch/arm/mach-at91/board-gsia18s.c b/arch/arm/mach-at91/board-gsia18s.c
index b729dd1271bf..bf5cc55c7db6 100644
--- a/arch/arm/mach-at91/board-gsia18s.c
+++ b/arch/arm/mach-at91/board-gsia18s.c
@@ -576,7 +576,7 @@ static void __init gsia18s_board_init(void)
 }
 
 MACHINE_START(GSIA18S, "GS_IA18_S")
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= gsia18s_init_early,
diff --git a/arch/arm/mach-at91/board-pcontrol-g20.c b/arch/arm/mach-at91/board-pcontrol-g20.c
index b48d95ec5152..9c26b94ce448 100644
--- a/arch/arm/mach-at91/board-pcontrol-g20.c
+++ b/arch/arm/mach-at91/board-pcontrol-g20.c
@@ -219,7 +219,7 @@ static void __init pcontrol_g20_board_init(void)
 
 MACHINE_START(PCONTROL_G20, "PControl G20")
 	/* Maintainer: pgsellmann@portner-elektronik.at */
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= pcontrol_g20_init_early,
diff --git a/arch/arm/mach-at91/board-sam9-l9260.c b/arch/arm/mach-at91/board-sam9-l9260.c
index d24dda67e2d3..2d6259c947e1 100644
--- a/arch/arm/mach-at91/board-sam9-l9260.c
+++ b/arch/arm/mach-at91/board-sam9-l9260.c
@@ -219,7 +219,7 @@ static void __init ek_board_init(void)
 
 MACHINE_START(SAM9_L9260, "Olimex SAM9-L9260")
 	/* Maintainer: Olimex */
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= ek_init_early,
diff --git a/arch/arm/mach-at91/board-sam9260ek.c b/arch/arm/mach-at91/board-sam9260ek.c
index 65dea12d685e..3c7e278999af 100644
--- a/arch/arm/mach-at91/board-sam9260ek.c
+++ b/arch/arm/mach-at91/board-sam9260ek.c
@@ -344,7 +344,7 @@ static void __init ek_board_init(void)
 
 MACHINE_START(AT91SAM9260EK, "Atmel AT91SAM9260-EK")
 	/* Maintainer: Atmel */
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= ek_init_early,
diff --git a/arch/arm/mach-at91/board-sam9261ek.c b/arch/arm/mach-at91/board-sam9261ek.c
index 4637432de08f..52c2863124c7 100644
--- a/arch/arm/mach-at91/board-sam9261ek.c
+++ b/arch/arm/mach-at91/board-sam9261ek.c
@@ -603,7 +603,7 @@ static void __init ek_board_init(void)
 
 MACHINE_START(AT91SAM9261EK, "Atmel AT91SAM9261-EK")
 	/* Maintainer: Atmel */
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= ek_init_early,
@@ -613,7 +613,7 @@ MACHINE_END
 
 MACHINE_START(AT91SAM9G10EK, "Atmel AT91SAM9G10-EK")
 	/* Maintainer: Atmel */
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= ek_init_early,
diff --git a/arch/arm/mach-at91/board-sam9263ek.c b/arch/arm/mach-at91/board-sam9263ek.c
index cd2726ee5add..4e2b6a60ce3e 100644
--- a/arch/arm/mach-at91/board-sam9263ek.c
+++ b/arch/arm/mach-at91/board-sam9263ek.c
@@ -444,7 +444,7 @@ static void __init ek_board_init(void)
 
 MACHINE_START(AT91SAM9263EK, "Atmel AT91SAM9263-EK")
 	/* Maintainer: Atmel */
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= ek_init_early,
diff --git a/arch/arm/mach-at91/board-sam9g20ek.c b/arch/arm/mach-at91/board-sam9g20ek.c
index e1be6e25b380..49f075213451 100644
--- a/arch/arm/mach-at91/board-sam9g20ek.c
+++ b/arch/arm/mach-at91/board-sam9g20ek.c
@@ -410,7 +410,7 @@ static void __init ek_board_init(void)
 
 MACHINE_START(AT91SAM9G20EK, "Atmel AT91SAM9G20-EK")
 	/* Maintainer: Atmel */
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= ek_init_early,
@@ -420,7 +420,7 @@ MACHINE_END
 
 MACHINE_START(AT91SAM9G20EK_2MMC, "Atmel AT91SAM9G20-EK 2 MMC Slot Mod")
 	/* Maintainer: Atmel */
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= ek_init_early,
diff --git a/arch/arm/mach-at91/board-sam9m10g45ek.c b/arch/arm/mach-at91/board-sam9m10g45ek.c
index 1ea61328f30d..d5ae482849b7 100644
--- a/arch/arm/mach-at91/board-sam9m10g45ek.c
+++ b/arch/arm/mach-at91/board-sam9m10g45ek.c
@@ -493,7 +493,7 @@ static void __init ek_board_init(void)
 
 MACHINE_START(AT91SAM9M10G45EK, "Atmel AT91SAM9M10G45-EK")
 	/* Maintainer: Atmel */
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= ek_init_early,
diff --git a/arch/arm/mach-at91/board-sam9rlek.c b/arch/arm/mach-at91/board-sam9rlek.c
index b64648b4a1fc..61e9c02ac798 100644
--- a/arch/arm/mach-at91/board-sam9rlek.c
+++ b/arch/arm/mach-at91/board-sam9rlek.c
@@ -323,7 +323,7 @@ static void __init ek_board_init(void)
 
 MACHINE_START(AT91SAM9RLEK, "Atmel AT91SAM9RL-EK")
 	/* Maintainer: Atmel */
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= ek_init_early,
diff --git a/arch/arm/mach-at91/board-snapper9260.c b/arch/arm/mach-at91/board-snapper9260.c
index 1b870e6def0c..8123cae14987 100644
--- a/arch/arm/mach-at91/board-snapper9260.c
+++ b/arch/arm/mach-at91/board-snapper9260.c
@@ -178,7 +178,7 @@ static void __init snapper9260_board_init(void)
 }
 
 MACHINE_START(SNAPPER_9260, "Bluewater Systems Snapper 9260/9G20 module")
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= snapper9260_init_early,
diff --git a/arch/arm/mach-at91/board-stamp9g20.c b/arch/arm/mach-at91/board-stamp9g20.c
index 3b575036ff96..e825641a1dee 100644
--- a/arch/arm/mach-at91/board-stamp9g20.c
+++ b/arch/arm/mach-at91/board-stamp9g20.c
@@ -275,7 +275,7 @@ static void __init stamp9g20evb_board_init(void)
 
 MACHINE_START(PORTUXG20, "taskit PortuxG20")
 	/* Maintainer: taskit GmbH */
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= stamp9g20_init_early,
@@ -285,7 +285,7 @@ MACHINE_END
 
 MACHINE_START(STAMP9G20, "taskit Stamp9G20")
 	/* Maintainer: taskit GmbH */
-	.init_time	= at91sam926x_pit_init,
+	.init_time	= at91_init_time,
 	.map_io		= at91_map_io,
 	.handle_irq	= at91_aic_handle_irq,
 	.init_early	= stamp9g20_init_early,
-- 
2.0.0


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

* [PATCH 12/13] AT91: PIT: Convert to an early_platform_device
  2014-06-25 13:06 [PATCH 00/13] AT91: PIT: Cleanups and move to drivers/clocksource Maxime Ripard
                   ` (10 preceding siblings ...)
  2014-06-25 13:06 ` [PATCH 11/13] AT91: Convert the boards to the " Maxime Ripard
@ 2014-06-25 13:06 ` Maxime Ripard
  2014-06-25 13:06 ` [PATCH 13/13] AT91: PIT: Move the driver to drivers/clocksource Maxime Ripard
  2014-06-26  5:30 ` [PATCH 00/13] AT91: PIT: Cleanups and move " Boris BREZILLON
  13 siblings, 0 replies; 21+ messages in thread
From: Maxime Ripard @ 2014-06-25 13:06 UTC (permalink / raw)
  To: linux, Nicolas Ferre, Jean-Christophe Plagniol-Villard, Daniel Lezcano
  Cc: Boris Brezillon, Alexandre Belloni, Thomas Petazzoni,
	linux-arm-kernel, linux-kernel, Maxime Ripard

Convert the legacy probing mechanism to the early_platform_driver probe.

This will allow a clear separation between the driver and the machine setup
code, which will in turn ease the move out of mach-at91.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 arch/arm/mach-at91/at91sam9260.c      | 30 ++++++++++++++++++++++++--
 arch/arm/mach-at91/at91sam9261.c      | 30 ++++++++++++++++++++++++--
 arch/arm/mach-at91/at91sam9263.c      | 30 ++++++++++++++++++++++++--
 arch/arm/mach-at91/at91sam926x_time.c | 40 ++++++++++++++++++++---------------
 arch/arm/mach-at91/at91sam9g45.c      | 31 +++++++++++++++++++++++++--
 arch/arm/mach-at91/at91sam9rl.c       | 30 ++++++++++++++++++++++++--
 arch/arm/mach-at91/generic.h          |  2 --
 7 files changed, 164 insertions(+), 29 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index d5141af1947c..a64ecaf905c0 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -341,7 +341,6 @@ static void __init at91sam9260_ioremap_registers(void)
 	at91_ioremap_shdwc(AT91SAM9260_BASE_SHDWC);
 	at91_ioremap_rstc(AT91SAM9260_BASE_RSTC);
 	at91_ioremap_ramc(0, AT91SAM9260_BASE_SDRAMC, 512);
-	at91sam926x_ioremap_pit(AT91SAM9260_BASE_PIT);
 	at91sam9_ioremap_smc(0, AT91SAM9260_BASE_SMC);
 	at91_ioremap_matrix(AT91SAM9260_BASE_MATRIX);
 	at91_pm_set_standby(at91sam9_sdram_standby);
@@ -400,9 +399,36 @@ static unsigned int at91sam9260_default_irq_priority[NR_AIC_IRQS] __initdata = {
 	0,	/* Advanced Interrupt Controller */
 };
 
+static struct resource pit_resources[] = {
+	[0] = {
+		.start	= AT91SAM9260_BASE_PIT,
+		.end	= AT91SAM9260_BASE_PIT + SZ_16 - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= NR_IRQS_LEGACY + AT91_ID_SYS,
+		.end	= NR_IRQS_LEGACY + AT91_ID_SYS,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device pit_device = {
+	.name		= "at91_pit",
+	.resource	= pit_resources,
+	.num_resources	= ARRAY_SIZE(pit_resources),
+};
+
+static struct platform_device *at91sam9260_early_devices[] __initdata = {
+	&pit_device,
+};
+
 static void __init at91sam9260_init_time(void)
 {
-	at91sam926x_pit_init();
+	early_platform_add_devices(at91sam9260_early_devices,
+				   ARRAY_SIZE(at91sam9260_early_devices));
+
+	early_platform_driver_register_all("earlytimer");
+	early_platform_driver_probe("earlytimer", 1, 0);
 }
 
 AT91_SOC_START(at91sam9260)
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index 5416fe4d5a0b..c8f85ace7f33 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -304,7 +304,6 @@ static void __init at91sam9261_ioremap_registers(void)
 	at91_ioremap_shdwc(AT91SAM9261_BASE_SHDWC);
 	at91_ioremap_rstc(AT91SAM9261_BASE_RSTC);
 	at91_ioremap_ramc(0, AT91SAM9261_BASE_SDRAMC, 512);
-	at91sam926x_ioremap_pit(AT91SAM9261_BASE_PIT);
 	at91sam9_ioremap_smc(0, AT91SAM9261_BASE_SMC);
 	at91_ioremap_matrix(AT91SAM9261_BASE_MATRIX);
 	at91_pm_set_standby(at91sam9_sdram_standby);
@@ -363,9 +362,36 @@ static unsigned int at91sam9261_default_irq_priority[NR_AIC_IRQS] __initdata = {
 	0,	/* Advanced Interrupt Controller */
 };
 
+static struct resource pit_resources[] = {
+	[0] = {
+		.start	= AT91SAM9261_BASE_PIT,
+		.end	= AT91SAM9261_BASE_PIT + SZ_16 - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= NR_IRQS_LEGACY + AT91_ID_SYS,
+		.end	= NR_IRQS_LEGACY + AT91_ID_SYS,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device pit_device = {
+	.name		= "at91_pit",
+	.resource	= pit_resources,
+	.num_resources	= ARRAY_SIZE(pit_resources),
+};
+
+static struct platform_device *at91sam9261_early_devices[] __initdata = {
+	&pit_device,
+};
+
 static void __init at91sam9261_init_time(void)
 {
-	at91sam926x_pit_init();
+	early_platform_add_devices(at91sam9261_early_devices,
+				   ARRAY_SIZE(at91sam9261_early_devices));
+
+	early_platform_driver_register_all("earlytimer");
+	early_platform_driver_probe("earlytimer", 1, 0);
 }
 
 AT91_SOC_START(at91sam9261)
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index 20b46118338c..b4bdfc20e0df 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -320,7 +320,6 @@ static void __init at91sam9263_ioremap_registers(void)
 	at91_ioremap_rstc(AT91SAM9263_BASE_RSTC);
 	at91_ioremap_ramc(0, AT91SAM9263_BASE_SDRAMC0, 512);
 	at91_ioremap_ramc(1, AT91SAM9263_BASE_SDRAMC1, 512);
-	at91sam926x_ioremap_pit(AT91SAM9263_BASE_PIT);
 	at91sam9_ioremap_smc(0, AT91SAM9263_BASE_SMC0);
 	at91sam9_ioremap_smc(1, AT91SAM9263_BASE_SMC1);
 	at91_ioremap_matrix(AT91SAM9263_BASE_MATRIX);
@@ -381,9 +380,36 @@ static unsigned int at91sam9263_default_irq_priority[NR_AIC_IRQS] __initdata = {
 	0,	/* Advanced Interrupt Controller (IRQ1) */
 };
 
+static struct resource pit_resources[] = {
+	[0] = {
+		.start	= AT91SAM9263_BASE_PIT,
+		.end	= AT91SAM9263_BASE_PIT + SZ_16 - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= NR_IRQS_LEGACY + AT91_ID_SYS,
+		.end	= NR_IRQS_LEGACY + AT91_ID_SYS,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device pit_device = {
+	.name		= "at91_pit",
+	.resource	= pit_resources,
+	.num_resources	= ARRAY_SIZE(pit_resources),
+};
+
+static struct platform_device *at91sam9263_early_devices[] __initdata = {
+	&pit_device,
+};
+
 static void __init at91sam9263_init_time(void)
 {
-	at91sam926x_pit_init();
+	early_platform_add_devices(at91sam9263_early_devices,
+				   ARRAY_SIZE(at91sam9263_early_devices));
+
+	early_platform_driver_register_all("earlytimer");
+	early_platform_driver_probe("earlytimer", 1, 0);
 }
 
 AT91_SOC_START(at91sam9263)
diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c
index f2c463567beb..b471865137fe 100644
--- a/arch/arm/mach-at91/at91sam926x_time.c
+++ b/arch/arm/mach-at91/at91sam926x_time.c
@@ -15,15 +15,15 @@
 #include <linux/clk.h>
 #include <linux/clockchips.h>
 #include <linux/interrupt.h>
+#include <linux/ioport.h>
 #include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
+#include <linux/platform_device.h>
 #include <linux/slab.h>
 
-#include <mach/hardware.h>
-
 #define AT91_PIT_MR		0x00			/* Mode Register */
 #define AT91_PIT_PITIEN			BIT(25)			/* Timer Interrupt Enable */
 #define AT91_PIT_PITEN			BIT(24)			/* Timer Enabled */
@@ -265,34 +265,40 @@ static void __init at91sam926x_pit_dt_init(struct device_node *node)
 CLOCKSOURCE_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit",
 		       at91sam926x_pit_dt_init);
 
-static void __iomem *pit_base_addr;
-
-void __init at91sam926x_pit_init(void)
+static int __init pit_early_probe(struct platform_device *pdev)
 {
 	struct pit_data *data;
+	struct resource *res;
 
 	data = kzalloc(sizeof(*data), GFP_KERNEL);
 	if (!data)
 		panic(pr_fmt("Unable to allocate memory\n"));
 
-	data->base = pit_base_addr;
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!request_mem_region(res->start, resource_size(res),	"at91_pit"))
+		panic(pr_fmt("Unable to request memory region\n"));
+
+	data->base = ioremap(res->start, resource_size(res));
+	if (!data->base)
+		panic(pr_fmt("Impossible to ioremap PIT\n"));
 
 	data->mck = clk_get(NULL, "mck");
 	if (IS_ERR(data->mck))
 		panic(pr_fmt("Unable to get mck clk\n"));
 
-	data->irq = NR_IRQS_LEGACY + AT91_ID_SYS;
+	data->irq = platform_get_irq(pdev, 0);
+	if (data->irq < 0)
+		panic(pr_fmt("Unable to get IRQ from resources\n"));
 
 	at91sam926x_pit_common_init(data);
-}
 
-void __init at91sam926x_ioremap_pit(u32 addr)
-{
-	if (of_have_populated_dt())
-		return;
-
-	pit_base_addr = ioremap(addr, 16);
-
-	if (!pit_base_addr)
-		panic(pr_fmt("Impossible to ioremap PIT\n"));
+	return 0;
 }
+
+static struct platform_driver pit_driver __initdata = {
+	.probe		= pit_early_probe,
+	.driver		= {
+		.name	= "at91_pit",
+	},
+};
+early_platform_init("earlytimer", &pit_driver);
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index 924d362121ef..b7ab0998afce 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/dma-mapping.h>
 #include <linux/clk/at91_pmc.h>
+#include <linux/platform_device.h>
 
 #include <asm/irq.h>
 #include <asm/mach/arch.h>
@@ -370,7 +371,6 @@ static void __init at91sam9g45_ioremap_registers(void)
 	at91_ioremap_rstc(AT91SAM9G45_BASE_RSTC);
 	at91_ioremap_ramc(0, AT91SAM9G45_BASE_DDRSDRC1, 512);
 	at91_ioremap_ramc(1, AT91SAM9G45_BASE_DDRSDRC0, 512);
-	at91sam926x_ioremap_pit(AT91SAM9G45_BASE_PIT);
 	at91sam9_ioremap_smc(0, AT91SAM9G45_BASE_SMC);
 	at91_ioremap_matrix(AT91SAM9G45_BASE_MATRIX);
 	at91_pm_set_standby(at91_ddr_standby);
@@ -430,9 +430,36 @@ static unsigned int at91sam9g45_default_irq_priority[NR_AIC_IRQS] __initdata = {
 	0,	/* Advanced Interrupt Controller (IRQ0) */
 };
 
+static struct resource pit_resources[] = {
+	[0] = {
+		.start	= AT91SAM9G45_BASE_PIT,
+		.end	= AT91SAM9G45_BASE_PIT + SZ_16 - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= NR_IRQS_LEGACY + AT91_ID_SYS,
+		.end	= NR_IRQS_LEGACY + AT91_ID_SYS,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device pit_device = {
+	.name		= "at91_pit",
+	.resource	= pit_resources,
+	.num_resources	= ARRAY_SIZE(pit_resources),
+};
+
+static struct platform_device *at91sam9g45_early_devices[] __initdata = {
+	&pit_device,
+};
+
 static void __init at91sam9g45_init_time(void)
 {
-	at91sam926x_pit_init();
+	early_platform_add_devices(at91sam9g45_early_devices,
+				   ARRAY_SIZE(at91sam9g45_early_devices));
+
+	early_platform_driver_register_all("earlytimer");
+	early_platform_driver_probe("earlytimer", 1, 0);
 }
 
 AT91_SOC_START(at91sam9g45)
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
index dd4a8deb5b36..664c29efdf3e 100644
--- a/arch/arm/mach-at91/at91sam9rl.c
+++ b/arch/arm/mach-at91/at91sam9rl.c
@@ -313,7 +313,6 @@ static void __init at91sam9rl_ioremap_registers(void)
 	at91_ioremap_shdwc(AT91SAM9RL_BASE_SHDWC);
 	at91_ioremap_rstc(AT91SAM9RL_BASE_RSTC);
 	at91_ioremap_ramc(0, AT91SAM9RL_BASE_SDRAMC, 512);
-	at91sam926x_ioremap_pit(AT91SAM9RL_BASE_PIT);
 	at91sam9_ioremap_smc(0, AT91SAM9RL_BASE_SMC);
 	at91_ioremap_matrix(AT91SAM9RL_BASE_MATRIX);
 	at91_pm_set_standby(at91sam9_sdram_standby);
@@ -373,9 +372,36 @@ static unsigned int at91sam9rl_default_irq_priority[NR_AIC_IRQS] __initdata = {
 	0,	/* Advanced Interrupt Controller */
 };
 
+static struct resource pit_resources[] = {
+	[0] = {
+		.start	= AT91SAM9RL_BASE_PIT,
+		.end	= AT91SAM9RL_BASE_PIT + SZ_16 - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= NR_IRQS_LEGACY + AT91_ID_SYS,
+		.end	= NR_IRQS_LEGACY + AT91_ID_SYS,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device pit_device = {
+	.name		= "at91_pit",
+	.resource	= pit_resources,
+	.num_resources	= ARRAY_SIZE(pit_resources),
+};
+
+static struct platform_device *at91sam9rl_early_devices[] __initdata = {
+	&pit_device,
+};
+
 static void __init at91sam9rl_init_time(void)
 {
-	at91sam926x_pit_init();
+	early_platform_add_devices(at91sam9rl_early_devices,
+				   ARRAY_SIZE(at91sam9rl_early_devices));
+
+	early_platform_driver_register_all("earlytimer");
+	early_platform_driver_probe("earlytimer", 1, 0);
 }
 
 AT91_SOC_START(at91sam9rl)
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index eb5512c3d717..2269d5fb83a9 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -45,8 +45,6 @@ extern void __init at91_sysirq_mask_rtt(u32 rtt_base);
 extern void __init at91_init_time(void);
 extern void at91rm9200_ioremap_st(u32 addr);
 extern void at91rm9200_timer_init(void);
-extern void at91sam926x_ioremap_pit(u32 addr);
-extern void at91sam926x_pit_init(void);
 extern void at91x40_timer_init(void);
 
  /* Clocks */
-- 
2.0.0


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

* [PATCH 13/13] AT91: PIT: Move the driver to drivers/clocksource
  2014-06-25 13:06 [PATCH 00/13] AT91: PIT: Cleanups and move to drivers/clocksource Maxime Ripard
                   ` (11 preceding siblings ...)
  2014-06-25 13:06 ` [PATCH 12/13] AT91: PIT: Convert to an early_platform_device Maxime Ripard
@ 2014-06-25 13:06 ` Maxime Ripard
  2014-06-26  5:26   ` Boris BREZILLON
  2014-06-26  5:30 ` [PATCH 00/13] AT91: PIT: Cleanups and move " Boris BREZILLON
  13 siblings, 1 reply; 21+ messages in thread
From: Maxime Ripard @ 2014-06-25 13:06 UTC (permalink / raw)
  To: linux, Nicolas Ferre, Jean-Christophe Plagniol-Villard, Daniel Lezcano
  Cc: Boris Brezillon, Alexandre Belloni, Thomas Petazzoni,
	linux-arm-kernel, linux-kernel, Maxime Ripard

Now that we don't depend on anyting in the mach-at91 directory, we can just
move the driver to where it belongs.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 arch/arm/mach-at91/Kconfig                                     | 4 ----
 arch/arm/mach-at91/Makefile                                    | 1 -
 drivers/clocksource/Kconfig                                    | 4 ++++
 drivers/clocksource/Makefile                                   | 1 +
 {arch/arm/mach-at91 => drivers/clocksource}/at91sam926x_time.c | 0
 5 files changed, 5 insertions(+), 5 deletions(-)
 rename {arch/arm/mach-at91 => drivers/clocksource}/at91sam926x_time.c (100%)

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index a64412a020d3..b10db0990999 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -36,10 +36,6 @@ config AT91_SAM9G45_RESET
 	bool
 	default !ARCH_AT91X40
 
-config AT91_SAM9_TIME
-	select CLKSRC_OF if OF
-	bool
-
 config HAVE_AT91_SMD
 	bool
 
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 78e9cec282f4..1a916ececbfd 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -10,7 +10,6 @@ obj-		:=
 obj-$(CONFIG_OLD_CLK_AT91)	+= clock.o
 obj-$(CONFIG_AT91_SAM9_ALT_RESET) += at91sam9_alt_reset.o
 obj-$(CONFIG_AT91_SAM9G45_RESET) += at91sam9g45_reset.o
-obj-$(CONFIG_AT91_SAM9_TIME)	+= at91sam926x_time.o
 obj-$(CONFIG_SOC_AT91SAM9)	+= sam9_smc.o
 
 # CPU-specific support
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 065131cbfcc0..cd8b73ddbef3 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -118,6 +118,10 @@ config CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK
 	help
 	 Use ARM global timer clock source as sched_clock
 
+config AT91_SAM9_TIME
+	select CLKSRC_OF if OF
+	bool
+
 config CLKSRC_METAG_GENERIC
 	def_bool y if METAG
 	help
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 800b1303c236..3088928070f8 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -1,5 +1,6 @@
 obj-$(CONFIG_CLKSRC_OF)	+= clksrc-of.o
 obj-$(CONFIG_ATMEL_TCB_CLKSRC)	+= tcb_clksrc.o
+obj-$(CONFIG_AT91_SAM9_TIME)	+= at91sam926x_time.o
 obj-$(CONFIG_X86_PM_TIMER)	+= acpi_pm.o
 obj-$(CONFIG_SCx200HR_TIMER)	+= scx200_hrt.o
 obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC)	+= cs5535-clockevt.o
diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/drivers/clocksource/at91sam926x_time.c
similarity index 100%
rename from arch/arm/mach-at91/at91sam926x_time.c
rename to drivers/clocksource/at91sam926x_time.c
-- 
2.0.0


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

* Re: [PATCH 09/13] AT91: PIT: (Almost) remove the global variables
  2014-06-25 13:06 ` [PATCH 09/13] AT91: PIT: (Almost) remove the global variables Maxime Ripard
@ 2014-06-26  5:12   ` Boris BREZILLON
  2014-06-26  9:28     ` Maxime Ripard
  0 siblings, 1 reply; 21+ messages in thread
From: Boris BREZILLON @ 2014-06-26  5:12 UTC (permalink / raw)
  To: Maxime Ripard, linux, Nicolas Ferre,
	Jean-Christophe Plagniol-Villard, Daniel Lezcano
  Cc: Boris Brezillon, Alexandre Belloni, Thomas Petazzoni,
	linux-arm-kernel, linux-kernel

Hello Maxime,

On 25/06/2014 15:06, Maxime Ripard wrote:
> The timer driver is using some global variables to define some variables it has
> to use in most of its functions, like the base address.
>
> Use some container_of calls to have a single dynamic (and local) variable to
> hold this content.
>
> The only exception is in the !DT case, where the call chain to
> at91sam926x_ioremap_pit and then at91sam926x_pit_init as init_time makes it
> hard for the moment to pass the physical address of the timer.
>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
>  arch/arm/mach-at91/at91sam926x_time.c | 179 ++++++++++++++++++++--------------
>  1 file changed, 108 insertions(+), 71 deletions(-)
>
> diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c
> index 9678ac391a81..f2c463567beb 100644
> --- a/arch/arm/mach-at91/at91sam926x_time.c
> +++ b/arch/arm/mach-at91/at91sam926x_time.c
> @@ -20,6 +20,7 @@
>  #include <linux/of.h>
>  #include <linux/of_address.h>
>  #include <linux/of_irq.h>
> +#include <linux/slab.h>
>  

[...]

>  	unsigned	bits;
> @@ -186,67 +195,95 @@ static void __init at91sam926x_pit_common_init(unsigned int pit_irq)
>  	 * Use our actual MCK to figure out how many MCK/16 ticks per
>  	 * 1/HZ period (instead of a compile-time constant LATCH).
>  	 */
> -	pit_rate = clk_get_rate(mck) / 16;
> -	pit_cycle = (pit_rate + HZ/2) / HZ;
> -	WARN_ON(((pit_cycle - 1) & ~AT91_PIT_PIV) != 0);
> +	pit_rate = clk_get_rate(data->mck) / 16;
> +	data->cycle = (pit_rate + HZ/2) / HZ;

You could use DIV_ROUND_CLOSEST here.

Regards,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


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

* Re: [PATCH 13/13] AT91: PIT: Move the driver to drivers/clocksource
  2014-06-25 13:06 ` [PATCH 13/13] AT91: PIT: Move the driver to drivers/clocksource Maxime Ripard
@ 2014-06-26  5:26   ` Boris BREZILLON
  2014-06-26  9:30     ` Maxime Ripard
  0 siblings, 1 reply; 21+ messages in thread
From: Boris BREZILLON @ 2014-06-26  5:26 UTC (permalink / raw)
  To: Maxime Ripard, linux, Nicolas Ferre,
	Jean-Christophe Plagniol-Villard, Daniel Lezcano
  Cc: Boris Brezillon, Alexandre Belloni, Thomas Petazzoni,
	linux-arm-kernel, linux-kernel


On 25/06/2014 15:06, Maxime Ripard wrote:
> Now that we don't depend on anyting in the mach-at91 directory, we can just
> move the driver to where it belongs.
>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
>  arch/arm/mach-at91/Kconfig                                     | 4 ----
>  arch/arm/mach-at91/Makefile                                    | 1 -
>  drivers/clocksource/Kconfig                                    | 4 ++++
>  drivers/clocksource/Makefile                                   | 1 +
>  {arch/arm/mach-at91 => drivers/clocksource}/at91sam926x_time.c | 0
>  5 files changed, 5 insertions(+), 5 deletions(-)
>  rename {arch/arm/mach-at91 => drivers/clocksource}/at91sam926x_time.c (100%)
>
> diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
> index a64412a020d3..b10db0990999 100644
> --- a/arch/arm/mach-at91/Kconfig
> +++ b/arch/arm/mach-at91/Kconfig
> @@ -36,10 +36,6 @@ config AT91_SAM9G45_RESET
>  	bool
>  	default !ARCH_AT91X40
>  
> -config AT91_SAM9_TIME
> -	select CLKSRC_OF if OF
> -	bool
> -
>  config HAVE_AT91_SMD
>  	bool
>  
> diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
> index 78e9cec282f4..1a916ececbfd 100644
> --- a/arch/arm/mach-at91/Makefile
> +++ b/arch/arm/mach-at91/Makefile
> @@ -10,7 +10,6 @@ obj-		:=
>  obj-$(CONFIG_OLD_CLK_AT91)	+= clock.o
>  obj-$(CONFIG_AT91_SAM9_ALT_RESET) += at91sam9_alt_reset.o
>  obj-$(CONFIG_AT91_SAM9G45_RESET) += at91sam9g45_reset.o
> -obj-$(CONFIG_AT91_SAM9_TIME)	+= at91sam926x_time.o
>  obj-$(CONFIG_SOC_AT91SAM9)	+= sam9_smc.o
>  
>  # CPU-specific support
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index 065131cbfcc0..cd8b73ddbef3 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -118,6 +118,10 @@ config CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK
>  	help
>  	 Use ARM global timer clock source as sched_clock
>  
> +config AT91_SAM9_TIME
> +	select CLKSRC_OF if OF
> +	bool
> +
>  config CLKSRC_METAG_GENERIC
>  	def_bool y if METAG
>  	help
> diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> index 800b1303c236..3088928070f8 100644
> --- a/drivers/clocksource/Makefile
> +++ b/drivers/clocksource/Makefile
> @@ -1,5 +1,6 @@
>  obj-$(CONFIG_CLKSRC_OF)	+= clksrc-of.o
>  obj-$(CONFIG_ATMEL_TCB_CLKSRC)	+= tcb_clksrc.o
> +obj-$(CONFIG_AT91_SAM9_TIME)	+= at91sam926x_time.o

I would rename both Kconfig and source file name into ATMEL_PIT and
atmel_pit.c (or AT91_PIT and atmel_pit.c) to cleary show that this
driver add support for the PIT block.

>  obj-$(CONFIG_X86_PM_TIMER)	+= acpi_pm.o
>  obj-$(CONFIG_SCx200HR_TIMER)	+= scx200_hrt.o
>  obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC)	+= cs5535-clockevt.o
> diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/drivers/clocksource/at91sam926x_time.c
> similarity index 100%
> rename from arch/arm/mach-at91/at91sam926x_time.c
> rename to drivers/clocksource/at91sam926x_time.c

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


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

* Re: [PATCH 00/13] AT91: PIT: Cleanups and move to drivers/clocksource
  2014-06-25 13:06 [PATCH 00/13] AT91: PIT: Cleanups and move to drivers/clocksource Maxime Ripard
                   ` (12 preceding siblings ...)
  2014-06-25 13:06 ` [PATCH 13/13] AT91: PIT: Move the driver to drivers/clocksource Maxime Ripard
@ 2014-06-26  5:30 ` Boris BREZILLON
  13 siblings, 0 replies; 21+ messages in thread
From: Boris BREZILLON @ 2014-06-26  5:30 UTC (permalink / raw)
  To: Maxime Ripard, linux, Nicolas Ferre,
	Jean-Christophe Plagniol-Villard, Daniel Lezcano
  Cc: Boris Brezillon, Alexandre Belloni, Thomas Petazzoni,
	linux-arm-kernel, linux-kernel

Hello Maxime,

On 25/06/2014 15:06, Maxime Ripard wrote:
> Hi everyone,
>
> This series cleans up the PIT driver in order for it to not depend on
> anything in mach-at91 anymore, and in the end move it out of
> mach-at91.
>
> Along the way, these patches also do a bit of cleanup.
>
> This has been tested on a G45-EK without DT and an Xplained with DT.

Except for the 2 nitpicks in patch 9 and 13, this series looks good to me.
I was a bit afraid to see code for non DT board support go into this new
driver (or driver rework), but you managed to get rid of all global
variables and non static functions thanks to the early device approach,
and that's great!

Thanks for your work.

Boris

>
> Thanks,
> Maxime
>
> Maxime Ripard (13):
>   AT91: PIT: Follow the general coding rules
>   AT91: generic.h: Add include safe guards
>   AT91: PIT: Use of_have_populated_dt instead of CONFIG_OF
>   AT91: PIT: Rework probe functions
>   AT91: dt: Remove init_time definitions
>   AT91: PIT: Use consistent exit path in probe
>   AT91: PIT: Use pr_fmt
>   AT91: PIT: use request_irq instead of setup_irq
>   AT91: PIT: (Almost) remove the global variables
>   AT91: soc: Add init_time callback
>   AT91: Convert the boards to the init_time callback
>   AT91: PIT: Convert to an early_platform_device
>   AT91: PIT: Move the driver to drivers/clocksource
>
>  arch/arm/mach-at91/Kconfig              |   3 -
>  arch/arm/mach-at91/Makefile             |   1 -
>  arch/arm/mach-at91/at91sam9260.c        |  34 +++-
>  arch/arm/mach-at91/at91sam9261.c        |  34 +++-
>  arch/arm/mach-at91/at91sam9263.c        |  34 +++-
>  arch/arm/mach-at91/at91sam926x_time.c   | 294 ------------------------------
>  arch/arm/mach-at91/at91sam9g45.c        |  35 +++-
>  arch/arm/mach-at91/at91sam9rl.c         |  34 +++-
>  arch/arm/mach-at91/board-afeb-9260v1.c  |   2 +-
>  arch/arm/mach-at91/board-cam60.c        |   2 +-
>  arch/arm/mach-at91/board-cpu9krea.c     |   2 +-
>  arch/arm/mach-at91/board-dt-sam9.c      |  10 --
>  arch/arm/mach-at91/board-dt-sama5.c     |   9 -
>  arch/arm/mach-at91/board-flexibity.c    |   2 +-
>  arch/arm/mach-at91/board-foxg20.c       |   2 +-
>  arch/arm/mach-at91/board-gsia18s.c      |   2 +-
>  arch/arm/mach-at91/board-pcontrol-g20.c |   2 +-
>  arch/arm/mach-at91/board-sam9-l9260.c   |   2 +-
>  arch/arm/mach-at91/board-sam9260ek.c    |   2 +-
>  arch/arm/mach-at91/board-sam9261ek.c    |   4 +-
>  arch/arm/mach-at91/board-sam9263ek.c    |   2 +-
>  arch/arm/mach-at91/board-sam9g20ek.c    |   4 +-
>  arch/arm/mach-at91/board-sam9m10g45ek.c |   2 +-
>  arch/arm/mach-at91/board-sam9rlek.c     |   2 +-
>  arch/arm/mach-at91/board-snapper9260.c  |   2 +-
>  arch/arm/mach-at91/board-stamp9g20.c    |   4 +-
>  arch/arm/mach-at91/generic.h            |   8 +-
>  arch/arm/mach-at91/setup.c              |   5 +
>  arch/arm/mach-at91/soc.h                |   1 +
>  drivers/clocksource/Kconfig             |   4 +
>  drivers/clocksource/Makefile            |   1 +
>  drivers/clocksource/at91sam926x_time.c  | 304 ++++++++++++++++++++++++++++++++
>  32 files changed, 506 insertions(+), 343 deletions(-)
>  delete mode 100644 arch/arm/mach-at91/at91sam926x_time.c
>  create mode 100644 drivers/clocksource/at91sam926x_time.c
>

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


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

* Re: [PATCH 09/13] AT91: PIT: (Almost) remove the global variables
  2014-06-26  5:12   ` Boris BREZILLON
@ 2014-06-26  9:28     ` Maxime Ripard
  0 siblings, 0 replies; 21+ messages in thread
From: Maxime Ripard @ 2014-06-26  9:28 UTC (permalink / raw)
  To: Boris BREZILLON
  Cc: linux, Nicolas Ferre, Jean-Christophe Plagniol-Villard,
	Daniel Lezcano, Boris Brezillon, Alexandre Belloni,
	Thomas Petazzoni, linux-arm-kernel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2112 bytes --]

Hi Boris,

On Thu, Jun 26, 2014 at 07:12:06AM +0200, Boris BREZILLON wrote:
> Hello Maxime,
> 
> On 25/06/2014 15:06, Maxime Ripard wrote:
> > The timer driver is using some global variables to define some variables it has
> > to use in most of its functions, like the base address.
> >
> > Use some container_of calls to have a single dynamic (and local) variable to
> > hold this content.
> >
> > The only exception is in the !DT case, where the call chain to
> > at91sam926x_ioremap_pit and then at91sam926x_pit_init as init_time makes it
> > hard for the moment to pass the physical address of the timer.
> >
> > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > ---
> >  arch/arm/mach-at91/at91sam926x_time.c | 179 ++++++++++++++++++++--------------
> >  1 file changed, 108 insertions(+), 71 deletions(-)
> >
> > diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c
> > index 9678ac391a81..f2c463567beb 100644
> > --- a/arch/arm/mach-at91/at91sam926x_time.c
> > +++ b/arch/arm/mach-at91/at91sam926x_time.c
> > @@ -20,6 +20,7 @@
> >  #include <linux/of.h>
> >  #include <linux/of_address.h>
> >  #include <linux/of_irq.h>
> > +#include <linux/slab.h>
> >  
> 
> [...]
> 
> >  	unsigned	bits;
> > @@ -186,67 +195,95 @@ static void __init at91sam926x_pit_common_init(unsigned int pit_irq)
> >  	 * Use our actual MCK to figure out how many MCK/16 ticks per
> >  	 * 1/HZ period (instead of a compile-time constant LATCH).
> >  	 */
> > -	pit_rate = clk_get_rate(mck) / 16;
> > -	pit_cycle = (pit_rate + HZ/2) / HZ;
> > -	WARN_ON(((pit_cycle - 1) & ~AT91_PIT_PIV) != 0);
> > +	pit_rate = clk_get_rate(data->mck) / 16;
> > +	data->cycle = (pit_rate + HZ/2) / HZ;
> 
> You could use DIV_ROUND_CLOSEST here.

I usually prefer not to introduce such changes whenever I'm just
renaming a variable, but it's true that this change would be
welcome. I'll do the change in a separate patch.

Maxime

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 13/13] AT91: PIT: Move the driver to drivers/clocksource
  2014-06-26  5:26   ` Boris BREZILLON
@ 2014-06-26  9:30     ` Maxime Ripard
  2014-06-26 11:48       ` Boris BREZILLON
  0 siblings, 1 reply; 21+ messages in thread
From: Maxime Ripard @ 2014-06-26  9:30 UTC (permalink / raw)
  To: Boris BREZILLON
  Cc: linux, Nicolas Ferre, Jean-Christophe Plagniol-Villard,
	Daniel Lezcano, Boris Brezillon, Alexandre Belloni,
	Thomas Petazzoni, linux-arm-kernel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3246 bytes --]

Hi Boris,

On Thu, Jun 26, 2014 at 07:26:54AM +0200, Boris BREZILLON wrote:
> 
> On 25/06/2014 15:06, Maxime Ripard wrote:
> > Now that we don't depend on anyting in the mach-at91 directory, we can just
> > move the driver to where it belongs.
> >
> > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > ---
> >  arch/arm/mach-at91/Kconfig                                     | 4 ----
> >  arch/arm/mach-at91/Makefile                                    | 1 -
> >  drivers/clocksource/Kconfig                                    | 4 ++++
> >  drivers/clocksource/Makefile                                   | 1 +
> >  {arch/arm/mach-at91 => drivers/clocksource}/at91sam926x_time.c | 0
> >  5 files changed, 5 insertions(+), 5 deletions(-)
> >  rename {arch/arm/mach-at91 => drivers/clocksource}/at91sam926x_time.c (100%)
> >
> > diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
> > index a64412a020d3..b10db0990999 100644
> > --- a/arch/arm/mach-at91/Kconfig
> > +++ b/arch/arm/mach-at91/Kconfig
> > @@ -36,10 +36,6 @@ config AT91_SAM9G45_RESET
> >  	bool
> >  	default !ARCH_AT91X40
> >  
> > -config AT91_SAM9_TIME
> > -	select CLKSRC_OF if OF
> > -	bool
> > -
> >  config HAVE_AT91_SMD
> >  	bool
> >  
> > diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
> > index 78e9cec282f4..1a916ececbfd 100644
> > --- a/arch/arm/mach-at91/Makefile
> > +++ b/arch/arm/mach-at91/Makefile
> > @@ -10,7 +10,6 @@ obj-		:=
> >  obj-$(CONFIG_OLD_CLK_AT91)	+= clock.o
> >  obj-$(CONFIG_AT91_SAM9_ALT_RESET) += at91sam9_alt_reset.o
> >  obj-$(CONFIG_AT91_SAM9G45_RESET) += at91sam9g45_reset.o
> > -obj-$(CONFIG_AT91_SAM9_TIME)	+= at91sam926x_time.o
> >  obj-$(CONFIG_SOC_AT91SAM9)	+= sam9_smc.o
> >  
> >  # CPU-specific support
> > diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> > index 065131cbfcc0..cd8b73ddbef3 100644
> > --- a/drivers/clocksource/Kconfig
> > +++ b/drivers/clocksource/Kconfig
> > @@ -118,6 +118,10 @@ config CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK
> >  	help
> >  	 Use ARM global timer clock source as sched_clock
> >  
> > +config AT91_SAM9_TIME
> > +	select CLKSRC_OF if OF
> > +	bool
> > +
> >  config CLKSRC_METAG_GENERIC
> >  	def_bool y if METAG
> >  	help
> > diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> > index 800b1303c236..3088928070f8 100644
> > --- a/drivers/clocksource/Makefile
> > +++ b/drivers/clocksource/Makefile
> > @@ -1,5 +1,6 @@
> >  obj-$(CONFIG_CLKSRC_OF)	+= clksrc-of.o
> >  obj-$(CONFIG_ATMEL_TCB_CLKSRC)	+= tcb_clksrc.o
> > +obj-$(CONFIG_AT91_SAM9_TIME)	+= at91sam926x_time.o
> 
> I would rename both Kconfig and source file name into ATMEL_PIT and
> atmel_pit.c (or AT91_PIT and atmel_pit.c) to cleary show that this
> driver add support for the PIT block.

I actually had the same idea, but older AT91 SoCs (rm9200, for
example) also mention the PIT, even though the IP is different.

Since AT91_PIT was just too generic and only added confusion, I left
it as is, but maybe we can find a better name.

Maxime

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 13/13] AT91: PIT: Move the driver to drivers/clocksource
  2014-06-26  9:30     ` Maxime Ripard
@ 2014-06-26 11:48       ` Boris BREZILLON
  2014-06-26 12:54         ` Maxime Ripard
  0 siblings, 1 reply; 21+ messages in thread
From: Boris BREZILLON @ 2014-06-26 11:48 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: linux, Nicolas Ferre, Jean-Christophe Plagniol-Villard,
	Daniel Lezcano, Boris Brezillon, Alexandre Belloni,
	Thomas Petazzoni, linux-arm-kernel, linux-kernel


On 26/06/2014 11:30, Maxime Ripard wrote:
> Hi Boris,
>
> On Thu, Jun 26, 2014 at 07:26:54AM +0200, Boris BREZILLON wrote:
>> On 25/06/2014 15:06, Maxime Ripard wrote:
>>> Now that we don't depend on anyting in the mach-at91 directory, we can just
>>> move the driver to where it belongs.
>>>
>>> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
>>> ---
>>>  arch/arm/mach-at91/Kconfig                                     | 4 ----
>>>  arch/arm/mach-at91/Makefile                                    | 1 -
>>>  drivers/clocksource/Kconfig                                    | 4 ++++
>>>  drivers/clocksource/Makefile                                   | 1 +
>>>  {arch/arm/mach-at91 => drivers/clocksource}/at91sam926x_time.c | 0
>>>  5 files changed, 5 insertions(+), 5 deletions(-)
>>>  rename {arch/arm/mach-at91 => drivers/clocksource}/at91sam926x_time.c (100%)
>>>
>>> diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
>>> index a64412a020d3..b10db0990999 100644
>>> --- a/arch/arm/mach-at91/Kconfig
>>> +++ b/arch/arm/mach-at91/Kconfig
>>> @@ -36,10 +36,6 @@ config AT91_SAM9G45_RESET
>>>  	bool
>>>  	default !ARCH_AT91X40
>>>  
>>> -config AT91_SAM9_TIME
>>> -	select CLKSRC_OF if OF
>>> -	bool
>>> -
>>>  config HAVE_AT91_SMD
>>>  	bool
>>>  
>>> diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
>>> index 78e9cec282f4..1a916ececbfd 100644
>>> --- a/arch/arm/mach-at91/Makefile
>>> +++ b/arch/arm/mach-at91/Makefile
>>> @@ -10,7 +10,6 @@ obj-		:=
>>>  obj-$(CONFIG_OLD_CLK_AT91)	+= clock.o
>>>  obj-$(CONFIG_AT91_SAM9_ALT_RESET) += at91sam9_alt_reset.o
>>>  obj-$(CONFIG_AT91_SAM9G45_RESET) += at91sam9g45_reset.o
>>> -obj-$(CONFIG_AT91_SAM9_TIME)	+= at91sam926x_time.o
>>>  obj-$(CONFIG_SOC_AT91SAM9)	+= sam9_smc.o
>>>  
>>>  # CPU-specific support
>>> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
>>> index 065131cbfcc0..cd8b73ddbef3 100644
>>> --- a/drivers/clocksource/Kconfig
>>> +++ b/drivers/clocksource/Kconfig
>>> @@ -118,6 +118,10 @@ config CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK
>>>  	help
>>>  	 Use ARM global timer clock source as sched_clock
>>>  
>>> +config AT91_SAM9_TIME
>>> +	select CLKSRC_OF if OF
>>> +	bool
>>> +
>>>  config CLKSRC_METAG_GENERIC
>>>  	def_bool y if METAG
>>>  	help
>>> diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
>>> index 800b1303c236..3088928070f8 100644
>>> --- a/drivers/clocksource/Makefile
>>> +++ b/drivers/clocksource/Makefile
>>> @@ -1,5 +1,6 @@
>>>  obj-$(CONFIG_CLKSRC_OF)	+= clksrc-of.o
>>>  obj-$(CONFIG_ATMEL_TCB_CLKSRC)	+= tcb_clksrc.o
>>> +obj-$(CONFIG_AT91_SAM9_TIME)	+= at91sam926x_time.o
>> I would rename both Kconfig and source file name into ATMEL_PIT and
>> atmel_pit.c (or AT91_PIT and atmel_pit.c) to cleary show that this
>> driver add support for the PIT block.
> I actually had the same idea, but older AT91 SoCs (rm9200, for
> example) also mention the PIT, even though the IP is different.

I checked at91rm9200 datasheet, and indeed it mention the concept of PIT
(Periodic Interval Timer), but the HW block is called ST (System Timer).

How about using the name ATMEL_PIT for this driver and later use
ATMEL_ST when we decide to move at91rm9200_time.c driver into
drivers/clocksource ?

>
> Since AT91_PIT was just too generic and only added confusion, I left
> it as is, but maybe we can find a better name.
>
> Maxime
>

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


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

* Re: [PATCH 13/13] AT91: PIT: Move the driver to drivers/clocksource
  2014-06-26 11:48       ` Boris BREZILLON
@ 2014-06-26 12:54         ` Maxime Ripard
  0 siblings, 0 replies; 21+ messages in thread
From: Maxime Ripard @ 2014-06-26 12:54 UTC (permalink / raw)
  To: Boris BREZILLON
  Cc: linux, Nicolas Ferre, Jean-Christophe Plagniol-Villard,
	Daniel Lezcano, Boris Brezillon, Alexandre Belloni,
	Thomas Petazzoni, linux-arm-kernel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3723 bytes --]

On Thu, Jun 26, 2014 at 01:48:18PM +0200, Boris BREZILLON wrote:
> 
> On 26/06/2014 11:30, Maxime Ripard wrote:
> > Hi Boris,
> >
> > On Thu, Jun 26, 2014 at 07:26:54AM +0200, Boris BREZILLON wrote:
> >> On 25/06/2014 15:06, Maxime Ripard wrote:
> >>> Now that we don't depend on anyting in the mach-at91 directory, we can just
> >>> move the driver to where it belongs.
> >>>
> >>> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> >>> ---
> >>>  arch/arm/mach-at91/Kconfig                                     | 4 ----
> >>>  arch/arm/mach-at91/Makefile                                    | 1 -
> >>>  drivers/clocksource/Kconfig                                    | 4 ++++
> >>>  drivers/clocksource/Makefile                                   | 1 +
> >>>  {arch/arm/mach-at91 => drivers/clocksource}/at91sam926x_time.c | 0
> >>>  5 files changed, 5 insertions(+), 5 deletions(-)
> >>>  rename {arch/arm/mach-at91 => drivers/clocksource}/at91sam926x_time.c (100%)
> >>>
> >>> diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
> >>> index a64412a020d3..b10db0990999 100644
> >>> --- a/arch/arm/mach-at91/Kconfig
> >>> +++ b/arch/arm/mach-at91/Kconfig
> >>> @@ -36,10 +36,6 @@ config AT91_SAM9G45_RESET
> >>>  	bool
> >>>  	default !ARCH_AT91X40
> >>>  
> >>> -config AT91_SAM9_TIME
> >>> -	select CLKSRC_OF if OF
> >>> -	bool
> >>> -
> >>>  config HAVE_AT91_SMD
> >>>  	bool
> >>>  
> >>> diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
> >>> index 78e9cec282f4..1a916ececbfd 100644
> >>> --- a/arch/arm/mach-at91/Makefile
> >>> +++ b/arch/arm/mach-at91/Makefile
> >>> @@ -10,7 +10,6 @@ obj-		:=
> >>>  obj-$(CONFIG_OLD_CLK_AT91)	+= clock.o
> >>>  obj-$(CONFIG_AT91_SAM9_ALT_RESET) += at91sam9_alt_reset.o
> >>>  obj-$(CONFIG_AT91_SAM9G45_RESET) += at91sam9g45_reset.o
> >>> -obj-$(CONFIG_AT91_SAM9_TIME)	+= at91sam926x_time.o
> >>>  obj-$(CONFIG_SOC_AT91SAM9)	+= sam9_smc.o
> >>>  
> >>>  # CPU-specific support
> >>> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> >>> index 065131cbfcc0..cd8b73ddbef3 100644
> >>> --- a/drivers/clocksource/Kconfig
> >>> +++ b/drivers/clocksource/Kconfig
> >>> @@ -118,6 +118,10 @@ config CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK
> >>>  	help
> >>>  	 Use ARM global timer clock source as sched_clock
> >>>  
> >>> +config AT91_SAM9_TIME
> >>> +	select CLKSRC_OF if OF
> >>> +	bool
> >>> +
> >>>  config CLKSRC_METAG_GENERIC
> >>>  	def_bool y if METAG
> >>>  	help
> >>> diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> >>> index 800b1303c236..3088928070f8 100644
> >>> --- a/drivers/clocksource/Makefile
> >>> +++ b/drivers/clocksource/Makefile
> >>> @@ -1,5 +1,6 @@
> >>>  obj-$(CONFIG_CLKSRC_OF)	+= clksrc-of.o
> >>>  obj-$(CONFIG_ATMEL_TCB_CLKSRC)	+= tcb_clksrc.o
> >>> +obj-$(CONFIG_AT91_SAM9_TIME)	+= at91sam926x_time.o
> >> I would rename both Kconfig and source file name into ATMEL_PIT and
> >> atmel_pit.c (or AT91_PIT and atmel_pit.c) to cleary show that this
> >> driver add support for the PIT block.
> > I actually had the same idea, but older AT91 SoCs (rm9200, for
> > example) also mention the PIT, even though the IP is different.
> 
> I checked at91rm9200 datasheet, and indeed it mention the concept of PIT
> (Periodic Interval Timer), but the HW block is called ST (System Timer).
> 
> How about using the name ATMEL_PIT for this driver and later use
> ATMEL_ST when we decide to move at91rm9200_time.c driver into
> drivers/clocksource ?

Works for me.

Maxime

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2014-06-26 12:55 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-25 13:06 [PATCH 00/13] AT91: PIT: Cleanups and move to drivers/clocksource Maxime Ripard
2014-06-25 13:06 ` [PATCH 01/13] AT91: PIT: Follow the general coding rules Maxime Ripard
2014-06-25 13:06 ` [PATCH 02/13] AT91: generic.h: Add include safe guards Maxime Ripard
2014-06-25 13:06 ` [PATCH 03/13] AT91: PIT: Use of_have_populated_dt instead of CONFIG_OF Maxime Ripard
2014-06-25 13:06 ` [PATCH 04/13] AT91: PIT: Rework probe functions Maxime Ripard
2014-06-25 13:06 ` [PATCH 05/13] AT91: dt: Remove init_time definitions Maxime Ripard
2014-06-25 13:06 ` [PATCH 06/13] AT91: PIT: Use consistent exit path in probe Maxime Ripard
2014-06-25 13:06 ` [PATCH 07/13] AT91: PIT: Use pr_fmt Maxime Ripard
2014-06-25 13:06 ` [PATCH 08/13] AT91: PIT: use request_irq instead of setup_irq Maxime Ripard
2014-06-25 13:06 ` [PATCH 09/13] AT91: PIT: (Almost) remove the global variables Maxime Ripard
2014-06-26  5:12   ` Boris BREZILLON
2014-06-26  9:28     ` Maxime Ripard
2014-06-25 13:06 ` [PATCH 10/13] AT91: soc: Add init_time callback Maxime Ripard
2014-06-25 13:06 ` [PATCH 11/13] AT91: Convert the boards to the " Maxime Ripard
2014-06-25 13:06 ` [PATCH 12/13] AT91: PIT: Convert to an early_platform_device Maxime Ripard
2014-06-25 13:06 ` [PATCH 13/13] AT91: PIT: Move the driver to drivers/clocksource Maxime Ripard
2014-06-26  5:26   ` Boris BREZILLON
2014-06-26  9:30     ` Maxime Ripard
2014-06-26 11:48       ` Boris BREZILLON
2014-06-26 12:54         ` Maxime Ripard
2014-06-26  5:30 ` [PATCH 00/13] AT91: PIT: Cleanups and move " Boris BREZILLON

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