Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Noam Camus and committed by
Vineet Gupta
0465fb49 09dcd195

+39 -26
+39 -26
drivers/clocksource/timer-nps.c
··· 46 46 /* This array is per cluster of CPUs (Each NPS400 cluster got 256 CPUs) */ 47 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 79 static cycle_t nps_clksrc_read(struct clocksource *clksrc) 52 80 { ··· 83 55 return (cycle_t)ioread32be(nps_msu_reg_low_addr[cluster]); 84 56 } 85 57 86 - static int __init nps_setup_clocksource(struct device_node *node, 87 - struct clk *clk) 58 + static int __init nps_setup_clocksource(struct device_node *node) 88 59 { 89 60 int ret, cluster; 61 + struct clk *clk; 62 + unsigned long nps_timer1_freq; 63 + 90 64 91 65 for (cluster = 0; cluster < NPS_CLUSTER_NUM; cluster++) 92 66 nps_msu_reg_low_addr[cluster] = 93 67 nps_host_reg((cluster << NPS_CLUSTER_OFFSET), 94 - NPS_MSU_BLKID, NPS_MSU_TICK_LOW); 68 + NPS_MSU_BLKID, NPS_MSU_TICK_LOW); 95 69 96 - ret = clk_prepare_enable(clk); 97 - if (ret) { 98 - pr_err("Couldn't enable parent clock\n"); 70 + ret = nps_get_timer_clk(node, &nps_timer1_freq, &clk); 71 + if (ret) 99 72 return ret; 100 - } 101 73 102 - nps_timer_rate = clk_get_rate(clk); 103 - 104 - ret = clocksource_mmio_init(nps_msu_reg_low_addr, "EZnps-tick", 105 - nps_timer_rate, 301, 32, nps_clksrc_read); 74 + ret = clocksource_mmio_init(nps_msu_reg_low_addr, "nps-tick", 75 + nps_timer1_freq, 300, 32, nps_clksrc_read); 106 76 if (ret) { 107 77 pr_err("Couldn't register clock source.\n"); 108 78 clk_disable_unprepare(clk); ··· 109 83 return ret; 110 84 } 111 85 112 - static int __init nps_timer_init(struct device_node *node) 113 - { 114 - struct clk *clk; 115 - 116 - clk = of_clk_get(node, 0); 117 - if (IS_ERR(clk)) { 118 - pr_err("Can't get timer clock.\n"); 119 - return PTR_ERR(clk); 120 - } 121 - 122 - return nps_setup_clocksource(node, clk); 123 - } 124 - 125 86 CLOCKSOURCE_OF_DECLARE(ezchip_nps400_clksrc, "ezchip,nps400-timer", 126 - nps_timer_init); 87 + nps_setup_clocksource);