arm: Move lastinc to arch_global_data
authorSimon Glass <sjg@chromium.org>
Thu, 13 Dec 2012 20:48:35 +0000 (20:48 +0000)
committerTom Rini <trini@ti.com>
Fri, 1 Feb 2013 20:07:50 +0000 (15:07 -0500)
Move this field into arch_global_data and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
25 files changed:
arch/arm/cpu/arm1136/mx31/timer.c
arch/arm/cpu/arm1136/mx35/timer.c
arch/arm/cpu/arm1136/omap24xx/timer.c
arch/arm/cpu/arm920t/at91/timer.c
arch/arm/cpu/arm920t/s3c24x0/timer.c
arch/arm/cpu/arm926ejs/kirkwood/timer.c
arch/arm/cpu/arm926ejs/mb86r0x/timer.c
arch/arm/cpu/arm926ejs/mx25/timer.c
arch/arm/cpu/arm926ejs/mx27/timer.c
arch/arm/cpu/arm926ejs/mxs/timer.c
arch/arm/cpu/arm926ejs/omap/timer.c
arch/arm/cpu/arm926ejs/orion5x/timer.c
arch/arm/cpu/arm926ejs/spear/timer.c
arch/arm/cpu/arm926ejs/versatile/timer.c
arch/arm/cpu/armv7/omap-common/timer.c
arch/arm/cpu/armv7/s5p-common/timer.c
arch/arm/cpu/armv7/socfpga/timer.c
arch/arm/cpu/armv7/u8500/timer.c
arch/arm/cpu/armv7/zynq/timer.c
arch/arm/cpu/ixp/timer.c
arch/arm/cpu/pxa/timer.c
arch/arm/cpu/tegra-common/timer.c
arch/arm/imx-common/timer.c
arch/arm/include/asm/global_data.h
arch/mips/cpu/xburst/timer.c

index 790bab457cb8b7b908d76ec552437bb68d278518..b006b6015de45928b668049b2e0ed7a1fdea833b 100644 (file)
@@ -115,12 +115,12 @@ unsigned long long get_ticks(void)
 {
        ulong now = GPTCNT; /* current tick value */
 
-       if (now >= gd->lastinc) /* normal mode (non roll) */
+       if (now >= gd->arch.lastinc)    /* normal mode (non roll) */
                /* move stamp forward with absolut diff ticks */
-               gd->arch.tbl += (now - gd->lastinc);
+               gd->arch.tbl += (now - gd->arch.lastinc);
        else                    /* we have rollover of incrementer */
-               gd->arch.tbl += (0xFFFFFFFF - gd->lastinc) + now;
-       gd->lastinc = now;
+               gd->arch.tbl += (0xFFFFFFFF - gd->arch.lastinc) + now;
+       gd->arch.lastinc = now;
        return gd->arch.tbl;
 }
 
index c21ca3f9833b83d319ab2f4d653bc345fa7f2563..584ad15135cf58ca0b024ff53a931c96b2936681 100644 (file)
@@ -33,7 +33,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 #define timestamp      (gd->arch.tbl)
-#define lastinc                (gd->lastinc)
+#define lastinc                (gd->arch.lastinc)
 
 /* General purpose timers bitfields */
 #define GPTCR_SWR       (1<<15)        /* Software reset */
index e179bb54d60e221dabe0cb4cd33483c25fd42f0f..53015cb77dc954016d6bbbec541d4d9c54d8cd02 100644 (file)
@@ -51,7 +51,7 @@ int timer_init (void)
        *((int32_t *) (CONFIG_SYS_TIMERBASE + TCLR)) = val;     /* start timer */
 
        /* reset time */
-       gd->lastinc = READ_TIMER;       /* capture current incrementer value */
+       gd->arch.lastinc = READ_TIMER;  /* capture current incrementer value */
        gd->arch.tbl = 0;               /* start "advancing" time stamp */
 
        return(0);
