linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] mfd: axp20x: Restore master mode support on AXP806
@ 2017-02-22 19:40 Rask Ingemann Lambertsen
  2017-02-22 19:41 ` [PATCH v2 1/2] dts: mfd: axp20x: Add "xpowers,master-mode" property for AXP806 PMICs Rask Ingemann Lambertsen
  2017-02-22 19:42 ` [PATCH v2 2/2] mfd: axp20x: Add support for dts property "xpowers,master-mode" Rask Ingemann Lambertsen
  0 siblings, 2 replies; 7+ messages in thread
From: Rask Ingemann Lambertsen @ 2017-02-22 19:40 UTC (permalink / raw)
  To: Chen-Yu Tsai, Lee Jones, Rob Herring, Mark Rutland
  Cc: devicetree, linux-arm-kernel, linux-kernel

The AXP806 (and very similar AXP808) PMICs can be wired to either master
mode or slave mode on a board-by-board basis. A register on the PMIC needs
to be set accordingly for the PMIC to respond to other register accesses.
The "xpowers,master-mode" property introduced in this patch series lets a
board's device tree specify the correct operating mode to use.

Known boards with the Allwinner A80 SoC include an AXP806 or AXP808.
The AXP806 support used to rely on the vendor boot loader to set the
operating mode, but nowadays, mainline U-Boot (since V2016.11) is usable
on boards using the A80 SoC, but doesn't yet have any support for the
AXP806 PMIC. So for kernel 4.11, a patch went in to always set the
AXP806 to slave mode to keep those two boards working (see below). That,
however, broke support for boards where the PMIC is wired for master mode.

There are so far three boards using the AXP806 PMIC support:
- Merrii A80 Optimus and Cubieboard4 developer boards with an AXP809
  paired with an AXP806 in slave mode. A device tree for each of these
  boards have been in the tree for a while now.
- Sunchip CX-A99 which uses just an AXP808 in master mode. An
  out-of-tree device tree works with the 4.9.9 and 4.10-rc7 kernels.
  A device tree will be submitted along with support for *-supply
  properties taking a regulator list.

The default needs to be slave mode for compatibility with the two boards'
device trees that are using the "xpowers,axp806" compatible since kernel
4.9 when the AXP806 support was added.

Patch 1 adds the "xpowers,master-mode" property to the AXP806 binding.
Patch 2 adds support for it to the axp20x driver.

Rask Ingemann Lambertsen (2):
  dts: mfd: axp20x: Add "xpowers,master-mode" property for AXP806 PMICs
  mfd: axp20x: Add support for dts property "xpowers,master-mode"

 Documentation/devicetree/bindings/mfd/axp20x.txt |  3 +++
 drivers/mfd/axp20x.c                             | 21 +++++++++++++--------
 2 files changed, 16 insertions(+), 8 deletions(-)

-- 
2.10.2

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

* [PATCH v2 1/2] dts: mfd: axp20x: Add "xpowers,master-mode" property for AXP806 PMICs
  2017-02-22 19:40 [PATCH v2 0/2] mfd: axp20x: Restore master mode support on AXP806 Rask Ingemann Lambertsen
@ 2017-02-22 19:41 ` Rask Ingemann Lambertsen
  2017-02-27 23:00   ` Rob Herring
  2017-03-14 16:19   ` Lee Jones
  2017-02-22 19:42 ` [PATCH v2 2/2] mfd: axp20x: Add support for dts property "xpowers,master-mode" Rask Ingemann Lambertsen
  1 sibling, 2 replies; 7+ messages in thread
From: Rask Ingemann Lambertsen @ 2017-02-22 19:41 UTC (permalink / raw)
  To: Chen-Yu Tsai, Lee Jones, Rob Herring, Mark Rutland
  Cc: devicetree, linux-arm-kernel, linux-kernel

commit b101829a029a ("mfd: axp20x: Fix AXP806 access errors on cold boot")
was intended to fix the case where a board uses an AXP806 in slave mode,
but the boot loader leaves it in master mode for lack of AXP806 support.
But now the driver breaks on boards where the PMIC is operating in master
mode. To let the device tree describe which mode of operation is needed,
this patch introduces a new property "xpowers,master-mode".

Fixes: 204ae2963e10 ("mfd: axp20x: Add bindings for AXP806 PMIC")
Signed-off-by: Rask Ingemann Lambertsen <rask@formelder.dk>
Acked-by: Chen-Yu Tsai <wens@csie.org>
---
Changes from v1 to v2:
Changed the commit message such that Fixes: points to the commit which
introduced the bindings for the AXP806 because the property should have been
included from the beginning of the AXP806 support.

 Documentation/devicetree/bindings/mfd/axp20x.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt
