Skip to contentSkip to conversation

Add ltc3562 voltage regulator driver

PATCH Superseded Mike Looijmans 3 participants 31 messages Oct 29, 2014 – Nov 5, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

This patch adds the LTC3562 I2C controlled voltage regulator to the kernel. The driver was tested and developed on a Topic Miami board where this chip supplies the IO voltages for the FPGA pins.

#1 lore raw

PATCH 1/1 Add ltc3562 voltage regulator driver

The ltc3562 is an I2C controlled regulator supporting 4 independent outputs.

---
 drivers/regulator/Kconfig   |    7 +
 drivers/regulator/Makefile  |    1 +
 drivers/regulator/ltc3562.c |  387 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 395 insertions(+)
 create mode 100644 drivers/regulator/ltc3562.c
drivers/regulator/Kconfig +7 -0
index 55d7b7b..4012601 100644
@@ -300,6 +300,13 @@ config REGULATOR_LP8788
 	help
 	  This driver supports LP8788 voltage regulator chip.
 
+config REGULATOR_LTC3562
+	tristate "LCT3562 quad output voltage regulator"
+	depends on I2C
+	help
+	  This enables support for the LCT3562 quad output voltage regulator
+	  controlled via I2C.
+
 config REGULATOR_LTC3589
 	tristate "LTC3589 8-output voltage regulator"
 	depends on I2C
drivers/regulator/Makefile +1 -0
index 1029ed3..9a15146 100644
@@ -41,6 +41,7 @@ obj-$(CONFIG_REGULATOR_LP872X) += lp872x.o
 obj-$(CONFIG_REGULATOR_LP8788) += lp8788-buck.o
 obj-$(CONFIG_REGULATOR_LP8788) += lp8788-ldo.o
 obj-$(CONFIG_REGULATOR_LP8755) += lp8755.o
+obj-$(CONFIG_REGULATOR_LTC3562) += ltc3562.o
 obj-$(CONFIG_REGULATOR_LTC3589) += ltc3589.o
 obj-$(CONFIG_REGULATOR_MAX14577) += max14577.o
 obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o
drivers/regulator/ltc3562.c new file +387 -0

387 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#2 lore raw

drivers/regulator/ltc3562.c line 80

