1 // SPDX-License-Identifier: GPL-2.0-only
3 * Power off driver for ams AS3722 device.
5 * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved.
10 #include <linux/mfd/as3722.h>
11 #include <linux/module.h>
13 #include <linux/platform_device.h>
14 #include <linux/slab.h>
16 struct as3722_poweroff {
18 struct as3722 *as3722;
21 static struct as3722_poweroff *as3722_pm_poweroff;
23 static void as3722_pm_power_off(void)
27 if (!as3722_pm_poweroff) {
28 pr_err("AS3722 poweroff is not initialised\n");
32 ret = as3722_update_bits(as3722_pm_poweroff->as3722,
33 AS3722_RESET_CONTROL_REG, AS3722_POWER_OFF, AS3722_POWER_OFF);
35 dev_err(as3722_pm_poweroff->dev,
36 "RESET_CONTROL_REG update failed, %d\n", ret);
39 static int as3722_poweroff_probe(struct platform_device *pdev)
41 struct as3722_poweroff *as3722_poweroff;
42 struct device_node *np = pdev->dev.parent->of_node;
47 if (!of_property_read_bool(np, "ams,system-power-controller"))
50 as3722_poweroff = devm_kzalloc(&pdev->dev, sizeof(*as3722_poweroff),
55 as3722_poweroff->as3722 = dev_get_drvdata(pdev->dev.parent);
56 as3722_poweroff->dev = &pdev->dev;
57 as3722_pm_poweroff = as3722_poweroff;
59 pm_power_off = as3722_pm_power_off;
64 static int as3722_poweroff_remove(struct platform_device *pdev)
66 if (pm_power_off == as3722_pm_power_off)
68 as3722_pm_poweroff = NULL;
73 static struct platform_driver as3722_poweroff_driver = {
75 .name = "as3722-power-off",
77 .probe = as3722_poweroff_probe,
78 .remove = as3722_poweroff_remove,
81 module_platform_driver(as3722_poweroff_driver);
83 MODULE_DESCRIPTION("Power off driver for ams AS3722 PMIC Device");
84 MODULE_ALIAS("platform:as3722-power-off");