linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] charger-supply for max8997_charger
@ 2021-01-30 17:28 Timon Baetz
  2021-01-30 17:29 ` [PATCH 1/3] regulator: dt-bindings: Document charger-supply for max8997 Timon Baetz
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Timon Baetz @ 2021-01-30 17:28 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Krzysztof Kozlowski, Rob Herring,
	Sebastian Reichel
  Cc: devicetree, linux-samsung-soc, linux-pm, Timon Baetz,
	linux-kernel, linux-arm-kernel

Based on the discussion from [0] add an optional DT property to retrieve
the regulator used for charging control in the max8997_charger driver.

[0] https://lore.kernel.org/lkml/20210118124505.GG4455@sirena.org.uk/


Timon Baetz (3):
  regulator: dt-bindings: Document charger-supply for max8997
  ARM: dts: exynos: Add charger supply for I9100
  power: supply: max8997_charger: Switch to new binding

 .../bindings/regulator/max8997-regulator.txt         |  1 +
 arch/arm/boot/dts/exynos4210-i9100.dts               |  2 ++
 drivers/power/supply/max8997_charger.c               | 12 ++++++++----
 3 files changed, 11 insertions(+), 4 deletions(-)

-- 
2.25.1



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 1/3] regulator: dt-bindings: Document charger-supply for max8997
  2021-01-30 17:28 [PATCH 0/3] charger-supply for max8997_charger Timon Baetz
@ 2021-01-30 17:29 ` Timon Baetz
  2021-01-31 16:46   ` Krzysztof Kozlowski
  2021-01-30 17:29 ` [PATCH 2/3] ARM: dts: exynos: Add charger supply for I9100 Timon Baetz
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 14+ messages in thread
From: Timon Baetz @ 2021-01-30 17:29 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Krzysztof Kozlowski, Rob Herring,
	Sebastian Reichel
  Cc: devicetree, linux-samsung-soc, linux-pm, Timon Baetz,
	linux-kernel, linux-arm-kernel

Add charger-supply optional property to enable charging control.

Signed-off-by: Timon Baetz <timon.baetz@protonmail.com>
---
 .../devicetree/bindings/regulator/max8997-regulator.txt          | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/regulator/max8997-regulator.txt b/Documentation/devicetree/bindings/regulator/max8997-regulator.txt
index 6fe825b8ac1b..b53c5e2b335f 100644
--- a/Documentation/devicetree/bindings/regulator/max8997-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/max8997-regulator.txt
@@ -35,6 +35,7 @@ Optional properties:
 - interrupts: Interrupt specifiers for two interrupt sources.
   - First interrupt specifier is for 'irq1' interrupt.
   - Second interrupt specifier is for 'alert' interrupt.
+- charger-supply: regulator node for charging current.
 - max8997,pmic-buck1-uses-gpio-dvs: 'buck1' can be controlled by gpio dvs.
 - max8997,pmic-buck2-uses-gpio-dvs: 'buck2' can be controlled by gpio dvs.
 - max8997,pmic-buck5-uses-gpio-dvs: 'buck5' can be controlled by gpio dvs.
-- 
2.25.1



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/3] ARM: dts: exynos: Add charger supply for I9100
  2021-01-30 17:28 [PATCH 0/3] charger-supply for max8997_charger Timon Baetz
  2021-01-30 17:29 ` [PATCH 1/3] regulator: dt-bindings: Document charger-supply for max8997 Timon Baetz
@ 2021-01-30 17:29 ` Timon Baetz
  2021-02-11  5:59   ` Timon Baetz
  2021-03-02  8:52   ` Krzysztof Kozlowski
  2021-01-30 17:30 ` [PATCH 3/3] power: supply: max8997_charger: Switch to new binding Timon Baetz
  2021-02-03 21:07 ` (subset) [PATCH 0/3] charger-supply for max8997_charger Mark Brown
  3 siblings, 2 replies; 14+ messages in thread
From: Timon Baetz @ 2021-01-30 17:29 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Krzysztof Kozlowski, Rob Herring,
	Sebastian Reichel
  Cc: devicetree, linux-samsung-soc, linux-pm, Timon Baetz,
	linux-kernel, linux-arm-kernel

The regulator is used for charging control by max8997_charger driver.

Signed-off-by: Timon Baetz <timon.baetz@protonmail.com>
---
 arch/arm/boot/dts/exynos4210-i9100.dts | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4210-i9100.dts b/arch/arm/boot/dts/exynos4210-i9100.dts
