]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
clocksource: samsung_pwm_timer: Correct definition of AUTORELOAD bit
authorTomasz Figa <tomasz.figa@gmail.com>
Mon, 17 Jun 2013 00:10:24 +0000 (02:10 +0200)
committerTomasz Figa <tomasz.figa@gmail.com>
Mon, 5 Aug 2013 23:21:41 +0000 (01:21 +0200)
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>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Mark Brown <broonie@linaro.org>
Tested-by: Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
drivers/clocksource/samsung_pwm_timer.c

index 3fa5b07fa50d8471603337d2c23f33c9da8a9c75..5d0049f07af42ea962b24ce0e28ced65653db0ae 100644 (file)
 #define TCFG1_SHIFT(x)                 ((x) * 4)
 #define TCFG1_MUX_MASK                 0xf
 
+/*
+ * Each channel occupies 4 bits in TCON register, but there is a gap of 4
+ * bits (one channel) after channel 0, so channels have different numbering
+ * when accessing TCON register.
+ *
+ * In addition, the location of autoreload bit for channel 4 (TCON channel 5)
+ * in its set of bits is 2 as opposed to 3 for other channels.
+ */
 #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) + 3))
+#define _TCON_AUTORELOAD4(chan)                (1 << (4 * (chan) + 2))
+#define TCON_AUTORELOAD(chan)          \
+       ((chan < 5) ? _TCON_AUTORELOAD(chan) : _TCON_AUTORELOAD4(chan))
 
 DEFINE_SPINLOCK(samsung_pwm_lock);
 EXPORT_SYMBOL(samsung_pwm_lock);