diff options
author | Noam Camus <noamca@mellanox.com> | 2016-11-16 01:31:12 -0500 |
---|---|---|
committer | Vineet Gupta <vgupta@synopsys.com> | 2016-11-30 14:54:25 -0500 |
commit | 0465fb495f9c9698de08ff103905008e5f38e8f1 (patch) | |
tree | 02ba9ebf43ce8e4140bd2d625f0817f71e2fe743 | |
parent | 09dcd1958be42ea473fef24a2c02d975f520ea71 (diff) |
clocksource: update "fn" at CLOCKSOURCE_OF_DECLARE() of nps400 timer
nps_setup_clocksource() should take node as only argument as defined by
typedef int (*of_init_fn_1_ret)(struct device_node *)
Therefore need to replace:
int __init nps_setup_clocksource(struct device_node *node, struct clk *clk)
with
int __init nps_setup_clocksource(struct device_node *node)
This patch also serve as preparation for next patch which add support
for clockevents to nps400.
Specifically we add new function nps_get_timer_clk() to serve clocksource
and later clockevent registration.
Signed-off-by: Noam Camus <noamca@mellanox.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r-- | drivers/clocksource/timer-nps.c | 65 |
1 files changed, 39 insertions, 26 deletions
diff --git a/drivers/clocksource/timer-nps.c b/drivers/clocksource/timer-nps.c index 70c149af8ee0..0c8e21f905d7 100644 --- a/drivers/clocksource/timer-nps.c +++ b/drivers/clocksource/timer-nps.c | |||
@@ -46,7 +46,35 @@ | |||
46 | /* This array is per cluster of CPUs (Each NPS400 cluster got 256 CPUs) */ | 46 | /* This array is per cluster of CPUs (Each NPS400 cluster got 256 CPUs) */ |
47 | static void *nps_msu_reg_low_addr[NPS_CLUSTER_NUM] __read_mostly; | 47 | static void *nps_msu_reg_low_addr[NPS_CLUSTER_NUM] __read_mostly; |
48 | 48 | ||
49 | static unsigned long nps_timer_rate; | 49 | static int __init nps_get_timer_clk(struct device_node *node, |
50 | unsigned long *timer_freq, | ||
51 | struct clk **clk) | ||
52 | { | ||
53 | int ret; | ||
54 | |||
55 | *clk = of_clk_get(node, 0); | ||
56 | if (IS_ERR(*clk)) { | ||
57 | pr_err("timer missing clk"); | ||
58 | return PTR_ERR(*clk); | ||
59 | } | ||
60 | |||
61 | ret = clk_prepare_enable(*clk); | ||
62 | if (ret) { | ||
63 | pr_err("Couldn't enable parent clk\n"); | ||
64 | clk_put(*clk); | ||
65 | return ret; | ||
66 | } | ||
67 | |||
68 | *timer_freq = clk_get_rate(*clk); | ||
69 | if (!(*timer_freq)) { | ||
70 | pr_err("Couldn't get clk rate\n"); | ||
71 | clk_disable_unprepare(*clk); | ||
72 | clk_put(*clk); | ||
73 | return -EINVAL; | ||
74 | } | ||
75 | |||
76 | return 0; | ||
77 | } | ||
50 | 78 | ||
51 | static cycle_t nps_clksrc_read(struct clocksource *clksrc) | 79 | static cycle_t nps_clksrc_read(struct clocksource *clksrc) |
52 | { | 80 | { |
@@ -55,26 +83,24 @@ static cycle_t nps_clksrc_read(struct clocksource *clksrc) | |||
55 | return (cycle_t)ioread32be(nps_msu_reg_low_addr[cluster]); | 83 | return (cycle_t)ioread32be(nps_msu_reg_low_addr[cluster]); |
56 | } | 84 | } |
57 | 85 | ||
58 | static int __init nps_setup_clocksource(struct device_node *node, | 86 | static int __init nps_setup_clocksource(struct device_node *node) |
59 | struct clk *clk) | ||
60 | { | 87 | { |
61 | int ret, cluster; | 88 | int ret, cluster; |
89 | struct clk *clk; | ||
90 | unsigned long nps_timer1_freq; | ||
91 | |||
62 | 92 | ||
63 | for (cluster = 0; cluster < NPS_CLUSTER_NUM; cluster++) | 93 | for (cluster = 0; cluster < NPS_CLUSTER_NUM; cluster++) |
64 | nps_msu_reg_low_addr[cluster] = | 94 | nps_msu_reg_low_addr[cluster] = |
65 | nps_host_reg((cluster << NPS_CLUSTER_OFFSET), | 95 | nps_host_reg((cluster << NPS_CLUSTER_OFFSET), |
66 | NPS_MSU_BLKID, NPS_MSU_TICK_LOW); | 96 | NPS_MSU_BLKID, NPS_MSU_TICK_LOW); |
67 | 97 | ||
68 | ret = clk_prepare_enable(clk); | 98 | ret = nps_get_timer_clk(node, &nps_timer1_freq, &clk); |
69 | if (ret) { | 99 | if (ret) |
70 | pr_err("Couldn't enable parent clock\n"); | ||
71 | return ret; | 100 | return ret; |
72 | } | ||
73 | 101 | ||
74 | nps_timer_rate = clk_get_rate(clk); | 102 | ret = clocksource_mmio_init(nps_msu_reg_low_addr, "nps-tick", |
75 | 103 | nps_timer1_freq, 300, 32, nps_clksrc_read); | |
76 | ret = clocksource_mmio_init(nps_msu_reg_low_addr, "EZnps-tick", | ||
77 | nps_timer_rate, 301, 32, nps_clksrc_read); | ||
78 | if (ret) { | 104 | if (ret) { |
79 | pr_err("Couldn't register clock source.\n"); | 105 | pr_err("Couldn't register clock source.\n"); |
80 | clk_disable_unprepare(clk); | 106 | clk_disable_unprepare(clk); |
@@ -83,18 +109,5 @@ static int __init nps_setup_clocksource(struct device_node *node, | |||
83 | return ret; | 109 | return ret; |
84 | } | 110 | } |
85 | 111 | ||
86 | static int __init nps_timer_init(struct device_node *node) | ||
87 | { | ||
88 | struct clk *clk; | ||
89 | |||
90 | clk = of_clk_get(node, 0); | ||
91 | if (IS_ERR(clk)) { | ||
92 | pr_err("Can't get timer clock.\n"); | ||
93 | return PTR_ERR(clk); | ||
94 | } | ||
95 | |||
96 | return nps_setup_clocksource(node, clk); | ||
97 | } | ||
98 | |||
99 | CLOCKSOURCE_OF_DECLARE(ezchip_nps400_clksrc, "ezchip,nps400-timer", | 112 | CLOCKSOURCE_OF_DECLARE(ezchip_nps400_clksrc, "ezchip,nps400-timer", |
100 | nps_timer_init); | 113 | nps_setup_clocksource); |