mfd: tps6586x: add api to power off tps6586x
PATCH 1/1 mfd: tps6586x: add api to power off tps6586x
From: Wei Ni <[email protected]>
Add an api to put tps6586x in sleep mode by resetting EXITSLREQ and setting SLEEP_MODE in SUPPLYENE register. It will power off ldos.
--- drivers/mfd/tps6586x.c | 29 +++++++++++++++++++++++++++++ include/linux/mfd/tps6586x.h | 1 + 2 files changed, 30 insertions(+), 0 deletions(-)
drivers/mfd/tps6586x.c +29 -0
@@ -27,6 +27,10 @@#include <linux/mfd/core.h> #include <linux/mfd/tps6586x.h> +#define TPS6586X_SUPPLYENE 0x14 +#define EXITSLREQ_BIT BIT(1)/* Exit sleep mode request */ +#define SLEEP_MODE_BIT BIT(3)/* Sleep mode */ +/* GPIO control registers */ #define TPS6586X_GPIOSET1 0x5d#define TPS6586X_GPIOSET2 0x5e
@@ -251,6 +255,29 @@ out: }EXPORT_SYMBOL_GPL (tps6586x_update); +static struct i2c_client *tps6586x_i2c_client; +int tps6586x_power_off (void ) +{ +struct device *dev =NULL ; +int ret = -EINVAL ; + +if (!tps6586x_i2c_client) +return ret; + + dev = &tps6586x_i2c_client->dev; + + ret =tps6586x_clr_bits (dev,TPS6586X_SUPPLYENE ,EXITSLREQ_BIT ); +if (ret) +return ret; + + ret =tps6586x_set_bits (dev,TPS6586X_SUPPLYENE ,SLEEP_MODE_BIT ); +if (ret) +return ret; + +return 0 ; +} +EXPORT_SYMBOL_GPL (tps6586x_power_off); +static int tps6586x_gpio_get (struct gpio_chip *gc,unsigned offset) { struct tps6586x *tps6586x = container_of(gc, struct tps6586x, gpio);
@@ -525,6 +552,8 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client, goto err_add_devs; } + tps6586x_i2c_client = client; +return 0 ; err_add_devs:
include/linux/mfd/tps6586x.h +1 -0
@@ -74,5 +74,6 @@ extern int tps6586x_set_bits(struct device *dev, int reg, uint8_t bit_mask);extern int tps6586x_clr_bits (struct device *dev,int reg,uint8_t bit_mask);extern int tps6586x_update (struct device *dev,int reg,uint8_t val,uint8_t mask); +extern int tps6586x_power_off (void );#endif /*__LINUX_MFD_TPS6586X_H */
Signature · 1 line
1.7.0
Could anyone review this patch?
Thanks
Wei.
nvpublic
Quoted 85 lines
-----Original Message-----
From: Wei Ni
Sent: 2011年7月28日 14:31
To: [email protected]; [email protected]; [email protected]; Nitin Kumbhar
Cc: [email protected]; Wei Ni
Subject: [PATCH] mfd: tps6586x: add api to power off tps6586xFrom: Wei Ni <[email protected]>
Add an api to put tps6586x in sleep mode by resetting EXITSLREQ and setting
SLEEP_MODEin SUPPLYENE register. It will power off ldos.Signed-off-by Wei Ni <[email protected]>Signed-off-by Nitin Kumbhar <[email protected]>---
drivers/mfd/tps6586x.c| 29 +++++++++++++++++++++++++++++include/linux/mfd/tps6586x.h| 1 +2 files changed, 30 insertions(+), 0 deletions(-)drivers/mfd/tps6586x.c +29
-0@@ -27,6 +27,10 @@#include <linux/mfd/core.h> #include <linux/mfd/tps6586x.h> +#define TPS6586X_SUPPLYENE 0x14 +#define EXITSLREQ_BIT BIT(1)/* Exit sleep mode request */ +#define SLEEP_MODE_BIT BIT(3)/* Sleep mode */ +/* GPIO control registers */ #define TPS6586X_GPIOSET1 0x5d#define TPS6586X_GPIOSET2 0x5e@@ -251,6 +255,29 @@ out: }EXPORT_SYMBOL_GPL (tps6586x_update); +static struct i2c_client *tps6586x_i2c_client; +int tps6586x_power_off (void ) +{ +struct device *dev =NULL ; +int ret = -EINVAL ; + +if (!tps6586x_i2c_client) +return ret; + + dev = &tps6586x_i2c_client->dev; + + ret =tps6586x_clr_bits (dev,TPS6586X_SUPPLYENE ,EXITSLREQ_BIT ); +if (ret) +return ret; + + ret =tps6586x_set_bits (dev,TPS6586X_SUPPLYENE ,SLEEP_MODE_BIT ); +if (ret) +return ret; + +return 0 ; +} +EXPORT_SYMBOL_GPL (tps6586x_power_off); +static int tps6586x_gpio_get (struct gpio_chip *gc,unsigned offset) { struct tps6586x *tps6586x = container_of(gc, struct tps6586x, gpio);@@ -525,6 +552,8 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client, goto err_add_devs; } + tps6586x_i2c_client = client; +return 0 ;
err_add_devs:include/linux/mfd/tps6586x.h +1
-1@@ -74,5 +74,6 @@ extern int tps6586x_set_bits(struct device *dev, int reg, uint8_t bit_mask);extern int tps6586x_clr_bits (struct device *dev,int reg,uint8_t bit_mask);extern int tps6586x_update (struct device *dev,int reg,uint8_t val,uint8_t mask); +extern int tps6586x_power_off (void );#endif /*__LINUX_MFD_TPS6586X_H */ --
Quoted 1 line
1.7.0
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Hello, could anyone review this patch?
Thanks
Wei.
nvpublic
Quoted 85 lines
-----Original Message-----
From: Wei Ni
Sent: Thursday, July 28, 2011 2:31 PM
To: [email protected]; [email protected]; [email protected]; Nitin Kumbhar
Cc: [email protected]; Wei Ni
Subject: [PATCH] mfd: tps6586x: add api to power off tps6586xFrom: Wei Ni <[email protected]>
Add an api to put tps6586x in sleep mode by resetting EXITSLREQ and setting
SLEEP_MODEin SUPPLYENE register. It will power off ldos.Signed-off-by Wei Ni <[email protected]>Signed-off-by Nitin Kumbhar <[email protected]>---
drivers/mfd/tps6586x.c| 29 +++++++++++++++++++++++++++++include/linux/mfd/tps6586x.h| 1 +2 files changed, 30 insertions(+), 0 deletions(-)drivers/mfd/tps6586x.c +29
-0@@ -27,6 +27,10 @@#include <linux/mfd/core.h> #include <linux/mfd/tps6586x.h> +#define TPS6586X_SUPPLYENE 0x14 +#define EXITSLREQ_BIT BIT(1)/* Exit sleep mode request */ +#define SLEEP_MODE_BIT BIT(3)/* Sleep mode */ +/* GPIO control registers */ #define TPS6586X_GPIOSET1 0x5d#define TPS6586X_GPIOSET2 0x5e@@ -251,6 +255,29 @@ out: }EXPORT_SYMBOL_GPL (tps6586x_update); +static struct i2c_client *tps6586x_i2c_client; +int tps6586x_power_off (void ) +{ +struct device *dev =NULL ; +int ret = -EINVAL ; + +if (!tps6586x_i2c_client) +return ret; + + dev = &tps6586x_i2c_client->dev; + + ret =tps6586x_clr_bits (dev,TPS6586X_SUPPLYENE ,EXITSLREQ_BIT ); +if (ret) +return ret; + + ret =tps6586x_set_bits (dev,TPS6586X_SUPPLYENE ,SLEEP_MODE_BIT ); +if (ret) +return ret; + +return 0 ; +} +EXPORT_SYMBOL_GPL (tps6586x_power_off); +static int tps6586x_gpio_get (struct gpio_chip *gc,unsigned offset) { struct tps6586x *tps6586x = container_of(gc, struct tps6586x, gpio);@@ -525,6 +552,8 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client, goto err_add_devs; } + tps6586x_i2c_client = client; +return 0 ;
err_add_devs:include/linux/mfd/tps6586x.h +1
-1@@ -74,5 +74,6 @@ extern int tps6586x_set_bits(struct device *dev, int reg, uint8_t bit_mask);extern int tps6586x_clr_bits (struct device *dev,int reg,uint8_t bit_mask);extern int tps6586x_update (struct device *dev,int reg,uint8_t val,uint8_t mask); +extern int tps6586x_power_off (void );#endif /*__LINUX_MFD_TPS6586X_H */ --
Quoted 1 line
1.7.0
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Hi Wei,
Quoted 1 line · On Thu, Jul 28, 2011 at 02:30:36PM +0800, [email protected] wrote:
+static struct
i2c_client*tps6586x_i2c_client;
That's not vey nice. By doing so, you're preventing anyone to have more than one of those chips in their boards.
Quoted 11 lines
drivers/mfd/tps6586x.c +11
-0+int tps6586x_power_off (void ) +{ +struct device *dev =NULL ; +int ret = -EINVAL ; + +if (!tps6586x_i2c_client) +return ret; + + dev = &tps6586x_i2c_client->dev; + + ret =tps6586x_clr_bits (dev,TPS6586X_SUPPLYENE ,EXITSLREQ_BIT );
drivers/mfd/tps6586x.c out: · line 279
Quoted 10 lines
drivers/mfd/tps6586x.c +10
-0+if (ret) +return ret; + + ret =tps6586x_set_bits (dev,TPS6586X_SUPPLYENE ,SLEEP_MODE_BIT ); +if (ret) +return ret; + +return 0 ; +} +EXPORT_SYMBOL_GPL (tps6586x_power_off);
Who is going to call this one ?
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/
Hi, Samuel
Thanks for your comments.
Please check the following lines with [Wei Ni]
Thanks
Wei.
Quoted 7 lines
-----Original Message-----
From: Samuel Ortiz [mailto:[email protected]]
Sent: Monday, August 22, 2011 7:05 AM
To: Wei Ni
Cc: [email protected]; [email protected]; Nitin Kumbhar; [email protected]
Subject: Re: [PATCH] mfd: tps6586x: add api to power off tps6586x
Quoted 6 lines
Hi Wei,
Quoted 1 line · On Thu, Jul 28, 2011 at 02:30:36PM +0800, [email protected] wrote:
+static struct
i2c_client*tps6586x_i2c_client;That's not vey nice. By doing so, you're preventing anyone to have more than one of those chips in their boards.
[Wei Ni] oh yes, I didn’t consider this issue. We use i2c_register_board_info() to register the tps6586x in the board file, but it didn't return the handle. Do you have any ideas?
Quoted 16 lines
Quoted 16 lines
drivers/mfd/tps6586x.c +14
-0+int tps6586x_power_off (void ) +{ +struct device *dev =NULL ; +int ret = -EINVAL ; + +if (!tps6586x_i2c_client) +return ret; + + dev = &tps6586x_i2c_client->dev; + + ret =tps6586x_clr_bits (dev,TPS6586X_SUPPLYENE ,EXITSLREQ_BIT ); +if (ret) +return ret; +
Quoted 8 lines
drivers/mfd/tps6586x.c out: · line 279
Quoted 7 lines
drivers/mfd/tps6586x.c +7
-0+ ret =tps6586x_set_bits (dev,TPS6586X_SUPPLYENE ,SLEEP_MODE_BIT ); +if (ret) +return ret; + +return 0 ; +} +EXPORT_SYMBOL_GPL (tps6586x_power_off);Who is going to call this one ?
[Wei Ni] the tegra board will call this function to power off system. It will put tps6586x in sleep mode by resetting EXITSLREQ and setting SLEEP_MODE in SUPPLYENE register. It will power off ldos.
Quoted 7 lines
Cheers,
Samuel.--
Intel Open Source Technology Centre
http://oss.intel.com/
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 17 lines · Wei Ni
Hi, Samuel
Thanks for your comments.
Please check the following lines with [Wei Ni]Thanks
Wei.Quoted 9 lines
-----Original Message-----
From: Samuel Ortiz [mailto:[email protected]]
Sent: Monday, August 22, 2011 7:05 AM
To: Wei Ni
Cc: [email protected]; [email protected]; Nitin Kumbhar; [email protected]
Subject: Re: [PATCH] mfd: tps6586x: add api to power off tps6586xHi Wei,
Quoted 9 lines
Quoted 4 lines · On Thu, Jul 28, 2011 at 02:30:36PM +0800, [email protected] wrote:
Quoted 1 line
+static struct
i2c_client*tps6586x_i2c_client;That's not vey nice. By doing so, you're preventing anyone to have more than one of those chips in their boards.
[Wei Ni] oh yes, I didn’t consider this issue. We use
i2c_register_board_info()to register the tps6586x in the board file, but it didn't return the handle. Do you have any ideas?Quoted 2 lines
Since there's no parameter in pm_power_off(), invoking power off function is a known issue
for i2c devices. And we can't get i2c client in board file.
Maybe we can add a LDO mapping in regulator driver. Since power-off function is always
customized in board file. We can disable this regulator while power_off() is called. So even
multiple PMICs is installed in one system, we only handle the real one to shutdown the
whole system.
Samuel & Mark,
Do you think that it's worth to do?
Thanks
Haojian
Quoted 7 lines · Haojian Zhuang
Maybe we can add a LDO mapping in regulator driver. Since power-off function is always
customized in board file. We can disable this regulator whilepower_off()is called. So even
multiple PMICs is installed in one system, we only handle the real one to shutdown the
whole system.
Some (ST?) platform had an issue like that. What they did IIRC is define a regulator consumer driver which is hooked up as normal then had that driver implemented a power_off() which used regulator_disable() to do the honours. Perhaps this could be made more generic somehow? Though it may have been part of their cpufreq driver or something - I can't remember the detail right now.