Skip to content

Commit 1d16cfb

Browse files
author
Rob Herring
committed
clocksource: tegra20: use the device_node pointer passed to init
We've already matched the node, so use the node pointer passed in. The rtc init was intermingled with the timer init, so split this out to a separate init function. Signed-off-by: Rob Herring <rob.herring@calxeda.com> Cc: John Stultz <johnstul@us.ibm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Stephen Warren <swarren@nvidia.com> Tested-by: Stephen Warren <swarren@nvidia.com>
1 parent effbfdd commit 1d16cfb

1 file changed

Lines changed: 26 additions & 41 deletions

File tree

‎drivers/clocksource/tegra20_timer.c‎

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -154,28 +154,12 @@ static struct irqaction tegra_timer_irq = {
154154
.dev_id = &tegra_clockevent,
155155
};
156156

157-
static const struct of_device_id timer_match[] __initconst = {
158-
{ .compatible = "nvidia,tegra20-timer" },
159-
{}
160-
};
161-
162-
static const struct of_device_id rtc_match[] __initconst = {
163-
{ .compatible = "nvidia,tegra20-rtc" },
164-
{}
165-
};
166-
167157
static void __init tegra20_init_timer(struct device_node *np)
168158
{
169159
struct clk *clk;
170160
unsigned long rate;
171161
int ret;
172162

173-
np = of_find_matching_node(NULL, timer_match);
174-
if (!np) {
175-
pr_err("Failed to find timer DT node\n");
176-
BUG();
177-
}
178-
179163
timer_reg_base = of_iomap(np, 0);
180164
if (!timer_reg_base) {
181165
pr_err("Can't map timer registers\n");
@@ -199,30 +183,6 @@ static void __init tegra20_init_timer(struct device_node *np)
199183

200184
of_node_put(np);
201185

202-
np = of_find_matching_node(NULL, rtc_match);
203-
if (!np) {
204-
pr_err("Failed to find RTC DT node\n");
205-
BUG();
206-
}
207-
208-
rtc_base = of_iomap(np, 0);
209-
if (!rtc_base) {
210-
pr_err("Can't map RTC registers");
211-
BUG();
212-
}
213-
214-
/*
215-
* rtc registers are used by read_persistent_clock, keep the rtc clock
216-
* enabled
217-
*/
218-
clk = clk_get_sys("rtc-tegra", NULL);
219-
if (IS_ERR(clk))
220-
pr_warn("Unable to get rtc-tegra clock\n");
221-
else
222-
clk_prepare_enable(clk);
223-
224-
of_node_put(np);
225-
226186
switch (rate) {
227187
case 12000000:
228188
timer_writel(0x000b, TIMERUS_USEC_CFG);
@@ -261,9 +221,34 @@ static void __init tegra20_init_timer(struct device_node *np)
261221
#ifdef CONFIG_HAVE_ARM_TWD
262222
twd_local_timer_of_register();
263223
#endif
224+
}
225+
CLOCKSOURCE_OF_DECLARE(tegra20_timer, "nvidia,tegra20-timer", tegra20_init_timer);
226+
227+
static void __init tegra20_init_rtc(struct device_node *np)
228+
{
229+
struct clk *clk;
230+
231+
rtc_base = of_iomap(np, 0);
232+
if (!rtc_base) {
233+
pr_err("Can't map RTC registers");
234+
BUG();
235+
}
236+
237+
/*
238+
* rtc registers are used by read_persistent_clock, keep the rtc clock
239+
* enabled
240+
*/
241+
clk = clk_get_sys("rtc-tegra", NULL);
242+
if (IS_ERR(clk))
243+
pr_warn("Unable to get rtc-tegra clock\n");
244+
else
245+
clk_prepare_enable(clk);
246+
247+
of_node_put(np);
248+
264249
register_persistent_clock(NULL, tegra_read_persistent_clock);
265250
}
266-
CLOCKSOURCE_OF_DECLARE(tegra20, "nvidia,tegra20-timer", tegra20_init_timer);
251+
CLOCKSOURCE_OF_DECLARE(tegra20_rtc, "nvidia,tegra20-rtc", tegra20_init_rtc);
267252

268253
#ifdef CONFIG_PM
269254
static u32 usec_config;

0 commit comments

Comments
 (0)