Skip to contentSkip to conversation

arm64: allwinner: h6: Enable AXP805 PMIC on Pine H64

PATCH Superseded Chen-Yu Tsai 3 participants 10 messages Jul 5, 2018 – Jul 12, 2018

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover arm64: allwinner: h6: Enable AXP805 PMIC on Pine H64

Hi everyone,

This series enables the AXP805 PMIC found on the Pine64 Pine H64 board. The AXP805 seems to be identical to the AXP806 when comparing datasheets. The Pine H64 uses the PMIC in stand-alone or "self-working" mode, using the I2C interface. Neither features are currently supported. This series adds support for them, and then adds the PMIC to the device tree.

Changes since v1:

- Mentioned "self-working mode" in device tree commit message
- Shortened one line mfd cell into just one line
- Dropped unrelated pinctrl change
- Collected tags from Rob, Icenowy and Lee

Patch 1 adds a new device tree property to describe the self-working mode for the AXP806.

Patch 2 adds support for the newly added property to the driver.

Patch 3 adds support for the using AXP806 with I2C.

Patch 4 converts raw clock/reset indices for the H6 R_CCU currently found in the device tree to macros defined as part of the device tree bindings.

Patch 5 adds the PMIC and its regulators to the Pine H64 device tree.

First three patches should go in through Lee's mfd tree. We'll take the other two through the sunxi tree.

Please have a look.

Regards
ChenYu

Chen-Yu Tsai (4):
dt-bindings: mfd: axp20x: Add "self-working" mode for AXP806
mfd: axp20x: Add self-working mode support for AXP806
mfd: axp20x: Support AXP806 in I2C mode
arm64: dts: allwinner: h6: Use macros for R_CCU clock and reset
indices

Icenowy Zheng (1):
arm64: dts: allwinner: h6: enable AXP805 PMIC on Pine H64

 .../devicetree/bindings/mfd/axp20x.txt        |   7 +-
 .../boot/dts/allwinner/sun50i-h6-pine-h64.dts | 109 ++++++++++++++++++
 arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi  |   8 +-
 drivers/mfd/axp20x-i2c.c                      |   2 +
 drivers/mfd/axp20x.c                          |  30 ++++-
 5 files changed, 148 insertions(+), 8 deletions(-)
Signature · 1 line
2.18.0
#1 lore raw

PATCH v2 1/5 dt-bindings: mfd: axp20x: Add "self-working" mode for AXP806

The AXP806 has three operation modes:

- master mode: The PMIC is the first or only AXP PMIC in the system, but is not in charge of power management, i.e. only provides regulator functions.

- slave mode: The PMIC is the second AXP PMIC in the system, chained to the first, or master, one.

- self-working mode: The PMIC is the only AXP PMIC in the system, and is in charge of power sequencing.

The functional differences between these modes can be found in the "Control and Operation" chapter of the AXP806 (in Chinese) and AXP805 (in English) datasheets. These include how the PMIC responds to external signals, whether it takes an external voltage reference or uses its own, and whether the EN/PWRON pin functions as an enable switch or power button.

We already support both slave and master mode. This patch adds a property for describing the self-working mode, and reworks the description for the mode properties.

---
 Documentation/devicetree/bindings/mfd/axp20x.txt | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/mfd/axp20x.txt +5 -2
index d1762f3b30af..eaaf79c01e1e 100644
@@ -45,8 +45,11 @@ Optional properties:
 			  board is driving OTG VBus or not.
 			  (axp221 / axp223 / axp803/ axp813 only)
 
-- x-powers,master-mode: Boolean (axp806 only). Set this when the PMIC is
-			wired for master mode. The default is slave mode.
+- x-powers,self-working-mode and
+  x-powers,master-mode: Boolean (axp806 only). Set either of these when the
+			PMIC is wired for self-working mode or master mode.
+			If neither is set then slave mode is assumed.
+			This corresponds to how the MODESET pin is wired.
 
 - <input>-supply: a phandle to the regulator supply node. May be omitted if
 		  inputs are unregulated, such as using the IPSOUT output
Signature · 1 line
2.18.0
#2 lore raw

PATCH v2 1/5 dt-bindings: mfd: axp20x: Add "self-working" mode for AXP806

Quoted 22 lines · Chen-Yu Tsai

The AXP806 has three operation modes:

- master mode: The PMIC is the first or only AXP PMIC in the system, but is not in charge of power management, i.e. only provides regulator functions.

- slave mode: The PMIC is the second AXP PMIC in the system, chained to the first, or master, one.

