From: Tomasz Figa <tomasz.figa@gmail.com>
To: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: linux-samsung-soc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-pwm@vger.kernel.org,
"Kukjin Kim" <kgene.kim@samsung.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"Olof Johansson" <olof@lixom.net>,
"Sylwester Nawrocki" <sylvester.nawrocki@gmail.com>,
"Heiko Stübner" <heiko@sntech.de>,
"Mark Brown" <broonie@kernel.org>,
"Thierry Reding" <thierry.reding@gmail.com>
Subject: Re: [PATCH v4 02/20] clocksource: samsung_pwm_timer: Correct definition of AUTORELOAD bit
Date: Mon, 22 Jul 2013 23:11:30 +0200 [thread overview]
Message-ID: <1658534.7nG6RFjcTc@flatron> (raw)
In-Reply-To: <51ED9C8C.10803@linaro.org>
On Monday 22 of July 2013 22:56:44 Daniel Lezcano wrote:
> On 07/22/2013 09:43 AM, Tomasz Figa wrote:
> > On Monday 22 of July 2013 05:50:09 Daniel Lezcano wrote:
> >> On 07/20/2013 02:04 AM, Tomasz Figa wrote:
> >>> PWM channel 4 has its autoreload bit located at different position.
> >>> This patch fixes the driver to account for that.
> >>>
> >>> This fixes a problem with the clocksource hanging after it overflows
> >>> because it is not reloaded any more.
> >>>
> >>> Signed-off-by: Tomasz Figa <tomasz.figa@gmail.com>
> >>> ---
> >>>
> >>> drivers/clocksource/samsung_pwm_timer.c | 3 ++-
> >>> 1 file changed, 2 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/drivers/clocksource/samsung_pwm_timer.c
> >>> b/drivers/clocksource/samsung_pwm_timer.c index 3fa5b07..e238fb0
> >>> 100644
> >>> --- a/drivers/clocksource/samsung_pwm_timer.c
> >>> +++ b/drivers/clocksource/samsung_pwm_timer.c
> >>> @@ -47,7 +47,8 @@
> >>>
> >>> #define TCON_START(chan) (1 << (4 * (chan) + 0))
> >>> #define TCON_MANUALUPDATE(chan) (1 << (4 * (chan) + 1))
> >>> #define TCON_INVERT(chan) (1 << (4 * (chan) + 2))
> >>>
> >>> -#define TCON_AUTORELOAD(chan) (1 << (4 * (chan) + 3))
> >>> +#define TCON_AUTORELOAD(chan) (1 << (4 * (chan) \
> >>> + + (((chan) < 5) ? 3 : 2)))
> >>
> >> This macro is not readable. Please, fix it up with a comment please.
> >
> > /*
> >
> > * Channel 4 (logically 5 in TCON register) has different position
> > * of autoreload bit.
> > */
> >
> > #define _TCON_AUTORELOAD(chan) (1 << (4 * (chan)
+ 3))
> > #define _TCON_AUTORELOAD4(chan) (1 << (4 * (chan)
+ 2))
> > #define TCON_AUTORELOAD(chan) ((chan < 5) ?
> >
> > _TCON_AUTORELOAD(chan) : _TCON_AUTORELOAD4(chan))
> >
> > What do you think?
>
> I don't get the arithmetic here and the code is poor in comment. A nice
> comment would valuable here.
Each channel occupies 4 bits in TCON register, but there is a gap of 4
bits after channel 0. In addition for channel 4 the location of autoreload
bit in its set of bits is 2 as opposed to 3 for other channels. Here's the
layout of the register, for reference:
Timer 4 Auto Reload on/off [22]
Timer 4 Manual Update [21]
Timer 4 Start/Stop [20]
Timer 3 Auto Reload on/off [19]
Reserved [18]
Timer 3 Manual Update [17]
Timer 3 Start/Stop [16]
Timer 2 Auto Reload on/off [15]
Reserved [14]
Timer 2 Manual Update [13]
Timer 2 Start/Stop [12]
Timer 1 Auto Reload on/off [11]
Timer 1 Output Inverter on/off [10]
Timer 1 Manual Update [9]
Timer 1 Start/Stop [8]
Reserved [7:5]
Dead zone enable/disable [4]
Timer 0 Auto Reload on/off [3]
Timer 0 Output Inverter on/off [2]
Timer 0 Manual Update [1]
Timer 0 Start/Stop [0]
> May be you can replace 1 << bla by BIT(bla) ?
Yes, BIT() would be nice here, but IMHO this is material for separate
patch as all the macros in this driver already use 1 << bla.
Best regards,
Tomasz
next prev parent reply other threads:[~2013-07-22 21:11 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-20 0:04 [PATCH v4 00/20] Samsung PWM support cleanup Tomasz Figa
2013-07-20 0:04 ` [PATCH v4 01/20] clocksource: samsung_pwm_timer: Do not request PWM mem region Tomasz Figa
2013-07-20 0:04 ` [PATCH v4 02/20] clocksource: samsung_pwm_timer: Correct definition of AUTORELOAD bit Tomasz Figa
2013-07-20 0:04 ` Tomasz Figa
2013-07-22 3:50 ` Daniel Lezcano
2013-07-22 7:43 ` Tomasz Figa
2013-07-22 20:56 ` Daniel Lezcano
2013-07-22 21:11 ` Tomasz Figa [this message]
2013-07-22 21:28 ` Daniel Lezcano
2013-07-23 23:32 ` [PATCH v6 " Tomasz Figa
2013-07-29 13:08 ` Daniel Lezcano
2013-07-22 20:54 ` [PATCH v5 " Tomasz Figa
2013-07-20 0:04 ` [PATCH v4 03/20] clocksource: samsung_pwm_timer: Cache clocksource register address Tomasz Figa
2013-07-20 0:04 ` [PATCH v4 04/20] clocksource: samsung_pwm_timer: Do not use clocksource_mmio Tomasz Figa
2013-07-22 3:56 ` Daniel Lezcano
2013-07-22 7:47 ` Tomasz Figa
2013-07-22 20:13 ` Daniel Lezcano
2013-07-22 20:17 ` Tomasz Figa
2013-07-20 0:04 ` [PATCH v4 05/20] clocksource: samsung_pwm_timer: Handle suspend/resume correctly Tomasz Figa
2013-07-22 3:57 ` Daniel Lezcano
2013-07-20 0:04 ` [PATCH v4 06/20] ARM: SAMSUNG: Unify base address definitions of timer block Tomasz Figa
2013-07-20 0:04 ` [PATCH v4 07/20] ARM: SAMSUNG: Add new PWM platform device Tomasz Figa
2013-07-21 19:46 ` Sylwester Nawrocki
2013-07-21 21:51 ` Tomasz Figa
2013-07-21 22:24 ` Tomasz Figa
2013-07-22 20:52 ` [PATCH v5 " Tomasz Figa
2013-07-20 0:04 ` [PATCH v4 08/20] ARM: SAMSUNG: Set PWM platform data Tomasz Figa
2013-07-20 0:04 ` [PATCH v4 09/20] ARM: SAMSUNG: Move all platforms to new clocksource driver Tomasz Figa
2013-07-22 3:59 ` Daniel Lezcano
2013-07-20 0:04 ` [PATCH v4 10/20] ARM: SAMSUNG: Remove old samsung-time driver Tomasz Figa
2013-07-20 0:04 ` [PATCH v4 11/20] ARM: SAMSUNG: Remove unused PWM timer IRQ chip code Tomasz Figa
2013-07-20 0:04 ` [PATCH v4 12/20] pwm: samsung: Rename to pwm-samsung-legacy Tomasz Figa
2013-07-29 11:44 ` Thierry Reding
2013-07-20 0:04 ` [PATCH v4 13/20] pwm: Add new pwm-samsung driver Tomasz Figa
2013-07-21 19:50 ` Sylwester Nawrocki
2013-07-21 21:58 ` Tomasz Figa
2013-07-22 20:50 ` [PATCH v5 " Tomasz Figa
2013-07-23 23:43 ` [PATCH v6 " Tomasz Figa
2013-08-07 19:35 ` Andrew Bresticker
2013-08-07 19:49 ` Tomasz Figa
2013-08-08 17:13 ` Andrew Bresticker
2013-08-08 21:27 ` Tomasz Figa
2013-07-29 11:44 ` [PATCH v4 " Thierry Reding
2013-07-20 0:04 ` [PATCH v4 14/20] ARM: SAMSUNG: Rework private data handling in dev-backlight Tomasz Figa
2013-07-20 0:04 ` [PATCH v4 15/20] ARM: SAMSUNG: Modify board files to use new PWM platform device Tomasz Figa
2013-07-20 0:04 ` [PATCH v4 16/20] pwm: Remove superseded pwm-samsung-legacy driver Tomasz Figa
2013-07-29 11:45 ` Thierry Reding
2013-07-20 0:04 ` [PATCH v4 17/20] ARM: SAMSUNG: Remove old PWM timer platform devices Tomasz Figa
2013-07-20 0:04 ` [PATCH v4 18/20] ARM: SAMSUNG: Remove pwm-clock infrastructure Tomasz Figa
2013-07-20 0:04 ` [PATCH v4 19/20] ARM: SAMSUNG: Remove remaining uses of plat/regs-timer.h header Tomasz Figa
2013-07-20 0:04 ` [PATCH v4 20/20] ARM: SAMSUNG: Remove " Tomasz Figa
2013-07-21 22:22 ` [PATCH v4 00/20] Samsung PWM support cleanup Sylwester Nawrocki
2013-07-21 22:25 ` Tomasz Figa
2013-07-22 1:55 ` Kukjin Kim
2013-07-22 2:01 ` Kukjin Kim
2013-07-22 7:49 ` Tomasz Figa
2013-07-23 15:30 ` Thierry Reding
2013-07-22 19:34 ` Olof Johansson
2013-07-28 12:22 ` Mark Brown
2013-07-31 19:03 ` Tomasz Figa
2013-08-04 19:28 ` Olof Johansson
2013-08-05 16:51 ` Kukjin Kim
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=1658534.7nG6RFjcTc@flatron \
--to=tomasz.figa@gmail.com \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=daniel.lezcano@linaro.org \
--cc=heiko@sntech.de \
--cc=kgene.kim@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=olof@lixom.net \
--cc=sylvester.nawrocki@gmail.com \
--cc=thierry.reding@gmail.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).