index 304a8ee2364c..dad950daafb4 100644
--- a/arch/arm/boot/dts/exynos4210-i9100.dts
+++ b/arch/arm/boot/dts/exynos4210-i9100.dts
@@ -384,6 +384,8 @@ pmic@66 {
 		pinctrl-0 = <&max8997_irq>, <&otg_gp>, <&usb_sel>;
 		pinctrl-names = "default";
 
+		charger-supply = <&charger_reg>;
+
 		regulators {
 			vadc_reg: LDO1 {
 				regulator-name = "VADC_3.3V_C210";
-- 
2.25.1



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 3/3] power: supply: max8997_charger: Switch to new binding
  2021-01-30 17:28 [PATCH 0/3] charger-supply for max8997_charger Timon Baetz
  2021-01-30 17:29 ` [PATCH 1/3] regulator: dt-bindings: Document charger-supply for max8997 Timon Baetz
  2021-01-30 17:29 ` [PATCH 2/3] ARM: dts: exynos: Add charger supply for I9100 Timon Baetz
@ 2021-01-30 17:30 ` Timon Baetz
  2021-01-31 17:28   ` Krzysztof Kozlowski
  2021-03-26 16:20   ` Timon Baetz
  2021-02-03 21:07 ` (subset) [PATCH 0/3] charger-supply for max8997_charger Mark Brown
  3 siblings, 2 replies; 14+ messages in thread
From: Timon Baetz @ 2021-01-30 17:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Krzysztof Kozlowski, Rob Herring,
	Sebastian Reichel
  Cc: devicetree, linux-samsung-soc, linux-pm, Timon Baetz,
	linux-kernel, linux-arm-kernel

Get regulator from parent device's node and extcon by name.

Signed-off-by: Timon Baetz <timon.baetz@protonmail.com>
---
 drivers/power/supply/max8997_charger.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/power/supply/max8997_charger.c b/drivers/power/supply/max8997_charger.c
index 321bd6b8ee41..625d8cc4312a 100644
--- a/drivers/power/supply/max8997_charger.c
+++ b/drivers/power/supply/max8997_charger.c
@@ -168,6 +168,7 @@ static int max8997_battery_probe(struct platform_device *pdev)
 	int ret = 0;
 	struct charger_data *charger;
 	struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
+	struct device_node *np = pdev->dev.of_node;
 	struct i2c_client *i2c = iodev->i2c;
 	struct max8997_platform_data *pdata = iodev->pdata;
 	struct power_supply_config psy_cfg = {};
@@ -237,20 +238,23 @@ static int max8997_battery_probe(struct platform_device *pdev)
 		return PTR_ERR(charger->battery);
 	}
 
+	// grab regulator from parent device's node
+	pdev->dev.of_node = iodev->dev->of_node;
 	charger->reg = devm_regulator_get_optional(&pdev->dev, "charger");
+	pdev->dev.of_node = np;
 	if (IS_ERR(charger->reg)) {
 		if (PTR_ERR(charger->reg) == -EPROBE_DEFER)
 			return -EPROBE_DEFER;
 		dev_info(&pdev->dev, "couldn't get charger regulator\n");
 	}
-	charger->edev = extcon_get_edev_by_phandle(&pdev->dev, 0);
-	if (IS_ERR(charger->edev)) {
-		if (PTR_ERR(charger->edev) == -EPROBE_DEFER)
+	charger->edev = extcon_get_extcon_dev("max8997-muic");
+	if (IS_ERR_OR_NULL(charger->edev)) {
+		if (!charger->edev)
 			return -EPROBE_DEFER;
 		dev_info(charger->dev, "couldn't get extcon device\n");
 	}
 
-	if (!IS_ERR(charger->reg) && !IS_ERR(charger->edev)) {
+	if (!IS_ERR(charger->reg) && !IS_ERR_OR_NULL(charger->edev)) {
 		INIT_WORK(&charger->extcon_work, max8997_battery_extcon_evt_worker);
 		ret = devm_add_action(&pdev->dev, max8997_battery_extcon_evt_stop_work, charger);
 		if (ret) {
-- 
2.25.1



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/3] regulator: dt-bindings: Document charger-supply for max8997
  2021-01-30 17:29 ` [PATCH 1/3] regulator: dt-bindings: Document charger-supply for max8997 Timon Baetz
@ 2021-01-31 16:46   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 14+ messages in thread
From: Krzysztof Kozlowski @ 2021-01-31 16:46 UTC (permalink / raw)
  To: Timon Baetz
  Cc: devicetree, linux-samsung-soc, linux-pm, linux-kernel,
	Rob Herring, Liam Girdwood, Mark Brown, Sebastian Reichel,
	linux-arm-kernel

On Sat, Jan 30, 2021 at 05:29:17PM +0000, Timon Baetz wrote:
> Add charger-supply optional property to enable charging control.
> 
> Signed-off-by: Timon Baetz <timon.baetz@protonmail.com>
> ---
>  .../devicetree/bindings/regulator/max8997-regulator.txt          | 1 +
>  1 file changed, 1 insertion(+)
> 

Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>

Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 3/3] power: supply: max8997_charger: Switch to new binding
  2021-01-30 17:30 ` [PATCH 3/3] power: supply: max8997_charger: Switch to new binding Timon Baetz
@ 2021-01-31 17:28   ` Krzysztof Kozlowski
  2021-02-01  9:26     ` Timon Baetz
  2021-03-26 16:20   ` Timon Baetz
  1 sibling, 1 reply; 14+ messages in thread
From: Krzysztof Kozlowski @ 2021-01-31 17:28 UTC (permalink / raw)
  To: Timon Baetz
  Cc: devicetree, linux-samsung-soc, linux-pm, linux-kernel,
	Rob Herring, Liam Girdwood, Mark Brown, Sebastian Reichel,
	linux-arm-kernel

On Sat, Jan 30, 2021 at 05:30:14PM +0000, Timon Baetz wrote:
> Get regulator from parent device's node and extcon by name.
> 
> Signed-off-by: Timon Baetz <timon.baetz@protonmail.com>
> ---
>  drivers/power/supply/max8997_charger.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/power/supply/max8997_charger.c b/drivers/power/supply/max8997_charger.c
> index 321bd6b8ee41..625d8cc4312a 100644
> --- a/drivers/power/supply/max8997_charger.c
> +++ b/drivers/power/supply/max8997_charger.c
> @@ -168,6 +168,7 @@ static int max8997_battery_probe(struct platform_device *pdev)
>  	int ret = 0;
>  	struct charger_data *charger;
>  	struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
> +	struct device_node *np = pdev->dev.of_node;
>  	struct i2c_client *i2c = iodev->i2c;
>  	struct max8997_platform_data *pdata = iodev->pdata;
>  	struct power_supply_config psy_cfg = {};
> @@ -237,20 +238,23 @@ static int max8997_battery_probe(struct platform_device *pdev)
>  		return PTR_ERR(charger->battery);
>  	}
>  
> +	// grab regulator from parent device's node
> +	pdev->dev.of_node = iodev->dev->of_node;
>  	charger->reg = devm_regulator_get_optional(&pdev->dev, "charger");
> +	pdev->dev.of_node = np;

I think the device does not have its own node anymore. Or did I miss
something?

>  	if (IS_ERR(charger->reg)) {
>  		if (PTR_ERR(charger->reg) == -EPROBE_DEFER)
>  			return -EPROBE_DEFER;
>  		dev_info(&pdev->dev, "couldn't get charger regulator\n");
>  	}
> -	charger->edev = extcon_get_edev_by_phandle(&pdev->dev, 0);
> -	if (IS_ERR(charger->edev)) {
> -		if (PTR_ERR(charger->edev) == -EPROBE_DEFER)
> +	charger->edev = extcon_get_extcon_dev("max8997-muic");
> +	if (IS_ERR_OR_NULL(charger->edev)) {
> +		if (!charger->edev)

Isn't NULL returned when there is simply no extcon? It's different than
deferred probe. Returning here EPROBE_DEFER might lead to infinite probe
tries (on every new device probe) instead of just failing it.

Best regards,
Krzysztof


>  			return -EPROBE_DEFER;
>  		dev_info(charger->dev, "couldn't get extcon device\n");
>  	}
>  
> -	if (!IS_ERR(charger->reg) && !IS_ERR(charger->edev)) {
> +	if (!IS_ERR(charger->reg) && !IS_ERR_OR_NULL(charger->edev)) {
>  		INIT_WORK(&charger->extcon_work, max8997_battery_extcon_evt_worker);
>  		ret = devm_add_action(&pdev->dev, max8997_battery_extcon_evt_stop_work, charger);
>  		if (ret) {
> -- 
> 2.25.1
> 
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 3/3] power: supply: max8997_charger: Switch to new binding
  2021-01-31 17:28   ` Krzysztof Kozlowski
@ 2021-02-01  9:26     ` Timon Baetz
  2021-02-01 18:03       ` Krzysztof Kozlowski
  0 siblings, 1 reply; 14+ messages in thread
From: Timon Baetz @ 2021-02-01  9:26 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: devicetree, linux-samsung-soc, linux-pm, linux-kernel,
	Rob Herring, Liam Girdwood, Mark Brown, Sebastian Reichel,
	linux-arm-kernel

On Sun, 31 Jan 2021 18:28:40 +0100, Krzysztof Kozlowski wrote:
> On Sat, Jan 30, 2021 at 05:30:14PM +0000, Timon Baetz wrote:
> > Get regulator from parent device's node and extcon by name.
> >
> > Signed-off-by: Timon Baetz <timon.baetz@protonmail.com>
> > ---
> >  drivers/power/supply/max8997_charger.c | 12 ++++++++----
> >  1 file changed, 8 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/power/supply/max8997_charger.c b/drivers/power/supply/max8997_charger.c
> > index 321bd6b8ee41..625d8cc4312a 100644
> > --- a/drivers/power/supply/max8997_charger.c
> > +++ b/drivers/power/supply/max8997_charger.c
> > @@ -168,6 +168,7 @@ static int max8997_battery_probe(struct platform_device *pdev)
> >  	int ret = 0;
> >  	struct charger_data *charger;
> >  	struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
> > +	struct device_node *np = pdev->dev.of_node;
> >  	struct i2c_client *i2c = iodev->i2c;
> >  	struct max8997_platform_data *pdata = iodev->pdata;
> >  	struct power_supply_config psy_cfg = {};
> > @@ -237,20 +238,23 @@ static int max8997_battery_probe(struct platform_device *pdev)
> >  		return PTR_ERR(charger->battery);
> >  	}
> >
> > +	// grab regulator from parent device's node
> > +	pdev->dev.of_node = iodev->dev->of_node;
> >  	charger->reg = devm_regulator_get_optional(&pdev->dev, "charger");
> > +	pdev->dev.of_node = np;  
> 
> I think the device does not have its own node anymore. Or did I miss
> something?

The idea is to reset of_node to whatever it was before (NULL) and basically 
leave the device unchanged. Probe might run again because of deferral.

> >  	if (IS_ERR(charger->reg)) {
> >  		if (PTR_ERR(charger->reg) == -EPROBE_DEFER)
> >  			return -EPROBE_DEFER;
> >  		dev_info(&pdev->dev, "couldn't get charger regulator\n");
> >  	}
> > -	charger->edev = extcon_get_edev_by_phandle(&pdev->dev, 0);
> > -	if (IS_ERR(charger->edev)) {
> > -		if (PTR_ERR(charger->edev) == -EPROBE_DEFER)
> > +	charger->edev = extcon_get_extcon_dev("max8997-muic");
> > +	if (IS_ERR_OR_NULL(charger->edev)) {
> > +		if (!charger->edev)  
> 
> Isn't NULL returned when there is simply no extcon? It's different than
> deferred probe. Returning here EPROBE_DEFER might lead to infinite probe
> tries (on every new device probe) instead of just failing it.

extcon_get_extcon_dev() just loops through all registered extcon devices
and compared names. It will return NULL when "max8997-muic" isn't
registered yet. extcon_get_extcon_dev() never returns EPROBE_DEFER so
checking for NULL seems to be the only way. Other drivers using that
function also do NULL check and return EPROBE_DEFER.

Thanks for reviewing,
Timon


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 3/3] power: supply: max8997_charger: Switch to new binding
  2021-02-01  9:26     ` Timon Baetz
@ 2021-02-01 18:03       ` Krzysztof Kozlowski
  2021-03-09  7:47         ` Timon Baetz
  0 siblings, 1 reply; 14+ messages in thread
From: Krzysztof Kozlowski @ 2021-02-01 18:03 UTC (permalink / raw)
  To: Timon Baetz
  Cc: devicetree, linux-samsung-soc, linux-pm, linux-kernel,
	Rob Herring, Liam Girdwood, Mark Brown, Sebastian Reichel,
	linux-arm-kernel

On Mon, Feb 01, 2021 at 09:26:42AM +0000, Timon Baetz wrote:
> On Sun, 31 Jan 2021 18:28:40 +0100, Krzysztof Kozlowski wrote:
> > On Sat, Jan 30, 2021 at 05:30:14PM +0000, Timon Baetz wrote:
> > > Get regulator from parent device's node and extcon by name.
> > >
> > > Signed-off-by: Timon Baetz <timon.baetz@protonmail.com>
> > > ---
> > >  drivers/power/supply/max8997_charger.c | 12 ++++++++----
> > >  1 file changed, 8 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/power/supply/max8997_charger.c b/drivers/power/supply/max8997_charger.c
> > > index 321bd6b8ee41..625d8cc4312a 100644
> > > --- a/drivers/power/supply/max8997_charger.c
> > > +++ b/drivers/power/supply/max8997_charger.c
> > > @@ -168,6 +168,7 @@ static int max8997_battery_probe(struct platform_device *pdev)
> > >  	int ret = 0;
> > >  	struct charger_data *charger;
> > >  	struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
> > > +	struct device_node *np = pdev->dev.of_node;
> > >  	struct i2c_client *i2c = iodev->i2c;
> > >  	struct max8997_platform_data *pdata = iodev->pdata;
> > >  	struct power_supply_config psy_cfg = {};
> > > @@ -237,20 +238,23 @@ static int max8997_battery_probe(struct platform_device *pdev)
> > >  		return PTR_ERR(charger->battery);
> > >  	}
> > >
> > > +	// grab regulator from parent device's node
> > > +	pdev->dev.of_node = iodev->dev->of_node;
> > >  	charger->reg = devm_regulator_get_optional(&pdev->dev, "charger");
> > > +	pdev->dev.of_node = np;  
> > 
> > I think the device does not have its own node anymore. Or did I miss
> > something?
> 
> The idea is to reset of_node to whatever it was before (NULL) and basically 
> leave the device unchanged. Probe might run again because of deferral.

Good point.

> 
> > >  	if (IS_ERR(charger->reg)) {
> > >  		if (PTR_ERR(charger->reg) == -EPROBE_DEFER)
> > >  			return -EPROBE_DEFER;
> > >  		dev_info(&pdev->dev, "couldn't get charger regulator\n");
> > >  	}
> > > -	charger->edev = extcon_get_edev_by_phandle(&pdev->dev, 0);
> > > -	if (IS_ERR(charger->edev)) {
> > > -		if (PTR_ERR(charger->edev) == -EPROBE_DEFER)
> > > +	charger->edev = extcon_get_extcon_dev("max8997-muic");
> > > +	if (IS_ERR_OR_NULL(charger->edev)) {
> > > +		if (!charger->edev)  
> > 
> > Isn't NULL returned when there is simply no extcon? It's different than
> > deferred probe. Returning here EPROBE_DEFER might lead to infinite probe
> > tries (on every new device probe) instead of just failing it.
> 
> extcon_get_extcon_dev() just loops through all registered extcon devices
> and compared names. It will return NULL when "max8997-muic" isn't
> registered yet. extcon_get_extcon_dev() never returns EPROBE_DEFER so
> checking for NULL seems to be the only way. Other drivers using that
> function also do NULL check and return EPROBE_DEFER.

Indeed, thanks for clarification. Looks good:

Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>

Best regards,
Krzysztof


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: (subset) [PATCH 0/3] charger-supply for max8997_charger
  2021-01-30 17:28 [PATCH 0/3] charger-supply for max8997_charger Timon Baetz
                   ` (2 preceding siblings ...)
  2021-01-30 17:30 ` [PATCH 3/3] power: supply: max8997_charger: Switch to new binding Timon Baetz
@ 2021-02-03 21:07 ` Mark Brown
  3 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2021-02-03 21:07 UTC (permalink / raw)
  To: Sebastian Reichel, Liam Girdwood, Rob Herring, Timon Baetz,
	Krzysztof Kozlowski
  Cc: devicetree, linux-samsung-soc, linux-kernel, linux-arm-kernel, linux-pm

On Sat, 30 Jan 2021 17:28:49 +0000, Timon Baetz wrote:
> Based on the discussion from [0] add an optional DT property to retrieve
> the regulator used for charging control in the max8997_charger driver.
> 
> [0] https://lore.kernel.org/lkml/20210118124505.GG4455@sirena.org.uk/
> 
> 
> Timon Baetz (3):
>   regulator: dt-bindings: Document charger-supply for max8997
>   ARM: dts: exynos: Add charger supply for I9100
>   power: supply: max8997_charger: Switch to new binding
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/3] regulator: dt-bindings: Document charger-supply for max8997
      commit: 41a8a027f4d3f81d83b8942ef29f84223ca35ffc

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/3] ARM: dts: exynos: Add charger supply for I9100
  2021-01-30 17:29 ` [PATCH 2/3] ARM: dts: exynos: Add charger supply for I9100 Timon Baetz
@ 2021-02-11  5:59   ` Timon Baetz
  2021-02-11  7:39     ` Krzysztof Kozlowski
  2021-03-02  8:52   ` Krzysztof Kozlowski
  1 sibling, 1 reply; 14+ messages in thread
From: Timon Baetz @ 2021-02-11  5:59 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Krzysztof Kozlowski, Rob Herring,
	Sebastian Reichel
  Cc: devicetree, linux-samsung-soc, linux-pm, Timon Baetz,
	linux-kernel, linux-arm-kernel

On Sat, 30 Jan 2021 17:29:31 +0000, Timon Baetz wrote:
> The regulator is used for charging control by max8997_charger driver.
> 
> Signed-off-by: Timon Baetz <timon.baetz@protonmail.com>
> ---
>  arch/arm/boot/dts/exynos4210-i9100.dts | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/exynos4210-i9100.dts b/arch/arm/boot/dts/exynos4210-i9100.dts
> index 304a8ee2364c..dad950daafb4 100644
> --- a/arch/arm/boot/dts/exynos4210-i9100.dts
> +++ b/arch/arm/boot/dts/exynos4210-i9100.dts
> @@ -384,6 +384,8 @@ pmic@66 {
>  		pinctrl-0 = <&max8997_irq>, <&otg_gp>, <&usb_sel>;
>  		pinctrl-names = "default";
>  
> +		charger-supply = <&charger_reg>;
> +
>  		regulators {
>  			vadc_reg: LDO1 {
>  				regulator-name = "VADC_3.3V_C210";

Now that the bindings have been accepted and integrated into linux-next,
is anything else blocking this?

Thanks,
Timon


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/3] ARM: dts: exynos: Add charger supply for I9100
  2021-02-11  5:59   ` Timon Baetz
@ 2021-02-11  7:39     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 14+ messages in thread
From: Krzysztof Kozlowski @ 2021-02-11  7:39 UTC (permalink / raw)
  To: Timon Baetz
  Cc: devicetree, linux-samsung-soc, linux-pm, linux-kernel,
	Rob Herring, Liam Girdwood, Mark Brown, Sebastian Reichel,
	linux-arm-kernel

On Thu, Feb 11, 2021 at 05:59:04AM +0000, Timon Baetz wrote:
> On Sat, 30 Jan 2021 17:29:31 +0000, Timon Baetz wrote:
> > The regulator is used for charging control by max8997_charger driver.
> > 
> > Signed-off-by: Timon Baetz <timon.baetz@protonmail.com>
> > ---
> >  arch/arm/boot/dts/exynos4210-i9100.dts | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/arch/arm/boot/dts/exynos4210-i9100.dts b/arch/arm/boot/dts/exynos4210-i9100.dts
> > index 304a8ee2364c..dad950daafb4 100644
> > --- a/arch/arm/boot/dts/exynos4210-i9100.dts
> > +++ b/arch/arm/boot/dts/exynos4210-i9100.dts
> > @@ -384,6 +384,8 @@ pmic@66 {
> >  		pinctrl-0 = <&max8997_irq>, <&otg_gp>, <&usb_sel>;
> >  		pinctrl-names = "default";
> >  
> > +		charger-supply = <&charger_reg>;
> > +
> >  		regulators {
> >  			vadc_reg: LDO1 {
> >  				regulator-name = "VADC_3.3V_C210";
> 
> Now that the bindings have been accepted and integrated into linux-next,
> is anything else blocking this?

No, patch is fine. It's just too late in the cycle, so I'll take the
patch after merge window.

Best regards,
Krzysztof


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/3] ARM: dts: exynos: Add charger supply for I9100
  2021-01-30 17:29 ` [PATCH 2/3] ARM: dts: exynos: Add charger supply for I9100 Timon Baetz
  2021-02-11  5:59   ` Timon Baetz
@ 2021-03-02  8:52   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 14+ messages in thread
From: Krzysztof Kozlowski @ 2021-03-02  8:52 UTC (permalink / raw)
  To: Timon Baetz
  Cc: devicetree, linux-samsung-soc, linux-pm, linux-kernel,
	Rob Herring, Liam Girdwood, Mark Brown, Sebastian Reichel,
	linux-arm-kernel

On Sat, Jan 30, 2021 at 05:29:31PM +0000, Timon Baetz wrote:
> The regulator is used for charging control by max8997_charger driver.
> 
> Signed-off-by: Timon Baetz <timon.baetz@protonmail.com>
> ---
>  arch/arm/boot/dts/exynos4210-i9100.dts | 2 ++
>  1 file changed, 2 insertions(+)

Thanks, applied.

Best regards,
Krzysztof


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 3/3] power: supply: max8997_charger: Switch to new binding
  2021-02-01 18:03       ` Krzysztof Kozlowski
@ 2021-03-09  7:47         ` Timon Baetz
  0 siblings, 0 replies; 14+ messages in thread
From: Timon Baetz @ 2021-03-09  7:47 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Liam Girdwood, Mark Brown, Rob Herring, Sebastian Reichel,
	linux-kernel, devicetree, linux-arm-kernel, linux-samsung-soc,
	linux-pm

On Mon, 1 Feb 2021 19:03:35 +0100, Krzysztof Kozlowski wrote:
> On Mon, Feb 01, 2021 at 09:26:42AM +0000, Timon Baetz wrote:
> > On Sun, 31 Jan 2021 18:28:40 +0100, Krzysztof Kozlowski wrote:
> > > On Sat, Jan 30, 2021 at 05:30:14PM +0000, Timon Baetz wrote:
> > > > Get regulator from parent device's node and extcon by name.
> > > >
> > > > Signed-off-by: Timon Baetz <timon.baetz@protonmail.com>
> > > > ---
> > > >  drivers/power/supply/max8997_charger.c | 12 ++++++++----
> > > >  1 file changed, 8 insertions(+), 4 deletions(-)
> > > >
> > > > diff --git a/drivers/power/supply/max8997_charger.c b/drivers/power/supply/max8997_charger.c
> > > > index 321bd6b8ee41..625d8cc4312a 100644
> > > > --- a/drivers/power/supply/max8997_charger.c
> > > > +++ b/drivers/power/supply/max8997_charger.c
> > > > @@ -168,6 +168,7 @@ static int max8997_battery_probe(struct platform_device *pdev)
> > > >  	int ret = 0;
> > > >  	struct charger_data *charger;
> > > >  	struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
> > > > +	struct device_node *np = pdev->dev.of_node;
> > > >  	struct i2c_client *i2c = iodev->i2c;
> > > >  	struct max8997_platform_data *pdata = iodev->pdata;
> > > >  	struct power_supply_config psy_cfg = {};
> > > > @@ -237,20 +238,23 @@ static int max8997_battery_probe(struct platform_device *pdev)
> > > >  		return PTR_ERR(charger->battery);
> > > >  	}
> > > >
> > > > +	// grab regulator from parent device's node
> > > > +	pdev->dev.of_node = iodev->dev->of_node;
> > > >  	charger->reg = devm_regulator_get_optional(&pdev->dev, "charger");
> > > > +	pdev->dev.of_node = np;
> > >
> > > I think the device does not have its own node anymore. Or did I miss
> > > something?
> >
> > The idea is to reset of_node to whatever it was before (NULL) and basically
> > leave the device unchanged. Probe might run again because of deferral.
>
> Good point.
>
> >
> > > >  	if (IS_ERR(charger->reg)) {
> > > >  		if (PTR_ERR(charger->reg) == -EPROBE_DEFER)
> > > >  			return -EPROBE_DEFER;
> > > >  		dev_info(&pdev->dev, "couldn't get charger regulator\n");
> > > >  	}
> > > > -	charger->edev = extcon_get_edev_by_phandle(&pdev->dev, 0);
> > > > -	if (IS_ERR(charger->edev)) {
> > > > -		if (PTR_ERR(charger->edev) == -EPROBE_DEFER)
> > > > +	charger->edev = extcon_get_extcon_dev("max8997-muic");
> > > > +	if (IS_ERR_OR_NULL(charger->edev)) {
> > > > +		if (!charger->edev)
> > >
> > > Isn't NULL returned when there is simply no extcon? It's different than
> > > deferred probe. Returning here EPROBE_DEFER might lead to infinite probe
> > > tries (on every new device probe) instead of just failing it.
> >
> > extcon_get_extcon_dev() just loops through all registered extcon devices
> > and compared names. It will return NULL when "max8997-muic" isn't
> > registered yet. extcon_get_extcon_dev() never returns EPROBE_DEFER so
> > checking for NULL seems to be the only way. Other drivers using that
> > function also do NULL check and return EPROBE_DEFER.
>
> Indeed, thanks for clarification. Looks good:
>
> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>

Is something blocking this from being accepted?

Timon



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 3/3] power: supply: max8997_charger: Switch to new binding
  2021-01-30 17:30 ` [PATCH 3/3] power: supply: max8997_charger: Switch to new binding Timon Baetz
  2021-01-31 17:28   ` Krzysztof Kozlowski
@ 2021-03-26 16:20   ` Timon Baetz
  1 sibling, 0 replies; 14+ messages in thread
From: Timon Baetz @ 2021-03-26 16:20 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Krzysztof Kozlowski, Rob Herring,
	Sebastian Reichel
  Cc: Timon Baetz, linux-kernel, devicetree, linux-arm-kernel,
	linux-samsung-soc, linux-pm

On Sat, 30 Jan 2021 17:30:14 +0000, Timon Baetz wrote:
> Get regulator from parent device's node and extcon by name.
>
> Signed-off-by: Timon Baetz <timon.baetz@protonmail.com>
> ---
>  drivers/power/supply/max8997_charger.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/power/supply/max8997_charger.c b/drivers/power/supply/max8997_charger.c
> index 321bd6b8ee41..625d8cc4312a 100644
> --- a/drivers/power/supply/max8997_charger.c
> +++ b/drivers/power/supply/max8997_charger.c
> @@ -168,6 +168,7 @@ static int max8997_battery_probe(struct platform_device *pdev)
>  	int ret = 0;
>  	struct charger_data *charger;
>  	struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
> +	struct device_node *np = pdev->dev.of_node;
>  	struct i2c_client *i2c = iodev->i2c;
>  	struct max8997_platform_data *pdata = iodev->pdata;
>  	struct power_supply_config psy_cfg = {};
> @@ -237,20 +238,23 @@ static int max8997_battery_probe(struct platform_device *pdev)
>  		return PTR_ERR(charger->battery);
>  	}
>
> +	// grab regulator from parent device's node
> +	pdev->dev.of_node = iodev->dev->of_node;
>  	charger->reg = devm_regulator_get_optional(&pdev->dev, "charger");
> +	pdev->dev.of_node = np;
>  	if (IS_ERR(charger->reg)) {
>  		if (PTR_ERR(charger->reg) == -EPROBE_DEFER)
>  			return -EPROBE_DEFER;
>  		dev_info(&pdev->dev, "couldn't get charger regulator\n");
>  	}
> -	charger->edev = extcon_get_edev_by_phandle(&pdev->dev, 0);
> -	if (IS_ERR(charger->edev)) {
> -		if (PTR_ERR(charger->edev) == -EPROBE_DEFER)
> +	charger->edev = extcon_get_extcon_dev("max8997-muic");
> +	if (IS_ERR_OR_NULL(charger->edev)) {
> +		if (!charger->edev)
>  			return -EPROBE_DEFER;
>  		dev_info(charger->dev, "couldn't get extcon device\n");
>  	}
>
> -	if (!IS_ERR(charger->reg) && !IS_ERR(charger->edev)) {
> +	if (!IS_ERR(charger->reg) && !IS_ERR_OR_NULL(charger->edev)) {
>  		INIT_WORK(&charger->extcon_work, max8997_battery_extcon_evt_worker);
>  		ret = devm_add_action(&pdev->dev, max8997_battery_extcon_evt_stop_work, charger);
>  		if (ret) {


Hello, I am not sure if I am missing something here. The other 2
patches of the series already made it into linux-next but this is still
pending. Do I have to resubmit? The patch still applies without
conflicts. Any help would be appreciated.

Thanks, Timon


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-03-26 16:21 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-30 17:28 [PATCH 0/3] charger-supply for max8997_charger Timon Baetz
2021-01-30 17:29 ` [PATCH 1/3] regulator: dt-bindings: Document charger-supply for max8997 Timon Baetz
2021-01-31 16:46   ` Krzysztof Kozlowski
2021-01-30 17:29 ` [PATCH 2/3] ARM: dts: exynos: Add charger supply for I9100 Timon Baetz
2021-02-11  5:59   ` Timon Baetz
2021-02-11  7:39     ` Krzysztof Kozlowski
2021-03-02  8:52   ` Krzysztof Kozlowski
2021-01-30 17:30 ` [PATCH 3/3] power: supply: max8997_charger: Switch to new binding Timon Baetz
2021-01-31 17:28   ` Krzysztof Kozlowski
2021-02-01  9:26     ` Timon Baetz
2021-02-01 18:03       ` Krzysztof Kozlowski
2021-03-09  7:47         ` Timon Baetz
2021-03-26 16:20   ` Timon Baetz
2021-02-03 21:07 ` (subset) [PATCH 0/3] charger-supply for max8997_charger Mark Brown

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).