linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] hwmon: (ad741x) Add DT bindings for Analog Devices AD741x
@ 2019-01-28 21:06 Linus Walleij
  2019-01-28 21:06 ` [PATCH 2/2] hwmon: (ad7418) Add device tree probing Linus Walleij
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Linus Walleij @ 2019-01-28 21:06 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck; +Cc: linux-hwmon, Linus Walleij, devicetree

This adds device tree bindings for Analog Devices AD741x
as found in Gateway routers.

Cc: devicetree@vger.kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 .../devicetree/bindings/hwmon/ad741x.txt          | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/ad741x.txt

diff --git a/Documentation/devicetree/bindings/hwmon/ad741x.txt b/Documentation/devicetree/bindings/hwmon/ad741x.txt
new file mode 100644
index 000000000000..9102152c8410
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/ad741x.txt
@@ -0,0 +1,15 @@
+* AD7416/AD7417/AD7418 Temperature Sensor Device Tree Bindings
+
+Required properties:
+- compatible: one of
+		"adi,ad7416"
+		"adi,ad7417"
+		"adi,ad7418"
+- reg: I2C address
+
+Example:
+
+hwmon@28 {
+	compatible = "adi,ad7418";
+	reg = <0x28>;
+};
-- 
2.20.1


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

* [PATCH 2/2] hwmon: (ad7418) Add device tree probing
  2019-01-28 21:06 [PATCH 1/2] hwmon: (ad741x) Add DT bindings for Analog Devices AD741x Linus Walleij
@ 2019-01-28 21:06 ` Linus Walleij
  2019-02-25 14:36   ` Guenter Roeck
  2019-02-25 14:28 ` [PATCH 1/2] hwmon: (ad741x) Add DT bindings for Analog Devices AD741x Rob Herring
  2019-02-25 14:36 ` Guenter Roeck
  2 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2019-01-28 21:06 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck; +Cc: linux-hwmon, Linus Walleij

This adds device tree probing for the AD7418 hwmon sensor.
When device tree is not enabled, stub functions will kick
in.

Tested on the Gateway Cambria GW2358-4.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/hwmon/ad7418.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/ad7418.c b/drivers/hwmon/ad7418.c
index 76f0a5c01e8a..ec0f5d8f18c3 100644
--- a/drivers/hwmon/ad7418.c
+++ b/drivers/hwmon/ad7418.c
@@ -19,6 +19,7 @@
 #include <linux/hwmon-sysfs.h>
 #include <linux/err.h>
 #include <linux/mutex.h>
+#include <linux/of_device.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
 
@@ -220,7 +221,10 @@ static int ad7418_probe(struct i2c_client *client,
 
 	mutex_init(&data->lock);
 	data->client = client;
-	data->type = id->driver_data;
+	if (dev->of_node)
+		data->type = (enum chips)of_device_get_match_data(dev);
+	else
+		data->type = id->driver_data;
 
 	switch (data->type) {
 	case ad7416:
@@ -258,9 +262,17 @@ static const struct i2c_device_id ad7418_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, ad7418_id);
 
+static const struct of_device_id ad7418_dt_ids[] = {
+	{ .compatible = "adi,ad7416", .data = (void *)ad7416, },
+	{ .compatible = "adi,ad7417", .data = (void *)ad7417, },
+	{ .compatible = "adi,ad7418", .data = (void *)ad7418, },
+};
+MODULE_DEVICE_TABLE(of, ad7418_dt_ids);
+
 static struct i2c_driver ad7418_driver = {
 	.driver = {
 		.name	= "ad7418",
+		.of_match_table = ad7418_dt_ids,
 	},
 	.probe		= ad7418_probe,
 	.id_table	= ad7418_id,
-- 
2.20.1


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

* Re: [PATCH 1/2] hwmon: (ad741x) Add DT bindings for Analog Devices AD741x
  2019-01-28 21:06 [PATCH 1/2] hwmon: (ad741x) Add DT bindings for Analog Devices AD741x Linus Walleij
  2019-01-28 21:06 ` [PATCH 2/2] hwmon: (ad7418) Add device tree probing Linus Walleij
@ 2019-02-25 14:28 ` Rob Herring
  2019-02-25 14:36 ` Guenter Roeck
  2 siblings, 0 replies; 5+ messages in thread
From: Rob Herring @ 2019-02-25 14:28 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Jean Delvare, Guenter Roeck, linux-hwmon, Linus Walleij, devicetree

On Mon, 28 Jan 2019 22:06:36 +0100, Linus Walleij wrote:
> This adds device tree bindings for Analog Devices AD741x
> as found in Gateway routers.
> 
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  .../devicetree/bindings/hwmon/ad741x.txt          | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/hwmon/ad741x.txt
> 

