From: Wang Dongsheng-B40534 <B40534@freescale.com>
To: Wood Scott-B07421 <B07421@freescale.com>
Cc: Gala Kumar-B11780 <B11780@freescale.com>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
Li Yang-R58472 <r58472@freescale.com>
Subject: RE: [PATCH 2/3] powerpc/mpic: add global timer support
Date: Tue, 19 Mar 2013 07:55:58 +0000 [thread overview]
Message-ID: <ABB05CD9C9F68C46A5CEDC7F15439259EB717E@039-SN2MPN1-022.039d.mgd.msft.net> (raw)
In-Reply-To: <1363650392.27435.22@snotra>
> > +static void convert_ticks_to_time(struct timer_group_priv *priv,
> > + const u64 ticks, struct timeval *time) {
> > + u64 tmp_sec;
> > + u32 rem_us;
> > + u32 div;
> > +
> > + if (!(priv->flags & FSL_GLOBAL_TIMER)) {
> > + time->tv_sec =3D (__kernel_time_t)
> > + div_u64_rem(ticks, priv->timerfreq, &rem_us);
> > + tmp_sec =3D (u64)time->tv_sec * (u64)priv->timerfreq;
> > + time->tv_usec =3D (__kernel_suseconds_t)
> > + div_u64((ticks - tmp_sec) * 1000000,
> > priv->timerfreq);
> > +
> > + return;
> > + }
> > +
> > + div =3D (1 << (MPIC_TIMER_TCR_CLKDIV_64 >> 8)) * 8;
> > +
> > + time->tv_sec =3D (__kernel_time_t)div_u64(ticks, priv->timerfreq
> > / div);
> > + tmp_sec =3D div_u64((u64)time->tv_sec * (u64)priv->timerfreq,
> > div);
> > +
> > + time->tv_usec =3D (__kernel_suseconds_t)
> > + div_u64((ticks - tmp_sec) * 1000000, priv->timerfreq /
> > div);
> > +
> > + return;
>=20
> Why don't you just adjust the clock frequency up front for CLKDIV_64,
> rather than introduce alternate (and untested!) code paths throughout the
> driver?
>=20
No, It cannot be integrated. The div cannot be removed.
Because if do priv->timerfreq /=3D div, that will affect the accuracy.
Like:
3 * 5 / 2 =3D 7;
3 / 2 * 5 =3D 5;
BTW
if (!(priv->flags & FSL_GLOBAL_TIMER)) {
time->tv_sec =3D (__kernel_time_t)
div_u64_rem(ticks, priv->timerfreq, &rem_us);
tmp_sec =3D (u64)time->tv_sec * (u64)priv->timerfreq;
time->tv_usec =3D (__kernel_suseconds_t)
div_u64((ticks - tmp_sec) * 1000000, priv->timerfreq);
return;
}
This branch I has been tested.
Test methods:
1. Get timerfreq and set timerfreq.
timerfreq /=3D 64;(Clock ratio is divide by 64)
2. Clear FSL_GLOBAL_TIMER flag.
Test Log:
[root@p5020 root]# echo 20 > /sys/devices/system/mpic/timer_wakeup
[root@p5020 root]# cat /sys/devices/system/mpic/timer_wakeup
sec =3D 18, ticks =3D 118295518.., timerfreq =3D 6249999..
19
[root@p5020 root]# cat /sys/devices/system/mpic/timer_wakeup
sec =3D 17, ticks =3D 110095766.., timerfreq =3D 6249999..
18
[root@p5020 root]# cat /sys/devices/system/mpic/timer_wakeup
sec =3D 16, ticks =3D 105095737.., timerfreq =3D 6249999..
17
[root@p5020 root]# cat /sys/devices/system/mpic/timer_wakeup
sec =3D 15, ticks =3D 99495711.., timerfreq =3D 6249999..
16
next prev parent reply other threads:[~2013-03-19 7:56 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-08 7:38 [PATCH 1/3] powerpc/mpic: add irq_set_wake support Wang Dongsheng
2013-03-08 7:38 ` [PATCH 2/3] powerpc/mpic: add global timer support Wang Dongsheng
2013-03-18 23:46 ` Scott Wood
2013-03-19 7:55 ` Wang Dongsheng-B40534 [this message]
2013-03-19 22:59 ` Scott Wood
2013-03-20 6:45 ` Wang Dongsheng-B40534
2013-03-20 22:59 ` Scott Wood
2013-03-22 6:14 ` Wang Dongsheng-B40534
2013-03-22 22:29 ` Scott Wood
2013-03-26 3:29 ` Wang Dongsheng-B40534
2013-03-26 17:31 ` Scott Wood
2013-03-27 3:23 ` Wang Dongsheng-B40534
2013-03-27 17:11 ` Scott Wood
2013-03-28 2:29 ` Wang Dongsheng-B40534
2013-03-28 19:47 ` Scott Wood
2013-03-29 1:58 ` Wang Dongsheng-B40534
2013-03-08 7:38 ` [PATCH 3/3] powerpc/fsl: add MPIC timer wakeup support Wang Dongsheng
2013-03-19 0:30 ` Scott Wood
2013-03-19 6:25 ` Wang Dongsheng-B40534
2013-03-19 22:54 ` Scott Wood
2013-03-20 3:48 ` Wang Dongsheng-B40534
2013-03-20 21:48 ` Scott Wood
2013-03-22 5:46 ` Wang Dongsheng-B40534
2013-03-22 22:11 ` Scott Wood
2013-03-26 3:27 ` Wang Dongsheng-B40534
2013-03-26 17:35 ` Scott Wood
2013-03-27 3:21 ` Wang Dongsheng-B40534
2013-03-27 20:25 ` Scott Wood
2013-03-28 3:09 ` Wang Dongsheng-B40534
2013-03-18 9:28 ` [PATCH 1/3] powerpc/mpic: add irq_set_wake support Wang Dongsheng-B40534
2013-03-18 14:41 ` Benjamin Herrenschmidt
2013-03-18 14:44 ` Gala Kumar-B11780
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=ABB05CD9C9F68C46A5CEDC7F15439259EB717E@039-SN2MPN1-022.039d.mgd.msft.net \
--to=b40534@freescale.com \
--cc=B07421@freescale.com \
--cc=B11780@freescale.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=r58472@freescale.com \
/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;
as well as URLs for NNTP newsgroup(s).