From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] IXP425: Fixing timer code Part 1/1
Date: Sun, 4 Jan 2009 08:40:04 +0100 [thread overview]
Message-ID: <20090104074004.GD6960@game.jcrosoft.org> (raw)
In-Reply-To: <gim47r$3uf$1@ger.gmane.org>
On 20:08 Sun 21 Dec , Stefan Althoefer wrote:
> This fixes bugs in non-interupt timer code for IXP425
>
> Fixed udelay() implementation to be more accurate.
> The timing error of udelay() was caused by
> too much looping overhead. The actual timing routine
> was called repeatedly for each microsecond. When
> bigger slices are used, it becomes more accurate.
> CONFIG_SYS_TIMER_CLK_FREQ can be set by config file
> if clock speed differs from IXP425 default (66,666MHz).
>
> Fixed get_timer() to return correct time in units
> of CONFIG_SYS_HZ. The code now works for times
> in execess of 64 seconds (the timer overflow
> limit), assumed get_timer() is called with a period
> < 64 seconds.
>
> do_sleep() now works correctly.
>
some general comments
please check the coding style
and please use the readx/writex accessors
> Signed-off-by: Stefan Althoefer <stefan.althoefer@web.de>
> ---
> cpu/ixp/timer.c | 64 ++++++++++++++++++++++++++++++++++++++++++-------------
> 1 files changed, 49 insertions(+), 15 deletions(-)
>
> diff --git a/cpu/ixp/timer.c b/cpu/ixp/timer.c
> index 09d8ad5..d30adbc 100644
> --- a/cpu/ixp/timer.c
> +++ b/cpu/ixp/timer.c
> @@ -33,18 +33,28 @@
> #include <asm/arch/ixp425.h>
>
> #ifndef CONFIG_USE_IRQ
> +
> +#ifndef CONFIG_SYS_TIMER_CLK_FREQ
> +#define CONFIG_SYS_TIMER_CLK_FREQ 66666666
> +#endif
> +
> ulong get_timer (ulong base)
> {
> - return get_timer_masked () - base;
> + return get_timer_masked () - base;
> }
>
> -void ixp425_udelay(unsigned long usec)
> +/* udelay uses timer 1 */
> +
> +void ixp425_udelay (unsigned long usec)
> {
> /*
> * This function has a max usec, but since it is called from udelay
> * we should not have to worry... be happy
> */
> - unsigned long usecs = CONFIG_SYS_HZ/1000000L & ~IXP425_OST_RELOAD_MASK;
> + unsigned long usecs = CONFIG_SYS_TIMER_CLK_FREQ/1000000L
please add a space before and after '/'
> + & ~IXP425_OST_RELOAD_MASK;
> +
> + usecs *= usec;
>
> *IXP425_OSST = IXP425_OSST_TIMER_1_PEND;
> usecs |= IXP425_OST_ONE_SHOT | IXP425_OST_ENABLE;
> @@ -54,30 +64,54 @@ void ixp425_udelay(unsigned long usec)
>
> void udelay (unsigned long usec)
> {
> - while (usec--) ixp425_udelay(1);
> + /* ipx425_udelay has big overhead, so call it in bigger slices */
> + while (usec>1000) {
please add a space before and after '>'
> + ixp425_udelay (1000);
> + usec -= 1000;
> + }
> + /* and now the rest */
> + ixp425_udelay (usec);
> }
>
Best Regards,
J.
prev parent reply other threads:[~2009-01-04 7:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-04 21:10 [U-Boot] [PATCH] IXP425: Fixing timer code Part 1/1 Stefan Althoefer
2008-12-15 23:26 ` Wolfgang Denk
2008-12-16 21:50 ` Stefan Althoefer
2008-12-21 19:08 ` Stefan Althoefer
2009-01-04 7:40 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090104074004.GD6960@game.jcrosoft.org \
--to=plagnioj@jcrosoft.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox