devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] mfd: rohm-bd71828: Add power off
@ 2024-04-02 11:16 Andreas Kemnade
  2024-04-02 11:16 ` [PATCH v3 1/2] dt-bindings: mfd: Add ROHM BD71828 system-power-controller property Andreas Kemnade
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Andreas Kemnade @ 2024-04-02 11:16 UTC (permalink / raw)
  To: lee, robh+dt, krzysztof.kozlowski+dt, conor+dt, mazziesaccount,
	devicetree, linux-kernel
  Cc: Andreas Kemnade

Add power off functionality. Marked as RFC because of magic numbers
without a good source and strange delays. The only information source is
a vendor kernel.

Changes in v3:
- define for poweroff bit
- rmw operation to set only that bit

Changes in v2:
- style corrections
- remove unnecessary writes and delays
- correctly unregister handler

Andreas Kemnade (2):
  dt-bindings: mfd: Add ROHM BD71828 system-power-controller property
  mfd: rohm-bd71828: Add power off functionality

 .../bindings/mfd/rohm,bd71828-pmic.yaml       |  2 ++
 drivers/mfd/rohm-bd71828.c                    | 36 ++++++++++++++++++-
 include/linux/mfd/rohm-bd71828.h              |  3 ++
 3 files changed, 40 insertions(+), 1 deletion(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3 1/2] dt-bindings: mfd: Add ROHM BD71828 system-power-controller property
  2024-04-02 11:16 [PATCH v3 0/2] mfd: rohm-bd71828: Add power off Andreas Kemnade
@ 2024-04-02 11:16 ` Andreas Kemnade
  2024-04-02 13:15   ` Matti Vaittinen
  2024-04-02 11:17 ` [PATCH v3 2/2] mfd: rohm-bd71828: Add power off functionality Andreas Kemnade
  2024-04-11 11:51 ` [PATCH v3 0/2] mfd: rohm-bd71828: Add power off Lee Jones
  2 siblings, 1 reply; 8+ messages in thread
From: Andreas Kemnade @ 2024-04-02 11:16 UTC (permalink / raw)
  To: lee, robh+dt, krzysztof.kozlowski+dt, conor+dt, mazziesaccount,
	devicetree, linux-kernel
  Cc: Andreas Kemnade, Krzysztof Kozlowski

As the PMIC can power off the system, add the corresponding property.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 Documentation/devicetree/bindings/mfd/rohm,bd71828-pmic.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/rohm,bd71828-pmic.yaml b/Documentation/devicetree/bindings/mfd/rohm,bd71828-pmic.yaml
index 11089aa89ec6..0b62f854bf6b 100644
--- a/Documentation/devicetree/bindings/mfd/rohm,bd71828-pmic.yaml
+++ b/Documentation/devicetree/bindings/mfd/rohm,bd71828-pmic.yaml
@@ -73,6 +73,8 @@ properties:
       used to mark the pins which should not be configured for GPIO. Please see
       the ../gpio/gpio.txt for more information.
 
+  system-power-controller: true
+
 required:
   - compatible
   - reg
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3 2/2] mfd: rohm-bd71828: Add power off functionality
  2024-04-02 11:16 [PATCH v3 0/2] mfd: rohm-bd71828: Add power off Andreas Kemnade
  2024-04-02 11:16 ` [PATCH v3 1/2] dt-bindings: mfd: Add ROHM BD71828 system-power-controller property Andreas Kemnade
