提交 61d7e205 编写于 作者: T Tomasz Figa

clocksource: samsung_pwm_timer: Cache clocksource register address

Instead of calculating register every time the timer should be read,
we can just do it one time at initialization and store the address in
driver data.
Signed-off-by: NTomasz Figa <tomasz.figa@gmail.com>
Reviewed-by: NSylwester Nawrocki <s.nawrocki@samsung.com>
Tested-by: NHeiko Stuebner <heiko@sntech.de>
Tested-by: NMark Brown <broonie@linaro.org>
Tested-by: NSylwester Nawrocki <sylvester.nawrocki@gmail.com>
Acked-by: NArnd Bergmann <arnd@arndb.de>
上级 ceea1241
...@@ -65,6 +65,7 @@ EXPORT_SYMBOL(samsung_pwm_lock); ...@@ -65,6 +65,7 @@ EXPORT_SYMBOL(samsung_pwm_lock);
struct samsung_pwm_clocksource { struct samsung_pwm_clocksource {
void __iomem *base; void __iomem *base;
void __iomem *source_reg;
unsigned int irq[SAMSUNG_PWM_NUM]; unsigned int irq[SAMSUNG_PWM_NUM];
struct samsung_pwm_variant variant; struct samsung_pwm_variant variant;
...@@ -297,23 +298,6 @@ static void __init samsung_clockevent_init(void) ...@@ -297,23 +298,6 @@ static void __init samsung_clockevent_init(void)
} }
} }
static void __iomem *samsung_timer_reg(void)
{
switch (pwm.source_id) {
case 0:
case 1:
case 2:
case 3:
return pwm.base + pwm.source_id * 0x0c + 0x14;
case 4:
return pwm.base + 0x40;
default:
BUG();
}
}
/* /*
* Override the global weak sched_clock symbol with this * Override the global weak sched_clock symbol with this
* local implementation which uses the clocksource to get some * local implementation which uses the clocksource to get some
...@@ -323,17 +307,11 @@ static void __iomem *samsung_timer_reg(void) ...@@ -323,17 +307,11 @@ static void __iomem *samsung_timer_reg(void)
*/ */
static u32 notrace samsung_read_sched_clock(void) static u32 notrace samsung_read_sched_clock(void)
{ {
void __iomem *reg = samsung_timer_reg(); return ~__raw_readl(pwm.source_reg);
if (!reg)
return 0;
return ~__raw_readl(reg);
} }
static void __init samsung_clocksource_init(void) static void __init samsung_clocksource_init(void)
{ {
void __iomem *reg = samsung_timer_reg();
unsigned long pclk; unsigned long pclk;
unsigned long clock_rate; unsigned long clock_rate;
int ret; int ret;
...@@ -348,10 +326,15 @@ static void __init samsung_clocksource_init(void) ...@@ -348,10 +326,15 @@ static void __init samsung_clocksource_init(void)
samsung_time_setup(pwm.source_id, pwm.tcnt_max); samsung_time_setup(pwm.source_id, pwm.tcnt_max);
samsung_time_start(pwm.source_id, true); samsung_time_start(pwm.source_id, true);
if (pwm.source_id == 4)
pwm.source_reg = pwm.base + 0x40;
else
pwm.source_reg = pwm.base + pwm.source_id * 0x0c + 0x14;
setup_sched_clock(samsung_read_sched_clock, setup_sched_clock(samsung_read_sched_clock,
pwm.variant.bits, clock_rate); pwm.variant.bits, clock_rate);
ret = clocksource_mmio_init(reg, "samsung_clocksource_timer", ret = clocksource_mmio_init(pwm.source_reg, "samsung_clocksource_timer",
clock_rate, 250, pwm.variant.bits, clock_rate, 250, pwm.variant.bits,
clocksource_mmio_readl_down); clocksource_mmio_readl_down);
if (ret) if (ret)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册