Commit 3eb90bad651fab39cffba750ec4421a9c01d60e7
Committed by
Wolfgang Denk
1 parent
1c409bc710
Exists in
master
and in
54 other branches
Generic udelay() with watchdog support
According to the PPC reference implementation the udelay() function is responsible for resetting the watchdog timer as frequently as needed. Most other architectures do not meet that requirement, so long-running operations might result in a watchdog reset. This patch adds a generic udelay() function which takes care of resetting the watchdog before calling an architecture-specific __udelay(). Signed-off-by: Ingo van Lil <inguin@gmx.de>
Showing 47 changed files with 98 additions and 62 deletions Side-by-side Diff
- board/armltd/integrator/timer.c
- board/freescale/mpc8313erdb/sdram.c
- cpu/arm1136/mx31/timer.c
- cpu/arm1136/omap24xx/timer.c
- cpu/arm1176/s3c64xx/timer.c
- cpu/arm720t/interrupts.c
- cpu/arm920t/at91rm9200/timer.c
- cpu/arm920t/imx/timer.c
- cpu/arm920t/ks8695/timer.c
- cpu/arm920t/s3c24x0/timer.c
- cpu/arm925t/timer.c
- cpu/arm926ejs/at91/timer.c
- cpu/arm926ejs/davinci/timer.c
- cpu/arm926ejs/kirkwood/timer.c
- cpu/arm926ejs/mx27/timer.c
- cpu/arm926ejs/nomadik/timer.c
- cpu/arm926ejs/omap/timer.c
- cpu/arm926ejs/versatile/timer.c
- cpu/arm_cortexa8/omap3/timer.c
- cpu/arm_cortexa8/s5pc1xx/timer.c
- cpu/at32ap/interrupts.c
- cpu/blackfin/interrupts.c
- cpu/i386/sc520/sc520_timer.c
- cpu/ixp/start.S
- cpu/ixp/timer.c
- cpu/lh7a40x/timer.c
- cpu/mcf547x_8x/slicetimer.c
- cpu/pxa/timer.c
- cpu/s3c44b0/timer.c
- cpu/sa1100/timer.c
- examples/api/Makefile
- examples/api/libgenwrap.c
- include/asm-blackfin/delay.h
- include/common.h
- include/exports.h
- lib_generic/Makefile
- lib_generic/time.c
- lib_i386/pcat_timer.c
- lib_m68k/time.c
- lib_microblaze/time.c
- lib_mips/time.c
- lib_nios/time.c
- lib_nios2/time.c
- lib_ppc/time.c
- lib_sh/time.c
- lib_sh/time_sh2.c
- lib_sparc/time.c
board/armltd/integrator/timer.c
board/freescale/mpc8313erdb/sdram.c
... | ... | @@ -72,7 +72,7 @@ |
72 | 72 | * Erratum DDR3 requires a 50ms delay after clearing DDRCDR[DDR_cfg], |
73 | 73 | * or the DDR2 controller may fail to initialize correctly. |
74 | 74 | */ |
75 | - udelay(50000); | |
75 | + __udelay(50000); | |
76 | 76 | |
77 | 77 | im->ddr.csbnds[0].csbnds = (msize - 1) >> 24; |
78 | 78 | im->ddr.cs_config[0] = CONFIG_SYS_DDR_CONFIG; |
cpu/arm1136/mx31/timer.c
cpu/arm1136/omap24xx/timer.c
cpu/arm1176/s3c64xx/timer.c
cpu/arm720t/interrupts.c
... | ... | @@ -224,7 +224,7 @@ |
224 | 224 | timestamp = t; |
225 | 225 | } |
226 | 226 | |
227 | -void udelay (unsigned long usec) | |
227 | +void __udelay (unsigned long usec) | |
228 | 228 | { |
229 | 229 | ulong tmo; |
230 | 230 | |
... | ... | @@ -296,7 +296,7 @@ |
296 | 296 | return timestamp - base; |
297 | 297 | } |
298 | 298 | |
299 | -void udelay (unsigned long usec) | |
299 | +void __udelay (unsigned long usec) | |
300 | 300 | { |
301 | 301 | u32 ticks; |
302 | 302 |
cpu/arm920t/at91rm9200/timer.c
cpu/arm920t/imx/timer.c
cpu/arm920t/ks8695/timer.c
cpu/arm920t/s3c24x0/timer.c
cpu/arm925t/timer.c
... | ... | @@ -81,7 +81,7 @@ |
81 | 81 | } |
82 | 82 | |
83 | 83 | /* delay x useconds AND preserve advance timestamp value */ |
84 | -void udelay (unsigned long usec) | |
84 | +void __udelay (unsigned long usec) | |
85 | 85 | { |
86 | 86 | int32_t tmo = usec * (TIMER_CLOCK / 1000) / 1000; |
87 | 87 | uint32_t now, last = __raw_readl(CONFIG_SYS_TIMERBASE + READ_TIM); |
cpu/arm926ejs/at91/timer.c
cpu/arm926ejs/davinci/timer.c
cpu/arm926ejs/kirkwood/timer.c
cpu/arm926ejs/mx27/timer.c
cpu/arm926ejs/nomadik/timer.c
cpu/arm926ejs/omap/timer.c
cpu/arm926ejs/versatile/timer.c
cpu/arm_cortexa8/omap3/timer.c
cpu/arm_cortexa8/s5pc1xx/timer.c
cpu/at32ap/interrupts.c
cpu/blackfin/interrupts.c
cpu/i386/sc520/sc520_timer.c
cpu/ixp/start.S
cpu/ixp/timer.c
cpu/lh7a40x/timer.c
cpu/mcf547x_8x/slicetimer.c
cpu/pxa/timer.c
cpu/s3c44b0/timer.c
cpu/sa1100/timer.c
examples/api/Makefile
... | ... | @@ -44,6 +44,7 @@ |
44 | 44 | EXT_COBJ_FILES-$(CONFIG_API) += lib_generic/ctype.o |
45 | 45 | EXT_COBJ_FILES-$(CONFIG_API) += lib_generic/div64.o |
46 | 46 | EXT_COBJ_FILES-$(CONFIG_API) += lib_generic/string.o |
47 | +EXT_COBJ_FILES-$(CONFIG_API) += lib_generic/time.o | |
47 | 48 | EXT_COBJ_FILES-$(CONFIG_API) += lib_generic/vsprintf.o |
48 | 49 | ifeq ($(ARCH),ppc) |
49 | 50 | EXT_SOBJ_FILES-$(CONFIG_API) += lib_ppc/ppcstring.o |
examples/api/libgenwrap.c
include/asm-blackfin/delay.h
include/common.h
... | ... | @@ -607,10 +607,13 @@ |
607 | 607 | void wait_ticks (unsigned long); |
608 | 608 | |
609 | 609 | /* lib_$(ARCH)/time.c */ |
610 | -void udelay (unsigned long); | |
610 | +void __udelay (unsigned long); | |
611 | 611 | ulong usec2ticks (unsigned long usec); |
612 | 612 | ulong ticks2usec (unsigned long ticks); |
613 | 613 | int init_timebase (void); |
614 | + | |
615 | +/* lib_generic/time.c */ | |
616 | +void udelay (unsigned long); | |
614 | 617 | |
615 | 618 | /* lib_generic/vsprintf.c */ |
616 | 619 | ulong simple_strtoul(const char *cp,char **endp,unsigned int base); |
include/exports.h
lib_generic/Makefile
lib_generic/time.c
1 | +/* | |
2 | + * (C) Copyright 2000-2009 | |
3 | + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | |
4 | + * | |
5 | + * See file CREDITS for list of people who contributed to this | |
6 | + * project. | |
7 | + * | |
8 | + * This program is free software; you can redistribute it and/or | |
9 | + * modify it under the terms of the GNU General Public License as | |
10 | + * published by the Free Software Foundation; either version 2 of | |
11 | + * the License, or (at your option) any later version. | |
12 | + * | |
13 | + * This program is distributed in the hope that it will be useful, | |
14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | + * GNU General Public License for more details. | |
17 | + * | |
18 | + * You should have received a copy of the GNU General Public License | |
19 | + * along with this program; if not, write to the Free Software | |
20 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | |
21 | + * MA 02111-1307 USA | |
22 | + */ | |
23 | + | |
24 | +#include <common.h> | |
25 | +#include <watchdog.h> | |
26 | + | |
27 | +#ifndef CONFIG_WD_PERIOD | |
28 | +# define CONFIG_WD_PERIOD (10 * 1000 * 1000) /* 10 seconds default*/ | |
29 | +#endif | |
30 | + | |
31 | +/* ------------------------------------------------------------------------- */ | |
32 | + | |
33 | +void udelay(unsigned long usec) | |
34 | +{ | |
35 | + ulong kv; | |
36 | + | |
37 | + do { | |
38 | + WATCHDOG_RESET(); | |
39 | + kv = usec > CONFIG_WD_PERIOD ? CONFIG_WD_PERIOD : usec; | |
40 | + __udelay (kv); | |
41 | + usec -= kv; | |
42 | + } while(usec); | |
43 | +} |
lib_i386/pcat_timer.c
lib_m68k/time.c
... | ... | @@ -47,7 +47,7 @@ |
47 | 47 | #endif |
48 | 48 | extern void dtimer_intr_setup(void); |
49 | 49 | |
50 | -void udelay(unsigned long usec) | |
50 | +void __udelay(unsigned long usec) | |
51 | 51 | { |
52 | 52 | volatile dtmr_t *timerp = (dtmr_t *) (CONFIG_SYS_UDELAY_BASE); |
53 | 53 | uint start, now, tmp; |
... | ... | @@ -139,7 +139,7 @@ |
139 | 139 | |
140 | 140 | static unsigned short lastinc; |
141 | 141 | |
142 | -void udelay(unsigned long usec) | |
142 | +void __udelay(unsigned long usec) | |
143 | 143 | { |
144 | 144 | volatile pit_t *timerp = (pit_t *) (CONFIG_SYS_UDELAY_BASE); |
145 | 145 | uint tmp; |
lib_microblaze/time.c
... | ... | @@ -27,14 +27,14 @@ |
27 | 27 | #include <common.h> |
28 | 28 | |
29 | 29 | #ifdef CONFIG_SYS_TIMER_0 |
30 | -void udelay (unsigned long usec) | |
30 | +void __udelay (unsigned long usec) | |
31 | 31 | { |
32 | 32 | int i; |
33 | 33 | i = get_timer (0); |
34 | 34 | while ((get_timer (0) - i) < (usec / 1000)) ; |
35 | 35 | } |
36 | 36 | #else |
37 | -void udelay (unsigned long usec) | |
37 | +void __udelay (unsigned long usec) | |
38 | 38 | { |
39 | 39 | unsigned int i; |
40 | 40 | for (i = 0; i < (usec * CONFIG_XILINX_CLOCK_FREQ / 10000000); i++); |
lib_mips/time.c
lib_nios/time.c
... | ... | @@ -27,14 +27,13 @@ |
27 | 27 | |
28 | 28 | extern void dly_clks( unsigned long ticks ); |
29 | 29 | |
30 | -void udelay(unsigned long usec) | |
30 | +void __udelay(unsigned long usec) | |
31 | 31 | { |
32 | 32 | /* The Nios core doesn't have a timebase, so we do our |
33 | 33 | * best for now and call a low-level loop that counts |
34 | 34 | * cpu clocks. |
35 | 35 | */ |
36 | 36 | unsigned long cnt = (CONFIG_SYS_CLK_FREQ/1000000) * usec; |
37 | - WATCHDOG_RESET (); /* trigger watchdog if needed */ | |
38 | 37 | dly_clks (cnt); |
39 | 38 | } |
lib_nios2/time.c
... | ... | @@ -27,14 +27,13 @@ |
27 | 27 | |
28 | 28 | extern void dly_clks( unsigned long ticks ); |
29 | 29 | |
30 | -void udelay(unsigned long usec) | |
30 | +void __udelay(unsigned long usec) | |
31 | 31 | { |
32 | 32 | /* The Nios core doesn't have a timebase, so we do our |
33 | 33 | * best for now and call a low-level loop that counts |
34 | 34 | * cpu clocks. |
35 | 35 | */ |
36 | 36 | unsigned long cnt = (CONFIG_SYS_CLK_FREQ/1000000) * usec; |
37 | - WATCHDOG_RESET (); /* trigger watchdog if needed */ | |
38 | 37 | dly_clks (cnt); |
39 | 38 | } |
lib_ppc/time.c
... | ... | @@ -23,10 +23,6 @@ |
23 | 23 | |
24 | 24 | #include <common.h> |
25 | 25 | |
26 | -#ifndef CONFIG_WD_PERIOD | |
27 | -# define CONFIG_WD_PERIOD (10 * 1000 * 1000) /* 10 seconds default*/ | |
28 | -#endif | |
29 | - | |
30 | 26 | /* ------------------------------------------------------------------------- */ |
31 | 27 | |
32 | 28 | /* |
33 | 29 | |
... | ... | @@ -54,16 +50,10 @@ |
54 | 50 | * microseconds to wait) into a number of time base ticks; then we |
55 | 51 | * watch the time base until it has incremented by that amount. |
56 | 52 | */ |
57 | -void udelay(unsigned long usec) | |
53 | +void __udelay(unsigned long usec) | |
58 | 54 | { |
59 | - ulong ticks, kv; | |
60 | - | |
61 | - do { | |
62 | - kv = usec > CONFIG_WD_PERIOD ? CONFIG_WD_PERIOD : usec; | |
63 | - ticks = usec2ticks (kv); | |
64 | - wait_ticks (ticks); | |
65 | - usec -= kv; | |
66 | - } while(usec); | |
55 | + ulong ticks = usec2ticks (usec); | |
56 | + wait_ticks (ticks); | |
67 | 57 | } |
68 | 58 | |
69 | 59 | /* ------------------------------------------------------------------------- */ |
lib_sh/time.c
lib_sh/time_sh2.c
lib_sparc/time.c
... | ... | @@ -53,7 +53,7 @@ |
53 | 53 | * microseconds to wait) into a number of time base ticks; then we |
54 | 54 | * watch the time base until it has incremented by that amount. |
55 | 55 | */ |
56 | -void udelay(unsigned long usec) | |
56 | +void __udelay(unsigned long usec) | |
57 | 57 | { |
58 | 58 | ulong ticks = usec2ticks(usec); |
59 | 59 |