[uClinux-dev] Re: [PATCH]: espd_4510b: time.c was: timer-problems with arm, linux-2.6.11.8-hsc0

Håkan Kvist hagar at df.lth.se
Wed Aug 24 10:24:05 EDT 2005


On Wed, Aug 24, 2005 at 04:19:39PM +0200, Håkan Kvist wrote:
> Hi.
> 
> I had problems with the espd 4510b target:
> 
> 1. calling sleep functions made the target sleep for about the double
>    requested time (according to the clock of the target)
> 
> 2. The time jumped backwards with 80-90 s every now and then.
> 
> This was probably due to a faulty implementation of the gettimeoffset
> function. 
> With the attatched patch, atleast my target behaves normal.
> 
> This patch is against linux-2.6.8.11-hsc0.

Sorry it is against, linux-2.6.11.8-hsc0 and not linux-2.6.8.11-hsc0
(that one has never existed).

regards
Håkan

> 
> --- ../linux-2.6.8.11/arch/arm/mach-espd_4510b/time.c	2005-08-10 11:12:28.000000000 +0200
> +++ linux-2.6.8.11/arch/arm/mach-espd_4510b/time.c	2005-08-24 15:58:46.778908015 +0200
> @@ -26,7 +26,6 @@
>  #include <asm/system.h>
>  #include <asm/leds.h>
>  #include <asm/mach-types.h>
> -                                                                                                                                           
>  #include <asm/io.h>
>  #include <asm/irq.h>
>  #include <asm/mach/time.h>
> @@ -34,35 +33,39 @@
>  #include <asm/hardware.h>
>  #include <asm/arch/timex.h>
>  #include <asm/mach/irq.h>
> -                                                                                                                                           
> +
>  #define CLOCKS_PER_USEC (CONFIG_ARM_CLK/1000000)
> -                                                                                                                                           
> +#define S3C4510B_PERIOD  (CLOCK_TICK_RATE/HZ)
> +
>  static volatile unsigned long timer_cnt;
> -                                                                                                                                           
> +
>  unsigned long s3c4510b_gettimeoffset (void)
>  {
> -        unsigned long usec;
> -                                                                                                                                           
> -        /* returns microseconds -- timer 1 is free running in countdown mode */
> -        usec = 0xFFFFFFFF - inl( REG_TCNT1);
> -        usec /= CLOCKS_PER_USEC;
> -                                                                                                                                           
> -        return usec;
> +  /* This driver was returning 0 in the kernel 2.4 version */
> +  
> +  unsigned long usec;
> +
> +  /* returns microseconds -- timer 1 is free running in countdown mode */
> +  /* usec = 0xFFFFFFFF - inl( REG_TCNT1);
> +     usec /= CLOCKS_PER_USEC;
> +  */
> +
> +  usec = S3C4510B_PERIOD - inl( REG_TCNT0);
> +  usec /= CLOCKS_PER_USEC;
> +  
> +  return usec;
>  }
> -                                                                                                                                           
> +
>  static irqreturn_t
>  s3c4510b_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
>  {
> -                                                                                                                                           
>          timer_cnt++;
> -                                                                                                                                           
>  #ifdef CONFIG_ARCH_ESPD_4510B
>          if ( ! (timer_cnt % (HZ/4))) {
>                  LED_TOGGLE(0);
>          }
>  #endif
>          timer_tick(regs);
> -                                                                                                                                           
>          return IRQ_HANDLED;
>  }
>  
> @@ -72,48 +75,49 @@
>          .handler        = s3c4510b_timer_interrupt
>  };
>  
> -                                                                                                                                           
>  /*
>   * Set up timer interrupt
>   */
>                                                                                                                                             
>  void __init  s3c4510b_time_init (void)
>  {
> -        u_int32_t period;
> -                                                                                                                                           
> +  /*u_int32_t period;*/
> +
>          /*
>           * disable and clear timers 0 and 1.  set both timers to
>           * interval mode.
>           */
>          outl( 0x0, REG_TMOD);
> +
>          /* clear any pending interrupts */
>          outl( 0x1FFFFF, REG_INTPEND);
> -                                                                                                                                           
> +
>          timer_cnt = 0;
> -                                                                                                                                           
> +
>          /* initialize the timer period */
> -        period = (CLOCK_TICK_RATE / HZ);
> -        outl( period, REG_TDATA0);
> -                                                                                                                                           
> +        /*period = (CLOCK_TICK_RATE / HZ);*/
> +        /*outl( period, REG_TDATA0);*/
> +        outl(S3C4510B_PERIOD, REG_TDATA0); 
> +
>          /* set timer1 to continually count down from FFFFFFFF */
> -        outl( 0xFFFFFFFF, REG_TDATA1);
> -                                                                                                                                           
> -//      printk(KERN_INFO "time_init():  TICK_RATE: %u, HZ: %u, period: %u\n", CLOCK_TICK_RATE, HZ, period);
> -                                                                                                                                           
> +        /* outl( 0xFFFFFFFF, REG_TDATA1); */
> +
> +        //printk(KERN_INFO "time_init():  TICK_RATE: %u, HZ: %u, period: %u\n", CLOCK_TICK_RATE, HZ, S3C4510B_PERIOD);
> +
>          s3c4510b_timer_irq.handler = s3c4510b_timer_interrupt;
> -                                                                                                                                           
> -        /* set up the interrupt vevtor for timer 0 match */
> +
> +        /* set up the interrupt vector for timer 0 match */
>          setup_irq( INT_TIMER0, &s3c4510b_timer_irq);
> -                                                                                                                                           
> +
>          /* enable the timer IRQ */
>          INT_ENABLE( INT_TIMER0);
> -                                                                                                                                           
> +
>          /* let timer 0 run... */
> -        outl( TM0_RUN | TM1_RUN, REG_TMOD);
> +        /*outl( TM0_RUN | TM1_RUN, REG_TMOD);*/
> +        outl( TM0_RUN, REG_TMOD);
>  }
> -                                                                                                                                           
> +
>  struct sys_timer s3c4510b_timer = {
> -        .init           = s3c4510b_time_init,
> -        .offset         = s3c4510b_gettimeoffset,
> +  .init           = s3c4510b_time_init,
> +  .offset         = s3c4510b_gettimeoffset,
>  };
> -
> _______________________________________________
> uClinux-dev mailing list
> uClinux-dev at uclinux.org
> http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
> This message was resent by uclinux-dev at uclinux.org
-- 
Håkan Kvist                  el-post: hagar at df.lth.se
telefon: 0703-14 21 14       hemsida: www.df.lth.se/~hagar



More information about the uClinux-dev mailing list