.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2012 Altera Corporation |
---|
3 | 4 | * Copyright (c) 2011 Picochip Ltd., Jamie Iles |
---|
4 | 5 | * |
---|
5 | 6 | * 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/>. |
---|
18 | 7 | */ |
---|
19 | 8 | #include <linux/delay.h> |
---|
20 | 9 | #include <linux/dw_apb_timer.h> |
---|
.. | .. |
---|
22 | 11 | #include <linux/of_address.h> |
---|
23 | 12 | #include <linux/of_irq.h> |
---|
24 | 13 | #include <linux/clk.h> |
---|
| 14 | +#include <linux/reset.h> |
---|
25 | 15 | #include <linux/sched_clock.h> |
---|
26 | 16 | |
---|
27 | 17 | static void __init timer_get_base_and_rate(struct device_node *np, |
---|
.. | .. |
---|
29 | 19 | { |
---|
30 | 20 | struct clk *timer_clk; |
---|
31 | 21 | struct clk *pclk; |
---|
| 22 | + struct reset_control *rstc; |
---|
32 | 23 | |
---|
33 | 24 | *base = of_iomap(np, 0); |
---|
34 | 25 | |
---|
35 | 26 | 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 | + } |
---|
37 | 38 | |
---|
38 | 39 | /* |
---|
39 | 40 | * Not all implementations use a periphal clock, so don't panic |
---|
.. | .. |
---|
42 | 43 | pclk = of_clk_get_by_name(np, "pclk"); |
---|
43 | 44 | if (!IS_ERR(pclk)) |
---|
44 | 45 | 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); |
---|
47 | 48 | |
---|
48 | 49 | timer_clk = of_clk_get_by_name(np, "timer"); |
---|
49 | 50 | if (IS_ERR(timer_clk)) |
---|
.. | .. |
---|
57 | 58 | try_clock_freq: |
---|
58 | 59 | if (of_property_read_u32(np, "clock-freq", rate) && |
---|
59 | 60 | 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); |
---|
61 | 62 | } |
---|
62 | 63 | |
---|
63 | 64 | static void __init add_clockevent(struct device_node *event_timer) |
---|
.. | .. |
---|
72 | 73 | |
---|
73 | 74 | timer_get_base_and_rate(event_timer, &iobase, &rate); |
---|
74 | 75 | |
---|
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, |
---|
76 | 77 | rate); |
---|
77 | 78 | if (!ced) |
---|
78 | 79 | panic("Unable to initialise clockevent device"); |
---|