1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2021 Emil Renner Berthing
6 #include <linux/mfd/tps65086.h>
7 #include <linux/mod_devicetable.h>
8 #include <linux/module.h>
9 #include <linux/platform_device.h>
10 #include <linux/reboot.h>
12 static int tps65086_restart_notify(struct sys_off_data
*data
)
14 struct tps65086
*tps65086
= data
->cb_data
;
17 ret
= regmap_write(tps65086
->regmap
, TPS65086_FORCESHUTDN
, 1);
19 dev_err(tps65086
->dev
, "%s: error writing to tps65086 pmic: %d\n",
24 /* give it a little time */
32 static int tps65086_restart_probe(struct platform_device
*pdev
)
34 struct tps65086
*tps65086
= dev_get_drvdata(pdev
->dev
.parent
);
36 return devm_register_sys_off_handler(&pdev
->dev
,
39 tps65086_restart_notify
,
43 static const struct platform_device_id tps65086_restart_id_table
[] = {
44 { "tps65086-reset", },
47 MODULE_DEVICE_TABLE(platform
, tps65086_restart_id_table
);
49 static struct platform_driver tps65086_restart_driver
= {
51 .name
= "tps65086-restart",
53 .probe
= tps65086_restart_probe
,
54 .id_table
= tps65086_restart_id_table
,
56 module_platform_driver(tps65086_restart_driver
);
58 MODULE_AUTHOR("Emil Renner Berthing <kernel@esmil.dk>");
59 MODULE_DESCRIPTION("TPS65086 restart driver");