Lines Matching refs:p
65 static inline unsigned long em_sti_read(struct em_sti_priv *p, int offs) in em_sti_read() argument
67 return ioread32(p->base + offs); in em_sti_read()
70 static inline void em_sti_write(struct em_sti_priv *p, int offs, in em_sti_write() argument
73 iowrite32(value, p->base + offs); in em_sti_write()
76 static int em_sti_enable(struct em_sti_priv *p) in em_sti_enable() argument
81 ret = clk_prepare_enable(p->clk); in em_sti_enable()
83 dev_err(&p->pdev->dev, "cannot enable clock\n"); in em_sti_enable()
88 p->rate = clk_get_rate(p->clk); in em_sti_enable()
91 em_sti_write(p, STI_SET_H, 0x40000000); in em_sti_enable()
92 em_sti_write(p, STI_SET_L, 0x00000000); in em_sti_enable()
95 em_sti_write(p, STI_INTENCLR, 3); in em_sti_enable()
96 em_sti_write(p, STI_INTFFCLR, 3); in em_sti_enable()
99 em_sti_write(p, STI_CONTROL, 1); in em_sti_enable()
104 static void em_sti_disable(struct em_sti_priv *p) in em_sti_disable() argument
107 em_sti_write(p, STI_INTENCLR, 3); in em_sti_disable()
110 clk_disable_unprepare(p->clk); in em_sti_disable()
113 static cycle_t em_sti_count(struct em_sti_priv *p) in em_sti_count() argument
123 raw_spin_lock_irqsave(&p->lock, flags); in em_sti_count()
124 ticks = (cycle_t)(em_sti_read(p, STI_COUNT_H) & 0xffff) << 32; in em_sti_count()
125 ticks |= em_sti_read(p, STI_COUNT_L); in em_sti_count()
126 raw_spin_unlock_irqrestore(&p->lock, flags); in em_sti_count()
131 static cycle_t em_sti_set_next(struct em_sti_priv *p, cycle_t next) in em_sti_set_next() argument
135 raw_spin_lock_irqsave(&p->lock, flags); in em_sti_set_next()
138 em_sti_write(p, STI_INTENCLR, 1); in em_sti_set_next()
141 em_sti_write(p, STI_COMPA_H, next >> 32); in em_sti_set_next()
142 em_sti_write(p, STI_COMPA_L, next & 0xffffffff); in em_sti_set_next()
145 em_sti_write(p, STI_INTFFCLR, 1); in em_sti_set_next()
148 em_sti_write(p, STI_INTENSET, 1); in em_sti_set_next()
150 raw_spin_unlock_irqrestore(&p->lock, flags); in em_sti_set_next()
157 struct em_sti_priv *p = dev_id; in em_sti_interrupt() local
159 p->ced.event_handler(&p->ced); in em_sti_interrupt()
163 static int em_sti_start(struct em_sti_priv *p, unsigned int user) in em_sti_start() argument
169 raw_spin_lock_irqsave(&p->lock, flags); in em_sti_start()
170 used_before = p->active[USER_CLOCKSOURCE] | p->active[USER_CLOCKEVENT]; in em_sti_start()
172 ret = em_sti_enable(p); in em_sti_start()
175 p->active[user] = 1; in em_sti_start()
176 raw_spin_unlock_irqrestore(&p->lock, flags); in em_sti_start()
181 static void em_sti_stop(struct em_sti_priv *p, unsigned int user) in em_sti_stop() argument
186 raw_spin_lock_irqsave(&p->lock, flags); in em_sti_stop()
187 used_before = p->active[USER_CLOCKSOURCE] | p->active[USER_CLOCKEVENT]; in em_sti_stop()
188 p->active[user] = 0; in em_sti_stop()
189 used_after = p->active[USER_CLOCKSOURCE] | p->active[USER_CLOCKEVENT]; in em_sti_stop()
192 em_sti_disable(p); in em_sti_stop()
193 raw_spin_unlock_irqrestore(&p->lock, flags); in em_sti_stop()
209 struct em_sti_priv *p = cs_to_em_sti(cs); in em_sti_clocksource_enable() local
211 ret = em_sti_start(p, USER_CLOCKSOURCE); in em_sti_clocksource_enable()
213 __clocksource_update_freq_hz(cs, p->rate); in em_sti_clocksource_enable()
227 static int em_sti_register_clocksource(struct em_sti_priv *p) in em_sti_register_clocksource() argument
229 struct clocksource *cs = &p->cs; in em_sti_register_clocksource()
232 cs->name = dev_name(&p->pdev->dev); in em_sti_register_clocksource()
242 dev_info(&p->pdev->dev, "used as clock source\n"); in em_sti_register_clocksource()
257 struct em_sti_priv *p = ced_to_em_sti(ced); in em_sti_clock_event_mode() local
262 em_sti_stop(p, USER_CLOCKEVENT); in em_sti_clock_event_mode()
270 dev_info(&p->pdev->dev, "used for oneshot clock events\n"); in em_sti_clock_event_mode()
271 em_sti_start(p, USER_CLOCKEVENT); in em_sti_clock_event_mode()
272 clockevents_config(&p->ced, p->rate); in em_sti_clock_event_mode()
276 em_sti_stop(p, USER_CLOCKEVENT); in em_sti_clock_event_mode()
286 struct em_sti_priv *p = ced_to_em_sti(ced); in em_sti_clock_event_next() local
290 next = em_sti_set_next(p, em_sti_count(p) + delta); in em_sti_clock_event_next()
291 safe = em_sti_count(p) < (next - 1); in em_sti_clock_event_next()
296 static void em_sti_register_clockevent(struct em_sti_priv *p) in em_sti_register_clockevent() argument
298 struct clock_event_device *ced = &p->ced; in em_sti_register_clockevent()
301 ced->name = dev_name(&p->pdev->dev); in em_sti_register_clockevent()
308 dev_info(&p->pdev->dev, "used for clock events\n"); in em_sti_register_clockevent()
316 struct em_sti_priv *p; in em_sti_probe() local
320 p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); in em_sti_probe()
321 if (p == NULL) in em_sti_probe()
324 p->pdev = pdev; in em_sti_probe()
325 platform_set_drvdata(pdev, p); in em_sti_probe()
335 p->base = devm_ioremap_resource(&pdev->dev, res); in em_sti_probe()
336 if (IS_ERR(p->base)) in em_sti_probe()
337 return PTR_ERR(p->base); in em_sti_probe()
340 p->clk = devm_clk_get(&pdev->dev, "sclk"); in em_sti_probe()
341 if (IS_ERR(p->clk)) { in em_sti_probe()
343 return PTR_ERR(p->clk); in em_sti_probe()
348 dev_name(&pdev->dev), p)) { in em_sti_probe()
353 raw_spin_lock_init(&p->lock); in em_sti_probe()
354 em_sti_register_clockevent(p); in em_sti_probe()
355 em_sti_register_clocksource(p); in em_sti_probe()