Lines Matching refs:ost
70 struct ingenic_ost *ost;
99 prescale = readl(ost_clk->ost->base + info->ostccr_reg);
113 prescale = readl(ost_clk->ost->base + info->ostccr_reg);
153 val = readl(ost_clk->ost->base + info->ostccr_reg);
155 writel(val, ost_clk->ost->base + info->ostccr_reg);
168 val = readl(ost_clk->ost->base + info->ostccr_reg);
170 writel(val, ost_clk->ost->base + info->ostccr_reg);
215 struct ingenic_ost *ost = ingenic_ost;
218 count = readl(ost->base + OST_REG_OST2CNTL);
235 struct ingenic_ost *ost = to_ingenic_ost(evt);
237 writel(OSTECR_OST1ENC, ost->base + OST_REG_OSTECR);
245 struct ingenic_ost *ost = to_ingenic_ost(evt);
247 writel((u32)~OSTFR_FFLAG, ost->base + OST_REG_OSTFR);
248 writel(next, ost->base + OST_REG_OST1DFR);
249 writel(OSTCR_OST1CLR, ost->base + OST_REG_OSTCR);
250 writel(OSTESR_OST1ENS, ost->base + OST_REG_OSTESR);
251 writel((u32)~OSTMR_FMASK, ost->base + OST_REG_OSTMR);
259 struct ingenic_ost *ost = to_ingenic_ost(evt);
261 writel(OSTECR_OST1ENC, ost->base + OST_REG_OSTECR);
269 static int __init ingenic_ost_register_clock(struct ingenic_ost *ost,
283 ost_clk->ost = ost;
286 val = readl(ost->base + info->ostccr_reg);
288 writel(val, ost->base + info->ostccr_reg);
313 struct ingenic_ost *ost)
319 ost->percpu_timer_clk = ingenic_ost_get_clock(np, channel);
320 if (IS_ERR(ost->percpu_timer_clk))
321 return PTR_ERR(ost->percpu_timer_clk);
323 err = clk_prepare_enable(ost->percpu_timer_clk);
327 rate = clk_get_rate(ost->percpu_timer_clk);
339 snprintf(ost->name, sizeof(ost->name), "OST percpu timer");
342 ost->name, &ost->cevt);
346 ost->cevt.cpumask = cpumask_of(smp_processor_id());
347 ost->cevt.features = CLOCK_EVT_FEAT_ONESHOT;
348 ost->cevt.name = ost->name;
349 ost->cevt.rating = 400;
350 ost->cevt.set_state_shutdown = ingenic_ost_cevt_set_state_shutdown;
351 ost->cevt.set_next_event = ingenic_ost_cevt_set_next;
353 clockevents_config_and_register(&ost->cevt, rate, 4, 0xffffffff);
360 clk_disable_unprepare(ost->percpu_timer_clk);
362 clk_put(ost->percpu_timer_clk);
367 struct ingenic_ost *ost)
370 struct clocksource *cs = &ost->cs;
374 ost->global_timer_clk = ingenic_ost_get_clock(np, channel);
375 if (IS_ERR(ost->global_timer_clk))
376 return PTR_ERR(ost->global_timer_clk);
378 err = clk_prepare_enable(ost->global_timer_clk);
382 rate = clk_get_rate(ost->global_timer_clk);
389 writel(OSTCR_OST2CLR, ost->base + OST_REG_OSTCR);
392 writel(OSTESR_OST2ENS, ost->base + OST_REG_OSTESR);
394 cs->name = "ingenic-ost";
407 clk_disable_unprepare(ost->global_timer_clk);
409 clk_put(ost->global_timer_clk);
418 { .compatible = "ingenic,x1000-ost", .data = &x1000_soc_info, },
425 struct ingenic_ost *ost;
429 ost = kzalloc(sizeof(*ost), GFP_KERNEL);
430 if (!ost)
433 ost->base = of_io_request_and_map(np, 0, of_node_full_name(np));
434 if (IS_ERR(ost->base)) {
436 ret = PTR_ERR(ost->base);
440 ost->clk = of_clk_get_by_name(np, "ost");
441 if (IS_ERR(ost->clk)) {
442 ret = PTR_ERR(ost->clk);
447 ret = clk_prepare_enable(ost->clk);
453 ost->soc_info = id->data;
455 ost->clocks = kzalloc(struct_size(ost->clocks, hws, ost->soc_info->num_channels),
457 if (!ost->clocks) {
462 ost->clocks->num = ost->soc_info->num_channels;
464 for (i = 0; i < ost->clocks->num; i++) {
465 ret = ingenic_ost_register_clock(ost, i, &ingenic_ost_clk_info[i], ost->clocks);
472 ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, ost->clocks);
478 ingenic_ost = ost;
483 for (i = 0; i < ost->clocks->num; i++)
484 if (ost->clocks->hws[i])
485 clk_hw_unregister(ost->clocks->hws[i]);
486 kfree(ost->clocks);
488 clk_disable_unprepare(ost->clk);
490 clk_put(ost->clk);
492 kfree(ost);
498 struct ingenic_ost *ost;
510 ost = ingenic_ost;
511 if (IS_ERR(ost))
512 return PTR_ERR(ost);
514 ret = ingenic_ost_global_timer_init(np, ost);
520 ret = ingenic_ost_percpu_timer_init(np, ost);
525 rate = clk_get_rate(ost->global_timer_clk);
531 clocksource_unregister(&ost->cs);
532 clk_disable_unprepare(ost->global_timer_clk);
533 clk_put(ost->global_timer_clk);
535 kfree(ost);
539 TIMER_OF_DECLARE(x1000_ost, "ingenic,x1000-ost", ingenic_ost_init);