linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] clocksource: sp804: Add OX810SE 24bit mode Support
@ 2016-04-01 14:22 Neil Armstrong
  2016-04-01 14:22 ` [PATCH 1/2] clocksource: sp804: Add support for OX810SE 24bit timer width Neil Armstrong
  2016-04-01 14:22 ` [PATCH 2/2] dt-bindings: timer: sp804: add new compatible for OX810SE SoC Neil Armstrong
  0 siblings, 2 replies; 10+ messages in thread
From: Neil Armstrong @ 2016-04-01 14:22 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, daniel.lezcano, tglx, rmk+kernel,
	sudeep.holla
  Cc: Neil Armstrong

This patchset includes support for Oxford Semiconductor OX810SE SoC by adding
variable width support. It selects the 24bit mode with a new compatible string.

It adds a timer_sp804 structure used to configure the clocksource and
clockevents.

It was originally posted part of a platform patchset available here :
http://lkml.kernel.org/r/1458838215-23314-1-git-send-email-narmstrong@baylibre.com

Changes this v3 patchset :
- Get rid of PLX Technology, replace by Oxford Semiconductor
- Switch to timer_sp804 structure to configure clocksource and clockevents

Neil Armstrong (2):
  clocksource: sp804: Add support for OX810SE 24bit timer width
  dt-bindings: timer: sp804: add new compatible for OX810SE SoC

 .../devicetree/bindings/timer/arm,sp804.txt        |   2 +-
 drivers/clocksource/timer-sp804.c                  | 107 +++++++++++++--------
 include/clocksource/timer-sp804.h                  |  42 ++++++--
 3 files changed, 103 insertions(+), 48 deletions(-)

-- 
1.9.1

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

* [PATCH 1/2] clocksource: sp804: Add support for OX810SE 24bit timer width
  2016-04-01 14:22 [PATCH 0/2] clocksource: sp804: Add OX810SE 24bit mode Support Neil Armstrong
@ 2016-04-01 14:22 ` Neil Armstrong
  2016-04-01 15:33   ` Mathieu Poirier
  2016-04-22  7:46   ` Daniel Lezcano
  2016-04-01 14:22 ` [PATCH 2/2] dt-bindings: timer: sp804: add new compatible for OX810SE SoC Neil Armstrong
  1 sibling, 2 replies; 10+ messages in thread
From: Neil Armstrong @ 2016-04-01 14:22 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, daniel.lezcano, tglx, rmk+kernel,
	sudeep.holla
  Cc: Neil Armstrong

In order to support the Dual-Timer on the Oxford Semiconductor OX810SE SoC,
implement variable counter width, keeping 32bit as default width.
Add new compatible string oxsemi,ox810se-rps-timer in order to select
the 24bit counter width.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 drivers/clocksource/timer-sp804.c | 107 ++++++++++++++++++++++++--------------
 include/clocksource/timer-sp804.h |  42 ++++++++++++---
 2 files changed, 102 insertions(+), 47 deletions(-)

diff --git a/drivers/clocksource/timer-sp804.c b/drivers/clocksource/timer-sp804.c
index 5f45b9a..e99269a 100644
--- a/drivers/clocksource/timer-sp804.c
+++ b/drivers/clocksource/timer-sp804.c
@@ -77,15 +77,15 @@ void __init sp804_timer_disable(void __iomem *base)
 	writel(0, base + TIMER_CTRL);
 }
 
