Lines Matching +full:no +full:- +full:read +full:- +full:rollover
8 * Updated by Jean-Christophe Dubois <jcd@tribudubois.net>
11 * the COPYING file in the top-level directory.
75 CLK_NONE, /* 000 No clock source */
86 CLK_NONE, /* 000 No clock source */
97 CLK_NONE, /* 000 No clock source */
108 CLK_NONE, /* 000 No clock source */
119 CLK_NONE, /* 000 No clock source */
130 CLK_NONE, /* 000 No clock source */
143 uint32_t clksrc = extract32(s->cr, GPT_CR_CLKSRC_SHIFT, 3); in imx_gpt_set_freq()
145 s->freq = imx_ccm_get_clock_frequency(s->ccm, in imx_gpt_set_freq()
146 s->clocks[clksrc]) / (1 + s->pr); in imx_gpt_set_freq()
148 trace_imx_gpt_set_freq(clksrc, s->freq); in imx_gpt_set_freq()
150 if (s->freq) { in imx_gpt_set_freq()
151 ptimer_set_freq(s->timer, s->freq); in imx_gpt_set_freq()
157 if ((s->sr & s->ir) && (s->cr & GPT_CR_EN)) { in imx_gpt_update_int()
158 qemu_irq_raise(s->irq); in imx_gpt_update_int()
160 qemu_irq_lower(s->irq); in imx_gpt_update_int()
166 s->cnt = s->next_timeout - (uint32_t)ptimer_get_count(s->timer); in imx_gpt_update_count()
168 return s->cnt; in imx_gpt_update_count()
188 if (!(s->cr & GPT_CR_EN)) { in imx_gpt_compute_next_timeout()
199 * timer counter is now equal to s->next_timeout. in imx_gpt_compute_next_timeout()
201 if (!(s->cr & GPT_CR_FRR) && (count == s->ocr1)) { in imx_gpt_compute_next_timeout()
205 count = s->cnt = s->next_timeout = 0; in imx_gpt_compute_next_timeout()
207 /* We reached GPT_TIMER_MAX so we need to rollover */ in imx_gpt_compute_next_timeout()
208 count = s->cnt = s->next_timeout = 0; in imx_gpt_compute_next_timeout()
214 if (s->ir & GPT_IR_OF1IE) { in imx_gpt_compute_next_timeout()
215 timeout = imx_gpt_find_limit(count, s->ocr1, timeout); in imx_gpt_compute_next_timeout()
217 if (s->ir & GPT_IR_OF2IE) { in imx_gpt_compute_next_timeout()
218 timeout = imx_gpt_find_limit(count, s->ocr2, timeout); in imx_gpt_compute_next_timeout()
220 if (s->ir & GPT_IR_OF3IE) { in imx_gpt_compute_next_timeout()
221 timeout = imx_gpt_find_limit(count, s->ocr3, timeout); in imx_gpt_compute_next_timeout()
226 s->next_int = 0; in imx_gpt_compute_next_timeout()
227 if ((s->ir & GPT_IR_OF1IE) && (timeout == s->ocr1)) { in imx_gpt_compute_next_timeout()
228 s->next_int |= GPT_SR_OF1; in imx_gpt_compute_next_timeout()
230 if ((s->ir & GPT_IR_OF2IE) && (timeout == s->ocr2)) { in imx_gpt_compute_next_timeout()
231 s->next_int |= GPT_SR_OF2; in imx_gpt_compute_next_timeout()
233 if ((s->ir & GPT_IR_OF3IE) && (timeout == s->ocr3)) { in imx_gpt_compute_next_timeout()
234 s->next_int |= GPT_SR_OF3; in imx_gpt_compute_next_timeout()
236 if ((s->ir & GPT_IR_ROVIE) && (timeout == GPT_TIMER_MAX)) { in imx_gpt_compute_next_timeout()
237 s->next_int |= GPT_SR_ROV; in imx_gpt_compute_next_timeout()
241 limit = timeout - imx_gpt_update_count(s); in imx_gpt_compute_next_timeout()
249 s->sr |= s->next_int; in imx_gpt_compute_next_timeout()
256 s->next_timeout = timeout; in imx_gpt_compute_next_timeout()
259 ptimer_set_limit(s->timer, limit, 1); in imx_gpt_compute_next_timeout()
270 reg_value = s->cr; in imx_gpt_read()
274 reg_value = s->pr; in imx_gpt_read()
278 reg_value = s->sr; in imx_gpt_read()
282 reg_value = s->ir; in imx_gpt_read()
286 reg_value = s->ocr1; in imx_gpt_read()
290 reg_value = s->ocr2; in imx_gpt_read()
294 reg_value = s->ocr3; in imx_gpt_read()
300 reg_value = s->icr1; in imx_gpt_read()
306 reg_value = s->icr2; in imx_gpt_read()
311 reg_value = s->cnt; in imx_gpt_read()
328 ptimer_transaction_begin(s->timer); in imx_gpt_reset_common()
330 ptimer_stop(s->timer); in imx_gpt_reset_common()
333 * register -- soft reset preserves the values of some bits there. in imx_gpt_reset_common()
337 s->cr &= GPT_CR_EN | GPT_CR_ENMOD | GPT_CR_STOPEN | GPT_CR_DOZEN | in imx_gpt_reset_common()
341 s->cr = 0; in imx_gpt_reset_common()
343 s->sr = 0; in imx_gpt_reset_common()
344 s->pr = 0; in imx_gpt_reset_common()
345 s->ir = 0; in imx_gpt_reset_common()
346 s->cnt = 0; in imx_gpt_reset_common()
347 s->ocr1 = GPT_TIMER_MAX; in imx_gpt_reset_common()
348 s->ocr2 = GPT_TIMER_MAX; in imx_gpt_reset_common()
349 s->ocr3 = GPT_TIMER_MAX; in imx_gpt_reset_common()
350 s->icr1 = 0; in imx_gpt_reset_common()
351 s->icr2 = 0; in imx_gpt_reset_common()
353 s->next_timeout = GPT_TIMER_MAX; in imx_gpt_reset_common()
354 s->next_int = 0; in imx_gpt_reset_common()
360 ptimer_set_limit(s->timer, GPT_TIMER_MAX, 1); in imx_gpt_reset_common()
363 if (s->freq && (s->cr & GPT_CR_EN)) { in imx_gpt_reset_common()
364 ptimer_run(s->timer, 1); in imx_gpt_reset_common()
366 ptimer_transaction_commit(s->timer); in imx_gpt_reset_common()
391 oldreg = s->cr; in imx_gpt_write()
392 s->cr = value & ~0x7c14; in imx_gpt_write()
393 if (s->cr & GPT_CR_SWR) { /* force reset */ in imx_gpt_write()
398 ptimer_transaction_begin(s->timer); in imx_gpt_write()
401 if ((oldreg ^ s->cr) & GPT_CR_EN) { in imx_gpt_write()
402 if (s->cr & GPT_CR_EN) { in imx_gpt_write()
403 if (s->cr & GPT_CR_ENMOD) { in imx_gpt_write()
404 s->next_timeout = GPT_TIMER_MAX; in imx_gpt_write()
405 ptimer_set_count(s->timer, GPT_TIMER_MAX); in imx_gpt_write()
408 ptimer_run(s->timer, 1); in imx_gpt_write()
411 ptimer_stop(s->timer); in imx_gpt_write()
414 ptimer_transaction_commit(s->timer); in imx_gpt_write()
419 s->pr = value & 0xfff; in imx_gpt_write()
420 ptimer_transaction_begin(s->timer); in imx_gpt_write()
422 ptimer_transaction_commit(s->timer); in imx_gpt_write()
426 s->sr &= ~(value & 0x3f); in imx_gpt_write()
430 case 3: /* IR -- interrupt register */ in imx_gpt_write()
431 s->ir = value & 0x3f; in imx_gpt_write()
434 ptimer_transaction_begin(s->timer); in imx_gpt_write()
436 ptimer_transaction_commit(s->timer); in imx_gpt_write()
440 case 4: /* OCR1 -- output compare register */ in imx_gpt_write()
441 s->ocr1 = value; in imx_gpt_write()
443 ptimer_transaction_begin(s->timer); in imx_gpt_write()
444 /* In non-freerun mode, reset count when this register is written */ in imx_gpt_write()
445 if (!(s->cr & GPT_CR_FRR)) { in imx_gpt_write()
446 s->next_timeout = GPT_TIMER_MAX; in imx_gpt_write()
447 ptimer_set_limit(s->timer, GPT_TIMER_MAX, 1); in imx_gpt_write()
452 ptimer_transaction_commit(s->timer); in imx_gpt_write()
456 case 5: /* OCR2 -- output compare register */ in imx_gpt_write()
457 s->ocr2 = value; in imx_gpt_write()
460 ptimer_transaction_begin(s->timer); in imx_gpt_write()
462 ptimer_transaction_commit(s->timer); in imx_gpt_write()
466 case 6: /* OCR3 -- output compare register */ in imx_gpt_write()
467 s->ocr3 = value; in imx_gpt_write()
470 ptimer_transaction_begin(s->timer); in imx_gpt_write()
472 ptimer_transaction_commit(s->timer); in imx_gpt_write()
489 s->sr |= s->next_int; in imx_gpt_timeout()
490 s->next_int = 0; in imx_gpt_timeout()
496 if (s->freq && (s->cr & GPT_CR_EN)) { in imx_gpt_timeout()
497 ptimer_run(s->timer, 1); in imx_gpt_timeout()
502 .read = imx_gpt_read,
513 sysbus_init_irq(sbd, &s->irq); in imx_gpt_realize()
514 memory_region_init_io(&s->iomem, OBJECT(s), &imx_gpt_ops, s, TYPE_IMX_GPT, in imx_gpt_realize()
516 sysbus_init_mmio(sbd, &s->iomem); in imx_gpt_realize()
518 s->timer = ptimer_init(imx_gpt_timeout, s, PTIMER_POLICY_LEGACY); in imx_gpt_realize()
525 dc->realize = imx_gpt_realize; in imx_gpt_class_init()
527 dc->vmsd = &vmstate_imx_timer_gpt; in imx_gpt_class_init()
528 dc->desc = "i.MX general timer"; in imx_gpt_class_init()
535 s->clocks = imx25_gpt_clocks; in imx25_gpt_init()
542 s->clocks = imx31_gpt_clocks; in imx31_gpt_init()
549 s->clocks = imx6_gpt_clocks; in imx6_gpt_init()
556 s->clocks = imx6ul_gpt_clocks; in imx6ul_gpt_init()
563 s->clocks = imx7_gpt_clocks; in imx7_gpt_init()
570 s->clocks = imx8mp_gpt_clocks; in imx8mp_gpt_init()