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

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.

Christoph Fritz (4):
  regulator: da9062: refactor buck modes into header
  regulator: da9062: add of_map_mode support for bucks
  dt-bindings: regulator: describe da906x buck regulator 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,da906x-regulator.h   | 16 +++++++
 4 files changed, 56 insertions(+), 18 deletions(-)
 create mode 100644 include/dt-bindings/regulator/dlg,da906x-regulator.h

-- 
2.1.4


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

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

* [PATCH 1/4] regulator: da9062: refactor buck modes into header
  2019-11-07 10:04 [PATCH 0/4] regulator da9062: support setting buck modes Christoph Fritz
@ 2019-11-07 10:04 ` Christoph Fritz
  2019-11-08 10:37   ` Adam Thomson
  2019-11-07 10:04 ` [PATCH 2/4] regulator: da9062: add of_map_mode support for bucks Christoph Fritz
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Christoph Fritz @ 2019-11-07 10:04 UTC (permalink / raw)
  To: Fabio Estevam, Mark Brown, Rob Herring, Mark Rutland, Shawn Guo
  Cc: devicetree, Lee Jones, Liam Girdwood, linux-arm-kernel,
	Support Opensource

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

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

diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-regulator.c
index 710e670..1a95982 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,da906x-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 = DA906X_BUCK_MODE_SYNC;
 		break;
 	case REGULATOR_MODE_NORMAL:
-		val = BUCK_MODE_AUTO;
+		val = DA906X_BUCK_MODE_AUTO;
 		break;
 	case REGULATOR_MODE_STANDBY:
-		val = BUCK_MODE_SLEEP;
+		val = DA906X_BUCK_MODE_SLEEP;
 		break;
 	default:
 		return -EINVAL;
@@ -145,15 +138,14 @@ static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
 
 	switch (val) {
 	default:
-	case BUCK_MODE_MANUAL:
 		mode = REGULATOR_MODE_FAST | REGULATOR_MODE_STANDBY;
 		/* Sleep flag bit decides the mode */
 		break;
-	case BUCK_MODE_SLEEP:
+	case DA906X_BUCK_MODE_SLEEP:
 		return REGULATOR_MODE_STANDBY;
-	case BUCK_MODE_SYNC:
+	case DA906X_BUCK_MODE_SYNC:
 		return REGULATOR_MODE_FAST;
-	case BUCK_MODE_AUTO:
+	case DA906X_BUCK_MODE_AUTO:
 		return REGULATOR_MODE_NORMAL;
 	}
 
@@ -282,13 +274,13 @@ static int da9062_buck_set_suspend_mode(struct regulator_dev *rdev,
 
 	switch (mode) {
 	case REGULATOR_MODE_FAST:
-		val = BUCK_MODE_SYNC;
+		val = DA906X_BUCK_MODE_SYNC;
 		break;
 	case REGULATOR_MODE_NORMAL:
-		val = BUCK_MODE_AUTO;
+		val = DA906X_BUCK_MODE_AUTO;
 		break;
 	case REGULATOR_MODE_STANDBY:
-		val = BUCK_MODE_SLEEP;
+		val = DA906X_BUCK_MODE_SLEEP;
 		break;
 	default:
 		return -EINVAL;
diff --git a/include/dt-bindings/regulator/dlg,da906x-regulator.h b/include/dt-bindings/regulator/dlg,da906x-regulator.h
new file mode 100644
index 00000000..848a4df
--- /dev/null
+++ b/include/dt-bindings/regulator/dlg,da906x-regulator.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __DLG_DA906X_REGULATOR_H
+#define __DLG_DA906X_REGULATOR_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 DA906X_BUCK_MODE_SLEEP		1
+#define DA906X_BUCK_MODE_SYNC		2
+#define DA906X_BUCK_MODE_AUTO		3
+
+#endif
-- 
2.1.4


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

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

* [PATCH 2/4] regulator: da9062: add of_map_mode support for bucks
  2019-11-07 10:04 [PATCH 0/4] regulator da9062: support setting buck modes Christoph Fritz
  2019-11-07 10:04 ` [PATCH 1/4] regulator: da9062: refactor buck modes into header Christoph Fritz
@ 2019-11-07 10:04 ` Christoph Fritz
  2019-11-08 10:42   ` Adam Thomson
  2019-11-07 10:04 ` [PATCH 3/4] dt-bindings: regulator: describe da906x buck regulator modes Christoph Fritz
  2019-11-07 10:04 ` [PATCH 4/4] ARM: dts: phycore-imx6: set buck regulator modes explicitly Christoph Fritz
  3 siblings, 1 reply; 11+ messages in thread
