All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Add ADI MAX77503 regulator driver and bindings
@ 2023-10-03 16:38 Gokhan Celik
  2023-10-03 16:38 ` [PATCH v3 1/2] regulator: max77503: Add ADI MAX77503 support Gokhan Celik
  2023-10-03 16:38 ` [PATCH v3 2/2] regulator: dt-bindings: " Gokhan Celik
  0 siblings, 2 replies; 7+ messages in thread
From: Gokhan Celik @ 2023-10-03 16:38 UTC (permalink / raw)
  To: outreachy
  Cc: Gokhan Celik, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Gokhan Celik

Add MAX77503 buck converter driver and devicetree bindings.
Apply patches in sequence.

Gokhan Celik (2):
  regulator: max77503: Add ADI MAX77503 support
  regulator: dt-bindings: Add ADI MAX77503 support

 .../regulator/adi,max77503-regulator.yaml     |  51 +++++++
 drivers/regulator/Kconfig                     |  10 ++
 drivers/regulator/Makefile                    |   1 +
 drivers/regulator/max77503-regulator.c        | 137 ++++++++++++++++++
 4 files changed, 199 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/adi,max77503-regulator.yaml
 create mode 100644 drivers/regulator/max77503-regulator.c

-- 
2.34.1


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

* [PATCH v3 1/2] regulator: max77503: Add ADI MAX77503 support
  2023-10-03 16:38 [PATCH v3 0/2] Add ADI MAX77503 regulator driver and bindings Gokhan Celik
@ 2023-10-03 16:38 ` Gokhan Celik
  2023-10-03 16:58   ` Mark Brown
  2023-10-23 17:00   ` Mark Brown
  2023-10-03 16:38 ` [PATCH v3 2/2] regulator: dt-bindings: " Gokhan Celik
  1 sibling, 2 replies; 7+ messages in thread
From: Gokhan Celik @ 2023-10-03 16:38 UTC (permalink / raw)
  To: outreachy
  Cc: Gokhan Celik, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Gokhan Celik

Add ADI MAX77503 buck converter driver support.

Signed-off-by: Gokhan Celik <gokhan.celik@analog.com>
---
 drivers/regulator/Kconfig              |  10 ++
 drivers/regulator/Makefile             |   1 +
 drivers/regulator/max77503-regulator.c | 137 +++++++++++++++++++++++++
 3 files changed, 148 insertions(+)
 create mode 100644 drivers/regulator/max77503-regulator.c

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 823f8e6e4801..dbd2053774e9 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -556,6 +556,16 @@ config REGULATOR_MAX597X
 	  The MAX5970/5978 is a smart switch with no output regulation, but
 	  fault protection and voltage and current monitoring capabilities.
 
+config REGULATOR_MAX77503
+	tristate "Analog Devices MAX77503 Regulator"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  This driver controls a Analog Devices MAX77503 14V input, 1.5A
+	  high-efficiency buck converter via I2C bus.
+	  Say M here if you want to include support for the regulator as a
+	  module.
+
 config REGULATOR_MAX77541
 	tristate "Analog Devices MAX77541/77540 Regulator"
 	depends on MFD_MAX77541
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 15e0d614ff66..b5b724699b51 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -68,6 +68,7 @@ obj-$(CONFIG_REGULATOR_LTC3676) += ltc3676.o
 obj-$(CONFIG_REGULATOR_MAX14577) += max14577-regulator.o
 obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o
 obj-$(CONFIG_REGULATOR_MAX597X) += max597x-regulator.o
+obj-$(CONFIG_REGULATOR_MAX77503) += max77503-regulator.o
 obj-$(CONFIG_REGULATOR_MAX77541) += max77541-regulator.o
 obj-$(CONFIG_REGULATOR_MAX77620) += max77620-regulator.o
 obj-$(CONFIG_REGULATOR_MAX77650) += max77650-regulator.o