-void __init __sp804_clocksource_and_sched_clock_init(void __iomem *base,
-						     const char *name,
-						     struct clk *clk,
-						     int use_sched_clock)
+void __init __sp804_clocksource_and_sched_clock_init(struct timer_sp804 *sp804,
+						     bool use_sched_clock)
 {
 	long rate;
+	u32 config = TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC;
+	struct clk *clk = sp804->clocksource_clk;
 
 	if (!clk) {
-		clk = clk_get_sys("sp804", name);
+		clk = clk_get_sys("sp804", sp804->name);
 		if (IS_ERR(clk)) {
 			pr_err("sp804: clock not found: %d\n",
 			       (int)PTR_ERR(clk));
@@ -98,19 +98,22 @@ void __init __sp804_clocksource_and_sched_clock_init(void __iomem *base,
 	if (rate < 0)
 		return;
 
+	if (sp804->width == 32)
+		config |= TIMER_CTRL_32BIT;
+
 	/* setup timer 0 as free-running clocksource */
-	writel(0, base + TIMER_CTRL);
-	writel(0xffffffff, base + TIMER_LOAD);
-	writel(0xffffffff, base + TIMER_VALUE);
-	writel(TIMER_CTRL_32BIT | TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC,
-		base + TIMER_CTRL);
+	writel(0, sp804->clocksource_base + TIMER_CTRL);
+	writel(0xffffffff, sp804->clocksource_base + TIMER_LOAD);
+	writel(0xffffffff, sp804->clocksource_base + TIMER_VALUE);
+	writel(config, sp804->clocksource_base + TIMER_CTRL);
 
-	clocksource_mmio_init(base + TIMER_VALUE, name,
-		rate, 200, 32, clocksource_mmio_readl_down);
+	clocksource_mmio_init(sp804->clocksource_base + TIMER_VALUE,
+			      sp804->name, rate, 200, sp804->width,
+			      clocksource_mmio_readl_down);
 
 	if (use_sched_clock) {
-		sched_clock_base = base;
-		sched_clock_register(sp804_read, 32, rate);
+		sched_clock_base = sp804->clocksource_base;
+		sched_clock_register(sp804_read, sp804->width, rate);
 	}
 }
 
@@ -186,15 +189,16 @@ static struct irqaction sp804_timer_irq = {
 	.dev_id		= &sp804_clockevent,
 };
 
-void __init __sp804_clockevents_init(void __iomem *base, unsigned int irq, struct clk *clk, const char *name)
+void __init __sp804_clockevents_init(struct timer_sp804 *sp804)
 {
 	struct clock_event_device *evt = &sp804_clockevent;
 	long rate;
+	struct clk *clk = sp804->clockevent_clk;
 
 	if (!clk)
-		clk = clk_get_sys("sp804", name);
+		clk = clk_get_sys("sp804", sp804->name);
 	if (IS_ERR(clk)) {
-		pr_err("sp804: %s clock not found: %d\n", name,
+		pr_err("sp804: %s clock not found: %d\n", sp804->name,
 			(int)PTR_ERR(clk));
 		return;
 	}
@@ -203,26 +207,27 @@ void __init __sp804_clockevents_init(void __iomem *base, unsigned int irq, struc
 	if (rate < 0)
 		return;
 
-	clkevt_base = base;
+	clkevt_base = sp804->clockevent_base;
 	clkevt_reload = DIV_ROUND_CLOSEST(rate, HZ);
-	evt->name = name;
-	evt->irq = irq;
+	evt->name = sp804->name;
+	evt->irq = sp804->irq;
 	evt->cpumask = cpu_possible_mask;
 
-	writel(0, base + TIMER_CTRL);
+	writel(0, sp804->clockevent_base + TIMER_CTRL);
 
-	setup_irq(irq, &sp804_timer_irq);
-	clockevents_config_and_register(evt, rate, 0xf, 0xffffffff);
+	setup_irq(sp804->irq, &sp804_timer_irq);
+	clockevents_config_and_register(evt, rate, 0xf,
+					GENMASK(sp804->width-1, 0));
 }
 
 static void __init sp804_of_init(struct device_node *np)
 {
 	static bool initialized = false;
+	struct timer_sp804 sp804;
 	void __iomem *base;
-	int irq;
 	u32 irq_num = 0;
 	struct clk *clk1, *clk2;
-	const char *name = of_get_property(np, "compatible", NULL);
+	u32 width = 32;
 
 	base = of_iomap(np, 0);
 	if (WARN_ON(!base))
@@ -250,19 +255,33 @@ static void __init sp804_of_init(struct device_node *np)
 	} else
 		clk2 = clk1;
 
-	irq = irq_of_parse_and_map(np, 0);
-	if (irq <= 0)
+	sp804.irq = irq_of_parse_and_map(np, 0);
+	if (sp804.irq <= 0)
 		goto err;
 
+	/* OX810SE Uses a special 24bit width */
+	if (of_device_is_compatible(np, "oxsemi,ox810se-rps-timer"))
+		width = 24;
+
 	of_property_read_u32(np, "arm,sp804-has-irq", &irq_num);
 	if (irq_num == 2) {
-		__sp804_clockevents_init(base + TIMER_2_BASE, irq, clk2, name);
-		__sp804_clocksource_and_sched_clock_init(base, name, clk1, 1);
+		sp804.clockevent_base = base + TIMER_2_BASE;
+		sp804.clocksource_base = base;
+		sp804.clockevent_clk = clk2;
+		sp804.clocksource_clk = clk1;
 	} else {
-		__sp804_clockevents_init(base, irq, clk1 , name);
-		__sp804_clocksource_and_sched_clock_init(base + TIMER_2_BASE,
-							 name, clk2, 1);
+		sp804.clockevent_base = base;
+		sp804.clocksource_base = base + TIMER_2_BASE;
+		sp804.clockevent_clk = clk1;
+		sp804.clocksource_clk = clk2;
 	}
+
+	sp804.name = of_get_property(np, "compatible", NULL);
+	sp804.width = width;
+
+	__sp804_clockevents_init(&sp804);
+	__sp804_clocksource_and_sched_clock_init(&sp804, true);
+
 	initialized = true;
 
 	return;
@@ -270,13 +289,13 @@ err:
 	iounmap(base);
 }
 CLOCKSOURCE_OF_DECLARE(sp804, "arm,sp804", sp804_of_init);
+CLOCKSOURCE_OF_DECLARE(ox810se, "oxsemi,ox810se-rps-timer", sp804_of_init);
 
 static void __init integrator_cp_of_init(struct device_node *np)
 {
 	static int init_count = 0;
+	struct timer_sp804 sp804;
 	void __iomem *base;
-	int irq;
-	const char *name = of_get_property(np, "compatible", NULL);
 	struct clk *clk;
 
 	base = of_iomap(np, 0);
@@ -292,14 +311,22 @@ static void __init integrator_cp_of_init(struct device_node *np)
 	if (init_count == 2 || !of_device_is_available(np))
 		goto err;
 
-	if (!init_count)
-		__sp804_clocksource_and_sched_clock_init(base, name, clk, 0);
-	else {
-		irq = irq_of_parse_and_map(np, 0);
-		if (irq <= 0)
+	sp804.name = of_get_property(np, "compatible", NULL);
+	sp804.width = 32;
+
+	if (!init_count) {
+		sp804.clocksource_base = base;
+		sp804.clocksource_clk = clk;
+
+		__sp804_clocksource_and_sched_clock_init(&sp804, false);
+	} else {
+		sp804.clockevent_base = base;
+		sp804.clockevent_clk = clk;
+		sp804.irq = irq_of_parse_and_map(np, 0);
+		if (sp804.irq <= 0)
 			goto err;
 
-		__sp804_clockevents_init(base, irq, clk, name);
+		__sp804_clockevents_init(&sp804);
 	}
 
 	init_count++;
diff --git a/include/clocksource/timer-sp804.h b/include/clocksource/timer-sp804.h
index 1f8a1ca..928091b 100644
--- a/include/clocksource/timer-sp804.h
+++ b/include/clocksource/timer-sp804.h
@@ -3,26 +3,54 @@
 
 struct clk;
 
-void __sp804_clocksource_and_sched_clock_init(void __iomem *,
-					      const char *, struct clk *, int);
-void __sp804_clockevents_init(void __iomem *, unsigned int,
-			      struct clk *, const char *);
+struct timer_sp804 {
+	void __iomem *clockevent_base;
+	void __iomem *clocksource_base;
+	const char *name;
+	struct clk *clockevent_clk;
+	struct clk *clocksource_clk;
+	unsigned int irq;
+	unsigned int width;
+};
+
+void __sp804_clocksource_and_sched_clock_init(struct timer_sp804 *sp804, bool);
+void __sp804_clockevents_init(struct timer_sp804 *sp804);
 void sp804_timer_disable(void __iomem *);
 
 static inline void sp804_clocksource_init(void __iomem *base, const char *name)
 {
-	__sp804_clocksource_and_sched_clock_init(base, name, NULL, 0);
+	struct timer_sp804 sp804 = {
+		.clocksource_base = base,
+		.name = name,
+		.clocksource_clk = NULL,
+		.width = 32,
+	};
+
+	__sp804_clocksource_and_sched_clock_init(&sp804, false);
 }
 
 static inline void sp804_clocksource_and_sched_clock_init(void __iomem *base,
 							  const char *name)
 {
-	__sp804_clocksource_and_sched_clock_init(base, name, NULL, 1);
+	struct timer_sp804 sp804 = {
+		.clocksource_base = base,
+		.name = name,
+		.clocksource_clk = NULL,
+		.width = 32,
+	};
+
+	__sp804_clocksource_and_sched_clock_init(&sp804, true);
 }
 
 static inline void sp804_clockevents_init(void __iomem *base, unsigned int irq, const char *name)
 {
-	__sp804_clockevents_init(base, irq, NULL, name);
+	struct timer_sp804 sp804 = {
+		.clockevent_base = base,
+		.name = name,
+		.clockevent_clk = NULL,
+		.width = 32,
+	};
 
+	__sp804_clockevents_init(&sp804);
 }
 #endif
-- 
1.9.1

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

* [PATCH 2/2] dt-bindings: timer: sp804: add new compatible for OX810SE SoC
  2016-04-01 14:22 [PATCH 0/2] clocksource: sp804: Add OX810SE 24bit mode Support Neil Armstrong
  2016-04-01 14:22 ` [PATCH 1/2] clocksource: sp804: Add support for OX810SE 24bit timer width Neil Armstrong
@ 2016-04-01 14:22 ` Neil Armstrong
  1 sibling, 0 replies; 10+ messages in thread
From: Neil Armstrong @ 2016-04-01 14:22 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, daniel.lezcano, tglx, rmk+kernel,
	sudeep.holla, devicetree
  Cc: Neil Armstrong

Add new oxsemi,ox810se-rps-timer compatible string to support the
Oxford Semiconductor OX810SE SoC Dual Timers variant.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 Documentation/devicetree/bindings/timer/arm,sp804.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/timer/arm,sp804.txt b/Documentation/devicetree/bindings/timer/arm,sp804.txt
index 5cd8eee7..ebe8753 100644
--- a/Documentation/devicetree/bindings/timer/arm,sp804.txt
+++ b/Documentation/devicetree/bindings/timer/arm,sp804.txt
@@ -2,7 +2,7 @@ ARM sp804 Dual Timers
 ---------------------------------------
 
 Required properties:
-- compatible: Should be "arm,sp804" & "arm,primecell"
+- compatible: Should be "arm,sp804" & "arm,primecell", or "oxsemi,ox810se-rps-timer"
 - interrupts: Should contain the list of Dual Timer interrupts. This is the
 	interrupt for timer 1 and timer 2. In the case of a single entry, it is
 	the combined interrupt or if "arm,sp804-has-irq" is present that
-- 
1.9.1

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

* Re: [PATCH 1/2] clocksource: sp804: Add support for OX810SE 24bit timer width
  2016-04-01 14:22 ` [PATCH 1/2] clocksource: sp804: Add support for OX810SE 24bit timer width Neil Armstrong
@ 2016-04-01 15:33   ` Mathieu Poirier
  2016-04-16 19:07     ` Neil Armstrong
  2016-04-22  7:46   ` Daniel Lezcano
  1 sibling, 1 reply; 10+ messages in thread
From: Mathieu Poirier @ 2016-04-01 15:33 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: linux-kernel, linux-arm-kernel, Daniel Lezcano, tglx,
	Russell King, Sudeep Holla

On 1 April 2016 at 08:22, Neil Armstrong <narmstrong@baylibre.com> wrote:
> In order to support the Dual-Timer on the Oxford Semiconductor OX810SE SoC,
> implement variable counter width, keeping 32bit as default width.
> Add new compatible string oxsemi,ox810se-rps-timer in order to select
> the 24bit counter width.
>
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>  drivers/clocksource/timer-sp804.c | 107 ++++++++++++++++++++++++--------------
>  include/clocksource/timer-sp804.h |  42 ++++++++++++---
>  2 files changed, 102 insertions(+), 47 deletions(-)
>
> diff --git a/drivers/clocksource/timer-sp804.c b/drivers/clocksource/timer-sp804.c
> index 5f45b9a..e99269a 100644
> --- a/drivers/clocksource/timer-sp804.c
> +++ b/drivers/clocksource/timer-sp804.c
> @@ -77,15 +77,15 @@ void __init sp804_timer_disable(void __iomem *base)
>         writel(0, base + TIMER_CTRL);
>  }
>
> -void __init __sp804_clocksource_and_sched_clock_init(void __iomem *base,
> -                                                    const char *name,
> -                                                    struct clk *clk,
> -                                                    int use_sched_clock)
> +void __init __sp804_clocksource_and_sched_clock_init(struct timer_sp804 *sp804,
> +                                                    bool use_sched_clock)
>  {
>         long rate;
> +       u32 config = TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC;
> +       struct clk *clk = sp804->clocksource_clk;
>
>         if (!clk) {
> -               clk = clk_get_sys("sp804", name);
> +               clk = clk_get_sys("sp804", sp804->name);
>                 if (IS_ERR(clk)) {
>                         pr_err("sp804: clock not found: %d\n",
>                                (int)PTR_ERR(clk));
> @@ -98,19 +98,22 @@ void __init __sp804_clocksource_and_sched_clock_init(void __iomem *base,
>         if (rate < 0)
>                 return;
>
> +       if (sp804->width == 32)
> +               config |= TIMER_CTRL_32BIT;
> +
>         /* setup timer 0 as free-running clocksource */
> -       writel(0, base + TIMER_CTRL);
> -       writel(0xffffffff, base + TIMER_LOAD);
> -       writel(0xffffffff, base + TIMER_VALUE);
> -       writel(TIMER_CTRL_32BIT | TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC,
> -               base + TIMER_CTRL);
> +       writel(0, sp804->clocksource_base + TIMER_CTRL);
> +       writel(0xffffffff, sp804->clocksource_base + TIMER_LOAD);
> +       writel(0xffffffff, sp804->clocksource_base + TIMER_VALUE);
> +       writel(config, sp804->clocksource_base + TIMER_CTRL);
>
> -       clocksource_mmio_init(base + TIMER_VALUE, name,
> -               rate, 200, 32, clocksource_mmio_readl_down);
> +       clocksource_mmio_init(sp804->clocksource_base + TIMER_VALUE,
> +                             sp804->name, rate, 200, sp804->width,
> +                             clocksource_mmio_readl_down);
>
>         if (use_sched_clock) {
> -               sched_clock_base = base;
> -               sched_clock_register(sp804_read, 32, rate);
> +               sched_clock_base = sp804->clocksource_base;
> +               sched_clock_register(sp804_read, sp804->width, rate);
>         }
>  }
>
> @@ -186,15 +189,16 @@ static struct irqaction sp804_timer_irq = {
>         .dev_id         = &sp804_clockevent,
>  };
>
> -void __init __sp804_clockevents_init(void __iomem *base, unsigned int irq, struct clk *clk, const char *name)
> +void __init __sp804_clockevents_init(struct timer_sp804 *sp804)
>  {
>         struct clock_event_device *evt = &sp804_clockevent;
>         long rate;
> +       struct clk *clk = sp804->clockevent_clk;
>
>         if (!clk)
> -               clk = clk_get_sys("sp804", name);
> +               clk = clk_get_sys("sp804", sp804->name);
>         if (IS_ERR(clk)) {
> -               pr_err("sp804: %s clock not found: %d\n", name,
> +               pr_err("sp804: %s clock not found: %d\n", sp804->name,
>                         (int)PTR_ERR(clk));
>                 return;
>         }
> @@ -203,26 +207,27 @@ void __init __sp804_clockevents_init(void __iomem *base, unsigned int irq, struc
>         if (rate < 0)
>                 return;
>
> -       clkevt_base = base;
> +       clkevt_base = sp804->clockevent_base;
>         clkevt_reload = DIV_ROUND_CLOSEST(rate, HZ);
> -       evt->name = name;
> -       evt->irq = irq;
> +       evt->name = sp804->name;
> +       evt->irq = sp804->irq;
>         evt->cpumask = cpu_possible_mask;
>
> -       writel(0, base + TIMER_CTRL);
> +       writel(0, sp804->clockevent_base + TIMER_CTRL);
>
> -       setup_irq(irq, &sp804_timer_irq);
> -       clockevents_config_and_register(evt, rate, 0xf, 0xffffffff);
> +       setup_irq(sp804->irq, &sp804_timer_irq);
> +       clockevents_config_and_register(evt, rate, 0xf,
> +                                       GENMASK(sp804->width-1, 0));
>  }
>
>  static void __init sp804_of_init(struct device_node *np)
>  {
>         static bool initialized = false;
> +       struct timer_sp804 sp804;
>         void __iomem *base;
> -       int irq;
>         u32 irq_num = 0;
>         struct clk *clk1, *clk2;
> -       const char *name = of_get_property(np, "compatible", NULL);
> +       u32 width = 32;
>
>         base = of_iomap(np, 0);
>         if (WARN_ON(!base))
> @@ -250,19 +255,33 @@ static void __init sp804_of_init(struct device_node *np)
>         } else
>                 clk2 = clk1;
>
> -       irq = irq_of_parse_and_map(np, 0);
> -       if (irq <= 0)
> +       sp804.irq = irq_of_parse_and_map(np, 0);
> +       if (sp804.irq <= 0)
>                 goto err;
>
> +       /* OX810SE Uses a special 24bit width */
> +       if (of_device_is_compatible(np, "oxsemi,ox810se-rps-timer"))
> +               width = 24;

Wouldn't it be better to add a new optional property for this?  If the
property is not specified then we default to a width of 32.  Otherwise
the new width is configured.  That way we don't have to add a new
compatible string every time (however often) a special width is
encountered.

Otherwise I think the code facelift looks good,
Mathieu

> +
>         of_property_read_u32(np, "arm,sp804-has-irq", &irq_num);
>         if (irq_num == 2) {
> -               __sp804_clockevents_init(base + TIMER_2_BASE, irq, clk2, name);
> -               __sp804_clocksource_and_sched_clock_init(base, name, clk1, 1);
> +               sp804.clockevent_base = base + TIMER_2_BASE;
> +               sp804.clocksource_base = base;
> +               sp804.clockevent_clk = clk2;
> +               sp804.clocksource_clk = clk1;
>         } else {
> -               __sp804_clockevents_init(base, irq, clk1 , name);
> -               __sp804_clocksource_and_sched_clock_init(base + TIMER_2_BASE,
> -                                                        name, clk2, 1);
> +               sp804.clockevent_base = base;
> +               sp804.clocksource_base = base + TIMER_2_BASE;
> +               sp804.clockevent_clk = clk1;
> +               sp804.clocksource_clk = clk2;
>         }
> +
> +       sp804.name = of_get_property(np, "compatible", NULL);
> +       sp804.width = width;
> +
> +       __sp804_clockevents_init(&sp804);
> +       __sp804_clocksource_and_sched_clock_init(&sp804, true);
> +
>         initialized = true;
>
>         return;
> @@ -270,13 +289,13 @@ err:
>         iounmap(base);
>  }
>  CLOCKSOURCE_OF_DECLARE(sp804, "arm,sp804", sp804_of_init);
> +CLOCKSOURCE_OF_DECLARE(ox810se, "oxsemi,ox810se-rps-timer", sp804_of_init);
>
>  static void __init integrator_cp_of_init(struct device_node *np)
>  {
>         static int init_count = 0;
> +       struct timer_sp804 sp804;
>         void __iomem *base;
> -       int irq;
> -       const char *name = of_get_property(np, "compatible", NULL);
>         struct clk *clk;
>
>         base = of_iomap(np, 0);
> @@ -292,14 +311,22 @@ static void __init integrator_cp_of_init(struct device_node *np)
>         if (init_count == 2 || !of_device_is_available(np))
>                 goto err;
>
> -       if (!init_count)
> -               __sp804_clocksource_and_sched_clock_init(base, name, clk, 0);
> -       else {
> -               irq = irq_of_parse_and_map(np, 0);
> -               if (irq <= 0)
> +       sp804.name = of_get_property(np, "compatible", NULL);
> +       sp804.width = 32;
> +
> +       if (!init_count) {
> +               sp804.clocksource_base = base;
> +               sp804.clocksource_clk = clk;
> +
> +               __sp804_clocksource_and_sched_clock_init(&sp804, false);
> +       } else {
> +               sp804.clockevent_base = base;
> +               sp804.clockevent_clk = clk;
> +               sp804.irq = irq_of_parse_and_map(np, 0);
> +               if (sp804.irq <= 0)
>                         goto err;
>
> -               __sp804_clockevents_init(base, irq, clk, name);
> +               __sp804_clockevents_init(&sp804);
>         }
>
>         init_count++;
> diff --git a/include/clocksource/timer-sp804.h b/include/clocksource/timer-sp804.h
> index 1f8a1ca..928091b 100644
> --- a/include/clocksource/timer-sp804.h
> +++ b/include/clocksource/timer-sp804.h
> @@ -3,26 +3,54 @@
>
>  struct clk;
>
> -void __sp804_clocksource_and_sched_clock_init(void __iomem *,
> -                                             const char *, struct clk *, int);
> -void __sp804_clockevents_init(void __iomem *, unsigned int,
> -                             struct clk *, const char *);
> +struct timer_sp804 {
> +       void __iomem *clockevent_base;
> +       void __iomem *clocksource_base;
> +       const char *name;
> +       struct clk *clockevent_clk;
> +       struct clk *clocksource_clk;
> +       unsigned int irq;
> +       unsigned int width;
> +};
> +
> +void __sp804_clocksource_and_sched_clock_init(struct timer_sp804 *sp804, bool);
> +void __sp804_clockevents_init(struct timer_sp804 *sp804);
>  void sp804_timer_disable(void __iomem *);
>
>  static inline void sp804_clocksource_init(void __iomem *base, const char *name)
>  {
> -       __sp804_clocksource_and_sched_clock_init(base, name, NULL, 0);
> +       struct timer_sp804 sp804 = {
> +               .clocksource_base = base,
> +               .name = name,
> +               .clocksource_clk = NULL,
> +               .width = 32,
> +       };
> +
> +       __sp804_clocksource_and_sched_clock_init(&sp804, false);
>  }
>
>  static inline void sp804_clocksource_and_sched_clock_init(void __iomem *base,
>                                                           const char *name)
>  {
> -       __sp804_clocksource_and_sched_clock_init(base, name, NULL, 1);
> +       struct timer_sp804 sp804 = {
> +               .clocksource_base = base,
> +               .name = name,
> +               .clocksource_clk = NULL,
> +               .width = 32,
> +       };
> +
> +       __sp804_clocksource_and_sched_clock_init(&sp804, true);
>  }
>
>  static inline void sp804_clockevents_init(void __iomem *base, unsigned int irq, const char *name)
>  {
> -       __sp804_clockevents_init(base, irq, NULL, name);
> +       struct timer_sp804 sp804 = {
> +               .clockevent_base = base,
> +               .name = name,
> +               .clockevent_clk = NULL,
> +               .width = 32,
> +       };
>
> +       __sp804_clockevents_init(&sp804);
>  }
>  #endif
> --
> 1.9.1
>

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

* Re: [PATCH 1/2] clocksource: sp804: Add support for OX810SE 24bit timer width
  2016-04-01 15:33   ` Mathieu Poirier
@ 2016-04-16 19:07     ` Neil Armstrong
  0 siblings, 0 replies; 10+ messages in thread
From: Neil Armstrong @ 2016-04-16 19:07 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: linux-kernel, linux-arm-kernel, Daniel Lezcano, tglx,
	Russell King, Sudeep Holla

On 04/01/2016 05:33 PM, Mathieu Poirier wrote:
> On 1 April 2016 at 08:22, Neil Armstrong <narmstrong@baylibre.com> wrote:
Hi Matthieu,
Thanks for the review.

>> +       /* OX810SE Uses a special 24bit width */
>> +       if (of_device_is_compatible(np, "oxsemi,ox810se-rps-timer"))
>> +               width = 24;
> 
> Wouldn't it be better to add a new optional property for this?  If the
> property is not specified then we default to a width of 32.  Otherwise
> the new width is configured.  That way we don't have to add a new
> compatible string every time (however often) a special width is
> encountered.
As explained by Rob Herring, this HW is compatible with SP804 but is /not/ an IP from ARM
and has been customized to support 24bit.
Having a DT property for this width is not wanted actually since it makes no sense for the
original SP804 IP, so it should be handled per vendor.

> 
> Otherwise I think the code facelift looks good,
> Mathieu

Is there any other blocking points ?

The point to have a change on sp804 is to economize a new very similar driver for oxnas.

Neil

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

* Re: [PATCH 1/2] clocksource: sp804: Add support for OX810SE 24bit timer width
  2016-04-01 14:22 ` [PATCH 1/2] clocksource: sp804: Add support for OX810SE 24bit timer width Neil Armstrong
  2016-04-01 15:33   ` Mathieu Poirier
@ 2016-04-22  7:46   ` Daniel Lezcano
  2016-04-22  7:53     ` Thomas Gleixner
  1 sibling, 1 reply; 10+ messages in thread
From: Daniel Lezcano @ 2016-04-22  7:46 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: linux-kernel, linux-arm-kernel, tglx, rmk+kernel, sudeep.holla

On Fri, Apr 01, 2016 at 04:22:38PM +0200, Neil Armstrong wrote:
> In order to support the Dual-Timer on the Oxford Semiconductor OX810SE SoC,
> implement variable counter width, keeping 32bit as default width.
> Add new compatible string oxsemi,ox810se-rps-timer in order to select
> the 24bit counter width.
> 
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>  drivers/clocksource/timer-sp804.c | 107 ++++++++++++++++++++++++--------------
>  include/clocksource/timer-sp804.h |  42 ++++++++++++---
>  2 files changed, 102 insertions(+), 47 deletions(-)

I will take those patches but this driver really deserves a cleanup.

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

* Re: [PATCH 1/2] clocksource: sp804: Add support for OX810SE 24bit timer width
  2016-04-22  7:46   ` Daniel Lezcano
@ 2016-04-22  7:53     ` Thomas Gleixner
  2016-04-25 14:48       ` Neil Armstrong
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Gleixner @ 2016-04-22  7:53 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Neil Armstrong, linux-kernel, linux-arm-kernel, rmk+kernel, sudeep.holla

On Fri, 22 Apr 2016, Daniel Lezcano wrote:

> On Fri, Apr 01, 2016 at 04:22:38PM +0200, Neil Armstrong wrote:
> > In order to support the Dual-Timer on the Oxford Semiconductor OX810SE SoC,
> > implement variable counter width, keeping 32bit as default width.
> > Add new compatible string oxsemi,ox810se-rps-timer in order to select
> > the 24bit counter width.
> > 
> > Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> > ---
> >  drivers/clocksource/timer-sp804.c | 107 ++++++++++++++++++++++++--------------
> >  include/clocksource/timer-sp804.h |  42 ++++++++++++---
> >  2 files changed, 102 insertions(+), 47 deletions(-)
> 
> I will take those patches but this driver really deserves a cleanup.

If it deserves a cleanup, then this should happen _BEFORE_ we add new
functionality to it.

Thanks,

	tglx

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

* Re: [PATCH 1/2] clocksource: sp804: Add support for OX810SE 24bit timer width
  2016-04-22  7:53     ` Thomas Gleixner
@ 2016-04-25 14:48       ` Neil Armstrong
  2016-04-26 16:30         ` Daniel Lezcano
  0 siblings, 1 reply; 10+ messages in thread
From: Neil Armstrong @ 2016-04-25 14:48 UTC (permalink / raw)
  To: Thomas Gleixner, Daniel Lezcano
  Cc: linux-kernel, linux-arm-kernel, rmk+kernel, sudeep.holla

On 04/22/2016 09:53 AM, Thomas Gleixner wrote:
> On Fri, 22 Apr 2016, Daniel Lezcano wrote:
> 
>> On Fri, Apr 01, 2016 at 04:22:38PM +0200, Neil Armstrong wrote:
>>> In order to support the Dual-Timer on the Oxford Semiconductor OX810SE SoC,
>>> implement variable counter width, keeping 32bit as default width.
>>> Add new compatible string oxsemi,ox810se-rps-timer in order to select
>>> the 24bit counter width.
>>>
>>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>>> ---
>>>  drivers/clocksource/timer-sp804.c | 107 ++++++++++++++++++++++++--------------
>>>  include/clocksource/timer-sp804.h |  42 ++++++++++++---
>>>  2 files changed, 102 insertions(+), 47 deletions(-)
>>
>> I will take those patches but this driver really deserves a cleanup.
> 
> If it deserves a cleanup, then this should happen _BEFORE_ we add new
> functionality to it.
> 
> Thanks,
> 
> 	tglx
> 

Hi Thomas, Daniel,

Sure this driver should have a cleanup, but it still depends on old legacy vexpress calls.

The reason I submitted a change and a small cleanup over this driver is because the high
similarities of the HW and avoiding adding a brand new driver cloning much of its
functionalities.

I propose to study an eventual cleanup, but could this change be submitted for 4.7 since
it's part of a base platform support serie ?

Thanks,
Neil

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

* Re: [PATCH 1/2] clocksource: sp804: Add support for OX810SE 24bit timer width
  2016-04-25 14:48       ` Neil Armstrong
@ 2016-04-26 16:30         ` Daniel Lezcano
  2016-05-11  7:31           ` Neil Armstrong
  0 siblings, 1 reply; 10+ messages in thread
From: Daniel Lezcano @ 2016-04-26 16:30 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: Thomas Gleixner, linux-kernel, linux-arm-kernel, rmk+kernel,
	sudeep.holla

On Mon, Apr 25, 2016 at 04:48:24PM +0200, Neil Armstrong wrote:
> On 04/22/2016 09:53 AM, Thomas Gleixner wrote:
> > On Fri, 22 Apr 2016, Daniel Lezcano wrote:
> > 
> >> On Fri, Apr 01, 2016 at 04:22:38PM +0200, Neil Armstrong wrote:
> >>> In order to support the Dual-Timer on the Oxford Semiconductor OX810SE SoC,
> >>> implement variable counter width, keeping 32bit as default width.
> >>> Add new compatible string oxsemi,ox810se-rps-timer in order to select
> >>> the 24bit counter width.
> >>>
> >>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> >>> ---
> >>>  drivers/clocksource/timer-sp804.c | 107 ++++++++++++++++++++++++--------------
> >>>  include/clocksource/timer-sp804.h |  42 ++++++++++++---
> >>>  2 files changed, 102 insertions(+), 47 deletions(-)
> >>
> >> I will take those patches but this driver really deserves a cleanup.
> > 
> > If it deserves a cleanup, then this should happen _BEFORE_ we add new
> > functionality to it.
> > 
> > Thanks,
> > 
> > 	tglx
> > 
> 
> Hi Thomas, Daniel,
> 
> Sure this driver should have a cleanup, but it still depends on old legacy vexpress calls.
> 
> The reason I submitted a change and a small cleanup over this driver is because the high
> similarities of the HW and avoiding adding a brand new driver cloning much of its
> functionalities.

Hi Neil,

it is a good idea to avoid having new drivers when it is possible to group 
them into a single one.
 
> I propose to study an eventual cleanup, but could this change be submitted for 4.7 since
> it's part of a base platform support serie ?

I am not against if the next patches you send are cleanups.

Thomas ?

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

* Re: [PATCH 1/2] clocksource: sp804: Add support for OX810SE 24bit timer width
  2016-04-26 16:30         ` Daniel Lezcano
@ 2016-05-11  7:31           ` Neil Armstrong
  0 siblings, 0 replies; 10+ messages in thread
From: Neil Armstrong @ 2016-05-11  7:31 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Daniel Lezcano, linux-kernel, linux-arm-kernel, rmk+kernel, sudeep.holla

On 04/26/2016 06:30 PM, Daniel Lezcano wrote:
> On Mon, Apr 25, 2016 at 04:48:24PM +0200, Neil Armstrong wrote:
>> On 04/22/2016 09:53 AM, Thomas Gleixner wrote:
>>> On Fri, 22 Apr 2016, Daniel Lezcano wrote:
>>>
>>>> On Fri, Apr 01, 2016 at 04:22:38PM +0200, Neil Armstrong wrote:
>>>>> In order to support the Dual-Timer on the Oxford Semiconductor OX810SE SoC,
>>>>> implement variable counter width, keeping 32bit as default width.
>>>>> Add new compatible string oxsemi,ox810se-rps-timer in order to select
>>>>> the 24bit counter width.
>>>>>
>>>>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>>>>> ---
>>>>>  drivers/clocksource/timer-sp804.c | 107 ++++++++++++++++++++++++--------------
>>>>>  include/clocksource/timer-sp804.h |  42 ++++++++++++---
>>>>>  2 files changed, 102 insertions(+), 47 deletions(-)
>>>>
>>>> I will take those patches but this driver really deserves a cleanup.
>>>
>>> If it deserves a cleanup, then this should happen _BEFORE_ we add new
>>> functionality to it.
>>>
>>> Thanks,
>>>
>>> 	tglx
>>>
>>
>> Hi Thomas, Daniel,
>>
>> Sure this driver should have a cleanup, but it still depends on old legacy vexpress calls.
>>
>> The reason I submitted a change and a small cleanup over this driver is because the high
>> similarities of the HW and avoiding adding a brand new driver cloning much of its
>> functionalities.
> 
> Hi Neil,
> 
> it is a good idea to avoid having new drivers when it is possible to group 
> them into a single one.
>  
>> I propose to study an eventual cleanup, but could this change be submitted for 4.7 since
>> it's part of a base platform support serie ?
> 
> I am not against if the next patches you send are cleanups.
> 
> Thomas ?
> 

Hi Thomas,

Is the proposition acceptable ? When this patchset will hit 4.7, I will work on a rework for 4.8.

Thanks,
Neil

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

end of thread, other threads:[~2016-05-11  7:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-01 14:22 [PATCH 0/2] clocksource: sp804: Add OX810SE 24bit mode Support Neil Armstrong
2016-04-01 14:22 ` [PATCH 1/2] clocksource: sp804: Add support for OX810SE 24bit timer width Neil Armstrong
2016-04-01 15:33   ` Mathieu Poirier
2016-04-16 19:07     ` Neil Armstrong
2016-04-22  7:46   ` Daniel Lezcano
2016-04-22  7:53     ` Thomas Gleixner
2016-04-25 14:48       ` Neil Armstrong
2016-04-26 16:30         ` Daniel Lezcano
2016-05-11  7:31           ` Neil Armstrong
2016-04-01 14:22 ` [PATCH 2/2] dt-bindings: timer: sp804: add new compatible for OX810SE SoC Neil Armstrong

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