Message ID | 20191107094218.13210-1-joel@jms.id.au |
---|---|
Headers | show |
Series | clocksource: Add ast2600 support to fttmr010 | expand |
Hi Daniel, Thomas, I noticed that this series never made it into the timer tree. Are you able to pick it up? https://lore.kernel.org/lkml/20191107094218.13210-1-joel@jms.id.au/ Cheers, Joel On Thu, 7 Nov 2019 at 09:42, Joel Stanley <joel@jms.id.au> wrote: > > This series adds support for the AST2600 timer. > > v2 adds r-b tags from Rob, Linus and Cédric (who reviewed the patches on the > openbmc mailing list[1]). I made two small naming changes in this > version that were suggested in review. > > [1] https://patchwork.ozlabs.org/project/openbmc/list/?series=140990 > > Joel Stanley (4): > clocksource: fttmr010: Parametrise shutdown > clocksource: fttmr010: Set interrupt and shutdown > clocksource: fttmr010: Add support for ast2600 > dt-bindings: fttmr010: Add ast2600 compatible > > .../bindings/timer/faraday,fttmr010.txt | 1 + > drivers/clocksource/timer-fttmr010.c | 68 +++++++++++++++---- > 2 files changed, 54 insertions(+), 15 deletions(-) > > -- > 2.24.0.rc1 >
On 29/01/2020 11:30, Joel Stanley wrote: > Hi Daniel, Thomas, I noticed that this series never made it into the > timer tree. Are you able to pick it up? Oops, missed it. Incoming comments. > https://lore.kernel.org/lkml/20191107094218.13210-1-joel@jms.id.au/ > > Cheers, > > Joel > > On Thu, 7 Nov 2019 at 09:42, Joel Stanley <joel@jms.id.au> wrote: >> >> This series adds support for the AST2600 timer. >> >> v2 adds r-b tags from Rob, Linus and Cédric (who reviewed the patches on the >> openbmc mailing list[1]). I made two small naming changes in this >> version that were suggested in review. >> >> [1] https://patchwork.ozlabs.org/project/openbmc/list/?series=140990 >> >> Joel Stanley (4): >> clocksource: fttmr010: Parametrise shutdown >> clocksource: fttmr010: Set interrupt and shutdown >> clocksource: fttmr010: Add support for ast2600 >> dt-bindings: fttmr010: Add ast2600 compatible >> >> .../bindings/timer/faraday,fttmr010.txt | 1 + >> drivers/clocksource/timer-fttmr010.c | 68 +++++++++++++++---- >> 2 files changed, 54 insertions(+), 15 deletions(-) >> >> -- >> 2.24.0.rc1 >>
On 07/11/2019 10:42, Joel Stanley wrote: > In preparation for supporting the ast2600 which uses a different method > to clear bits in the control register, use a callback for performing the > shutdown sequence. > > Reviewed-by: Cédric Le Goater <clg@kaod.org> > Reviewed-by: Linus Walleij <linus.walleij@linaro.org> > Signed-off-by: Joel Stanley <joel@jms.id.au> It will be cleaner if you create a struct of_device_id array where you store the different variant data. eg. struct myops { int (*shutdown)(struct clock_event_device *evt); }; struct fttmr010 { ... struct myops *ops; }; ... static const struct of_device_id fttmr010_of_match[] = { { .compatible = "faraday,fttmr010", .data = &fttmr010_ops }, ... { .compatible = "aspeed,ast2600-timer", .data = &as2600_ops, }, { /* sentinel */ } }; Keep the generic timer_shutdown function, get the ops from there and then call the shutdown callback. At init time: ... const struct of_device_id *match; ... match = of_match_node(fttmr010_of_match, node); fttmr010->ops = (struct myops *)match->data; ... (also if you have time, remove the is_aspeed boolean test by a corresponding callback). > --- > drivers/clocksource/timer-fttmr010.c | 19 ++++++++----------- > 1 file changed, 8 insertions(+), 11 deletions(-) > > diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c > index fadff7915dd9..c2d30eb9dc72 100644 > --- a/drivers/clocksource/timer-fttmr010.c > +++ b/drivers/clocksource/timer-fttmr010.c > @@ -97,6 +97,7 @@ struct fttmr010 { > bool is_aspeed; > u32 t1_enable_val; > struct clock_event_device clkevt; > + int (*timer_shutdown)(struct clock_event_device *evt); > #ifdef CONFIG_ARM > struct delay_timer delay_timer; > #endif > @@ -140,9 +141,7 @@ static int fttmr010_timer_set_next_event(unsigned long cycles, > u32 cr; > > /* Stop */ > - cr = readl(fttmr010->base + TIMER_CR); > - cr &= ~fttmr010->t1_enable_val; > - writel(cr, fttmr010->base + TIMER_CR); > + fttmr010->timer_shutdown(evt); > > if (fttmr010->is_aspeed) { > /* > @@ -183,9 +182,7 @@ static int fttmr010_timer_set_oneshot(struct clock_event_device *evt) > u32 cr; > > /* Stop */ > - cr = readl(fttmr010->base + TIMER_CR); > - cr &= ~fttmr010->t1_enable_val; > - writel(cr, fttmr010->base + TIMER_CR); > + fttmr010->timer_shutdown(evt); > > /* Setup counter start from 0 or ~0 */ > writel(0, fttmr010->base + TIMER1_COUNT); > @@ -211,9 +208,7 @@ static int fttmr010_timer_set_periodic(struct clock_event_device *evt) > u32 cr; > > /* Stop */ > - cr = readl(fttmr010->base + TIMER_CR); > - cr &= ~fttmr010->t1_enable_val; > - writel(cr, fttmr010->base + TIMER_CR); > + fttmr010->timer_shutdown(evt); > > /* Setup timer to fire at 1/HZ intervals. */ > if (fttmr010->is_aspeed) { > @@ -350,6 +345,8 @@ static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed) > fttmr010->tick_rate); > } > > + fttmr010->timer_shutdown = fttmr010_timer_shutdown; > + > /* > * Setup clockevent timer (interrupt-driven) on timer 1. > */ > @@ -370,10 +367,10 @@ static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed) > fttmr010->clkevt.features = CLOCK_EVT_FEAT_PERIODIC | > CLOCK_EVT_FEAT_ONESHOT; > fttmr010->clkevt.set_next_event = fttmr010_timer_set_next_event; > - fttmr010->clkevt.set_state_shutdown = fttmr010_timer_shutdown; > + fttmr010->clkevt.set_state_shutdown = fttmr010->timer_shutdown; > fttmr010->clkevt.set_state_periodic = fttmr010_timer_set_periodic; > fttmr010->clkevt.set_state_oneshot = fttmr010_timer_set_oneshot; > - fttmr010->clkevt.tick_resume = fttmr010_timer_shutdown; > + fttmr010->clkevt.tick_resume = fttmr010->timer_shutdown; > fttmr010->clkevt.cpumask = cpumask_of(0); > fttmr010->clkevt.irq = irq; > clockevents_config_and_register(&fttmr010->clkevt, >
On 29/01/2020 12:41, Joel Stanley wrote: > On Wed, 29 Jan 2020 at 11:25, Daniel Lezcano <daniel.lezcano@linaro.org> wrote: >> >> On 07/11/2019 10:42, Joel Stanley wrote: >>> In preparation for supporting the ast2600 which uses a different method >>> to clear bits in the control register, use a callback for performing the >>> shutdown sequence. >>> >>> Reviewed-by: Cédric Le Goater <clg@kaod.org> >>> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> >>> Signed-off-by: Joel Stanley <joel@jms.id.au> >> >> It will be cleaner if you create a struct of_device_id array where you >> store the different variant data. > > I agree, and that's the path I would have taken when writing a normal > driver. However as the timer drivers probe with the > TIMER_OF_DECLARE/timer_probe infrastructure, we can't register our own > .data pointer (TIMER_OF_DECLARE uses .data to store the _init > function). > > Unless I'm missing something? I was suggesting to add the array like: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clocksource/timer-atmel-tcb.c#n351 TIMER_OF_DECLARE is used and the probe functions relies on the match array: match = of_match_node(atmel_tcb_of_match, node->parent); (note in this case, it is the node parent). >> >> eg. >> struct myops { >> int (*shutdown)(struct clock_event_device *evt); >> }; >> >> struct fttmr010 { >> ... >> struct myops *ops; >> }; >> >> ... >> >> static const struct of_device_id fttmr010_of_match[] = { >> { .compatible = "faraday,fttmr010", .data = &fttmr010_ops }, >> ... >> { .compatible = "aspeed,ast2600-timer", .data = &as2600_ops, }, >> { /* sentinel */ } >> }; >> >> Keep the generic timer_shutdown function, get the ops from there and >> then call the shutdown callback. >> >> At init time: >> >> ... >> >> const struct of_device_id *match; >> >> ... >> >> match = of_match_node(fttmr010_of_match, node); >> fttmr010->ops = (struct myops *)match->data; >> >> ... >> >> (also if you have time, remove the is_aspeed boolean test by a >> corresponding callback). >> >>> --- >>> drivers/clocksource/timer-fttmr010.c | 19 ++++++++----------- >>> 1 file changed, 8 insertions(+), 11 deletions(-) >>> >>> diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c >>> index fadff7915dd9..c2d30eb9dc72 100644 >>> --- a/drivers/clocksource/timer-fttmr010.c >>> +++ b/drivers/clocksource/timer-fttmr010.c >>> @@ -97,6 +97,7 @@ struct fttmr010 { >>> bool is_aspeed; >>> u32 t1_enable_val; >>> struct clock_event_device clkevt; >>> + int (*timer_shutdown)(struct clock_event_device *evt); >>> #ifdef CONFIG_ARM >>> struct delay_timer delay_timer; >>> #endif >>> @@ -140,9 +141,7 @@ static int fttmr010_timer_set_next_event(unsigned long cycles, >>> u32 cr; >>> >>> /* Stop */ >>> - cr = readl(fttmr010->base + TIMER_CR); >>> - cr &= ~fttmr010->t1_enable_val; >>> - writel(cr, fttmr010->base + TIMER_CR); >>> + fttmr010->timer_shutdown(evt); >>> >>> if (fttmr010->is_aspeed) { >>> /* >>> @@ -183,9 +182,7 @@ static int fttmr010_timer_set_oneshot(struct clock_event_device *evt) >>> u32 cr; >>> >>> /* Stop */ >>> - cr = readl(fttmr010->base + TIMER_CR); >>> - cr &= ~fttmr010->t1_enable_val; >>> - writel(cr, fttmr010->base + TIMER_CR); >>> + fttmr010->timer_shutdown(evt); >>> >>> /* Setup counter start from 0 or ~0 */ >>> writel(0, fttmr010->base + TIMER1_COUNT); >>> @@ -211,9 +208,7 @@ static int fttmr010_timer_set_periodic(struct clock_event_device *evt) >>> u32 cr; >>> >>> /* Stop */ >>> - cr = readl(fttmr010->base + TIMER_CR); >>> - cr &= ~fttmr010->t1_enable_val; >>> - writel(cr, fttmr010->base + TIMER_CR); >>> + fttmr010->timer_shutdown(evt); >>> >>> /* Setup timer to fire at 1/HZ intervals. */ >>> if (fttmr010->is_aspeed) { >>> @@ -350,6 +345,8 @@ static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed) >>> fttmr010->tick_rate); >>> } >>> >>> + fttmr010->timer_shutdown = fttmr010_timer_shutdown; >>> + >>> /* >>> * Setup clockevent timer (interrupt-driven) on timer 1. >>> */ >>> @@ -370,10 +367,10 @@ static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed) >>> fttmr010->clkevt.features = CLOCK_EVT_FEAT_PERIODIC | >>> CLOCK_EVT_FEAT_ONESHOT; >>> fttmr010->clkevt.set_next_event = fttmr010_timer_set_next_event; >>> - fttmr010->clkevt.set_state_shutdown = fttmr010_timer_shutdown; >>> + fttmr010->clkevt.set_state_shutdown = fttmr010->timer_shutdown; >>> fttmr010->clkevt.set_state_periodic = fttmr010_timer_set_periodic; >>> fttmr010->clkevt.set_state_oneshot = fttmr010_timer_set_oneshot; >>> - fttmr010->clkevt.tick_resume = fttmr010_timer_shutdown; >>> + fttmr010->clkevt.tick_resume = fttmr010->timer_shutdown; >>> fttmr010->clkevt.cpumask = cpumask_of(0); >>> fttmr010->clkevt.irq = irq; >>> clockevents_config_and_register(&fttmr010->clkevt, >>> >> >> >> -- >> <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 >>