All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/2] lm87 configuration from dts
@ 2017-03-30 23:00 Chris Packham
  2017-03-30 23:00 ` [PATCH v5 1/2] Documentation: dtb: lm87: Add hwmon binding documentation Chris Packham
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Chris Packham @ 2017-03-30 23:00 UTC (permalink / raw)
  To: linux-hwmon, linux; +Cc: Chris Packham

I've picked these changes up from Mahoda to hopefully get them landed
upstream.

Technically this is v5 of the documentation patch and v3 of the driver
changes but I'm bundling them as v5 of the series.

Mahoda Ratnayaka (2):
  Documentation: dtb: lm87: Add hwmon binding documentation
  lm87: Allow channel data to be set from dts file

 Documentation/devicetree/bindings/hwmon/lm87.txt | 30 ++++++++++++++++++++++++
 drivers/hwmon/lm87.c                             | 23 ++++++++++++++++--
 2 files changed, 51 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/hwmon/lm87.txt

-- 
2.11.0.24.ge6920cf

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

* [PATCH v5 1/2] Documentation: dtb: lm87: Add hwmon binding documentation
  2017-03-30 23:00 [PATCH v5 0/2] lm87 configuration from dts Chris Packham
@ 2017-03-30 23:00 ` Chris Packham
  2017-03-30 23:01 ` [PATCH v5 2/2] lm87: Allow channel data to be set from dts file Chris Packham
  2017-04-02 11:42 ` [PATCH v5 0/2] lm87 configuration from dts Guenter Roeck
  2 siblings, 0 replies; 4+ messages in thread
From: Chris Packham @ 2017-03-30 23:00 UTC (permalink / raw)
  To: linux-hwmon, linux
  Cc: Mahoda Ratnayaka, Chris Packham, Rob Herring, Mark Rutland,
	devicetree, linux-kernel

From: Mahoda Ratnayaka <mahoda.ratnayaka@alliedtelesis.co.nz>

This patch adds lm87 hwmon device tree node documentation.

Signed-off-by: Mahoda Ratnayaka <mahoda.ratnayaka@alliedtelesis.co.nz>
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Acked-by: Rob Herring <robh+dt@kernel.org>
---
- Changes since v1:
   As suggested include all the changes are moved in
   to the same patch and the all the optional properties
   are now defined instead of using a single variable to
   indicate those properties.
    
- Changes since v2:
   Changed has-vcc-5v to use regulator binding and fixed
   a minor copy paste mistake.
    
- Changes since v3:
   Update the vcc-supply description.

- Changes since v4:
   Collect Ack from Rob Herring

 Documentation/devicetree/bindings/hwmon/lm87.txt | 30 ++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/lm87.txt

diff --git a/Documentation/devicetree/bindings/hwmon/lm87.txt b/Documentation/devicetree/bindings/hwmon/lm87.txt
new file mode 100644
index 000000000000..e1b79903f204
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/lm87.txt
@@ -0,0 +1,30 @@
+*LM87 hwmon sensor.
+
+Required properties:
+- compatible: Should be
+	"ti,lm87"
+
+- reg: I2C address
+
+optional properties:
+- has-temp3: This configures pins 18 and 19 to be used as a second
+             remote temperature sensing channel. By default the pins
+             are configured as voltage input pins in0 and in5.
+
+- has-in6: When set, pin 5 is configured to be used as voltage input
+           in6. Otherwise the pin is set as FAN1 input.
+
+- has-in7: When set, pin 6 is configured to be used as voltage input
+           in7. Otherwise the pin is set as FAN2 input.
+
+- vcc-supply: a Phandle for the regulator supplying power, can be
+              cofigured to measure 5.0V power supply. Default is 3.3V.
+
+Example:
+
+lm87@2e {
+	compatible = "ti,lm87";
+	reg = <0x2e>;
+	has-temp3;
+	vcc-supply = <&reg_5v0>;
+};
-- 
2.11.0.24.ge6920cf


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

