9
9
#include "timer-of.h"
10
10
11
11
#define CMP_OFFSET 0x10000
12
+ #define RD_OFFSET 0x20000
12
13
13
14
#define CNTCV_LO 0x8
14
15
#define CNTCV_HI 0xc
15
16
#define CMPCV_LO (CMP_OFFSET + 0x20)
16
17
#define CMPCV_HI (CMP_OFFSET + 0x24)
17
18
#define CMPCR (CMP_OFFSET + 0x2c)
19
+ #define CNTCV_LO_IMX95 (RD_OFFSET + 0x8)
20
+ #define CNTCV_HI_IMX95 (RD_OFFSET + 0xc)
18
21
19
22
#define SYS_CTR_EN 0x1
20
23
#define SYS_CTR_IRQ_MASK 0x2
23
26
24
27
struct sysctr_private {
25
28
u32 cmpcr ;
29
+ u32 lo_off ;
30
+ u32 hi_off ;
26
31
};
27
32
28
33
static void sysctr_timer_enable (struct clock_event_device * evt , bool enable )
@@ -47,13 +52,14 @@ static void sysctr_irq_acknowledge(struct clock_event_device *evt)
47
52
static inline u64 sysctr_read_counter (struct clock_event_device * evt )
48
53
{
49
54
struct timer_of * to = to_timer_of (evt );
55
+ struct sysctr_private * priv = to -> private_data ;
50
56
void __iomem * base = timer_of_base (to );
51
57
u32 cnt_hi , tmp_hi , cnt_lo ;
52
58
53
59
do {
54
- cnt_hi = readl_relaxed (base + CNTCV_HI );
55
- cnt_lo = readl_relaxed (base + CNTCV_LO );
56
- tmp_hi = readl_relaxed (base + CNTCV_HI );
60
+ cnt_hi = readl_relaxed (base + priv -> hi_off );
61
+ cnt_lo = readl_relaxed (base + priv -> lo_off );
62
+ tmp_hi = readl_relaxed (base + priv -> hi_off );
57
63
} while (tmp_hi != cnt_hi );
58
64
59
65
return ((u64 ) cnt_hi << 32 ) | cnt_lo ;
@@ -127,7 +133,7 @@ static struct timer_of to_sysctr = {
127
133
},
128
134
};
129
135
130
- static int __init sysctr_timer_init (struct device_node * np )
136
+ static int __init __sysctr_timer_init (struct device_node * np )
131
137
{
132
138
struct sysctr_private * priv ;
133
139
void __iomem * base ;
@@ -154,9 +160,48 @@ static int __init sysctr_timer_init(struct device_node *np)
154
160
base = timer_of_base (& to_sysctr );
155
161
priv -> cmpcr = readl (base + CMPCR ) & ~SYS_CTR_EN ;
156
162
163
+ return 0 ;
164
+ }
165
+
166
+ static int __init sysctr_timer_init (struct device_node * np )
167
+ {
168
+ struct sysctr_private * priv ;
169
+ int ret ;
170
+
171
+ ret = __sysctr_timer_init (np );
172
+ if (ret )
173
+ return ret ;
174
+
175
+ priv = to_sysctr .private_data ;
176
+ priv -> lo_off = CNTCV_LO ;
177
+ priv -> hi_off = CNTCV_HI ;
178
+
157
179
clockevents_config_and_register (& to_sysctr .clkevt ,
158
180
timer_of_rate (& to_sysctr ),
159
181
0xff , 0x7fffffff );
182
+
160
183
return 0 ;
161
184
}
185
+
186
+ static int __init sysctr_timer_imx95_init (struct device_node * np )
187
+ {
188
+ struct sysctr_private * priv ;
189
+ int ret ;
190
+
191
+ ret = __sysctr_timer_init (np );
192
+ if (ret )
193
+ return ret ;
194
+
195
+ priv = to_sysctr .private_data ;
196
+ priv -> lo_off = CNTCV_LO_IMX95 ;
197
+ priv -> hi_off = CNTCV_HI_IMX95 ;
198
+
199
+ clockevents_config_and_register (& to_sysctr .clkevt ,
200
+ timer_of_rate (& to_sysctr ),
201
+ 0xff , 0x7fffffff );
202
+
203
+ return 0 ;
204
+ }
205
+
162
206
TIMER_OF_DECLARE (sysctr_timer , "nxp,sysctr-timer" , sysctr_timer_init );
207
+ TIMER_OF_DECLARE (sysctr_timer_imx95 , "nxp,imx95-sysctr-timer" , sysctr_timer_imx95_init );
0 commit comments