
On Fri, 11 Jan 2008, TsiChung Liew wrote:
diff --git a/cpu/mcf547x_8x/slicetimer.c b/cpu/mcf547x_8x/slicetimer.c new file mode 100644 index 0000000..10418fa --- /dev/null +++ b/cpu/mcf547x_8x/slicetimer.c @@ -0,0 +1,132 @@ +/*
- (C) Copyright 2007 Freescale Semiconductor, Inc.
- TsiChung Liew (Tsi-Chung.Liew@freescale.com)
- See file CREDITS for list of people who contributed to this
- project.
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
- */
+#include <common.h>
+#include <asm/timer.h> +#include <asm/immap.h>
+DECLARE_GLOBAL_DATA_PTR;
+static ulong timestamp;
+#if defined(CONFIG_SLTTMR) +#ifndef CFG_UDELAY_BASE +# error "uDelay base not defined!" +#endif
+#if !defined(CFG_TMR_BASE) || !defined(CFG_INTR_BASE) || !defined (CFG_TMRINTR_NO) || !defined(CFG_TMRINTR_MASK)
At least this patch seems line-wrapped to me. Above is just one example.
+# error "TMR_BASE, INTR_BASE, TMRINTR_NO or TMRINTR_MASk not defined!" +#endif +extern void dtimer_intr_setup(void);
+void udelay(unsigned long usec) +{
- volatile slt_t *timerp = (slt_t *) (CFG_UDELAY_BASE);
- u32 now, freq;
- /* 1 us period */
- freq = CFG_TIMER_PRESCALER;
- timerp->cr = 0; /* Disable */
- timerp->tcnt = usec * freq;
- timerp->cr = SLT_CR_TEN;
- now = timerp->cnt;
- while (now != 0)
now = timerp->cnt;
- timerp->sr |= SLT_SR_ST;
- timerp->cr = 0;
+}
+void dtimer_interrupt(void *not_used) +{
- volatile slt_t *timerp = (slt_t *) (CFG_TMR_BASE);
- /* check for timer interrupt asserted */
- if ((CFG_TMRPND_REG & CFG_TMRINTR_MASK) == CFG_TMRINTR_PEND) {
timerp->sr |= SLT_SR_ST;
timestamp++;
return;
- }
+}
+void timer_init(void) +{
- volatile slt_t *timerp = (slt_t *) (CFG_TMR_BASE);
- timestamp = 0;
- timerp->cr = 0; /* disable timer */
- timerp->tcnt = 0;
- timerp->sr = SLT_SR_BE | SLT_SR_ST; /* clear status */
- /* initialize and enable timer interrupt */
- irq_install_handler(CFG_TMRINTR_NO, dtimer_interrupt, 0);
- /* Interrupt every ms */
- timerp->tcnt = 1000 * CFG_TIMER_PRESCALER;
- dtimer_intr_setup();
- /* set a period of 1us, set timer mode to restart and
enable timer and interrupt */
- timerp->cr = SLT_CR_RUN | SLT_CR_IEN | SLT_CR_TEN;
+}
+void reset_timer(void) +{
- timestamp = 0;
+}
+ulong get_timer(ulong base) +{
- return (timestamp - base);
+}
+void set_timer(ulong t) +{
- timestamp = t;
+} +#endif /* CONFIG_SLTTMR */
+/*
- This function is derived from PowerPC code (read timebase as long
long).
And here's another one
- On M68K it just returns the timer value.
- */
Is this really the correct comment here? I see the code is copied from lib_m68k/time.c. Isn't lib_m68k going to be linked with this board? Won't symbols conflict then? Obviously they don't, as you are running this code, just I don't see immediately how this works. And if CONFIG_SLTTMR is not defined, looks like get_timer will be undefined, right? Is this the intended behaviour?
+unsigned long long get_ticks(void) +{
- return get_timer(0);
+}
+/*
- This function is derived from PowerPC code (timebase clock
frequency).
and another one
- On M68K it returns the number of timer ticks per second.
- */
and the comment is from lib_m68k/time.c again.
+ulong get_tbclk(void) +{
- ulong tbclk;
- tbclk = CFG_HZ;
- return tbclk;
+}
- movec %d0, %ACR2
- movec %d0, %ACR3
- /* initialize general use internal ram */
- move.l #0, %d0
- move.l #(ICACHE_STATUS), %a1 /* icache */
- move.l #(DCACHE_STATUS), %a2 /* icache */
- move.l #(CACR_STATUS), %a3 /* CACR */
- move.l %d0, (%a1)
- move.l %d0, (%a2)
- move.l %d0, (%a3)
- /* set stackpointer to end of internal ram to get some stackspace for
the
Strange, this line is wrapped
first c-code */
- move.l #(CFG_INIT_RAM_ADDR + CFG_INIT_SP_OFFSET), %sp
- clr.l %sp@-
- move.l #__got_start, %a5 /* put relocation table address to a5 */
- bsr cpu_init_f /* run low-level CPU init code (from flash) */
- bsr board_init_f /* run low-level board init code (from flash) */
but these longer ones are not.
Thanks Guennadi --- Guennadi Liakhovetski, Ph.D.
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office@denx.de