devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] regulator da9062: support setting buck modes
@ 2019-11-13 13:40 Christoph Fritz
  2019-11-13 13:40 ` [PATCH v2 1/4] regulator: da9062: refactor buck modes into header Christoph Fritz
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Christoph Fritz @ 2019-11-13 13:40 UTC (permalink / raw)
  To: Adam Thomson, Mark Brown, Fabio Estevam, Rob Herring,
	Mark Rutland, Shawn Guo
  Cc: Lee Jones, Liam Girdwood, Support Opensource, devicetree,
	linux-arm-kernel

This patchset adds of_map_mode support to regulator da9062, documents
its bindings and makes use of it in dts phycore-imx6 so that buck modes
get configured explicitly for this hardware.

Changes in v2:
 - rename defines (and header filename) from 906X to 9063
 - explain usage of name da9063 in changelog
 - rename da906x_map_buck_mode() to da9062_map_buck_mode()
 - rebase patchset on top of next-20191113
 - adapt subject line of dt-bindings patch to reflect changes
   in mfd sub-system

Christoph Fritz (4):
  regulator: da9062: refactor buck modes into header
  regulator: da9062: add of_map_mode support for bucks
  dt-bindings: mfd: da9062: describe buck modes
  ARM: dts: phycore-imx6: set buck regulator modes explicitly

 Documentation/devicetree/bindings/mfd/da9062.txt   |  4 ++
 arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi  |  5 +++
 drivers/regulator/da9062-regulator.c               | 49 ++++++++++++++--------
 .../dt-bindings/regulator/dlg,da9063-regulator.h   | 16 +++++++
 4 files changed, 56 insertions(+), 18 deletions(-)
 create mode 100644 include/dt-bindings/regulator/dlg,da9063-regulator.h

-- 
2.1.4


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

* [PATCH v2 1/4] regulator: da9062: refactor buck modes into header
  2019-11-13 13:40 [PATCH v2 0/4] regulator da9062: support setting buck modes Christoph Fritz
@ 2019-11-13 13:40 ` Christoph Fritz
  2019-11-13 16:19   ` Adam Thomson
  2019-11-15 12:25   ` Applied "regulator: da9062: refactor buck modes into header" to the regulator tree Mark Brown
  2019-11-13 13:40 ` [PATCH v2 2/4] regulator: da9062: add of_map_mode support for bucks Christoph Fritz
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 16+ messages in thread
From: Christoph Fritz @ 2019-11-13 13:40 UTC (permalink / raw)
  To: Adam Thomson, Mark Brown, Fabio Estevam, Rob Herring,
	Mark Rutland, Shawn Guo
  Cc: Lee Jones, Liam Girdwood, Support Opensource, devicetree,
	linux-arm-kernel

This patch refactors buck modes into a header file so that device trees
can make use of these mode constants.

The new header filename uses da9063 because DA9063 was the earlier chip
and its driver code will want updating at some point in a similar manner.

Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
---
 drivers/regulator/da9062-regulator.c               | 28 ++++++++--------------
 .../dt-bindings/regulator/dlg,da9063-regulator.h   | 16 +++++++++++++
 2 files changed, 26 insertions(+), 18 deletions(-)
 create mode 100644 include/dt-bindings/regulator/dlg,da9063-regulator.h

diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-regulator.c
index 4b24518..601002e 100644
--- a/drivers/regulator/da9062-regulator.c
+++ b/drivers/regulator/da9062-regulator.c
@@ -16,6 +16,7 @@
 #include <linux/regulator/of_regulator.h>
 #include <linux/mfd/da9062/core.h>
 #include <linux/mfd/da9062/registers.h>
+#include <dt-bindings/regulator/dlg,da9063-regulator.h>
 
 /* Regulator IDs */
 enum {
@@ -75,14 +76,6 @@ struct da9062_regulators {
 	struct da9062_regulator			regulator[0];
 };
 
-/* BUCK modes */
-enum {
-	BUCK_MODE_MANUAL,	/* 0 */
-	BUCK_MODE_SLEEP,	/* 1 */
-	BUCK_MODE_SYNC,		/* 2 */
-	BUCK_MODE_AUTO		/* 3 */
-};
-
 /* Regulator operations */
 
 /* Current limits array (in uA)
@@ -112,13 +105,13 @@ static int da9062_buck_set_mode(struct regulator_dev *rdev, unsigned mode)
 
 	switch (mode) {
 	case REGULATOR_MODE_FAST:
-		val = BUCK_MODE_SYNC;
+		val = DA9063_BUCK_MODE_SYNC;
 		break;
 	case REGULATOR_MODE_NORMAL:
-		val = BUCK_MODE_AUTO;
+		val = DA9063_BUCK_MODE_AUTO;
 		break;
 	case REGULATOR_MODE_STANDBY:
-		val = BUCK_MODE_SLEEP;
+		val = DA9063_BUCK_MODE_SLEEP;
 		break;
 	default:
 		return -EINVAL;
@@ -145,14 +138,13 @@ static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
 
 	switch (val) {
 	default:
-	case BUCK_MODE_MANUAL:
 		/* Sleep flag bit decides the mode */
 		break;
-	case BUCK_MODE_SLEEP:
+	case DA9063_BUCK_MODE_SLEEP:
 		return REGULATOR_MODE_STANDBY;
-	case BUCK_MODE_SYNC:
+	case DA9063_BUCK_MODE_SYNC:
 		return REGULATOR_MODE_FAST;
-	case BUCK_MODE_AUTO:
+	case DA9063_BUCK_MODE_AUTO:
 		return REGULATOR_MODE_NORMAL;
 	}
 
@@ -279,13 +271,13 @@ static int da9062_buck_set_suspend_mode(struct regulator_dev *rdev,
 
 	switch (mode) {
 	case REGULATOR_MODE_FAST:
-		val = BUCK_MODE_SYNC;
+		val = DA9063_BUCK_MODE_SYNC;
 		break;
 	case REGULATOR_MODE_NORMAL:
-		val = BUCK_MODE_AUTO;
+		val = DA9063_BUCK_MODE_AUTO;
 		break;
 	case REGULATOR_MODE_STANDBY:
-		val = BUCK_MODE_SLEEP;
+		val = DA9063_BUCK_MODE_SLEEP;
 		break;
 	default:
 		return -EINVAL;
diff --git a/include/dt-bindings/regulator/dlg,da9063-regulator.h b/include/dt-bindings/regulator/dlg,da9063-regulator.h
new file mode 100644
index 00000000..1de710d
--- /dev/null
+++ b/include/dt-bindings/regulator/dlg,da9063-regulator.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _DT_BINDINGS_REGULATOR_DLG_DA9063_H
+#define _DT_BINDINGS_REGULATOR_DLG_DA9063_H
+
+/*
+ * These buck mode constants may be used to specify values in device tree
+ * properties (e.g. regulator-initial-mode).
+ * A description of the following modes is in the manufacturers datasheet.
+ */
+
+#define DA9063_BUCK_MODE_SLEEP		1
+#define DA9063_BUCK_MODE_SYNC		2
+#define DA9063_BUCK_MODE_AUTO		3
+
+#endif
-- 
2.1.4


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

* [PATCH v2 2/4] regulator: da9062: add of_map_mode support for bucks
  2019-11-13 13:40 [PATCH v2 0/4] regulator da9062: support setting buck modes Christoph Fritz
  2019-11-13 13:40 ` [PATCH v2 1/4] regulator: da9062: refactor buck modes into header Christoph Fritz
