Skip to content

Commit

Permalink
clocksource: kona: Add basic use of external clock
Browse files Browse the repository at this point in the history
When an clock is specified in the device tree, enable it and use it to
determine the external clock frequency.

Signed-off-by: Tim Kryger <[email protected]>
Reviewed-by: Markus Mayer <[email protected]>
Reviewed-by: Matt Porter <[email protected]>
Reviewed-by: Christian Daudt <[email protected]>
Acked-by: Daniel Lezcano <[email protected]>
Signed-off-by: Christian Daudt <[email protected]>
Signed-off-by: Olof Johansson <[email protected]>
  • Loading branch information
Tim Kryger authored and olofj committed Feb 1, 2014
1 parent 7c76203 commit 50ac206
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions drivers/clocksource/bcm_kona_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/jiffies.h>
#include <linux/clockchips.h>
#include <linux/types.h>
#include <linux/clk.h>

#include <linux/io.h>
#include <asm/mach/time.h>
Expand Down Expand Up @@ -101,11 +102,18 @@ kona_timer_get_counter(void *timer_base, uint32_t *msw, uint32_t *lsw)
static void __init kona_timers_init(struct device_node *node)
{
u32 freq;
struct clk *external_clk;

if (!of_property_read_u32(node, "clock-frequency", &freq))
external_clk = of_clk_get_by_name(node, NULL);

if (!IS_ERR(external_clk)) {
arch_timer_rate = clk_get_rate(external_clk);
clk_prepare_enable(external_clk);
} else if (!of_property_read_u32(node, "clock-frequency", &freq)) {
arch_timer_rate = freq;
else
panic("clock-frequency not set in the .dts file");
} else {
panic("unable to determine clock-frequency");
}

/* Setup IRQ numbers */
timers.tmr_irq = irq_of_parse_and_map(node, 0);
Expand Down

0 comments on commit 50ac206

Please sign in to comment.