diff --git a/drivers/regulator/max77503-regulator.c b/drivers/regulator/max77503-regulator.c
new file mode 100644
index 000000000000..4a6ba4dd2acd
--- /dev/null
+++ b/drivers/regulator/max77503-regulator.c
@@ -0,0 +1,137 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2023 Analog Devices, Inc.
+ * ADI regulator driver for MAX77503.
+ */
+
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/of_regulator.h>
+#include <linux/util_macros.h>
+
+#define MAX77503_REG_CFG			0x00
+#define MAX77503_REG_VOUT			0x01
+
+#define MAX77503_BIT_EN				BIT(0)
+#define MAX77503_BIT_CURR_LIM		BIT(3)
+#define MAX77503_BIT_ADEN			BIT(6)
+
+#define MAX77503_BITS_SOFT_START	GENMASK(5, 4)
+#define MAX77503_BITS_MX_VOUT		GENMASK(7, 0)
+
+#define MAX77503_AD_ENABLED			0x1
+#define MAX77503_AD_DISABLED		0x0
+
+struct max77503_dev {
+	struct device *dev;
+	struct device_node *of_node;
+	struct regulator_desc desc;
+	struct regulator_dev *rdev;
+	struct regmap *regmap;
+};
+
+static const struct regmap_config max77503_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = 0x2,
+};
+
+static const struct regulator_ops max77503_buck_ops = {
+	.list_voltage = regulator_list_voltage_linear_range,
+	.map_voltage = regulator_map_voltage_ascend,
+	.is_enabled = regulator_is_enabled_regmap,
+	.enable = regulator_enable_regmap,
+	.disable = regulator_disable_regmap,
+	.get_voltage_sel = regulator_get_voltage_sel_regmap,
+	.set_voltage_sel = regulator_set_voltage_sel_regmap,
+	.get_current_limit = regulator_get_current_limit_regmap,
+	.set_current_limit = regulator_set_current_limit_regmap,
+	.set_active_discharge = regulator_set_active_discharge_regmap,
+	.set_soft_start = regulator_set_soft_start_regmap,
+};
+
+static const struct linear_range max77503_buck_ranges[] = {
+	REGULATOR_LINEAR_RANGE(800000, 0x00, 0x54, 50000)
+};
+
+static const unsigned int max77503_current_limit_table[] = {
+	500000, 2000000
+};
+
+static const struct regulator_desc max77503_regulators_desc = {
+	.name = "max77503",
+	.enable_reg = MAX77503_REG_CFG,
+	.enable_mask = MAX77503_BIT_EN,
+	.ops = &max77503_buck_ops,
+	.type = REGULATOR_VOLTAGE,
+	.linear_ranges = max77503_buck_ranges,
+	.n_linear_ranges = ARRAY_SIZE(max77503_buck_ranges),
+	.vsel_reg = MAX77503_REG_VOUT,
+	.vsel_mask = MAX77503_BITS_MX_VOUT,
+	.soft_start_reg = MAX77503_REG_CFG,
+	.soft_start_mask = MAX77503_BITS_SOFT_START,
+	.active_discharge_reg = MAX77503_REG_CFG,
+	.active_discharge_mask = MAX77503_BIT_ADEN,
+	.active_discharge_off = MAX77503_AD_DISABLED,
+	.active_discharge_on = MAX77503_AD_ENABLED,
+	.csel_reg = MAX77503_REG_CFG,
+	.csel_mask = MAX77503_BIT_CURR_LIM,
+	.curr_table = max77503_current_limit_table,
+	.n_current_limits = ARRAY_SIZE(max77503_current_limit_table),
+	.owner = THIS_MODULE,
+};
+
+static int max77503_regulator_probe(struct i2c_client *client)
+{
+	struct device *dev = &client->dev;
+	struct regulator_config config = {};
+	struct regulator_dev *rdev;
+
+	config.dev = dev;
+	config.of_node = dev->of_node;
+	config.regmap = devm_regmap_init_i2c(client, &max77503_regmap_config);
+	if (IS_ERR(config.regmap)) {
+		dev_err(dev, "Failed to init regmap");
+		return PTR_ERR(config.regmap);
+	}
+
+	rdev = devm_regulator_register(dev, &max77503_regulators_desc, &config);
+	if (IS_ERR(rdev)) {
+		dev_err(dev, "Failed to register regulator MAX77503");
+		return PTR_ERR(rdev);
+	}
+
+	return 0;
+}
+
+static const struct of_device_id of_max77503_match_tbl[] = {
+	{ .compatible = "adi,max77503", },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(of, of_max77503_match_tbl);
+
+static const struct i2c_device_id max77503_regulator_id[] = {
+	{"max77503"},
+	{ }
+};
+
+MODULE_DEVICE_TABLE(i2c, max77503_regulator_id);
+
+static struct i2c_driver max77503_regulator_driver = {
+	.driver = {
+		.name = "max77503",
+		.of_match_table = of_max77503_match_tbl
+	},
+	.probe = max77503_regulator_probe,
+	.id_table = max77503_regulator_id,
+};
+
+module_i2c_driver(max77503_regulator_driver);
+
+MODULE_AUTHOR("Gokhan Celik <Gokhan.Celik@analog.com>");
+MODULE_DESCRIPTION("MAX77503 regulator driver");
+MODULE_LICENSE("GPL");
-- 
2.34.1


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

* [PATCH v3 2/2] regulator: dt-bindings: Add ADI MAX77503 support
  2023-10-03 16:38 [PATCH v3 0/2] Add ADI MAX77503 regulator driver and bindings Gokhan Celik
  2023-10-03 16:38 ` [PATCH v3 1/2] regulator: max77503: Add ADI MAX77503 support Gokhan Celik
@ 2023-10-03 16:38 ` Gokhan Celik
  2023-10-04  7:52   ` Krzysztof Kozlowski
  1 sibling, 1 reply; 7+ messages in thread
From: Gokhan Celik @ 2023-10-03 16:38 UTC (permalink / raw)
  To: outreachy
  Cc: Gokhan Celik, Conor Dooley, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Gokhan Celik

Add ADI MAX77503 buck converter devicetree document.

Signed-off-by: Gokhan Celik <gokhan.celik@analog.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
---
Changelog:
V2 -> V3: Addressed the review comments
 
 .../regulator/adi,max77503-regulator.yaml     | 51 +++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/adi,max77503-regulator.yaml

diff --git a/Documentation/devicetree/bindings/regulator/adi,max77503-regulator.yaml b/Documentation/devicetree/bindings/regulator/adi,max77503-regulator.yaml
new file mode 100644
index 000000000000..554df8e2b0b6
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/adi,max77503-regulator.yaml
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright (c) 2023 Analog Devices, Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/adi,max77503-regulator.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices MAX77503 Buck Converter
+
+maintainers:
+  - Gokhan Celik <Gokhan.Celik@analog.com>
+
+description: |
+  The Analog Devices MAX77503 is a single channel 14V input, 1.5A 
+  high-efficiency buck converter. This converter has 94% efficiency
+  for 2-Cell/3-Cell battery applications.
+
+allOf:
+  - $ref: regulator.yaml#
+
+properties:
+  compatible:
+    enum:
+      - adi,max77503
+
+  reg:
+    description: I2C address of the device
+    items:
+      - enum: [0x1e, 0x24, 0x37]
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        regulator@1e {
+            compatible = "adi,max77503";
+            reg = <0x1e>;
+
+            regulator-min-microvolt = <800000>;
+            regulator-max-microvolt = <5000000>;
+        };
+    };
+
-- 
2.34.1


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

* Re: [PATCH v3 1/2] regulator: max77503: Add ADI MAX77503 support
  2023-10-03 16:38 ` [PATCH v3 1/2] regulator: max77503: Add ADI MAX77503 support Gokhan Celik
@ 2023-10-03 16:58   ` Mark Brown
  2023-10-23 17:00   ` Mark Brown
  1 sibling, 0 replies; 7+ messages in thread
From: Mark Brown @ 2023-10-03 16:58 UTC (permalink / raw)
  To: Gokhan Celik
  Cc: outreachy, Liam Girdwood, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley

[-- Attachment #1: Type: text/plain, Size: 179 bytes --]

On Tue, Oct 03, 2023 at 07:38:02PM +0300, Gokhan Celik wrote:
> Add ADI MAX77503 buck converter driver support.

This doesn't apply against current code, please check and resend.

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

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

* Re: [PATCH v3 2/2] regulator: dt-bindings: Add ADI MAX77503 support
  2023-10-03 16:38 ` [PATCH v3 2/2] regulator: dt-bindings: " Gokhan Celik
@ 2023-10-04  7:52   ` Krzysztof Kozlowski
  2023-10-04  7:53     ` Krzysztof Kozlowski
  0 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2023-10-04  7:52 UTC (permalink / raw)
  To: Gokhan Celik, outreachy
  Cc: Conor Dooley, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley

On 03/10/2023 18:38, Gokhan Celik wrote:
> Add ADI MAX77503 buck converter devicetree document.
> 
> Signed-off-by: Gokhan Celik <gokhan.celik@analog.com>
> Reviewed-by: Conor Dooley <conor.dooley@microchip.com>

Please use scripts/get_maintainers.pl to get a list of necessary people
and lists to CC. It might happen, that command when run on an older
kernel, gives you outdated entries. Therefore please be sure you base
your patches on recent Linux kernel.

You missed at least devicetree list (maybe more), so this won't be
tested by automated tooling.

Please kindly resend and include all necessary To/Cc entries.


...

> +
> +examples:
> +  - |
> +    i2c {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        regulator@1e {
> +            compatible = "adi,max77503";
> +            reg = <0x1e>;
> +
> +            regulator-min-microvolt = <800000>;
> +            regulator-max-microvolt = <5000000>;
> +        };
> +    };
> +

Looks like extra blank line here.


Best regards,
Krzysztof


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

* Re: [PATCH v3 2/2] regulator: dt-bindings: Add ADI MAX77503 support
  2023-10-04  7:52   ` Krzysztof Kozlowski
@ 2023-10-04  7:53     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2023-10-04  7:53 UTC (permalink / raw)
  To: Gokhan Celik, outreachy
  Cc: Conor Dooley, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley

On 04/10/2023 09:52, Krzysztof Kozlowski wrote:
> On 03/10/2023 18:38, Gokhan Celik wrote:
>> Add ADI MAX77503 buck converter devicetree document.
>>
>> Signed-off-by: Gokhan Celik <gokhan.celik@analog.com>
>> Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
> 
> Please use scripts/get_maintainers.pl to get a list of necessary people
> and lists to CC. It might happen, that command when run on an older
> kernel, gives you outdated entries. Therefore please be sure you base
> your patches on recent Linux kernel.
> 
> You missed at least devicetree list (maybe more), so this won't be
> tested by automated tooling.
> 
> Please kindly resend and include all necessary To/Cc entries.

Update: this missed all mailing lists, in fact. :/

Best regards,
Krzysztof


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

* Re: [PATCH v3 1/2] regulator: max77503: Add ADI MAX77503 support
  2023-10-03 16:38 ` [PATCH v3 1/2] regulator: max77503: Add ADI MAX77503 support Gokhan Celik
  2023-10-03 16:58   ` Mark Brown
@ 2023-10-23 17:00   ` Mark Brown
  1 sibling, 0 replies; 7+ messages in thread
From: Mark Brown @ 2023-10-23 17:00 UTC (permalink / raw)
  To: outreachy, Gokhan Celik
  Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Gokhan Celik

On Tue, 03 Oct 2023 19:38:02 +0300, Gokhan Celik wrote:
> Add ADI MAX77503 buck converter driver support.
> 
> 

Applied to

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

Thanks!

[1/2] regulator: max77503: Add ADI MAX77503 support
      commit: a0c543bdf4ba4f10d21fb2d44a9abc5715184966
[2/2] regulator: dt-bindings: Add ADI MAX77503 support
      commit: ff5f76b820a95957df0420bba4c67b02978e6c52

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] 7+ messages in thread

end of thread, other threads:[~2023-10-23 17:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-03 16:38 [PATCH v3 0/2] Add ADI MAX77503 regulator driver and bindings Gokhan Celik
2023-10-03 16:38 ` [PATCH v3 1/2] regulator: max77503: Add ADI MAX77503 support Gokhan Celik
2023-10-03 16:58   ` Mark Brown
2023-10-23 17:00   ` Mark Brown
2023-10-03 16:38 ` [PATCH v3 2/2] regulator: dt-bindings: " Gokhan Celik
2023-10-04  7:52   ` Krzysztof Kozlowski
2023-10-04  7:53     ` Krzysztof Kozlowski

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.