@ 2024-04-02 11:17 ` Andreas Kemnade
  2024-04-11 11:50   ` Lee Jones
  2024-04-11 11:51 ` [PATCH v3 0/2] mfd: rohm-bd71828: Add power off Lee Jones
  2 siblings, 1 reply; 8+ messages in thread
From: Andreas Kemnade @ 2024-04-02 11:17 UTC (permalink / raw)
  To: lee, robh+dt, krzysztof.kozlowski+dt, conor+dt, mazziesaccount,
	devicetree, linux-kernel
  Cc: Andreas Kemnade

Since the chip can power off the system, add the corresponding
functionality.
Based on https://github.com/kobolabs/Kobo-Reader/raw/master/hw/imx6sll-clara2e/kernel.tar.bz2

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Acked-by: Matti Vaittinen <mazziesaccount@gmail.com>
---
 drivers/mfd/rohm-bd71828.c       | 36 +++++++++++++++++++++++++++++++-
 include/linux/mfd/rohm-bd71828.h |  3 +++
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/rohm-bd71828.c b/drivers/mfd/rohm-bd71828.c
index 594718f7e8e1..4a1fa8a0d76a 100644
--- a/drivers/mfd/rohm-bd71828.c
+++ b/drivers/mfd/rohm-bd71828.c
@@ -464,6 +464,27 @@ static int set_clk_mode(struct device *dev, struct regmap *regmap,
 				  OUT32K_MODE_CMOS);
 }
 
+static struct i2c_client *bd71828_dev;
+static void bd71828_power_off(void)
+{
+	while (true) {
+		s32 val;
+
+		/* We are not allowed to sleep, so do not use regmap involving mutexes here. */
+		val = i2c_smbus_read_byte_data(bd71828_dev, BD71828_REG_PS_CTRL_1);
+		if (val >= 0)
+			i2c_smbus_write_byte_data(bd71828_dev,
+						  BD71828_REG_PS_CTRL_1,
+						  BD71828_MASK_STATE_HBNT | (u8)val);
+		mdelay(500);
+	}
+}
+
+static void bd71828_remove_poweroff(void *data)
+{
+	pm_power_off = NULL;
+}
+
 static int bd71828_i2c_probe(struct i2c_client *i2c)
 {
 	struct regmap_irq_chip_data *irq_data;
@@ -542,7 +563,20 @@ static int bd71828_i2c_probe(struct i2c_client *i2c)
 	ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO, mfd, cells,
 				   NULL, 0, regmap_irq_get_domain(irq_data));
 	if (ret)
-		dev_err_probe(&i2c->dev, ret, "Failed to create subdevices\n");
+		return	dev_err_probe(&i2c->dev, ret, "Failed to create subdevices\n");
+
+	if (of_device_is_system_power_controller(i2c->dev.of_node) &&
+	    chip_type == ROHM_CHIP_TYPE_BD71828) {
+		if (!pm_power_off) {
+			bd71828_dev = i2c;
+			pm_power_off = bd71828_power_off;
+			ret = devm_add_action_or_reset(&i2c->dev,
+						       bd71828_remove_poweroff,
+						       NULL);
+		} else {
+			dev_warn(&i2c->dev, "Poweroff callback already assigned\n");
+		}
+	}
 
 	return ret;
 }
diff --git a/include/linux/mfd/rohm-bd71828.h b/include/linux/mfd/rohm-bd71828.h
index 3b5f3a7db4bd..9776fde1262d 100644
--- a/include/linux/mfd/rohm-bd71828.h
+++ b/include/linux/mfd/rohm-bd71828.h
@@ -4,6 +4,7 @@
 #ifndef __LINUX_MFD_BD71828_H__
 #define __LINUX_MFD_BD71828_H__
 
+#include <linux/bits.h>
 #include <linux/mfd/rohm-generic.h>
 #include <linux/mfd/rohm-shared.h>
 
@@ -41,6 +42,8 @@ enum {
 #define BD71828_REG_PS_CTRL_2		0x05
 #define BD71828_REG_PS_CTRL_3		0x06
 
+#define BD71828_MASK_STATE_HBNT		BIT(1)
+
 //#define BD71828_REG_SWRESET		0x06
 #define BD71828_MASK_RUN_LVL_CTRL	0x30
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 1/2] dt-bindings: mfd: Add ROHM BD71828 system-power-controller property
  2024-04-02 11:16 ` [PATCH v3 1/2] dt-bindings: mfd: Add ROHM BD71828 system-power-controller property Andreas Kemnade
@ 2024-04-02 13:15   ` Matti Vaittinen
  0 siblings, 0 replies; 8+ messages in thread
From: Matti Vaittinen @ 2024-04-02 13:15 UTC (permalink / raw)
  To: Andreas Kemnade, lee, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	devicetree, linux-kernel
  Cc: Krzysztof Kozlowski

On 4/2/24 14:16, Andreas Kemnade wrote:
> As the PMIC can power off the system, add the corresponding property.
> 
> Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

FWIW
Acked-by: Matti Vaittinen <mazziesaccount@gmail.com>

> ---
>   Documentation/devicetree/bindings/mfd/rohm,bd71828-pmic.yaml | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/rohm,bd71828-pmic.yaml b/Documentation/devicetree/bindings/mfd/rohm,bd71828-pmic.yaml
> index 11089aa89ec6..0b62f854bf6b 100644
> --- a/Documentation/devicetree/bindings/mfd/rohm,bd71828-pmic.yaml
> +++ b/Documentation/devicetree/bindings/mfd/rohm,bd71828-pmic.yaml
> @@ -73,6 +73,8 @@ properties:
>         used to mark the pins which should not be configured for GPIO. Please see
>         the ../gpio/gpio.txt for more information.
>   
> +  system-power-controller: true
> +
>   required:
>     - compatible
>     - reg

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/2] mfd: rohm-bd71828: Add power off functionality
  2024-04-02 11:17 ` [PATCH v3 2/2] mfd: rohm-bd71828: Add power off functionality Andreas Kemnade
@ 2024-04-11 11:50   ` Lee Jones
  2024-04-11 12:14     ` Matti Vaittinen
  0 siblings, 1 reply; 8+ messages in thread
From: Lee Jones @ 2024-04-11 11:50 UTC (permalink / raw)
  To: Andreas Kemnade
  Cc: robh+dt, krzysztof.kozlowski+dt, conor+dt, mazziesaccount,
	devicetree, linux-kernel

On Tue, 02 Apr 2024, Andreas Kemnade wrote:

> Since the chip can power off the system, add the corresponding
> functionality.
> Based on https://github.com/kobolabs/Kobo-Reader/raw/master/hw/imx6sll-clara2e/kernel.tar.bz2
> 
> Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> Acked-by: Matti Vaittinen <mazziesaccount@gmail.com>
> ---
>  drivers/mfd/rohm-bd71828.c       | 36 +++++++++++++++++++++++++++++++-
>  include/linux/mfd/rohm-bd71828.h |  3 +++
>  2 files changed, 38 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mfd/rohm-bd71828.c b/drivers/mfd/rohm-bd71828.c
> index 594718f7e8e1..4a1fa8a0d76a 100644
> --- a/drivers/mfd/rohm-bd71828.c
> +++ b/drivers/mfd/rohm-bd71828.c
> @@ -464,6 +464,27 @@ static int set_clk_mode(struct device *dev, struct regmap *regmap,
>  				  OUT32K_MODE_CMOS);
>  }
>  
> +static struct i2c_client *bd71828_dev;
> +static void bd71828_power_off(void)
> +{
> +	while (true) {
> +		s32 val;
> +
> +		/* We are not allowed to sleep, so do not use regmap involving mutexes here. */
> +		val = i2c_smbus_read_byte_data(bd71828_dev, BD71828_REG_PS_CTRL_1);
> +		if (val >= 0)
> +			i2c_smbus_write_byte_data(bd71828_dev,
> +						  BD71828_REG_PS_CTRL_1,
> +						  BD71828_MASK_STATE_HBNT | (u8)val);
> +		mdelay(500);
> +	}
> +}
> +
> +static void bd71828_remove_poweroff(void *data)
> +{
> +	pm_power_off = NULL;
> +}
> +
>  static int bd71828_i2c_probe(struct i2c_client *i2c)
>  {
>  	struct regmap_irq_chip_data *irq_data;
> @@ -542,7 +563,20 @@ static int bd71828_i2c_probe(struct i2c_client *i2c)
>  	ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO, mfd, cells,
>  				   NULL, 0, regmap_irq_get_domain(irq_data));
>  	if (ret)
> -		dev_err_probe(&i2c->dev, ret, "Failed to create subdevices\n");
> +		return	dev_err_probe(&i2c->dev, ret, "Failed to create subdevices\n");
> +
> +	if (of_device_is_system_power_controller(i2c->dev.of_node) &&
> +	    chip_type == ROHM_CHIP_TYPE_BD71828) {
> +		if (!pm_power_off) {
> +			bd71828_dev = i2c;
> +			pm_power_off = bd71828_power_off;
> +			ret = devm_add_action_or_reset(&i2c->dev,
> +						       bd71828_remove_poweroff,
> +						       NULL);
> +		} else {
> +			dev_warn(&i2c->dev, "Poweroff callback already assigned\n");
> +		}
> +	}
>  
>  	return ret;
>  }
> diff --git a/include/linux/mfd/rohm-bd71828.h b/include/linux/mfd/rohm-bd71828.h
> index 3b5f3a7db4bd..9776fde1262d 100644
> --- a/include/linux/mfd/rohm-bd71828.h
> +++ b/include/linux/mfd/rohm-bd71828.h
> @@ -4,6 +4,7 @@
>  #ifndef __LINUX_MFD_BD71828_H__
>  #define __LINUX_MFD_BD71828_H__
>  
> +#include <linux/bits.h>
>  #include <linux/mfd/rohm-generic.h>
>  #include <linux/mfd/rohm-shared.h>
>  
> @@ -41,6 +42,8 @@ enum {
>  #define BD71828_REG_PS_CTRL_2		0x05
>  #define BD71828_REG_PS_CTRL_3		0x06
>  
> +#define BD71828_MASK_STATE_HBNT		BIT(1)
> +
>  //#define BD71828_REG_SWRESET		0x06

How did this get in here?

>  #define BD71828_MASK_RUN_LVL_CTRL	0x30
>  
> -- 
> 2.39.2
> 

-- 
Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 0/2] mfd: rohm-bd71828: Add power off
  2024-04-02 11:16 [PATCH v3 0/2] mfd: rohm-bd71828: Add power off Andreas Kemnade
  2024-04-02 11:16 ` [PATCH v3 1/2] dt-bindings: mfd: Add ROHM BD71828 system-power-controller property Andreas Kemnade
  2024-04-02 11:17 ` [PATCH v3 2/2] mfd: rohm-bd71828: Add power off functionality Andreas Kemnade
@ 2024-04-11 11:51 ` Lee Jones
  2 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2024-04-11 11:51 UTC (permalink / raw)
  To: lee, robh+dt, krzysztof.kozlowski+dt, conor+dt, mazziesaccount,
	devicetree, linux-kernel, Andreas Kemnade

On Tue, 02 Apr 2024 13:16:58 +0200, Andreas Kemnade wrote:
> Add power off functionality. Marked as RFC because of magic numbers
> without a good source and strange delays. The only information source is
> a vendor kernel.
> 
> Changes in v3:
> - define for poweroff bit
> - rmw operation to set only that bit
> 
> [...]

Applied, thanks!

[1/2] dt-bindings: mfd: Add ROHM BD71828 system-power-controller property
      commit: 6ed9be0f9a1481280429d24c60b7d20f3706e4dc
[2/2] mfd: rohm-bd71828: Add power off functionality
      commit: d7ff3cc4d9cdc5880541bb2e04b1fa40307029f6

--
Lee Jones [李琼斯]


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/2] mfd: rohm-bd71828: Add power off functionality
  2024-04-11 11:50   ` Lee Jones
