|
@@ -78,55 +78,77 @@ static void hpet_enable_legacy_int(void)
|
|
/* Do nothing on Loongson-3 */
|
|
/* Do nothing on Loongson-3 */
|
|
}
|
|
}
|
|
|
|
|
|
-static void hpet_set_mode(enum clock_event_mode mode,
|
|
|
|
- struct clock_event_device *evt)
|
|
|
|
|
|
+static int hpet_set_state_periodic(struct clock_event_device *evt)
|
|
{
|
|
{
|
|
- int cfg = 0;
|
|
|
|
|
|
+ int cfg;
|
|
|
|
|
|
spin_lock(&hpet_lock);
|
|
spin_lock(&hpet_lock);
|
|
- switch (mode) {
|
|
|
|
- case CLOCK_EVT_MODE_PERIODIC:
|
|
|
|
- pr_info("set clock event to periodic mode!\n");
|
|
|
|
- /* stop counter */
|
|
|
|
- hpet_stop_counter();
|
|
|
|
-
|
|
|
|
- /* enables the timer0 to generate a periodic interrupt */
|
|
|
|
- cfg = hpet_read(HPET_T0_CFG);
|
|
|
|
- cfg &= ~HPET_TN_LEVEL;
|
|
|
|
- cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC |
|
|
|
|
- HPET_TN_SETVAL | HPET_TN_32BIT;
|
|
|
|
- hpet_write(HPET_T0_CFG, cfg);
|
|
|
|
-
|
|
|
|
- /* set the comparator */
|
|
|
|
- hpet_write(HPET_T0_CMP, HPET_COMPARE_VAL);
|
|
|
|
- udelay(1);
|
|
|
|
- hpet_write(HPET_T0_CMP, HPET_COMPARE_VAL);
|
|
|
|
-
|
|
|
|
- /* start counter */
|
|
|
|
- hpet_start_counter();
|
|
|
|
- break;
|
|
|
|
- case CLOCK_EVT_MODE_SHUTDOWN:
|
|
|
|
- case CLOCK_EVT_MODE_UNUSED:
|
|
|
|
- cfg = hpet_read(HPET_T0_CFG);
|
|
|
|
- cfg &= ~HPET_TN_ENABLE;
|
|
|
|
- hpet_write(HPET_T0_CFG, cfg);
|
|
|
|
- break;
|
|
|
|
- case CLOCK_EVT_MODE_ONESHOT:
|
|
|
|
- pr_info("set clock event to one shot mode!\n");
|
|
|
|
- cfg = hpet_read(HPET_T0_CFG);
|
|
|
|
- /* set timer0 type
|
|
|
|
- * 1 : periodic interrupt
|
|
|
|
- * 0 : non-periodic(oneshot) interrupt
|
|
|
|
- */
|
|
|
|
- cfg &= ~HPET_TN_PERIODIC;
|
|
|
|
- cfg |= HPET_TN_ENABLE | HPET_TN_32BIT;
|
|
|
|
- hpet_write(HPET_T0_CFG, cfg);
|
|
|
|
- break;
|
|
|
|
- case CLOCK_EVT_MODE_RESUME:
|
|
|
|
- hpet_enable_legacy_int();
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ pr_info("set clock event to periodic mode!\n");
|
|
|
|
+ /* stop counter */
|
|
|
|
+ hpet_stop_counter();
|
|
|
|
+
|
|
|
|
+ /* enables the timer0 to generate a periodic interrupt */
|
|
|
|
+ cfg = hpet_read(HPET_T0_CFG);
|
|
|
|
+ cfg &= ~HPET_TN_LEVEL;
|
|
|
|
+ cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC | HPET_TN_SETVAL |
|
|
|
|
+ HPET_TN_32BIT;
|
|
|
|
+ hpet_write(HPET_T0_CFG, cfg);
|
|
|
|
+
|
|
|
|
+ /* set the comparator */
|
|
|
|
+ hpet_write(HPET_T0_CMP, HPET_COMPARE_VAL);
|
|
|
|
+ udelay(1);
|
|
|
|
+ hpet_write(HPET_T0_CMP, HPET_COMPARE_VAL);
|
|
|
|
+
|
|
|
|
+ /* start counter */
|
|
|
|
+ hpet_start_counter();
|
|
|
|
+
|
|
|
|
+ spin_unlock(&hpet_lock);
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int hpet_set_state_shutdown(struct clock_event_device *evt)
|
|
|
|
+{
|
|
|
|
+ int cfg;
|
|
|
|
+
|
|
|
|
+ spin_lock(&hpet_lock);
|
|
|
|
+
|
|
|
|
+ cfg = hpet_read(HPET_T0_CFG);
|
|
|
|
+ cfg &= ~HPET_TN_ENABLE;
|
|
|
|
+ hpet_write(HPET_T0_CFG, cfg);
|
|
|
|
+
|
|
spin_unlock(&hpet_lock);
|
|
spin_unlock(&hpet_lock);
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int hpet_set_state_oneshot(struct clock_event_device *evt)
|
|
|
|
+{
|
|
|
|
+ int cfg;
|
|
|
|
+
|
|
|
|
+ spin_lock(&hpet_lock);
|
|
|
|
+
|
|
|
|
+ pr_info("set clock event to one shot mode!\n");
|
|
|
|
+ cfg = hpet_read(HPET_T0_CFG);
|
|
|
|
+ /*
|
|
|
|
+ * set timer0 type
|
|
|
|
+ * 1 : periodic interrupt
|
|
|
|
+ * 0 : non-periodic(oneshot) interrupt
|
|
|
|
+ */
|
|
|
|
+ cfg &= ~HPET_TN_PERIODIC;
|
|
|
|
+ cfg |= HPET_TN_ENABLE | HPET_TN_32BIT;
|
|
|
|
+ hpet_write(HPET_T0_CFG, cfg);
|
|
|
|
+
|
|
|
|
+ spin_unlock(&hpet_lock);
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int hpet_tick_resume(struct clock_event_device *evt)
|
|
|
|
+{
|
|
|
|
+ spin_lock(&hpet_lock);
|
|
|
|
+ hpet_enable_legacy_int();
|
|
|
|
+ spin_unlock(&hpet_lock);
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
}
|
|
}
|
|
|
|
|
|
static int hpet_next_event(unsigned long delta,
|
|
static int hpet_next_event(unsigned long delta,
|
|
@@ -206,7 +228,10 @@ void __init setup_hpet_timer(void)
|
|
cd->name = "hpet";
|
|
cd->name = "hpet";
|
|
cd->rating = 320;
|
|
cd->rating = 320;
|
|
cd->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
|
|
cd->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
|
|
- cd->set_mode = hpet_set_mode;
|
|
|
|
|
|
+ cd->set_state_shutdown = hpet_set_state_shutdown;
|
|
|
|
+ cd->set_state_periodic = hpet_set_state_periodic;
|
|
|
|
+ cd->set_state_oneshot = hpet_set_state_oneshot;
|
|
|
|
+ cd->tick_resume = hpet_tick_resume;
|
|
cd->set_next_event = hpet_next_event;
|
|
cd->set_next_event = hpet_next_event;
|
|
cd->irq = HPET_T0_IRQ;
|
|
cd->irq = HPET_T0_IRQ;
|
|
cd->cpumask = cpumask_of(cpu);
|
|
cd->cpumask = cpumask_of(cpu);
|