Skip to contentSkip to conversation

mfd: axp20x: Restore master mode support on AXP806

PATCH Applied Rask Ingemann Lambertsen 4 participants 7 messages Feb 22, 2017 – Mar 14, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover mfd: axp20x: Restore master mode support on AXP806

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(-)
Signature · 1 line
2.10.2
#1 lore raw

PATCH v2 1/2 dts: mfd: axp20x: Add "xpowers,master-mode" property for AXP806 PMICs

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

---
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(+)
Documentation/devicetree/bindings/mfd/axp20x.txt +3 -0
index 8f3ad9a..b41d260 100644
@@ -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.
Signature · 1 line
2.10.2
maintainer Acked-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] dts: mfd: axp20x: Add "xpowers,master-mode" property for AXP806 PMICs

Quoted 10 lines · Rask Ingemann Lambertsen

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")
Quoted 8 lines

---
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
#3 lore raw

Re: [PATCH v2 1/2] dts: mfd: axp20x: Add "xpowers,master-mode" property for AXP806 PMICs

In reply to Rask Ingemann Lambertsen
Quoted 10 lines · Rask Ingemann Lambertsen

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")
Quoted 8 lines

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

Quoted 14 lines
Documentation/devicetree/bindings/mfd/axp20x.txt +3 -0
index 8f3ad9a..b41d260 100644
@@ -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.
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#4 lore raw

PATCH v2 2/2 mfd: axp20x: Add support for dts property "xpowers,master-mode"

In reply to Rask Ingemann Lambertsen

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

---
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(-)
drivers/mfd/axp20x.c +13 -8
index 25115fe..0512900 100644
@@ -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,
Signature · 1 line
2.10.2
Acked-by on v2 2/2
#5 lore raw

Re: [PATCH v2 2/2] mfd: axp20x: Add support for dts property "xpowers,master-mode"

Quoted 9 lines · Rask Ingemann Lambertsen

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")
Applied
#6 lore raw

Re: [PATCH v2 2/2] mfd: axp20x: Add support for dts property "xpowers,master-mode"

In reply to Rask Ingemann Lambertsen
Quoted 9 lines · Rask Ingemann Lambertsen

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")
Quoted 8 lines

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

Quoted 40 lines
drivers/mfd/axp20x.c +13 -8
index 25115fe..0512900 100644
@@ -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,
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog