Lines Matching refs:rt
37 static inline void rt_timer_w32(struct rt_timer *rt, u8 reg, u32 val) in rt_timer_w32() argument
39 __raw_writel(val, rt->membase + reg); in rt_timer_w32()
42 static inline u32 rt_timer_r32(struct rt_timer *rt, u8 reg) in rt_timer_r32() argument
44 return __raw_readl(rt->membase + reg); in rt_timer_r32()
49 struct rt_timer *rt = (struct rt_timer *) _rt; in rt_timer_irq() local
51 rt_timer_w32(rt, TIMER_REG_TMR0LOAD, rt->timer_freq / rt->timer_div); in rt_timer_irq()
52 rt_timer_w32(rt, TIMER_REG_TMRSTAT, TMRSTAT_TMR0INT); in rt_timer_irq()
58 static int rt_timer_request(struct rt_timer *rt) in rt_timer_request() argument
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()
66 rt_timer_w32(rt, TIMER_REG_TMR0CTL, t); in rt_timer_request()
71 static int rt_timer_config(struct rt_timer *rt, unsigned long divisor) in rt_timer_config() argument
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()
83 static int rt_timer_enable(struct rt_timer *rt) in rt_timer_enable() argument
87 rt_timer_w32(rt, TIMER_REG_TMR0LOAD, rt->timer_freq / rt->timer_div); in rt_timer_enable()
89 t = rt_timer_r32(rt, TIMER_REG_TMR0CTL); in rt_timer_enable()
91 rt_timer_w32(rt, TIMER_REG_TMR0CTL, t); in rt_timer_enable()
98 struct rt_timer *rt; in rt_timer_probe() local
101 rt = devm_kzalloc(&pdev->dev, sizeof(*rt), GFP_KERNEL); in rt_timer_probe()
102 if (!rt) { 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()
121 rt->timer_freq = clk_get_rate(clk) / TMR0CTL_PRESCALE_DIV; in rt_timer_probe()
122 if (!rt->timer_freq) in rt_timer_probe()
125 rt->dev = &pdev->dev; in rt_timer_probe()
126 platform_set_drvdata(pdev, rt); in rt_timer_probe()
128 rt_timer_request(rt); in rt_timer_probe()
129 rt_timer_config(rt, 2); in rt_timer_probe()
130 rt_timer_enable(rt); in rt_timer_probe()
132 dev_info(&pdev->dev, "maximum frequency is %luHz\n", rt->timer_freq); in rt_timer_probe()