@@ -81,7 +81,7 @@ void __udelay (unsigned long usec)
        tmp = get_timer (0);            /* get current timestamp */
        if ((tmo + tmp + 1) < tmp) {    /* if setting this forward will roll */
                                        /* time stamp, then reset time */
-               gd->lastinc = READ_TIMER;       /* capture incrementer value */
+               gd->arch.lastinc = READ_TIMER;  /* capture incrementer value */
                gd->arch.tbl = 0;                       /* start time stamp */
        } else {
                tmo     += tmp;         /* else, set advancing stamp wake up time */
@@ -94,14 +94,14 @@ ulong get_timer_masked (void)
 {
        ulong now = READ_TIMER;         /* current tick value */
 
-       if (now >= gd->lastinc) {               /* normal mode (non roll) */
+       if (now >= gd->arch.lastinc) {          /* normal mode (non roll) */
                /* move stamp fordward with absoulte diff ticks */
-               gd->arch.tbl += (now - gd->lastinc);
+               gd->arch.tbl += (now - gd->arch.lastinc);
        } else {
                /* we have rollover of incrementer */
-               gd->arch.tbl += (0xFFFFFFFF - gd->lastinc) + now;
+               gd->arch.tbl += (0xFFFFFFFF - gd->arch.lastinc) + now;
        }
-       gd->lastinc = now;
+       gd->arch.lastinc = now;
        return gd->arch.tbl;
 }
 
index 439ceab950c71fb3bb04e4ae703022cc894b21a1..8ce75843a0e239e7000621f3b56fe278ed848db7 100644 (file)
@@ -63,7 +63,7 @@ int timer_init(void)
        writel(TIMER_LOAD_VAL, &tc->tc[0].rc);
 
        writel(AT91_TC_CCR_SWTRG | AT91_TC_CCR_CLKEN, &tc->tc[0].ccr);
-       gd->lastinc = 0;
+       gd->arch.lastinc = 0;
        gd->arch.tbl = 0;
 
        return 0;
@@ -89,14 +89,14 @@ ulong get_timer_raw(void)
 
        now = readl(&tc->tc[0].cv) & 0x0000ffff;
 
-       if (now >= gd->lastinc) {
+       if (now >= gd->arch.lastinc) {
                /* normal mode */
-               gd->arch.tbl += now - gd->lastinc;
+               gd->arch.tbl += now - gd->arch.lastinc;
        } else {
                /* we have an overflow ... */
-               gd->arch.tbl += now + TIMER_LOAD_VAL - gd->lastinc;
+               gd->arch.tbl += now + TIMER_LOAD_VAL - gd->arch.lastinc;
        }
-       gd->lastinc = now;
+       gd->arch.lastinc = now;
 
        return gd->arch.tbl;
 }
index eb2b8d081612ab826758f48fcb1ca95d03e42dff..d76bf186b6516891f2044a92a3a8c29ff2c2540e 100644 (file)
@@ -62,7 +62,7 @@ int timer_init(void)
        /* auto load, start timer 4 */
        tmr = (tmr & ~0x0700000) | 0x0500000;
        writel(tmr, &timers->tcon);
-       gd->lastinc = 0;
+       gd->arch.lastinc = 0;
        gd->arch.tbl = 0;
 
        return 0;
@@ -128,14 +128,14 @@ unsigned long long get_ticks(void)
        struct s3c24x0_timers *timers = s3c24x0_get_base_timers();
        ulong now = readl(&timers->tcnto4) & 0xffff;
 
-       if (gd->lastinc >= now) {
+       if (gd->arch.lastinc >= now) {
                /* normal mode */
-               gd->arch.tbl += gd->lastinc - now;
+               gd->arch.tbl += gd->arch.lastinc - now;
        } else {
                /* we have an overflow ... */
-               gd->arch.tbl += gd->lastinc + gd->arch.tbu - now;
+               gd->arch.tbl += gd->arch.lastinc + gd->arch.tbu - now;
        }
-       gd->lastinc = now;
+       gd->arch.lastinc = now;
 
        return gd->arch.tbl;
 }
index 41dc0745f165bf112c2d13f789e72d52d0d4078f..85e81e3f4438e0443db0317836a96a41fa6ceb39 100644 (file)
@@ -87,7 +87,7 @@ struct kwtmr_registers *kwtmr_regs = (struct kwtmr_registers *)KW_TIMER_BASE;
 DECLARE_GLOBAL_DATA_PTR;
 
 #define timestamp gd->arch.tbl
-#define lastdec gd->lastinc
+#define lastdec gd->arch.lastinc
 
 ulong get_timer_masked(void)
 {
index 1f1900e9099104f54e8ecfe52642bbc832601e04..c6486c13eb26acd00dcf488dbbcde1fc503757f0 100644 (file)
@@ -36,7 +36,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 #define timestamp gd->arch.tbl
-#define lastdec gd->lastinc
+#define lastdec gd->arch.lastinc
 
 static inline unsigned long long tick_to_time(unsigned long long tick)
 {
index 8b5217ff4fbe7b644f1c191e003b39da2ab823a7..f8bebccd63d4c844351cc82b6e0188dd64743763 100644 (file)
@@ -45,7 +45,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 #define timestamp      (gd->arch.tbl)
-#define lastinc                (gd->lastinc)
+#define lastinc                (gd->arch.lastinc)
 
 /*
  * "time" is measured in 1 / CONFIG_SYS_HZ seconds,
index 06e30867bd4740bcfa068c190da26b493678cf6f..07e132ad2f7d957fc2230d7c850fdfb4030ad87a 100644 (file)
@@ -46,7 +46,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 #define timestamp      (gd->arch.tbl)
-#define lastinc                (gd->lastinc)
+#define lastinc                (gd->arch.lastinc)
 
 /*
  * "time" is measured in 1 / CONFIG_SYS_HZ seconds,
index a12a7e31506123180c2702e8f87d3817aa600b2e..373841180ff84af4811695674170f278c5846c76 100644 (file)
@@ -37,7 +37,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 #define timestamp (gd->arch.tbl)
-#define lastdec (gd->lastinc)
+#define lastdec (gd->arch.lastinc)
 
 /*
  * This driver uses 1kHz clock source.
index 71b8700f0cffb519df469e48d284ce0112fc95d8..34ec7b2b1ccc6f6a7b24dcb7378978f07c250399 100644 (file)
@@ -45,7 +45,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 #define timestamp gd->arch.tbl
-#define lastdec gd->lastinc
+#define lastdec gd->arch.lastinc
 
 int timer_init (void)
 {
index f69af71b7942fd38ea5bebea8180340ad56cc804..f7233512cd78ef7db6f7cbaf762d95fa7815daa5 100644 (file)
@@ -93,7 +93,7 @@ static inline ulong read_timer(void)
 DECLARE_GLOBAL_DATA_PTR;
 
 #define timestamp gd->arch.tbl
-#define lastdec gd->lastinc
+#define lastdec gd->arch.lastinc
 
 ulong get_timer_masked(void)
 {
index 06ea65b66ee55142109b65864bb43c234f19c196..de4ba7b21345cfbc85abb178e118250c681be432 100644 (file)
@@ -39,7 +39,7 @@ static struct misc_regs *const misc_regs_p =
 DECLARE_GLOBAL_DATA_PTR;
 
 #define timestamp gd->arch.tbl
-#define lastdec gd->lastinc
+#define lastdec gd->arch.lastinc
 
 int timer_init(void)
 {
index be73b932960075aa9d642af276b450db1506ccf4..b36d6d93a57a865e36fbb301a859c59c03d93eff 100644 (file)
@@ -45,7 +45,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 #define timestamp gd->arch.tbl
-#define lastdec gd->lastinc
+#define lastdec gd->arch.lastinc
 
 #define TIMER_ENABLE   (1 << 7)
 #define TIMER_MODE_MSK (1 << 6)
index e321d53458d668251a9fa4169692f4c30e30b372..36bea5f94c118c8adeb69e83eb99800107c41921 100644 (file)
@@ -56,7 +56,8 @@ int timer_init(void)
                &timer_base->tclr);
 
        /* reset time, capture current incrementer value time */
-       gd->lastinc = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ);
+       gd->arch.lastinc = readl(&timer_base->tcrr) /
+                                       (TIMER_CLOCK / CONFIG_SYS_HZ);
        gd->arch.tbl = 0;       /* start "advancing" time stamp from 0 */
 
        return 0;
@@ -91,14 +92,14 @@ ulong get_timer_masked(void)
        /* current tick value */
        ulong now = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ);
 
-       if (now >= gd->lastinc) {       /* normal mode (non roll) */
+       if (now >= gd->arch.lastinc) {  /* normal mode (non roll) */
                /* move stamp fordward with absoulte diff ticks */
-               gd->arch.tbl += (now - gd->lastinc);
+               gd->arch.tbl += (now - gd->arch.lastinc);
        } else {        /* we have rollover of incrementer */
                gd->arch.tbl += ((TIMER_LOAD_VAL / (TIMER_CLOCK /
-                               CONFIG_SYS_HZ)) - gd->lastinc) + now;
+                               CONFIG_SYS_HZ)) - gd->arch.lastinc) + now;
        }
