Revert "clocksource: tegra20: use the device_node pointer passed to init"
Dan Willemsen [Tue, 20 Aug 2013 04:35:33 +0000 (21:35 -0700)]
This reverts commit 1d16cfb3aeba71bc6ecf2d19ccbabed0426e5c22.

Signed-off-by: Dan Willemsen <dwillemsen@nvidia.com>

drivers/clocksource/tegra20_timer.c

index 15cc723..b3396ab 100644 (file)
@@ -154,12 +154,28 @@ static struct irqaction tegra_timer_irq = {
        .dev_id         = &tegra_clockevent,
 };
 
+static const struct of_device_id timer_match[] __initconst = {
+       { .compatible = "nvidia,tegra20-timer" },
+       {}
+};
+
+static const struct of_device_id rtc_match[] __initconst = {
+       { .compatible = "nvidia,tegra20-rtc" },
+       {}
+};
+
 static void __init tegra20_init_timer(struct device_node *np)
 {
        struct clk *clk;
        unsigned long rate;
        int ret;
 
+       np = of_find_matching_node(NULL, timer_match);
+       if (!np) {
+               pr_err("Failed to find timer DT node\n");
+               BUG();
+       }
+
        timer_reg_base = of_iomap(np, 0);
        if (!timer_reg_base) {
                pr_err("Can't map timer registers\n");
@@ -183,6 +199,30 @@ static void __init tegra20_init_timer(struct device_node *np)
 
        of_node_put(np);
 
+       np = of_find_matching_node(NULL, rtc_match);
+       if (!np) {
+               pr_err("Failed to find RTC DT node\n");
+               BUG();
+       }
+
+       rtc_base = of_iomap(np, 0);
+       if (!rtc_base) {
+               pr_err("Can't map RTC registers");
+               BUG();
+       }
+
+       /*
+        * rtc registers are used by read_persistent_clock, keep the rtc clock
+        * enabled
+        */
+       clk = clk_get_sys("rtc-tegra", NULL);
+       if (IS_ERR(clk))
+               pr_warn("Unable to get rtc-tegra clock\n");
+       else
+               clk_prepare_enable(clk);
+
+       of_node_put(np);
+
        switch (rate) {
        case 12000000:
                timer_writel(0x000b, TIMERUS_USEC_CFG);
@@ -221,34 +261,9 @@ static void __init tegra20_init_timer(struct device_node *np)
 #ifdef CONFIG_HAVE_ARM_TWD
        twd_local_timer_of_register();
 #endif
-}
-CLOCKSOURCE_OF_DECLARE(tegra20_timer, "nvidia,tegra20-timer", tegra20_init_timer);
-
-static void __init tegra20_init_rtc(struct device_node *np)
-{
-       struct clk *clk;
-
-       rtc_base = of_iomap(np, 0);
-       if (!rtc_base) {
-               pr_err("Can't map RTC registers");
-               BUG();
-       }
-
-       /*
-        * rtc registers are used by read_persistent_clock, keep the rtc clock
-        * enabled
-        */
-       clk = clk_get_sys("rtc-tegra", NULL);
-       if (IS_ERR(clk))
-               pr_warn("Unable to get rtc-tegra clock\n");
-       else
-               clk_prepare_enable(clk);
-
-       of_node_put(np);
-
        register_persistent_clock(NULL, tegra_read_persistent_clock);
 }
-CLOCKSOURCE_OF_DECLARE(tegra20_rtc, "nvidia,tegra20-rtc", tegra20_init_rtc);
+CLOCKSOURCE_OF_DECLARE(tegra20, "nvidia,tegra20-timer", tegra20_init_timer);
 
 #ifdef CONFIG_PM
 static u32 usec_config;