All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] regulator: Add support for TPS6286x
@ 2022-02-04 15:52 Vincent Whitchurch
  2022-02-04 15:52 ` [PATCH 1/2] regulator: Add bindings for TPS62864x Vincent Whitchurch
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Vincent Whitchurch @ 2022-02-04 15:52 UTC (permalink / raw)
  To: lgirdwood, broonie
  Cc: kernel, devicetree, linux-kernel, robh+dt, Vincent Whitchurch

TI's TPS62864/TPS6286/TPS62868/TPS62869 are high-frequency synchronous
step-down converters controlled via I2C.  There are differences in the
electrical characteristics and packaging between the variants, but the
register interfaces are identical.

This series adds basic support for these chips.

Vincent Whitchurch (2):
  regulator: Add bindings for TPS62864x
  regulator: Add support for TPS6286x

 .../bindings/regulator/ti,tps62864.yaml       |  62 +++++++
 drivers/regulator/Kconfig                     |   9 +
 drivers/regulator/Makefile                    |   1 +
 drivers/regulator/tps6286x-regulator.c        | 159 ++++++++++++++++++
 include/dt-bindings/regulator/ti,tps62864.h   |   9 +
 5 files changed, 240 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/ti,tps62864.yaml
 create mode 100644 drivers/regulator/tps6286x-regulator.c
 create mode 100644 include/dt-bindings/regulator/ti,tps62864.h

-- 
2.34.1


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

* [PATCH 1/2] regulator: Add bindings for TPS62864x
  2022-02-04 15:52 [PATCH 0/2] regulator: Add support for TPS6286x Vincent Whitchurch
@ 2022-02-04 15:52 ` Vincent Whitchurch
  2022-02-09 18:05   ` Rob Herring
  2022-02-04 15:52 ` [PATCH 2/2] regulator: Add support for TPS6286x Vincent Whitchurch
  2022-02-08 19:00 ` [PATCH 0/2] " Mark Brown
  2 siblings, 1 reply; 5+ messages in thread
From: Vincent Whitchurch @ 2022-02-04 15:52 UTC (permalink / raw)
  To: lgirdwood, broonie
  Cc: kernel, devicetree, linux-kernel, robh+dt, Vincent Whitchurch

Add bindings for the TPS62864/TPS6286/TPS62868/TPS62869 voltage
regulators.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
 .../bindings/regulator/ti,tps62864.yaml       | 62 +++++++++++++++++++
 include/dt-bindings/regulator/ti,tps62864.h   |  9 +++
 2 files changed, 71 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/ti,tps62864.yaml
 create mode 100644 include/dt-bindings/regulator/ti,tps62864.h

diff --git a/Documentation/devicetree/bindings/regulator/ti,tps62864.yaml b/Documentation/devicetree/bindings/regulator/ti,tps62864.yaml
new file mode 100644
index 000000000000..e3d739a37ab0
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/ti,tps62864.yaml
@@ -0,0 +1,62 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/ti,tps62864.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TI TPS62864/TPS6286/TPS62868/TPS62869 voltage regulator
+
+maintainers:
+  - Vincent Whitchurch <vincent.whitchurch@axis.com>
+
+properties:
+  compatible:
+    enum:
+      - ti,tps62864
+      - ti,tps62866
+      - ti,tps62868
+      - ti,tps62869
+
+  reg:
+    maxItems: 1
+
+  regulators:
+    type: object
+
+    patternProperties:
+      "SW":
+        type: object
+        $ref: regulator.yaml#
+
+    additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - regulators
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/regulator/ti,tps62864.h>
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      regulator@48 {
+        compatible = "ti,tps62864";
+        reg = <0x48>;
+
+        regulators {
+          SW {
+            regulator-name = "+0.85V";
+            regulator-min-microvolt = <800000>;
+            regulator-max-microvolt = <890000>;
+            regulator-initial-mode = <TPS62864_MODE_FPWM>;
+          };
+        };
+      };
+    };
+
+...
diff --git a/include/dt-bindings/regulator/ti,tps62864.h b/include/dt-bindings/regulator/ti,tps62864.h
new file mode 100644
index 000000000000..8db31f23d956
--- /dev/null
+++ b/include/dt-bindings/regulator/ti,tps62864.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+
+#ifndef _DT_BINDINGS_REGULATOR_TI_TPS62864_H
+#define _DT_BINDINGS_REGULATOR_TI_TPS62864_H
+
+#define TPS62864_MODE_NORMAL			0
+#define TPS62864_MODE_FPWM			1
+
+#endif
-- 
2.34.1


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

* [PATCH 2/2] regulator: Add support for TPS6286x
  2022-02-04 15:52 [PATCH 0/2] regulator: Add support for TPS6286x Vincent Whitchurch
  2022-02-04 15:52 ` [PATCH 1/2] regulator: Add bindings for TPS62864x Vincent Whitchurch