Quoted 3 lines · Mike Looijmans
drivers/regulator/ltc3562.c new file +3 -0
+	if (!status->voltage_set) {
+		if (of_property_read_u32(dev->dev.of_node,
+			"ltc3562-default-voltage", &v_default) == 0) {

A couple of problems here:

- This contains DT code but no DT bindings documentation; the binding documentation is mandatory for any new bindings.
- It's not obvious why a "default voltage" property would be device specific - what is this for and why is it being added in an individual device driver?

#3 lore raw
Quoted 10 lines · Mark Brown

drivers/regulator/ltc3562.c line 80

Quoted 3 lines · Mike Looijmans
drivers/regulator/ltc3562.c new file +3 -0
+	if (!status->voltage_set) {
+		if (of_property_read_u32(dev->dev.of_node,
+			"ltc3562-default-voltage", &v_default) == 0) {

A couple of problems here:

- This contains DT code but no DT bindings documentation; the binding documentation is mandatory for any new bindings.

Should I submit a new patch to add the DT bindings and CC to the dt mailing list, or do you want it included in this patch? I was basically waiting for feedback on the driver first.

Quoted 3 lines

- It's not obvious why a "default voltage" property would be device specific - what is this for and why is it being added in an individual device driver?

As for the "why" part: The default is used when there isn't a consumer available. It'll typically be combined with "always-on". When the output is used for say an MMC card, the consumer will ask for a specific voltage. When used to regulate the IO voltage of an FPGA bank (as is the case on our board), there isn't a single consumer to request a particular voltage, but the min and max will represent the range that the IO banks support (e.g. 1v8..3v3 or 1v2..1v8), because selecting voltages outside this range may damage the FPGA hardware. This allows a devicetree overlay to specify a different value for a different board or application, while still being able to restrict the range to what the hardware connected to the regulator supports.

The "default voltage" may not be device specific, but regulator.txt doesn't have a property that describes what we needed here, because we can't get away with specifying min=max as fixed-regulator does. We also cannot assume that default=min or default=max, because that might harm hardware connected to the other side of the IO bank.

I noticed after rebasing to mainline that there is now also a driver for a similar chip (similar in function, that is), the ltc3589, which requires similar properties like the resistor dividers. I think it would be good to use similar names in the ltc3562 driver. I'll do that first and submit a v2 patch, along with the DT description.

Thank you for your feedback, Mike.

Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert

TOPIC Embedded Systems Eindhovenseweg 32-C, NL-5683 KH Best Postbus 440, NL-5680 AK Best
Telefoon: (+31) (0) 499 33 69 79
Telefax: (+31) (0) 499 33 69 70
E-mail: [email protected]
Website: www.topic.nl

Please consider the environment before printing this e-mail

Topic zoekt gedreven (embedded) software specialisten!
http://topic.nl/vacatures/topic-zoekt-software-engineers/

maintainer
#4 lore raw
Quoted 10 lines · Mike Looijmans
Quoted 4 lines · Mark Brown

A couple of problems here:

- This contains DT code but no DT bindings documentation; the binding documentation is mandatory for any new bindings.

Should I submit a new patch to add the DT bindings and CC to the dt mailing list, or do you want it included in this patch? I was basically waiting for feedback on the driver first.

I'm not going to review a driver with bindings without those bindings being documented, it's a well documented requirement and apart from anything else it's not really possible to review the code that manages the bindings without seeing the bindings.

Quoted 5 lines

The "default voltage" may not be device specific, but regulator.txt doesn't have a property that describes what we needed here, because we can't get away with specifying min=max as fixed-regulator does. We also cannot assume that default=min or default=max, because that might harm hardware connected to the other side of the IO bank.

No, if you need a generic property add it in the generic code rather than just hacking a device specific property into your driver.

#5 lore raw
Quoted 17 lines · Mark Brown
Quoted 10 lines · Mike Looijmans
Quoted 4 lines · Mark Brown

A couple of problems here:

- This contains DT code but no DT bindings documentation; the binding documentation is mandatory for any new bindings.

Should I submit a new patch to add the DT bindings and CC to the dt mailing list, or do you want it included in this patch? I was basically waiting for feedback on the driver first.

I'm not going to review a driver with bindings without those bindings being documented, it's a well documented requirement and apart from anything else it's not really possible to review the code that manages the bindings without seeing the bindings.

Quoted 8 lines
Quoted 5 lines

The "default voltage" may not be device specific, but regulator.txt doesn't have a property that describes what we needed here, because we can't get away with specifying min=max as fixed-regulator does. We also cannot assume that default=min or default=max, because that might harm hardware connected to the other side of the IO bank.

No, if you need a generic property add it in the generic code rather than just hacking a device specific property into your driver.

So I should add "regulator-default-voltage" to the generic code? That would indeed be better than trying to do it into this driver.

But would that need a separate patch for regulator core to add the property?

Mike.

Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert

TOPIC Embedded Systems Eindhovenseweg 32-C, NL-5683 KH Best Postbus 440, NL-5680 AK Best
Telefoon: (+31) (0) 499 33 69 79
Telefax: (+31) (0) 499 33 69 70
E-mail: [email protected]
Website: www.topic.nl

Please consider the environment before printing this e-mail

Topic zoekt gedreven (embedded) software specialisten!
http://topic.nl/vacatures/topic-zoekt-software-engineers/

#6 lore raw
Quoted 24 lines · Mike Looijmans
Quoted 23 lines · Mark Brown
Quoted 10 lines · Mike Looijmans
Quoted 4 lines · Mark Brown

A couple of problems here:

- This contains DT code but no DT bindings documentation; the binding documentation is mandatory for any new bindings.

Should I submit a new patch to add the DT bindings and CC to the dt mailing list, or do you want it included in this patch? I was basically waiting for feedback on the driver first.

I'm not going to review a driver with bindings without those bindings being documented, it's a well documented requirement and apart from anything else it's not really possible to review the code that manages the bindings without seeing the bindings.

Quoted 5 lines

The "default voltage" may not be device specific, but regulator.txt doesn't have a property that describes what we needed here, because we can't get away with specifying min=max as fixed-regulator does. We also cannot assume that default=min or default=max, because that might harm hardware connected to the other side of the IO bank.

Quoted 7 lines
Quoted 2 lines

No, if you need a generic property add it in the generic code rather than just hacking a device specific property into your driver.

So I should add "regulator-default-voltage" to the generic code? That would indeed be better than trying to do it into this driver.

But would that need a separate patch for regulator core to add the property?

Hmm, I looked into doing that, but that isn't trivial, and too many devices will suffer.

Since default-voltage is unacceptable, I will remove it from the ltc3562 driver and just use the min==max setting in the devicetree to reach the same effect. The driver that will match IO voltages between SOM and carrier is far from being ready for submission anyway.

I'll submit a v2 patch with all these things reworked soon.

Mike.

Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert

TOPIC Embedded Systems Eindhovenseweg 32-C, NL-5683 KH Best Postbus 440, NL-5680 AK Best
Telefoon: (+31) (0) 499 33 69 79
Telefax: (+31) (0) 499 33 69 70
E-mail: [email protected]
Website: www.topic.nl

Please consider the environment before printing this e-mail

Topic zoekt gedreven (embedded) software specialisten!
http://topic.nl/vacatures/topic-zoekt-software-engineers/

maintainer
#7 lore raw
Quoted 6 lines · Mike Looijmans
Quoted 4 lines · Mike Looijmans

So I should add "regulator-default-voltage" to the generic code? That would indeed be better than trying to do it into this driver.

But would that need a separate patch for regulator core to add the property?

Yes.

Quoted 2 lines

Hmm, I looked into doing that, but that isn't trivial, and too many devices will suffer.

Why would this have a negative effect on other devices? Unless somehow the other devices add the property they should not be affected by it; if users do add the property presumably that's because it's doing something useful.

#8 lore raw
Quoted 10 lines · Mark Brown
Quoted 6 lines · Mike Looijmans
Quoted 4 lines · Mike Looijmans

So I should add "regulator-default-voltage" to the generic code? That would indeed be better than trying to do it into this driver.

But would that need a separate patch for regulator core to add the property?

Yes.

Quoted 7 lines
Quoted 2 lines

Hmm, I looked into doing that, but that isn't trivial, and too many devices will suffer.

Why would this have a negative effect on other devices? Unless somehow the other devices add the property they should not be affected by it; if users do add the property presumably that's because it's doing something useful.

The "default" would end up in the constraints, thus adding extra fields to that struct.

So far, all other drivers have accomplished this by setting min=max, and some experimenting proved that my driver is no exception to that. It even reduced the amount of code.

Mike.

Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert

TOPIC Embedded Systems Eindhovenseweg 32-C, NL-5683 KH Best Postbus 440, NL-5680 AK Best
Telefoon: (+31) (0) 499 33 69 79
Telefax: (+31) (0) 499 33 69 70
E-mail: [email protected]
Website: www.topic.nl

Please consider the environment before printing this e-mail

Topic zoekt gedreven (embedded) software specialisten!
http://topic.nl/vacatures/topic-zoekt-software-engineers/

maintainer
#9 lore raw
Quoted 5 lines · Mike Looijmans
Quoted 2 lines · Mark Brown
Quoted 2 lines

Hmm, I looked into doing that, but that isn't trivial, and too many devices will suffer.

Quoted 7 lines
Quoted 4 lines

Why would this have a negative effect on other devices? Unless somehow the other devices add the property they should not be affected by it; if users do add the property presumably that's because it's doing something useful.

The "default" would end up in the constraints, thus adding extra fields to that struct.

Sure, but why is that a problem?

Quoted 3 lines

So far, all other drivers have accomplished this by setting min=max, and some experimenting proved that my driver is no exception to that. It even reduced the amount of code.

Yes, if you don't need to both set an initial voltage and support voltage changing that works - it sounded like you needed both.

#10 lore raw

PATCH v2 1/1 Add ltc3562 voltage regulator driver

In reply to Mike Looijmans

The ltc3562 is an I2C controlled regulator supporting 4 independent outputs.

v2: Prefix "lltc" to devicetree properties. Use the same property names
as the ltc3589 driver. Remove default-voltage property. Use devm_register_regulator.

---
 .../devicetree/bindings/regulator/ltc3562.txt      |   56 ++++
 drivers/regulator/Kconfig                          |    7 +
 drivers/regulator/Makefile                         |    1 +
 drivers/regulator/ltc3562.c                        |  337 ++++++++++++++++++++
 4 files changed, 401 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/ltc3562.txt
 create mode 100644 drivers/regulator/ltc3562.c
Documentation/devicetree/bindings/regulator/ltc3562.txt new file +56 -0
new file mode 100644
index 0000000..81ed923
@@ -0,0 +1,56 @@
+Linear Technology LTC3562 I2C controlled 4-output regulator
+
+Required properties:
+- compatible: "ltc3562"
+- reg: I2C slave address
+
+Required child node:
+- regulators: Contains four regulator child nodes R400B, R600B, R400A, R600A,
+  specifying the initialization data as documented in
+  Documentation/devicetree/bindings/regulator/regulator.txt.
+
+Each regulator is defined using the standard binding for regulators. The
+nodes for R400A and R600A additionally need to specify the resistor values of
+their external feedback voltage dividers:
+
+Required properties (A-type only):
+- lltc,fb-voltage-divider: An array of two integers containing the resistor
+  values R1 and R2 of the feedback voltage divider. Both values must remain in
+  the range 1..1000, only their quotient matters.
+
+Example:
+
+	ltc3562: ltc3562@65 {
+		compatible = "ltc3562";
+		reg = <0x65>;
+		regulators {
+			R400B_reg: R400B {
+				regulator-name = "R400B";
+				regulator-min-microvolt = <600000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-boot-on;
+				regulator-always-on;
+			};
+			R600B_reg: R600B {
+				regulator-name = "R600B";
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-boot-on;
+				regulator-always-on;
+			};
+			R400A_reg: R400A {
+				regulator-name = "R400A";
+				regulator-min-microvolt = <425000>;
+				regulator-max-microvolt = <8000000>;
+				lltc,fb-voltage-divider = <1, 1>;
+			};
+			R600A_reg: R600A {
+				regulator-name = "R600A";
+				regulator-min-microvolt = <425000>;
+				regulator-max-microvolt = <1800000>;
+				lltc,fb-voltage-divider = <316, 100>;
+				regulator-boot-on;
+				regulator-always-on;
+			};
+		};
+	};
drivers/regulator/Kconfig +7 -0
index 55d7b7b..4012601 100644
@@ -300,6 +300,13 @@ config REGULATOR_LP8788
 	help
 	  This driver supports LP8788 voltage regulator chip.
 
+config REGULATOR_LTC3562
+	tristate "LCT3562 quad output voltage regulator"
+	depends on I2C
+	help
+	  This enables support for the LCT3562 quad output voltage regulator
+	  controlled via I2C.
+
 config REGULATOR_LTC3589
 	tristate "LTC3589 8-output voltage regulator"
 	depends on I2C
drivers/regulator/Makefile +1 -0
index 1029ed3..9a15146 100644
@@ -41,6 +41,7 @@ obj-$(CONFIG_REGULATOR_LP872X) += lp872x.o
 obj-$(CONFIG_REGULATOR_LP8788) += lp8788-buck.o
 obj-$(CONFIG_REGULATOR_LP8788) += lp8788-ldo.o
 obj-$(CONFIG_REGULATOR_LP8755) += lp8755.o
+obj-$(CONFIG_REGULATOR_LTC3562) += ltc3562.o
 obj-$(CONFIG_REGULATOR_LTC3589) += ltc3589.o
 obj-$(CONFIG_REGULATOR_MAX14577) += max14577.o
 obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o
drivers/regulator/ltc3562.c new file +337 -0

337 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#11 lore raw
Quoted 6 lines · Mike Looijmans

The ltc3562 is an I2C controlled regulator supporting 4 independent outputs.

v2: Prefix "lltc" to devicetree properties. Use the same property names
as the ltc3589 driver. Remove default-voltage property. Use devm_register_regulator.

As covered in SubmittingPatches things like this should be after ---.

Quoted 2 lines

+Required properties:
+- compatible: "ltc3562"

This needs a vendor in the compatible string.

Documentation/devicetree/bindings/regulator/ltc3562.txt line 10

Quoted 4 lines
Documentation/devicetree/bindings/regulator/ltc3562.txt new file +4 -0
+Required child node:
+- regulators: Contains four regulator child nodes R400B, R600B, R400A, R600A,
+  specifying the initialization data as documented in
+  Documentation/devicetree/bindings/regulator/regulator.txt.

All regulator child nodes should be optional.

Documentation/devicetree/bindings/regulator/ltc3562.txt line 48

Quoted 2 lines
Documentation/devicetree/bindings/regulator/ltc3562.txt new file +2 -0
+			R600A_reg: R600A {
+				regulator-name = "R600A";

Remove these regulator-names, this is for the name of the supplies on the board not the regulator itself.

drivers/regulator/ltc3562.c line 44

Quoted 2 lines
drivers/regulator/ltc3562.c new file +2 -0
+static int ltc3562_write(struct i2c_client *i2c, u8 reg_a, u8 reg_b);
+static int ltc3562_dummy_write(struct i2c_client *i2c);

This appears to be reimplementing regmap (including a cache). Please use that instead. Pretty much the entire driver could then be replaced with the regmap helpers, none of the operations look like they'd be needed, and you'd get the regmap diagnostic infrastructure.

drivers/regulator/ltc3562.c line 262

Quoted 6 lines
drivers/regulator/ltc3562.c new file +5 -0
+	np = of_node_get(i2c->dev.of_node);
+	np_regulators = of_get_child_by_name(np, "regulators");
 
+		np_child = of_get_child_by_name(np_regulators,
+			ltc3562_regulators[i].name);
+		if (np_child == NULL) {

Use the core support for looking up constraints please - set regulators_node and so on.

drivers/regulator/ltc3562.c line 330

Quoted 8 lines
drivers/regulator/ltc3562.c new file +8 -0
+static struct i2c_driver ltc3562_i2c_driver = {
+	.driver = {
+		.name = "LTC3562",
+		.owner = THIS_MODULE,
+	},
+	.probe    = ltc3562_i2c_probe,
+	.id_table = ltc3562_i2c_id,
+};

You need to supply an of_match_table too.

#12 lore raw
Quoted 8 lines · Mark Brown
Quoted 6 lines · Mike Looijmans

The ltc3562 is an I2C controlled regulator supporting 4 independent outputs.

v2: Prefix "lltc" to devicetree properties. Use the same property names
as the ltc3589 driver. Remove default-voltage property. Use devm_register_regulator.

Quoted 6 lines

As covered in SubmittingPatches things like this should be after ---.

Quoted 2 lines

+Required properties:
+- compatible: "ltc3562"

This needs a vendor in the compatible string.

Will do.

Quoted 13 lines

Documentation/devicetree/bindings/regulator/ltc3562.txt line 10

Quoted 4 lines
Documentation/devicetree/bindings/regulator/ltc3562.txt new file +4 -0
+Required child node:
+- regulators: Contains four regulator child nodes R400B, R600B, R400A, R600A,
+  specifying the initialization data as documented in
+  Documentation/devicetree/bindings/regulator/regulator.txt.

All regulator child nodes should be optional.

Documentation/devicetree/bindings/regulator/ltc3562.txt line 48

Quoted 2 lines
Documentation/devicetree/bindings/regulator/ltc3562.txt new file +2 -0
+			R600A_reg: R600A {
+				regulator-name = "R600A";

Remove these regulator-names, this is for the name of the supplies on the board not the regulator itself.

Quoted 7 lines

drivers/regulator/ltc3562.c line 44

Quoted 2 lines
drivers/regulator/ltc3562.c new file +2 -0
+static int ltc3562_write(struct i2c_client *i2c, u8 reg_a, u8 reg_b);
+static int ltc3562_dummy_write(struct i2c_client *i2c);

This appears to be reimplementing regmap (including a cache). Please use that instead. Pretty much the entire driver could then be replaced with the regmap helpers, none of the operations look like they'd be needed, and you'd get the regmap diagnostic infrastructure.

The chip doesn't have an I2C register map, it uses "commands".
It does not support read transactions at all, it will NACK those. The first byte contains a bit mask that tells which outputs are to be configured and in what mode, the next is the enable bit and setpoint value. The first byte already contains data, it's not just an address.

I would have used regmap if I thought it'd help (if only for the diagnostics), but it simply doesn't fit here.

If you insist, I can probably get it to fit on regmap, but that would still mean implementing some custom write method that translates between some non-existing registry format and what the chip really wants.

Quoted 9 lines

drivers/regulator/ltc3562.c line 262

Quoted 6 lines
drivers/regulator/ltc3562.c new file +5 -0
+	np = of_node_get(i2c->dev.of_node);
+	np_regulators = of_get_child_by_name(np, "regulators");
 
+		np_child = of_get_child_by_name(np_regulators,
+			ltc3562_regulators[i].name);
+		if (np_child == NULL) {

Use the core support for looking up constraints please - set regulators_node and so on.

I'll dig into it, seems that there's more infrastructure here to use.

Quoted 10 lines

drivers/regulator/ltc3562.c line 330

Quoted 8 lines
drivers/regulator/ltc3562.c new file +8 -0
+static struct i2c_driver ltc3562_i2c_driver = {
+	.driver = {
+		.name = "LTC3562",
+		.owner = THIS_MODULE,
+	},
+	.probe    = ltc3562_i2c_probe,
+	.id_table = ltc3562_i2c_id,
+};

You need to supply an of_match_table too.

Hmm, that would explain why I couldn't get it to work using "lltc,ltc3562" during our first attempts at the driver.

Signature · 1 line
Mike Looijmans
maintainer
#13 lore raw
Quoted 7 lines · Mike Looijmans
Quoted 4 lines · Mark Brown

This appears to be reimplementing regmap (including a cache). Please use that instead. Pretty much the entire driver could then be replaced with the regmap helpers, none of the operations look like they'd be needed, and you'd get the regmap diagnostic infrastructure.

Quoted 5 lines

The chip doesn't have an I2C register map, it uses "commands". It does not support read transactions at all, it will NACK those. The first byte contains a bit mask that tells which outputs are to be configured and in what mode, the next is the enable bit and setpoint value. The first byte already contains data, it's not just an address.

If that's the case the code is really rather unclear about what it's doing - the use of "reg" for what's being written doesn't help, nor does the fact that what looks like a cache is being kept. The code should either use regmap or make it clear why that doesn't fit well.

#14 lore raw
In reply to Mark Brown
Quoted 10 lines · Mark Brown

drivers/regulator/ltc3562.c line 262

Quoted 6 lines · Mike Looijmans
drivers/regulator/ltc3562.c new file +5 -0
+	np = of_node_get(i2c->dev.of_node);
+	np_regulators = of_get_child_by_name(np, "regulators");
 
+		np_child = of_get_child_by_name(np_regulators,
+			ltc3562_regulators[i].name);
+		if (np_child == NULL) {

Use the core support for looking up constraints please - set regulators_node and so on.

I've been reworking the driver, but this is the only feedback comment I didn't quite understand. What is it that I'm expected to do here? Probably just the name of the method I'm supposed to call here would be enough.

The rest of your feedback I've processed and tested the results.

Mike.

Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert

TOPIC Embedded Systems Eindhovenseweg 32-C, NL-5683 KH Best Postbus 440, NL-5680 AK Best
Telefoon: (+31) (0) 499 33 69 79
Telefax: (+31) (0) 499 33 69 70
E-mail: [email protected]
Website: www.topic.nl

Please consider the environment before printing this e-mail

Topic zoekt gedreven (embedded) software specialisten!
http://topic.nl/vacatures/topic-zoekt-software-engineers/

maintainer
#15 lore raw
Quoted 9 lines · Mike Looijmans
Quoted 6 lines · Mark Brown

drivers/regulator/ltc3562.c line 262

Quoted 3 lines
drivers/regulator/ltc3562.c new file +3 -0
+		np_child = of_get_child_by_name(np_regulators,
+			ltc3562_regulators[i].name);
+		if (np_child == NULL) {

Use the core support for looking up constraints please - set regulators_node and so on.

Quoted 3 lines

I've been reworking the driver, but this is the only feedback comment I didn't quite understand. What is it that I'm expected to do here? Probably just the name of the method I'm supposed to call here would be enough.

No function calls, just use regulators_node. What is unclear about the functionality?

#16 lore raw
Quoted 10 lines · Mark Brown
Quoted 8 lines · Mike Looijmans
Quoted 6 lines · Mark Brown

drivers/regulator/ltc3562.c line 262

Quoted 3 lines
drivers/regulator/ltc3562.c new file +3 -0
+		np_child = of_get_child_by_name(np_regulators,
+			ltc3562_regulators[i].name);
+		if (np_child == NULL) {

Use the core support for looking up constraints please - set regulators_node and so on.

Quoted 6 lines
Quoted 3 lines

I've been reworking the driver, but this is the only feedback comment I didn't quite understand. What is it that I'm expected to do here? Probably just the name of the method I'm supposed to call here would be enough.

No function calls, just use regulators_node. What is unclear about the functionality?

I don't understand what you mean by "regulators_node".

"grep -R regulators_node *" in the kernel source tree returns no results, nor does http://lxr.free-electrons.com/ident?i=regulators_node

Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert

TOPIC Embedded Systems Eindhovenseweg 32-C, NL-5683 KH Best Postbus 440, NL-5680 AK Best
Telefoon: (+31) (0) 499 33 69 79
Telefax: (+31) (0) 499 33 69 70
E-mail: [email protected]
Website: www.topic.nl

Please consider the environment before printing this e-mail

Topic zoekt gedreven (embedded) software specialisten!
http://topic.nl/vacatures/topic-zoekt-software-engineers/

maintainer
#17 lore raw
Quoted 9 lines · Mike Looijmans
Quoted 2 lines · Mark Brown

No function calls, just use regulators_node. What is unclear about the functionality?

I don't understand what you mean by "regulators_node".

"grep -R regulators_node *" in the kernel source tree returns no results, nor does http://lxr.free-electrons.com/ident?i=regulators_node

You need to develop against current versions of the kernel, this is something that was merged into Linus' tree during the merge window.

#18 lore raw
Quoted 6 lines · Mark Brown
Quoted 4 lines · Mike Looijmans
Quoted 2 lines · Mark Brown

No function calls, just use regulators_node. What is unclear about the functionality?

Quoted 7 lines
Quoted 4 lines

I don't understand what you mean by "regulators_node".

"grep -R regulators_node *" in the kernel source tree returns no results, nor does http://lxr.free-electrons.com/ident?i=regulators_node

You need to develop against current versions of the kernel, this is something that was merged into Linus' tree during the merge window.

Is this an absolute show-stopper for you?

With some effort I could move from our current 3.15 to 3.17, but even that wouldn't be recent enough then. I can justify spending a few days on getting the driver integrated into mainline, even if the initial version cost less than that; but moving everything to mainline is going to take weeks and the boss is definitely going to say "no" to that.

Signature · 1 line
Mike Looijmans
#19 lore raw
Quoted 15 lines · Mike Looijmans
Quoted 6 lines · Mark Brown
Quoted 4 lines · Mike Looijmans
Quoted 2 lines · Mark Brown

No function calls, just use regulators_node. What is unclear about the functionality?

Quoted 7 lines
Quoted 4 lines

I don't understand what you mean by "regulators_node".

"grep -R regulators_node *" in the kernel source tree returns no results, nor does http://lxr.free-electrons.com/ident?i=regulators_node

You need to develop against current versions of the kernel, this is something that was merged into Linus' tree during the merge window.

Quoted 7 lines

Is this an absolute show-stopper for you?

With some effort I could move from our current 3.15 to 3.17, but even that wouldn't be recent enough then. I can justify spending a few days on getting the driver integrated into mainline, even if the initial version cost less than that; but moving everything to mainline is going to take weeks and the boss is definitely going to say "no" to that.

More important than that: Since this chip powers the IO banks, we need it for our own products, and hence it has to work (also) on the current 3.15 kernel. Using APIs from 3.18 wouold render the driver useless to ourselves.

Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert

TOPIC Embedded Systems Eindhovenseweg 32-C, NL-5683 KH Best Postbus 440, NL-5680 AK Best
Telefoon: (+31) (0) 499 33 69 79
Telefax: (+31) (0) 499 33 69 70
E-mail: [email protected]
Website: www.topic.nl

Please consider the environment before printing this e-mail

Topic zoekt gedreven (embedded) software specialisten!
http://topic.nl/vacatures/topic-zoekt-software-engineers/

maintainer
#20 lore raw
Quoted 5 lines · Mike Looijmans
Quoted 2 lines · Mike Looijmans
Quoted 2 lines

You need to develop against current versions of the kernel, this is something that was merged into Linus' tree during the merge window.

Quoted 7 lines
Quoted 7 lines

Is this an absolute show-stopper for you?

With some effort I could move from our current 3.15 to 3.17, but even that wouldn't be recent enough then. I can justify spending a few days on getting the driver integrated into mainline, even if the initial version cost less than that; but moving everything to mainline is going to take weeks and the boss is definitely going to say "no" to that.

It should be easy to backport the support into your current kernel, it's just a few commits and there hasn't been much development in this area of the code. Can you take a look at doing that please?

Quoted 3 lines

More important than that: Since this chip powers the IO banks, we need it for our own products, and hence it has to work (also) on the current 3.15 kernel. Using APIs from 3.18 wouold render the driver useless to ourselves.

This is just not at all important upstream, sorry. The kernel moves on and internal APIs within the kernel move on so it is expected that code used in production won't be the latest and greatest upstream code.

#21 lore raw
Quoted 14 lines · Mark Brown
Quoted 5 lines · Mike Looijmans
Quoted 2 lines · Mike Looijmans
Quoted 2 lines

You need to develop against current versions of the kernel, this is something that was merged into Linus' tree during the merge window.

Quoted 7 lines
Quoted 7 lines

Is this an absolute show-stopper for you?

With some effort I could move from our current 3.15 to 3.17, but even that wouldn't be recent enough then. I can justify spending a few days on getting the driver integrated into mainline, even if the initial version cost less than that; but moving everything to mainline is going to take weeks and the boss is definitely going to say "no" to that.

Quoted 3 lines

It should be easy to backport the support into your current kernel, it's just a few commits and there hasn't been much development in this area of the code. Can you take a look at doing that please?

That option hadn't crossed my mind yet, I'll look into it.

Quoted 8 lines
Quoted 4 lines

More important than that: Since this chip powers the IO banks, we need it for our own products, and hence it has to work (also) on the current 3.15 kernel. Using APIs from 3.18 wouold render the driver useless to ourselves.

This is just not at all important upstream, sorry. The kernel moves on and internal APIs within the kernel move on so it is expected that code used in production won't be the latest and greatest upstream code.

I realize that, but then the result would be that I'll stop working on getting the driver into mainline and force customers to use a patch or use our fork of linux.

Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert

TOPIC Embedded Systems Eindhovenseweg 32-C, NL-5683 KH Best Postbus 440, NL-5680 AK Best
Telefoon: (+31) (0) 499 33 69 79
Telefax: (+31) (0) 499 33 69 70
E-mail: [email protected]
Website: www.topic.nl

Please consider the environment before printing this e-mail

Topic zoekt gedreven (embedded) software specialisten!
http://topic.nl/vacatures/topic-zoekt-software-engineers/

#22 lore raw
In reply to Mark Brown
Quoted 14 lines · Mark Brown
Quoted 5 lines · Mike Looijmans
Quoted 2 lines · Mike Looijmans
Quoted 2 lines

You need to develop against current versions of the kernel, this is something that was merged into Linus' tree during the merge window.

Quoted 7 lines
Quoted 7 lines

Is this an absolute show-stopper for you?

With some effort I could move from our current 3.15 to 3.17, but even that wouldn't be recent enough then. I can justify spending a few days on getting the driver integrated into mainline, even if the initial version cost less than that; but moving everything to mainline is going to take weeks and the boss is definitely going to say "no" to that.

Quoted 3 lines

It should be easy to backport the support into your current kernel, it's just a few commits and there hasn't been much development in this area of the code. Can you take a look at doing that please?

I can cherry-pick about 4 commits to get the updated core into my 3.15 tree.

I still need help with one thing that isn't clear to me though. The DT is parsed when calling regulator_register. But then how do I fetch my "private" settings in there BEFORE the regulator gets enabled? The feedback resistors and regulator mode must be set to the correct board before the output is enabled, otherwise it may damage the chip and its periferals.

The only two drivers using the regulators_node (tps65217 and isl9305.c) don't have any private values in the DT.

M.

Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert

TOPIC Embedded Systems Eindhovenseweg 32-C, NL-5683 KH Best Postbus 440, NL-5680 AK Best
Telefoon: (+31) (0) 499 33 69 79
Telefax: (+31) (0) 499 33 69 70
E-mail: [email protected]
Website: www.topic.nl

Please consider the environment before printing this e-mail

Topic zoekt gedreven (embedded) software specialisten!
http://topic.nl/vacatures/topic-zoekt-software-engineers/

maintainer
#23 lore raw
Quoted 5 lines · Mike Looijmans

I still need help with one thing that isn't clear to me though. The DT is parsed when calling regulator_register. But then how do I fetch my "private" settings in there BEFORE the regulator gets enabled? The feedback resistors and regulator mode must be set to the correct board before the output is enabled, otherwise it may damage the chip and its periferals.

Add a callback for this. Javier and/or Krzysztof were looking at this for some other stuff, though I think they were intending to add core functionality for their specific feature.

#24 lore raw
Quoted 11 lines · Mark Brown
Quoted 5 lines · Mike Looijmans

I still need help with one thing that isn't clear to me though. The DT is parsed when calling regulator_register. But then how do I fetch my "private" settings in there BEFORE the regulator gets enabled? The feedback resistors and regulator mode must be set to the correct board before the output is enabled, otherwise it may damage the chip and its periferals.

Add a callback for this. Javier and/or Krzysztof were looking at this for some other stuff, though I think they were intending to add core functionality for their specific feature.

I needed a callback and added such. The callback was called on each DT node parsed. However I dropped that idea because it turned our to be unsuitable to my case.

I needed to feed regulator_config.ena_gpio with data parsed from such callback. But the callback called from inside the regulator_register() has the regulator_config const.

Best regards,
Krzysztof

#25 lore raw
In reply to Mark Brown
Quoted 8 lines · Mark Brown
Quoted 5 lines · Mike Looijmans

I still need help with one thing that isn't clear to me though. The DT is parsed when calling regulator_register. But then how do I fetch my "private" settings in there BEFORE the regulator gets enabled? The feedback resistors and regulator mode must be set to the correct board before the output is enabled, otherwise it may damage the chip and its periferals.

Quoted 4 lines

Add a callback for this. Javier and/or Krzysztof were looking at this for some other stuff, though I think they were intending to add core functionality for their specific feature.

I've run out of my hours-to-spend-on-driver-submission budget for this period , so it'll be at least a week before I can post a new version. The good news is that I have upgrading the kernel to 3.17 on the planning board now, so that'll at least reduce the version gap.

Mike.

Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert

TOPIC Embedded Systems Eindhovenseweg 32-C, NL-5683 KH Best Postbus 440, NL-5680 AK Best
Telefoon: (+31) (0) 499 33 69 79
Telefax: (+31) (0) 499 33 69 70
E-mail: [email protected]
Website: www.topic.nl

Please consider the environment before printing this e-mail

Topic zoekt gedreven (embedded) software specialisten!
http://topic.nl/vacatures/topic-zoekt-software-engineers/

#26 lore raw

PATCH v3 1/1 Add ltc3562 voltage regulator driver

In reply to Mike Looijmans

The ltc3562 is an I2C controlled regulator supporting 4 independent outputs.

---

v3: Add .of_match_table and prefix lltc
Clarify why regmap cannot be used
Add lltc,operating-mode (0..3) DT property
regulator child nodes are optional

 .../devicetree/bindings/regulator/ltc3562.txt      |   57 ++++
 drivers/regulator/Kconfig                          |    7 +
 drivers/regulator/Makefile                         |    1 +
 drivers/regulator/ltc3562.c                        |  337 ++++++++++++++++++++
 4 files changed, 402 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/ltc3562.txt
 create mode 100644 drivers/regulator/ltc3562.c
Documentation/devicetree/bindings/regulator/ltc3562.txt new file +57 -0
new file mode 100644
index 0000000..d73c865
@@ -0,0 +1,57 @@
+Linear Technology LTC3562 I2C controlled 4-output regulator
+
+Required properties:
+- compatible: "lltc,ltc3562"
+- reg: I2C slave address
+
+Required child node:
+- regulators: Contains optional regulator child nodes R400B, R600B, R400A
+  and R600A specifying the initialization data as documented in
+  Documentation/devicetree/bindings/regulator/regulator.txt.
+
+Each regulator is defined using the standard binding for regulators. The
+nodes for R400A and R600A additionally need to specify the resistor values of
+their external feedback voltage dividers:
+
+Required properties (A-type only):
+- lltc,fb-voltage-divider: An array of two integers containing the resistor
+  values R1 and R2 of the feedback voltage divider. Both values must remain in
+  the range 1..1000, only their quotient matters.
+
+Optional properties:
+- lltc,operating-mode: Operating mode as specified in table 3 of the datasheet.
+  This value is passed as the lower two bits of the first data byte, and sets
+  the operating mode: 0=Pulse-skip (default), 1=LDO, 2=Forced-burst, 3=Burst.
+
+Example:
+
+	ltc3562: ltc3562@65 {
+		compatible = "ltc3562";
+		reg = <0x65>;
+		regulators {
+			R400B_reg: R400B {
+				regulator-min-microvolt = <600000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-boot-on;
+				regulator-always-on;
+			};
+			R600B_reg: R600B {
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-boot-on;
+				regulator-always-on;
+			};
+			R400A_reg: R400A {
+				regulator-min-microvolt = <425000>;
+				regulator-max-microvolt = <8000000>;
+				lltc,fb-voltage-divider = <1, 1>;
+			};
+			R600A_reg: R600A {
+				regulator-min-microvolt = <425000>;
+				regulator-max-microvolt = <1800000>;
+				lltc,fb-voltage-divider = <316, 100>;
+				regulator-boot-on;
+				regulator-always-on;
+			};
+		};
+	};
drivers/regulator/Kconfig +7 -0
index 55d7b7b..4012601 100644
@@ -300,6 +300,13 @@ config REGULATOR_LP8788
 	help
 	  This driver supports LP8788 voltage regulator chip.
 
+config REGULATOR_LTC3562
+	tristate "LCT3562 quad output voltage regulator"
+	depends on I2C
+	help
+	  This enables support for the LCT3562 quad output voltage regulator
+	  controlled via I2C.
+
 config REGULATOR_LTC3589
 	tristate "LTC3589 8-output voltage regulator"
 	depends on I2C
drivers/regulator/Makefile +1 -0
index 1029ed3..9a15146 100644
@@ -41,6 +41,7 @@ obj-$(CONFIG_REGULATOR_LP872X) += lp872x.o
 obj-$(CONFIG_REGULATOR_LP8788) += lp8788-buck.o
 obj-$(CONFIG_REGULATOR_LP8788) += lp8788-ldo.o
 obj-$(CONFIG_REGULATOR_LP8755) += lp8755.o
+obj-$(CONFIG_REGULATOR_LTC3562) += ltc3562.o
 obj-$(CONFIG_REGULATOR_LTC3589) += ltc3589.o
 obj-$(CONFIG_REGULATOR_MAX14577) += max14577.o
 obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o
drivers/regulator/ltc3562.c new file +337 -0

337 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#27 lore raw
Quoted 4 lines · Mike Looijmans

v3: Add .of_match_table and prefix lltc
Clarify why regmap cannot be used
Add lltc,operating-mode (0..3) DT property
regulator child nodes are optional

Leave out the mode setting in the DT for now please, Javier was looking at adding a standard property for this with a driver defined mapping to modes - you should implement the standard get_mode() and set_mode() (but can always do that as a followup).

drivers/regulator/ltc3562.c line 36

Quoted 7 lines
drivers/regulator/ltc3562.c new file +7 -0
+/* the LTC3562 does not have a register map, instead it receives a two-byte
+ * command set. The first byte sets the mask for the output(s) to be programmed
+ * and the second byte hold the "enable" bit and the DAC code. */
+struct ltc3562_status {
+	u8 addr_mode;	/* sub-address byte: program mask an operating mode */
+	u8 enable_daccode;	/* data byte: Enable bit and DAC code  */
+};

So, I managed to find a datasheet[1] and this does actually seem to be a standard register map. It looks like this is a 4x12 register map with the program bytes being essentially register addresses (called sub addresses in the datasheet), two pad bits (normally we'd include these in the data for convenience) and the rest of the bits data. What am I missing here?

Otherwise this looks good.

[1] http://cds.linear.com/docs/en/datasheet/3562fa.pdf

#28 lore raw
Quoted 27 lines · Mark Brown
Quoted 4 lines · Mike Looijmans

v3: Add .of_match_table and prefix lltc
Clarify why regmap cannot be used
Add lltc,operating-mode (0..3) DT property
regulator child nodes are optional

Leave out the mode setting in the DT for now please, Javier was looking at adding a standard property for this with a driver defined mapping to modes - you should implement the standard get_mode() and set_mode() (but can always do that as a followup).

drivers/regulator/ltc3562.c line 36

Quoted 7 lines
drivers/regulator/ltc3562.c new file +7 -0
+/* the LTC3562 does not have a register map, instead it receives a two-byte
+ * command set. The first byte sets the mask for the output(s) to be programmed
+ * and the second byte hold the "enable" bit and the DAC code. */
+struct ltc3562_status {
+	u8 addr_mode;	/* sub-address byte: program mask an operating mode */
+	u8 enable_daccode;	/* data byte: Enable bit and DAC code  */
+};

So, I managed to find a datasheet[1] and this does actually seem to be a standard register map. It looks like this is a 4x12 register map with the program bytes being essentially register addresses (called sub addresses in the datasheet), two pad bits (normally we'd include these in the data for convenience) and the rest of the bits data. What am I missing here?

Quoted 4 lines

Otherwise this looks good.

[1] http://cds.linear.com/docs/en/datasheet/3562fa.pdf

Things that makes me think it's NOT a register map:
- You cannot read from the device
- You always have to send a complete command set (two bytes)
- There is data (the regulator mode) in the address byte
- The 'address' is not an index but a bitmask in bits 4..7

Yeah, I think you can force-feed this to regmap. It will just make the code considerably bigger and harder to understand, and as far as I know, the one and only advantage this will bring is that you can dump the current "registers" (4x10 bits of data) via /sys/kernel/debug/regmap.

I fail to see the use for regmap here, but if your view on this is "regmap or burst" then I'll implement it.

Mike.

Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert

TOPIC Embedded Systems Eindhovenseweg 32-C, NL-5683 KH Best Postbus 440, NL-5680 AK Best
Telefoon: (+31) (0) 499 33 69 79
Telefax: (+31) (0) 499 33 69 70
E-mail: [email protected]
Website: www.topic.nl

Please consider the environment before printing this e-mail

Topic zoekt gedreven (embedded) software specialisten!
http://topic.nl/vacatures/topic-zoekt-software-engineers/

maintainer
#29 lore raw
Quoted 11 lines · Mike Looijmans
Quoted 6 lines · Mark Brown

So, I managed to find a datasheet[1] and this does actually seem to be a standard register map. It looks like this is a 4x12 register map with the program bytes being essentially register addresses (called sub addresses in the datasheet), two pad bits (normally we'd include these in the data for convenience) and the rest of the bits data. What am I missing here?

Things that makes me think it's NOT a register map:
- You cannot read from the device

That's entirely normal for older devices, on larger process nodes the extra digital to implement read was expensive enough for people to care and I believe there were some IP issues with implementing read support.

Quoted 2 lines

- You always have to send a complete command set (two bytes)
- There is data (the regulator mode) in the address byte

Having to send both a register and a value is the standard thing, and with older write only devices things frequently weren't full byte multiples, 7x9 was extremely common.

Quoted 1 line

- The 'address' is not an index but a bitmask in bits 4..7

That's just a sparse register map, again very common (you'll also often see holes in the register map due to undocumented registers or with larger register addresses just to keep the map neat).

Quoted 2 lines

I fail to see the use for regmap here, but if your view on this is "regmap or burst" then I'll implement it.

The biggest advantage is that it means that a large proportion of the code in the driver can be removed and standard implementations in the core used instead. In general removing code is good and this means that if we do things like impement support for enabling and disabling multiple regulators with a single write then the driver will support this for free.

maintainer
#30 lore raw
In reply to Mike Looijmans
Quoted 3 lines · Mike Looijmans

This patch adds the LTC3562 I2C controlled voltage regulator to the kernel. The driver was tested and developed on a Topic Miami board where this chip supplies the IO voltages for the FPGA pins.

Please don't send cover letters for single patches, if there's anything that needs to be added just put it in the changelog or after the --- if it shouldn't go there.