Lines Matching refs:td
119 static int tim_timer_irq(const TestData *td) in tim_timer_irq() argument
121 return td->tim->irq_base + timer_index(td->timer); in tim_timer_irq()
126 static void tim_write(const TestData *td, in tim_write() argument
129 writel(td->tim->base_addr + offset, value); in tim_write()
132 static uint32_t tim_read(const TestData *td, unsigned int offset) in tim_read() argument
134 return readl(td->tim->base_addr + offset); in tim_read()
137 static void tim_write_tcsr(const TestData *td, uint32_t value) in tim_write_tcsr() argument
139 tim_write(td, td->timer->tcsr_offset, value); in tim_write_tcsr()
142 static uint32_t tim_read_tcsr(const TestData *td) in tim_read_tcsr() argument
144 return tim_read(td, td->timer->tcsr_offset); in tim_read_tcsr()
147 static void tim_write_ticr(const TestData *td, uint32_t value) in tim_write_ticr() argument
149 tim_write(td, td->timer->ticr_offset, value); in tim_write_ticr()
152 static uint32_t tim_read_ticr(const TestData *td) in tim_read_ticr() argument
154 return tim_read(td, td->timer->ticr_offset); in tim_read_ticr()
157 static uint32_t tim_read_tdr(const TestData *td) in tim_read_tdr() argument
159 return tim_read(td, td->timer->tdr_offset); in tim_read_tdr()
169 static uint32_t tim_timer_bit(const TestData *td) in tim_timer_bit() argument
171 return BIT(timer_index(td->timer)); in tim_timer_bit()
175 static void tim_reset(const TestData *td) in tim_reset() argument
192 const TestData *td = test_data; in test_reset() local
194 tim_reset(td); in test_reset()
196 g_assert_cmphex(tim_read_tcsr(td), ==, TCSR_DEFAULT); in test_reset()
197 g_assert_cmphex(tim_read_ticr(td), ==, 0); in test_reset()
198 g_assert_cmphex(tim_read_tdr(td), ==, 0); in test_reset()
199 g_assert_cmphex(tim_read(td, TISR), ==, 0); in test_reset()
200 g_assert_cmphex(tim_read(td, WTCR), ==, WTCLK(1)); in test_reset()
206 const TestData *td = test_data; in test_reset_overrides_enable() local
208 tim_reset(td); in test_reset_overrides_enable()
211 tim_write_tcsr(td, CEN | CRST | TCSR_DEFAULT); in test_reset_overrides_enable()
213 g_assert_cmphex(tim_read_tcsr(td), ==, TCSR_DEFAULT); in test_reset_overrides_enable()
214 g_assert_cmphex(tim_read_tdr(td), ==, 0); in test_reset_overrides_enable()
215 g_assert_cmphex(tim_read(td, TISR), ==, 0); in test_reset_overrides_enable()
221 const TestData *td = test_data; in test_oneshot_enable_then_disable() local
223 tim_reset(td); in test_oneshot_enable_then_disable()
226 tim_write_tcsr(td, CEN | TCSR_DEFAULT); in test_oneshot_enable_then_disable()
227 tim_write_tcsr(td, TCSR_DEFAULT); in test_oneshot_enable_then_disable()
229 g_assert_cmphex(tim_read_tcsr(td), ==, TCSR_DEFAULT); in test_oneshot_enable_then_disable()
230 g_assert_cmphex(tim_read_tdr(td), ==, 0); in test_oneshot_enable_then_disable()
232 g_assert_cmphex(tim_read(td, TISR), ==, tim_timer_bit(td)); in test_oneshot_enable_then_disable()
233 g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); in test_oneshot_enable_then_disable()
239 const TestData *td = test_data; in test_oneshot_ps5() local
243 tim_reset(td); in test_oneshot_ps5()
245 tim_write_ticr(td, count); in test_oneshot_ps5()
246 tim_write_tcsr(td, CEN | PRESCALE(ps)); in test_oneshot_ps5()
247 g_assert_cmphex(tim_read_tcsr(td), ==, CEN | CACT | PRESCALE(ps)); in test_oneshot_ps5()
248 g_assert_cmpuint(tim_read_tdr(td), ==, count); in test_oneshot_ps5()
252 g_assert_cmphex(tim_read_tcsr(td), ==, CEN | CACT | PRESCALE(ps)); in test_oneshot_ps5()
253 g_assert_cmpuint(tim_read_tdr(td), <, count); in test_oneshot_ps5()
254 g_assert_cmphex(tim_read(td, TISR), ==, 0); in test_oneshot_ps5()
258 g_assert_cmphex(tim_read_tcsr(td), ==, PRESCALE(ps)); in test_oneshot_ps5()
259 g_assert_cmpuint(tim_read_tdr(td), ==, count); in test_oneshot_ps5()
260 g_assert_cmphex(tim_read(td, TISR), ==, tim_timer_bit(td)); in test_oneshot_ps5()
261 g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); in test_oneshot_ps5()
264 tim_write(td, TISR, tim_timer_bit(td)); in test_oneshot_ps5()
265 g_assert_cmphex(tim_read(td, TISR), ==, 0); in test_oneshot_ps5()
266 g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); in test_oneshot_ps5()
270 g_assert_cmphex(tim_read(td, TISR), ==, 0); in test_oneshot_ps5()
271 g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); in test_oneshot_ps5()
277 const TestData *td = test_data; in test_oneshot_ps0() local
281 tim_reset(td); in test_oneshot_ps0()
283 tim_write_ticr(td, count); in test_oneshot_ps0()
284 tim_write_tcsr(td, CEN | PRESCALE(ps)); in test_oneshot_ps0()
285 g_assert_cmphex(tim_read_tcsr(td), ==, CEN | CACT | PRESCALE(ps)); in test_oneshot_ps0()
286 g_assert_cmpuint(tim_read_tdr(td), ==, count); in test_oneshot_ps0()
290 g_assert_cmphex(tim_read_tcsr(td), ==, CEN | CACT | PRESCALE(ps)); in test_oneshot_ps0()
291 g_assert_cmpuint(tim_read_tdr(td), <, count); in test_oneshot_ps0()
292 g_assert_cmphex(tim_read(td, TISR), ==, 0); in test_oneshot_ps0()
296 g_assert_cmphex(tim_read_tcsr(td), ==, PRESCALE(ps)); in test_oneshot_ps0()
297 g_assert_cmpuint(tim_read_tdr(td), ==, count); in test_oneshot_ps0()
298 g_assert_cmphex(tim_read(td, TISR), ==, tim_timer_bit(td)); in test_oneshot_ps0()
299 g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); in test_oneshot_ps0()
305 const TestData *td = test_data; in test_oneshot_ps255() local
309 tim_reset(td); in test_oneshot_ps255()
311 tim_write_ticr(td, count); in test_oneshot_ps255()
312 tim_write_tcsr(td, CEN | PRESCALE(ps)); in test_oneshot_ps255()
313 g_assert_cmphex(tim_read_tcsr(td), ==, CEN | CACT | PRESCALE(ps)); in test_oneshot_ps255()
314 g_assert_cmpuint(tim_read_tdr(td), ==, count); in test_oneshot_ps255()
318 g_assert_cmphex(tim_read_tcsr(td), ==, CEN | CACT | PRESCALE(ps)); in test_oneshot_ps255()
319 g_assert_cmpuint(tim_read_tdr(td), <, count); in test_oneshot_ps255()
320 g_assert_cmphex(tim_read(td, TISR), ==, 0); in test_oneshot_ps255()
324 g_assert_cmphex(tim_read_tcsr(td), ==, PRESCALE(ps)); in test_oneshot_ps255()
325 g_assert_cmpuint(tim_read_tdr(td), ==, count); in test_oneshot_ps255()
326 g_assert_cmphex(tim_read(td, TISR), ==, tim_timer_bit(td)); in test_oneshot_ps255()
327 g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); in test_oneshot_ps255()
333 const TestData *td = test_data; in test_oneshot_interrupt() local
337 tim_reset(td); in test_oneshot_interrupt()
339 tim_write_ticr(td, count); in test_oneshot_interrupt()
340 tim_write_tcsr(td, IE | CEN | MODE_ONESHOT | PRESCALE(ps)); in test_oneshot_interrupt()
344 g_assert_cmphex(tim_read(td, TISR), ==, tim_timer_bit(td)); in test_oneshot_interrupt()
345 g_assert_true(qtest_get_irq(global_qtest, tim_timer_irq(td))); in test_oneshot_interrupt()
354 const TestData *td = test_data; in test_pause_resume() local
358 tim_reset(td); in test_pause_resume()
360 tim_write_ticr(td, count); in test_pause_resume()
361 tim_write_tcsr(td, IE | CEN | MODE_ONESHOT | PRESCALE(ps)); in test_pause_resume()
365 tim_write_tcsr(td, IE | MODE_ONESHOT | PRESCALE(ps)); in test_pause_resume()
366 g_assert_cmpuint(tim_read_tdr(td), ==, count / 2); in test_pause_resume()
370 g_assert_cmpuint(tim_read_tdr(td), ==, count / 2); in test_pause_resume()
371 g_assert_cmphex(tim_read(td, TISR), ==, 0); in test_pause_resume()
372 g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); in test_pause_resume()
375 tim_write_tcsr(td, IE | CEN | MODE_ONESHOT | PRESCALE(ps)); in test_pause_resume()
377 g_assert_cmpuint(tim_read_tdr(td), <, count); in test_pause_resume()
378 g_assert_cmphex(tim_read(td, TISR), ==, 0); in test_pause_resume()
379 g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); in test_pause_resume()
383 g_assert_cmphex(tim_read(td, TISR), ==, tim_timer_bit(td)); in test_pause_resume()
384 g_assert_true(qtest_get_irq(global_qtest, tim_timer_irq(td))); in test_pause_resume()
390 const TestData *td = test_data; in test_prescaler_change() local
394 tim_reset(td); in test_prescaler_change()
396 tim_write_ticr(td, count); in test_prescaler_change()
397 tim_write_tcsr(td, CEN | MODE_ONESHOT | PRESCALE(ps)); in test_prescaler_change()
401 g_assert_cmpuint(tim_read_tdr(td), ==, 3 * count / 4); in test_prescaler_change()
403 tim_write_tcsr(td, CEN | MODE_ONESHOT | PRESCALE(ps)); in test_prescaler_change()
405 g_assert_cmpuint(tim_read_tdr(td), ==, 3 * count / 4); in test_prescaler_change()
409 g_assert_cmpuint(tim_read_tdr(td), ==, count / 2); in test_prescaler_change()
411 tim_write_tcsr(td, CEN | MODE_ONESHOT | PRESCALE(ps)); in test_prescaler_change()
413 g_assert_cmpuint(tim_read_tdr(td), ==, count / 2); in test_prescaler_change()
417 g_assert_cmpuint(tim_read_tdr(td), ==, count / 4); in test_prescaler_change()
419 tim_write_tcsr(td, CEN | MODE_ONESHOT | PRESCALE(ps)); in test_prescaler_change()
421 g_assert_cmpuint(tim_read_tdr(td), ==, count / 4); in test_prescaler_change()
425 g_assert_cmpuint(tim_read_tdr(td), <, count); in test_prescaler_change()
426 g_assert_cmphex(tim_read(td, TISR), ==, 0); in test_prescaler_change()
430 g_assert_cmphex(tim_read(td, TISR), ==, tim_timer_bit(td)); in test_prescaler_change()
436 const TestData *td = test_data; in test_periodic_no_interrupt() local
441 tim_reset(td); in test_periodic_no_interrupt()
443 tim_write_ticr(td, count); in test_periodic_no_interrupt()
444 tim_write_tcsr(td, CEN | MODE_PERIODIC | PRESCALE(ps)); in test_periodic_no_interrupt()
449 g_assert_cmphex(tim_read(td, TISR), ==, tim_timer_bit(td)); in test_periodic_no_interrupt()
450 g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); in test_periodic_no_interrupt()
452 tim_write(td, TISR, tim_timer_bit(td)); in test_periodic_no_interrupt()
454 g_assert_cmphex(tim_read(td, TISR), ==, 0); in test_periodic_no_interrupt()
455 g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); in test_periodic_no_interrupt()
462 const TestData *td = test_data; in test_periodic_interrupt() local
467 tim_reset(td); in test_periodic_interrupt()
469 tim_write_ticr(td, count); in test_periodic_interrupt()
470 tim_write_tcsr(td, CEN | IE | MODE_PERIODIC | PRESCALE(ps)); in test_periodic_interrupt()
475 g_assert_cmphex(tim_read(td, TISR), ==, tim_timer_bit(td)); in test_periodic_interrupt()
476 g_assert_true(qtest_get_irq(global_qtest, tim_timer_irq(td))); in test_periodic_interrupt()
478 tim_write(td, TISR, tim_timer_bit(td)); in test_periodic_interrupt()
480 g_assert_cmphex(tim_read(td, TISR), ==, 0); in test_periodic_interrupt()
481 g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); in test_periodic_interrupt()
491 const TestData *td = test_data; in test_disable_on_expiration() local
495 tim_reset(td); in test_disable_on_expiration()
497 tim_write_ticr(td, count); in test_disable_on_expiration()
498 tim_write_tcsr(td, CEN | MODE_ONESHOT | PRESCALE(ps)); in test_disable_on_expiration()
502 tim_write_tcsr(td, MODE_ONESHOT | PRESCALE(ps)); in test_disable_on_expiration()
503 tim_write_tcsr(td, CEN | MODE_ONESHOT | PRESCALE(ps)); in test_disable_on_expiration()
505 tim_write_tcsr(td, MODE_ONESHOT | PRESCALE(ps)); in test_disable_on_expiration()
506 g_assert_cmphex(tim_read(td, TISR), ==, tim_timer_bit(td)); in test_disable_on_expiration()
513 static void tim_add_test(const char *name, const TestData *td, GTestDataFunc fn) in tim_add_test() argument
516 "npcm7xx_timer/tim[%d]/timer[%d]/%s", tim_index(td->tim), in tim_add_test()
517 timer_index(td->timer), name); in tim_add_test()
518 qtest_add_data_func(full_name, td, fn); in tim_add_test()
522 #define add_test(name, td) tim_add_test(#name, td, test_##name) argument
535 TestData *td = &testdata[i * ARRAY_SIZE(timer) + j]; in main() local
536 td->tim = &timer_block[i]; in main()
537 td->timer = &timer[j]; in main()
539 add_test(reset, td); in main()
540 add_test(reset_overrides_enable, td); in main()
541 add_test(oneshot_enable_then_disable, td); in main()
542 add_test(oneshot_ps5, td); in main()
543 add_test(oneshot_ps0, td); in main()
544 add_test(oneshot_ps255, td); in main()
545 add_test(oneshot_interrupt, td); in main()
546 add_test(pause_resume, td); in main()
547 add_test(prescaler_change, td); in main()
548 add_test(periodic_no_interrupt, td); in main()
549 add_test(periodic_interrupt, td); in main()
550 add_test(disable_on_expiration, td); in main()