[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250705160129.3688026-4-daniel.lezcano@linaro.org>
Date: Sat, 5 Jul 2025 18:01:10 +0200
From: Daniel Lezcano <daniel.lezcano@...aro.org>
To: daniel.lezcano@...aro.org,
tglx@...utronix.de
Cc: ghennadi.procopciuc@....nxp.com,
S32@....com,
linux-kernel@...r.kernel.org
Subject: [PATCH 04/20] clocksource/drivers/vf_pit: Rework the base address usage
This change passes the base address to the clockevent and clocksource
initialization functions in order to use different base address in the
next changes.
No functional changes intended.
Signed-off-by: Daniel Lezcano <daniel.lezcano@...aro.org>
---
drivers/clocksource/timer-vf-pit.c | 37 +++++++++++++++++++-----------
1 file changed, 24 insertions(+), 13 deletions(-)
diff --git a/drivers/clocksource/timer-vf-pit.c b/drivers/clocksource/timer-vf-pit.c
index 581b46e7b111..34edb23194c5 100644
--- a/drivers/clocksource/timer-vf-pit.c
+++ b/drivers/clocksource/timer-vf-pit.c
@@ -66,16 +66,27 @@ static u64 notrace pit_read_sched_clock(void)
return ~readl(clksrc_base + PITCVAL);
}
-static int __init pit_clocksource_init(struct pit_timer *pit, unsigned long rate)
+static int __init pit_clocksource_init(struct pit_timer *pit, void __iomem *base,
+ unsigned long rate)
{
+ /*
+ * PIT0 and PIT1 can be chained to build a 64-bit timer, so
+ * choose PIT2 as clocksource and leave PIT0 and PIT1 unused
+ * for anyone else who needs them.
+ */
+ pit->clksrc_base = base + PIT_CH(2);
+
/* set the max load value and start the clock source counter */
writel(0, pit->clksrc_base + PITTCTRL);
writel(~0, pit->clksrc_base + PITLDVAL);
writel(PITTCTRL_TEN, pit->clksrc_base + PITTCTRL);
+ clksrc_base = pit->clksrc_base;
+
sched_clock_register(pit_read_sched_clock, 32, rate);
+
return clocksource_mmio_init(pit->clksrc_base + PITCVAL, "vf-pit", rate,
- 300, 32, clocksource_mmio_readl_down);
+ 300, 32, clocksource_mmio_readl_down);
}
static int pit_set_next_event(unsigned long delta, struct clock_event_device *ced)
@@ -135,8 +146,16 @@ static irqreturn_t pit_timer_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
}
-static int __init pit_clockevent_init(struct pit_timer *pit, unsigned long rate, int irq)
+static int __init pit_clockevent_init(struct pit_timer *pit, void __iomem *base,
+ unsigned long rate, int irq)
{
+ /*
+ * PIT0 and PIT1 can be chained to build a 64-bit timer, so
+ * choose PIT3 as clockevent and leave PIT0 and PIT1 unused
+ * for anyone else who needs them.
+ */
+ pit->clkevt_base = base + PIT_CH(3);
+
writel(0, pit->clkevt_base + PITTCTRL);
writel(PITTFLG_TIF, pit->clkevt_base + PITTFLG);
@@ -180,14 +199,6 @@ static int __init pit_timer_init(struct device_node *np)
return -ENXIO;
}
- /*
- * PIT0 and PIT1 can be chained to build a 64-bit timer,
- * so choose PIT2 as clocksource, PIT3 as clockevent device,
- * and leave PIT0 and PIT1 unused for anyone else who needs them.
- */
- pit_timer.clksrc_base = timer_base + PIT_CH(2);
- pit_timer.clkevt_base = timer_base + PIT_CH(3);
-
irq = irq_of_parse_and_map(np, 0);
if (irq <= 0)
return -EINVAL;
@@ -206,10 +217,10 @@ static int __init pit_timer_init(struct device_node *np)
/* enable the pit module */
writel(~PITMCR_MDIS, timer_base + PITMCR);
- ret = pit_clocksource_init(&pit_timer, clk_rate);
+ ret = pit_clocksource_init(&pit_timer, timer_base, clk_rate);
if (ret)
return ret;
- return pit_clockevent_init(&pit_timer, clk_rate, irq);
+ return pit_clockevent_init(&pit_timer, timer_base, clk_rate, irq);
}
TIMER_OF_DECLARE(vf610, "fsl,vf610-pit", pit_timer_init);
--
2.43.0
Powered by blists - more mailing lists