- self-working mode: The PMIC is the only AXP PMIC in the system, and is in charge of power sequencing.

The functional differences between these modes can be found in the "Control and Operation" chapter of the AXP806 (in Chinese) and AXP805 (in English) datasheets. These include how the PMIC responds to external signals, whether it takes an external voltage reference or uses its own, and whether the EN/PWRON pin functions as an enable switch or power button.

We already support both slave and master mode. This patch adds a property for describing the self-working mode, and reworks the description for the mode properties.

Quoted 7 lines
---
 Documentation/devicetree/bindings/mfd/axp20x.txt | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

For my own reference:

Signature · 4 lines
Lee Jones [???]
Linaro Services Technical Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#3 lore raw

PATCH v2 2/5 mfd: axp20x: Add self-working mode support for AXP806

In reply to Chen-Yu Tsai

The AXP806 can operate in a standalone "self-working" mode, in which it is also responsible for power control of the overall system. This mode is similar to the master mode, but the EN/PWRON pin functions as a power button, instead of a level-triggered enable switch.

This patch adds code checking for the new "x-powers,self-working-mode" property, and a separate mfd_cell list that includes the power button (PEK) sub-device.

---
 drivers/mfd/axp20x.c | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)
drivers/mfd/axp20x.c +27 -3
index 9a2ef3d9b8f8..1988881529a9 100644
@@ -221,6 +221,11 @@ static const struct resource axp803_pek_resources[] = {
 	DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
+static const struct resource axp806_pek_resources[] = {
+	DEFINE_RES_IRQ_NAMED(AXP806_IRQ_POK_RISE, "PEK_DBR"),
+	DEFINE_RES_IRQ_NAMED(AXP806_IRQ_POK_FALL, "PEK_DBF"),
+};
+
 static const struct resource axp809_pek_resources[] = {
 	DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
 	DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
@@ -730,6 +735,17 @@ static const struct mfd_cell axp803_cells[] = {
 	{	.name			= "axp20x-regulator" },
 };
 
+static const struct mfd_cell axp806_self_working_cells[] = {
+	{
+		.name			= "axp221-pek",
+		.num_resources		= ARRAY_SIZE(axp806_pek_resources),
+		.resources		= axp806_pek_resources,
+	},
+	{
+		.name			= "axp20x-regulator",
+	},
+};
+
 static const struct mfd_cell axp806_cells[] = {
 	{
 		.id			= 2,
@@ -842,8 +858,14 @@ int axp20x_match_device(struct axp20x_dev *axp20x)
 		axp20x->regmap_irq_chip = &axp803_regmap_irq_chip;
 		break;
 	case AXP806_ID:
-		axp20x->nr_cells = ARRAY_SIZE(axp806_cells);
-		axp20x->cells = axp806_cells;
+		if (of_property_read_bool(axp20x->dev->of_node,
+					  "x-powers,self-working-mode")) {
+			axp20x->nr_cells = ARRAY_SIZE(axp806_self_working_cells);
+			axp20x->cells = axp806_self_working_cells;
+		} else {
+			axp20x->nr_cells = ARRAY_SIZE(axp806_cells);
+			axp20x->cells = axp806_cells;
+		}
 		axp20x->regmap_cfg = &axp806_regmap_config;
 		axp20x->regmap_irq_chip = &axp806_regmap_irq_chip;
 		break;
@@ -901,7 +923,9 @@ int axp20x_device_probe(struct axp20x_dev *axp20x)
 	 */
 	if (axp20x->variant == AXP806_ID) {
 		if (of_property_read_bool(axp20x->dev->of_node,
-					  "x-powers,master-mode"))
+					  "x-powers,master-mode") ||
+		    of_property_read_bool(axp20x->dev->of_node,
+					  "x-powers,self-working-mode"))
 			regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT,
 				     AXP806_REG_ADDR_EXT_ADDR_MASTER_MODE);
 		else
Signature · 1 line
2.18.0
#4 lore raw

PATCH v2 2/5 mfd: axp20x: Add self-working mode support for AXP806

Quoted 35 lines · Chen-Yu Tsai

The AXP806 can operate in a standalone "self-working" mode, in which it is also responsible for power control of the overall system. This mode is similar to the master mode, but the EN/PWRON pin functions as a power button, instead of a level-triggered enable switch.

This patch adds code checking for the new "x-powers,self-working-mode" property, and a separate mfd_cell list that includes the power button (PEK) sub-device.

---
 drivers/mfd/axp20x.c | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)
drivers/mfd/axp20x.c +5 -0
index 9a2ef3d9b8f8..1988881529a9 100644
@@ -221,6 +221,11 @@ static const struct resource axp803_pek_resources[] = {
 	DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
+static const struct resource axp806_pek_resources[] = {
+	DEFINE_RES_IRQ_NAMED(AXP806_IRQ_POK_RISE, "PEK_DBR"),
+	DEFINE_RES_IRQ_NAMED(AXP806_IRQ_POK_FALL, "PEK_DBF"),
+};
+
 static const struct resource axp809_pek_resources[] = {
 	DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
 	DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
@@ -730,6 +735,17 @@ static const struct mfd_cell axp803_cells[] = {
 	{	.name			= "axp20x-regulator" },
 };

drivers/mfd/axp20x.c static const struct mfd_cell axp803_cells[] = { · line 746

Quoted 10 lines
drivers/mfd/axp20x.c +9 -0
 
+static const struct mfd_cell axp806_self_working_cells[] = {
+	{
+		.name			= "axp221-pek",
+		.num_resources		= ARRAY_SIZE(axp806_pek_resources),
+		.resources		= axp806_pek_resources,
+	},
+	{
+		.name			= "axp20x-regulator",
+	},

Nit: this should be on a single line, like it is above.

Once fixed, please re-submit with my:

For my own reference:

Signature · 4 lines
Lee Jones [???]
Linaro Services Technical Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#5 lore raw

PATCH v2 3/5 mfd: axp20x: Support AXP806 in I2C mode

In reply to Chen-Yu Tsai

The Pine64 H64 board uses an AXP806 PMIC in I2C and self-working mode. The H64 SoC does not have the usual RSB controller.

This patch adds AXP806 to the list of devices supported in I2C mode. In theory, all RSB-based PMICs can also be used in I2C mode.

---
 drivers/mfd/axp20x-i2c.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mfd/axp20x-i2c.c +2 -0
index d35a5fe6c950..a7b7c5423ea5 100644
@@ -65,6 +65,7 @@ static const struct of_device_id axp20x_i2c_of_match[] = {
 	{ .compatible = "x-powers,axp202", .data = (void *)AXP202_ID },
 	{ .compatible = "x-powers,axp209", .data = (void *)AXP209_ID },
 	{ .compatible = "x-powers,axp221", .data = (void *)AXP221_ID },
+	{ .compatible = "x-powers,axp806", .data = (void *)AXP806_ID },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, axp20x_i2c_of_match);
@@ -74,6 +75,7 @@ static const struct i2c_device_id axp20x_i2c_id[] = {
 	{ "axp202", 0 },
 	{ "axp209", 0 },
 	{ "axp221", 0 },
+	{ "axp806", 0 },
 	{ },
 };
 MODULE_DEVICE_TABLE(i2c, axp20x_i2c_id);
Signature · 1 line
2.18.0
#6 lore raw

PATCH v2 3/5 mfd: axp20x: Support AXP806 in I2C mode

Quoted 6 lines · Chen-Yu Tsai

The Pine64 H64 board uses an AXP806 PMIC in I2C and self-working mode. The H64 SoC does not have the usual RSB controller.

This patch adds AXP806 to the list of devices supported in I2C mode. In theory, all RSB-based PMICs can also be used in I2C mode.

Quoted 6 lines
---
 drivers/mfd/axp20x-i2c.c | 2 ++
 1 file changed, 2 insertions(+)

For my own reference:

Signature · 4 lines
Lee Jones [???]
Linaro Services Technical Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#7 lore raw

PATCH v2 4/5 arm64: dts: allwinner: h6: Use macros for R_CCU clock and reset indices

In reply to Chen-Yu Tsai

Now that the device tree binding headers for the R_CCU have been merged, we can use the macros, instead of raw numbers.

Switch to R_CCU macros for clock and reset indices.

---
 arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +5 -3
index c72da8cd9ef5..37c2e11fca2e 100644
@@ -5,7 +5,9 @@
 
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/clock/sun50i-h6-ccu.h>
+#include <dt-bindings/clock/sun50i-h6-r-ccu.h>
 #include <dt-bindings/reset/sun50i-h6-ccu.h>
+#include <dt-bindings/reset/sun50i-h6-r-ccu.h>
 
 / {
 	interrupt-parent = <&gic>;
@@ -198,7 +200,7 @@
 			reg = <0x07022000 0x400>;
 			interrupts = <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>,
 				     <GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&r_ccu 2>, <&osc24M>, <&osc32k>;
+			clocks = <&r_ccu CLK_R_APB1>, <&osc24M>, <&osc32k>;
 			clock-names = "apb", "hosc", "losc";
 			gpio-controller;
 			#gpio-cells = <3>;
@@ -215,8 +217,8 @@
 			compatible = "allwinner,sun6i-a31-i2c";
 			reg = <0x07081400 0x400>;
 			interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&r_ccu 8>;
-			resets = <&r_ccu 4>;
+			clocks = <&r_ccu CLK_R_APB2_I2C>;
+			resets = <&r_ccu RST_R_APB2_I2C>;
 			pinctrl-names = "default";
 			pinctrl-0 = <&r_i2c_pins>;
 			status = "disabled";
Signature · 1 line
2.18.0
#8 lore raw

PATCH v2 5/5 arm64: dts: allwinner: h6: enable AXP805 PMIC on Pine H64

In reply to Chen-Yu Tsai

From: Icenowy Zheng <[email protected]>

Pine H64 board has an AXP805 PMIC on it, wired up in standalone, or self-working, mode.

Enable it in the device tree.

---
 .../boot/dts/allwinner/sun50i-h6-pine-h64.dts | 109 ++++++++++++++++++
 1 file changed, 109 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dts +109 -0
index 2e97173c9204..1673636358ef 100644
@@ -44,6 +44,115 @@
 &r_i2c {
 	status = "okay";
 
+	axp805: pmic at 36 {
+		compatible = "x-powers,axp805", "x-powers,axp806";
+		reg = <0x36>;
+		interrupt-parent = <&r_intc>;
+		interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		x-powers,self-working-mode;
+
+		regulators {
+			reg_aldo1: aldo1 {
+				regulator-always-on;
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-name = "vcc-pl";
+			};
+
+			reg_aldo2: aldo2 {
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-name = "vcc-ac200";
+			};
+
+			reg_aldo3: aldo3 {
+				/* This regulator is connected with CLDO1 */
+				regulator-always-on;
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-name = "vcc-3v3-1";
+			};
+
+			reg_bldo1: bldo1 {
+				regulator-always-on;
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+				regulator-name = "vcc-bias-pll";
+			};
+
+			reg_bldo2: bldo2 {
+				regulator-always-on;
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+				regulator-name = "vcc-efuse-pcie-hdmi-io";
+			};
+
+			reg_bldo3: bldo3 {
+				regulator-always-on;
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+				regulator-name = "vcc-dcxoio";
+			};
+
+			bldo4 {
+				/* unused */
+			};
+
+			reg_cldo1: cldo1 {
+				/* This regulator is connected with ALDO3 */
+				regulator-always-on;
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-name = "vcc-3v3-2";
+			};
+
+			reg_cldo2: cldo2 {
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-name = "vcc-wifi-1";
+			};
+
+			reg_cldo3: cldo3 {
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-name = "vcc-wifi-2";
+			};
+
+			reg_dcdca: dcdca {
+				regulator-always-on;
+				regulator-min-microvolt = <810000>;
+				regulator-max-microvolt = <1080000>;
+				regulator-name = "vdd-cpu";
+			};
+
+			reg_dcdcc: dcdcc {
+				regulator-min-microvolt = <810000>;
+				regulator-max-microvolt = <1080000>;
+				regulator-name = "vdd-gpu";
+			};
+
+			reg_dcdcd: dcdcd {
+				regulator-always-on;
+				regulator-min-microvolt = <960000>;
+				regulator-max-microvolt = <960000>;
+				regulator-name = "vdd-sys";
+			};
+
+			reg_dcdce: dcdce {
+				regulator-always-on;
+				regulator-min-microvolt = <1200000>;
+				regulator-max-microvolt = <1200000>;
+				regulator-name = "vcc-dram";
+			};
+
+			sw {
+				/* unused */
+			};
+		};
+	};
+
 	pcf8563: rtc at 51 {
 		compatible = "nxp,pcf8563";
 		reg = <0x51>;
Signature · 1 line
2.18.0
#9 lore raw

v2 cover arm64: allwinner: h6: Enable AXP805 PMIC on Pine H64

In reply to Chen-Yu Tsai
Quoted 7 lines · Chen-Yu Tsai

Hi everyone,

This series enables the AXP805 PMIC found on the Pine64 Pine H64 board. The AXP805 seems to be identical to the AXP806 when comparing datasheets. The Pine H64 uses the PMIC in stand-alone or "self-working" mode, using the I2C interface. Neither features are currently supported. This series adds support for them, and then adds the PMIC to the device tree.

Maxime

Signature · 10 lines
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180705/1539a556/attachment.sig>