-       gd->lastinc = now;
+       gd->arch.lastinc = now;
        return gd->arch.tbl;
 }
 
index 156622638633da4a56c324e94b753b23c615e218..e78c716d3fa4e88953f05c31daac6a4e1f34eefe 100644 (file)
@@ -105,7 +105,7 @@ void reset_timer_masked(void)
        struct s5p_timer *const timer = s5p_get_base_timer();
 
        /* reset time */
-       gd->lastinc = readl(&timer->tcnto4);
+       gd->arch.lastinc = readl(&timer->tcnto4);
        gd->arch.tbl = 0;
 }
 
@@ -123,12 +123,12 @@ unsigned long get_current_tick(void)
        unsigned long now = readl(&timer->tcnto4);
        unsigned long count_value = readl(&timer->tcntb4);
 
-       if (gd->lastinc >= now)
-               gd->arch.tbl += gd->lastinc - now;
+       if (gd->arch.lastinc >= now)
+               gd->arch.tbl += gd->arch.lastinc - now;
        else
-               gd->arch.tbl += gd->lastinc + count_value - now;
+               gd->arch.tbl += gd->arch.lastinc + count_value - now;
 
-       gd->lastinc = now;
+       gd->arch.lastinc = now;
 
        return gd->arch.tbl;
 }
index a7421215369678a60a613bbd0749550bafc71c05..efa28c2ae9440e1352676ebd32942cf81af97395 100644 (file)
@@ -80,15 +80,15 @@ ulong get_timer_masked(void)
 {
        /* current tick value */
        ulong now = read_timer() / (CONFIG_TIMER_CLOCK_KHZ/CONFIG_SYS_HZ);
-       if (gd->lastinc >= now) {
+       if (gd->arch.lastinc >= now) {
                /* normal mode (non roll) */
                /* move stamp forward with absolute diff ticks */
-               gd->arch.tbl += gd->lastinc - now;
+               gd->arch.tbl += gd->arch.lastinc - now;
        } else {
                /* we have overflow of the count down timer */
-               gd->arch.tbl += TIMER_LOAD_VAL - gd->lastinc + now;
+               gd->arch.tbl += TIMER_LOAD_VAL - gd->arch.lastinc + now;
        }
-       gd->lastinc = now;
+       gd->arch.lastinc = now;
        return gd->arch.tbl;
 }
 
@@ -98,7 +98,8 @@ ulong get_timer_masked(void)
 void reset_timer(void)
 {
        /* capture current decrementer value time */
-       gd->lastinc = read_timer() / (CONFIG_TIMER_CLOCK_KHZ/CONFIG_SYS_HZ);
+       gd->arch.lastinc = read_timer() /
+                               (CONFIG_TIMER_CLOCK_KHZ / CONFIG_SYS_HZ);
        /* start "advancing" time stamp from 0 */
        gd->arch.tbl = 0;
 }
index a20897b76a96e970355c89764bec7f900f2722a5..a4b88f3815c096aa1db369918f02585c1d0a3e31 100644 (file)
@@ -100,13 +100,13 @@ ulong get_timer_masked(void)
        /* current tick value */
        ulong now = TICKS_TO_HZ(READ_TIMER());
 
-       if (now >= gd->lastinc) {       /* normal (non rollover) */
-               gd->arch.tbl += (now - gd->lastinc);
+       if (now >= gd->arch.lastinc) {  /* normal (non rollover) */
+               gd->arch.tbl += (now - gd->arch.lastinc);
        } else {                        /* rollover */
-               gd->arch.tbl += (TICKS_TO_HZ(TIMER_LOAD_VAL) - gd->lastinc)
-                               + now;
+               gd->arch.tbl += (TICKS_TO_HZ(TIMER_LOAD_VAL) -
+                                       gd->arch.lastinc) + now;
        }
-       gd->lastinc = now;
+       gd->arch.lastinc = now;
        return gd->arch.tbl;
 }
 
index e126ebbcd8a71aec73721a9ac7060f7f7845ac64..45b405a4ba2a764831615a24ecd86d2cb6214466 100644 (file)
@@ -83,7 +83,7 @@ int timer_init(void)
                                                                emask);
 
        /* Reset time */
