summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e6db0f2)
raw | patch | inline | side by side (parent: e6db0f2)
author | Russ Dill <Russ.Dill@ti.com> | |
Tue, 26 Aug 2014 05:43:20 +0000 (11:13 +0530) | ||
committer | Tero Kristo <t-kristo@ti.com> | |
Mon, 1 Sep 2014 07:55:09 +0000 (10:55 +0300) |
This allows the TPS to be used with RTC only suspend/resume, otherwise
it powers off when attempting suspend.
Signed-off-by: Russ Dill <Russ.Dill@ti.com>
[j-keerthy@ti.com] ported to 3.14 with minor fixes
Signed-off-by: Keerthy <j-keerthy@ti.com>
it powers off when attempting suspend.
Signed-off-by: Russ Dill <Russ.Dill@ti.com>
[j-keerthy@ti.com] ported to 3.14 with minor fixes
Signed-off-by: Keerthy <j-keerthy@ti.com>
drivers/mfd/tps65217.c | patch | blob | history | |
include/linux/mfd/tps65217.h | patch | blob | history |
diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c
index 21eea218c080877c9ab7337825a4a2e11d779eb2..4353047f7793bbedb5f20c19afa6dfd6e49e374a 100644 (file)
--- a/drivers/mfd/tps65217.c
+++ b/drivers/mfd/tps65217.c
#include <linux/slab.h>
#include <linux/regmap.h>
#include <linux/err.h>
+#include <linux/reboot.h>
#include <linux/of.h>
#include <linux/of_device.h>
.max_register = 0x1e,
};
+static int tps65217_reboot_handler(struct notifier_block *this,
+ unsigned long code,
+ void *unused)
+{
+ struct tps65217 *tps = container_of(this, struct tps65217,
+ reboot_notifier);
+
+ if (code == SYS_POWER_OFF && tps->write_status_off) {
+ int ret;
+ dev_info(tps->dev, "%s: Enabling STATUS_OFF\n", __func__);
+ ret = tps65217_set_bits(tps, TPS65217_REG_STATUS,
+ TPS65217_STATUS_OFF,
+ TPS65217_STATUS_OFF,
+ TPS65217_PROTECT_NONE);
+ if (ret < 0)
+ dev_err(tps->dev, "Failed to set status OFF\n");
+ }
+
+ return NOTIFY_OK;
+}
+
static const struct of_device_id tps65217_of_match[] = {
{ .compatible = "ti,tps65217", .data = (void *)TPS65217 },
{ /* sentinel */ },
/* Set the PMIC to shutdown on PWR_EN toggle */
if (status_off) {
- ret = tps65217_set_bits(tps, TPS65217_REG_STATUS,
- TPS65217_STATUS_OFF, TPS65217_STATUS_OFF,
- TPS65217_PROTECT_NONE);
- if (ret)
- dev_warn(tps->dev, "unable to set the status OFF\n");
+ tps->write_status_off = 1;
+ tps->reboot_notifier.notifier_call = tps65217_reboot_handler;
+ ret = register_reboot_notifier(&tps->reboot_notifier);
+ if (ret < 0) {
+ dev_err(tps->dev, "Failed to register reboot handler\n");
+ return ret;
+ }
+ ret = tps65217_clear_bits(tps, TPS65217_REG_STATUS,
+ TPS65217_STATUS_OFF,
+ TPS65217_PROTECT_NONE);
+ if (ret < 0) {
+ dev_err(tps->dev, "Failed to clear status-off bit\n");
+ return ret;
+ }
}
dev_info(tps->dev, "TPS65217 ID %#x version 1.%d\n",
{
struct tps65217 *tps = i2c_get_clientdata(client);
+ if (tps->write_status_off)
+ unregister_reboot_notifier(&tps->reboot_notifier);
+
mfd_remove_devices(tps->dev);
return 0;
index 54b5458ec084a50ec06cc9f418d4e623e0aaf7bc..4c809137525cd1fcd3d411cbf24dbb56fdde659e 100644 (file)
#include <linux/i2c.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
+#include <linux/notifier.h>
/* TPS chip id list */
#define TPS65217 0xF0
struct regulator_desc desc[TPS65217_NUM_REGULATOR];
struct regulator_dev *rdev[TPS65217_NUM_REGULATOR];
struct regmap *regmap;
+
+ int write_status_off;
+ struct notifier_block reboot_notifier;
};
static inline struct tps65217 *dev_to_tps65217(struct device *dev)