Lines Matching refs:rt
42 static inline void rt_timer_w32(struct rt_timer *rt, u8 reg, u32 val) in rt_timer_w32() argument
44 __raw_writel(val, rt->membase + reg); in rt_timer_w32()
47 static inline u32 rt_timer_r32(struct rt_timer *rt, u8 reg) in rt_timer_r32() argument
49 return __raw_readl(rt->membase + reg); in rt_timer_r32()
54 struct rt_timer *rt = (struct rt_timer *) _rt; in rt_timer_irq() local
56 rt_timer_w32(rt, TIMER_REG_TMR0LOAD, rt->timer_freq / rt->timer_div); in rt_timer_irq()
57 rt_timer_w32(rt, TIMER_REG_TMRSTAT, TMRSTAT_TMR0INT); in rt_timer_irq()
63 static int rt_timer_request(struct rt_timer *rt) in rt_timer_request() argument
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()
71 rt_timer_w32(rt, TIMER_REG_TMR0CTL, t); in rt_timer_request()
76 static int rt_timer_config(struct rt_timer *rt, unsigned long divisor) in rt_timer_config() argument
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()
88 static int rt_timer_enable(struct rt_timer *rt) in rt_timer_enable() argument
92 rt_timer_w32(rt, TIMER_REG_TMR0LOAD, rt->timer_freq / rt->timer_div); in rt_timer_enable()
94 t = rt_timer_r32(rt, TIMER_REG_TMR0CTL); in rt_timer_enable()
96 rt_timer_w32(rt, TIMER_REG_TMR0CTL, t); in rt_timer_enable()
103 struct rt_timer *rt; in rt_timer_probe() local
106 rt = devm_kzalloc(&pdev->dev, sizeof(*rt), GFP_KERNEL); in rt_timer_probe()
107 if (!rt) { 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()
126 rt->timer_freq = clk_get_rate(clk) / TMR0CTL_PRESCALE_DIV; in rt_timer_probe()
127 if (!rt->timer_freq) in rt_timer_probe()
130 rt->dev = &pdev->dev; in rt_timer_probe()
131 platform_set_drvdata(pdev, rt); in rt_timer_probe()
133 rt_timer_request(rt); in rt_timer_probe()
134 rt_timer_config(rt, 2); in rt_timer_probe()
135 rt_timer_enable(rt); in rt_timer_probe()
137 dev_info(&pdev->dev, "maximum frequency is %luHz\n", rt->timer_freq); in rt_timer_probe()