@@ -23,6 +23,7 @@ struct clock_event_device;
extern void __iomem *twd_base;
void twd_timer_setup(struct clock_event_device *);
+int twd_timer_setup_dt(struct clock_event_device *);
void twd_timer_stop(struct clock_event_device *);
#endif
@@ -20,6 +20,9 @@
#include <linux/clockchips.h>
#include <linux/irq.h>
#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
#include <asm/smp_twd.h>
#include <asm/localtimer.h>
@@ -266,3 +269,21 @@ void __cpuinit twd_timer_setup(struct clock_event_device *clk)
0xf, 0xffffffff);
enable_percpu_irq(clk->irq, 0);
}
+
+int __cpuinit twd_timer_setup_dt(struct clock_event_device *clk)
+{
+ struct device_node *np;
+
+ np = of_find_compatible_node(NULL, NULL, "arm,smp-twd");
+ if (np) {
+ if (!twd_base) {
+ twd_base = of_iomap(np, 0);
+ if (!twd_base)
+ return -ENOMEM;
+ }
+ evt->irq = irq_of_parse_and_map(np, 0);
+ }
+ twd_timer_setup(evt);
+
+ return 0;
+}
@@ -16,9 +16,6 @@
*/
#include <linux/init.h>
#include <linux/clockchips.h>
-#include <linux/of.h>
-#include <linux/of_address.h>
-#include <linux/of_irq.h>
#include <asm/smp_twd.h>
@@ -27,14 +24,5 @@
*/
int __cpuinit local_timer_setup(struct clock_event_device *evt)
{
- struct device_node *np;
-
- np = of_find_compatible_node(NULL, NULL, "arm,smp-twd");
- if (!twd_base) {
- twd_base = of_iomap(np, 0);
- WARN_ON(!twd_base);
- }
- evt->irq = irq_of_parse_and_map(np, 0);
- twd_timer_setup(evt);
- return 0;
+ return twd_timer_setup_dt(evt);
}
@@ -12,8 +12,6 @@
#include <linux/init.h>
#include <linux/clockchips.h>
-#include <linux/of_address.h>
-#include <linux/of_irq.h>
#include <asm/smp_twd.h>
/*
@@ -21,15 +19,5 @@
*/
int __cpuinit local_timer_setup(struct clock_event_device *evt)
{
- struct device_node *np;
-
- np = of_find_compatible_node(NULL, NULL, "arm,smp-twd");
- if (!twd_base) {
- twd_base = of_iomap(np, 0);
- WARN_ON(!twd_base);
- }
- evt->irq = irq_of_parse_and_map(np, 0);
- twd_timer_setup(evt);
-
- return 0;
+ return twd_timer_setup_dt(evt);
}