* [U-Boot] [PATCH] ARM: bcm2835: fix get_timer() to return mS
@ 2013-03-22 3:32 Stephen Warren
2013-03-28 9:00 ` Albert ARIBAUD
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Warren @ 2013-03-22 3:32 UTC (permalink / raw)
To: u-boot
Apparently, CONFIG_SYS_HZ must be 1000. Change this, and fix the timer
driver to conform to this.
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
---
arch/arm/cpu/arm1176/bcm2835/timer.c | 13 +++++++++----
include/configs/rpi_b.h | 2 +-
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/arch/arm/cpu/arm1176/bcm2835/timer.c b/arch/arm/cpu/arm1176/bcm2835/timer.c
index d232d7e..f550020 100644
--- a/arch/arm/cpu/arm1176/bcm2835/timer.c
+++ b/arch/arm/cpu/arm1176/bcm2835/timer.c
@@ -23,12 +23,17 @@ int timer_init(void)
return 0;
}
-ulong get_timer(ulong base)
+ulong get_timer_us(void)
{
struct bcm2835_timer_regs *regs =
(struct bcm2835_timer_regs *)BCM2835_TIMER_PHYSADDR;
- return readl(®s->clo) - base;
+ return readl(®s->clo);
+}
+
+ulong get_timer(ulong base)
+{
+ return (get_timer_us() / 1000) - base;
}
unsigned long long get_ticks(void)
@@ -46,10 +51,10 @@ void __udelay(unsigned long usec)
ulong endtime;
signed long diff;
- endtime = get_timer(0) + usec;
+ endtime = get_timer_us() + usec;
do {
- ulong now = get_timer(0);
+ ulong now = get_timer_us();
diff = endtime - now;
} while (diff >= 0);
}
diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h
index 3d55d36..c18b35b 100644
--- a/include/configs/rpi_b.h
+++ b/include/configs/rpi_b.h
@@ -31,7 +31,7 @@
#define CONFIG_MACH_TYPE MACH_TYPE_BCM2708
/* Timer */
-#define CONFIG_SYS_HZ 1000000
+#define CONFIG_SYS_HZ 1000
/* Memory layout */
#define CONFIG_NR_DRAM_BANKS 1
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* [U-Boot] [PATCH] ARM: bcm2835: fix get_timer() to return mS
2013-03-22 3:32 [U-Boot] [PATCH] ARM: bcm2835: fix get_timer() to return mS Stephen Warren
@ 2013-03-28 9:00 ` Albert ARIBAUD
2013-03-28 15:10 ` Stephen Warren
0 siblings, 1 reply; 3+ messages in thread
From: Albert ARIBAUD @ 2013-03-28 9:00 UTC (permalink / raw)
To: u-boot
Hi Stephen,
On Thu, 21 Mar 2013 21:32:30 -0600, Stephen Warren
<swarren@wwwdotorg.org> wrote:
> Apparently, CONFIG_SYS_HZ must be 1000. Change this, and fix the timer
> driver to conform to this.
>
> Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
> ---
> arch/arm/cpu/arm1176/bcm2835/timer.c | 13 +++++++++----
> include/configs/rpi_b.h | 2 +-
> 2 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm/cpu/arm1176/bcm2835/timer.c b/arch/arm/cpu/arm1176/bcm2835/timer.c
> index d232d7e..f550020 100644
> --- a/arch/arm/cpu/arm1176/bcm2835/timer.c
> +++ b/arch/arm/cpu/arm1176/bcm2835/timer.c
> @@ -23,12 +23,17 @@ int timer_init(void)
> return 0;
> }
>
> -ulong get_timer(ulong base)
> +ulong get_timer_us(void)
> {
> struct bcm2835_timer_regs *regs =
> (struct bcm2835_timer_regs *)BCM2835_TIMER_PHYSADDR;
>
> - return readl(®s->clo) - base;
> + return readl(®s->clo);
> +}
> +
> +ulong get_timer(ulong base)
> +{
> + return (get_timer_us() / 1000) - base;
> }
>
> unsigned long long get_ticks(void)
> @@ -46,10 +51,10 @@ void __udelay(unsigned long usec)
> ulong endtime;
> signed long diff;
>
> - endtime = get_timer(0) + usec;
> + endtime = get_timer_us() + usec;
>
> do {
> - ulong now = get_timer(0);
> + ulong now = get_timer_us();
> diff = endtime - now;
> } while (diff >= 0);
> }
> diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h
> index 3d55d36..c18b35b 100644
> --- a/include/configs/rpi_b.h
> +++ b/include/configs/rpi_b.h
> @@ -31,7 +31,7 @@
> #define CONFIG_MACH_TYPE MACH_TYPE_BCM2708
>
> /* Timer */
> -#define CONFIG_SYS_HZ 1000000
> +#define CONFIG_SYS_HZ 1000
>
> /* Memory layout */
> #define CONFIG_NR_DRAM_BANKS 1
Is this a fix to some known issue or bug?
Amicalement,
--
Albert.
^ permalink raw reply [flat|nested] 3+ messages in thread* [U-Boot] [PATCH] ARM: bcm2835: fix get_timer() to return mS
2013-03-28 9:00 ` Albert ARIBAUD
@ 2013-03-28 15:10 ` Stephen Warren
0 siblings, 0 replies; 3+ messages in thread
From: Stephen Warren @ 2013-03-28 15:10 UTC (permalink / raw)
To: u-boot
On 03/28/2013 03:00 AM, Albert ARIBAUD wrote:
> Hi Stephen,
>
> On Thu, 21 Mar 2013 21:32:30 -0600, Stephen Warren
> <swarren@wwwdotorg.org> wrote:
>
>> Apparently, CONFIG_SYS_HZ must be 1000. Change this, and fix the timer
>> driver to conform to this.
>
> Is this a fix to some known issue or bug?
Yes. The bootdelay timeout implementation was recently(?) changed and
the new code doesn't use CONFIG_SYS_HZ at all, but rather assumes that
it's 1000. Since rpi_b's SYS_HZ was 1000000, the bootdelay runs by far
too fast. This fixes that.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-28 15:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-22 3:32 [U-Boot] [PATCH] ARM: bcm2835: fix get_timer() to return mS Stephen Warren
2013-03-28 9:00 ` Albert ARIBAUD
2013-03-28 15:10 ` Stephen Warren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox