diff options
-rw-r--r-- | arch/arm/mach-picoxcell/common.h | 2 | ||||
-rw-r--r-- | drivers/clocksource/dw_apb_timer.c | 6 | ||||
-rw-r--r-- | drivers/clocksource/dw_apb_timer_of.c | 52 | ||||
-rw-r--r-- | include/linux/dw_apb_timer.h | 6 |
4 files changed, 29 insertions, 37 deletions
diff --git a/arch/arm/mach-picoxcell/common.h b/arch/arm/mach-picoxcell/common.h index 481b42a4ef15..237fb3bcbd04 100644 --- a/arch/arm/mach-picoxcell/common.h +++ b/arch/arm/mach-picoxcell/common.h | |||
@@ -12,6 +12,4 @@ | |||
12 | 12 | ||
13 | #include <asm/mach/time.h> | 13 | #include <asm/mach/time.h> |
14 | 14 | ||
15 | extern void dw_apb_timer_init(void); | ||
16 | |||
17 | #endif /* __PICOXCELL_COMMON_H__ */ | 15 | #endif /* __PICOXCELL_COMMON_H__ */ |
diff --git a/drivers/clocksource/dw_apb_timer.c b/drivers/clocksource/dw_apb_timer.c index e54ca1062d8e..e7042bc5c7d2 100644 --- a/drivers/clocksource/dw_apb_timer.c +++ b/drivers/clocksource/dw_apb_timer.c | |||
@@ -21,12 +21,6 @@ | |||
21 | #define APBT_MIN_PERIOD 4 | 21 | #define APBT_MIN_PERIOD 4 |
22 | #define APBT_MIN_DELTA_USEC 200 | 22 | #define APBT_MIN_DELTA_USEC 200 |
23 | 23 | ||
24 | #define APBTMR_N_LOAD_COUNT 0x00 | ||
25 | #define APBTMR_N_CURRENT_VALUE 0x04 | ||
26 | #define APBTMR_N_CONTROL 0x08 | ||
27 | #define APBTMR_N_EOI 0x0c | ||
28 | #define APBTMR_N_INT_STATUS 0x10 | ||
29 | |||
30 | #define APBTMRS_INT_STATUS 0xa0 | 24 | #define APBTMRS_INT_STATUS 0xa0 |
31 | #define APBTMRS_EOI 0xa4 | 25 | #define APBTMRS_EOI 0xa4 |
32 | #define APBTMRS_RAW_INT_STATUS 0xa8 | 26 | #define APBTMRS_RAW_INT_STATUS 0xa8 |
diff --git a/drivers/clocksource/dw_apb_timer_of.c b/drivers/clocksource/dw_apb_timer_of.c index ab09ed3742ee..44a3b9163c46 100644 --- a/drivers/clocksource/dw_apb_timer_of.c +++ b/drivers/clocksource/dw_apb_timer_of.c | |||
@@ -57,6 +57,15 @@ static void add_clockevent(struct device_node *event_timer) | |||
57 | dw_apb_clockevent_register(ced); | 57 | dw_apb_clockevent_register(ced); |
58 | } | 58 | } |
59 | 59 | ||
60 | static void __iomem *sched_io_base; | ||
61 | |||
62 | /* This is actually same as __apbt_read_clocksource(), but with | ||
63 | different interface */ | ||
64 | static u32 read_sched_clock_sptimer(void) | ||
65 | { | ||
66 | return ~__raw_readl(sched_io_base + APBTMR_N_CURRENT_VALUE); | ||
67 | } | ||
68 | |||
60 | static void add_clocksource(struct device_node *source_timer) | 69 | static void add_clocksource(struct device_node *source_timer) |
61 | { | 70 | { |
62 | void __iomem *iobase; | 71 | void __iomem *iobase; |
@@ -71,41 +80,27 @@ static void add_clocksource(struct device_node *source_timer) | |||
71 | 80 | ||
72 | dw_apb_clocksource_start(cs); | 81 | dw_apb_clocksource_start(cs); |
73 | dw_apb_clocksource_register(cs); | 82 | dw_apb_clocksource_register(cs); |
74 | } | ||
75 | 83 | ||
76 | static void __iomem *sched_io_base; | 84 | sched_io_base = iobase; |
77 | 85 | setup_sched_clock(read_sched_clock_sptimer, 32, rate); | |
78 | static u32 read_sched_clock(void) | ||
79 | { | ||
80 | return __raw_readl(sched_io_base); | ||
81 | } | 86 | } |
82 | 87 | ||
83 | static const struct of_device_id sptimer_ids[] __initconst = { | 88 | static const struct of_device_id osctimer_ids[] __initconst = { |
84 | { .compatible = "picochip,pc3x2-rtc" }, | 89 | { .compatible = "picochip,pc3x2-timer" }, |
90 | { .compatible = "snps,dw-apb-timer-osc" }, | ||
85 | { .compatible = "snps,dw-apb-timer-sp" }, | 91 | { .compatible = "snps,dw-apb-timer-sp" }, |
86 | { /* Sentinel */ }, | 92 | { /* Sentinel */ }, |
87 | }; | 93 | }; |
88 | 94 | ||
89 | static void init_sched_clock(void) | 95 | /* |
90 | { | 96 | You don't have to use dw_apb_timer for scheduler clock, |
91 | struct device_node *sched_timer; | 97 | this should also work fine on arm: |
92 | u32 rate; | ||
93 | |||
94 | sched_timer = of_find_matching_node(NULL, sptimer_ids); | ||
95 | if (!sched_timer) | ||
96 | panic("No RTC for sched clock to use"); | ||
97 | 98 | ||
98 | timer_get_base_and_rate(sched_timer, &sched_io_base, &rate); | 99 | twd_local_timer_of_register(); |
99 | of_node_put(sched_timer); | 100 | arch_timer_of_register(); |
101 | arch_timer_sched_clock_init(); | ||
102 | */ | ||
100 | 103 | ||
101 | setup_sched_clock(read_sched_clock, 32, rate); | ||
102 | } | ||
103 | |||
104 | static const struct of_device_id osctimer_ids[] __initconst = { | ||
105 | { .compatible = "picochip,pc3x2-timer" }, | ||
106 | { .compatible = "snps,dw-apb-timer-osc" }, | ||
107 | {}, | ||
108 | }; | ||
109 | 104 | ||
110 | void __init dw_apb_timer_init(void) | 105 | void __init dw_apb_timer_init(void) |
111 | { | 106 | { |
@@ -121,7 +116,6 @@ void __init dw_apb_timer_init(void) | |||
121 | panic("No timer for clocksource"); | 116 | panic("No timer for clocksource"); |
122 | add_clocksource(source_timer); | 117 | add_clocksource(source_timer); |
123 | 118 | ||
119 | of_node_put(event_timer); | ||
124 | of_node_put(source_timer); | 120 | of_node_put(source_timer); |
125 | |||
126 | init_sched_clock(); | ||
127 | } | 121 | } |
diff --git a/include/linux/dw_apb_timer.h b/include/linux/dw_apb_timer.h index b1cd9597c241..de0904e38f33 100644 --- a/include/linux/dw_apb_timer.h +++ b/include/linux/dw_apb_timer.h | |||
@@ -17,6 +17,12 @@ | |||
17 | #include <linux/clocksource.h> | 17 | #include <linux/clocksource.h> |
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
19 | 19 | ||
20 | #define APBTMR_N_LOAD_COUNT 0x00 | ||
21 | #define APBTMR_N_CURRENT_VALUE 0x04 | ||
22 | #define APBTMR_N_CONTROL 0x08 | ||
23 | #define APBTMR_N_EOI 0x0c | ||
24 | #define APBTMR_N_INT_STATUS 0x10 | ||
25 | |||
20 | #define APBTMRS_REG_SIZE 0x14 | 26 | #define APBTMRS_REG_SIZE 0x14 |
21 | 27 | ||
22 | struct dw_apb_timer { | 28 | struct dw_apb_timer { |