Skip to content

Commit 004c15a

Browse files
Bill HuangSamuel Ortiz
authored andcommitted
mfd: dt: tps6586x: Add power off control
Add DT property "ti,system-power-controller" telling whether or not this pmic is in charge of controlling the system power, so the power off routine can be hooked up to system call "pm_power_off". Based on the work by: Dan Willemsen <dwillemsen@nvidia.com> Signed-off-by: Bill Huang <bilhuang@nvidia.com> Tested-by: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent 80633f0 commit 004c15a

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

‎Documentation/devicetree/bindings/regulator/tps6586x.txt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Required properties:
1818
- vinldo678-supply: The input supply for the LDO6, LDO7 and LDO8
1919
- vinldo9-supply: The input supply for the LDO9
2020

21+
Optional properties:
22+
- ti,system-power-controller: Telling whether or not this pmic is controlling
23+
the system power.
24+
2125
Each regulator is defined using the standard binding for regulators.
2226

2327
Example:
@@ -30,6 +34,8 @@ Example:
3034
#gpio-cells = <2>;
3135
gpio-controller;
3236

37+
ti,system-power-controller;
38+
3339
sm0-supply = <&some_reg>;
3440
sm1-supply = <&some_reg>;
3541
sm2-supply = <&some_reg>;

‎drivers/mfd/tps6586x.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
#include <linux/mfd/core.h>
3030
#include <linux/mfd/tps6586x.h>
3131

32+
#define TPS6586X_SUPPLYENE 0x14
33+
#define EXITSLREQ_BIT BIT(1)
34+
#define SLEEP_MODE_BIT BIT(3)
35+
3236
/* interrupt control registers */
3337
#define TPS6586X_INT_ACK1 0xb5
3438
#define TPS6586X_INT_ACK2 0xb6
@@ -409,6 +413,7 @@ static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *clien
409413
pdata->subdevs = devs;
410414
pdata->gpio_base = -1;
411415
pdata->irq_base = -1;
416+
pdata->pm_off = of_property_read_bool(np, "ti,system-power-controller");
412417

413418
return pdata;
414419
}
@@ -441,6 +446,15 @@ static const struct regmap_config tps6586x_regmap_config = {
441446
.cache_type = REGCACHE_RBTREE,
442447
};
443448

449+
static struct device *tps6586x_dev;
450+
static void tps6586x_power_off(void)
451+
{
452+
if (tps6586x_clr_bits(tps6586x_dev, TPS6586X_SUPPLYENE, EXITSLREQ_BIT))
453+
return;
454+
455+
tps6586x_set_bits(tps6586x_dev, TPS6586X_SUPPLYENE, SLEEP_MODE_BIT);
456+
}
457+
444458
static int __devinit tps6586x_i2c_probe(struct i2c_client *client,
445459
const struct i2c_device_id *id)
446460
{
@@ -506,6 +520,11 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client,
506520
goto err_add_devs;
507521
}
508522

523+
if (pdata->pm_off && !pm_power_off) {
524+
tps6586x_dev = &client->dev;
525+
pm_power_off = tps6586x_power_off;
526+
}
527+
509528
return 0;
510529

511530
err_add_devs:

‎include/linux/mfd/tps6586x.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct tps6586x_platform_data {
7777

7878
int gpio_base;
7979
int irq_base;
80+
bool pm_off;
8081
};
8182

8283
/*

0 commit comments

Comments
 (0)