Reviewed-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH 1/2] hwmon: (ad741x) Add DT bindings for Analog Devices AD741x
  2019-01-28 21:06 [PATCH 1/2] hwmon: (ad741x) Add DT bindings for Analog Devices AD741x Linus Walleij
  2019-01-28 21:06 ` [PATCH 2/2] hwmon: (ad7418) Add device tree probing Linus Walleij
  2019-02-25 14:28 ` [PATCH 1/2] hwmon: (ad741x) Add DT bindings for Analog Devices AD741x Rob Herring
@ 2019-02-25 14:36 ` Guenter Roeck
  2 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2019-02-25 14:36 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Jean Delvare, linux-hwmon, devicetree

On Mon, Jan 28, 2019 at 10:06:36PM +0100, Linus Walleij wrote:
> This adds device tree bindings for Analog Devices AD741x
> as found in Gateway routers.
> 
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> Reviewed-by: Rob Herring <robh@kernel.org>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  .../devicetree/bindings/hwmon/ad741x.txt          | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/hwmon/ad741x.txt
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/ad741x.txt b/Documentation/devicetree/bindings/hwmon/ad741x.txt
> new file mode 100644
> index 000000000000..9102152c8410
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/hwmon/ad741x.txt
> @@ -0,0 +1,15 @@
> +* AD7416/AD7417/AD7418 Temperature Sensor Device Tree Bindings
> +
> +Required properties:
> +- compatible: one of
> +		"adi,ad7416"
> +		"adi,ad7417"
> +		"adi,ad7418"
> +- reg: I2C address
> +
> +Example:
> +
> +hwmon@28 {
> +	compatible = "adi,ad7418";
> +	reg = <0x28>;
> +};

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

* Re: [PATCH 2/2] hwmon: (ad7418) Add device tree probing
  2019-01-28 21:06 ` [PATCH 2/2] hwmon: (ad7418) Add device tree probing Linus Walleij
@ 2019-02-25 14:36   ` Guenter Roeck
  0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2019-02-25 14:36 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Jean Delvare, linux-hwmon

On Mon, Jan 28, 2019 at 10:06:37PM +0100, Linus Walleij wrote:
> This adds device tree probing for the AD7418 hwmon sensor.
> When device tree is not enabled, stub functions will kick
> in.
> 
> Tested on the Gateway Cambria GW2358-4.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  drivers/hwmon/ad7418.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/ad7418.c b/drivers/hwmon/ad7418.c
> index 76f0a5c01e8a..ec0f5d8f18c3 100644
> --- a/drivers/hwmon/ad7418.c
> +++ b/drivers/hwmon/ad7418.c
> @@ -19,6 +19,7 @@
>  #include <linux/hwmon-sysfs.h>
>  #include <linux/err.h>
>  #include <linux/mutex.h>
> +#include <linux/of_device.h>
>  #include <linux/delay.h>
>  #include <linux/slab.h>
>  
> @@ -220,7 +221,10 @@ static int ad7418_probe(struct i2c_client *client,
>  
>  	mutex_init(&data->lock);
>  	data->client = client;
> -	data->type = id->driver_data;
> +	if (dev->of_node)
> +		data->type = (enum chips)of_device_get_match_data(dev);
> +	else
> +		data->type = id->driver_data;
>  
>  	switch (data->type) {
>  	case ad7416:
> @@ -258,9 +262,17 @@ static const struct i2c_device_id ad7418_id[] = {
>  };
>  MODULE_DEVICE_TABLE(i2c, ad7418_id);
>  
> +static const struct of_device_id ad7418_dt_ids[] = {
> +	{ .compatible = "adi,ad7416", .data = (void *)ad7416, },
> +	{ .compatible = "adi,ad7417", .data = (void *)ad7417, },
> +	{ .compatible = "adi,ad7418", .data = (void *)ad7418, },
> +};
> +MODULE_DEVICE_TABLE(of, ad7418_dt_ids);
> +
>  static struct i2c_driver ad7418_driver = {
>  	.driver = {
>  		.name	= "ad7418",
> +		.of_match_table = ad7418_dt_ids,
>  	},
>  	.probe		= ad7418_probe,
>  	.id_table	= ad7418_id,

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

end of thread, other threads:[~2019-02-25 14:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-28 21:06 [PATCH 1/2] hwmon: (ad741x) Add DT bindings for Analog Devices AD741x Linus Walleij
2019-01-28 21:06 ` [PATCH 2/2] hwmon: (ad7418) Add device tree probing Linus Walleij
2019-02-25 14:36   ` Guenter Roeck
2019-02-25 14:28 ` [PATCH 1/2] hwmon: (ad741x) Add DT bindings for Analog Devices AD741x Rob Herring
2019-02-25 14:36 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).