hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/clocksource/dw_apb_timer_of.c
....@@ -1,20 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2012 Altera Corporation
34 * Copyright (c) 2011 Picochip Ltd., Jamie Iles
45 *
56 * Modified from mach-picoxcell/time.c
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
187 */
198 #include <linux/delay.h>
209 #include <linux/dw_apb_timer.h>
....@@ -22,6 +11,7 @@
2211 #include <linux/of_address.h>
2312 #include <linux/of_irq.h>
2413 #include <linux/clk.h>
14
+#include <linux/reset.h>
2515 #include <linux/sched_clock.h>
2616
2717 static void __init timer_get_base_and_rate(struct device_node *np,
....@@ -29,11 +19,22 @@
2919 {
3020 struct clk *timer_clk;
3121 struct clk *pclk;
22
+ struct reset_control *rstc;
3223
3324 *base = of_iomap(np, 0);
3425
3526 if (!*base)
36
- panic("Unable to map regs for %s", np->name);
27
+ panic("Unable to map regs for %pOFn", np);
28
+
29
+ /*
30
+ * Reset the timer if the reset control is available, wiping
31
+ * out the state the firmware may have left it
32
+ */
33
+ rstc = of_reset_control_get(np, NULL);
34
+ if (!IS_ERR(rstc)) {
35
+ reset_control_assert(rstc);
36
+ reset_control_deassert(rstc);
37
+ }
3738
3839 /*
3940 * Not all implementations use a periphal clock, so don't panic
....@@ -42,8 +43,8 @@
4243 pclk = of_clk_get_by_name(np, "pclk");
4344 if (!IS_ERR(pclk))
4445 if (clk_prepare_enable(pclk))
45
- pr_warn("pclk for %s is present, but could not be activated\n",
46
- np->name);
46
+ pr_warn("pclk for %pOFn is present, but could not be activated\n",
47
+ np);
4748
4849 timer_clk = of_clk_get_by_name(np, "timer");
4950 if (IS_ERR(timer_clk))
....@@ -57,7 +58,7 @@
5758 try_clock_freq:
5859 if (of_property_read_u32(np, "clock-freq", rate) &&
5960 of_property_read_u32(np, "clock-frequency", rate))
60
- panic("No clock nor clock-frequency property for %s", np->name);
61
+ panic("No clock nor clock-frequency property for %pOFn", np);
6162 }
6263
6364 static void __init add_clockevent(struct device_node *event_timer)
....@@ -72,7 +73,7 @@
7273
7374 timer_get_base_and_rate(event_timer, &iobase, &rate);
7475
75
- ced = dw_apb_clockevent_init(0, event_timer->name, 300, iobase, irq,
76
+ ced = dw_apb_clockevent_init(-1, event_timer->name, 300, iobase, irq,
7677 rate);
7778 if (!ced)
7879 panic("Unable to initialise clockevent device");