summaryrefslogtreecommitdiff
path: root/cleopatre/u-boot-1.1.6/cpu
diff options
context:
space:
mode:
authorsave2009-09-01 21:40:35 +0000
committersave2009-09-01 21:40:35 +0000
commit694296acf6e0568c93fb6fa94f65c97dc6250608 (patch)
treec0780112fe8de70a847b739207dfc0019805524d /cleopatre/u-boot-1.1.6/cpu
parent840dc2f4ebdc956a0fb67cb558d3237e1fdb86b6 (diff)
[CLEO][U-BOOT] Changed Timer prescaler for spk300g
Timer depends on xclk but have a programmable prescaler U-boot manage prescaler to always have a timer clock eqaul to 3.125MHz git-svn-id: svn+ssh://pessac/svn/cesar/trunk@5387 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cleopatre/u-boot-1.1.6/cpu')
-rw-r--r--cleopatre/u-boot-1.1.6/cpu/spc300/start.S29
-rw-r--r--cleopatre/u-boot-1.1.6/cpu/spc300/timer.c24
2 files changed, 30 insertions, 23 deletions
diff --git a/cleopatre/u-boot-1.1.6/cpu/spc300/start.S b/cleopatre/u-boot-1.1.6/cpu/spc300/start.S
index cbbbfb5afa..eb0901fb44 100644
--- a/cleopatre/u-boot-1.1.6/cpu/spc300/start.S
+++ b/cleopatre/u-boot-1.1.6/cpu/spc300/start.S
@@ -262,6 +262,11 @@ in_sdram:
bne bl_no_nvram
/*
+ * Configure timer prescaler
+ */
+ bl timer_clock_config /* we pass NVRAM addr in r10; do not corrupt r10 in this function */
+
+ /*
* Configure GPIOs and PIO
* WARNING: NVRAM need to be found and put to r10
*/
@@ -458,6 +463,30 @@ gpio_pio_init:
/*
*************************************************************************
*
+ * TIMER PRESCALER Configuration
+ *
+ *************************************************************************
+ */
+timer_clock_config:
+ /* Find Xclk val from NVRAM (struct address is in r10) */
+ mov r2, #0 /* default timer_clk = xclk */
+ ldr r1, [r10, #8] /* load pkg_cfg */
+ and r1, r1, #0x03 /* r1 = xclk */
+ cmp r1, #0 /* xclk = 18,75MHz ? */
+ moveq r2, #2 /* yes: timer_clk = xclk/(2*(2+1)) = 3.125MHz */
+ cmp r1, #1 /* xclk = 25MHz ? */
+ moveq r2, #3 /* yes: timer_clk = xclk*(2*(3+1)) = 3.125MHz */
+ movne r2, #5 /* no: timer_clk = xclk*2*(5+1) = 3.125MHz */
+
+ /* store prescaler */
+ ldr r0, =REGBANK_BASE
+ str r2, [r0, #RB_CLK_DIV_T1]
+
+ mov pc, lr /* back to my caller */
+
+/*
+ *************************************************************************
+ *
* Interrupt handling
*
*************************************************************************
diff --git a/cleopatre/u-boot-1.1.6/cpu/spc300/timer.c b/cleopatre/u-boot-1.1.6/cpu/spc300/timer.c
index eafe939a74..a10229e454 100644
--- a/cleopatre/u-boot-1.1.6/cpu/spc300/timer.c
+++ b/cleopatre/u-boot-1.1.6/cpu/spc300/timer.c
@@ -29,36 +29,14 @@
/* macro to read the 32 bit timer */
#define READ_TIMER readl(TIMER1CURRENTVAL_1)
-#define TIME_HZ (timerclk/2) /* MARIA_TIMER_CLOCK/timer_prescaler == Xclk/timer_prescaler (timer_prescaler == 2) */
+#define TIME_HZ (3125000) /* xclk/timer_prescaler = 3.125MHz */
static ulong timestamp;
static ulong lastdec;
-static ulong timerclk;
-
-static void get_timer_clock(void)
-{
- DECLARE_GLOBAL_DATA_PTR;
- bd_t *bd = gd->bd;
- spc300_nvram_t *nvram = (spc300_nvram_t*)bd->bi_nvram_addr;
- switch(nvram->pkg_cfg & 0x03)
- {
- case 1:
- timerclk = 25000000;
- break;
- case 2:
- timerclk = 37500000;
- break;
- default:
- timerclk = 18750000;
- break;
- }
-}
/* nothing really to do with interrupts, just starts up a counter. */
int timer_init (void)
{
- get_timer_clock();
-
writel(0x00, TIMER1CONTROLREG_1); /* disable timer1 */
writel(TIMER_LOAD_VAL, TIMER1LOADCOUNT_1);
writel(TIMER_LOAD_VAL, TIMER1CURRENTVAL_1);