index 8f3ad9a..b41d260 100644
--- a/Documentation/devicetree/bindings/mfd/axp20x.txt
+++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
@@ -28,6 +28,9 @@ Optional properties:
 		  regulator to drive the OTG VBus, rather then as an input pin
 		  which signals whether the board is driving OTG VBus or not.
 
+- x-powers,master-mode: Boolean (axp806 only). Set this when the PMIC is
+			wired for master mode. The default is slave mode.
+
 - <input>-supply: a phandle to the regulator supply node. May be omitted if
 		  inputs are unregulated, such as using the IPSOUT output
 		  from the PMIC.
-- 
2.10.2

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

* [PATCH v2 2/2] mfd: axp20x: Add support for dts property "xpowers,master-mode"
  2017-02-22 19:40 [PATCH v2 0/2] mfd: axp20x: Restore master mode support on AXP806 Rask Ingemann Lambertsen
  2017-02-22 19:41 ` [PATCH v2 1/2] dts: mfd: axp20x: Add "xpowers,master-mode" property for AXP806 PMICs Rask Ingemann Lambertsen
@ 2017-02-22 19:42 ` Rask Ingemann Lambertsen
  2017-02-23  3:57   ` Chen-Yu Tsai
  2017-03-14 16:19   ` Lee Jones
  1 sibling, 2 replies; 7+ messages in thread
From: Rask Ingemann Lambertsen @ 2017-02-22 19:42 UTC (permalink / raw)
  To: Chen-Yu Tsai, Lee Jones, Rob Herring, Mark Rutland
  Cc: devicetree, linux-arm-kernel, linux-kernel

commit b101829a029a ("mfd: axp20x: Fix AXP806 access errors on cold boot")
was intended to fix the case where a board uses an AXP806 in slave mode,
but the boot loader leaves it in master mode for lack of AXP806 support.
But now the driver breaks on boards where the PMIC is operating in master
mode. This patch lets the driver use the new device tree property
"xpowers,master-mode" to set the correct operating mode for the board.

Fixes: 8824ee857348 ("mfd: axp20x: Add support for AXP806 PMIC")
Signed-off-by: Rask Ingemann Lambertsen <rask@formelder.dk>
---
Changes from v1 to v2:
Changed the commit message such that Fixes: points to the commit which added
the AXP806 driver because the property should have been included from the
beginning of the AXP806 support.

 drivers/mfd/axp20x.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index 25115fe..0512900 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -31,6 +31,7 @@
 
 #define AXP20X_OFF	0x80
 
