Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1422861 > unrolled thread

[PATCH v3 0/2] clocksource: Add support for Oxford Semiconductor RPS Dual Timer

Started byNeil Armstrong <narmstrong@baylibre.com>
First post2016-06-15 12:20 +0200
Last post2016-06-15 12:20 +0200
Articles 8 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v3 0/2] clocksource: Add support for Oxford Semiconductor RPS Dual Timer Neil Armstrong <narmstrong@baylibre.com> - 2016-06-15 12:20 +0200
    [PATCH v3 2/2] dt-bindings: clocksource: Add Add Oxford Semiconductor RPS Timer bindings Neil Armstrong <narmstrong@baylibre.com> - 2016-06-15 12:20 +0200
      Re: [PATCH v3 2/2] dt-bindings: clocksource: Add Add Oxford  Semiconductor RPS Timer bindings Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-15 12:30 +0200
        Re: [PATCH v3 2/2] dt-bindings: clocksource: Add Add Oxford  Semiconductor RPS Timer bindings Neil Armstrong <narmstrong@baylibre.com> - 2016-06-15 12:40 +0200
        Re: [PATCH v3 2/2] dt-bindings: clocksource: Add Add Oxford  Semiconductor RPS Timer bindings Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-16 17:10 +0200
        Re: [PATCH v3 2/2] dt-bindings: clocksource: Add Add Oxford  Semiconductor RPS Timer bindings Neil Armstrong <narmstrong@baylibre.com> - 2016-06-16 17:10 +0200
      Re: [PATCH v3 2/2] dt-bindings: clocksource: Add Add Oxford  Semiconductor RPS Timer bindings Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-15 12:30 +0200
    [PATCH v3 1/2] clocksource: Add Oxford Semiconductor RPS Dual Timer Neil Armstrong <narmstrong@baylibre.com> - 2016-06-15 12:20 +0200

#1422861 — [PATCH v3 0/2] clocksource: Add support for Oxford Semiconductor RPS Dual Timer

FromNeil Armstrong <narmstrong@baylibre.com>
Date2016-06-15 12:20 +0200
Subject[PATCH v3 0/2] clocksource: Add support for Oxford Semiconductor RPS Dual Timer
Message-ID<rKg5r-1fI-1@gated-at.bofh.it>
Adds driver for the Oxford Semiconductor RPS Dual Timer as base of the OX810SE
clock tick event and sched clock source.

This driver was posted with the initial OX810SE platform patchset at :
http://lkml.kernel.org/r/1457005210-18485-5-git-send-email-narmstrong@baylibre.com
and
http://lkml.kernel.org/r/1457005210-18485-6-git-send-email-narmstrong@baylibre.com

But since the SP804 was very similar, I decided to adapt it for OX810SE usage.
For some reasons, the SP804 has a lot of legacy code for non-dt, non-multiarch
platforms and needs a complete rewrite.
For now, this adds a dedicated driver with the same bindings as intended for SP804.

Changes since v2 at http://lkml.kernel.org/r/1465315452-20599-1-git-send-email-narmstrong@baylibre.com :
- Add Kconfig text with COMPILE_TEST options
- Add CLKSRC_OF select
- Add clean rollback of init in case of error
- Prepare for clocksource and clockevent rollback by returning an int value
- Switch kzalloc WARN_ON to a pr_err

Changes since v1 at http://lkml.kernel.org/r/1464688198-9655-1-git-send-email-narmstrong@baylibre.com :
- fix timer_shutdown behaviour
- clean up period calculation

Neil Armstrong (2):
  clocksource: Add Oxford Semiconductor RPS Dual Timer
  dt-bindings: clocksource: Add Add Oxford Semiconductor RPS Timer
    bindings

 .../devicetree/bindings/timer/oxsemi,rps-timer.txt |  17 ++
 drivers/clocksource/Kconfig                        |   7 +
 drivers/clocksource/Makefile                       |   1 +
 drivers/clocksource/timer-oxnas-rps.c              | 290 +++++++++++++++++++++
 4 files changed, 315 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/oxsemi,rps-timer.txt
 create mode 100644 drivers/clocksource/timer-oxnas-rps.c

