@@ -58,43 +58,38 @@ static int constant_set_state_oneshot(struct clock_event_device *evt)
5858 return 0 ;
5959}
6060
61- static int constant_set_state_oneshot_stopped (struct clock_event_device * evt )
61+ static int constant_set_state_periodic (struct clock_event_device * evt )
6262{
63+ unsigned long period ;
6364 unsigned long timer_config ;
6465
6566 raw_spin_lock (& state_lock );
6667
67- timer_config = csr_read64 (LOONGARCH_CSR_TCFG );
68- timer_config &= ~CSR_TCFG_EN ;
68+ period = const_clock_freq / HZ ;
69+ timer_config = period & CSR_TCFG_VAL ;
70+ timer_config |= (CSR_TCFG_PERIOD | CSR_TCFG_EN );
6971 csr_write64 (timer_config , LOONGARCH_CSR_TCFG );
7072
7173 raw_spin_unlock (& state_lock );
7274
7375 return 0 ;
7476}
7577
76- static int constant_set_state_periodic (struct clock_event_device * evt )
78+ static int constant_set_state_shutdown (struct clock_event_device * evt )
7779{
78- unsigned long period ;
7980 unsigned long timer_config ;
8081
8182 raw_spin_lock (& state_lock );
8283
83- period = const_clock_freq / HZ ;
84- timer_config = period & CSR_TCFG_VAL ;
85- timer_config |= (CSR_TCFG_PERIOD | CSR_TCFG_EN );
84+ timer_config = csr_read64 (LOONGARCH_CSR_TCFG );
85+ timer_config &= ~CSR_TCFG_EN ;
8686 csr_write64 (timer_config , LOONGARCH_CSR_TCFG );
8787
8888 raw_spin_unlock (& state_lock );
8989
9090 return 0 ;
9191}
9292
93- static int constant_set_state_shutdown (struct clock_event_device * evt )
94- {
95- return 0 ;
96- }
97-
9893static int constant_timer_next_event (unsigned long delta , struct clock_event_device * evt )
9994{
10095 unsigned long timer_config ;
@@ -161,7 +156,7 @@ int constant_clockevent_init(void)
161156 cd -> rating = 320 ;
162157 cd -> cpumask = cpumask_of (cpu );
163158 cd -> set_state_oneshot = constant_set_state_oneshot ;
164- cd -> set_state_oneshot_stopped = constant_set_state_oneshot_stopped ;
159+ cd -> set_state_oneshot_stopped = constant_set_state_shutdown ;
165160 cd -> set_state_periodic = constant_set_state_periodic ;
166161 cd -> set_state_shutdown = constant_set_state_shutdown ;
167162 cd -> set_next_event = constant_timer_next_event ;
0 commit comments