Lines Matching refs:rt
40 static inline void rt_timer_w32(struct rt_timer *rt, u8 reg, u32 val) in rt_timer_w32() argument
42 __raw_writel(val, rt->membase + reg); in rt_timer_w32()
45 static inline u32 rt_timer_r32(struct rt_timer *rt, u8 reg) in rt_timer_r32() argument
47 return __raw_readl(rt->membase + reg); in rt_timer_r32()
52 struct rt_timer *rt = (struct rt_timer *) _rt; in rt_timer_irq() local
54 rt_timer_w32(rt, TIMER_REG_TMR0LOAD, rt->timer_freq / rt->timer_div); in rt_timer_irq()
55 rt_timer_w32(rt, TIMER_REG_TMRSTAT, TMRSTAT_TMR0INT); in rt_timer_irq()
61 static int rt_timer_request(struct rt_timer *rt) in rt_timer_request() argument
63 int err = request_irq(rt->irq, rt_timer_irq, 0, in rt_timer_request()
64 dev_name(rt->dev), rt); in rt_timer_request()
66 dev_err(rt->dev, "failed to request irq\n"); in rt_timer_request()
69 rt_timer_w32(rt, TIMER_REG_TMR0CTL, t); in rt_timer_request()
74 static int rt_timer_config(struct rt_timer *rt, unsigned long divisor) in rt_timer_config() argument
76 if (rt->timer_freq < divisor) in rt_timer_config()
77 rt->timer_div = rt->timer_freq; in rt_timer_config()
79 rt->timer_div = divisor; in rt_timer_config()
81 rt_timer_w32(rt, TIMER_REG_TMR0LOAD, rt->timer_freq / rt->timer_div); in rt_timer_config()
86 static int rt_timer_enable(struct rt_timer *rt) in rt_timer_enable() argument
90 rt_timer_w32(rt, TIMER_REG_TMR0LOAD, rt->timer_freq / rt->timer_div); in rt_timer_enable()
92 t = rt_timer_r32(rt, TIMER_REG_TMR0CTL); in rt_timer_enable()
94 rt_timer_w32(rt, TIMER_REG_TMR0CTL, t); in rt_timer_enable()
102 struct rt_timer *rt; in rt_timer_probe() local
105 rt = devm_kzalloc(&pdev->dev, sizeof(*rt), GFP_KERNEL); in rt_timer_probe()
106 if (!rt) { in rt_timer_probe()
111 rt->irq = platform_get_irq(pdev, 0); in rt_timer_probe()
112 if (!rt->irq) { in rt_timer_probe()
117 rt->membase = devm_ioremap_resource(&pdev->dev, res); in rt_timer_probe()
118 if (IS_ERR(rt->membase)) in rt_timer_probe()
119 return PTR_ERR(rt->membase); in rt_timer_probe()
127 rt->timer_freq = clk_get_rate(clk) / TMR0CTL_PRESCALE_DIV; in rt_timer_probe()
128 if (!rt->timer_freq) in rt_timer_probe()
131 rt->dev = &pdev->dev; in rt_timer_probe()
132 platform_set_drvdata(pdev, rt); in rt_timer_probe()
134 rt_timer_request(rt); in rt_timer_probe()
135 rt_timer_config(rt, 2); in rt_timer_probe()
136 rt_timer_enable(rt); in rt_timer_probe()
138 dev_info(&pdev->dev, "maximum frequency is %luHz\n", rt->timer_freq); in rt_timer_probe()