Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Bill Huang and committed by
Samuel Ortiz
004c15a6 80633f05

+26
+6
Documentation/devicetree/bindings/regulator/tps6586x.txt
··· 18 18 - vinldo678-supply: The input supply for the LDO6, LDO7 and LDO8 19 19 - vinldo9-supply: The input supply for the LDO9 20 20 21 + Optional properties: 22 + - ti,system-power-controller: Telling whether or not this pmic is controlling 23 + the system power. 24 + 21 25 Each regulator is defined using the standard binding for regulators. 22 26 23 27 Example: ··· 33 29 34 30 #gpio-cells = <2>; 35 31 gpio-controller; 32 + 33 + ti,system-power-controller; 36 34 37 35 sm0-supply = <&some_reg>; 38 36 sm1-supply = <&some_reg>;
+19
drivers/mfd/tps6586x.c
··· 29 29 #include <linux/mfd/core.h> 30 30 #include <linux/mfd/tps6586x.h> 31 31 32 + #define TPS6586X_SUPPLYENE 0x14 33 + #define EXITSLREQ_BIT BIT(1) 34 + #define SLEEP_MODE_BIT BIT(3) 35 + 32 36 /* interrupt control registers */ 33 37 #define TPS6586X_INT_ACK1 0xb5 34 38 #define TPS6586X_INT_ACK2 0xb6 ··· 413 409 pdata->subdevs = devs; 414 410 pdata->gpio_base = -1; 415 411 pdata->irq_base = -1; 412 + pdata->pm_off = of_property_read_bool(np, "ti,system-power-controller"); 416 413 417 414 return pdata; 418 415 } ··· 445 440 .volatile_reg = is_volatile_reg, 446 441 .cache_type = REGCACHE_RBTREE, 447 442 }; 443 + 444 + static struct device *tps6586x_dev; 445 + static void tps6586x_power_off(void) 446 + { 447 + if (tps6586x_clr_bits(tps6586x_dev, TPS6586X_SUPPLYENE, EXITSLREQ_BIT)) 448 + return; 449 + 450 + tps6586x_set_bits(tps6586x_dev, TPS6586X_SUPPLYENE, SLEEP_MODE_BIT); 451 + } 448 452 449 453 static int __devinit tps6586x_i2c_probe(struct i2c_client *client, 450 454 const struct i2c_device_id *id) ··· 518 504 if (ret) { 519 505 dev_err(&client->dev, "add devices failed: %d\n", ret); 520 506 goto err_add_devs; 507 + } 508 + 509 + if (pdata->pm_off && !pm_power_off) { 510 + tps6586x_dev = &client->dev; 511 + pm_power_off = tps6586x_power_off; 521 512 } 522 513 523 514 return 0;
+1
include/linux/mfd/tps6586x.h
··· 77 77 78 78 int gpio_base; 79 79 int irq_base; 80 + bool pm_off; 80 81 }; 81 82 82 83 /*