2 * Power off driver for ams AS3722 device.
4 * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved.
6 * Author: Laxman Dewangan <ldewangan@nvidia.com>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 #include <linux/mfd/as3722.h>
19 #include <linux/module.h>
21 #include <linux/of_device.h>
22 #include <linux/platform_device.h>
23 #include <linux/slab.h>
25 struct as3722_poweroff
{
27 struct as3722
*as3722
;
30 static struct as3722_poweroff
*as3722_pm_poweroff
;
32 static void as3722_pm_power_off(void)
36 if (!as3722_pm_poweroff
) {
37 pr_err("AS3722 poweroff is not initialised\n");
41 ret
= as3722_update_bits(as3722_pm_poweroff
->as3722
,
42 AS3722_RESET_CONTROL_REG
, AS3722_POWER_OFF
, AS3722_POWER_OFF
);
44 dev_err(as3722_pm_poweroff
->dev
,
45 "RESET_CONTROL_REG update failed, %d\n", ret
);
48 static int as3722_poweroff_probe(struct platform_device
*pdev
)
50 struct as3722_poweroff
*as3722_poweroff
;
51 struct device_node
*np
= pdev
->dev
.parent
->of_node
;
56 if (!of_property_read_bool(np
, "ams,system-power-controller"))
59 as3722_poweroff
= devm_kzalloc(&pdev
->dev
, sizeof(*as3722_poweroff
),
64 as3722_poweroff
->as3722
= dev_get_drvdata(pdev
->dev
.parent
);
65 as3722_poweroff
->dev
= &pdev
->dev
;
66 as3722_pm_poweroff
= as3722_poweroff
;
68 pm_power_off
= as3722_pm_power_off
;
73 static int as3722_poweroff_remove(struct platform_device
*pdev
)
75 if (pm_power_off
== as3722_pm_power_off
)
77 as3722_pm_poweroff
= NULL
;
82 static struct platform_driver as3722_poweroff_driver
= {
84 .name
= "as3722-power-off",
86 .probe
= as3722_poweroff_probe
,
87 .remove
= as3722_poweroff_remove
,
90 module_platform_driver(as3722_poweroff_driver
);
92 MODULE_DESCRIPTION("Power off driver for ams AS3722 PMIC Device");
93 MODULE_ALIAS("platform:as3722-power-off");
94 MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
95 MODULE_LICENSE("GPL v2");