Lines Matching +full:rt2880 +full:- +full:timer

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Ralink RT2880 timer
11 #include <linux/timer.h>
15 #include <asm/mach-ralink/ralink_regs.h>
26 #define TMR0CTL_PRESCALE_VAL (0xf - TMR0CTL_PRESCALER)
39 __raw_writel(val, rt->membase + reg); in rt_timer_w32()
44 return __raw_readl(rt->membase + reg); in rt_timer_r32()
51 rt_timer_w32(rt, TIMER_REG_TMR0LOAD, rt->timer_freq / rt->timer_div); in rt_timer_irq()
60 int err = request_irq(rt->irq, rt_timer_irq, 0, in rt_timer_request()
61 dev_name(rt->dev), rt); in rt_timer_request()
63 dev_err(rt->dev, "failed to request irq\n"); in rt_timer_request()
73 if (rt->timer_freq < divisor) in rt_timer_config()
74 rt->timer_div = rt->timer_freq; in rt_timer_config()
76 rt->timer_div = divisor; in rt_timer_config()
78 rt_timer_w32(rt, TIMER_REG_TMR0LOAD, rt->timer_freq / rt->timer_div); in rt_timer_config()
87 rt_timer_w32(rt, TIMER_REG_TMR0LOAD, rt->timer_freq / rt->timer_div); in rt_timer_enable()
101 rt = devm_kzalloc(&pdev->dev, sizeof(*rt), GFP_KERNEL); in rt_timer_probe()
103 dev_err(&pdev->dev, "failed to allocate memory\n"); in rt_timer_probe()
104 return -ENOMEM; in rt_timer_probe()
107 rt->irq = platform_get_irq(pdev, 0); in rt_timer_probe()
108 if (rt->irq < 0) in rt_timer_probe()
109 return rt->irq; in rt_timer_probe()
111 rt->membase = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); in rt_timer_probe()
112 if (IS_ERR(rt->membase)) in rt_timer_probe()
113 return PTR_ERR(rt->membase); in rt_timer_probe()
115 clk = devm_clk_get(&pdev->dev, NULL); in rt_timer_probe()
117 dev_err(&pdev->dev, "failed get clock rate\n"); in rt_timer_probe()
121 rt->timer_freq = clk_get_rate(clk) / TMR0CTL_PRESCALE_DIV; in rt_timer_probe()
122 if (!rt->timer_freq) in rt_timer_probe()
123 return -EINVAL; in rt_timer_probe()
125 rt->dev = &pdev->dev; in rt_timer_probe()
132 dev_info(&pdev->dev, "maximum frequency is %luHz\n", rt->timer_freq); in rt_timer_probe()
138 { .compatible = "ralink,rt2880-timer" },
145 .name = "rt-timer",