From: Marek Vasut <marek.vasut@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/9] openrisc: Add library functions
Date: Tue, 22 Nov 2011 05:48:53 +0100 [thread overview]
Message-ID: <201111220548.53786.marek.vasut@gmail.com> (raw)
In-Reply-To: <20111122041913.GB7158@chokladfabriken.org>
> On Mon, Nov 21, 2011 at 11:52:59PM +0100, Marek Vasut wrote:
> > > create mode 100644 arch/openrisc/lib/timer.c
> >
> > Timer support isn't a library function but a CPU function, so move it to
> > 3/9.
>
> I never quite worked out where the timer functions belongs,
> some have them in interupts.c and some in their own file.
> Some have them cpu/ and some in lib/
>
> > > + asm("l.nop 0x1"); /* Kill any simulation */
> >
> > Simulation? Oh, it's an FPGA based CPU or what?
>
> Well, yes, FPGAs are probably the most common case, but also ASIC
> implementations exists.
> The extra argument to the nop instruction is ignored by hardware,
> but have special meanings when ran in simulation.
Hmm ... I'm not quite sure this is right.
>
> > > +int timer_init(void)
> > > +{
> > > + /* Install timer exception handler */
> > > + exception_install_handler(EXC_TIMER, timer_isr);
> > > +
> > > + /* Set up the timer for the first expiration. */
> > > + timestamp = 0;
> > > +
> > > + mtspr(SPR_TTMR, SPR_TTMR_IE | SPR_TTMR_RT |
> > > + (TIMER_COUNTER_CYCLES & SPR_TTMR_TP));
> > > +
> > > + /* Enable tick timer exception in supervisor register */
> > > + mtspr(SPR_SR, mfspr(SPR_SR) | SPR_SR_TEE);
> > > +
> > > + return 0;
> > > +}
> > > +
> > > +void reset_timer(void)
> > > +{
> > > + timestamp = 0;
> > > +
> > > + mtspr(SPR_TTMR, SPR_TTMR_IE | SPR_TTMR_RT |
> > > + (TIMER_COUNTER_CYCLES & SPR_TTMR_TP));
> > > +}
> > > +
> > > +/*
> > > + * The timer value in ms is calculated by taking the
> > > + * value accumulated by full timer revolutions plus the value
> > > + * accumulated in this period
> > > + */
> > > +ulong get_timer(ulong base)
> > > +{
> > > + return timestamp + mfspr(SPR_TTCR)/TIMER_CYCLES_MS - base;
> > > +}
> > > +
> > > +void set_timer(ulong t)
> > > +{
> > > + reset_timer();
> > > + timestamp = t;
> > > +}
> > > +
> > > +void __udelay(ulong usec)
> > > +{
> > > + ulong elapsed = 0;
> > > + ulong tick;
> > > + ulong last_tick;
> > > +
> > > + last_tick = mfspr(SPR_TTCR);
> > > + while ((elapsed / TIMER_CYCLES_US) < usec) {
> > > + tick = mfspr(SPR_TTCR);
> > > + if (tick >= last_tick)
> > > + elapsed += (tick - last_tick);
> > > + else
> > > + elapsed += TIMER_COUNTER_CYCLES - (last_tick - tick);
> > > + last_tick = tick;
> > > + }
> > > +}
> >
> > I'm not sure if this conforms with current timer api, can you cross-check
> > with arch/arm/arm926ejs/mx28/timer.c ? That's the latest addition and
> > should conform.
>
> In my opinion it seems to do the same thing as that, what exactly did you
> find non-conforming?
I was just curious if it's ok. If it is, so be it.
>
> Stefan
next prev parent reply other threads:[~2011-11-22 4:48 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-19 5:21 [U-Boot] [PATCH 0/9] Add support for the OpenRISC architecture Stefan Kristiansson
2011-11-19 5:21 ` [U-Boot] [PATCH 1/9] openrisc: Add architecture header files Stefan Kristiansson
2011-11-19 6:06 ` Mike Frysinger
2011-11-19 5:21 ` [U-Boot] [PATCH 2/9] openrisc: Add architecture image support Stefan Kristiansson
2011-11-21 22:45 ` Marek Vasut
2011-11-22 9:43 ` [U-Boot] [PATCH] Fix clash between IH_ARCH_NDS32 and IH_ARCH_SANDBOX Stefan Kristiansson
2011-11-22 11:03 ` [U-Boot] 回覆: " macpaul at andestech.com
2011-11-22 14:15 ` Marek Vasut
2011-11-23 6:10 ` Macpaul Lin
2011-11-19 5:21 ` [U-Boot] [PATCH 3/9] openrisc: Add cpu files Stefan Kristiansson
2011-11-19 5:59 ` Mike Frysinger
2011-11-20 4:27 ` Stefan Kristiansson
2011-11-20 5:27 ` Mike Frysinger
2011-11-21 22:50 ` Marek Vasut
2011-11-22 3:51 ` Stefan Kristiansson
2011-11-22 4:46 ` Marek Vasut
2011-11-22 7:17 ` Stefan Kristiansson
2011-11-22 14:07 ` Marek Vasut
2011-11-22 20:29 ` Scott Wood
2011-11-22 20:54 ` Mike Frysinger
2011-11-19 5:21 ` [U-Boot] [PATCH 4/9] openrisc: Add library functions Stefan Kristiansson
2011-11-19 6:04 ` Mike Frysinger
2011-11-21 22:52 ` Marek Vasut
2011-11-22 4:19 ` Stefan Kristiansson
2011-11-22 4:48 ` Marek Vasut [this message]
2011-11-22 6:00 ` Stefan Kristiansson
2011-11-22 14:10 ` Marek Vasut
2011-11-19 5:21 ` [U-Boot] [PATCH 5/9] openrisc: Add board info printout to cmd_bdinfo Stefan Kristiansson
2011-11-21 22:53 ` Marek Vasut
2011-11-22 4:30 ` Stefan Kristiansson
2011-11-22 4:49 ` Marek Vasut
2011-11-19 5:21 ` [U-Boot] [PATCH 6/9] openrisc: Add support for standalone programs Stefan Kristiansson
2011-11-19 5:21 ` [U-Boot] [PATCH 7/9] openrisc: Add openrisc-generic example board Stefan Kristiansson
2011-11-19 5:21 ` [U-Boot] [PATCH 8/9] openrisc: Add architecture to MAKEALL Stefan Kristiansson
2011-11-19 5:21 ` [U-Boot] [PATCH 9/9] openrisc: Add MAINTAINERS entry Stefan Kristiansson
2011-11-21 22:54 ` Marek Vasut
2011-11-22 4:32 ` Stefan Kristiansson
2011-11-19 6:07 ` [U-Boot] [PATCH 0/9] Add support for the OpenRISC architecture Mike Frysinger
2011-11-19 7:23 ` Stefan Kristiansson
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=201111220548.53786.marek.vasut@gmail.com \
--to=marek.vasut@gmail.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.