@ 2024-04-11 12:14     ` Matti Vaittinen
  2024-04-11 14:07       ` Lee Jones
  0 siblings, 1 reply; 8+ messages in thread
From: Matti Vaittinen @ 2024-04-11 12:14 UTC (permalink / raw)
  To: Lee Jones, Andreas Kemnade
  Cc: robh+dt, krzysztof.kozlowski+dt, conor+dt, devicetree,
	linux-kernel

On 4/11/24 14:50, Lee Jones wrote:
> On Tue, 02 Apr 2024, Andreas Kemnade wrote:
> 
>> Since the chip can power off the system, add the corresponding
>> functionality.
>> Based on https://github.com/kobolabs/Kobo-Reader/raw/master/hw/imx6sll-clara2e/kernel.tar.bz2
>>
>> Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
>> Acked-by: Matti Vaittinen <mazziesaccount@gmail.com>
>> ---
>>   drivers/mfd/rohm-bd71828.c       | 36 +++++++++++++++++++++++++++++++-
>>   include/linux/mfd/rohm-bd71828.h |  3 +++
>>   2 files changed, 38 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mfd/rohm-bd71828.c b/drivers/mfd/rohm-bd71828.c
>> index 594718f7e8e1..4a1fa8a0d76a 100644
>> --- a/drivers/mfd/rohm-bd71828.c
>> +++ b/drivers/mfd/rohm-bd71828.c
>> @@ -464,6 +464,27 @@ static int set_clk_mode(struct device *dev, struct regmap *regmap,
>>   				  OUT32K_MODE_CMOS);
>>   }
>>   
>> +static struct i2c_client *bd71828_dev;
>> +static void bd71828_power_off(void)
>> +{
>> +	while (true) {
>> +		s32 val;
>> +
>> +		/* We are not allowed to sleep, so do not use regmap involving mutexes here. */
>> +		val = i2c_smbus_read_byte_data(bd71828_dev, BD71828_REG_PS_CTRL_1);
>> +		if (val >= 0)
>> +			i2c_smbus_write_byte_data(bd71828_dev,
>> +						  BD71828_REG_PS_CTRL_1,
>> +						  BD71828_MASK_STATE_HBNT | (u8)val);
>> +		mdelay(500);
>> +	}
>> +}
>> +
>> +static void bd71828_remove_poweroff(void *data)
>> +{
>> +	pm_power_off = NULL;
>> +}
>> +
>>   static int bd71828_i2c_probe(struct i2c_client *i2c)
>>   {
>>   	struct regmap_irq_chip_data *irq_data;
>> @@ -542,7 +563,20 @@ static int bd71828_i2c_probe(struct i2c_client *i2c)
>>   	ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO, mfd, cells,
>>   				   NULL, 0, regmap_irq_get_domain(irq_data));
>>   	if (ret)
>> -		dev_err_probe(&i2c->dev, ret, "Failed to create subdevices\n");
>> +		return	dev_err_probe(&i2c->dev, ret, "Failed to create subdevices\n");
>> +
>> +	if (of_device_is_system_power_controller(i2c->dev.of_node) &&
>> +	    chip_type == ROHM_CHIP_TYPE_BD71828) {
>> +		if (!pm_power_off) {
>> +			bd71828_dev = i2c;
>> +			pm_power_off = bd71828_power_off;
>> +			ret = devm_add_action_or_reset(&i2c->dev,
>> +						       bd71828_remove_poweroff,
>> +						       NULL);
>> +		} else {
>> +			dev_warn(&i2c->dev, "Poweroff callback already assigned\n");
>> +		}
>> +	}
>>   
>>   	return ret;
>>   }
>> diff --git a/include/linux/mfd/rohm-bd71828.h b/include/linux/mfd/rohm-bd71828.h
>> index 3b5f3a7db4bd..9776fde1262d 100644
>> --- a/include/linux/mfd/rohm-bd71828.h
>> +++ b/include/linux/mfd/rohm-bd71828.h
>> @@ -4,6 +4,7 @@
>>   #ifndef __LINUX_MFD_BD71828_H__
>>   #define __LINUX_MFD_BD71828_H__
>>   
>> +#include <linux/bits.h>
>>   #include <linux/mfd/rohm-generic.h>
>>   #include <linux/mfd/rohm-shared.h>
>>   
>> @@ -41,6 +42,8 @@ enum {
>>   #define BD71828_REG_PS_CTRL_2		0x05
>>   #define BD71828_REG_PS_CTRL_3		0x06
>>   
>> +#define BD71828_MASK_STATE_HBNT		BIT(1)
>> +
>>   //#define BD71828_REG_SWRESET		0x06
> 
> How did this get in here?

Don't blame me, blame git... Errm... :)
[mvaittin@fedora linux]$ git blame include/linux/mfd/rohm-bd71828.h 
|grep \/\/
1c743ad523bb2 (Matti Vaittinen 2020-01-20 15:43:28 +0200  44) //#define 
BD71828_REG_SWRESET		0x06
1c743ad523bb2 (Matti Vaittinen 2020-01-20 15:43:28 +0200 136) //#define 
BD71828_REG_LDO6_VOLT		0x4

I can send a clean-up patch unless you want to do it while applying 
other stuff...

Yours,
	Matti

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/2] mfd: rohm-bd71828: Add power off functionality
  2024-04-11 12:14     ` Matti Vaittinen
@ 2024-04-11 14:07       ` Lee Jones
  0 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2024-04-11 14:07 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: Andreas Kemnade, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	devicetree, linux-kernel