+#define AXP806_REG_ADDR_EXT_ADDR_MASTER_MODE	0
 #define AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE	BIT(4)
 
 static const char * const axp20x_model_names[] = {
@@ -877,15 +878,19 @@ int axp20x_device_probe(struct axp20x_dev *axp20x)
 	 * the these device addressing bits (in the upper 4 bits of the
 	 * registers) match.
 	 *
-	 * Since we only support an AXP806 chained to an AXP809 in slave
-	 * mode, and there isn't any existing hardware which uses AXP806
-	 * in master mode, or has 2 AXP806s in the same system, we can
-	 * just program the register address extension to the slave mode
-	 * address.
+	 * By default we support an AXP806 chained to an AXP809 in slave
+	 * mode. Boards which use an AXP806 in master mode can set the
+	 * property "x-powers,master-mode" to override the default.
 	 */
-	if (axp20x->variant == AXP806_ID)
-		regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT,
-			     AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE);
+	if (axp20x->variant == AXP806_ID) {
+		if (of_property_read_bool(axp20x->dev->of_node,
+					  "x-powers,master-mode"))
+			regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT,
+				     AXP806_REG_ADDR_EXT_ADDR_MASTER_MODE);
+		else
+			regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT,
+				     AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE);
+	}
 
 	ret = regmap_add_irq_chip(axp20x->regmap, axp20x->irq,
 			  IRQF_ONESHOT | IRQF_SHARED | axp20x->irq_flags,
-- 
2.10.2

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

* Re: [PATCH v2 2/2] mfd: axp20x: Add support for dts property "xpowers,master-mode"
  2017-02-22 19:42 ` [PATCH v2 2/2] mfd: axp20x: Add support for dts property "xpowers,master-mode" Rask Ingemann Lambertsen
@ 2017-02-23  3:57   ` Chen-Yu Tsai
  2017-03-14 16:19   ` Lee Jones
  1 sibling, 0 replies; 7+ messages in thread
From: Chen-Yu Tsai @ 2017-02-23  3:57 UTC (permalink / raw)
  To: Rask Ingemann Lambertsen
  Cc: Chen-Yu Tsai, Lee Jones, Rob Herring, Mark Rutland, devicetree,
	linux-arm-kernel, linux-kernel

On Thu, Feb 23, 2017 at 3:42 AM, Rask Ingemann Lambertsen
<rask@formelder.dk> wrote:
> commit b101829a029a ("mfd: axp20x: Fix AXP806 access errors on cold boot")
> was intended to fix the case where a board uses an AXP806 in slave mode,
> but the boot loader leaves it in master mode for lack of AXP806 support.
> But now the driver breaks on boards where the PMIC is operating in master
> mode. This patch lets the driver use the new device tree property
> "xpowers,master-mode" to set the correct operating mode for the board.
>
> Fixes: 8824ee857348 ("mfd: axp20x: Add support for AXP806 PMIC")
> Signed-off-by: Rask Ingemann Lambertsen <rask@formelder.dk>

Acked-by: Chen-Yu Tsai <wens@csie.org>

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

* Re: [PATCH v2 1/2] dts: mfd: axp20x: Add "xpowers,master-mode" property for AXP806 PMICs
  2017-02-22 19:41 ` [PATCH v2 1/2] dts: mfd: axp20x: Add "xpowers,master-mode" property for AXP806 PMICs Rask Ingemann Lambertsen
@ 2017-02-27 23:00   ` Rob Herring
  2017-03-14 16:19   ` Lee Jones
  1 sibling, 0 replies; 7+ messages in thread
From: Rob Herring @ 2017-02-27 23:00 UTC (permalink / raw)
  To: Rask Ingemann Lambertsen
  Cc: Chen-Yu Tsai, Lee Jones, Mark Rutland, devicetree,
	linux-arm-kernel, linux-kernel

On Wed, Feb 22, 2017 at 08:41:02PM +0100, Rask Ingemann Lambertsen wrote:
> commit b101829a029a ("mfd: axp20x: Fix AXP806 access errors on cold boot")
> was intended to fix the case where a board uses an AXP806 in slave mode,
> but the boot loader leaves it in master mode for lack of AXP806 support.
> But now the driver breaks on boards where the PMIC is operating in master
> mode. To let the device tree describe which mode of operation is needed,
> this patch introduces a new property "xpowers,master-mode".
> 
> Fixes: 204ae2963e10 ("mfd: axp20x: Add bindings for AXP806 PMIC")
> Signed-off-by: Rask Ingemann Lambertsen <rask@formelder.dk>
> Acked-by: Chen-Yu Tsai <wens@csie.org>
> ---
> Changes from v1 to v2:
> Changed the commit message such that Fixes: points to the commit which
> introduced the bindings for the AXP806 because the property should have been
> included from the beginning of the AXP806 support.
> 
>  Documentation/devicetree/bindings/mfd/axp20x.txt | 3 +++
>  1 file changed, 3 insertions(+)

Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v2 1/2] dts: mfd: axp20x: Add "xpowers,master-mode" property for AXP806 PMICs
  2017-02-22 19:41 ` [PATCH v2 1/2] dts: mfd: axp20x: Add "xpowers,master-mode" property for AXP806 PMICs Rask Ingemann Lambertsen
  2017-02-27 23:00   ` Rob Herring
@ 2017-03-14 16:19   ` Lee Jones
  1 sibling, 0 replies; 7+ messages in thread
From: Lee Jones @ 2017-03-14 16:19 UTC (permalink / raw)
  To: Rask Ingemann Lambertsen
  Cc: Chen-Yu Tsai, Rob Herring, Mark Rutland, devicetree,
	linux-arm-kernel, linux-kernel

On Wed, 22 Feb 2017, Rask Ingemann Lambertsen wrote:

> commit b101829a029a ("mfd: axp20x: Fix AXP806 access errors on cold boot")
> was intended to fix the case where a board uses an AXP806 in slave mode,
> but the boot loader leaves it in master mode for lack of AXP806 support.
> But now the driver breaks on boards where the PMIC is operating in master
> mode. To let the device tree describe which mode of operation is needed,
> this patch introduces a new property "xpowers,master-mode".
> 
> Fixes: 204ae2963e10 ("mfd: axp20x: Add bindings for AXP806 PMIC")
> Signed-off-by: Rask Ingemann Lambertsen <rask@formelder.dk>
> Acked-by: Chen-Yu Tsai <wens@csie.org>
> ---
> Changes from v1 to v2:
> Changed the commit message such that Fixes: points to the commit which
> introduced the bindings for the AXP806 because the property should have been
> included from the beginning of the AXP806 support.
> 
>  Documentation/devicetree/bindings/mfd/axp20x.txt | 3 +++
>  1 file changed, 3 insertions(+)

Applied, thanks.

> diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt
> index 8f3ad9a..b41d260 100644
> --- a/Documentation/devicetree/bindings/mfd/axp20x.txt
> +++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
> @@ -28,6 +28,9 @@ Optional properties:
>  		  regulator to drive the OTG VBus, rather then as an input pin
>  		  which signals whether the board is driving OTG VBus or not.
>  
> +- x-powers,master-mode: Boolean (axp806 only). Set this when the PMIC is
> +			wired for master mode. The default is slave mode.
> +
>  - <input>-supply: a phandle to the regulator supply node. May be omitted if
>  		  inputs are unregulated, such as using the IPSOUT output
>  		  from the PMIC.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v2 2/2] mfd: axp20x: Add support for dts property "xpowers,master-mode"
  2017-02-22 19:42 ` [PATCH v2 2/2] mfd: axp20x: Add support for dts property "xpowers,master-mode" Rask Ingemann Lambertsen
  2017-02-23  3:57   ` Chen-Yu Tsai
@ 2017-03-14 16:19   ` Lee Jones
  1 sibling, 0 replies; 7+ messages in thread