@ 2019-11-13 13:40 ` Christoph Fritz
  2019-11-13 16:24   ` Adam Thomson
  2019-11-15 12:25   ` Applied "regulator: da9062: add of_map_mode support for bucks" to the regulator tree Mark Brown
  2019-11-13 13:40 ` [PATCH v2 3/4] dt-bindings: mfd: da9062: describe buck modes Christoph Fritz
  2019-11-13 13:40 ` [PATCH v2 4/4] ARM: dts: phycore-imx6: set buck regulator modes explicitly Christoph Fritz
  3 siblings, 2 replies; 16+ messages in thread
From: Christoph Fritz @ 2019-11-13 13:40 UTC (permalink / raw)
  To: Adam Thomson, Mark Brown, Fabio Estevam, Rob Herring,
	Mark Rutland, Shawn Guo
  Cc: Lee Jones, Liam Girdwood, Support Opensource, devicetree,
	linux-arm-kernel, Christian Hemp, Stefan Riedmueller

This patch adds of_map_mode support for bucks to set regulator modes
from within regulator framework.

Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
Signed-off-by: Christian Hemp <c.hemp@phytec.de>
Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
---
 drivers/regulator/da9062-regulator.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-regulator.c
index 601002e..29f4a60 100644
--- a/drivers/regulator/da9062-regulator.c
+++ b/drivers/regulator/da9062-regulator.c
@@ -98,6 +98,20 @@ static const unsigned int da9062_buck_b_limits[] = {
 	2300000, 2400000, 2500000, 2600000, 2700000, 2800000, 2900000, 3000000
 };
 
+static unsigned int da9062_map_buck_mode(unsigned int mode)
+{
+	switch (mode) {
+	case DA9063_BUCK_MODE_SLEEP:
+		return REGULATOR_MODE_STANDBY;
+	case DA9063_BUCK_MODE_SYNC:
+		return REGULATOR_MODE_FAST;
+	case DA9063_BUCK_MODE_AUTO:
+		return REGULATOR_MODE_NORMAL;
+	default:
+		return -EINVAL;
+	}
+}
+
 static int da9062_buck_set_mode(struct regulator_dev *rdev, unsigned mode)
 {
 	struct da9062_regulator *regl = rdev_get_drvdata(rdev);
@@ -360,6 +374,7 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
 		.desc.vsel_reg = DA9062AA_VBUCK1_A,
 		.desc.vsel_mask = DA9062AA_VBUCK1_A_MASK,
 		.desc.linear_min_sel = 0,
+		.desc.of_map_mode = da9062_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK1_A,
 			__builtin_ffs((int)DA9062AA_BUCK1_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
@@ -396,6 +411,7 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
 		.desc.vsel_reg = DA9062AA_VBUCK3_A,
 		.desc.vsel_mask = DA9062AA_VBUCK3_A_MASK,
 		.desc.linear_min_sel = 0,
+		.desc.of_map_mode = da9062_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK3_A,
 			__builtin_ffs((int)DA9062AA_BUCK3_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
@@ -432,6 +448,7 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
 		.desc.vsel_reg = DA9062AA_VBUCK4_A,
 		.desc.vsel_mask = DA9062AA_VBUCK4_A_MASK,
 		.desc.linear_min_sel = 0,
+		.desc.of_map_mode = da9062_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK4_A,
 			__builtin_ffs((int)DA9062AA_BUCK4_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
@@ -604,6 +621,7 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
 		.desc.vsel_reg = DA9062AA_VBUCK1_A,
 		.desc.vsel_mask = DA9062AA_VBUCK1_A_MASK,
 		.desc.linear_min_sel = 0,
+		.desc.of_map_mode = da9062_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK1_A,
 			__builtin_ffs((int)DA9062AA_BUCK1_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
@@ -640,6 +658,7 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
 		.desc.vsel_reg = DA9062AA_VBUCK2_A,
 		.desc.vsel_mask = DA9062AA_VBUCK2_A_MASK,
 		.desc.linear_min_sel = 0,
+		.desc.of_map_mode = da9062_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK2_A,
 			__builtin_ffs((int)DA9062AA_BUCK2_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
@@ -676,6 +695,7 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
 		.desc.vsel_reg = DA9062AA_VBUCK3_A,
 		.desc.vsel_mask = DA9062AA_VBUCK3_A_MASK,
 		.desc.linear_min_sel = 0,
+		.desc.of_map_mode = da9062_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK3_A,
 			__builtin_ffs((int)DA9062AA_BUCK3_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
@@ -712,6 +732,7 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
 		.desc.vsel_reg = DA9062AA_VBUCK4_A,
 		.desc.vsel_mask = DA9062AA_VBUCK4_A_MASK,
 		.desc.linear_min_sel = 0,
+		.desc.of_map_mode = da9062_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK4_A,
 			__builtin_ffs((int)DA9062AA_BUCK4_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
-- 
2.1.4


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

* [PATCH v2 3/4] dt-bindings: mfd: da9062: describe buck modes
  2019-11-13 13:40 [PATCH v2 0/4] regulator da9062: support setting buck modes Christoph Fritz
  2019-11-13 13:40 ` [PATCH v2 1/4] regulator: da9062: refactor buck modes into header Christoph Fritz
  2019-11-13 13:40 ` [PATCH v2 2/4] regulator: da9062: add of_map_mode support for bucks Christoph Fritz
@ 2019-11-13 13:40 ` Christoph Fritz
  2019-11-13 16:26   ` Adam Thomson
  2019-11-15 12:25   ` Applied "dt-bindings: mfd: da9062: describe buck modes" to the regulator tree Mark Brown
  2019-11-13 13:40 ` [PATCH v2 4/4] ARM: dts: phycore-imx6: set buck regulator modes explicitly Christoph Fritz
  3 siblings, 2 replies; 16+ messages in thread
From: Christoph Fritz @ 2019-11-13 13:40 UTC (permalink / raw)
  To: Adam Thomson, Mark Brown, Fabio Estevam, Rob Herring,
	Mark Rutland, Shawn Guo
  Cc: Lee Jones, Liam Girdwood, Support Opensource, devicetree,
	linux-arm-kernel

This patch adds DT description of da9062 buck regulator modes.

Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
---
 Documentation/devicetree/bindings/mfd/da9062.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/da9062.txt b/Documentation/devicetree/bindings/mfd/da9062.txt
index edca653..bc4b59d 100644
--- a/Documentation/devicetree/bindings/mfd/da9062.txt
+++ b/Documentation/devicetree/bindings/mfd/da9062.txt
@@ -66,6 +66,9 @@ Sub-nodes:
   details of individual regulator device can be found in:
   Documentation/devicetree/bindings/regulator/regulator.txt
 
+  regulator-initial-mode may be specified for buck regulators using mode values
+  from include/dt-bindings/regulator/dlg,da9063-regulator.h.
+
 - rtc : This node defines settings required for the Real-Time Clock associated
   with the DA9062. There are currently no entries in this binding, however
   compatible = "dlg,da9062-rtc" should be added if a node is created.
@@ -96,6 +99,7 @@ Example:
 				regulator-max-microvolt = <1570000>;
 				regulator-min-microamp = <500000>;
 				regulator-max-microamp = <2000000>;
+				regulator-initial-mode = <DA9063_BUCK_MODE_SYNC>;
 				regulator-boot-on;
 			};
 			DA9062_LDO1: ldo1 {
-- 
2.1.4


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

* [PATCH v2 4/4] ARM: dts: phycore-imx6: set buck regulator modes explicitly
  2019-11-13 13:40 [PATCH v2 0/4] regulator da9062: support setting buck modes Christoph Fritz
                   ` (2 preceding siblings ...)
  2019-11-13 13:40 ` [PATCH v2 3/4] dt-bindings: mfd: da9062: describe buck modes Christoph Fritz
@ 2019-11-13 13:40 ` Christoph Fritz
  2019-11-13 16:26   ` Adam Thomson
  3 siblings, 1 reply; 16+ messages in thread
From: Christoph Fritz @ 2019-11-13 13:40 UTC (permalink / raw)
  To: Adam Thomson, Mark Brown, Fabio Estevam, Rob Herring,
	Mark Rutland, Shawn Guo
  Cc: Lee Jones, Liam Girdwood, Support Opensource, devicetree,
	linux-arm-kernel

This patch sets initial buck regulator modes explicitly to a state this
hardware needs. So a wrong initial mode set by bootloader or pmic itself
does not interfere anymore.

Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
---
 arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi b/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi
index 6486df3..644625d 100644
--- a/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi
@@ -5,6 +5,7 @@
  */
 
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/regulator/dlg,da9063-regulator.h>
 
 / {
 	aliases {
@@ -109,6 +110,7 @@
 				regulator-name = "vdd_arm";
 				regulator-min-microvolt = <730000>;
 				regulator-max-microvolt = <1380000>;
+				regulator-initial-mode = <DA9063_BUCK_MODE_SYNC>;
 				regulator-always-on;
 			};
 
@@ -116,6 +118,7 @@
 				regulator-name = "vdd_soc";
 				regulator-min-microvolt = <730000>;
 				regulator-max-microvolt = <1380000>;
+				regulator-initial-mode = <DA9063_BUCK_MODE_SYNC>;
 				regulator-always-on;
 			};
 
@@ -123,6 +126,7 @@
 				regulator-name = "vdd_ddr3";
 				regulator-min-microvolt = <1500000>;
 				regulator-max-microvolt = <1500000>;
+				regulator-initial-mode = <DA9063_BUCK_MODE_SYNC>;
 				regulator-always-on;
 			};
 
@@ -130,6 +134,7 @@
 				regulator-name = "vdd_eth";
 				regulator-min-microvolt = <1200000>;
 				regulator-max-microvolt = <1200000>;
+				regulator-initial-mode = <DA9063_BUCK_MODE_SYNC>;
 				regulator-always-on;
 			};
 
-- 
2.1.4


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

* RE: [PATCH v2 1/4] regulator: da9062: refactor buck modes into header
  2019-11-13 13:40 ` [PATCH v2 1/4] regulator: da9062: refactor buck modes into header Christoph Fritz
