CLOCKSOURCE: mips-gic: Update clockevent frequency on clock rate changes

This commit introduces the clockevent frequency update, using
a clock notifier. It will be used to support CPUFreq on platforms
using MIPS GIC based clockevents.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@imgtec.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@linux-mips.org
Cc: devicetree@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Bresticker <abrestic@chromium.org>
Cc: James Hartley <James.Hartley@imgtec.com>
Cc: Govindraj Raja <Govindraj.Raja@imgtec.com>
Cc: Damien Horsley <Damien.Horsley@imgtec.com>
Cc: James Hogan <James.Hogan@imgtec.com>
Cc: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Patchwork: https://patchwork.linux-mips.org/patch/10782/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
Ezequiel Garcia 2015-07-27 15:00:15 +01:00 committed by Ralf Baechle
parent 42b002ab73
commit fc6a6772f8

View File

@ -79,6 +79,13 @@ static void gic_clockevent_cpu_exit(struct clock_event_device *cd)
disable_percpu_irq(gic_timer_irq); disable_percpu_irq(gic_timer_irq);
} }
static void gic_update_frequency(void *data)
{
unsigned long rate = (unsigned long)data;
clockevents_update_freq(this_cpu_ptr(&gic_clockevent_device), rate);
}
static int gic_cpu_notifier(struct notifier_block *nb, unsigned long action, static int gic_cpu_notifier(struct notifier_block *nb, unsigned long action,
void *data) void *data)
{ {
@ -94,10 +101,26 @@ static int gic_cpu_notifier(struct notifier_block *nb, unsigned long action,
return NOTIFY_OK; return NOTIFY_OK;
} }
static int gic_clk_notifier(struct notifier_block *nb, unsigned long action,
void *data)
{
struct clk_notifier_data *cnd = data;
if (action == POST_RATE_CHANGE)
on_each_cpu(gic_update_frequency, (void *)cnd->new_rate, 1);
return NOTIFY_OK;
}
static struct notifier_block gic_cpu_nb = { static struct notifier_block gic_cpu_nb = {
.notifier_call = gic_cpu_notifier, .notifier_call = gic_cpu_notifier,
}; };
static struct notifier_block gic_clk_nb = {
.notifier_call = gic_clk_notifier,
};
static int gic_clockevent_init(void) static int gic_clockevent_init(void)
{ {
int ret; int ret;
@ -160,6 +183,7 @@ void __init gic_clocksource_init(unsigned int frequency)
static void __init gic_clocksource_of_init(struct device_node *node) static void __init gic_clocksource_of_init(struct device_node *node)
{ {
struct clk *clk; struct clk *clk;
int ret;
if (WARN_ON(!gic_present || !node->parent || if (WARN_ON(!gic_present || !node->parent ||
!of_device_is_compatible(node->parent, "mti,gic"))) !of_device_is_compatible(node->parent, "mti,gic")))
@ -186,7 +210,12 @@ static void __init gic_clocksource_of_init(struct device_node *node)
} }
__gic_clocksource_init(); __gic_clocksource_init();
gic_clockevent_init();
ret = gic_clockevent_init();
if (!ret && !IS_ERR(clk)) {
if (clk_notifier_register(clk, &gic_clk_nb) < 0)
pr_warn("GIC: Unable to register clock notifier\n");
}
/* And finally start the counter */ /* And finally start the counter */
gic_start_count(); gic_start_count();