* [PATCH v2 0/2] DA9121 regulator support
@ 2020-11-03 10:00 Vincent Whitchurch
2020-11-03 10:00 ` [PATCH v2 1/2] dt-bindings: regulator: Add DA9121 Vincent Whitchurch
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Vincent Whitchurch @ 2020-11-03 10:00 UTC (permalink / raw)
To: lgirdwood, broonie, support.opensource
Cc: kernel, devicetree, linux-kernel, robh+dt, Vincent Whitchurch
This series adds support for the DA9121, a "High-Performance, 10 A, Dual-Phase
DC-DC Converter". The datasheet is currently available here:
https://www.dialog-semiconductor.com/sites/default/files/da9121_datasheet_2v3.pdf
v2:
- Let the core get the constraints itself from a subnode in the device tree.
Vincent Whitchurch (2):
dt-bindings: regulator: Add DA9121
regulator: Add support for DA9121 regulator
.../bindings/regulator/dlg,da9121.yaml | 47 ++++++++
drivers/regulator/Kconfig | 12 ++
drivers/regulator/Makefile | 1 +
drivers/regulator/da9121-regulator.c | 108 ++++++++++++++++++
4 files changed, 168 insertions(+)
create mode 100644 Documentation/devicetree/bindings/regulator/dlg,da9121.yaml
create mode 100644 drivers/regulator/da9121-regulator.c
--
2.28.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/2] dt-bindings: regulator: Add DA9121
2020-11-03 10:00 [PATCH v2 0/2] DA9121 regulator support Vincent Whitchurch
@ 2020-11-03 10:00 ` Vincent Whitchurch
2020-11-04 18:57 ` Rob Herring
2020-11-03 10:00 ` [PATCH v2 2/2] regulator: Add support for DA9121 regulator Vincent Whitchurch
2020-11-03 18:15 ` [PATCH v2 0/2] DA9121 regulator support Mark Brown
2 siblings, 1 reply; 7+ messages in thread
From: Vincent Whitchurch @ 2020-11-03 10:00 UTC (permalink / raw)
To: lgirdwood, broonie, support.opensource
Cc: kernel, devicetree, linux-kernel, robh+dt, Vincent Whitchurch
Add bindings for the Dialog Semiconductor DA9121 voltage regulator.
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
.../bindings/regulator/dlg,da9121.yaml | 47 +++++++++++++++++++
1 file changed, 47 insertions(+)
create mode 100644 Documentation/devicetree/bindings/regulator/dlg,da9121.yaml
diff --git a/Documentation/devicetree/bindings/regulator/dlg,da9121.yaml b/Documentation/devicetree/bindings/regulator/dlg,da9121.yaml
new file mode 100644
index 000000000000..cde0d82dd201
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/dlg,da9121.yaml
@@ -0,0 +1,47 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/dlg,da9121.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Dialog Semiconductor DA9121 voltage regulator
+
+maintainers:
+ - Vincent Whitchurch <vincent.whitchurch@axis.com>
+
+properties:
+ compatible:
+ const: dlg,da9121
+
+ reg:
+ maxItems: 1
+
+ buck1:
+ description:
+ Initial data for the Buck1 regulator.
+ $ref: "regulator.yaml#"
+ type: object
+
+unevaluatedProperties: false
+
+required:
+ - compatible
+ - reg
+
+examples:
+ - |
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ regulator@68 {
+ compatible = "dlg,da9121";
+ reg = <0x68>;
+
+ buck1 {
+ regulator-min-microvolt = <680000>;
+ regulator-max-microvolt = <820000>;
+ };
+ };
+ };
+
+...
--
2.28.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] regulator: Add support for DA9121 regulator
2020-11-03 10:00 [PATCH v2 0/2] DA9121 regulator support Vincent Whitchurch
2020-11-03 10:00 ` [PATCH v2 1/2] dt-bindings: regulator: Add DA9121 Vincent Whitchurch
@ 2020-11-03 10:00 ` Vincent Whitchurch
2020-11-03 18:15 ` [PATCH v2 0/2] DA9121 regulator support Mark Brown
2 siblings, 0 replies; 7+ messages in thread
From: Vincent Whitchurch @ 2020-11-03 10:00 UTC (permalink / raw)
To: lgirdwood, broonie, support.opensource
Cc: kernel, devicetree, linux-kernel, robh+dt, Vincent Whitchurch
Add support for the Dialog Semiconductor DA9121, a single-channel
dual-phase buck converter controlled via I2C.
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
drivers/regulator/Kconfig | 12 +++
drivers/regulator/Makefile | 1 +
drivers/regulator/da9121-regulator.c | 108 +++++++++++++++++++++++++++
3 files changed, 121 insertions(+)
create mode 100644 drivers/regulator/da9121-regulator.c
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 020a00d6696b..005a6036dd38 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -303,6 +303,18 @@ config REGULATOR_DA9063
This driver can also be built as a module. If so, the module
will be called da9063-regulator.
+config REGULATOR_DA9121
+ tristate "Dialog Semiconductor DA9121 regulator"
+ depends on I2C && OF
+ select REGMAP_I2C
+ help
+ Say y here to support for the Dialog Semiconductor DA9121. The
+ DA9210 is a dual-phase buck converter controlled through an I2C
+ interface.
+
+ This driver can also be built as a module. If so, the module
+ will be called da9121-regulator.
+
config REGULATOR_DA9210
tristate "Dialog Semiconductor DA9210 regulator"
depends on I2C
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 6ebae516258e..6096862a1d60 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
obj-$(CONFIG_REGULATOR_DA9055) += da9055-regulator.o
obj-$(CONFIG_REGULATOR_DA9062) += da9062-regulator.o
obj-$(CONFIG_REGULATOR_DA9063) += da9063-regulator.o
+obj-$(CONFIG_REGULATOR_DA9121) += da9121-regulator.o
obj-$(CONFIG_REGULATOR_DA9210) += da9210-regulator.o
obj-$(CONFIG_REGULATOR_DA9211) += da9211-regulator.o
obj-$(CONFIG_REGULATOR_DBX500_PRCMU) += dbx500-prcmu.o
diff --git a/drivers/regulator/da9121-regulator.c b/drivers/regulator/da9121-regulator.c
new file mode 100644
index 000000000000..66bdfd1979c0
--- /dev/null
+++ b/drivers/regulator/da9121-regulator.c
@@ -0,0 +1,108 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (C) 2020 Axis Communications AB */
+
+#include <linux/of_device.h>
+#include <linux/regulator/of_regulator.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/driver.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+#include <linux/err.h>
+#include <linux/i2c.h>
+
+#define DA9121_BUCK_BUCK1_0 0x20
+#define DA9121_BUCK_BUCK1_0_CH1_EN BIT(0)
+
+#define DA9121_BUCK_BUCK1_5 0x25
+#define DA9121_BUCK_BUCK1_5_CH1_A_VOUT GENMASK(7, 0)
+
+#define DA9121_MIN_MV 300
+#define DA9121_MAX_MV 1900
+#define DA9121_STEP_MV 10
+#define DA9121_MIN_SEL (DA9121_MIN_MV / DA9121_STEP_MV)
+#define DA9121_N_VOLTAGES (((DA9121_MAX_MV - DA9121_MIN_MV) / DA9121_STEP_MV) \
+ + 1 + DA9121_MIN_SEL)
+
+static const struct regmap_config da9121_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+};
+
+static const struct regulator_ops da9121_buck_ops = {
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .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 const struct regulator_desc da9121_reg = {
+ .name = "da9121",
+ .of_match = "buck1",
+ .owner = THIS_MODULE,
+ .ops = &da9121_buck_ops,
+ .type = REGULATOR_VOLTAGE,
+ .n_voltages = DA9121_N_VOLTAGES,
+ .min_uV = DA9121_MIN_MV * 1000,
+ .uV_step = DA9121_STEP_MV * 1000,
+ .linear_min_sel = DA9121_MIN_SEL,
+ .vsel_reg = DA9121_BUCK_BUCK1_5,
+ .vsel_mask = DA9121_BUCK_BUCK1_5_CH1_A_VOUT,
+ .enable_reg = DA9121_BUCK_BUCK1_0,
+ .enable_mask = DA9121_BUCK_BUCK1_0_CH1_EN,
+ /* Default value of BUCK_BUCK1_0.CH1_SRC_DVC_UP */
+ .ramp_delay = 20000,
+ /* tBUCK_EN */
+ .enable_time = 20,
+};
+
+static const struct of_device_id da9121_dt_ids[] = {
+ { .compatible = "dlg,da9121", },
+ { }
+};
+MODULE_DEVICE_TABLE(of, da9121_dt_ids);
+
+static int da9121_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, &da9121_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, &da9121_reg, &config);
+ if (IS_ERR(rdev)) {
+ dev_err(&i2c->dev, "Failed to register da9121 regulator\n");
+ return PTR_ERR(rdev);
+ }
+
+ return 0;
+}
+
+static const struct i2c_device_id da9121_i2c_id[] = {
+ { "da9121", 0 },
+ {},
+};
+MODULE_DEVICE_TABLE(i2c, da9121_i2c_id);
+
+static struct i2c_driver da9121_regulator_driver = {
+ .driver = {
+ .name = "da9121",
+ .of_match_table = of_match_ptr(da9121_dt_ids),
+ },
+ .probe = da9121_i2c_probe,
+ .id_table = da9121_i2c_id,
+};
+
+module_i2c_driver(da9121_regulator_driver);
+
+MODULE_LICENSE("GPL v2");
--
2.28.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/2] DA9121 regulator support
2020-11-03 10:00 [PATCH v2 0/2] DA9121 regulator support Vincent Whitchurch
2020-11-03 10:00 ` [PATCH v2 1/2] dt-bindings: regulator: Add DA9121 Vincent Whitchurch
2020-11-03 10:00 ` [PATCH v2 2/2] regulator: Add support for DA9121 regulator Vincent Whitchurch
@ 2020-11-03 18:15 ` Mark Brown
2 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2020-11-03 18:15 UTC (permalink / raw)
To: lgirdwood, support.opensource, Vincent Whitchurch
Cc: devicetree, robh+dt, kernel, linux-kernel
On Tue, 3 Nov 2020 11:00:19 +0100, Vincent Whitchurch wrote:
> This series adds support for the DA9121, a "High-Performance, 10 A, Dual-Phase
> DC-DC Converter". The datasheet is currently available here:
>
> https://www.dialog-semiconductor.com/sites/default/files/da9121_datasheet_2v3.pdf
>
> v2:
> - Let the core get the constraints itself from a subnode in the device tree.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
Thanks!
[1/2] regulator: Add DA9121
commit: 1119c59404141200125af31f775d3fbbba52c651
[2/2] regulator: Add support for DA9121 regulator
commit: e6ff10f24c587c1af705b898761e5df615fb0e1a
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
* Re: [PATCH v2 1/2] dt-bindings: regulator: Add DA9121
2020-11-03 10:00 ` [PATCH v2 1/2] dt-bindings: regulator: Add DA9121 Vincent Whitchurch
@ 2020-11-04 18:57 ` Rob Herring
2020-11-05 9:39 ` Vincent Whitchurch
0 siblings, 1 reply; 7+ messages in thread
From: Rob Herring @ 2020-11-04 18:57 UTC (permalink / raw)
To: Vincent Whitchurch
Cc: lgirdwood, broonie, kernel, devicetree, linux-kernel, robh+dt,
support.opensource
On Tue, 03 Nov 2020 11:00:20 +0100, Vincent Whitchurch wrote:
> Add bindings for the Dialog Semiconductor DA9121 voltage regulator.
>
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> ---
> .../bindings/regulator/dlg,da9121.yaml | 47 +++++++++++++++++++
> 1 file changed, 47 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/regulator/dlg,da9121.yaml
>
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/regulator/dlg,da9121.yaml: 'additionalProperties' is a required property
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/regulator/dlg,da9121.yaml: ignoring, error in schema:
warning: no schema found in file: ./Documentation/devicetree/bindings/regulator/dlg,da9121.yaml
See https://patchwork.ozlabs.org/patch/1392753
The base for the patch is generally the last rc1. Any dependencies
should be noted.
If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:
pip3 install dtschema --upgrade
Please check and re-submit.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: regulator: Add DA9121
2020-11-04 18:57 ` Rob Herring
@ 2020-11-05 9:39 ` Vincent Whitchurch
2020-11-20 20:32 ` Rob Herring
0 siblings, 1 reply; 7+ messages in thread
From: Vincent Whitchurch @ 2020-11-05 9:39 UTC (permalink / raw)
To: Rob Herring
Cc: lgirdwood, broonie, kernel, devicetree, linux-kernel, robh+dt,
support.opensource
On Wed, Nov 04, 2020 at 07:57:55PM +0100, Rob Herring wrote:
> On Tue, 03 Nov 2020 11:00:20 +0100, Vincent Whitchurch wrote:
> > Add bindings for the Dialog Semiconductor DA9121 voltage regulator.
> >
> > Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> > ---
> > .../bindings/regulator/dlg,da9121.yaml | 47 +++++++++++++++++++
> > 1 file changed, 47 insertions(+)
> > create mode 100644 Documentation/devicetree/bindings/regulator/dlg,da9121.yaml
> >
>
> My bot found errors running 'make dt_binding_check' on your patch:
>
> yamllint warnings/errors:
>
> dtschema/dtc warnings/errors:
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/regulator/dlg,da9121.yaml: 'additionalProperties' is a required property
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/regulator/dlg,da9121.yaml: ignoring, error in schema:
> warning: no schema found in file: ./Documentation/devicetree/bindings/regulator/dlg,da9121.yaml
>
> See https://patchwork.ozlabs.org/patch/1392753
OK, thanks. I'll fix it by changing the unevaluatedProperties to an
additionalProperties (since the $ref has moved).
I think I should also move the unevaluatedProperties to the buck1 level
instead of removing it completely, because I see a bunch of other
regulator bindings doing it, but the checks don't complain about that
being missing and I can't see that making any difference for the
validation.
For example, I was hoping that this:
buck1:
description:
Initial data for the Buck1 regulator.
$ref: "regulator.yaml#"
type: object
unevaluatedProperties: false
would complain about something like:
buck1 {
not-a-real-property;
regulator-min-microvolt = <680000>;
regulator-max-microvolt = <820000>;
};
but it doesn't, so I don't quite understand what "unevaluatedProperties:
false" prevents.
>
> The base for the patch is generally the last rc1. Any dependencies
> should be noted.
>
> If you already ran 'make dt_binding_check' and didn't see the above
> error(s), then make sure 'yamllint' is installed and dt-schema is up to
> date:
>
> pip3 install dtschema --upgrade
Not sure if it's just something wrong in my setup, but I had dtschema
installed from master a while ago, and the above command didn't upgrade
it for me. I had to explicitly upgrade it with the full URL again to
get the latest version:
pip3 install --upgrade git+https://github.com/devicetree-org/dt-schema.git@master
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: regulator: Add DA9121
2020-11-05 9:39 ` Vincent Whitchurch
@ 2020-11-20 20:32 ` Rob Herring
0 siblings, 0 replies; 7+ messages in thread
From: Rob Herring @ 2020-11-20 20:32 UTC (permalink / raw)
To: Vincent Whitchurch
Cc: lgirdwood, broonie, kernel, devicetree, linux-kernel, support.opensource
On Thu, Nov 5, 2020 at 3:39 AM Vincent Whitchurch
<vincent.whitchurch@axis.com> wrote:
>
> On Wed, Nov 04, 2020 at 07:57:55PM +0100, Rob Herring wrote:
> > On Tue, 03 Nov 2020 11:00:20 +0100, Vincent Whitchurch wrote:
> > > Add bindings for the Dialog Semiconductor DA9121 voltage regulator.
> > >
> > > Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> > > ---
> > > .../bindings/regulator/dlg,da9121.yaml | 47 +++++++++++++++++++
> > > 1 file changed, 47 insertions(+)
> > > create mode 100644 Documentation/devicetree/bindings/regulator/dlg,da9121.yaml
> > >
> >
> > My bot found errors running 'make dt_binding_check' on your patch:
> >
> > yamllint warnings/errors:
> >
> > dtschema/dtc warnings/errors:
> > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/regulator/dlg,da9121.yaml: 'additionalProperties' is a required property
> > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/regulator/dlg,da9121.yaml: ignoring, error in schema:
> > warning: no schema found in file: ./Documentation/devicetree/bindings/regulator/dlg,da9121.yaml
> >
> > See https://patchwork.ozlabs.org/patch/1392753
>
> OK, thanks. I'll fix it by changing the unevaluatedProperties to an
> additionalProperties (since the $ref has moved).
>
> I think I should also move the unevaluatedProperties to the buck1 level
> instead of removing it completely, because I see a bunch of other
> regulator bindings doing it, but the checks don't complain about that
> being missing and I can't see that making any difference for the
> validation.
Because the meta-schema is not recursing down levels. It probably
should, but that's another round of fixing all the current cases. And
the top-level is more well defined as to what the structure is (IOW,
we might not be able to define a rule that works everywhere).
> For example, I was hoping that this:
>
> buck1:
> description:
> Initial data for the Buck1 regulator.
> $ref: "regulator.yaml#"
> type: object
> unevaluatedProperties: false
>
> would complain about something like:
>
> buck1 {
> not-a-real-property;
> regulator-min-microvolt = <680000>;
> regulator-max-microvolt = <820000>;
> };
>
> but it doesn't, so I don't quite understand what "unevaluatedProperties:
> false" prevents.
That's because it's currently a nop as the Python jsonschema package
doesn't yet support 2019.09 version of jsonschema.
If you aren't defining properties in addition to what's defined by a
$ref, then use additionalProperties.
Rob
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-11-20 20:32 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-03 10:00 [PATCH v2 0/2] DA9121 regulator support Vincent Whitchurch
2020-11-03 10:00 ` [PATCH v2 1/2] dt-bindings: regulator: Add DA9121 Vincent Whitchurch
2020-11-04 18:57 ` Rob Herring
2020-11-05 9:39 ` Vincent Whitchurch
2020-11-20 20:32 ` Rob Herring
2020-11-03 10:00 ` [PATCH v2 2/2] regulator: Add support for DA9121 regulator Vincent Whitchurch
2020-11-03 18:15 ` [PATCH v2 0/2] DA9121 regulator support 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.