On Thu, 11 Apr 2024, Matti Vaittinen wrote:

> On 4/11/24 14:50, Lee Jones wrote:
> > On Tue, 02 Apr 2024, Andreas Kemnade wrote:
> > 
> > > Since the chip can power off the system, add the corresponding
> > > functionality.
> > > Based on https://github.com/kobolabs/Kobo-Reader/raw/master/hw/imx6sll-clara2e/kernel.tar.bz2
> > > 
> > > Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> > > Acked-by: Matti Vaittinen <mazziesaccount@gmail.com>
> > > ---
> > >   drivers/mfd/rohm-bd71828.c       | 36 +++++++++++++++++++++++++++++++-
> > >   include/linux/mfd/rohm-bd71828.h |  3 +++
> > >   2 files changed, 38 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/mfd/rohm-bd71828.c b/drivers/mfd/rohm-bd71828.c
> > > index 594718f7e8e1..4a1fa8a0d76a 100644
> > > --- a/drivers/mfd/rohm-bd71828.c
> > > +++ b/drivers/mfd/rohm-bd71828.c
> > > @@ -464,6 +464,27 @@ static int set_clk_mode(struct device *dev, struct regmap *regmap,
> > >   				  OUT32K_MODE_CMOS);
> > >   }
> > > +static struct i2c_client *bd71828_dev;
> > > +static void bd71828_power_off(void)
> > > +{
> > > +	while (true) {
> > > +		s32 val;
> > > +
> > > +		/* We are not allowed to sleep, so do not use regmap involving mutexes here. */
> > > +		val = i2c_smbus_read_byte_data(bd71828_dev, BD71828_REG_PS_CTRL_1);
> > > +		if (val >= 0)
> > > +			i2c_smbus_write_byte_data(bd71828_dev,
> > > +						  BD71828_REG_PS_CTRL_1,
> > > +						  BD71828_MASK_STATE_HBNT | (u8)val);
> > > +		mdelay(500);
> > > +	}
> > > +}
> > > +
> > > +static void bd71828_remove_poweroff(void *data)
> > > +{
> > > +	pm_power_off = NULL;
> > > +}
> > > +
> > >   static int bd71828_i2c_probe(struct i2c_client *i2c)
> > >   {
> > >   	struct regmap_irq_chip_data *irq_data;
> > > @@ -542,7 +563,20 @@ static int bd71828_i2c_probe(struct i2c_client *i2c)
> > >   	ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO, mfd, cells,
> > >   				   NULL, 0, regmap_irq_get_domain(irq_data));
> > >   	if (ret)
> > > -		dev_err_probe(&i2c->dev, ret, "Failed to create subdevices\n");
> > > +		return	dev_err_probe(&i2c->dev, ret, "Failed to create subdevices\n");
> > > +
> > > +	if (of_device_is_system_power_controller(i2c->dev.of_node) &&
> > > +	    chip_type == ROHM_CHIP_TYPE_BD71828) {
> > > +		if (!pm_power_off) {
> > > +			bd71828_dev = i2c;
> > > +			pm_power_off = bd71828_power_off;
> > > +			ret = devm_add_action_or_reset(&i2c->dev,
> > > +						       bd71828_remove_poweroff,
> > > +						       NULL);
> > > +		} else {
> > > +			dev_warn(&i2c->dev, "Poweroff callback already assigned\n");
> > > +		}
> > > +	}
> > >   	return ret;
> > >   }
> > > diff --git a/include/linux/mfd/rohm-bd71828.h b/include/linux/mfd/rohm-bd71828.h
> > > index 3b5f3a7db4bd..9776fde1262d 100644
> > > --- a/include/linux/mfd/rohm-bd71828.h
> > > +++ b/include/linux/mfd/rohm-bd71828.h
> > > @@ -4,6 +4,7 @@
> > >   #ifndef __LINUX_MFD_BD71828_H__
> > >   #define __LINUX_MFD_BD71828_H__
> > > +#include <linux/bits.h>
> > >   #include <linux/mfd/rohm-generic.h>
> > >   #include <linux/mfd/rohm-shared.h>
> > > @@ -41,6 +42,8 @@ enum {
> > >   #define BD71828_REG_PS_CTRL_2		0x05
> > >   #define BD71828_REG_PS_CTRL_3		0x06
> > > +#define BD71828_MASK_STATE_HBNT		BIT(1)
> > > +
> > >   //#define BD71828_REG_SWRESET		0x06
> > 
> > How did this get in here?
> 
> Don't blame me, blame git... Errm... :)
> [mvaittin@fedora linux]$ git blame include/linux/mfd/rohm-bd71828.h |grep
> \/\/
> 1c743ad523bb2 (Matti Vaittinen 2020-01-20 15:43:28 +0200  44) //#define
> BD71828_REG_SWRESET		0x06
> 1c743ad523bb2 (Matti Vaittinen 2020-01-20 15:43:28 +0200 136) //#define
> BD71828_REG_LDO6_VOLT		0x4
> 
> I can send a clean-up patch unless you want to do it while applying other
> stuff...

Please submit a patch.

-- 
Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-04-11 14:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-02 11:16 [PATCH v3 0/2] mfd: rohm-bd71828: Add power off Andreas Kemnade
2024-04-02 11:16 ` [PATCH v3 1/2] dt-bindings: mfd: Add ROHM BD71828 system-power-controller property Andreas Kemnade
2024-04-02 13:15   ` Matti Vaittinen
2024-04-02 11:17 ` [PATCH v3 2/2] mfd: rohm-bd71828: Add power off functionality Andreas Kemnade
2024-04-11 11:50   ` Lee Jones
2024-04-11 12:14     ` Matti Vaittinen
2024-04-11 14:07       ` Lee Jones
2024-04-11 11:51 ` [PATCH v3 0/2] mfd: rohm-bd71828: Add power off Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).