From: Christoph Fritz @ 2019-11-07 10:04 UTC (permalink / raw)
  To: Fabio Estevam, Mark Brown, Rob Herring, Mark Rutland, Shawn Guo
  Cc: devicetree, Support Opensource, Stefan Riedmueller,
	Liam Girdwood, Christian Hemp, Lee Jones, linux-arm-kernel

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 1a95982..f5f2ead 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 da906x_map_buck_mode(unsigned int mode)
+{
+	switch (mode) {
+	case DA906X_BUCK_MODE_SLEEP:
+		return REGULATOR_MODE_STANDBY;
+	case DA906X_BUCK_MODE_SYNC:
+		return REGULATOR_MODE_FAST;
+	case DA906X_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);
@@ -363,6 +377,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 = da906x_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK1_A,
 			__builtin_ffs((int)DA9062AA_BUCK1_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
@@ -399,6 +414,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 = da906x_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK3_A,
 			__builtin_ffs((int)DA9062AA_BUCK3_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
@@ -435,6 +451,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 = da906x_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK4_A,
 			__builtin_ffs((int)DA9062AA_BUCK4_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
@@ -607,6 +624,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 = da906x_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK1_A,
 			__builtin_ffs((int)DA9062AA_BUCK1_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
@@ -643,6 +661,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 = da906x_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK2_A,
 			__builtin_ffs((int)DA9062AA_BUCK2_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
@@ -679,6 +698,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 = da906x_map_buck_mode,
 		.sleep = REG_FIELD(DA9062AA_VBUCK3_A,
 			__builtin_ffs((int)DA9062AA_BUCK3_SL_A_MASK) - 1,
 			sizeof(unsigned int) * 8 -
@@ -715,6 +735,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 = da906x_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


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

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

* [PATCH 3/4] dt-bindings: regulator: describe da906x buck regulator modes
  2019-11-07 10:04 [PATCH 0/4] regulator da9062: support setting buck modes Christoph Fritz
  2019-11-07 10:04 ` [PATCH 1/4] regulator: da9062: refactor buck modes into header Christoph Fritz
  2019-11-07 10:04 ` [PATCH 2/4] regulator: da9062: add of_map_mode support for bucks Christoph Fritz
@ 2019-11-07 10:04 ` Christoph Fritz
  2019-11-07 11:55   ` Mark Brown
                     ` (2 more replies)
  2019-11-07 10:04 ` [PATCH 4/4] ARM: dts: phycore-imx6: set buck regulator modes explicitly Christoph Fritz
  3 siblings, 3 replies; 11+ messages in thread
From: Christoph Fritz @ 2019-11-07 10:04 UTC (permalink / raw)
  To: Fabio Estevam, Mark Brown, Rob Herring, Mark Rutland, Shawn Guo
  Cc: devicetree, Lee Jones, Liam Girdwood, linux-arm-kernel,
	Support Opensource

This patch adds DT description of da906x 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..5989411 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,da906x-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 = <DA906X_BUCK_MODE_SYNC>;
 				regulator-boot-on;
 			};
 			DA9062_LDO1: ldo1 {
-- 
2.1.4


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

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

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

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..e3f2181 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,da906x-regulator.h>
 
 / {
 	aliases {
@@ -109,6 +110,7 @@
 				regulator-name = "vdd_arm";
 				regulator-min-microvolt = <730000>;
 				regulator-max-microvolt = <1380000>;
+				regulator-initial-mode = <DA906X_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 = <DA906X_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 = <DA906X_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 = <DA906X_BUCK_MODE_SYNC>;
 				regulator-always-on;
 			};
 
-- 
2.1.4


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

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

* Re: [PATCH 3/4] dt-bindings: regulator: describe da906x buck regulator modes
  2019-11-07 10:04 ` [PATCH 3/4] dt-bindings: regulator: describe da906x buck regulator modes Christoph Fritz
@ 2019-11-07 11:55   ` Mark Brown
  2019-11-08 10:44   ` Adam Thomson
  2019-11-13 13:32   ` Rob Herring
  2 siblings, 0 replies; 11+ messages in thread
From: Mark Brown @ 2019-11-07 11:55 UTC (permalink / raw)
  To: Christoph Fritz
  Cc: Mark Rutland, devicetree, Support Opensource, Lee Jones,
	Liam Girdwood, Rob Herring, Fabio Estevam, Shawn Guo,
	linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 461 bytes --]

On Thu, Nov 07, 2019 at 11:04:09AM +0100, Christoph Fritz wrote:
> This patch adds DT description of da906x buck regulator modes.

Please submit patches using subject lines reflecting the style for the
subsystem, this makes it easier for people to identify relevant patches.
Look at what existing commits in the area you're changing are doing and
make sure your subject lines visually resemble what they're doing.
There's no need to resubmit to fix this alone.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

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

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

* RE: [PATCH 1/4] regulator: da9062: refactor buck modes into header
  2019-11-07 10:04 ` [PATCH 1/4] regulator: da9062: refactor buck modes into header Christoph Fritz
@ 2019-11-08 10:37   ` Adam Thomson
  2019-11-13 11:04     ` Christoph Fritz
  0 siblings, 1 reply; 11+ messages in thread
From: Adam Thomson @ 2019-11-08 10:37 UTC (permalink / raw)
  To: Christoph Fritz, Fabio Estevam, Mark Brown, Rob Herring,
	Mark Rutland, Shawn Guo
  Cc: devicetree, Lee Jones, Liam Girdwood, linux-arm-kernel,
	Support Opensource

On 07 November 2019 10:04, Christoph Fritz wrote: 

> This patch refactors buck modes into a header so that device trees
> can make use of these mode constants.
> 
> Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
> ---
>  drivers/regulator/da9062-regulator.c               | 28 ++++++++--------------
>  .../dt-bindings/regulator/dlg,da906x-regulator.h   | 16 +++++++++++++
>  2 files changed, 26 insertions(+), 18 deletions(-)
>  create mode 100644 include/dt-bindings/regulator/dlg,da906x-regulator.h
> 
> diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-
> regulator.c
> index 710e670..1a95982 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,da906x-regulator.h>

Can we please rename this file to use da9063 instead of da906x as this header
wouldn't necessarily be valid for other da906x prefixed devices outside of
DA9061/2/3. DA9063 was the earlier chip so it makes sense to use that name over
DA9062, and DA9063 driver code will want updating at some point in a similar
manner.

> 
>  /* 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 = DA906X_BUCK_MODE_SYNC;
>  		break;
>  	case REGULATOR_MODE_NORMAL:
> -		val = BUCK_MODE_AUTO;
> +		val = DA906X_BUCK_MODE_AUTO;
>  		break;
>  	case REGULATOR_MODE_STANDBY:
> -		val = BUCK_MODE_SLEEP;
> +		val = DA906X_BUCK_MODE_SLEEP;
>  		break;
>  	default:
>  		return -EINVAL;
> @@ -145,15 +138,14 @@ static unsigned da9062_buck_get_mode(struct
> regulator_dev *rdev)
> 
>  	switch (val) {
>  	default:
> -	case BUCK_MODE_MANUAL:
>  		mode = REGULATOR_MODE_FAST |
> REGULATOR_MODE_STANDBY;
>  		/* Sleep flag bit decides the mode */
>  		break;

I'm not sure your code is based on the latest regulator updates as I believe
Axel Lin made some improvements to this bit of code. Checkout Mark's regulator
fork of the kernel.

> -	case BUCK_MODE_SLEEP:
> +	case DA906X_BUCK_MODE_SLEEP:
>  		return REGULATOR_MODE_STANDBY;
> -	case BUCK_MODE_SYNC:
> +	case DA906X_BUCK_MODE_SYNC:
>  		return REGULATOR_MODE_FAST;
> -	case BUCK_MODE_AUTO:
> +	case DA906X_BUCK_MODE_AUTO:
>  		return REGULATOR_MODE_NORMAL;
>  	}
> 
> @@ -282,13 +274,13 @@ static int da9062_buck_set_suspend_mode(struct
> regulator_dev *rdev,
> 
>  	switch (mode) {
>  	case REGULATOR_MODE_FAST:
> -		val = BUCK_MODE_SYNC;
> +		val = DA906X_BUCK_MODE_SYNC;
>  		break;
>  	case REGULATOR_MODE_NORMAL:
> -		val = BUCK_MODE_AUTO;
> +		val = DA906X_BUCK_MODE_AUTO;
>  		break;
>  	case REGULATOR_MODE_STANDBY:
> -		val = BUCK_MODE_SLEEP;
> +		val = DA906X_BUCK_MODE_SLEEP;
>  		break;
>  	default:
>  		return -EINVAL;
> diff --git a/include/dt-bindings/regulator/dlg,da906x-regulator.h b/include/dt-
> bindings/regulator/dlg,da906x-regulator.h
> new file mode 100644
> index 00000000..848a4df
> --- /dev/null
> +++ b/include/dt-bindings/regulator/dlg,da906x-regulator.h
> @@ -0,0 +1,16 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +
> +#ifndef __DLG_DA906X_REGULATOR_H
> +#define __DLG_DA906X_REGULATOR_H

Just to echo previous comment, rename from DA906X to DA9063

> +
> +/*
> + * 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 DA906X_BUCK_MODE_SLEEP		1
> +#define DA906X_BUCK_MODE_SYNC		2
> +#define DA906X_BUCK_MODE_AUTO		3
> +
> +#endif
> --
> 2.1.4


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

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

* RE: [PATCH 2/4] regulator: da9062: add of_map_mode support for bucks
  2019-11-07 10:04 ` [PATCH 2/4] regulator: da9062: add of_map_mode support for bucks Christoph Fritz
@ 2019-11-08 10:42   ` Adam Thomson
  0 siblings, 0 replies; 11+ messages in thread
From: Adam Thomson @ 2019-11-08 10:42 UTC (permalink / raw)
  To: Christoph Fritz, Fabio Estevam, Mark Brown, Rob Herring,
	Mark Rutland, Shawn Guo
  Cc: devicetree, Support Opensource, Stefan Riedmueller,
	Liam Girdwood, Christian Hemp, Lee Jones, linux-arm-kernel

On 07 November 2019 10:04, Christoph Fritz wrote:

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

This looks fine to me, other than a couple of little points below.

> 
> 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 1a95982..f5f2ead 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 da906x_map_buck_mode(unsigned int mode)

This can just be called da9062 as this function is only used in this file.

> +{
> +	switch (mode) {
> +	case DA906X_BUCK_MODE_SLEEP:

Obvioulsy these names will want updating as per my comments on patch 01 in the
series.

> +		return REGULATOR_MODE_STANDBY;
> +	case DA906X_BUCK_MODE_SYNC:
> +		return REGULATOR_MODE_FAST;
> +	case DA906X_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);
> @@ -363,6 +377,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 = da906x_map_buck_mode,
>  		.sleep = REG_FIELD(DA9062AA_VBUCK1_A,
>  			__builtin_ffs((int)DA9062AA_BUCK1_SL_A_MASK) - 1,
>  			sizeof(unsigned int) * 8 -
> @@ -399,6 +414,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 = da906x_map_buck_mode,
>  		.sleep = REG_FIELD(DA9062AA_VBUCK3_A,
>  			__builtin_ffs((int)DA9062AA_BUCK3_SL_A_MASK) - 1,
>  			sizeof(unsigned int) * 8 -
> @@ -435,6 +451,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 = da906x_map_buck_mode,
>  		.sleep = REG_FIELD(DA9062AA_VBUCK4_A,
>  			__builtin_ffs((int)DA9062AA_BUCK4_SL_A_MASK) - 1,
>  			sizeof(unsigned int) * 8 -
> @@ -607,6 +624,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 = da906x_map_buck_mode,
>  		.sleep = REG_FIELD(DA9062AA_VBUCK1_A,
>  			__builtin_ffs((int)DA9062AA_BUCK1_SL_A_MASK) - 1,
>  			sizeof(unsigned int) * 8 -
> @@ -643,6 +661,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 = da906x_map_buck_mode,
>  		.sleep = REG_FIELD(DA9062AA_VBUCK2_A,
>  			__builtin_ffs((int)DA9062AA_BUCK2_SL_A_MASK) - 1,
>  			sizeof(unsigned int) * 8 -
> @@ -679,6 +698,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 = da906x_map_buck_mode,
>  		.sleep = REG_FIELD(DA9062AA_VBUCK3_A,
>  			__builtin_ffs((int)DA9062AA_BUCK3_SL_A_MASK) - 1,
>  			sizeof(unsigned int) * 8 -
> @@ -715,6 +735,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 = da906x_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


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

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

* RE: [PATCH 3/4] dt-bindings: regulator: describe da906x buck regulator modes
  2019-11-07 10:04 ` [PATCH 3/4] dt-bindings: regulator: describe da906x buck regulator modes Christoph Fritz
  2019-11-07 11:55   ` Mark Brown
@ 2019-11-08 10:44   ` Adam Thomson
  2019-11-13 13:32   ` Rob Herring
  2 siblings, 0 replies; 11+ messages in thread
From: Adam Thomson @ 2019-11-08 10:44 UTC (permalink / raw)
  To: Christoph Fritz, Fabio Estevam, Mark Brown, Rob Herring,
	Mark Rutland, Shawn Guo
  Cc: devicetree, Lee Jones, Liam Girdwood, linux-arm-kernel,
	Support Opensource

On 07 November 2019 10:04, Christoph Fritz wrote:

> This patch adds DT description of da906x buck regulator modes.

Just the renames from da906x to da9063 required as per 01 patch comments

> 
> 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..5989411 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,da906x-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 =
> <DA906X_BUCK_MODE_SYNC>;
>  				regulator-boot-on;
>  			};
>  			DA9062_LDO1: ldo1 {
> --
> 2.1.4


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

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

* Re: [PATCH 1/4] regulator: da9062: refactor buck modes into header
  2019-11-08 10:37   ` Adam Thomson
@ 2019-11-13 11:04     ` Christoph Fritz
  0 siblings, 0 replies; 11+ messages in thread
From: Christoph Fritz @ 2019-11-13 11:04 UTC (permalink / raw)
  To: Adam Thomson
  Cc: Mark Rutland, devicetree, Support Opensource, Lee Jones,
	Liam Girdwood, Rob Herring, Mark Brown, Fabio Estevam, Shawn Guo,
	linux-arm-kernel

Hi Adam

On Fri, 2019-11-08 at 10:37 +0000, Adam Thomson wrote:
> > --- 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,da906x-regulator.h>
> 
> Can we please rename this file to use da9063 instead of da906x
[..]

sure

> > @@ -145,15 +138,14 @@ static unsigned da9062_buck_get_mode(struct
> > regulator_dev *rdev)
> > 
> >  	switch (val) {
> >  	default:
> > -	case BUCK_MODE_MANUAL:
> >  		mode = REGULATOR_MODE_FAST |
> > REGULATOR_MODE_STANDBY;
> >  		/* Sleep flag bit decides the mode */
> >  		break;
> 
> I'm not sure your code is based on the latest regulator updates as I believe
> Axel Lin made some improvements to this bit of code. Checkout Mark's regulator
> fork of the kernel.

yes, the line

 mode = REGULATOR_MODE_FAST | REGULATOR_MODE_STANDBY;

is now gone by commit

 be446f183ae35a8c76
 regulator: da9062: Simplify da9062_buck_set_mode for BUCK_MODE_MANUAL case

it's already in linux-next, I'll rebase this patchset


> > diff --git a/include/dt-bindings/regulator/dlg,da906x-regulator.h b/include/dt-
> > bindings/regulator/dlg,da906x-regulator.h
> > new file mode 100644
> > index 00000000..848a4df
> > --- /dev/null
> > +++ b/include/dt-bindings/regulator/dlg,da906x-regulator.h
> > @@ -0,0 +1,16 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +
> > +#ifndef __DLG_DA906X_REGULATOR_H
> > +#define __DLG_DA906X_REGULATOR_H
> 
> Just to echo previous comment, rename from DA906X to DA9063

ok



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

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

* Re: [PATCH 3/4] dt-bindings: regulator: describe da906x buck regulator modes
  2019-11-07 10:04 ` [PATCH 3/4] dt-bindings: regulator: describe da906x buck regulator modes Christoph Fritz
  2019-11-07 11:55   ` Mark Brown
  2019-11-08 10:44   ` Adam Thomson
@ 2019-11-13 13:32   ` Rob Herring
  2 siblings, 0 replies; 11+ messages in thread
From: Rob Herring @ 2019-11-13 13:32 UTC (permalink / raw)
  To: Christoph Fritz
  Cc: devicetree, Support Opensource, Fabio Estevam, Liam Girdwood,
	Mark Brown, Lee Jones, linux-arm-kernel

On Thu,  7 Nov 2019 11:04:09 +0100, Christoph Fritz wrote:
> This patch adds DT description of da906x buck regulator modes.
> 
> Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
> ---
>  Documentation/devicetree/bindings/mfd/da9062.txt | 4 ++++
>  1 file changed, 4 insertions(+)
> 

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

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

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

end of thread, other threads:[~2019-11-13 13:32 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-07 10:04 [PATCH 0/4] regulator da9062: support setting buck modes Christoph Fritz
2019-11-07 10:04 ` [PATCH 1/4] regulator: da9062: refactor buck modes into header Christoph Fritz
2019-11-08 10:37   ` Adam Thomson
2019-11-13 11:04     ` Christoph Fritz
2019-11-07 10:04 ` [PATCH 2/4] regulator: da9062: add of_map_mode support for bucks Christoph Fritz
2019-11-08 10:42   ` Adam Thomson
2019-11-07 10:04 ` [PATCH 3/4] dt-bindings: regulator: describe da906x buck regulator modes Christoph Fritz
2019-11-07 11:55   ` Mark Brown
2019-11-08 10:44   ` Adam Thomson
2019-11-13 13:32   ` Rob Herring
2019-11-07 10:04 ` [PATCH 4/4] ARM: dts: phycore-imx6: set buck regulator modes explicitly Christoph Fritz

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