@ 2022-02-04 15:52 ` Vincent Whitchurch
  2022-02-08 19:00 ` [PATCH 0/2] " Mark Brown
  2 siblings, 0 replies; 5+ messages in thread
From: Vincent Whitchurch @ 2022-02-04 15:52 UTC (permalink / raw)
  To: lgirdwood, broonie
  Cc: kernel, devicetree, linux-kernel, robh+dt, Vincent Whitchurch

TI's TPS62864/TPS6286/TPS62868/TPS62869 are high-frequency synchronous
step-down converters controlled via I2C.  There are differences in the
electrical characteristics and packaging between the variants, but the
register interfaces are identical.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
 drivers/regulator/Kconfig              |   9 ++
 drivers/regulator/Makefile             |   1 +
 drivers/regulator/tps6286x-regulator.c | 159 +++++++++++++++++++++++++
 3 files changed, 169 insertions(+)
 create mode 100644 drivers/regulator/tps6286x-regulator.c

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 1c35fed20d34..49e26f187742 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -1263,6 +1263,15 @@ config REGULATOR_TPS62360
 	  high-frequency synchronous step down dc-dc converter optimized
 	  for battery-powered portable applications.
 
+config REGULATOR_TPS6286X
+	tristate "TI TPS6286x Power Regulator"
+	depends on I2C && OF
+	select REGMAP_I2C
+	help
+	  This driver supports TPS6236x voltage regulator chips. These are
+	  high-frequency synchronous step-down converters with an I2C
+	  interface.
+
 config REGULATOR_TPS65023
 	tristate "TI TPS65023 Power regulators"
 	depends on I2C
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 2e1b087489fa..4b8794a73e17 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -149,6 +149,7 @@ obj-$(CONFIG_REGULATOR_SY8827N) += sy8827n.o
 obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o
 obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o
 obj-$(CONFIG_REGULATOR_TPS62360) += tps62360-regulator.o
+obj-$(CONFIG_REGULATOR_TPS6286X) += tps6286x-regulator.o
 obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o
 obj-$(CONFIG_REGULATOR_TPS6507X) += tps6507x-regulator.o
 obj-$(CONFIG_REGULATOR_TPS65086) += tps65086-regulator.o
diff --git a/drivers/regulator/tps6286x-regulator.c b/drivers/regulator/tps6286x-regulator.c
new file mode 100644
index 000000000000..e29deda30d75
--- /dev/null
+++ b/drivers/regulator/tps6286x-regulator.c
@@ -0,0 +1,159 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// Copyright Axis Communications AB
+
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+#include <linux/regulator/of_regulator.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/driver.h>
+
+#include <dt-bindings/regulator/ti,tps62864.h>
+
+#define TPS6286X_VOUT1		0x01
+#define TPS6286X_VOUT1_VO1_SET	GENMASK(7, 0)
+
+#define TPS6286X_CONTROL	0x03
+#define TPS6286X_CONTROL_FPWM	BIT(4)
+#define TPS6286X_CONTROL_SWEN	BIT(5)
+
+#define TPS6286X_MIN_MV		400
+#define TPS6286X_MAX_MV		1675
+#define TPS6286X_STEP_MV	5
+
+static const struct regmap_config tps6286x_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+};
+
+static int tps6286x_set_mode(struct regulator_dev *rdev, unsigned int mode)
+{
+	unsigned int val;
+
+	switch (mode) {
+	case REGULATOR_MODE_NORMAL:
+		val = 0;
+		break;
+	case REGULATOR_MODE_FAST:
+		val = TPS6286X_CONTROL_FPWM;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return regmap_update_bits(rdev->regmap, TPS6286X_CONTROL,
+				  TPS6286X_CONTROL_FPWM, val);
+}
+
+static unsigned int tps6286x_get_mode(struct regulator_dev *rdev)
+{
+	unsigned int val;
+	int ret;
+
+	ret = regmap_read(rdev->regmap, TPS6286X_CONTROL, &val);
+	if (ret < 0)
+		return 0;
+
+	return (val & TPS6286X_CONTROL_FPWM) ? REGULATOR_MODE_FAST : REGULATOR_MODE_NORMAL;
+}
+
+static const struct regulator_ops tps6286x_regulator_ops = {
+	.enable = regulator_enable_regmap,
+	.disable = regulator_disable_regmap,
+	.set_mode = tps6286x_set_mode,
+	.get_mode = tps6286x_get_mode,
+	.is_enabled = regulator_is_enabled_regmap,
+	.set_voltage_sel = regulator_set_voltage_sel_regmap,
+	.get_voltage_sel = regulator_get_voltage_sel_regmap,
+	.list_voltage = regulator_list_voltage_linear,
+};
+
+static unsigned int tps6286x_of_map_mode(unsigned int mode)
+{
+	switch (mode) {
+	case TPS62864_MODE_NORMAL:
+		return REGULATOR_MODE_NORMAL;
+	case TPS62864_MODE_FPWM:
+		return REGULATOR_MODE_FAST;
+	default:
+		return REGULATOR_MODE_INVALID;
+	}
+}
+
+static const struct regulator_desc tps6286x_reg = {
+	.name = "tps6286x",
+	.of_match = of_match_ptr("SW"),
+	.owner = THIS_MODULE,
+	.ops = &tps6286x_regulator_ops,
+	.of_map_mode = tps6286x_of_map_mode,
+	.regulators_node = of_match_ptr("regulators"),
+	.type = REGULATOR_VOLTAGE,
+	.n_voltages = ((TPS6286X_MAX_MV - TPS6286X_MIN_MV) / TPS6286X_STEP_MV) + 1,
+	.min_uV = TPS6286X_MIN_MV * 1000,
+	.uV_step = TPS6286X_STEP_MV * 1000,
+	.vsel_reg = TPS6286X_VOUT1,
+	.vsel_mask = TPS6286X_VOUT1_VO1_SET,
+	.enable_reg = TPS6286X_CONTROL,
+	.enable_mask = TPS6286X_CONTROL_SWEN,
+	.ramp_delay = 1000,
+	/* tDelay + tRamp, rounded up */
+	.enable_time = 3000,
+};
+
+static const struct of_device_id tps6286x_dt_ids[] = {
+	{ .compatible = "ti,tps62864", },
+	{ .compatible = "ti,tps62866", },
+	{ .compatible = "ti,tps62868", },
+	{ .compatible = "ti,tps62869", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, tps6286x_dt_ids);
+
+static int tps6286x_i2c_probe(struct i2c_client *i2c,
+			    const struct i2c_device_id *id)
+{
+	struct device *dev = &i2c->dev;
+	struct regulator_config config = {};
+	struct regulator_dev *rdev;
+	struct regmap *regmap;
+
+	regmap = devm_regmap_init_i2c(i2c, &tps6286x_regmap_config);
+	if (IS_ERR(regmap))
+		return PTR_ERR(regmap);
+
+	config.dev = &i2c->dev;
+	config.of_node = dev->of_node;
+	config.regmap = regmap;
+
+	rdev = devm_regulator_register(&i2c->dev, &tps6286x_reg, &config);
+	if (IS_ERR(rdev)) {
+		dev_err(&i2c->dev, "Failed to register tps6286x regulator\n");
+		return PTR_ERR(rdev);
+	}
+
+	return 0;
+}
+
+static const struct i2c_device_id tps6286x_i2c_id[] = {
+	{ "tps62864", 0 },
+	{ "tps62866", 0 },
+	{ "tps62868", 0 },
+	{ "tps62869", 0 },
+	{},
+};
+MODULE_DEVICE_TABLE(i2c, tps6286x_i2c_id);
+
+static struct i2c_driver tps6286x_regulator_driver = {
+	.driver = {
+		.name = "tps6286x",
+		.of_match_table = of_match_ptr(tps6286x_dt_ids),
+	},
+	.probe = tps6286x_i2c_probe,
+	.id_table = tps6286x_i2c_id,
+};
+
+module_i2c_driver(tps6286x_regulator_driver);
+
+MODULE_LICENSE("GPL v2");
-- 
2.34.1


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

* Re: [PATCH 0/2] regulator: Add support for TPS6286x
  2022-02-04 15:52 [PATCH 0/2] regulator: Add support for TPS6286x Vincent Whitchurch
  2022-02-04 15:52 ` [PATCH 1/2] regulator: Add bindings for TPS62864x Vincent Whitchurch
  2022-02-04 15:52 ` [PATCH 2/2] regulator: Add support for TPS6286x Vincent Whitchurch
@ 2022-02-08 19:00 ` Mark Brown
  2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2022-02-08 19:00 UTC (permalink / raw)
  To: lgirdwood, Vincent Whitchurch; +Cc: linux-kernel, kernel, devicetree, robh+dt

On Fri, 4 Feb 2022 16:52:39 +0100, Vincent Whitchurch wrote:
> TI's TPS62864/TPS6286/TPS62868/TPS62869 are high-frequency synchronous
> step-down converters controlled via I2C.  There are differences in the
> electrical characteristics and packaging between the variants, but the
> register interfaces are identical.
> 
> This series adds basic support for these chips.
> 
> [...]

Applied to

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

Thanks!

[1/2] regulator: Add bindings for TPS62864x
      commit: 2f04aa69ab5c5c40d2e3e51fd73ce2ecb651e9ba
[2/2] regulator: Add support for TPS6286x
      commit: e2a01b4e8806087743e5ee42f9dcedfc741d4112

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

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

* Re: [PATCH 1/2] regulator: Add bindings for TPS62864x
  2022-02-04 15:52 ` [PATCH 1/2] regulator: Add bindings for TPS62864x Vincent Whitchurch
@ 2022-02-09 18:05   ` Rob Herring
  0 siblings, 0 replies; 5+ messages in thread
From: Rob Herring @ 2022-02-09 18:05 UTC (permalink / raw)
  To: Vincent Whitchurch; +Cc: lgirdwood, broonie, kernel, devicetree, linux-kernel

On Fri, Feb 04, 2022 at 04:52:40PM +0100, Vincent Whitchurch wrote:
> Add bindings for the TPS62864/TPS6286/TPS62868/TPS62869 voltage
> regulators.
> 
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> ---
>  .../bindings/regulator/ti,tps62864.yaml       | 62 +++++++++++++++++++
>  include/dt-bindings/regulator/ti,tps62864.h   |  9 +++
>  2 files changed, 71 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/regulator/ti,tps62864.yaml
>  create mode 100644 include/dt-bindings/regulator/ti,tps62864.h
> 
> diff --git a/Documentation/devicetree/bindings/regulator/ti,tps62864.yaml b/Documentation/devicetree/bindings/regulator/ti,tps62864.yaml
> new file mode 100644
> index 000000000000..e3d739a37ab0
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/regulator/ti,tps62864.yaml
> @@ -0,0 +1,62 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/regulator/ti,tps62864.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: TI TPS62864/TPS6286/TPS62868/TPS62869 voltage regulator
> +
> +maintainers:
> +  - Vincent Whitchurch <vincent.whitchurch@axis.com>
> +
> +properties:
> +  compatible:
> +    enum:
> +      - ti,tps62864
> +      - ti,tps62866
> +      - ti,tps62868
> +      - ti,tps62869
> +
> +  reg:
> +    maxItems: 1
> +
> +  regulators:
> +    type: object
> +
> +    patternProperties:
> +      "SW":

Not a pattern, use 'properties'. Actually it is a pattern, so 'fooSWbar' 
would be a valid node name.

> +        type: object
> +        $ref: regulator.yaml#

           unevaluatedProperties: false

> +
> +    additionalProperties: false
> +
> +required:
> +  - compatible
> +  - reg
> +  - regulators
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/regulator/ti,tps62864.h>
> +    i2c {
> +      #address-cells = <1>;
> +      #size-cells = <0>;
> +
> +      regulator@48 {
> +        compatible = "ti,tps62864";
> +        reg = <0x48>;
> +
> +        regulators {
> +          SW {
> +            regulator-name = "+0.85V";
> +            regulator-min-microvolt = <800000>;
> +            regulator-max-microvolt = <890000>;
> +            regulator-initial-mode = <TPS62864_MODE_FPWM>;
> +          };
> +        };
> +      };
> +    };
> +
> +...
> diff --git a/include/dt-bindings/regulator/ti,tps62864.h b/include/dt-bindings/regulator/ti,tps62864.h
> new file mode 100644
> index 000000000000..8db31f23d956
> --- /dev/null
> +++ b/include/dt-bindings/regulator/ti,tps62864.h
> @@ -0,0 +1,9 @@
> +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
> +
> +#ifndef _DT_BINDINGS_REGULATOR_TI_TPS62864_H
> +#define _DT_BINDINGS_REGULATOR_TI_TPS62864_H
> +
> +#define TPS62864_MODE_NORMAL			0
> +#define TPS62864_MODE_FPWM			1
> +
> +#endif
> -- 
> 2.34.1
> 
> 

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

end of thread, other threads:[~2022-02-09 18:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-04 15:52 [PATCH 0/2] regulator: Add support for TPS6286x Vincent Whitchurch
2022-02-04 15:52 ` [PATCH 1/2] regulator: Add bindings for TPS62864x Vincent Whitchurch
2022-02-09 18:05   ` Rob Herring
2022-02-04 15:52 ` [PATCH 2/2] regulator: Add support for TPS6286x Vincent Whitchurch
2022-02-08 19:00 ` [PATCH 0/2] " Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.