-- 
1.9.1

[toc] | [next] | [standalone]


#1422862 — [PATCH v3 2/2] dt-bindings: clocksource: Add Add Oxford Semiconductor RPS Timer bindings

FromNeil Armstrong <narmstrong@baylibre.com>
Date2016-06-15 12:20 +0200
Subject[PATCH v3 2/2] dt-bindings: clocksource: Add Add Oxford Semiconductor RPS Timer bindings
Message-ID<rKg5r-1fI-7@gated-at.bofh.it>
In reply to#1422861
Add DT bindings for the Oxford Semiconductor RPS dual Timer.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 .../devicetree/bindings/timer/oxsemi,rps-timer.txt      | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/oxsemi,rps-timer.txt

diff --git a/Documentation/devicetree/bindings/timer/oxsemi,rps-timer.txt b/Documentation/devicetree/bindings/timer/oxsemi,rps-timer.txt
new file mode 100644
index 0000000..3ca89cd
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/oxsemi,rps-timer.txt
@@ -0,0 +1,17 @@
+Oxford Semiconductor OXNAS SoCs Family RPS Timer
+================================================
+
+Required properties:
+- compatible: Should be "oxsemi,ox810se-rps-timer"
+- reg : Specifies base physical address and size of the registers.
+- interrupts : The interrupts of the two timers
+- clocks : The phandle of the timer clock source
+
+example:
+
+timer0: timer@200 {
+	compatible = "oxsemi,ox810se-rps-timer";
+	reg = <0x200 0x40>;
+	clocks = <&rpsclk>;
+	interrupts = <4 5>;
+};
-- 
1.9.1

[toc] | [prev] | [next] | [standalone]


#1422884 — Re: [PATCH v3 2/2] dt-bindings: clocksource: Add Add Oxford Semiconductor RPS Timer bindings

FromDaniel Lezcano <daniel.lezcano@linaro.org>
Date2016-06-15 12:30 +0200
SubjectRe: [PATCH v3 2/2] dt-bindings: clocksource: Add Add Oxford Semiconductor RPS Timer bindings
Message-ID<rKgfd-1jj-19@gated-at.bofh.it>
In reply to#1422862
On 06/15/2016 12:23 PM, Daniel Lezcano wrote:
> On 06/15/2016 12:13 PM, Neil Armstrong wrote:
>> Add DT bindings for the Oxford Semiconductor RPS dual Timer.
>>
>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>> ---
>
> Waiting for Rob's acked before picking the series.

Ok, Rob already acked this patch in the V2.

I will take these patches in my tree.

Thanks.

   -- Daniel

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

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

[toc] | [prev] | [next] | [standalone]


#1422896 — Re: [PATCH v3 2/2] dt-bindings: clocksource: Add Add Oxford Semiconductor RPS Timer bindings

FromNeil Armstrong <narmstrong@baylibre.com>
Date2016-06-15 12:40 +0200
SubjectRe: [PATCH v3 2/2] dt-bindings: clocksource: Add Add Oxford Semiconductor RPS Timer bindings
Message-ID<rKgoN-1mz-9@gated-at.bofh.it>
In reply to#1422884
On 06/15/2016 12:26 PM, Daniel Lezcano wrote:
> On 06/15/2016 12:23 PM, Daniel Lezcano wrote:
>> On 06/15/2016 12:13 PM, Neil Armstrong wrote:
>>> Add DT bindings for the Oxford Semiconductor RPS dual Timer.
>>>
>>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>>> ---
>>
>> Waiting for Rob's acked before picking the series.
> 
> Ok, Rob already acked this patch in the V2.
> 
> I will take these patches in my tree.
> 
> Thanks.
> 
>   -- Daniel
> 

Yes, I must fix this, I keep dropping these Acks.

Thanks Daniel,

Neil

[toc] | [prev] | [next] | [standalone]


#1424164 — Re: [PATCH v3 2/2] dt-bindings: clocksource: Add Add Oxford Semiconductor RPS Timer bindings

