lkml.org 
[lkml]   [2017]   [Feb]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] rtc: sun6i: extend test coverage
Hi Alexandre,

[auto build test ERROR on abelloni/rtc-next]
[also build test ERROR on next-20170201]
[cannot apply to v4.10-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Alexandre-Belloni/rtc-sun6i-extend-test-coverage/20170201-200542
base: https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64

All error/warnings (new ones prefixed by >>):

>> drivers/clocksource/timer-sun5i.c:52:21: error: field 'clksrc' has incomplete type
struct clocksource clksrc;
^~~~~~
>> drivers/clocksource/timer-sun5i.c:60:28: error: field 'clkevt' has incomplete type
struct clock_event_device clkevt;
^~~~~~
In file included from include/linux/clk.h:16:0,
from drivers/clocksource/timer-sun5i.c:13:
drivers/clocksource/timer-sun5i.c: In function 'sun5i_clkevt_shutdown':
include/linux/kernel.h:850:48: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
>> drivers/clocksource/timer-sun5i.c:64:2: note: in expansion of macro 'container_of'
container_of(x, struct sun5i_timer_clkevt, clkevt)
^~~~~~~~~~~~
>> drivers/clocksource/timer-sun5i.c:108:34: note: in expansion of macro 'to_sun5i_timer_clkevt'
struct sun5i_timer_clkevt *ce = to_sun5i_timer_clkevt(clkevt);
^~~~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:850:48: note: (near initialization for 'ce')
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
>> drivers/clocksource/timer-sun5i.c:64:2: note: in expansion of macro 'container_of'
container_of(x, struct sun5i_timer_clkevt, clkevt)
^~~~~~~~~~~~
>> drivers/clocksource/timer-sun5i.c:108:34: note: in expansion of macro 'to_sun5i_timer_clkevt'
struct sun5i_timer_clkevt *ce = to_sun5i_timer_clkevt(clkevt);
^~~~~~~~~~~~~~~~~~~~~
drivers/clocksource/timer-sun5i.c: In function 'sun5i_clkevt_set_oneshot':
include/linux/kernel.h:850:48: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
>> drivers/clocksource/timer-sun5i.c:64:2: note: in expansion of macro 'container_of'
container_of(x, struct sun5i_timer_clkevt, clkevt)
^~~~~~~~~~~~
drivers/clocksource/timer-sun5i.c:116:34: note: in expansion of macro 'to_sun5i_timer_clkevt'
struct sun5i_timer_clkevt *ce = to_sun5i_timer_clkevt(clkevt);
^~~~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:850:48: note: (near initialization for 'ce')
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
>> drivers/clocksource/timer-sun5i.c:64:2: note: in expansion of macro 'container_of'
container_of(x, struct sun5i_timer_clkevt, clkevt)
^~~~~~~~~~~~
drivers/clocksource/timer-sun5i.c:116:34: note: in expansion of macro 'to_sun5i_timer_clkevt'
struct sun5i_timer_clkevt *ce = to_sun5i_timer_clkevt(clkevt);
^~~~~~~~~~~~~~~~~~~~~
drivers/clocksource/timer-sun5i.c: In function 'sun5i_clkevt_set_periodic':
include/linux/kernel.h:850:48: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
>> drivers/clocksource/timer-sun5i.c:64:2: note: in expansion of macro 'container_of'
container_of(x, struct sun5i_timer_clkevt, clkevt)
^~~~~~~~~~~~
drivers/clocksource/timer-sun5i.c:125:34: note: in expansion of macro 'to_sun5i_timer_clkevt'
struct sun5i_timer_clkevt *ce = to_sun5i_timer_clkevt(clkevt);
^~~~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:850:48: note: (near initialization for 'ce')
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
>> drivers/clocksource/timer-sun5i.c:64:2: note: in expansion of macro 'container_of'
container_of(x, struct sun5i_timer_clkevt, clkevt)
^~~~~~~~~~~~
drivers/clocksource/timer-sun5i.c:125:34: note: in expansion of macro 'to_sun5i_timer_clkevt'
struct sun5i_timer_clkevt *ce = to_sun5i_timer_clkevt(clkevt);
^~~~~~~~~~~~~~~~~~~~~
drivers/clocksource/timer-sun5i.c: In function 'sun5i_clkevt_next_event':
include/linux/kernel.h:850:48: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
>> drivers/clocksource/timer-sun5i.c:64:2: note: in expansion of macro 'container_of'
container_of(x, struct sun5i_timer_clkevt, clkevt)
^~~~~~~~~~~~
drivers/clocksource/timer-sun5i.c:136:34: note: in expansion of macro 'to_sun5i_timer_clkevt'
struct sun5i_timer_clkevt *ce = to_sun5i_timer_clkevt(clkevt);
^~~~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:850:48: note: (near initialization for 'ce')
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
>> drivers/clocksource/timer-sun5i.c:64:2: note: in expansion of macro 'container_of'
container_of(x, struct sun5i_timer_clkevt, clkevt)
^~~~~~~~~~~~
drivers/clocksource/timer-sun5i.c:136:34: note: in expansion of macro 'to_sun5i_timer_clkevt'
struct sun5i_timer_clkevt *ce = to_sun5i_timer_clkevt(clkevt);
^~~~~~~~~~~~~~~~~~~~~
drivers/clocksource/timer-sun5i.c: In function 'sun5i_clksrc_read':
include/linux/kernel.h:850:48: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
drivers/clocksource/timer-sun5i.c:56:2: note: in expansion of macro 'container_of'
container_of(x, struct sun5i_timer_clksrc, clksrc)
^~~~~~~~~~~~
>> drivers/clocksource/timer-sun5i.c:157:34: note: in expansion of macro 'to_sun5i_timer_clksrc'
struct sun5i_timer_clksrc *cs = to_sun5i_timer_clksrc(clksrc);
^~~~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:850:48: note: (near initialization for 'cs')
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
drivers/clocksource/timer-sun5i.c:56:2: note: in expansion of macro 'container_of'
container_of(x, struct sun5i_timer_clksrc, clksrc)
^~~~~~~~~~~~
>> drivers/clocksource/timer-sun5i.c:157:34: note: in expansion of macro 'to_sun5i_timer_clksrc'
struct sun5i_timer_clksrc *cs = to_sun5i_timer_clksrc(clksrc);
^~~~~~~~~~~~~~~~~~~~~
drivers/clocksource/timer-sun5i.c: In function 'sun5i_rate_cb_clksrc':
>> drivers/clocksource/timer-sun5i.c:171:3: error: implicit declaration of function 'clocksource_unregister' [-Werror=implicit-function-declaration]
clocksource_unregister(&cs->clksrc);
^~~~~~~~~~~~~~~~~~~~~~
>> drivers/clocksource/timer-sun5i.c:175:3: error: implicit declaration of function 'clocksource_register_hz' [-Werror=implicit-function-declaration]
clocksource_register_hz(&cs->clksrc, ndata->new_rate);
^~~~~~~~~~~~~~~~~~~~~~~
drivers/clocksource/timer-sun5i.c: In function 'sun5i_setup_clocksource':
>> drivers/clocksource/timer-sun5i.c:223:20: error: implicit declaration of function 'CLOCKSOURCE_MASK' [-Werror=implicit-function-declaration]
cs->clksrc.mask = CLOCKSOURCE_MASK(32);
^~~~~~~~~~~~~~~~
>> drivers/clocksource/timer-sun5i.c:224:21: error: 'CLOCK_SOURCE_IS_CONTINUOUS' undeclared (first use in this function)
cs->clksrc.flags = CLOCK_SOURCE_IS_CONTINUOUS;
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/clocksource/timer-sun5i.c:224:21: note: each undeclared identifier is reported only once for each function it appears in
drivers/clocksource/timer-sun5i.c: In function 'sun5i_rate_cb_clkevt':
>> drivers/clocksource/timer-sun5i.c:251:3: error: implicit declaration of function 'clockevents_update_freq' [-Werror=implicit-function-declaration]
clockevents_update_freq(&ce->clkevt, ndata->new_rate);
^~~~~~~~~~~~~~~~~~~~~~~
drivers/clocksource/timer-sun5i.c: In function 'sun5i_setup_clockevent':
>> drivers/clocksource/timer-sun5i.c:291:24: error: 'CLOCK_EVT_FEAT_PERIODIC' undeclared (first use in this function)
ce->clkevt.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
^~~~~~~~~~~~~~~~~~~~~~~
--
>> drivers/clocksource/cadence_ttc_timer.c:92:21: error: field 'cs' has incomplete type
struct clocksource cs;
^~
>> drivers/clocksource/cadence_ttc_timer.c:100:28: error: field 'ce' has incomplete type
struct clock_event_device ce;
^~
In file included from include/linux/clk.h:16:0,
from drivers/clocksource/cadence_ttc_timer.c:18:
drivers/clocksource/cadence_ttc_timer.c: In function '__ttc_clocksource_read':
include/linux/kernel.h:850:48: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
>> drivers/clocksource/cadence_ttc_timer.c:96:3: note: in expansion of macro 'container_of'
container_of(x, struct ttc_timer_clocksource, cs)
^~~~~~~~~~~~
>> drivers/clocksource/cadence_ttc_timer.c:163:29: note: in expansion of macro 'to_ttc_timer_clksrc'
struct ttc_timer *timer = &to_ttc_timer_clksrc(cs)->ttc;
^~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:850:48: note: (near initialization for 'timer')
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
>> drivers/clocksource/cadence_ttc_timer.c:96:3: note: in expansion of macro 'container_of'
container_of(x, struct ttc_timer_clocksource, cs)
^~~~~~~~~~~~
>> drivers/clocksource/cadence_ttc_timer.c:163:29: note: in expansion of macro 'to_ttc_timer_clksrc'
struct ttc_timer *timer = &to_ttc_timer_clksrc(cs)->ttc;
^~~~~~~~~~~~~~~~~~~
drivers/clocksource/cadence_ttc_timer.c: In function 'ttc_set_next_event':
include/linux/kernel.h:850:48: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
drivers/clocksource/cadence_ttc_timer.c:104:3: note: in expansion of macro 'container_of'
container_of(x, struct ttc_timer_clockevent, ce)
^~~~~~~~~~~~
>> drivers/clocksource/cadence_ttc_timer.c:185:38: note: in expansion of macro 'to_ttc_timer_clkevent'
struct ttc_timer_clockevent *ttce = to_ttc_timer_clkevent(evt);
^~~~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:850:48: note: (near initialization for 'ttce')
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
drivers/clocksource/cadence_ttc_timer.c:104:3: note: in expansion of macro 'container_of'
container_of(x, struct ttc_timer_clockevent, ce)
^~~~~~~~~~~~
>> drivers/clocksource/cadence_ttc_timer.c:185:38: note: in expansion of macro 'to_ttc_timer_clkevent'
struct ttc_timer_clockevent *ttce = to_ttc_timer_clkevent(evt);
^~~~~~~~~~~~~~~~~~~~~
drivers/clocksource/cadence_ttc_timer.c: In function 'ttc_shutdown':
include/linux/kernel.h:850:48: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
drivers/clocksource/cadence_ttc_timer.c:104:3: note: in expansion of macro 'container_of'
container_of(x, struct ttc_timer_clockevent, ce)
^~~~~~~~~~~~
drivers/clocksource/cadence_ttc_timer.c:199:38: note: in expansion of macro 'to_ttc_timer_clkevent'
struct ttc_timer_clockevent *ttce = to_ttc_timer_clkevent(evt);
^~~~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:850:48: note: (near initialization for 'ttce')
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
drivers/clocksource/cadence_ttc_timer.c:104:3: note: in expansion of macro 'container_of'
container_of(x, struct ttc_timer_clockevent, ce)
^~~~~~~~~~~~
drivers/clocksource/cadence_ttc_timer.c:199:38: note: in expansion of macro 'to_ttc_timer_clkevent'
struct ttc_timer_clockevent *ttce = to_ttc_timer_clkevent(evt);
^~~~~~~~~~~~~~~~~~~~~
drivers/clocksource/cadence_ttc_timer.c: In function 'ttc_set_periodic':
include/linux/kernel.h:850:48: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
drivers/clocksource/cadence_ttc_timer.c:104:3: note: in expansion of macro 'container_of'
container_of(x, struct ttc_timer_clockevent, ce)
^~~~~~~~~~~~
drivers/clocksource/cadence_ttc_timer.c:211:38: note: in expansion of macro 'to_ttc_timer_clkevent'
struct ttc_timer_clockevent *ttce = to_ttc_timer_clkevent(evt);
^~~~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:850:48: note: (near initialization for 'ttce')
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
drivers/clocksource/cadence_ttc_timer.c:104:3: note: in expansion of macro 'container_of'
container_of(x, struct ttc_timer_clockevent, ce)
^~~~~~~~~~~~
drivers/clocksource/cadence_ttc_timer.c:211:38: note: in expansion of macro 'to_ttc_timer_clkevent'
struct ttc_timer_clockevent *ttce = to_ttc_timer_clkevent(evt);
^~~~~~~~~~~~~~~~~~~~~
drivers/clocksource/cadence_ttc_timer.c: In function 'ttc_resume':
include/linux/kernel.h:850:48: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
drivers/clocksource/cadence_ttc_timer.c:104:3: note: in expansion of macro 'container_of'
container_of(x, struct ttc_timer_clockevent, ce)
^~~~~~~~~~~~
drivers/clocksource/cadence_ttc_timer.c:221:38: note: in expansion of macro 'to_ttc_timer_clkevent'
struct ttc_timer_clockevent *ttce = to_ttc_timer_clkevent(evt);
^~~~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:850:48: note: (near initialization for 'ttce')
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^
drivers/clocksource/cadence_ttc_timer.c:104:3: note: in expansion of macro 'container_of'
container_of(x, struct ttc_timer_clockevent, ce)
^~~~~~~~~~~~
drivers/clocksource/cadence_ttc_timer.c:221:38: note: in expansion of macro 'to_ttc_timer_clkevent'
struct ttc_timer_clockevent *ttce = to_ttc_timer_clkevent(evt);
^~~~~~~~~~~~~~~~~~~~~
drivers/clocksource/cadence_ttc_timer.c: In function 'ttc_setup_clocksource':
>> drivers/clocksource/cadence_ttc_timer.c:358:19: error: implicit declaration of function 'CLOCKSOURCE_MASK' [-Werror=implicit-function-declaration]
ttccs->cs.mask = CLOCKSOURCE_MASK(timer_width);
^~~~~~~~~~~~~~~~
>> drivers/clocksource/cadence_ttc_timer.c:359:20: error: 'CLOCK_SOURCE_IS_CONTINUOUS' undeclared (first use in this function)
ttccs->cs.flags = CLOCK_SOURCE_IS_CONTINUOUS;
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/clocksource/cadence_ttc_timer.c:359:20: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/clocksource/cadence_ttc_timer.c:372:8: error: implicit declaration of function 'clocksource_register_hz' [-Werror=implicit-function-declaration]
err = clocksource_register_hz(&ttccs->cs, ttccs->ttc.freq / PRESCALE);
^~~~~~~~~~~~~~~~~~~~~~~
drivers/clocksource/cadence_ttc_timer.c: In function 'ttc_rate_change_clockevent_cb':
>> drivers/clocksource/cadence_ttc_timer.c:398:3: error: implicit declaration of function 'clockevents_update_freq' [-Werror=implicit-function-declaration]
clockevents_update_freq(&ttcce->ce, ndata->new_rate / PRESCALE);
^~~~~~~~~~~~~~~~~~~~~~~
drivers/clocksource/cadence_ttc_timer.c: In function 'ttc_setup_clockevent':
>> drivers/clocksource/cadence_ttc_timer.c:441:23: error: 'CLOCK_EVT_FEAT_PERIODIC' undeclared (first use in this function)
ttcce->ce.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/clocksource/cadence_ttc_timer.c:441:49: error: 'CLOCK_EVT_FEAT_ONESHOT' undeclared (first use in this function)
ttcce->ce.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
^~~~~~~~~~~~~~~~~~~~~~
>> drivers/clocksource/cadence_ttc_timer.c:468:2: error: implicit declaration of function 'clockevents_config_and_register' [-Werror=implicit-function-declaration]
clockevents_config_and_register(&ttcce->ce,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/clocksource/cadence_ttc_timer.c: At top level:
>> drivers/clocksource/cadence_ttc_timer.c:542:29: error: expected ')' before string constant
CLOCKSOURCE_OF_DECLARE(ttc, "cdns,ttc", ttc_timer_init);
^~~~~~~~~~
drivers/clocksource/cadence_ttc_timer.c:480:19: warning: 'ttc_timer_init' defined but not used [-Wunused-function]
static int __init ttc_timer_init(struct device_node *timer)
^~~~~~~~~~~~~~
cc1: some warnings being treated as errors

vim +/clksrc +52 drivers/clocksource/timer-sun5i.c

67905540 Maxime Ripard 2013-11-07 7 *
67905540 Maxime Ripard 2013-11-07 8 * This file is licensed under the terms of the GNU General Public
67905540 Maxime Ripard 2013-11-07 9 * License version 2. This program is licensed "as is" without any
67905540 Maxime Ripard 2013-11-07 10 * warranty of any kind, whether express or implied.
67905540 Maxime Ripard 2013-11-07 11 */
67905540 Maxime Ripard 2013-11-07 12
67905540 Maxime Ripard 2013-11-07 @13 #include <linux/clk.h>
67905540 Maxime Ripard 2013-11-07 14 #include <linux/clockchips.h>
67905540 Maxime Ripard 2013-11-07 15 #include <linux/delay.h>
67905540 Maxime Ripard 2013-11-07 16 #include <linux/interrupt.h>
67905540 Maxime Ripard 2013-11-07 17 #include <linux/irq.h>
67905540 Maxime Ripard 2013-11-07 18 #include <linux/irqreturn.h>
e50a00be Maxime Ripard 2014-04-17 19 #include <linux/reset.h>
4a59058f Maxime Ripard 2015-03-31 20 #include <linux/slab.h>
67905540 Maxime Ripard 2013-11-07 21 #include <linux/of.h>
67905540 Maxime Ripard 2013-11-07 22 #include <linux/of_address.h>
67905540 Maxime Ripard 2013-11-07 23 #include <linux/of_irq.h>
67905540 Maxime Ripard 2013-11-07 24
67905540 Maxime Ripard 2013-11-07 25 #define TIMER_IRQ_EN_REG 0x00
67905540 Maxime Ripard 2013-11-07 26 #define TIMER_IRQ_EN(val) BIT(val)
67905540 Maxime Ripard 2013-11-07 27 #define TIMER_IRQ_ST_REG 0x04
67905540 Maxime Ripard 2013-11-07 28 #define TIMER_CTL_REG(val) (0x20 * (val) + 0x10)
67905540 Maxime Ripard 2013-11-07 29 #define TIMER_CTL_ENABLE BIT(0)
67905540 Maxime Ripard 2013-11-07 30 #define TIMER_CTL_RELOAD BIT(1)
67905540 Maxime Ripard 2013-11-07 31 #define TIMER_CTL_CLK_PRES(val) (((val) & 0x7) << 4)
67905540 Maxime Ripard 2013-11-07 32 #define TIMER_CTL_ONESHOT BIT(7)
67905540 Maxime Ripard 2013-11-07 33 #define TIMER_INTVAL_LO_REG(val) (0x20 * (val) + 0x14)
67905540 Maxime Ripard 2013-11-07 34 #define TIMER_INTVAL_HI_REG(val) (0x20 * (val) + 0x18)
67905540 Maxime Ripard 2013-11-07 35 #define TIMER_CNTVAL_LO_REG(val) (0x20 * (val) + 0x1c)
67905540 Maxime Ripard 2013-11-07 36 #define TIMER_CNTVAL_HI_REG(val) (0x20 * (val) + 0x20)
67905540 Maxime Ripard 2013-11-07 37
67905540 Maxime Ripard 2013-11-07 38 #define TIMER_SYNC_TICKS 3
67905540 Maxime Ripard 2013-11-07 39
4a59058f Maxime Ripard 2015-03-31 40 struct sun5i_timer {
4a59058f Maxime Ripard 2015-03-31 41 void __iomem *base;
4a59058f Maxime Ripard 2015-03-31 42 struct clk *clk;
3071efa4 Maxime Ripard 2015-03-31 43 struct notifier_block clk_rate_cb;
4a59058f Maxime Ripard 2015-03-31 44 u32 ticks_per_jiffy;
4a59058f Maxime Ripard 2015-03-31 45 };
4a59058f Maxime Ripard 2015-03-31 46
3071efa4 Maxime Ripard 2015-03-31 47 #define to_sun5i_timer(x) \
3071efa4 Maxime Ripard 2015-03-31 48 container_of(x, struct sun5i_timer, clk_rate_cb)
3071efa4 Maxime Ripard 2015-03-31 49
4a59058f Maxime Ripard 2015-03-31 50 struct sun5i_timer_clksrc {
4a59058f Maxime Ripard 2015-03-31 51 struct sun5i_timer timer;
4a59058f Maxime Ripard 2015-03-31 @52 struct clocksource clksrc;
4a59058f Maxime Ripard 2015-03-31 53 };
4a59058f Maxime Ripard 2015-03-31 54
4a59058f Maxime Ripard 2015-03-31 55 #define to_sun5i_timer_clksrc(x) \
4a59058f Maxime Ripard 2015-03-31 @56 container_of(x, struct sun5i_timer_clksrc, clksrc)
4a59058f Maxime Ripard 2015-03-31 57
4a59058f Maxime Ripard 2015-03-31 58 struct sun5i_timer_clkevt {
4a59058f Maxime Ripard 2015-03-31 59 struct sun5i_timer timer;
4a59058f Maxime Ripard 2015-03-31 @60 struct clock_event_device clkevt;
4a59058f Maxime Ripard 2015-03-31 61 };
4a59058f Maxime Ripard 2015-03-31 62
4a59058f Maxime Ripard 2015-03-31 63 #define to_sun5i_timer_clkevt(x) \
4a59058f Maxime Ripard 2015-03-31 @64 container_of(x, struct sun5i_timer_clkevt, clkevt)
67905540 Maxime Ripard 2013-11-07 65
67905540 Maxime Ripard 2013-11-07 66 /*
67905540 Maxime Ripard 2013-11-07 67 * When we disable a timer, we need to wait at least for 2 cycles of
67905540 Maxime Ripard 2013-11-07 68 * the timer source clock. We will use for that the clocksource timer
67905540 Maxime Ripard 2013-11-07 69 * that is already setup and runs at the same frequency than the other
67905540 Maxime Ripard 2013-11-07 70 * timers, and we never will be disabled.
67905540 Maxime Ripard 2013-11-07 71 */
4a59058f Maxime Ripard 2015-03-31 72 static void sun5i_clkevt_sync(struct sun5i_timer_clkevt *ce)
67905540 Maxime Ripard 2013-11-07 73 {
4a59058f Maxime Ripard 2015-03-31 74 u32 old = readl(ce->timer.base + TIMER_CNTVAL_LO_REG(1));
67905540 Maxime Ripard 2013-11-07 75
4a59058f Maxime Ripard 2015-03-31 76 while ((old - readl(ce->timer.base + TIMER_CNTVAL_LO_REG(1))) < TIMER_SYNC_TICKS)
67905540 Maxime Ripard 2013-11-07 77 cpu_relax();
67905540 Maxime Ripard 2013-11-07 78 }
67905540 Maxime Ripard 2013-11-07 79
4a59058f Maxime Ripard 2015-03-31 80 static void sun5i_clkevt_time_stop(struct sun5i_timer_clkevt *ce, u8 timer)
67905540 Maxime Ripard 2013-11-07 81 {
4a59058f Maxime Ripard 2015-03-31 82 u32 val = readl(ce->timer.base + TIMER_CTL_REG(timer));
4a59058f Maxime Ripard 2015-03-31 83 writel(val & ~TIMER_CTL_ENABLE, ce->timer.base + TIMER_CTL_REG(timer));
67905540 Maxime Ripard 2013-11-07 84
4a59058f Maxime Ripard 2015-03-31 85 sun5i_clkevt_sync(ce);
67905540 Maxime Ripard 2013-11-07 86 }
67905540 Maxime Ripard 2013-11-07 87
4a59058f Maxime Ripard 2015-03-31 88 static void sun5i_clkevt_time_setup(struct sun5i_timer_clkevt *ce, u8 timer, u32 delay)
67905540 Maxime Ripard 2013-11-07 89 {
4a59058f Maxime Ripard 2015-03-31 90 writel(delay, ce->timer.base + TIMER_INTVAL_LO_REG(timer));
67905540 Maxime Ripard 2013-11-07 91 }
67905540 Maxime Ripard 2013-11-07 92
4a59058f Maxime Ripard 2015-03-31 93 static void sun5i_clkevt_time_start(struct sun5i_timer_clkevt *ce, u8 timer, bool periodic)
67905540 Maxime Ripard 2013-11-07 94 {
4a59058f Maxime Ripard 2015-03-31 95 u32 val = readl(ce->timer.base + TIMER_CTL_REG(timer));
67905540 Maxime Ripard 2013-11-07 96
67905540 Maxime Ripard 2013-11-07 97 if (periodic)
67905540 Maxime Ripard 2013-11-07 98 val &= ~TIMER_CTL_ONESHOT;
67905540 Maxime Ripard 2013-11-07 99 else
67905540 Maxime Ripard 2013-11-07 100 val |= TIMER_CTL_ONESHOT;
67905540 Maxime Ripard 2013-11-07 101
67905540 Maxime Ripard 2013-11-07 102 writel(val | TIMER_CTL_ENABLE | TIMER_CTL_RELOAD,
4a59058f Maxime Ripard 2015-03-31 103 ce->timer.base + TIMER_CTL_REG(timer));
67905540 Maxime Ripard 2013-11-07 104 }
67905540 Maxime Ripard 2013-11-07 105
7486f5ad Viresh Kumar 2015-06-18 106 static int sun5i_clkevt_shutdown(struct clock_event_device *clkevt)
67905540 Maxime Ripard 2013-11-07 107 {
4a59058f Maxime Ripard 2015-03-31 @108 struct sun5i_timer_clkevt *ce = to_sun5i_timer_clkevt(clkevt);
4a59058f Maxime Ripard 2015-03-31 109
4a59058f Maxime Ripard 2015-03-31 110 sun5i_clkevt_time_stop(ce, 0);
7486f5ad Viresh Kumar 2015-06-18 111 return 0;
7486f5ad Viresh Kumar 2015-06-18 112 }
7486f5ad Viresh Kumar 2015-06-18 113
7486f5ad Viresh Kumar 2015-06-18 114 static int sun5i_clkevt_set_oneshot(struct clock_event_device *clkevt)
7486f5ad Viresh Kumar 2015-06-18 115 {
7486f5ad Viresh Kumar 2015-06-18 116 struct sun5i_timer_clkevt *ce = to_sun5i_timer_clkevt(clkevt);
7486f5ad Viresh Kumar 2015-06-18 117
4a59058f Maxime Ripard 2015-03-31 118 sun5i_clkevt_time_stop(ce, 0);
4a59058f Maxime Ripard 2015-03-31 119 sun5i_clkevt_time_start(ce, 0, false);
7486f5ad Viresh Kumar 2015-06-18 120 return 0;
67905540 Maxime Ripard 2013-11-07 121 }
7486f5ad Viresh Kumar 2015-06-18 122
7486f5ad Viresh Kumar 2015-06-18 123 static int sun5i_clkevt_set_periodic(struct clock_event_device *clkevt)
7486f5ad Viresh Kumar 2015-06-18 124 {
7486f5ad Viresh Kumar 2015-06-18 125 struct sun5i_timer_clkevt *ce = to_sun5i_timer_clkevt(clkevt);
7486f5ad Viresh Kumar 2015-06-18 126
7486f5ad Viresh Kumar 2015-06-18 127 sun5i_clkevt_time_stop(ce, 0);
7486f5ad Viresh Kumar 2015-06-18 128 sun5i_clkevt_time_setup(ce, 0, ce->timer.ticks_per_jiffy);
7486f5ad Viresh Kumar 2015-06-18 129 sun5i_clkevt_time_start(ce, 0, true);
7486f5ad Viresh Kumar 2015-06-18 130 return 0;
67905540 Maxime Ripard 2013-11-07 131 }
67905540 Maxime Ripard 2013-11-07 132
67905540 Maxime Ripard 2013-11-07 133 static int sun5i_clkevt_next_event(unsigned long evt,
4a59058f Maxime Ripard 2015-03-31 134 struct clock_event_device *clkevt)
67905540 Maxime Ripard 2013-11-07 135 {
4a59058f Maxime Ripard 2015-03-31 136 struct sun5i_timer_clkevt *ce = to_sun5i_timer_clkevt(clkevt);
4a59058f Maxime Ripard 2015-03-31 137
4a59058f Maxime Ripard 2015-03-31 138 sun5i_clkevt_time_stop(ce, 0);
4a59058f Maxime Ripard 2015-03-31 139 sun5i_clkevt_time_setup(ce, 0, evt - TIMER_SYNC_TICKS);
4a59058f Maxime Ripard 2015-03-31 140 sun5i_clkevt_time_start(ce, 0, false);
67905540 Maxime Ripard 2013-11-07 141
67905540 Maxime Ripard 2013-11-07 142 return 0;
67905540 Maxime Ripard 2013-11-07 143 }
67905540 Maxime Ripard 2013-11-07 144
67905540 Maxime Ripard 2013-11-07 145 static irqreturn_t sun5i_timer_interrupt(int irq, void *dev_id)
67905540 Maxime Ripard 2013-11-07 146 {
4a59058f Maxime Ripard 2015-03-31 147 struct sun5i_timer_clkevt *ce = (struct sun5i_timer_clkevt *)dev_id;
67905540 Maxime Ripard 2013-11-07 148
4a59058f Maxime Ripard 2015-03-31 149 writel(0x1, ce->timer.base + TIMER_IRQ_ST_REG);
4a59058f Maxime Ripard 2015-03-31 150 ce->clkevt.event_handler(&ce->clkevt);
67905540 Maxime Ripard 2013-11-07 151
67905540 Maxime Ripard 2013-11-07 152 return IRQ_HANDLED;
67905540 Maxime Ripard 2013-11-07 153 }
67905540 Maxime Ripard 2013-11-07 154
a5a1d1c2 Thomas Gleixner 2016-12-21 155 static u64 sun5i_clksrc_read(struct clocksource *clksrc)
59387683 Chen-Yu Tsai 2016-10-18 156 {
59387683 Chen-Yu Tsai 2016-10-18 @157 struct sun5i_timer_clksrc *cs = to_sun5i_timer_clksrc(clksrc);
59387683 Chen-Yu Tsai 2016-10-18 158
59387683 Chen-Yu Tsai 2016-10-18 159 return ~readl(cs->timer.base + TIMER_CNTVAL_LO_REG(1));
59387683 Chen-Yu Tsai 2016-10-18 160 }
59387683 Chen-Yu Tsai 2016-10-18 161
3071efa4 Maxime Ripard 2015-03-31 162 static int sun5i_rate_cb_clksrc(struct notifier_block *nb,
3071efa4 Maxime Ripard 2015-03-31 163 unsigned long event, void *data)
3071efa4 Maxime Ripard 2015-03-31 164 {
3071efa4 Maxime Ripard 2015-03-31 165 struct clk_notifier_data *ndata = data;
3071efa4 Maxime Ripard 2015-03-31 166 struct sun5i_timer *timer = to_sun5i_timer(nb);
3071efa4 Maxime Ripard 2015-03-31 167 struct sun5i_timer_clksrc *cs = container_of(timer, struct sun5i_timer_clksrc, timer);
3071efa4 Maxime Ripard 2015-03-31 168
3071efa4 Maxime Ripard 2015-03-31 169 switch (event) {
3071efa4 Maxime Ripard 2015-03-31 170 case PRE_RATE_CHANGE:
3071efa4 Maxime Ripard 2015-03-31 @171 clocksource_unregister(&cs->clksrc);
3071efa4 Maxime Ripard 2015-03-31 172 break;
3071efa4 Maxime Ripard 2015-03-31 173
3071efa4 Maxime Ripard 2015-03-31 174 case POST_RATE_CHANGE:
3071efa4 Maxime Ripard 2015-03-31 @175 clocksource_register_hz(&cs->clksrc, ndata->new_rate);
3071efa4 Maxime Ripard 2015-03-31 176 break;
3071efa4 Maxime Ripard 2015-03-31 177
3071efa4 Maxime Ripard 2015-03-31 178 default:
3071efa4 Maxime Ripard 2015-03-31 179 break;
3071efa4 Maxime Ripard 2015-03-31 180 }
3071efa4 Maxime Ripard 2015-03-31 181
3071efa4 Maxime Ripard 2015-03-31 182 return NOTIFY_DONE;
3071efa4 Maxime Ripard 2015-03-31 183 }
3071efa4 Maxime Ripard 2015-03-31 184
4a59058f Maxime Ripard 2015-03-31 185 static int __init sun5i_setup_clocksource(struct device_node *node,
4a59058f Maxime Ripard 2015-03-31 186 void __iomem *base,
4a59058f Maxime Ripard 2015-03-31 187 struct clk *clk, int irq)
4a59058f Maxime Ripard 2015-03-31 188 {
4a59058f Maxime Ripard 2015-03-31 189 struct sun5i_timer_clksrc *cs;
4a59058f Maxime Ripard 2015-03-31 190 unsigned long rate;
4a59058f Maxime Ripard 2015-03-31 191 int ret;
4a59058f Maxime Ripard 2015-03-31 192
4a59058f Maxime Ripard 2015-03-31 193 cs = kzalloc(sizeof(*cs), GFP_KERNEL);
4a59058f Maxime Ripard 2015-03-31 194 if (!cs)
4a59058f Maxime Ripard 2015-03-31 195 return -ENOMEM;
4a59058f Maxime Ripard 2015-03-31 196
4a59058f Maxime Ripard 2015-03-31 197 ret = clk_prepare_enable(clk);
4a59058f Maxime Ripard 2015-03-31 198 if (ret) {
4a59058f Maxime Ripard 2015-03-31 199 pr_err("Couldn't enable parent clock\n");
4a59058f Maxime Ripard 2015-03-31 200 goto err_free;
4a59058f Maxime Ripard 2015-03-31 201 }
4a59058f Maxime Ripard 2015-03-31 202
4a59058f Maxime Ripard 2015-03-31 203 rate = clk_get_rate(clk);
4a59058f Maxime Ripard 2015-03-31 204
4a59058f Maxime Ripard 2015-03-31 205 cs->timer.base = base;
4a59058f Maxime Ripard 2015-03-31 206 cs->timer.clk = clk;
3071efa4 Maxime Ripard 2015-03-31 207 cs->timer.clk_rate_cb.notifier_call = sun5i_rate_cb_clksrc;
3071efa4 Maxime Ripard 2015-03-31 208 cs->timer.clk_rate_cb.next = NULL;
3071efa4 Maxime Ripard 2015-03-31 209
3071efa4 Maxime Ripard 2015-03-31 210 ret = clk_notifier_register(clk, &cs->timer.clk_rate_cb);
3071efa4 Maxime Ripard 2015-03-31 211 if (ret) {
3071efa4 Maxime Ripard 2015-03-31 212 pr_err("Unable to register clock notifier.\n");
3071efa4 Maxime Ripard 2015-03-31 213 goto err_disable_clk;
3071efa4 Maxime Ripard 2015-03-31 214 }
4a59058f Maxime Ripard 2015-03-31 215
4a59058f Maxime Ripard 2015-03-31 216 writel(~0, base + TIMER_INTVAL_LO_REG(1));
4a59058f Maxime Ripard 2015-03-31 217 writel(TIMER_CTL_ENABLE | TIMER_CTL_RELOAD,
4a59058f Maxime Ripard 2015-03-31 218 base + TIMER_CTL_REG(1));
4a59058f Maxime Ripard 2015-03-31 219
59387683 Chen-Yu Tsai 2016-10-18 220 cs->clksrc.name = node->name;
59387683 Chen-Yu Tsai 2016-10-18 221 cs->clksrc.rating = 340;
59387683 Chen-Yu Tsai 2016-10-18 222 cs->clksrc.read = sun5i_clksrc_read;
59387683 Chen-Yu Tsai 2016-10-18 @223 cs->clksrc.mask = CLOCKSOURCE_MASK(32);
59387683 Chen-Yu Tsai 2016-10-18 @224 cs->clksrc.flags = CLOCK_SOURCE_IS_CONTINUOUS;
59387683 Chen-Yu Tsai 2016-10-18 225
59387683 Chen-Yu Tsai 2016-10-18 226 ret = clocksource_register_hz(&cs->clksrc, rate);
4a59058f Maxime Ripard 2015-03-31 227 if (ret) {
4a59058f Maxime Ripard 2015-03-31 228 pr_err("Couldn't register clock source.\n");
3071efa4 Maxime Ripard 2015-03-31 229 goto err_remove_notifier;
4a59058f Maxime Ripard 2015-03-31 230 }
4a59058f Maxime Ripard 2015-03-31 231
4a59058f Maxime Ripard 2015-03-31 232 return 0;
4a59058f Maxime Ripard 2015-03-31 233
3071efa4 Maxime Ripard 2015-03-31 234 err_remove_notifier:
3071efa4 Maxime Ripard 2015-03-31 235 clk_notifier_unregister(clk, &cs->timer.clk_rate_cb);
4a59058f Maxime Ripard 2015-03-31 236 err_disable_clk:
4a59058f Maxime Ripard 2015-03-31 237 clk_disable_unprepare(clk);
4a59058f Maxime Ripard 2015-03-31 238 err_free:
4a59058f Maxime Ripard 2015-03-31 239 kfree(cs);
4a59058f Maxime Ripard 2015-03-31 240 return ret;
4a59058f Maxime Ripard 2015-03-31 241 }
4a59058f Maxime Ripard 2015-03-31 242
3071efa4 Maxime Ripard 2015-03-31 243 static int sun5i_rate_cb_clkevt(struct notifier_block *nb,
3071efa4 Maxime Ripard 2015-03-31 244 unsigned long event, void *data)
3071efa4 Maxime Ripard 2015-03-31 245 {
3071efa4 Maxime Ripard 2015-03-31 246 struct clk_notifier_data *ndata = data;
3071efa4 Maxime Ripard 2015-03-31 247 struct sun5i_timer *timer = to_sun5i_timer(nb);
3071efa4 Maxime Ripard 2015-03-31 248 struct sun5i_timer_clkevt *ce = container_of(timer, struct sun5i_timer_clkevt, timer);
3071efa4 Maxime Ripard 2015-03-31 249
3071efa4 Maxime Ripard 2015-03-31 250 if (event == POST_RATE_CHANGE) {
3071efa4 Maxime Ripard 2015-03-31 @251 clockevents_update_freq(&ce->clkevt, ndata->new_rate);
3071efa4 Maxime Ripard 2015-03-31 252 ce->timer.ticks_per_jiffy = DIV_ROUND_UP(ndata->new_rate, HZ);
3071efa4 Maxime Ripard 2015-03-31 253 }
3071efa4 Maxime Ripard 2015-03-31 254

:::::: The code at line 52 was first introduced by commit
:::::: 4a59058f0b09682200c04b1db236b4a3b92128d7 clocksource/drivers/sun5i: Refactor the current code

:::::: TO: Maxime Ripard <maxime.ripard@free-electrons.com>
:::::: CC: Ingo Molnar <mingo@kernel.org>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[unhandled content-type:application/gzip]
\
 
 \ /
  Last update: 2017-02-01 15:55    [W:0.063 / U:49.856 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site