Skip to content

Commit d2c60dc

Browse files
alexandrebellonidlezcano
authored andcommitted
clocksource/drivers/timer-atmel-tcb: Fill tcb_config
Use the tcb_config and struct atmel_tcb_config to get the timer counter width. This is necessary because atmel_tcb_config will be extended later on. Signed-off-by: Alexandre Belloni <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 228e218 commit d2c60dc

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

drivers/clocksource/timer-atmel-tcb.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,17 @@ static void __init tcb_setup_single_chan(struct atmel_tc *tc, int mck_divisor_id
348348

349349
static const u8 atmel_tcb_divisors[] = { 2, 8, 32, 128 };
350350

351+
static struct atmel_tcb_config tcb_rm9200_config = {
352+
.counter_width = 16,
353+
};
354+
355+
static struct atmel_tcb_config tcb_sam9x5_config = {
356+
.counter_width = 32,
357+
};
358+
351359
static const struct of_device_id atmel_tcb_of_match[] = {
352-
{ .compatible = "atmel,at91rm9200-tcb", .data = (void *)16, },
353-
{ .compatible = "atmel,at91sam9x5-tcb", .data = (void *)32, },
360+
{ .compatible = "atmel,at91rm9200-tcb", .data = &tcb_rm9200_config, },
361+
{ .compatible = "atmel,at91sam9x5-tcb", .data = &tcb_sam9x5_config, },
354362
{ /* sentinel */ }
355363
};
356364

@@ -398,7 +406,11 @@ static int __init tcb_clksrc_init(struct device_node *node)
398406
}
399407

400408
match = of_match_node(atmel_tcb_of_match, node->parent);
401-
bits = (uintptr_t)match->data;
409+
if (!match)
410+
return -ENODEV;
411+
412+
tc.tcb_config = match->data;
413+
bits = tc.tcb_config->counter_width;
402414

403415
for (i = 0; i < ARRAY_SIZE(tc.irq); i++)
404416
writel(ATMEL_TC_ALL_IRQ, tc.regs + ATMEL_TC_REG(i, IDR));

0 commit comments

Comments
 (0)