FromDaniel Lezcano <daniel.lezcano@linaro.org>
Date2016-06-16 17:10 +0200
SubjectRe: [PATCH v3 2/2] dt-bindings: clocksource: Add Add Oxford Semiconductor RPS Timer bindings
Message-ID<rKH5E-1u6-7@gated-at.bofh.it>
In reply to#1422884
On 06/16/2016 05:01 PM, Neil Armstrong wrote:
> On 06/15/2016 12:26 PM, Daniel Lezcano wrote:
>> On 06/15/2016 12:23 PM, Daniel Lezcano wrote:
>>> On 06/15/2016 12:13 PM, Neil Armstrong wrote:
>>>> Add DT bindings for the Oxford Semiconductor RPS dual Timer.
>>>>
>>>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>>>> ---
>>>
>>> Waiting for Rob's acked before picking the series.
>>
>> Ok, Rob already acked this patch in the V2.
>>
>> I will take these patches in my tree.
>>
>> Thanks.
>>
>>    -- Daniel
>>
>
> OK, Do I need to send a v4, a simple patch fixing the Kconfig or can you change it while pushing to your branch ?

I will do the change myself, that will be simpler.

   -- Daniel



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

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

[toc] | [prev] | [next] | [standalone]


#1424167 — Re: [PATCH v3 2/2] dt-bindings: clocksource: Add Add Oxford Semiconductor RPS Timer bindings

FromNeil Armstrong <narmstrong@baylibre.com>
Date2016-06-16 17:10 +0200
SubjectRe: [PATCH v3 2/2] dt-bindings: clocksource: Add Add Oxford Semiconductor RPS Timer bindings
Message-ID<rKH5E-1u6-9@gated-at.bofh.it>
In reply to#1422884
On 06/15/2016 12:26 PM, Daniel Lezcano wrote:
> On 06/15/2016 12:23 PM, Daniel Lezcano wrote:
>> On 06/15/2016 12:13 PM, Neil Armstrong wrote:
>>> Add DT bindings for the Oxford Semiconductor RPS dual Timer.
>>>
>>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>>> ---
>>
>> Waiting for Rob's acked before picking the series.
> 
> Ok, Rob already acked this patch in the V2.
> 
> I will take these patches in my tree.
> 
> Thanks.
> 
>   -- Daniel
> 

OK, Do I need to send a v4, a simple patch fixing the Kconfig or can you change it while pushing to your branch ?

Thanks,
Neil

[toc] | [prev] | [next] | [standalone]


#1422888 — Re: [PATCH v3 2/2] dt-bindings: clocksource: Add Add Oxford Semiconductor RPS Timer bindings

FromDaniel Lezcano <daniel.lezcano@linaro.org>
Date2016-06-15 12:30 +0200
SubjectRe: [PATCH v3 2/2] dt-bindings: clocksource: Add Add Oxford Semiconductor RPS Timer bindings
Message-ID<rKgfd-1jj-21@gated-at.bofh.it>
In reply to#1422862
On 06/15/2016 12:13 PM, Neil Armstrong wrote:
> Add DT bindings for the Oxford Semiconductor RPS dual Timer.
>
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---

Waiting for Rob's acked before picking the series.

Thanks !

   -- Daniel


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

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

[toc] | [prev] | [next] | [standalone]


#1422869 — [PATCH v3 1/2] clocksource: Add Oxford Semiconductor RPS Dual Timer

FromNeil Armstrong <narmstrong@baylibre.com>
Date2016-06-15 12:20 +0200
Subject[PATCH v3 1/2] clocksource: Add Oxford Semiconductor RPS Dual Timer
Message-ID<rKg5r-1fI-23@gated-at.bofh.it>
In reply to#1422861
Add clocksource and clockevent driver from dual RPS timer.
The HW provides a dual one-shot or periodic 24bit timers,
the drivers set the first one as tick event source and the
second as a continuous scheduler clock source.
The timer can use 1, 16 or 256 as pre-dividers, thus the
clocksource uses 16 by default.

