public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Vlad Zakharov <Vladislav.Zakharov@synopsys.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/3] drivers: timer: Introduce ARC timer driver
Date: Tue, 31 Jan 2017 14:44:39 +0000	[thread overview]
Message-ID: <1485873879.11876.38.camel@synopsys.com> (raw)
In-Reply-To: <CAPnjgZ1eZ21ZFdG5y9asf6tzWdbWvBZDHhrt7DWgzLNHB_00qQ@mail.gmail.com>

Hi Simon,

On Fri, 2017-01-20 at 20:51 -0700, Simon Glass wrote:
> > +?????? switch (priv->timer_id) {
> > +?????? case 0:
> > +?????????????? /* Disable timer if CPU is halted */
> > +?????????????? write_aux_reg(ARC_AUX_TIMER0_CTRL, NH_MODE);
> > +?????????????? /* Set max value for counter/timer */
> > +?????????????? write_aux_reg(ARC_AUX_TIMER0_LIMIT, 0xffffffff);
> > +?????????????? /* Set initial count value and restart counter/timer */
> > +?????????????? write_aux_reg(ARC_AUX_TIMER0_CNT, 0);
> > +?????????????? break;
> > +?????? case 1:
> > +?????????????? /* Disable timer if CPU is halted */
> > +?????????????? write_aux_reg(ARC_AUX_TIMER1_CTRL, NH_MODE);
> > +?????????????? /* Set max value for counter/timer */
> > +?????????????? write_aux_reg(ARC_AUX_TIMER1_LIMIT, 0xffffffff);
> > +?????????????? /* Set initial count value and restart counter/timer */
> > +?????????????? write_aux_reg(ARC_AUX_TIMER1_CNT, 0);
> 
> You are writing the same values in each case. Can you set a value to
> either ARC_AUX_TIMER0 or ARC_AUX_TIMER1? and then just have the code
> once?

Yes, here we have some code duplication. But in fact we have a reason for this. ARC timers are controlled by auxiliary
registers that are not mapped anywhere. They have their fixed numbers and are being accessed using special ARC asm
commands. Of course I can write something like this:
---------------------------------->8------------------------------------
timer_base = priv->timer_id ? ARC_AUX_TIMER1_BASE : ARC_AUX_TIMER0_BASE;

write_aux_reg(timer_base + ARC_TIMER_CTRL, NH_MODE);
write_aux_reg(timer_base + ARC_TIMER_LIMIT, 0xffffffff);
write_aux_reg(timer_base + ARC_TIMER_CNT, 0);
---------------------------------->8------------------------------------
But unfortunately it will not reflect the real life. We don't have any ARC timer base addresses, only fixed register
numbers.

If you insist I will use the latter code snippet. But from our point of view the code is being duplicated in this patch
is very small but helps to understand what is really happening with ARC timers much better.

Thanks.

-- 
Best regards,
Vlad Zakharov <vzakhar@synopsys.com>

  reply	other threads:[~2017-01-31 14:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-16 13:49 [U-Boot] [PATCH 0/3] arc: introduce timer driver and update device tree Vlad Zakharov
2017-01-16 13:49 ` [U-Boot] [PATCH 1/3] drivers: timer: Introduce ARC timer driver Vlad Zakharov
2017-01-21  3:51   ` Simon Glass
2017-01-31 14:44     ` Vlad Zakharov [this message]
2017-01-31 15:35       ` Alexey Brodkin
2017-02-06 15:33         ` Simon Glass
2017-02-06 16:46           ` Alexey Brodkin
2017-01-16 13:49 ` [U-Boot] [PATCH 2/3] arc: dts: separate single axs10x.dts file Vlad Zakharov
2017-01-21  3:51   ` Simon Glass
2017-01-16 13:49 ` [U-Boot] [PATCH 3/3] arc: use timer driver for ARC boards Vlad Zakharov
2017-01-21  3:51   ` Simon Glass

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=1485873879.11876.38.camel@synopsys.com \
    --to=vladislav.zakharov@synopsys.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