* [PATCH v5 2/2] lm87: Allow channel data to be set from dts file
  2017-03-30 23:00 [PATCH v5 0/2] lm87 configuration from dts Chris Packham
  2017-03-30 23:00 ` [PATCH v5 1/2] Documentation: dtb: lm87: Add hwmon binding documentation Chris Packham
@ 2017-03-30 23:01 ` Chris Packham
  2017-04-02 11:42 ` [PATCH v5 0/2] lm87 configuration from dts Guenter Roeck
  2 siblings, 0 replies; 4+ messages in thread
From: Chris Packham @ 2017-03-30 23:01 UTC (permalink / raw)
  To: linux-hwmon, linux
  Cc: Mahoda Ratnayaka, Chris Packham, Jean Delvare, linux-kernel

From: Mahoda Ratnayaka <mahoda.ratnayaka@alliedtelesis.co.nz>

Currently there is no method for setting the channel
value from the DTS file. When, the driver uses a dts
file to initialize the driver platform_data is not set.
As a result channel variable may not be set correctly.

Without the channel variable set correctly, some of the
sensors will not be initialized correctly. For example
temp3 sensor sysfs entries.

This implements the schema agreed with the device tree
binding document.

Signed-off-by: Mahoda Ratnayaka <mahoda.ratnayaka@alliedtelesis.co.nz>
Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
- Changes since v1:
  Removed unncessary variables channel and np.
  Update the code as per review comments.

- Changes since v2 (note v3 and v4 skipped):
  Use of_property_read_bool for flag properties (has-foo)
  Use regulator API and vcc-supply property to select 5V/3V3 scaling.

 drivers/hwmon/lm87.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c
index e06faf9d3f0f..04a7a1ddb030 100644
--- a/drivers/hwmon/lm87.c
+++ b/drivers/hwmon/lm87.c
@@ -66,6 +66,7 @@
 #include <linux/hwmon-vid.h>
 #include <linux/err.h>
 #include <linux/mutex.h>
+#include <linux/regulator/consumer.h>
 
 /*
  * Addresses to scan
@@ -855,8 +856,26 @@ static int lm87_init_client(struct i2c_client *client)
 {
 	struct lm87_data *data = i2c_get_clientdata(client);
 	int rc;
-
-	if (dev_get_platdata(&client->dev)) {
+	struct device_node *of_node = client->dev.of_node;
+	u8 val = 0;
+	struct regulator *vcc = NULL;
+
+	if (of_node) {
+		if (of_property_read_bool(of_node, "has-temp3"))
+			val |= CHAN_TEMP3;
+		if (of_property_read_bool(of_node, "has-in6"))
+			val |= CHAN_NO_FAN(0);
+		if (of_property_read_bool(of_node, "has-in7"))
+			val |= CHAN_NO_FAN(1);
+		vcc = devm_regulator_get_optional(&client->dev, "vcc");
+		if (!IS_ERR(vcc)) {
+			if (regulator_get_voltage(vcc) == 5000000)
+				val |= CHAN_VCC_5V;
+		}
+		data->channel = val;
+		lm87_write_value(client,
+				LM87_REG_CHANNEL_MODE, data->channel);
+	} else if (dev_get_platdata(&client->dev)) {
 		data->channel = *(u8 *)dev_get_platdata(&client->dev);
 		lm87_write_value(client,
 				 LM87_REG_CHANNEL_MODE, data->channel);
-- 
2.11.0.24.ge6920cf

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

* Re: [PATCH v5 0/2] lm87 configuration from dts
  2017-03-30 23:00 [PATCH v5 0/2] lm87 configuration from dts Chris Packham
  2017-03-30 23:00 ` [PATCH v5 1/2] Documentation: dtb: lm87: Add hwmon binding documentation Chris Packham
  2017-03-30 23:01 ` [PATCH v5 2/2] lm87: Allow channel data to be set from dts file Chris Packham
@ 2017-04-02 11:42 ` Guenter Roeck
  2 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2017-04-02 11:42 UTC (permalink / raw)
  To: Chris Packham, linux-hwmon

On 03/30/2017 04:00 PM, Chris Packham wrote:
> I've picked these changes up from Mahoda to hopefully get them landed
> upstream.
>
> Technically this is v5 of the documentation patch and v3 of the driver
> changes but I'm bundling them as v5 of the series.
>
> Mahoda Ratnayaka (2):
>   Documentation: dtb: lm87: Add hwmon binding documentation
>   lm87: Allow channel data to be set from dts file
>
>  Documentation/devicetree/bindings/hwmon/lm87.txt | 30 ++++++++++++++++++++++++
>  drivers/hwmon/lm87.c                             | 23 ++++++++++++++++--
>  2 files changed, 51 insertions(+), 2 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/hwmon/lm87.txt
>
Series applied.

Thanks,
Guenter


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

end of thread, other threads:[~2017-04-02 11:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-30 23:00 [PATCH v5 0/2] lm87 configuration from dts Chris Packham
2017-03-30 23:00 ` [PATCH v5 1/2] Documentation: dtb: lm87: Add hwmon binding documentation Chris Packham
2017-03-30 23:01 ` [PATCH v5 2/2] lm87: Allow channel data to be set from dts file Chris Packham
2017-04-02 11:42 ` [PATCH v5 0/2] lm87 configuration from dts Guenter Roeck

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.