Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clockevents/drivers/exynos_mct: Migrate to new 'set-state' interface

Migrate exynos_mct driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

Cc: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

authored by

Viresh Kumar and committed by
Daniel Lezcano
79e436d3 cf4541c1

+41 -46
+41 -46
drivers/clocksource/exynos_mct.c
··· 257 257 exynos4_mct_write(0, EXYNOS4_MCT_G_INT_ENB); 258 258 } 259 259 260 - static void exynos4_mct_comp0_start(enum clock_event_mode mode, 261 - unsigned long cycles) 260 + static void exynos4_mct_comp0_start(bool periodic, unsigned long cycles) 262 261 { 263 262 unsigned int tcon; 264 263 cycle_t comp_cycle; 265 264 266 265 tcon = readl_relaxed(reg_base + EXYNOS4_MCT_G_TCON); 267 266 268 - if (mode == CLOCK_EVT_MODE_PERIODIC) { 267 + if (periodic) { 269 268 tcon |= MCT_G_TCON_COMP0_AUTO_INC; 270 269 exynos4_mct_write(cycles, EXYNOS4_MCT_G_COMP0_ADD_INCR); 271 270 } ··· 282 283 static int exynos4_comp_set_next_event(unsigned long cycles, 283 284 struct clock_event_device *evt) 284 285 { 285 - exynos4_mct_comp0_start(evt->mode, cycles); 286 + exynos4_mct_comp0_start(false, cycles); 286 287 287 288 return 0; 288 289 } 289 290 290 - static void exynos4_comp_set_mode(enum clock_event_mode mode, 291 - struct clock_event_device *evt) 291 + static int mct_set_state_shutdown(struct clock_event_device *evt) 292 + { 293 + exynos4_mct_comp0_stop(); 294 + return 0; 295 + } 296 + 297 + static int mct_set_state_periodic(struct clock_event_device *evt) 292 298 { 293 299 unsigned long cycles_per_jiffy; 300 + 301 + cycles_per_jiffy = (((unsigned long long)NSEC_PER_SEC / HZ * evt->mult) 302 + >> evt->shift); 294 303 exynos4_mct_comp0_stop(); 295 - 296 - switch (mode) { 297 - case CLOCK_EVT_MODE_PERIODIC: 298 - cycles_per_jiffy = 299 - (((unsigned long long) NSEC_PER_SEC / HZ * evt->mult) >> evt->shift); 300 - exynos4_mct_comp0_start(mode, cycles_per_jiffy); 301 - break; 302 - 303 - case CLOCK_EVT_MODE_ONESHOT: 304 - case CLOCK_EVT_MODE_UNUSED: 305 - case CLOCK_EVT_MODE_SHUTDOWN: 306 - case CLOCK_EVT_MODE_RESUME: 307 - break; 308 - } 304 + exynos4_mct_comp0_start(true, cycles_per_jiffy); 305 + return 0; 309 306 } 310 307 311 308 static struct clock_event_device mct_comp_device = { 312 - .name = "mct-comp", 313 - .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, 314 - .rating = 250, 315 - .set_next_event = exynos4_comp_set_next_event, 316 - .set_mode = exynos4_comp_set_mode, 309 + .name = "mct-comp", 310 + .features = CLOCK_EVT_FEAT_PERIODIC | 311 + CLOCK_EVT_FEAT_ONESHOT, 312 + .rating = 250, 313 + .set_next_event = exynos4_comp_set_next_event, 314 + .set_state_periodic = mct_set_state_periodic, 315 + .set_state_shutdown = mct_set_state_shutdown, 316 + .set_state_oneshot = mct_set_state_shutdown, 317 + .tick_resume = mct_set_state_shutdown, 317 318 }; 318 319 319 320 static irqreturn_t exynos4_mct_comp_isr(int irq, void *dev_id) ··· 389 390 return 0; 390 391 } 391 392 392 - static inline void exynos4_tick_set_mode(enum clock_event_mode mode, 393 - struct clock_event_device *evt) 393 + static int set_state_shutdown(struct clock_event_device *evt) 394 + { 395 + exynos4_mct_tick_stop(this_cpu_ptr(&percpu_mct_tick)); 396 + return 0; 397 + } 398 + 399 + static int set_state_periodic(struct clock_event_device *evt) 394 400 { 395 401 struct mct_clock_event_device *mevt = this_cpu_ptr(&percpu_mct_tick); 396 402 unsigned long cycles_per_jiffy; 397 403 404 + cycles_per_jiffy = (((unsigned long long)NSEC_PER_SEC / HZ * evt->mult) 405 + >> evt->shift); 398 406 exynos4_mct_tick_stop(mevt); 399 - 400 - switch (mode) { 401 - case CLOCK_EVT_MODE_PERIODIC: 402 - cycles_per_jiffy = 403 - (((unsigned long long) NSEC_PER_SEC / HZ * evt->mult) >> evt->shift); 404 - exynos4_mct_tick_start(cycles_per_jiffy, mevt); 405 - break; 406 - 407 - case CLOCK_EVT_MODE_ONESHOT: 408 - case CLOCK_EVT_MODE_UNUSED: 409 - case CLOCK_EVT_MODE_SHUTDOWN: 410 - case CLOCK_EVT_MODE_RESUME: 411 - break; 412 - } 407 + exynos4_mct_tick_start(cycles_per_jiffy, mevt); 408 + return 0; 413 409 } 414 410 415 411 static void exynos4_mct_tick_clear(struct mct_clock_event_device *mevt) 416 412 { 417 - struct clock_event_device *evt = &mevt->evt; 418 - 419 413 /* 420 414 * This is for supporting oneshot mode. 421 415 * Mct would generate interrupt periodically 422 416 * without explicit stopping. 423 417 */ 424 - if (evt->mode != CLOCK_EVT_MODE_PERIODIC) 418 + if (!clockevent_state_periodic(&mevt->evt)) 425 419 exynos4_mct_tick_stop(mevt); 426 420 427 421 /* Clear the MCT tick interrupt */ ··· 445 453 evt->name = mevt->name; 446 454 evt->cpumask = cpumask_of(cpu); 447 455 evt->set_next_event = exynos4_tick_set_next_event; 448 - evt->set_mode = exynos4_tick_set_mode; 456 + evt->set_state_periodic = set_state_periodic; 457 + evt->set_state_shutdown = set_state_shutdown; 458 + evt->set_state_oneshot = set_state_shutdown; 459 + evt->tick_resume = set_state_shutdown; 449 460 evt->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; 450 461 evt->rating = 450; 451 462 ··· 474 479 { 475 480 struct clock_event_device *evt = &mevt->evt; 476 481 477 - evt->set_mode(CLOCK_EVT_MODE_UNUSED, evt); 482 + evt->set_state_shutdown(evt); 478 483 if (mct_int_type == MCT_INT_SPI) { 479 484 if (evt->irq != -1) 480 485 disable_irq_nosync(evt->irq);