Skip to content

Commit e1ce697

Browse files
committed
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Thomas writes: "Three small fixes for clocksource drivers: - Proper error handling in the Atmel PIT driver - Add CLOCK_SOURCE_SUSPEND_NONSTOP for TI SoCs so suspend works again - Fix the next event function for Facebook Backpack-CMM BMC chips so usleep(100) doesnt sleep several milliseconds" * 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: clocksource/drivers/timer-atmel-pit: Properly handle error cases clocksource/drivers/fttmr010: Fix set_next_event handler clocksource/drivers/ti-32k: Add CLOCK_SOURCE_SUSPEND_NONSTOP flag for non-am43 SoCs
2 parents af17b3a + 090bcfd commit e1ce697

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

drivers/clocksource/timer-atmel-pit.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,26 +180,29 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
180180
data->base = of_iomap(node, 0);
181181
if (!data->base) {
182182
pr_err("Could not map PIT address\n");
183-
return -ENXIO;
183+
ret = -ENXIO;
184+
goto exit;
184185
}
185186

186187
data->mck = of_clk_get(node, 0);
187188
if (IS_ERR(data->mck)) {
188189
pr_err("Unable to get mck clk\n");
189-
return PTR_ERR(data->mck);
190+
ret = PTR_ERR(data->mck);
191+
goto exit;
190192
}
191193

192194
ret = clk_prepare_enable(data->mck);
193195
if (ret) {
194196
pr_err("Unable to enable mck\n");
195-
return ret;
197+
goto exit;
196198
}
197199

198200
/* Get the interrupts property */
199201
data->irq = irq_of_parse_and_map(node, 0);
200202
if (!data->irq) {
201203
pr_err("Unable to get IRQ from DT\n");
202-
return -EINVAL;
204+
ret = -EINVAL;
205+
goto exit;
203206
}
204207

205208
/*
@@ -227,7 +230,7 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
227230
ret = clocksource_register_hz(&data->clksrc, pit_rate);
228231
if (ret) {
229232
pr_err("Failed to register clocksource\n");
230-
return ret;
233+
goto exit;
231234
}
232235

233236
/* Set up irq handler */
@@ -236,7 +239,8 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
236239
"at91_tick", data);
237240
if (ret) {
238241
pr_err("Unable to setup IRQ\n");
239-
return ret;
242+
clocksource_unregister(&data->clksrc);
243+
goto exit;
240244
}
241245

242246
/* Set up and register clockevents */
@@ -254,6 +258,10 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
254258
clockevents_register_device(&data->clkevt);
255259

256260
return 0;
261+
262+
exit:
263+
kfree(data);
264+
return ret;
257265
}
258266
TIMER_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit",
259267
at91sam926x_pit_dt_init);

drivers/clocksource/timer-fttmr010.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,17 @@ static int fttmr010_timer_set_next_event(unsigned long cycles,
130130
cr &= ~fttmr010->t1_enable_val;
131131
writel(cr, fttmr010->base + TIMER_CR);
132132

133-
/* Setup the match register forward/backward in time */
134-
cr = readl(fttmr010->base + TIMER1_COUNT);
135-
if (fttmr010->count_down)
136-
cr -= cycles;
137-
else
138-
cr += cycles;
139-
writel(cr, fttmr010->base + TIMER1_MATCH1);
133+
if (fttmr010->count_down) {
134+
/*
135+
* ASPEED Timer Controller will load TIMER1_LOAD register
136+
* into TIMER1_COUNT register when the timer is re-enabled.
137+
*/
138+
writel(cycles, fttmr010->base + TIMER1_LOAD);
139+
} else {
140+
/* Setup the match register forward in time */
141+
cr = readl(fttmr010->base + TIMER1_COUNT);
142+
writel(cr + cycles, fttmr010->base + TIMER1_MATCH1);
143+
}
140144

141145
/* Start */
142146
cr = readl(fttmr010->base + TIMER_CR);

drivers/clocksource/timer-ti-32k.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ static int __init ti_32k_timer_init(struct device_node *np)
9797
return -ENXIO;
9898
}
9999

100+
if (!of_machine_is_compatible("ti,am43"))
101+
ti_32k_timer.cs.flags |= CLOCK_SOURCE_SUSPEND_NONSTOP;
102+
100103
ti_32k_timer.counter = ti_32k_timer.base;
101104

102105
/*

0 commit comments

Comments
 (0)