CC: Ma Haijun <mahaijuns@gmail.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 drivers/clocksource/Kconfig           |   7 +
 drivers/clocksource/Makefile          |   1 +
 drivers/clocksource/timer-oxnas-rps.c | 290 ++++++++++++++++++++++++++++++++++
 3 files changed, 298 insertions(+)
 create mode 100644 drivers/clocksource/timer-oxnas-rps.c

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 47352d2..7e937e1 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -293,6 +293,13 @@ config VF_PIT_TIMER
 	help
 	  Support for Period Interrupt Timer on Freescale Vybrid Family SoCs.
 
+config OXNAS_RPS_TIMER
+	bool "Oxford Semiconductor OXNAS RPS Timers driver" if COMPILE_TEST
+	select CLKSRC_OF
+	select CLKSRC_MMIO
+	help
+	  This enables support for the Oxford Semiconductor OXNAS RPS timers.
+
 config SYS_SUPPORTS_SH_CMT
         bool
 
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 473974f..bc66981 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -48,6 +48,7 @@ obj-$(CONFIG_MTK_TIMER)		+= mtk_timer.o
 obj-$(CONFIG_CLKSRC_PISTACHIO)	+= time-pistachio.o
 obj-$(CONFIG_CLKSRC_TI_32K)	+= timer-ti-32k.o
 obj-$(CONFIG_CLKSRC_NPS)	+= timer-nps.o
+obj-$(CONFIG_OXNAS_RPS_TIMER)	+= timer-oxnas-rps.o
 
 obj-$(CONFIG_ARM_ARCH_TIMER)		+= arm_arch_timer.o
 obj-$(CONFIG_ARM_GLOBAL_TIMER)		+= arm_global_timer.o
