Source
184
184
};
185
185
186
186
static const struct atmel_hlcdc_pwm_errata atmel_hlcdc_pwm_at91sam9x5_errata = {
187
187
.slow_clk_erratum = true,
188
188
};
189
189
190
190
static const struct atmel_hlcdc_pwm_errata atmel_hlcdc_pwm_sama5d3_errata = {
191
191
.div1_clk_erratum = true,
192
192
};
193
193
194
+
#ifdef CONFIG_PM_SLEEP
195
+
static int atmel_hlcdc_pwm_suspend(struct device *dev)
196
+
{
197
+
struct atmel_hlcdc_pwm *chip = dev_get_drvdata(dev);
198
+
199
+
/* Keep the periph clock enabled if the PWM is still running. */
200
+
if (pwm_is_enabled(&chip->chip.pwms[0]))
201
+
clk_disable_unprepare(chip->hlcdc->periph_clk);
202
+
203
+
return 0;
204
+
}
205
+
206
+
static int atmel_hlcdc_pwm_resume(struct device *dev)
207
+
{
208
+
struct atmel_hlcdc_pwm *chip = dev_get_drvdata(dev);
209
+
struct pwm_state state;
210
+
int ret;
211
+
212
+
pwm_get_state(&chip->chip.pwms[0], &state);
213
+
214
+
/* Re-enable the periph clock it was stopped during suspend. */
215
+
if (!state.enabled) {
216
+
ret = clk_prepare_enable(chip->hlcdc->periph_clk);
217
+
if (ret)
218
+
return ret;
219
+
}
220
+
221
+
return atmel_hlcdc_pwm_apply(&chip->chip, &chip->chip.pwms[0], &state);
222
+
}
223
+
#endif
224
+
225
+
static SIMPLE_DEV_PM_OPS(atmel_hlcdc_pwm_pm_ops,
226
+
atmel_hlcdc_pwm_suspend, atmel_hlcdc_pwm_resume);
227
+
194
228
static const struct of_device_id atmel_hlcdc_dt_ids[] = {
195
229
{
196
230
.compatible = "atmel,at91sam9n12-hlcdc",
197
231
/* 9n12 has same errata as 9x5 HLCDC PWM */
198
232
.data = &atmel_hlcdc_pwm_at91sam9x5_errata,
199
233
},
200
234
{
201
235
.compatible = "atmel,at91sam9x5-hlcdc",
202
236
.data = &atmel_hlcdc_pwm_at91sam9x5_errata,
203
237
},
273
307
274
308
static const struct of_device_id atmel_hlcdc_pwm_dt_ids[] = {
275
309
{ .compatible = "atmel,hlcdc-pwm" },
276
310
{ /* sentinel */ },
277
311
};
278
312
279
313
static struct platform_driver atmel_hlcdc_pwm_driver = {
280
314
.driver = {
281
315
.name = "atmel-hlcdc-pwm",
282
316
.of_match_table = atmel_hlcdc_pwm_dt_ids,
317
+
.pm = &atmel_hlcdc_pwm_pm_ops,
283
318
},
284
319
.probe = atmel_hlcdc_pwm_probe,
285
320
.remove = atmel_hlcdc_pwm_remove,
286
321
};
287
322
module_platform_driver(atmel_hlcdc_pwm_driver);
288
323
289
324
MODULE_ALIAS("platform:atmel-hlcdc-pwm");
290
325
MODULE_AUTHOR("Boris Brezillon <boris.brezillon@free-electrons.com>");
291
326
MODULE_DESCRIPTION("Atmel HLCDC PWM driver");
292
327
MODULE_LICENSE("GPL v2");