-       gd->lastinc = readl(&timer_base->counter) /
+       gd->arch.lastinc = readl(&timer_base->counter) /
                                        (TIMER_TICK_HZ / CONFIG_SYS_HZ);
        gd->arch.tbl = 0;
 
@@ -100,14 +100,14 @@ ulong get_timer_masked(void)
 
        now = readl(&timer_base->counter) / (TIMER_TICK_HZ / CONFIG_SYS_HZ);
 
-       if (gd->lastinc >= now) {
+       if (gd->arch.lastinc >= now) {
                /* Normal mode */
-               gd->arch.tbl += gd->lastinc - now;
+               gd->arch.tbl += gd->arch.lastinc - now;
        } else {
                /* We have an overflow ... */
-               gd->arch.tbl += gd->lastinc + TIMER_LOAD_VAL - now;
+               gd->arch.tbl += gd->arch.lastinc + TIMER_LOAD_VAL - now;
        }
-       gd->lastinc = now;
+       gd->arch.lastinc = now;
 
        return gd->arch.tbl;
 }
index 087ddf80ef7c9f28ea62c3ca4d7a14530edffa22..0450b51031fecd8222dd80f35c37dc62061b8224 100644 (file)
@@ -70,13 +70,13 @@ unsigned long long get_ticks(void)
 
        if (readl(IXP425_OSST) & IXP425_OSST_TIMER_TS_PEND) {
                /* rollover of timestamp timer register */
-               gd->timestamp += (0xFFFFFFFF - gd->lastinc) + now + 1;
+               gd->timestamp += (0xFFFFFFFF - gd->arch.lastinc) + now + 1;
                writel(IXP425_OSST_TIMER_TS_PEND, IXP425_OSST);
        } else {
                /* move stamp forward with absolut diff ticks */
-               gd->timestamp += (now - gd->lastinc);
+               gd->timestamp += (now - gd->arch.lastinc);
        }
-       gd->lastinc = now;
+       gd->arch.lastinc = now;
        return gd->timestamp;
 }
 
@@ -84,7 +84,7 @@ unsigned long long get_ticks(void)
 void reset_timer_masked(void)
 {
        /* capture current timestamp counter */
-       gd->lastinc = readl(IXP425_OSTS_B);
+       gd->arch.lastinc = readl(IXP425_OSTS_B);
        /* start "advancing" time stamp from 0 */
        gd->timestamp = 0;
 }
index 7799c146b53f809f3afdb8a661d821c8d07b64f6..212b31eb6853f7d4182ef2b2b745dfe37abf8989 100644 (file)
@@ -32,7 +32,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define        TIMER_LOAD_VAL  0xffffffff
 
 #define        timestamp       (gd->arch.tbl)
-#define        lastinc         (gd->lastinc)
+#define        lastinc         (gd->arch.lastinc)
 
 #if defined(CONFIG_CPU_PXA27X) || defined(CONFIG_CPU_MONAHANS)
 #define        TIMER_FREQ_HZ   3250000
