3737#define TIMER3_MATCH2 (0x2c)
3838#define TIMER_CR (0x30)
3939
40+ /*
41+ * Control register set to clear for ast2600 only.
42+ */
43+ #define AST2600_TIMER_CR_CLR (0x3c)
44+
4045/*
4146 * Control register (TMC30) bit fields for fttmr010/gemini/moxart timers.
4247 */
@@ -163,6 +168,16 @@ static int fttmr010_timer_set_next_event(unsigned long cycles,
163168 return 0 ;
164169}
165170
171+ static int ast2600_timer_shutdown (struct clock_event_device * evt )
172+ {
173+ struct fttmr010 * fttmr010 = to_fttmr010 (evt );
174+
175+ /* Stop */
176+ writel (fttmr010 -> t1_enable_val , fttmr010 -> base + AST2600_TIMER_CR_CLR );
177+
178+ return 0 ;
179+ }
180+
166181static int fttmr010_timer_shutdown (struct clock_event_device * evt )
167182{
168183 struct fttmr010 * fttmr010 = to_fttmr010 (evt );
@@ -244,7 +259,21 @@ static irqreturn_t fttmr010_timer_interrupt(int irq, void *dev_id)
244259 return IRQ_HANDLED ;
245260}
246261
247- static int __init fttmr010_common_init (struct device_node * np , bool is_aspeed )
262+ static irqreturn_t ast2600_timer_interrupt (int irq , void * dev_id )
263+ {
264+ struct clock_event_device * evt = dev_id ;
265+ struct fttmr010 * fttmr010 = to_fttmr010 (evt );
266+
267+ writel (0x1 , fttmr010 -> base + TIMER_INTR_STATE );
268+
269+ evt -> event_handler (evt );
270+ return IRQ_HANDLED ;
271+ }
272+
273+ static int __init fttmr010_common_init (struct device_node * np ,
274+ bool is_aspeed ,
275+ int (* timer_shutdown )(struct clock_event_device * ),
276+ irq_handler_t irq_handler )
248277{
249278 struct fttmr010 * fttmr010 ;
250279 int irq ;
@@ -345,7 +374,7 @@ static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed)
345374 fttmr010 -> tick_rate );
346375 }
347376
348- fttmr010 -> timer_shutdown = fttmr010_timer_shutdown ;
377+ fttmr010 -> timer_shutdown = timer_shutdown ;
349378
350379 /*
351380 * Setup clockevent timer (interrupt-driven) on timer 1.
@@ -354,7 +383,7 @@ static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed)
354383 writel (0 , fttmr010 -> base + TIMER1_LOAD );
355384 writel (0 , fttmr010 -> base + TIMER1_MATCH1 );
356385 writel (0 , fttmr010 -> base + TIMER1_MATCH2 );
357- ret = request_irq (irq , fttmr010_timer_interrupt , IRQF_TIMER ,
386+ ret = request_irq (irq , irq_handler , IRQF_TIMER ,
358387 "FTTMR010-TIMER1" , & fttmr010 -> clkevt );
359388 if (ret ) {
360389 pr_err ("FTTMR010-TIMER1 no IRQ\n" );
@@ -401,18 +430,30 @@ static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed)
401430 return ret ;
402431}
403432
433+ static __init int ast2600_timer_init (struct device_node * np )
434+ {
435+ return fttmr010_common_init (np , true,
436+ ast2600_timer_shutdown ,
437+ ast2600_timer_interrupt );
438+ }
439+
404440static __init int aspeed_timer_init (struct device_node * np )
405441{
406- return fttmr010_common_init (np , true);
442+ return fttmr010_common_init (np , true,
443+ fttmr010_timer_shutdown ,
444+ fttmr010_timer_interrupt );
407445}
408446
409447static __init int fttmr010_timer_init (struct device_node * np )
410448{
411- return fttmr010_common_init (np , false);
449+ return fttmr010_common_init (np , false,
450+ fttmr010_timer_shutdown ,
451+ fttmr010_timer_interrupt );
412452}
413453
414454TIMER_OF_DECLARE (fttmr010 , "faraday,fttmr010" , fttmr010_timer_init );
415455TIMER_OF_DECLARE (gemini , "cortina,gemini-timer" , fttmr010_timer_init );
416456TIMER_OF_DECLARE (moxart , "moxa,moxart-timer" , fttmr010_timer_init );
417457TIMER_OF_DECLARE (ast2400 , "aspeed,ast2400-timer" , aspeed_timer_init );
418458TIMER_OF_DECLARE (ast2500 , "aspeed,ast2500-timer" , aspeed_timer_init );
459+ TIMER_OF_DECLARE (ast2600 , "aspeed,ast2600-timer" , ast2600_timer_init );
0 commit comments