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: Encapsulate the macros

Pass the base address to the macro, so we can use the macro with
multiple instances of the timer because we deal with different base
address. At the same time, change writes to the register to the
existing corresponding functions.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20250804152344.1109310-11-daniel.lezcano@linaro.org

+18 -16
+18 -16
drivers/clocksource/timer-vf-pit.c
··· 16 16 #define PITMCR 0x00 17 17 #define PIT0_OFFSET 0x100 18 18 #define PIT_CH(n) (PIT0_OFFSET + 0x10 * (n)) 19 - #define PITLDVAL 0x00 19 + 20 20 #define PITCVAL 0x04 21 - #define PITTCTRL 0x08 22 - #define PITTFLG 0x0c 23 21 24 22 #define PITMCR_MDIS BIT(1) 25 23 26 - #define PITTCTRL_TEN BIT(0) 27 - #define PITTCTRL_TIE BIT(1) 28 - #define PITCTRL_CHN BIT(2) 24 + #define PITLDVAL(__base) (__base) 25 + #define PITTCTRL(__base) ((__base) + 0x08) 29 26 30 - #define PITTFLG_TIF 0x1 27 + #define PITTCTRL_TEN BIT(0) 28 + #define PITTCTRL_TIE BIT(1) 29 + 30 + #define PITTFLG(__base) ((__base) + 0x0c) 31 + 32 + #define PITTFLG_TIF BIT(0) 31 33 32 34 struct pit_timer { 33 35 void __iomem *clksrc_base; ··· 53 51 54 52 static inline void pit_timer_enable(struct pit_timer *pit) 55 53 { 56 - writel(PITTCTRL_TEN | PITTCTRL_TIE, pit->clkevt_base + PITTCTRL); 54 + writel(PITTCTRL_TEN | PITTCTRL_TIE, PITTCTRL(pit->clkevt_base)); 57 55 } 58 56 59 57 static inline void pit_timer_disable(struct pit_timer *pit) 60 58 { 61 - writel(0, pit->clkevt_base + PITTCTRL); 59 + writel(0, PITTCTRL(pit->clkevt_base)); 62 60 } 63 61 64 62 static inline void pit_irq_acknowledge(struct pit_timer *pit) 65 63 { 66 - writel(PITTFLG_TIF, pit->clkevt_base + PITTFLG); 64 + writel(PITTFLG_TIF, PITTFLG(pit->clkevt_base)); 67 65 } 68 66 69 67 static u64 notrace pit_read_sched_clock(void) ··· 94 92 pit->cs.flags = CLOCK_SOURCE_IS_CONTINUOUS; 95 93 96 94 /* set the max load value and start the clock source counter */ 97 - writel(0, pit->clksrc_base + PITTCTRL); 98 - writel(~0, pit->clksrc_base + PITLDVAL); 99 - writel(PITTCTRL_TEN, pit->clksrc_base + PITTCTRL); 95 + pit_timer_disable(pit); 96 + writel(~0, PITLDVAL(pit->clksrc_base)); 97 + writel(PITTCTRL_TEN, PITTCTRL(pit->clksrc_base)); 100 98 101 99 clksrc_base = pit->clksrc_base; 102 100 ··· 117 115 * hardware requirement. 118 116 */ 119 117 pit_timer_disable(pit); 120 - writel(delta - 1, pit->clkevt_base + PITLDVAL); 118 + writel(delta - 1, PITLDVAL(pit->clkevt_base)); 121 119 pit_timer_enable(pit); 122 120 123 121 return 0; ··· 173 171 pit->clkevt_base = base + PIT_CH(3); 174 172 pit->cycle_per_jiffy = rate / (HZ); 175 173 176 - writel(0, pit->clkevt_base + PITTCTRL); 174 + pit_timer_disable(pit); 177 175 178 - writel(PITTFLG_TIF, pit->clkevt_base + PITTFLG); 176 + pit_irq_acknowledge(pit); 179 177 180 178 BUG_ON(request_irq(irq, pit_timer_interrupt, IRQF_TIMER | IRQF_IRQPOLL, 181 179 "VF pit timer", &pit->ced));