index dc9cc6cc3a9a1c5df27f6ae91dbeabcb8a03085f..51902e9544bc6a6d319482a355e636adbeb0bad8 100644 (file)
@@ -75,13 +75,13 @@ ulong get_timer_masked(void)
        /* current tick value */
        now = timer_get_us() / (TIMER_CLK / CONFIG_SYS_HZ);
 
-       if (now >= gd->lastinc) /* normal mode (non roll) */
+       if (now >= gd->arch.lastinc)    /* normal mode (non roll) */
                /* move stamp forward with absolute diff ticks */
-               gd->arch.tbl += (now - gd->lastinc);
+               gd->arch.tbl += (now - gd->arch.lastinc);
        else    /* we have rollover of incrementer */
                gd->arch.tbl += ((TIMER_LOAD_VAL / (TIMER_CLK / CONFIG_SYS_HZ))
-                               - gd->lastinc) + now;
-       gd->lastinc = now;
+                               - gd->arch.lastinc) + now;
+       gd->arch.lastinc = now;
        return gd->arch.tbl;
 }
 
index de21e44a20760e477a9a81d97ac084e6c9fbfc5a..ab37d641ece97c82f230ad9e6a89511fea8fddff 100644 (file)
@@ -49,7 +49,7 @@ static struct mxc_gpt *cur_gpt = (struct mxc_gpt *)GPT1_BASE_ADDR;
 DECLARE_GLOBAL_DATA_PTR;
 
 #define timestamp (gd->arch.tbl)
-#define lastinc (gd->lastinc)
+#define lastinc (gd->arch.lastinc)
 
 static inline unsigned long long tick_to_time(unsigned long long tick)
 {
index f44730804f64a67a5fd817622132358fa2d3b165..d7d47430f126311c40e0a2aae042fe017fc9715a 100644 (file)
@@ -39,6 +39,7 @@ struct arch_global_data {
        unsigned long timer_rate_hz;
        unsigned long tbu;
        unsigned long tbl;
+       unsigned long lastinc;
 };
 
 /*
@@ -66,7 +67,6 @@ typedef       struct  global_data {
 #ifdef CONFIG_ARM
        /* "static data" needed by most of timer.c on ARM platforms */
        unsigned long long      timer_reset_value;
-       unsigned long   lastinc;
 #endif
 #ifdef CONFIG_IXP425
        unsigned long   timestamp;
index 8ac8bf70ff96cfbfd93ded3e64c7af6c718cad42..8c33d3ca3c339266743e53fc9bbf39c812150848 100644 (file)
@@ -34,7 +34,7 @@ static struct jz4740_tcu *tcu = (struct jz4740_tcu *)JZ4740_TCU_BASE;
 void reset_timer_masked(void)
 {
        /* reset time */
-       gd->lastinc = readl(&tcu->tcnt0);
+       gd->arch.lastinc = readl(&tcu->tcnt0);
        gd->arch.tbl = 0;
 }
 
@@ -42,14 +42,14 @@ ulong get_timer_masked(void)
 {
        ulong now = readl(&tcu->tcnt0);
 
-       if (gd->lastinc <= now)
-               gd->arch.tbl += now - gd->lastinc; /* normal mode */
+       if (gd->arch.lastinc <= now)
+               gd->arch.tbl += now - gd->arch.lastinc; /* normal mode */
        else {
                /* we have an overflow ... */
-               gd->arch.tbl += TIMER_FDATA + now - gd->lastinc;
+               gd->arch.tbl += TIMER_FDATA + now - gd->arch.lastinc;
        }
 
-       gd->lastinc = now;
+       gd->arch.lastinc = now;
 
        return gd->arch.tbl;
 }
@@ -94,7 +94,7 @@ int timer_init(void)
        writel(1 << TIMER_CHAN, &tcu->tscr); /* enable timer clock */
        writeb(1 << TIMER_CHAN, &tcu->tesr); /* start counting up */
 
-       gd->lastinc = 0;
+       gd->arch.lastinc = 0;
        gd->arch.tbl = 0;
 
        return 0;