From: Lee Jones @ 2017-03-14 16:19 UTC (permalink / raw)
  To: Rask Ingemann Lambertsen
  Cc: Chen-Yu Tsai, Rob Herring, Mark Rutland, devicetree,
	linux-arm-kernel, linux-kernel

On Wed, 22 Feb 2017, Rask Ingemann Lambertsen wrote:

> commit b101829a029a ("mfd: axp20x: Fix AXP806 access errors on cold boot")
> was intended to fix the case where a board uses an AXP806 in slave mode,
> but the boot loader leaves it in master mode for lack of AXP806 support.
> But now the driver breaks on boards where the PMIC is operating in master
> mode. This patch lets the driver use the new device tree property
> "xpowers,master-mode" to set the correct operating mode for the board.
> 
> Fixes: 8824ee857348 ("mfd: axp20x: Add support for AXP806 PMIC")
> Signed-off-by: Rask Ingemann Lambertsen <rask@formelder.dk>
> ---
> Changes from v1 to v2:
> Changed the commit message such that Fixes: points to the commit which added
> the AXP806 driver because the property should have been included from the
> beginning of the AXP806 support.
> 
>  drivers/mfd/axp20x.c | 21 +++++++++++++--------
>  1 file changed, 13 insertions(+), 8 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index 25115fe..0512900 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -31,6 +31,7 @@
>  
>  #define AXP20X_OFF	0x80
>  
> +#define AXP806_REG_ADDR_EXT_ADDR_MASTER_MODE	0
>  #define AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE	BIT(4)
>  
>  static const char * const axp20x_model_names[] = {
> @@ -877,15 +878,19 @@ int axp20x_device_probe(struct axp20x_dev *axp20x)
>  	 * the these device addressing bits (in the upper 4 bits of the
>  	 * registers) match.
>  	 *
> -	 * Since we only support an AXP806 chained to an AXP809 in slave
> -	 * mode, and there isn't any existing hardware which uses AXP806
> -	 * in master mode, or has 2 AXP806s in the same system, we can
> -	 * just program the register address extension to the slave mode
> -	 * address.
> +	 * By default we support an AXP806 chained to an AXP809 in slave
> +	 * mode. Boards which use an AXP806 in master mode can set the
> +	 * property "x-powers,master-mode" to override the default.
>  	 */
> -	if (axp20x->variant == AXP806_ID)
> -		regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT,
> -			     AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE);
> +	if (axp20x->variant == AXP806_ID) {
> +		if (of_property_read_bool(axp20x->dev->of_node,
> +					  "x-powers,master-mode"))
> +			regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT,
> +				     AXP806_REG_ADDR_EXT_ADDR_MASTER_MODE);
> +		else
> +			regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT,
> +				     AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE);
> +	}
>  
>  	ret = regmap_add_irq_chip(axp20x->regmap, axp20x->irq,
>  			  IRQF_ONESHOT | IRQF_SHARED | axp20x->irq_flags,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

end of thread, other threads:[~2017-03-14 16:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-22 19:40 [PATCH v2 0/2] mfd: axp20x: Restore master mode support on AXP806 Rask Ingemann Lambertsen
2017-02-22 19:41 ` [PATCH v2 1/2] dts: mfd: axp20x: Add "xpowers,master-mode" property for AXP806 PMICs Rask Ingemann Lambertsen
2017-02-27 23:00   ` Rob Herring
2017-03-14 16:19   ` Lee Jones
2017-02-22 19:42 ` [PATCH v2 2/2] mfd: axp20x: Add support for dts property "xpowers,master-mode" Rask Ingemann Lambertsen
2017-02-23  3:57   ` Chen-Yu Tsai
2017-03-14 16:19   ` 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).