@ 2019-11-13 16:19   ` Adam Thomson
  2019-11-15 12:25   ` Applied "regulator: da9062: refactor buck modes into header" to the regulator tree Mark Brown
  1 sibling, 0 replies; 16+ messages in thread
From: Adam Thomson @ 2019-11-13 16:19 UTC (permalink / raw)
  To: Christoph Fritz, Adam Thomson, Mark Brown, Fabio Estevam,
	Rob Herring, Mark Rutland, Shawn Guo
  Cc: Lee Jones, Liam Girdwood, Support Opensource, devicetree,
	linux-arm-kernel

On 13 November 2019 13:40, Christoph Fritz wrote:

> This patch refactors buck modes into a header file so that device trees
> can make use of these mode constants.
> 
> The new header filename uses da9063 because DA9063 was the earlier chip
> and its driver code will want updating at some point in a similar manner.
> 
> Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>

Reviewed-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>

> ---
>  drivers/regulator/da9062-regulator.c               | 28 ++++++++--------------
>  .../dt-bindings/regulator/dlg,da9063-regulator.h   | 16 +++++++++++++
>  2 files changed, 26 insertions(+), 18 deletions(-)
>  create mode 100644 include/dt-bindings/regulator/dlg,da9063-regulator.h
> 
> diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-
> regulator.c
> index 4b24518..601002e 100644
> --- a/drivers/regulator/da9062-regulator.c
> +++ b/drivers/regulator/da9062-regulator.c
> @@ -16,6 +16,7 @@
>  #include <linux/regulator/of_regulator.h>
>  #include <linux/mfd/da9062/core.h>
>  #include <linux/mfd/da9062/registers.h>
> +#include <dt-bindings/regulator/dlg,da9063-regulator.h>
> 
>  /* Regulator IDs */
>  enum {
> @@ -75,14 +76,6 @@ struct da9062_regulators {
>  	struct da9062_regulator			regulator[0];
>  };
> 
> -/* BUCK modes */
> -enum {
> -	BUCK_MODE_MANUAL,	/* 0 */
> -	BUCK_MODE_SLEEP,	/* 1 */
> -	BUCK_MODE_SYNC,		/* 2 */
> -	BUCK_MODE_AUTO		/* 3 */
> -};
> -
>  /* Regulator operations */
> 
>  /* Current limits array (in uA)
> @@ -112,13 +105,13 @@ static int da9062_buck_set_mode(struct regulator_dev
> *rdev, unsigned mode)
> 
>  	switch (mode) {
>  	case REGULATOR_MODE_FAST:
> -		val = BUCK_MODE_SYNC;
> +		val = DA9063_BUCK_MODE_SYNC;
>  		break;
>  	case REGULATOR_MODE_NORMAL:
> -		val = BUCK_MODE_AUTO;
> +		val = DA9063_BUCK_MODE_AUTO;
>  		break;
>  	case REGULATOR_MODE_STANDBY:
> -		val = BUCK_MODE_SLEEP;
> +		val = DA9063_BUCK_MODE_SLEEP;
>  		break;
>  	default:
>  		return -EINVAL;
> @@ -145,14 +138,13 @@ static unsigned da9062_buck_get_mode(struct
> regulator_dev *rdev)
> 
>  	switch (val) {
>  	default:
> -	case BUCK_MODE_MANUAL:
>  		/* Sleep flag bit decides the mode */
>  		break;
> -	case BUCK_MODE_SLEEP:
> +	case DA9063_BUCK_MODE_SLEEP:
>  		return REGULATOR_MODE_STANDBY;
> -	case BUCK_MODE_SYNC:
> +	case DA9063_BUCK_MODE_SYNC:
>  		return REGULATOR_MODE_FAST;
> -	case BUCK_MODE_AUTO:
> +	case DA9063_BUCK_MODE_AUTO:
>  		return REGULATOR_MODE_NORMAL;
>  	}
> 
> @@ -279,13 +271,13 @@ static int da9062_buck_set_suspend_mode(struct
> regulator_dev *rdev,
> 
>  	switch (mode) {
>  	case REGULATOR_MODE_FAST:
> -		val = BUCK_MODE_SYNC;
> +		val = DA9063_BUCK_MODE_SYNC;
>  		break;
>  	case REGULATOR_MODE_NORMAL:
> -		val = BUCK_MODE_AUTO;
> +		val = DA9063_BUCK_MODE_AUTO;
>  		break;
>  	case REGULATOR_MODE_STANDBY:
> -		val = BUCK_MODE_SLEEP;
> +		val = DA9063_BUCK_MODE_SLEEP;
>  		break;
>  	default:
>  		return -EINVAL;
> diff --git a/include/dt-bindings/regulator/dlg,da9063-regulator.h b/include/dt-
> bindings/regulator/dlg,da9063-regulator.h
> new file mode 100644
> index 00000000..1de710d
> --- /dev/null
> +++ b/include/dt-bindings/regulator/dlg,da9063-regulator.h
> @@ -0,0 +1,16 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +
> +#ifndef _DT_BINDINGS_REGULATOR_DLG_DA9063_H
> +#define _DT_BINDINGS_REGULATOR_DLG_DA9063_H
> +
> +/*
> + * These buck mode constants may be used to specify values in device tree
> + * properties (e.g. regulator-initial-mode).
> + * A description of the following modes is in the manufacturers datasheet.
> + */
> +
> +#define DA9063_BUCK_MODE_SLEEP		1
> +#define DA9063_BUCK_MODE_SYNC		2
> +#define DA9063_BUCK_MODE_AUTO		3
> +
> +#endif
> --
> 2.1.4


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

* RE: [PATCH v2 2/4] regulator: da9062: add of_map_mode support for bucks
  2019-11-13 13:40 ` [PATCH v2 2/4] regulator: da9062: add of_map_mode support for bucks Christoph Fritz
@ 2019-11-13 16:24   ` Adam Thomson
  2019-11-15 12:25   ` Applied "regulator: da9062: add of_map_mode support for bucks" to the regulator tree Mark Brown
  1 sibling, 0 replies; 16+ messages in thread
From: Adam Thomson @ 2019-11-13 16:24 UTC (permalink / raw)
  To: Christoph Fritz, Adam Thomson, Mark Brown, Fabio Estevam,
	Rob Herring, Mark Rutland, Shawn Guo
  Cc: Lee Jones, Liam Girdwood, Support Opensource, devicetree,
	linux-arm-kernel, Christian Hemp, Stefan Riedmueller

On 13 November 2019 13:40, Christoph Fritz wrote:

> This patch adds of_map_mode support for bucks to set regulator modes
> from within regulator framework.
> 
> Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
> Signed-off-by: Christian Hemp <c.hemp@phytec.de>
> Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>

Reviewed-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>

> ---
>  drivers/regulator/da9062-regulator.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-
> regulator.c
> index 601002e..29f4a60 100644
> --- a/drivers/regulator/da9062-regulator.c
> +++ b/drivers/regulator/da9062-regulator.c
> @@ -98,6 +98,20 @@ static const unsigned int da9062_buck_b_limits[] = {
>  	2300000, 2400000, 2500000, 2600000, 2700000, 2800000, 2900000, 3000000
>  };
> 
> +static unsigned int da9062_map_buck_mode(unsigned int mode)
> +{
> +	switch (mode) {
> +	case DA9063_BUCK_MODE_SLEEP:
> +		return REGULATOR_MODE_STANDBY;
> +	case DA9063_BUCK_MODE_SYNC:
> +		return REGULATOR_MODE_FAST;
> +	case DA9063_BUCK_MODE_AUTO:
> +		return REGULATOR_MODE_NORMAL;
> +	default:
> +		return -EINVAL;
> +	}
> +}
> +
>  static int da9062_buck_set_mode(struct regulator_dev *rdev, unsigned mode)
>  {
>  	struct da9062_regulator *regl = rdev_get_drvdata(rdev);
> @@ -360,6 +374,7 @@ static const struct da9062_regulator_info
> local_da9061_regulator_info[] = {
>  		.desc.vsel_reg = DA9062AA_VBUCK1_A,
>  		.desc.vsel_mask = DA9062AA_VBUCK1_A_MASK,
>  		.desc.linear_min_sel = 0,
> +		.desc.of_map_mode = da9062_map_buck_mode,
>  		.sleep = REG_FIELD(DA9062AA_VBUCK1_A,
>  			__builtin_ffs((int)DA9062AA_BUCK1_SL_A_MASK) - 1,
>  			sizeof(unsigned int) * 8 -
> @@ -396,6 +411,7 @@ static const struct da9062_regulator_info
> local_da9061_regulator_info[] = {
>  		.desc.vsel_reg = DA9062AA_VBUCK3_A,
>  		.desc.vsel_mask = DA9062AA_VBUCK3_A_MASK,
>  		.desc.linear_min_sel = 0,
> +		.desc.of_map_mode = da9062_map_buck_mode,
>  		.sleep = REG_FIELD(DA9062AA_VBUCK3_A,
>  			__builtin_ffs((int)DA9062AA_BUCK3_SL_A_MASK) - 1,
>  			sizeof(unsigned int) * 8 -
> @@ -432,6 +448,7 @@ static const struct da9062_regulator_info
> local_da9061_regulator_info[] = {
>  		.desc.vsel_reg = DA9062AA_VBUCK4_A,
>  		.desc.vsel_mask = DA9062AA_VBUCK4_A_MASK,
>  		.desc.linear_min_sel = 0,
> +		.desc.of_map_mode = da9062_map_buck_mode,
>  		.sleep = REG_FIELD(DA9062AA_VBUCK4_A,
>  			__builtin_ffs((int)DA9062AA_BUCK4_SL_A_MASK) - 1,
>  			sizeof(unsigned int) * 8 -
> @@ -604,6 +621,7 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
>  		.desc.vsel_reg = DA9062AA_VBUCK1_A,
>  		.desc.vsel_mask = DA9062AA_VBUCK1_A_MASK,
>  		.desc.linear_min_sel = 0,
> +		.desc.of_map_mode = da9062_map_buck_mode,
>  		.sleep = REG_FIELD(DA9062AA_VBUCK1_A,
>  			__builtin_ffs((int)DA9062AA_BUCK1_SL_A_MASK) - 1,
>  			sizeof(unsigned int) * 8 -
> @@ -640,6 +658,7 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
>  		.desc.vsel_reg = DA9062AA_VBUCK2_A,
>  		.desc.vsel_mask = DA9062AA_VBUCK2_A_MASK,
>  		.desc.linear_min_sel = 0,
> +		.desc.of_map_mode = da9062_map_buck_mode,
>  		.sleep = REG_FIELD(DA9062AA_VBUCK2_A,
>  			__builtin_ffs((int)DA9062AA_BUCK2_SL_A_MASK) - 1,
>  			sizeof(unsigned int) * 8 -
> @@ -676,6 +695,7 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
>  		.desc.vsel_reg = DA9062AA_VBUCK3_A,
>  		.desc.vsel_mask = DA9062AA_VBUCK3_A_MASK,
>  		.desc.linear_min_sel = 0,
> +		.desc.of_map_mode = da9062_map_buck_mode,
>  		.sleep = REG_FIELD(DA9062AA_VBUCK3_A,
>  			__builtin_ffs((int)DA9062AA_BUCK3_SL_A_MASK) - 1,
>  			sizeof(unsigned int) * 8 -
> @@ -712,6 +732,7 @@ static const struct da9062_regulator_info
> local_da9062_regulator_info[] = {
>  		.desc.vsel_reg = DA9062AA_VBUCK4_A,
>  		.desc.vsel_mask = DA9062AA_VBUCK4_A_MASK,
>  		.desc.linear_min_sel = 0,
> +		.desc.of_map_mode = da9062_map_buck_mode,
>  		.sleep = REG_FIELD(DA9062AA_VBUCK4_A,
>  			__builtin_ffs((int)DA9062AA_BUCK4_SL_A_MASK) - 1,
>  			sizeof(unsigned int) * 8 -
> --
> 2.1.4


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

* RE: [PATCH v2 3/4] dt-bindings: mfd: da9062: describe buck modes
  2019-11-13 13:40 ` [PATCH v2 3/4] dt-bindings: mfd: da9062: describe buck modes Christoph Fritz
@ 2019-11-13 16:26   ` Adam Thomson
  2019-11-15 12:25   ` Applied "dt-bindings: mfd: da9062: describe buck modes" to the regulator tree Mark Brown
  1 sibling, 0 replies; 16+ messages in thread
From: Adam Thomson @ 2019-11-13 16:26 UTC (permalink / raw)
  To: Christoph Fritz, Adam Thomson, Mark Brown, Fabio Estevam,
	Rob Herring, Mark Rutland, Shawn Guo
  Cc: Lee Jones, Liam Girdwood, Support Opensource, devicetree,
	linux-arm-kernel

On 13 November 2019 13:40, Christoph Fritz wrote:

> This patch adds DT description of da9062 buck regulator modes.
> 
> Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>

Reviewed-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>

> ---
>  Documentation/devicetree/bindings/mfd/da9062.txt | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/da9062.txt
> b/Documentation/devicetree/bindings/mfd/da9062.txt
> index edca653..bc4b59d 100644
> --- a/Documentation/devicetree/bindings/mfd/da9062.txt
> +++ b/Documentation/devicetree/bindings/mfd/da9062.txt
> @@ -66,6 +66,9 @@ Sub-nodes:
>    details of individual regulator device can be found in:
>    Documentation/devicetree/bindings/regulator/regulator.txt
> 
> +  regulator-initial-mode may be specified for buck regulators using mode values
> +  from include/dt-bindings/regulator/dlg,da9063-regulator.h.
> +
>  - rtc : This node defines settings required for the Real-Time Clock associated
>    with the DA9062. There are currently no entries in this binding, however
>    compatible = "dlg,da9062-rtc" should be added if a node is created.
> @@ -96,6 +99,7 @@ Example:
>  				regulator-max-microvolt = <1570000>;
>  				regulator-min-microamp = <500000>;
>  				regulator-max-microamp = <2000000>;
> +				regulator-initial-mode =
> <DA9063_BUCK_MODE_SYNC>;
>  				regulator-boot-on;
>  			};
>  			DA9062_LDO1: ldo1 {
> --
> 2.1.4


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

* RE: [PATCH v2 4/4] ARM: dts: phycore-imx6: set buck regulator modes explicitly
  2019-11-13 13:40 ` [PATCH v2 4/4] ARM: dts: phycore-imx6: set buck regulator modes explicitly Christoph Fritz
@ 2019-11-13 16:26   ` Adam Thomson
  2019-11-28 20:30     ` Christoph Fritz
  0 siblings, 1 reply; 16+ messages in thread
From: Adam Thomson @ 2019-11-13 16:26 UTC (permalink / raw)
  To: Christoph Fritz, Adam Thomson, Mark Brown, Fabio Estevam,
	Rob Herring, Mark Rutland, Shawn Guo
  Cc: Lee Jones, Liam Girdwood, Support Opensource, devicetree,
	linux-arm-kernel

On 13 November 2019 13:40, Christoph Fritz wrote:

> This patch sets initial buck regulator modes explicitly to a state this
> hardware needs. So a wrong initial mode set by bootloader or pmic itself
> does not interfere anymore.
> 
> Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>

Reviewed-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>

> ---
>  arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi
> b/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi
> index 6486df3..644625d 100644
> --- a/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi
> +++ b/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi
> @@ -5,6 +5,7 @@
>   */
> 
>  #include <dt-bindings/gpio/gpio.h>
> +#include <dt-bindings/regulator/dlg,da9063-regulator.h>
> 
>  / {
>  	aliases {
> @@ -109,6 +110,7 @@
>  				regulator-name = "vdd_arm";
>  				regulator-min-microvolt = <730000>;
>  				regulator-max-microvolt = <1380000>;
> +				regulator-initial-mode =
> <DA9063_BUCK_MODE_SYNC>;
>  				regulator-always-on;
>  			};
> 
> @@ -116,6 +118,7 @@
>  				regulator-name = "vdd_soc";
>  				regulator-min-microvolt = <730000>;
>  				regulator-max-microvolt = <1380000>;
> +				regulator-initial-mode =
> <DA9063_BUCK_MODE_SYNC>;
>  				regulator-always-on;
>  			};
> 
> @@ -123,6 +126,7 @@
>  				regulator-name = "vdd_ddr3";
>  				regulator-min-microvolt = <1500000>;
>  				regulator-max-microvolt = <1500000>;
> +				regulator-initial-mode =
> <DA9063_BUCK_MODE_SYNC>;
>  				regulator-always-on;
>  			};
> 
> @@ -130,6 +134,7 @@
>  				regulator-name = "vdd_eth";
>  				regulator-min-microvolt = <1200000>;
>  				regulator-max-microvolt = <1200000>;
> +				regulator-initial-mode =
> <DA9063_BUCK_MODE_SYNC>;
>  				regulator-always-on;
>  			};
> 
> --
> 2.1.4


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

* Applied "regulator: da9062: refactor buck modes into header" to the regulator tree
  2019-11-13 13:40 ` [PATCH v2 1/4] regulator: da9062: refactor buck modes into header Christoph Fritz
  2019-11-13 16:19   ` Adam Thomson
@ 2019-11-15 12:25   ` Mark Brown
  1 sibling, 0 replies; 16+ messages in thread
From: Mark Brown @ 2019-11-15 12:25 UTC (permalink / raw)
  To: Christoph Fritz
  Cc: Adam Thomson, devicetree, Fabio Estevam, Lee Jones,
	Liam Girdwood, linux-arm-kernel, linux-kernel, Mark Brown,
	Mark Rutland, Rob Herring, Shawn Guo, Support Opensource

The patch

   regulator: da9062: refactor buck modes into header

has been applied to the regulator tree at

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

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

From 7d34aec52d292197d6b13395b023c718cac4630f Mon Sep 17 00:00:00 2001
From: Christoph Fritz <chf.fritz@googlemail.com>
Date: Wed, 13 Nov 2019 14:40:13 +0100
Subject: [PATCH] regulator: da9062: refactor buck modes into header

This patch refactors buck modes into a header file so that device trees
can make use of these mode constants.

The new header filename uses da9063 because DA9063 was the earlier chip
and its driver code will want updating at some point in a similar manner.

Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
Link: https://lore.kernel.org/r/1573652416-9848-2-git-send-email-chf.fritz@googlemail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/regulator/da9062-regulator.c          | 28 +++++++------------
 .../regulator/dlg,da9063-regulator.h          | 16 +++++++++++
 2 files changed, 26 insertions(+), 18 deletions(-)
 create mode 100644 include/dt-bindings/regulator/dlg,da9063-regulator.h

diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-regulator.c
index 4b24518f75b5..601002e3e012 100644
--- a/drivers/regulator/da9062-regulator.c
+++ b/drivers/regulator/da9062-regulator.c
@@ -16,6 +16,7 @@
 #include <linux/regulator/of_regulator.h>
 #include <linux/mfd/da9062/core.h>
 #include <linux/mfd/da9062/registers.h>
+#include <dt-bindings/regulator/dlg,da9063-regulator.h>
 
 /* Regulator IDs */
 enum {
@@ -75,14 +76,6 @@ struct da9062_regulators {
 	struct da9062_regulator			regulator[0];
 };
 
-/* BUCK modes */
-enum {
-	BUCK_MODE_MANUAL,	/* 0 */
-	BUCK_MODE_SLEEP,	/* 1 */
-	BUCK_MODE_SYNC,		/* 2 */
-	BUCK_MODE_AUTO		/* 3 */
-};
-
 /* Regulator operations */
 
 /* Current limits array (in uA)
@@ -112,13 +105,13 @@ static int da9062_buck_set_mode(struct regulator_dev *rdev, unsigned mode)
 
 	switch (mode) {
 	case REGULATOR_MODE_FAST:
-		val = BUCK_MODE_SYNC;
+		val = DA9063_BUCK_MODE_SYNC;
 		break;
 	case REGULATOR_MODE_NORMAL:
-		val = BUCK_MODE_AUTO;
+		val = DA9063_BUCK_MODE_AUTO;
 		break;
 	case REGULATOR_MODE_STANDBY:
-		val = BUCK_MODE_SLEEP;
+		val = DA9063_BUCK_MODE_SLEEP;
 		break;
 	default:
 		return -EINVAL;
@@ -145,14 +138,13 @@ static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
 
 	switch (val) {
 	default:
-	case BUCK_MODE_MANUAL:
 		/* Sleep flag bit decides the mode */
 		break;
-	case BUCK_MODE_SLEEP:
+	case DA9063_BUCK_MODE_SLEEP:
 		return REGULATOR_MODE_STANDBY;
-	case BUCK_MODE_SYNC:
+	case DA9063_BUCK_MODE_SYNC:
 		return REGULATOR_MODE_FAST;
-	case BUCK_MODE_AUTO:
+	case DA9063_BUCK_MODE_AUTO:
 		return REGULATOR_MODE_NORMAL;
 	}
 
@@ -279,13 +271,13 @@ static int da9062_buck_set_suspend_mode(struct regulator_dev *rdev,
 
 	switch (mode) {
 	case REGULATOR_MODE_FAST:
-		val = BUCK_MODE_SYNC;
+		val = DA9063_BUCK_MODE_SYNC;
 		break;
 	case REGULATOR_MODE_NORMAL:
-		val = BUCK_MODE_AUTO;
+		val = DA9063_BUCK_MODE_AUTO;
 		break;
 	case REGULATOR_MODE_STANDBY:
-		val = BUCK_MODE_SLEEP;
+		val = DA9063_BUCK_MODE_SLEEP;
 		break;
 	default:
 		return -EINVAL;
diff --git a/include/dt-bindings/regulator/dlg,da9063-regulator.h b/include/dt-bindings/regulator/dlg,da9063-regulator.h
new file mode 100644
index 000000000000..1de710dd0899
--- /dev/null
+++ b/include/dt-bindings/regulator/dlg,da9063-regulator.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _DT_BINDINGS_REGULATOR_DLG_DA9063_H
+#define _DT_BINDINGS_REGULATOR_DLG_DA9063_H
+
+/*
+ * These buck mode constants may be used to specify values in device tree
+ * properties (e.g. regulator-initial-mode).
+ * A description of the following modes is in the manufacturers datasheet.
+ */
+
+#define DA9063_BUCK_MODE_SLEEP		1
+#define DA9063_BUCK_MODE_SYNC		2
+#define DA9063_BUCK_MODE_AUTO		3
+
+#endif
-- 
2.20.1


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

* Applied "regulator: da9062: add of_map_mode support for bucks" to the regulator tree
  2019-11-13 13:40 ` [PATCH v2 2/4] regulator: da9062: add of_map_mode support for bucks Christoph Fritz
  2019-11-13 16:24   ` Adam Thomson
@ 2019-11-15 12:25   ` Mark Brown
  1 sibling, 0 replies; 16+ messages in thread
From: Mark Brown @ 2019-11-15 12:25 UTC (permalink / raw)
  To: Christoph Fritz
  Cc: Adam Thomson, Christian Hemp, devicetree, Fabio Estevam,
	Lee Jones, Liam Girdwood, linux-arm-kernel, linux-kernel,
	Mark Brown, Mark Rutland, Rob Herring, Shawn Guo,
	Stefan Riedmueller, Support Opensource

The patch

   regulator: da9062: add of_map_mode support for bucks

has been applied to the regulator tree at

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

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

From 844e7492ee3da1a8714bf3cc1dd54d777a5257c2 Mon Sep 17 00:00:00 2001
From: Christoph Fritz <chf.fritz@googlemail.com>
Date: Wed, 13 Nov 2019 14:40:14 +0100
Subject: [PATCH] regulator: da9062: add of_map_mode support for bucks

This patch adds of_map_mode support for bucks to set regulator modes
from within regulator framework.

Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
Signed-off-by: Christian Hemp <c.hemp@phytec.de>
Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
Link: https://lore.kernel.org/r/1573652416-9848-3-git-send-email-chf.fritz@googlemail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/regulator/da9062-regulator.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-regulator.c
index 601002e3e012..29f4a60398a3 100644
--- a/drivers/regulator/da9062-regulator.c
+++ b/drivers/regulator/da9062-regulator.c
@@ -98,6 +98,20 @@ static const unsigned int da9062_buck_b_limits[] = {
 	2300000, 2400000, 2500000, 2600000, 2700000, 2800000, 2900000, 3000000
 };
 
+static unsigned int da9062_map_buck_mode(unsigned int mode)
+{
+	switch (mode) {
+	case DA9063_BUCK_MODE_SLEEP:
+		return REGULATOR_MODE_STANDBY;
+	case DA9063_BUCK_MODE_SYNC:
+		return REGULATOR_MODE_FAST;
+	case DA9063_BUCK_MODE_AUTO:
+		return REGULATOR_MODE_NORMAL;
+	default:
+		return -EINVAL;
+	}
+}
+
 static int da9062_buck_set_mode(struct regulator_dev *rdev, unsigned mode)
 {
 	struct da9062_regulator *regl = rdev_get_drvdata(rdev);
@@ -360,6 +374,7 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
 		.desc.vsel_reg = DA9062AA_VBUCK1_A,
 		.desc.vsel_mask = DA9062AA_VBUCK1_A_MASK,
 		.desc.linear_min_sel = 0,
+		.desc.of_map_mode = da9062_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK1_A,
 			__builtin_ffs((int)DA9062AA_BUCK1_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
@@ -396,6 +411,7 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
 		.desc.vsel_reg = DA9062AA_VBUCK3_A,
 		.desc.vsel_mask = DA9062AA_VBUCK3_A_MASK,
 		.desc.linear_min_sel = 0,
+		.desc.of_map_mode = da9062_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK3_A,
 			__builtin_ffs((int)DA9062AA_BUCK3_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
@@ -432,6 +448,7 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
 		.desc.vsel_reg = DA9062AA_VBUCK4_A,
 		.desc.vsel_mask = DA9062AA_VBUCK4_A_MASK,
 		.desc.linear_min_sel = 0,
+		.desc.of_map_mode = da9062_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK4_A,
 			__builtin_ffs((int)DA9062AA_BUCK4_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
@@ -604,6 +621,7 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
 		.desc.vsel_reg = DA9062AA_VBUCK1_A,
 		.desc.vsel_mask = DA9062AA_VBUCK1_A_MASK,
 		.desc.linear_min_sel = 0,
+		.desc.of_map_mode = da9062_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK1_A,
 			__builtin_ffs((int)DA9062AA_BUCK1_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
@@ -640,6 +658,7 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
 		.desc.vsel_reg = DA9062AA_VBUCK2_A,
 		.desc.vsel_mask = DA9062AA_VBUCK2_A_MASK,
 		.desc.linear_min_sel = 0,
+		.desc.of_map_mode = da9062_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK2_A,
 			__builtin_ffs((int)DA9062AA_BUCK2_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
@@ -676,6 +695,7 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
 		.desc.vsel_reg = DA9062AA_VBUCK3_A,
 		.desc.vsel_mask = DA9062AA_VBUCK3_A_MASK,
 		.desc.linear_min_sel = 0,
+		.desc.of_map_mode = da9062_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK3_A,
 			__builtin_ffs((int)DA9062AA_BUCK3_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
@@ -712,6 +732,7 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
 		.desc.vsel_reg = DA9062AA_VBUCK4_A,
 		.desc.vsel_mask = DA9062AA_VBUCK4_A_MASK,
 		.desc.linear_min_sel = 0,
+		.desc.of_map_mode = da9062_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK4_A,
 			__builtin_ffs((int)DA9062AA_BUCK4_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
-- 
2.20.1


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

* Applied "dt-bindings: mfd: da9062: describe buck modes" to the regulator tree
  2019-11-13 13:40 ` [PATCH v2 3/4] dt-bindings: mfd: da9062: describe buck modes Christoph Fritz
  2019-11-13 16:26   ` Adam Thomson
@ 2019-11-15 12:25   ` Mark Brown
  1 sibling, 0 replies; 16+ messages in thread
From: Mark Brown @ 2019-11-15 12:25 UTC (permalink / raw)
  To: Christoph Fritz
  Cc: Adam Thomson, devicetree, Fabio Estevam, Lee Jones,
	Liam Girdwood, linux-arm-kernel, linux-kernel, Mark Brown,
	Mark Rutland, Rob Herring, Shawn Guo, Support Opensource

The patch

   dt-bindings: mfd: da9062: describe buck modes

has been applied to the regulator tree at

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

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

From a4bb429811bd4a5be94873ae218062c83c476ed9 Mon Sep 17 00:00:00 2001
From: Christoph Fritz <chf.fritz@googlemail.com>
Date: Wed, 13 Nov 2019 14:40:15 +0100
Subject: [PATCH] dt-bindings: mfd: da9062: describe buck modes

This patch adds DT description of da9062 buck regulator modes.

Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
Link: https://lore.kernel.org/r/1573652416-9848-4-git-send-email-chf.fritz@googlemail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 Documentation/devicetree/bindings/mfd/da9062.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/da9062.txt b/Documentation/devicetree/bindings/mfd/da9062.txt
index edca653a5777..bc4b59de6a55 100644
--- a/Documentation/devicetree/bindings/mfd/da9062.txt
+++ b/Documentation/devicetree/bindings/mfd/da9062.txt
@@ -66,6 +66,9 @@ Sub-nodes:
   details of individual regulator device can be found in:
   Documentation/devicetree/bindings/regulator/regulator.txt
 
+  regulator-initial-mode may be specified for buck regulators using mode values
+  from include/dt-bindings/regulator/dlg,da9063-regulator.h.
+
 - rtc : This node defines settings required for the Real-Time Clock associated
   with the DA9062. There are currently no entries in this binding, however
   compatible = "dlg,da9062-rtc" should be added if a node is created.
@@ -96,6 +99,7 @@ Example:
 				regulator-max-microvolt = <1570000>;
 				regulator-min-microamp = <500000>;
 				regulator-max-microamp = <2000000>;
+				regulator-initial-mode = <DA9063_BUCK_MODE_SYNC>;
 				regulator-boot-on;
 			};
 			DA9062_LDO1: ldo1 {
-- 
2.20.1


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

* Re: [PATCH v2 4/4] ARM: dts: phycore-imx6: set buck regulator modes explicitly
  2019-11-13 16:26   ` Adam Thomson
@ 2019-11-28 20:30     ` Christoph Fritz
  2019-12-04 12:53       ` Shawn Guo
  0 siblings, 1 reply; 16+ messages in thread
From: Christoph Fritz @ 2019-11-28 20:30 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Adam Thomson, Mark Brown, Fabio Estevam, Rob Herring,
	Mark Rutland, Lee Jones, Liam Girdwood, Support Opensource,
	devicetree, linux-arm-kernel

Hi Shawn,

 any chance to get this patch queued for the upcoming kernel?

bye
 -- Christoph

On Wed, 2019-11-13 at 16:26 +0000, Adam Thomson wrote:
> On 13 November 2019 13:40, Christoph Fritz wrote:
> 
> > This patch sets initial buck regulator modes explicitly to a state this
> > hardware needs. So a wrong initial mode set by bootloader or pmic itself
> > does not interfere anymore.
> > 
> > Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
> 
> Reviewed-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> 
> > ---
> >  arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi
> > b/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi
> > index 6486df3..644625d 100644
> > --- a/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi
> > +++ b/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi
> > @@ -5,6 +5,7 @@
> >   */
> > 
> >  #include <dt-bindings/gpio/gpio.h>
> > +#include <dt-bindings/regulator/dlg,da9063-regulator.h>
> > 
> >  / {
> >  	aliases {
> > @@ -109,6 +110,7 @@
> >  				regulator-name = "vdd_arm";
> >  				regulator-min-microvolt = <730000>;
> >  				regulator-max-microvolt = <1380000>;
> > +				regulator-initial-mode =
> > <DA9063_BUCK_MODE_SYNC>;
> >  				regulator-always-on;
> >  			};
> > 
> > @@ -116,6 +118,7 @@
> >  				regulator-name = "vdd_soc";
> >  				regulator-min-microvolt = <730000>;
> >  				regulator-max-microvolt = <1380000>;
> > +				regulator-initial-mode =
> > <DA9063_BUCK_MODE_SYNC>;
> >  				regulator-always-on;
> >  			};
> > 
> > @@ -123,6 +126,7 @@
> >  				regulator-name = "vdd_ddr3";
> >  				regulator-min-microvolt = <1500000>;
> >  				regulator-max-microvolt = <1500000>;
> > +				regulator-initial-mode =
> > <DA9063_BUCK_MODE_SYNC>;
> >  				regulator-always-on;
> >  			};
> > 
> > @@ -130,6 +134,7 @@
> >  				regulator-name = "vdd_eth";
> >  				regulator-min-microvolt = <1200000>;
> >  				regulator-max-microvolt = <1200000>;
> > +				regulator-initial-mode =
> > <DA9063_BUCK_MODE_SYNC>;
> >  				regulator-always-on;
> >  			};
> > 
> > --
> > 2.1.4
> 




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

* Re: [PATCH v2 4/4] ARM: dts: phycore-imx6: set buck regulator modes explicitly
  2019-11-28 20:30     ` Christoph Fritz
@ 2019-12-04 12:53       ` Shawn Guo
  2019-12-11 18:56         ` Christoph Fritz
  0 siblings, 1 reply; 16+ messages in thread
From: Shawn Guo @ 2019-12-04 12:53 UTC (permalink / raw)
  To: Christoph Fritz
  Cc: Adam Thomson, Mark Brown, Fabio Estevam, Rob Herring,
	Mark Rutland, Lee Jones, Liam Girdwood, Support Opensource,
	devicetree, linux-arm-kernel

On Thu, Nov 28, 2019 at 09:30:44PM +0100, Christoph Fritz wrote:
> Hi Shawn,
> 
>  any chance to get this patch queued for the upcoming kernel?

Sorry, no.  I need to wait for DA9063_BUCK_MODE_SYNC landing on 5.5-rc1,
and then apply this DTS patch.

Shawn

> 
> bye
>  -- Christoph
> 
> On Wed, 2019-11-13 at 16:26 +0000, Adam Thomson wrote:
> > On 13 November 2019 13:40, Christoph Fritz wrote:
> > 
> > > This patch sets initial buck regulator modes explicitly to a state this
> > > hardware needs. So a wrong initial mode set by bootloader or pmic itself
> > > does not interfere anymore.
> > > 
> > > Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
> > 
> > Reviewed-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> > 
> > > ---
> > >  arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi | 5 +++++
> > >  1 file changed, 5 insertions(+)
> > > 
> > > diff --git a/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi
> > > b/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi
> > > index 6486df3..644625d 100644
> > > --- a/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi
> > > +++ b/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi
> > > @@ -5,6 +5,7 @@
> > >   */
> > > 
> > >  #include <dt-bindings/gpio/gpio.h>
> > > +#include <dt-bindings/regulator/dlg,da9063-regulator.h>
> > > 
> > >  / {
> > >  	aliases {
> > > @@ -109,6 +110,7 @@
> > >  				regulator-name = "vdd_arm";
> > >  				regulator-min-microvolt = <730000>;
> > >  				regulator-max-microvolt = <1380000>;
> > > +				regulator-initial-mode =
> > > <DA9063_BUCK_MODE_SYNC>;
> > >  				regulator-always-on;
> > >  			};
> > > 
> > > @@ -116,6 +118,7 @@
> > >  				regulator-name = "vdd_soc";
> > >  				regulator-min-microvolt = <730000>;
> > >  				regulator-max-microvolt = <1380000>;
> > > +				regulator-initial-mode =
> > > <DA9063_BUCK_MODE_SYNC>;
> > >  				regulator-always-on;
> > >  			};
> > > 
> > > @@ -123,6 +126,7 @@
> > >  				regulator-name = "vdd_ddr3";
> > >  				regulator-min-microvolt = <1500000>;
> > >  				regulator-max-microvolt = <1500000>;
> > > +				regulator-initial-mode =
> > > <DA9063_BUCK_MODE_SYNC>;
> > >  				regulator-always-on;
> > >  			};
> > > 
> > > @@ -130,6 +134,7 @@
> > >  				regulator-name = "vdd_eth";
> > >  				regulator-min-microvolt = <1200000>;
> > >  				regulator-max-microvolt = <1200000>;
> > > +				regulator-initial-mode =
> > > <DA9063_BUCK_MODE_SYNC>;
> > >  				regulator-always-on;
> > >  			};
> > > 
> > > --
> > > 2.1.4
> > 
> 
> 
> 

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

* Re: [PATCH v2 4/4] ARM: dts: phycore-imx6: set buck regulator modes explicitly
  2019-12-04 12:53       ` Shawn Guo
@ 2019-12-11 18:56         ` Christoph Fritz
  2019-12-12  1:41           ` Shawn Guo
  0 siblings, 1 reply; 16+ messages in thread
From: Christoph Fritz @ 2019-12-11 18:56 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Adam Thomson, Mark Brown, Fabio Estevam, Rob Herring,
	Mark Rutland, Lee Jones, Liam Girdwood, Support Opensource,
	devicetree, linux-arm-kernel

On Wed, 2019-12-04 at 20:53 +0800, Shawn Guo wrote:
> On Thu, Nov 28, 2019 at 09:30:44PM +0100, Christoph Fritz wrote:
> > Hi Shawn,
> > 
> >  any chance to get this patch queued for the upcoming kernel?
> 
> Sorry, no.  I need to wait for DA9063_BUCK_MODE_SYNC landing on 5.5-rc1,
> and then apply this DTS patch.


DA9063_BUCK_MODE_SYNC is now available in 5.5-rc1, could you queue this
patch now?


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

* Re: [PATCH v2 4/4] ARM: dts: phycore-imx6: set buck regulator modes explicitly
  2019-12-11 18:56         ` Christoph Fritz
@ 2019-12-12  1:41           ` Shawn Guo
  0 siblings, 0 replies; 16+ messages in thread
From: Shawn Guo @ 2019-12-12  1:41 UTC (permalink / raw)
  To: Christoph Fritz
  Cc: Adam Thomson, Mark Brown, Fabio Estevam, Rob Herring,
	Mark Rutland, Lee Jones, Liam Girdwood, Support Opensource,
	devicetree, linux-arm-kernel

On Wed, Dec 11, 2019 at 07:56:26PM +0100, Christoph Fritz wrote:
> On Wed, 2019-12-04 at 20:53 +0800, Shawn Guo wrote:
> > On Thu, Nov 28, 2019 at 09:30:44PM +0100, Christoph Fritz wrote:
> > > Hi Shawn,
> > > 
> > >  any chance to get this patch queued for the upcoming kernel?
> > 
> > Sorry, no.  I need to wait for DA9063_BUCK_MODE_SYNC landing on 5.5-rc1,
> > and then apply this DTS patch.
> 
> 
> DA9063_BUCK_MODE_SYNC is now available in 5.5-rc1, could you queue this
> patch now?

Done.  Thanks for reminding.

Shawn

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

end of thread, other threads:[~2019-12-12  1:41 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-13 13:40 [PATCH v2 0/4] regulator da9062: support setting buck modes Christoph Fritz
2019-11-13 13:40 ` [PATCH v2 1/4] regulator: da9062: refactor buck modes into header Christoph Fritz
2019-11-13 16:19   ` Adam Thomson
2019-11-15 12:25   ` Applied "regulator: da9062: refactor buck modes into header" to the regulator tree Mark Brown
2019-11-13 13:40 ` [PATCH v2 2/4] regulator: da9062: add of_map_mode support for bucks Christoph Fritz
2019-11-13 16:24   ` Adam Thomson
2019-11-15 12:25   ` Applied "regulator: da9062: add of_map_mode support for bucks" to the regulator tree Mark Brown
2019-11-13 13:40 ` [PATCH v2 3/4] dt-bindings: mfd: da9062: describe buck modes Christoph Fritz
2019-11-13 16:26   ` Adam Thomson
2019-11-15 12:25   ` Applied "dt-bindings: mfd: da9062: describe buck modes" to the regulator tree Mark Brown
2019-11-13 13:40 ` [PATCH v2 4/4] ARM: dts: phycore-imx6: set buck regulator modes explicitly Christoph Fritz
2019-11-13 16:26   ` Adam Thomson
2019-11-28 20:30     ` Christoph Fritz
2019-12-04 12:53       ` Shawn Guo
2019-12-11 18:56         ` Christoph Fritz
2019-12-12  1:41           ` Shawn Guo

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