diff --git a/drivers/clocksource/timer-oxnas-rps.c b/drivers/clocksource/timer-oxnas-rps.c
new file mode 100644
index 0000000..c002e99
--- /dev/null
+++ b/drivers/clocksource/timer-oxnas-rps.c
@@ -0,0 +1,290 @@
+/*
+ * drivers/clocksource/timer-oxnas-rps.c
+ *
+ * Copyright (C) 2009 Oxford Semiconductor Ltd
+ * Copyright (C) 2013 Ma Haijun <mahaijuns@gmail.com>
+ * Copyright (C) 2016 Neil Armstrong <narmstrong@baylibre.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define pr_fmt(fmt)	KBUILD_MODNAME ": " fmt
+
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/io.h>
+#include <linux/clk.h>
+#include <linux/slab.h>
+#include <linux/interrupt.h>
+#include <linux/of_irq.h>
+#include <linux/of_address.h>
+#include <linux/clockchips.h>
+#include <linux/sched_clock.h>
+
+/* TIMER1 used as tick
+ * TIMER2 used as clocksource
+ */
+
+/* Registers definitions */
+
+#define TIMER_LOAD_REG		0x0
+#define TIMER_CURR_REG		0x4
+#define TIMER_CTRL_REG		0x8
+#define TIMER_CLRINT_REG	0xC
+
+#define TIMER_BITS		24
+
+#define TIMER_MAX_VAL		(BIT(TIMER_BITS) - 1)
+
+#define TIMER_PERIODIC		BIT(6)
+#define TIMER_ENABLE		BIT(7)
+
+#define TIMER_DIV1		(0)
+#define TIMER_DIV16		(1 << 2)
+#define TIMER_DIV256		(2 << 2)
+
+#define TIMER1_REG_OFFSET	0
+#define TIMER2_REG_OFFSET	0x20
+
+/* Clockevent & Clocksource data */
+
+struct oxnas_rps_timer {
+	struct clock_event_device clkevent;
+	void __iomem *clksrc_base;
+	void __iomem *clkevt_base;
+	unsigned long timer_period;
+	unsigned int timer_prescaler;
+	struct clk *clk;
+	int irq;
+};
+
+static irqreturn_t oxnas_rps_timer_irq(int irq, void *dev_id)
+{
+	struct oxnas_rps_timer *rps = dev_id;
+
+	writel_relaxed(0, rps->clkevt_base + TIMER_CLRINT_REG);
+
+	rps->clkevent.event_handler(&rps->clkevent);
+
+	return IRQ_HANDLED;
+}
+
+static void oxnas_rps_timer_config(struct oxnas_rps_timer *rps,
+				   unsigned long period,
+				   unsigned int periodic)
+{
+	uint32_t cfg = rps->timer_prescaler;
+
+	if (period)
+		cfg |= TIMER_ENABLE;
+
+	if (periodic)
+		cfg |= TIMER_PERIODIC;
+
+	writel_relaxed(period, rps->clkevt_base + TIMER_LOAD_REG);
+	writel_relaxed(cfg, rps->clkevt_base + TIMER_CTRL_REG);
+}
+
+static int oxnas_rps_timer_shutdown(struct clock_event_device *evt)
+{
+	struct oxnas_rps_timer *rps =
+		container_of(evt, struct oxnas_rps_timer, clkevent);
+
+	oxnas_rps_timer_config(rps, 0, 0);
+
+	return 0;
+}
+
+static int oxnas_rps_timer_set_periodic(struct clock_event_device *evt)
+{
+	struct oxnas_rps_timer *rps =
+		container_of(evt, struct oxnas_rps_timer, clkevent);
+
+	oxnas_rps_timer_config(rps, rps->timer_period, 1);
+
+	return 0;
+}
+
+static int oxnas_rps_timer_set_oneshot(struct clock_event_device *evt)
+{
+	struct oxnas_rps_timer *rps =
+		container_of(evt, struct oxnas_rps_timer, clkevent);
+
+	oxnas_rps_timer_config(rps, rps->timer_period, 0);
+
+	return 0;
+}
+
+static int oxnas_rps_timer_next_event(unsigned long delta,
+				struct clock_event_device *evt)
+{
+	struct oxnas_rps_timer *rps =
+		container_of(evt, struct oxnas_rps_timer, clkevent);
+
+	oxnas_rps_timer_config(rps, delta, 0);
+
+	return 0;
+}
+
+static int __init oxnas_rps_clockevent_init(struct oxnas_rps_timer *rps)
+{
+	ulong clk_rate = clk_get_rate(rps->clk);
+	ulong timer_rate;
+
+	/* Start with prescaler 1 */
+	rps->timer_prescaler = TIMER_DIV1;
+	rps->timer_period = DIV_ROUND_UP(clk_rate, HZ);
+	timer_rate = clk_rate;
+
+	if (rps->timer_period > TIMER_MAX_VAL) {
+		rps->timer_prescaler = TIMER_DIV16;
+		timer_rate = clk_rate / 16;
+		rps->timer_period = DIV_ROUND_UP(timer_rate, HZ);
+	}
+	if (rps->timer_period > TIMER_MAX_VAL) {
+		rps->timer_prescaler = TIMER_DIV256;
+		timer_rate = clk_rate / 256;
+		rps->timer_period = DIV_ROUND_UP(timer_rate, HZ);
+	}
+
+	rps->clkevent.name = "oxnas-rps";
+	rps->clkevent.features = CLOCK_EVT_FEAT_PERIODIC |
+				 CLOCK_EVT_FEAT_ONESHOT |
+				 CLOCK_EVT_FEAT_DYNIRQ;
+	rps->clkevent.tick_resume = oxnas_rps_timer_shutdown;
+	rps->clkevent.set_state_shutdown = oxnas_rps_timer_shutdown;
+	rps->clkevent.set_state_periodic = oxnas_rps_timer_set_periodic;
+	rps->clkevent.set_state_oneshot = oxnas_rps_timer_set_oneshot;
+	rps->clkevent.set_next_event = oxnas_rps_timer_next_event;
+	rps->clkevent.rating = 200;
+	rps->clkevent.cpumask = cpu_possible_mask;
+	rps->clkevent.irq = rps->irq;
+	clockevents_config_and_register(&rps->clkevent,
+					timer_rate,
+					1,
+					TIMER_MAX_VAL);
+
+	pr_info("Registered clock event rate %luHz prescaler %x period %lu\n",
+			clk_rate,
+			rps->timer_prescaler,
+			rps->timer_period);
+
+	return 0;
+}
+
+/* Clocksource */
+
+static void __iomem *timer_sched_base;
+
+static u64 notrace oxnas_rps_read_sched_clock(void)
+{
+	return ~readl_relaxed(timer_sched_base);
+}
+
+static int __init oxnas_rps_clocksource_init(struct oxnas_rps_timer *rps)
+{
+	ulong clk_rate = clk_get_rate(rps->clk);
+	int ret;
+
+	/* use prescale 16 */
+	clk_rate = clk_rate / 16;
+
+	writel_relaxed(TIMER_MAX_VAL, rps->clksrc_base + TIMER_LOAD_REG);
+	writel_relaxed(TIMER_PERIODIC | TIMER_ENABLE | TIMER_DIV16,
+			rps->clksrc_base + TIMER_CTRL_REG);
+
+	timer_sched_base = rps->clksrc_base + TIMER_CURR_REG;
+	sched_clock_register(oxnas_rps_read_sched_clock,
+			     TIMER_BITS, clk_rate);
+	ret = clocksource_mmio_init(timer_sched_base,
+				    "oxnas_rps_clocksource_timer",
+				    clk_rate, 250, TIMER_BITS,
+				    clocksource_mmio_readl_down);
+	if (WARN_ON(ret)) {
+		pr_err("can't register clocksource\n");
+		return ret;
+	}
+
+	pr_info("Registered clocksource rate %luHz\n", clk_rate);
+
+	return 0;
+}
+
+static void __init oxnas_rps_timer_init(struct device_node *np)
+{
+	struct oxnas_rps_timer *rps;
+	void __iomem *base;
+	int ret;
+
+	rps = kzalloc(sizeof(*rps), GFP_KERNEL);
+	if (!rps) {
+		pr_err("Failed to allocate rps structure\n");
+		return;
+	}
+
+	rps->clk = of_clk_get(np, 0);
+	if (WARN_ON(IS_ERR(rps->clk)))
+		goto err_alloc;
+
+	if (WARN_ON(clk_prepare_enable(rps->clk)))
+		goto err_clk;
+
+	base = of_iomap(np, 0);
+	if (WARN_ON(!base))
+		goto err_clk_prepare;
+
+	rps->irq = irq_of_parse_and_map(np, 0);
+	if (WARN_ON(rps->irq < 0))
+		goto err_iomap;
+
+	rps->clkevt_base = base + TIMER1_REG_OFFSET;
+	rps->clksrc_base = base + TIMER2_REG_OFFSET;
+
+	/* Disable timers */
+	writel_relaxed(0, rps->clkevt_base + TIMER_CTRL_REG);
+	writel_relaxed(0, rps->clksrc_base + TIMER_CTRL_REG);
+	writel_relaxed(0, rps->clkevt_base + TIMER_LOAD_REG);
+	writel_relaxed(0, rps->clksrc_base + TIMER_LOAD_REG);
+	writel_relaxed(0, rps->clkevt_base + TIMER_CLRINT_REG);
+	writel_relaxed(0, rps->clksrc_base + TIMER_CLRINT_REG);
+
+	ret = request_irq(rps->irq, oxnas_rps_timer_irq,
+			  IRQF_TIMER | IRQF_IRQPOLL,
+			  "rps-timer", rps);
+	if (WARN_ON(ret))
+		goto err_iomap;
+
+	ret = oxnas_rps_clocksource_init(rps);
+	if (ret)
+		goto err_irqreq;
+
+	ret = oxnas_rps_clockevent_init(rps);
+	if (ret)
+		goto err_irqreq;
+
+	return;
+
+err_irqreq:
+	free_irq(rps->irq, rps);
+err_iomap:
+	iounmap(base);
+err_clk_prepare:
+	clk_disable_unprepare(rps->clk);
+err_clk:
+	clk_put(rps->clk);
+err_alloc:
+	kfree(rps);
+}
+
+CLOCKSOURCE_OF_DECLARE(ox810se_rps,
+		       "oxsemi,ox810se-rps-timer", oxnas_rps_timer_init);
-- 
1.9.1

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web