static int apbt_resume(struct clock_event_device *evt) { struct dw_apb_clock_event_device *dw_ced = ced_to_dw_apb_ced(evt); pr_debug("%s CPU %d state=resume\n", __func__, cpumask_first(evt->cpumask)); apbt_enable_int(&dw_ced->timer); return 0; }
/** * dw_apb_clockevent_register() - register the clock with the generic layer * * @dw_ced: The APB clock to register as a clock_event_device. */ void dw_apb_clockevent_register(struct dw_apb_clock_event_device *dw_ced) { apbt_writel(&dw_ced->timer, 0, APBTMR_N_CONTROL); clockevents_register_device(&dw_ced->ced); apbt_enable_int(&dw_ced->timer); }
static void apbt_set_mode(enum clock_event_mode mode, struct clock_event_device *evt) { unsigned long ctrl; unsigned long period; struct dw_apb_clock_event_device *dw_ced = ced_to_dw_apb_ced(evt); pr_debug("%s CPU %d mode=%d\n", __func__, first_cpu(*evt->cpumask), mode); switch (mode) { case CLOCK_EVT_MODE_PERIODIC: period = DIV_ROUND_UP(dw_ced->timer.freq, HZ); ctrl = apbt_readl(&dw_ced->timer, APBTMR_N_CONTROL); ctrl |= APBTMR_CONTROL_MODE_PERIODIC; apbt_writel(&dw_ced->timer, ctrl, APBTMR_N_CONTROL); /* * DW APB p. 46, have to disable timer before load counter, * may cause sync problem. */ ctrl &= ~APBTMR_CONTROL_ENABLE; apbt_writel(&dw_ced->timer, ctrl, APBTMR_N_CONTROL); udelay(1); pr_debug("Setting clock period %lu for HZ %d\n", period, HZ); apbt_writel(&dw_ced->timer, period, APBTMR_N_LOAD_COUNT); ctrl |= APBTMR_CONTROL_ENABLE; apbt_writel(&dw_ced->timer, ctrl, APBTMR_N_CONTROL); break; case CLOCK_EVT_MODE_ONESHOT: ctrl = apbt_readl(&dw_ced->timer, APBTMR_N_CONTROL); /* * set free running mode, this mode will let timer reload max * timeout which will give time (3min on 25MHz clock) to rearm * the next event, therefore emulate the one-shot mode. */ ctrl &= ~APBTMR_CONTROL_ENABLE; ctrl &= ~APBTMR_CONTROL_MODE_PERIODIC; apbt_writel(&dw_ced->timer, ctrl, APBTMR_N_CONTROL); /* write again to set free running mode */ apbt_writel(&dw_ced->timer, ctrl, APBTMR_N_CONTROL); /* * DW APB p. 46, load counter with all 1s before starting free * running mode. */ apbt_writel(&dw_ced->timer, ~0, APBTMR_N_LOAD_COUNT); ctrl &= ~APBTMR_CONTROL_INT; ctrl |= APBTMR_CONTROL_ENABLE; apbt_writel(&dw_ced->timer, ctrl, APBTMR_N_CONTROL); break; case CLOCK_EVT_MODE_UNUSED: case CLOCK_EVT_MODE_SHUTDOWN: ctrl = apbt_readl(&dw_ced->timer, APBTMR_N_CONTROL); ctrl &= ~APBTMR_CONTROL_ENABLE; apbt_writel(&dw_ced->timer, ctrl, APBTMR_N_CONTROL); break; case CLOCK_EVT_MODE_RESUME: apbt_enable_int(&dw_ced->timer); break; } }