Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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@linaro.org>
Link: https://lore.kernel.org/r/20250804152344.1109310-5-daniel.lezcano@linaro.org

+22 -13
+22 -13
drivers/clocksource/timer-vf-pit.c
··· 66 66 return ~readl(clksrc_base + PITCVAL); 67 67 } 68 68 69 - static int __init pit_clocksource_init(struct pit_timer *pit, unsigned long rate) 69 + static int __init pit_clocksource_init(struct pit_timer *pit, void __iomem *base, 70 + unsigned long rate) 70 71 { 72 + /* 73 + * The channels 0 and 1 can be chained to build a 64-bit 74 + * timer. Let's use the channel 2 as a clocksource and leave 75 + * the channels 0 and 1 unused for anyone else who needs them 76 + */ 77 + pit->clksrc_base = base + PIT_CH(2); 78 + 71 79 /* set the max load value and start the clock source counter */ 72 80 writel(0, pit->clksrc_base + PITTCTRL); 73 81 writel(~0, pit->clksrc_base + PITLDVAL); ··· 84 76 clksrc_base = pit->clksrc_base; 85 77 86 78 sched_clock_register(pit_read_sched_clock, 32, rate); 79 + 87 80 return clocksource_mmio_init(pit->clksrc_base + PITCVAL, "vf-pit", rate, 88 - 300, 32, clocksource_mmio_readl_down); 81 + 300, 32, clocksource_mmio_readl_down); 89 82 } 90 83 91 84 static int pit_set_next_event(unsigned long delta, struct clock_event_device *ced) ··· 146 137 return IRQ_HANDLED; 147 138 } 148 139 149 - static int __init pit_clockevent_init(struct pit_timer *pit, unsigned long rate, int irq) 140 + static int __init pit_clockevent_init(struct pit_timer *pit, void __iomem *base, 141 + unsigned long rate, int irq) 150 142 { 143 + /* 144 + * The channels 0 and 1 can be chained to build a 64-bit 145 + * timer. Let's use the channel 3 as a clockevent and leave 146 + * the channels 0 and 1 unused for anyone else who needs them 147 + */ 148 + pit->clkevt_base = base + PIT_CH(3); 149 + 151 150 writel(0, pit->clkevt_base + PITTCTRL); 152 151 153 152 writel(PITTFLG_TIF, pit->clkevt_base + PITTFLG); ··· 199 182 return -ENXIO; 200 183 } 201 184 202 - /* 203 - * PIT0 and PIT1 can be chained to build a 64-bit timer, 204 - * so choose PIT2 as clocksource, PIT3 as clockevent device, 205 - * and leave PIT0 and PIT1 unused for anyone else who needs them. 206 - */ 207 - pit_timer.clksrc_base = timer_base + PIT_CH(2); 208 - pit_timer.clkevt_base = timer_base + PIT_CH(3); 209 - 210 185 irq = irq_of_parse_and_map(np, 0); 211 186 if (irq <= 0) 212 187 return -EINVAL; ··· 217 208 /* enable the pit module */ 218 209 writel(~PITMCR_MDIS, timer_base + PITMCR); 219 210 220 - ret = pit_clocksource_init(&pit_timer, clk_rate); 211 + ret = pit_clocksource_init(&pit_timer, timer_base, clk_rate); 221 212 if (ret) 222 213 return ret; 223 214 224 - return pit_clockevent_init(&pit_timer, clk_rate, irq); 215 + return pit_clockevent_init(&pit_timer, timer_base, clk_rate, irq); 225 216 } 226 217 TIMER_OF_DECLARE(vf610, "fsl,vf610-pit", pit_timer_init);