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

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Ralink RT2880 timer
17 #include <linux/timer.h>
20 #include <asm/mach-ralink/ralink_regs.h>
31 #define TMR0CTL_PRESCALE_VAL (0xf - TMR0CTL_PRESCALER)
44 __raw_writel(val, rt->membase + reg); in rt_timer_w32()
49 return __raw_readl(rt->membase + reg); in rt_timer_r32()
56 rt_timer_w32(rt, TIMER_REG_TMR0LOAD, rt->timer_freq / rt->timer_div); in rt_timer_irq()
65 int err = request_irq(rt->irq, rt_timer_irq, 0, in rt_timer_request()
66 dev_name(rt->dev), rt); in rt_timer_request()
68 dev_err(rt->dev, "failed to request irq\n"); in rt_timer_request()
78 if (rt->timer_freq < divisor) in rt_timer_config()
79 rt->timer_div = rt->timer_freq; in rt_timer_config()
81 rt->timer_div = divisor; in rt_timer_config()
83 rt_timer_w32(rt, TIMER_REG_TMR0LOAD, rt->timer_freq / rt->timer_div); in rt_timer_config()
92 rt_timer_w32(rt, TIMER_REG_TMR0LOAD, rt->timer_freq / rt->timer_div); in rt_timer_enable()
106 rt = devm_kzalloc(&pdev->dev, sizeof(*rt), GFP_KERNEL); in rt_timer_probe()
108 dev_err(&pdev->dev, "failed to allocate memory\n"); in rt_timer_probe()
109 return -ENOMEM; in rt_timer_probe()
112 rt->irq = platform_get_irq(pdev, 0); in rt_timer_probe()
113 if (rt->irq < 0) in rt_timer_probe()
114 return rt->irq; in rt_timer_probe()
116 rt->membase = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); in rt_timer_probe()
117 if (IS_ERR(rt->membase)) in rt_timer_probe()
118 return PTR_ERR(rt->membase); in rt_timer_probe()
120 clk = devm_clk_get(&pdev->dev, NULL); in rt_timer_probe()
122 dev_err(&pdev->dev, "failed get clock rate\n"); in rt_timer_probe()
126 rt->timer_freq = clk_get_rate(clk) / TMR0CTL_PRESCALE_DIV; in rt_timer_probe()
127 if (!rt->timer_freq) in rt_timer_probe()
128 return -EINVAL; in rt_timer_probe()
130 rt->dev = &pdev->dev; in rt_timer_probe()
137 dev_info(&pdev->dev, "maximum frequency is %luHz\n", rt->timer_freq); in rt_timer_probe()
143 { .compatible = "ralink,rt2880-timer" },
150 .name = "rt-timer",