Source
149
149
if (ret)
150
150
return ret;
151
151
152
152
sprd_timer_enable_interrupt(timer_of_base(&to));
153
153
clockevents_config_and_register(&to.clkevt, timer_of_rate(&to),
154
154
1, UINT_MAX);
155
155
156
156
return 0;
157
157
}
158
158
159
+
static struct timer_of suspend_to = {
160
+
.flags = TIMER_OF_BASE | TIMER_OF_CLOCK,
161
+
};
162
+
163
+
static u64 sprd_suspend_timer_read(struct clocksource *cs)
164
+
{
165
+
return ~(u64)readl_relaxed(timer_of_base(&suspend_to) +
166
+
TIMER_VALUE_SHDW_LO) & cs->mask;
167
+
}
168
+
169
+
static int sprd_suspend_timer_enable(struct clocksource *cs)
170
+
{
171
+
sprd_timer_update_counter(timer_of_base(&suspend_to),
172
+
TIMER_VALUE_LO_MASK);
173
+
sprd_timer_enable(timer_of_base(&suspend_to), TIMER_CTL_PERIOD_MODE);
174
+
175
+
return 0;
176
+
}
177
+
178
+
static void sprd_suspend_timer_disable(struct clocksource *cs)
179
+
{
180
+
sprd_timer_disable(timer_of_base(&suspend_to));
181
+
}
182
+
183
+
static struct clocksource suspend_clocksource = {
184
+
.name = "sprd_suspend_timer",
185
+
.rating = 200,
186
+
.read = sprd_suspend_timer_read,
187
+
.enable = sprd_suspend_timer_enable,
188
+
.disable = sprd_suspend_timer_disable,
189
+
.mask = CLOCKSOURCE_MASK(32),
190
+
.flags = CLOCK_SOURCE_IS_CONTINUOUS | CLOCK_SOURCE_SUSPEND_NONSTOP,
191
+
};
192
+
193
+
static int __init sprd_suspend_timer_init(struct device_node *np)
194
+
{
195
+
int ret;
196
+
197
+
ret = timer_of_init(np, &suspend_to);
198
+
if (ret)
199
+
return ret;
200
+
201
+
clocksource_register_hz(&suspend_clocksource,
202
+
timer_of_rate(&suspend_to));
203
+
204
+
return 0;
205
+
}
206
+
159
207
TIMER_OF_DECLARE(sc9860_timer, "sprd,sc9860-timer", sprd_timer_init);
208
+
TIMER_OF_DECLARE(sc9860_persistent_timer, "sprd,sc9860-suspend-timer",
209
+
sprd_suspend_timer_init);