From: Tom <Tom.Rix@windriver.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/8] nomadik_mtu: support configurable clock rates
Date: Sun, 28 Mar 2010 12:36:58 -0500 [thread overview]
Message-ID: <4BAF93BA.2060609@windriver.com> (raw)
In-Reply-To: <1268888890-32301-1-git-send-email-rabin.vincent@stericsson.com>
Rabin Vincent wrote:
> Change the Nomadik MTU driver to get the clock rate and prescaler from
> the config file. Also remove the hardcoded divisors and do the
> calculations based on the configured rate.
>
> Acked-by: Alessandro Rubini <rubini@unipv.it>
> Acked-by: Michael Brandt <michael.brandt@stericsson.com>
> Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
> ---
> drivers/misc/nomadik_mtu.c | 22 +++++++++++++---------
> include/configs/nhk8815.h | 3 +++
> 2 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/misc/nomadik_mtu.c b/drivers/misc/nomadik_mtu.c
> index b9c0fb1..4ec75ad 100644
> --- a/drivers/misc/nomadik_mtu.c
> +++ b/drivers/misc/nomadik_mtu.c
> @@ -22,25 +22,29 @@
>
> #include <common.h>
> #include <asm/io.h>
> +#include <div64.h>
> #include <nomadik_mtu.h>
>
> -/*
> - * The timer is a decrementer, we'll left it free running at 2.4MHz.
> - * We have 2.4 ticks per microsecond and an overflow in almost 30min
> - */
> -#define TIMER_CLOCK (24 * 100 * 1000)
> -#define COUNT_TO_USEC(x) ((x) * 5 / 12) /* overflows at 6min */
> -#define USEC_TO_COUNT(x) ((x) * 12 / 5) /* overflows at 6min */
> +#define TIMER_CLOCK CONFIG_NOMADIK_MTU_CLOCK
> #define TICKS_PER_HZ (TIMER_CLOCK / CONFIG_SYS_HZ)
> #define TICKS_TO_HZ(x) ((x) / TICKS_PER_HZ)
TICKS_TO_HZ is only used once.
This macro should be expanded in get_timer() and removed
TICKS_PER_HZ is only used in TICKS_PER_HZ, it should be expanded and removed
TIMER_CLOCK is a remapping of CONFIG_NOMADIK_MTU_CLOCK.
CONFIG_NOMADIK_MTU_CLOCK should just be used
>
> /* macro to read the decrementing 32 bit timer as an increasing count */
> #define READ_TIMER() (0 - readl(CONFIG_SYS_TIMERBASE + MTU_VAL(0)))
>
> +static unsigned long usec_to_count(unsigned long long usec)
> +{
> + unsigned long long count = usec * TIMER_CLOCK;
> +
> + do_div(count, 1000000);
> +
> + return count;
> +}
> +
> /* Configure a free-running, auto-wrap counter with no prescaler */
> int timer_init(void)
> {
> - writel(MTU_CRn_ENA | MTU_CRn_PRESCALE_1 | MTU_CRn_32BITS,
> + writel(MTU_CRn_ENA | CONFIG_NOMADIK_MTU_PRESCALE | MTU_CRn_32BITS,
> CONFIG_SYS_TIMERBASE + MTU_CR(0));
> reset_timer();
> return 0;
> @@ -73,7 +77,7 @@ void __udelay(unsigned long usec)
> ulong ini, end;
>
> ini = READ_TIMER();
> - end = ini + USEC_TO_COUNT(usec);
> + end = ini + usec_to_count(usec);
> while ((signed)(end - READ_TIMER()) > 0)
> ;
> }
> diff --git a/include/configs/nhk8815.h b/include/configs/nhk8815.h
> index 8ba1e5e..d52f50c 100644
> --- a/include/configs/nhk8815.h
> +++ b/include/configs/nhk8815.h
> @@ -98,6 +98,9 @@
> #define CONFIG_SYS_HZ 1000 /* Mandatory... */
> #define CONFIG_SYS_TIMERBASE 0x101E2000
> #define CONFIG_NOMADIK_MTU
> +/* We have 2.4 ticks per microsecond and an overflow in almost 30min */
> +#define CONFIG_NOMADIK_MTU_CLOCK (24 * 100 * 1000)
> +#define CONFIG_NOMADIK_MTU_PRESCALE MTU_CRn_PRESCALE_1
>
> /* GPIO */
> #define CONFIG_NOMADIK_GPIO
Tom
next prev parent reply other threads:[~2010-03-28 17:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-18 4:20 [U-Boot] [PATCH 0/8] ST-Ericsson Ux500 support Rabin Vincent
2010-03-18 4:20 ` [U-Boot] [PATCH 1/8] Nomadik: move timer code to drivers/misc Rabin Vincent
2010-03-28 17:30 ` Tom
2010-04-06 11:16 ` Rabin VINCENT
2010-04-06 11:30 ` Alessandro Rubini
2010-03-18 4:28 ` [U-Boot] [PATCH 2/8] Nomadik: move gpio driver to drivers/gpio Rabin Vincent
2010-03-28 17:32 ` Tom
2010-04-06 11:25 ` Rabin VINCENT
2010-03-18 5:02 ` [U-Boot] [PATCH 3/8] nomadik_gpio: get base address from platform code Rabin Vincent
2010-03-28 17:35 ` Tom
2010-03-18 5:08 ` [U-Boot] [PATCH 4/8] nomadik_mtu: support configurable clock rates Rabin Vincent
2010-03-28 17:36 ` Tom [this message]
2010-03-18 5:10 ` [U-Boot] [PATCH 5/8] ARM Cortex A8: ifdef code calling lowlevel init Rabin Vincent
2010-03-28 17:38 ` Tom
2010-03-18 5:10 ` [U-Boot] [PATCH 6/8] ux500: add SoC-specific code Rabin Vincent
2010-03-28 17:42 ` Tom
2010-04-07 6:15 ` Rabin VINCENT
2010-03-18 5:10 ` [U-Boot] [PATCH 7/8] pl01x: add support for Ux500 variant of pl011 Rabin Vincent
2010-03-28 17:45 ` Tom
2010-03-18 5:33 ` [U-Boot] [PATCH 8/8] mop500: add board-specific files Rabin Vincent
2010-03-28 17:49 ` Tom
2010-04-08 13:41 ` Rabin VINCENT
2010-04-09 22:28 ` Wolfgang Denk
2010-04-17 21:46 ` Tom Rix
2010-03-21 19:42 ` [U-Boot] [PATCH 0/8] ST-Ericsson Ux500 support Wolfgang Denk
2010-03-28 17:27 ` Tom
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=4BAF93BA.2060609@windriver.com \
--to=tom.rix@windriver.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.