* [PATCH v4 2/2] hwmon: (sht15) Add device tree support
@ 2017-02-16 12:23 ` Marco Franchi
0 siblings, 0 replies; 16+ messages in thread
From: Marco Franchi @ 2017-02-16 12:23 UTC (permalink / raw)
To: linux; +Cc: robh+dt, devicetree, linux-hwmon, marcofrk, FoxPeter, Marco Franchi
Allow the driver to work with device tree support.
Based on initial patch submission from Peter Fox.
Tested on a imx7d-sdb board connected to a SHT15 board via Mikro Bus.
Signed-off-by: Marco Franchi <marco.franchi@nxp.com>
---
Changes since v3:
-Remove the optional properties because they are not hardware description
-Change the sensor node name
Documentation/devicetree/bindings/hwmon/sht15.txt | 19 +++++++
drivers/hwmon/sht15.c | 64 +++++++++++++++++++++--
2 files changed, 79 insertions(+), 4 deletions(-)
create mode 100644 Documentation/devicetree/bindings/hwmon/sht15.txt
diff --git a/Documentation/devicetree/bindings/hwmon/sht15.txt b/Documentation/devicetree/bindings/hwmon/sht15.txt
new file mode 100644
index 0000000..6a80277
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/sht15.txt
@@ -0,0 +1,19 @@
+Sensirion SHT15 Humidity and Temperature Sensor
+
+Required properties:
+
+ - "compatible": must be "sensirion,sht15".
+ - "data-gpios": GPIO connected to the data line.
+ - "clk-gpios": GPIO connected to the clock line.
+ - "vcc-supply": regulator that drives the VCC pin.
+
+Example:
+
+ sensor {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_sensor>;
+ compatible = "sensirion,sht15";
+ clk-gpios = <&gpio4 12 0>;
+ data-gpios = <&gpio4 13 0>;
+ vcc-supply = <®_sht15>;
+ };
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
index f16687c..69141b2 100644
--- a/drivers/hwmon/sht15.c
+++ b/drivers/hwmon/sht15.c
@@ -34,6 +34,7 @@
#include <linux/slab.h>
#include <linux/atomic.h>
#include <linux/bitrev.h>
+#include <linux/of_gpio.h>
/* Commands */
#define SHT15_MEASURE_TEMP 0x03
@@ -911,6 +912,54 @@ static int sht15_invalidate_voltage(struct notifier_block *nb,
return NOTIFY_OK;
}
+#ifdef CONFIG_OF
+static const struct of_device_id sht15_dt_match[] = {
+ { .compatible = "sensirion,sht15" },
+ { },
+};
+MODULE_DEVICE_TABLE(of, sht15_dt_match);
+
+/*
+ * This function returns NULL if pdev isn't a device instatiated by dt,
+ * a pointer to pdata if it could successfully get all information
+ * from dt or a negative ERR_PTR() on error.
+ */
+static struct sht15_platform_data *sht15_probe_dt(struct device *dev)
+{
+ struct device_node *np = dev->of_node;
+ struct sht15_platform_data *pdata;
+
+ /* no device tree device */
+ if (!np)
+ return NULL;
+
+ pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+ if (!pdata)
+ return ERR_PTR(-ENOMEM);
+
+ pdata->gpio_data = of_get_named_gpio(np, "data-gpios", 0);
+ if (pdata->gpio_data < 0) {
+ if (pdata->gpio_data != -EPROBE_DEFER)
+ dev_err(dev, "data-gpios not found\n");
+ return ERR_PTR(pdata->gpio_data);
+ }
+
+ pdata->gpio_sck = of_get_named_gpio(np, "clk-gpios", 0);
+ if (pdata->gpio_sck < 0) {
+ if (pdata->gpio_sck != -EPROBE_DEFER)
+ dev_err(dev, "clk-gpios not found\n");
+ return ERR_PTR(pdata->gpio_sck);
+ }
+
+ return pdata;
+}
+#else
+static inline struct sht15_platform_data *sht15_probe_dt(struct device *dev)
+{
+ return NULL;
+}
+#endif
+
static int sht15_probe(struct platform_device *pdev)
{
int ret;
@@ -928,11 +977,17 @@ static int sht15_probe(struct platform_device *pdev)
data->dev = &pdev->dev;
init_waitqueue_head(&data->wait_queue);
- if (dev_get_platdata(&pdev->dev) == NULL) {
- dev_err(&pdev->dev, "no platform data supplied\n");
- return -EINVAL;
+ data->pdata = sht15_probe_dt(&pdev->dev);
+ if (IS_ERR(data->pdata))
+ return PTR_ERR(data->pdata);
+ if (data->pdata == NULL) {
+ data->pdata = dev_get_platdata(&pdev->dev);
+ if (data->pdata == NULL) {
+ dev_err(&pdev->dev, "no platform data supplied\n");
+ return -EINVAL;
+ }
}
- data->pdata = dev_get_platdata(&pdev->dev);
+
data->supply_uv = data->pdata->supply_mv * 1000;
if (data->pdata->checksum)
data->checksumming = true;
@@ -1075,6 +1130,7 @@ MODULE_DEVICE_TABLE(platform, sht15_device_ids);
static struct platform_driver sht15_driver = {
.driver = {
.name = "sht15",
+ .of_match_table = of_match_ptr(sht15_dt_match),
},
.probe = sht15_probe,
.remove = sht15_remove,
--
2.7.4
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v4 2/2] hwmon: (sht15) Add device tree support
@ 2017-02-16 12:23 ` Marco Franchi
0 siblings, 0 replies; 16+ messages in thread
From: Marco Franchi @ 2017-02-16 12:23 UTC (permalink / raw)
To: linux; +Cc: robh+dt, devicetree, linux-hwmon, marcofrk, FoxPeter, Marco Franchi
Allow the driver to work with device tree support.
Based on initial patch submission from Peter Fox.
Tested on a imx7d-sdb board connected to a SHT15 board via Mikro Bus.
Signed-off-by: Marco Franchi <marco.franchi@nxp.com>
---
Changes since v3:
-Remove the optional properties because they are not hardware description
-Change the sensor node name
Documentation/devicetree/bindings/hwmon/sht15.txt | 19 +++++++
drivers/hwmon/sht15.c | 64 +++++++++++++++++++++--
2 files changed, 79 insertions(+), 4 deletions(-)
create mode 100644 Documentation/devicetree/bindings/hwmon/sht15.txt
diff --git a/Documentation/devicetree/bindings/hwmon/sht15.txt b/Documentation/devicetree/bindings/hwmon/sht15.txt
new file mode 100644
index 0000000..6a80277
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/sht15.txt
@@ -0,0 +1,19 @@
+Sensirion SHT15 Humidity and Temperature Sensor
+
+Required properties:
+
+ - "compatible": must be "sensirion,sht15".
+ - "data-gpios": GPIO connected to the data line.
+ - "clk-gpios": GPIO connected to the clock line.
+ - "vcc-supply": regulator that drives the VCC pin.
+
+Example:
+
+ sensor {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_sensor>;
+ compatible = "sensirion,sht15";
+ clk-gpios = <&gpio4 12 0>;
+ data-gpios = <&gpio4 13 0>;
+ vcc-supply = <®_sht15>;
+ };
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
index f16687c..69141b2 100644
--- a/drivers/hwmon/sht15.c
+++ b/drivers/hwmon/sht15.c
@@ -34,6 +34,7 @@
#include <linux/slab.h>
#include <linux/atomic.h>
#include <linux/bitrev.h>
+#include <linux/of_gpio.h>
/* Commands */
#define SHT15_MEASURE_TEMP 0x03
@@ -911,6 +912,54 @@ static int sht15_invalidate_voltage(struct notifier_block *nb,
return NOTIFY_OK;
}
+#ifdef CONFIG_OF
+static const struct of_device_id sht15_dt_match[] = {
+ { .compatible = "sensirion,sht15" },
+ { },
+};
+MODULE_DEVICE_TABLE(of, sht15_dt_match);
+
+/*
+ * This function returns NULL if pdev isn't a device instatiated by dt,
+ * a pointer to pdata if it could successfully get all information
+ * from dt or a negative ERR_PTR() on error.
+ */
+static struct sht15_platform_data *sht15_probe_dt(struct device *dev)
+{
+ struct device_node *np = dev->of_node;
+ struct sht15_platform_data *pdata;
+
+ /* no device tree device */
+ if (!np)
+ return NULL;
+
+ pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+ if (!pdata)
+ return ERR_PTR(-ENOMEM);
+
+ pdata->gpio_data = of_get_named_gpio(np, "data-gpios", 0);
+ if (pdata->gpio_data < 0) {
+ if (pdata->gpio_data != -EPROBE_DEFER)
+ dev_err(dev, "data-gpios not found\n");
+ return ERR_PTR(pdata->gpio_data);
+ }
+
+ pdata->gpio_sck = of_get_named_gpio(np, "clk-gpios", 0);
+ if (pdata->gpio_sck < 0) {
+ if (pdata->gpio_sck != -EPROBE_DEFER)
+ dev_err(dev, "clk-gpios not found\n");
+ return ERR_PTR(pdata->gpio_sck);
+ }
+
+ return pdata;
+}
+#else
+static inline struct sht15_platform_data *sht15_probe_dt(struct device *dev)
+{
+ return NULL;
+}
+#endif
+
static int sht15_probe(struct platform_device *pdev)
{
int ret;
@@ -928,11 +977,17 @@ static int sht15_probe(struct platform_device *pdev)
data->dev = &pdev->dev;
init_waitqueue_head(&data->wait_queue);
- if (dev_get_platdata(&pdev->dev) == NULL) {
- dev_err(&pdev->dev, "no platform data supplied\n");
- return -EINVAL;
+ data->pdata = sht15_probe_dt(&pdev->dev);
+ if (IS_ERR(data->pdata))
+ return PTR_ERR(data->pdata);
+ if (data->pdata == NULL) {
+ data->pdata = dev_get_platdata(&pdev->dev);
+ if (data->pdata == NULL) {
+ dev_err(&pdev->dev, "no platform data supplied\n");
+ return -EINVAL;
+ }
}
- data->pdata = dev_get_platdata(&pdev->dev);
+
data->supply_uv = data->pdata->supply_mv * 1000;
if (data->pdata->checksum)
data->checksumming = true;
@@ -1075,6 +1130,7 @@ MODULE_DEVICE_TABLE(platform, sht15_device_ids);
static struct platform_driver sht15_driver = {
.driver = {
.name = "sht15",
+ .of_match_table = of_match_ptr(sht15_dt_match),
},
.probe = sht15_probe,
.remove = sht15_remove,
--
2.7.4
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v4 1/2] dt: Add vendor prefix for Sensirion
@ 2017-02-16 12:23 ` Marco Franchi
0 siblings, 0 replies; 16+ messages in thread
From: Marco Franchi @ 2017-02-16 12:23 UTC (permalink / raw)
To: linux; +Cc: robh+dt, devicetree, linux-hwmon, marcofrk, FoxPeter, Marco Franchi
Sensirion is a sensor manufacturer, providing relative humidity sensors,
temperature sensor and flow sensor solutions.
Signed-off-by: Marco Franchi <marco.franchi@nxp.com>
---
Changes since v3:
- none
Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 7a98c33..43e1799 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -263,6 +263,7 @@ sbs Smart Battery System
schindler Schindler
seagate Seagate Technology PLC
semtech Semtech Corporation
+sensirion Sensirion AG
sgx SGX Sensortech
sharp Sharp Corporation
si-en Si-En Technology Ltd.
--
2.7.4
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v4 1/2] dt: Add vendor prefix for Sensirion
@ 2017-02-16 12:23 ` Marco Franchi
0 siblings, 0 replies; 16+ messages in thread
From: Marco Franchi @ 2017-02-16 12:23 UTC (permalink / raw)
To: linux-0h96xk9xTtrk1uMJSBkQmQ
Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-hwmon-u79uwXL29TY76Z2rM5mHXA,
marcofrk-Re5JQEeQqe8AvxtiuMwx3w, FoxPeter-5t/GDYzpMLSELgA04lAiVw,
Marco Franchi
Sensirion is a sensor manufacturer, providing relative humidity sensors,
temperature sensor and flow sensor solutions.
Signed-off-by: Marco Franchi <marco.franchi-3arQi8VN3Tc@public.gmane.org>
---
Changes since v3:
- none
Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 7a98c33..43e1799 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -263,6 +263,7 @@ sbs Smart Battery System
schindler Schindler
seagate Seagate Technology PLC
semtech Semtech Corporation
+sensirion Sensirion AG
sgx SGX Sensortech
sharp Sharp Corporation
si-en Si-En Technology Ltd.
--
2.7.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v4 2/2] hwmon: (sht15) Add device tree support
@ 2017-02-16 12:53 ` Fabio Estevam
0 siblings, 0 replies; 16+ messages in thread
From: Fabio Estevam @ 2017-02-16 12:53 UTC (permalink / raw)
To: Marco Franchi
Cc: Guenter Roeck, robh+dt, devicetree, linux-hwmon,
Marco Antonio Franchi, FoxPeter
On Thu, Feb 16, 2017 at 10:23 AM, Marco Franchi <marco.franchi@nxp.com> wrote:
> Allow the driver to work with device tree support.
>
> Based on initial patch submission from Peter Fox.
>
> Tested on a imx7d-sdb board connected to a SHT15 board via Mikro Bus.
>
> Signed-off-by: Marco Franchi <marco.franchi@nxp.com>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4 2/2] hwmon: (sht15) Add device tree support
@ 2017-02-16 12:53 ` Fabio Estevam
0 siblings, 0 replies; 16+ messages in thread
From: Fabio Estevam @ 2017-02-16 12:53 UTC (permalink / raw)
To: Marco Franchi
Cc: Guenter Roeck, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-hwmon-u79uwXL29TY76Z2rM5mHXA, Marco Antonio Franchi,
FoxPeter-5t/GDYzpMLSELgA04lAiVw
On Thu, Feb 16, 2017 at 10:23 AM, Marco Franchi <marco.franchi-3arQi8VN3Tc@public.gmane.org> wrote:
> Allow the driver to work with device tree support.
>
> Based on initial patch submission from Peter Fox.
>
> Tested on a imx7d-sdb board connected to a SHT15 board via Mikro Bus.
>
> Signed-off-by: Marco Franchi <marco.franchi-3arQi8VN3Tc@public.gmane.org>
Reviewed-by: Fabio Estevam <fabio.estevam-3arQi8VN3Tc@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4 1/2] dt: Add vendor prefix for Sensirion
@ 2017-02-16 14:43 ` Guenter Roeck
0 siblings, 0 replies; 16+ messages in thread
From: Guenter Roeck @ 2017-02-16 14:43 UTC (permalink / raw)
To: Marco Franchi; +Cc: robh+dt, devicetree, linux-hwmon, marcofrk, FoxPeter
On 02/16/2017 04:23 AM, Marco Franchi wrote:
> Sensirion is a sensor manufacturer, providing relative humidity sensors,
> temperature sensor and flow sensor solutions.
>
> Signed-off-by: Marco Franchi <marco.franchi@nxp.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Wonder who should queue this up. Rob ?
Thanks,
guenter
> ---
> Changes since v3:
> - none
>
> Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index 7a98c33..43e1799 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -263,6 +263,7 @@ sbs Smart Battery System
> schindler Schindler
> seagate Seagate Technology PLC
> semtech Semtech Corporation
> +sensirion Sensirion AG
> sgx SGX Sensortech
> sharp Sharp Corporation
> si-en Si-En Technology Ltd.
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4 1/2] dt: Add vendor prefix for Sensirion
@ 2017-02-16 14:43 ` Guenter Roeck
0 siblings, 0 replies; 16+ messages in thread
From: Guenter Roeck @ 2017-02-16 14:43 UTC (permalink / raw)
To: Marco Franchi
Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-hwmon-u79uwXL29TY76Z2rM5mHXA,
marcofrk-Re5JQEeQqe8AvxtiuMwx3w, FoxPeter-5t/GDYzpMLSELgA04lAiVw
On 02/16/2017 04:23 AM, Marco Franchi wrote:
> Sensirion is a sensor manufacturer, providing relative humidity sensors,
> temperature sensor and flow sensor solutions.
>
> Signed-off-by: Marco Franchi <marco.franchi-3arQi8VN3Tc@public.gmane.org>
Reviewed-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
Wonder who should queue this up. Rob ?
Thanks,
guenter
> ---
> Changes since v3:
> - none
>
> Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index 7a98c33..43e1799 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -263,6 +263,7 @@ sbs Smart Battery System
> schindler Schindler
> seagate Seagate Technology PLC
> semtech Semtech Corporation
> +sensirion Sensirion AG
> sgx SGX Sensortech
> sharp Sharp Corporation
> si-en Si-En Technology Ltd.
>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4 2/2] hwmon: (sht15) Add device tree support
2017-02-16 12:23 ` Marco Franchi
` (2 preceding siblings ...)
(?)
@ 2017-02-16 14:48 ` Guenter Roeck
-1 siblings, 0 replies; 16+ messages in thread
From: Guenter Roeck @ 2017-02-16 14:48 UTC (permalink / raw)
To: Marco Franchi; +Cc: robh+dt, devicetree, linux-hwmon, marcofrk, FoxPeter
On 02/16/2017 04:23 AM, Marco Franchi wrote:
> Allow the driver to work with device tree support.
>
> Based on initial patch submission from Peter Fox.
>
> Tested on a imx7d-sdb board connected to a SHT15 board via Mikro Bus.
>
> Signed-off-by: Marco Franchi <marco.franchi@nxp.com>
> ---
> Changes since v3:
> -Remove the optional properties because they are not hardware description
Yes but they are in platform data. I thought that kind of configuration data
is fair game nowadays for devicetree data, but on the other side I must admit
that I may not be up to date on what is permitted or not.
Either case, I'll queue this patch up for -next. Refinements can be made
later if/when needed.
Thanks,
Guenter
> -Change the sensor node name
>
> Documentation/devicetree/bindings/hwmon/sht15.txt | 19 +++++++
> drivers/hwmon/sht15.c | 64 +++++++++++++++++++++--
> 2 files changed, 79 insertions(+), 4 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/hwmon/sht15.txt
>
> diff --git a/Documentation/devicetree/bindings/hwmon/sht15.txt b/Documentation/devicetree/bindings/hwmon/sht15.txt
> new file mode 100644
> index 0000000..6a80277
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/hwmon/sht15.txt
> @@ -0,0 +1,19 @@
> +Sensirion SHT15 Humidity and Temperature Sensor
> +
> +Required properties:
> +
> + - "compatible": must be "sensirion,sht15".
> + - "data-gpios": GPIO connected to the data line.
> + - "clk-gpios": GPIO connected to the clock line.
> + - "vcc-supply": regulator that drives the VCC pin.
> +
> +Example:
> +
> + sensor {
> + pinctrl-names = "default";
> + pinctrl-0 = <&pinctrl_sensor>;
> + compatible = "sensirion,sht15";
> + clk-gpios = <&gpio4 12 0>;
> + data-gpios = <&gpio4 13 0>;
> + vcc-supply = <®_sht15>;
> + };
> diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
> index f16687c..69141b2 100644
> --- a/drivers/hwmon/sht15.c
> +++ b/drivers/hwmon/sht15.c
> @@ -34,6 +34,7 @@
> #include <linux/slab.h>
> #include <linux/atomic.h>
> #include <linux/bitrev.h>
> +#include <linux/of_gpio.h>
>
> /* Commands */
> #define SHT15_MEASURE_TEMP 0x03
> @@ -911,6 +912,54 @@ static int sht15_invalidate_voltage(struct notifier_block *nb,
> return NOTIFY_OK;
> }
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id sht15_dt_match[] = {
> + { .compatible = "sensirion,sht15" },
> + { },
> +};
> +MODULE_DEVICE_TABLE(of, sht15_dt_match);
> +
> +/*
> + * This function returns NULL if pdev isn't a device instatiated by dt,
> + * a pointer to pdata if it could successfully get all information
> + * from dt or a negative ERR_PTR() on error.
> + */
> +static struct sht15_platform_data *sht15_probe_dt(struct device *dev)
> +{
> + struct device_node *np = dev->of_node;
> + struct sht15_platform_data *pdata;
> +
> + /* no device tree device */
> + if (!np)
> + return NULL;
> +
> + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> + if (!pdata)
> + return ERR_PTR(-ENOMEM);
> +
> + pdata->gpio_data = of_get_named_gpio(np, "data-gpios", 0);
> + if (pdata->gpio_data < 0) {
> + if (pdata->gpio_data != -EPROBE_DEFER)
> + dev_err(dev, "data-gpios not found\n");
> + return ERR_PTR(pdata->gpio_data);
> + }
> +
> + pdata->gpio_sck = of_get_named_gpio(np, "clk-gpios", 0);
> + if (pdata->gpio_sck < 0) {
> + if (pdata->gpio_sck != -EPROBE_DEFER)
> + dev_err(dev, "clk-gpios not found\n");
> + return ERR_PTR(pdata->gpio_sck);
> + }
> +
> + return pdata;
> +}
> +#else
> +static inline struct sht15_platform_data *sht15_probe_dt(struct device *dev)
> +{
> + return NULL;
> +}
> +#endif
> +
> static int sht15_probe(struct platform_device *pdev)
> {
> int ret;
> @@ -928,11 +977,17 @@ static int sht15_probe(struct platform_device *pdev)
> data->dev = &pdev->dev;
> init_waitqueue_head(&data->wait_queue);
>
> - if (dev_get_platdata(&pdev->dev) == NULL) {
> - dev_err(&pdev->dev, "no platform data supplied\n");
> - return -EINVAL;
> + data->pdata = sht15_probe_dt(&pdev->dev);
> + if (IS_ERR(data->pdata))
> + return PTR_ERR(data->pdata);
> + if (data->pdata == NULL) {
> + data->pdata = dev_get_platdata(&pdev->dev);
> + if (data->pdata == NULL) {
> + dev_err(&pdev->dev, "no platform data supplied\n");
> + return -EINVAL;
> + }
> }
> - data->pdata = dev_get_platdata(&pdev->dev);
> +
> data->supply_uv = data->pdata->supply_mv * 1000;
> if (data->pdata->checksum)
> data->checksumming = true;
> @@ -1075,6 +1130,7 @@ MODULE_DEVICE_TABLE(platform, sht15_device_ids);
> static struct platform_driver sht15_driver = {
> .driver = {
> .name = "sht15",
> + .of_match_table = of_match_ptr(sht15_dt_match),
> },
> .probe = sht15_probe,
> .remove = sht15_remove,
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4 2/2] hwmon: (sht15) Add device tree support
@ 2017-02-27 15:57 ` Rob Herring
0 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2017-02-27 15:57 UTC (permalink / raw)
To: Marco Franchi; +Cc: linux, devicetree, linux-hwmon, marcofrk, FoxPeter
On Thu, Feb 16, 2017 at 10:23:43AM -0200, Marco Franchi wrote:
> Allow the driver to work with device tree support.
>
> Based on initial patch submission from Peter Fox.
>
> Tested on a imx7d-sdb board connected to a SHT15 board via Mikro Bus.
>
> Signed-off-by: Marco Franchi <marco.franchi@nxp.com>
> ---
> Changes since v3:
> -Remove the optional properties because they are not hardware description
> -Change the sensor node name
>
> Documentation/devicetree/bindings/hwmon/sht15.txt | 19 +++++++
> drivers/hwmon/sht15.c | 64 +++++++++++++++++++++--
> 2 files changed, 79 insertions(+), 4 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/hwmon/sht15.txt
>
> diff --git a/Documentation/devicetree/bindings/hwmon/sht15.txt b/Documentation/devicetree/bindings/hwmon/sht15.txt
> new file mode 100644
> index 0000000..6a80277
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/hwmon/sht15.txt
> @@ -0,0 +1,19 @@
> +Sensirion SHT15 Humidity and Temperature Sensor
> +
> +Required properties:
> +
> + - "compatible": must be "sensirion,sht15".
> + - "data-gpios": GPIO connected to the data line.
> + - "clk-gpios": GPIO connected to the clock line.
Looks like this device is I2C perhaps? Though I'm not sure the waveforms
before and after transactions are compliant.
> + - "vcc-supply": regulator that drives the VCC pin.
> +
> +Example:
> +
> + sensor {
> + pinctrl-names = "default";
> + pinctrl-0 = <&pinctrl_sensor>;
> + compatible = "sensirion,sht15";
> + clk-gpios = <&gpio4 12 0>;
> + data-gpios = <&gpio4 13 0>;
> + vcc-supply = <®_sht15>;
> + };
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4 2/2] hwmon: (sht15) Add device tree support
@ 2017-02-27 15:57 ` Rob Herring
0 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2017-02-27 15:57 UTC (permalink / raw)
To: Marco Franchi
Cc: linux-0h96xk9xTtrk1uMJSBkQmQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-hwmon-u79uwXL29TY76Z2rM5mHXA,
marcofrk-Re5JQEeQqe8AvxtiuMwx3w, FoxPeter-5t/GDYzpMLSELgA04lAiVw
On Thu, Feb 16, 2017 at 10:23:43AM -0200, Marco Franchi wrote:
> Allow the driver to work with device tree support.
>
> Based on initial patch submission from Peter Fox.
>
> Tested on a imx7d-sdb board connected to a SHT15 board via Mikro Bus.
>
> Signed-off-by: Marco Franchi <marco.franchi-3arQi8VN3Tc@public.gmane.org>
> ---
> Changes since v3:
> -Remove the optional properties because they are not hardware description
> -Change the sensor node name
>
> Documentation/devicetree/bindings/hwmon/sht15.txt | 19 +++++++
> drivers/hwmon/sht15.c | 64 +++++++++++++++++++++--
> 2 files changed, 79 insertions(+), 4 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/hwmon/sht15.txt
>
> diff --git a/Documentation/devicetree/bindings/hwmon/sht15.txt b/Documentation/devicetree/bindings/hwmon/sht15.txt
> new file mode 100644
> index 0000000..6a80277
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/hwmon/sht15.txt
> @@ -0,0 +1,19 @@
> +Sensirion SHT15 Humidity and Temperature Sensor
> +
> +Required properties:
> +
> + - "compatible": must be "sensirion,sht15".
> + - "data-gpios": GPIO connected to the data line.
> + - "clk-gpios": GPIO connected to the clock line.
Looks like this device is I2C perhaps? Though I'm not sure the waveforms
before and after transactions are compliant.
> + - "vcc-supply": regulator that drives the VCC pin.
> +
> +Example:
> +
> + sensor {
> + pinctrl-names = "default";
> + pinctrl-0 = <&pinctrl_sensor>;
> + compatible = "sensirion,sht15";
> + clk-gpios = <&gpio4 12 0>;
> + data-gpios = <&gpio4 13 0>;
> + vcc-supply = <®_sht15>;
> + };
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4 1/2] dt: Add vendor prefix for Sensirion
2017-02-16 14:43 ` Guenter Roeck
(?)
@ 2017-02-27 15:58 ` Rob Herring
2017-02-27 17:32 ` Rob Herring
-1 siblings, 1 reply; 16+ messages in thread
From: Rob Herring @ 2017-02-27 15:58 UTC (permalink / raw)
To: Guenter Roeck; +Cc: Marco Franchi, devicetree, linux-hwmon, marcofrk, FoxPeter
On Thu, Feb 16, 2017 at 06:43:51AM -0800, Guenter Roeck wrote:
> On 02/16/2017 04:23 AM, Marco Franchi wrote:
> > Sensirion is a sensor manufacturer, providing relative humidity sensors,
> > temperature sensor and flow sensor solutions.
> >
> > Signed-off-by: Marco Franchi <marco.franchi@nxp.com>
>
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
>
> Wonder who should queue this up. Rob ?
You can apply with the rest of the series.
Acked-by: Rob Herring <robh@kernel.org>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4 2/2] hwmon: (sht15) Add device tree support
2017-02-27 15:57 ` Rob Herring
@ 2017-02-27 16:46 ` Fabio Estevam
-1 siblings, 0 replies; 16+ messages in thread
From: Fabio Estevam @ 2017-02-27 16:46 UTC (permalink / raw)
To: Rob Herring
Cc: Marco Franchi, Guenter Roeck, devicetree, linux-hwmon,
Marco Antonio Franchi, FoxPeter
Hi Rob,
On Mon, Feb 27, 2017 at 12:57 PM, Rob Herring <robh@kernel.org> wrote:
>> +Required properties:
>> +
>> + - "compatible": must be "sensirion,sht15".
>> + - "data-gpios": GPIO connected to the data line.
>> + - "clk-gpios": GPIO connected to the clock line.
>
> Looks like this device is I2C perhaps? Though I'm not sure the waveforms
> before and after transactions are compliant.
No, the SHT15 datasheet is very clear that the device does not operate
in I2C mode:
"The sensor cannot be addressed by I2C protocol".
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4 2/2] hwmon: (sht15) Add device tree support
@ 2017-02-27 16:46 ` Fabio Estevam
0 siblings, 0 replies; 16+ messages in thread
From: Fabio Estevam @ 2017-02-27 16:46 UTC (permalink / raw)
To: Rob Herring
Cc: Marco Franchi, Guenter Roeck, devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-hwmon-u79uwXL29TY76Z2rM5mHXA, Marco Antonio Franchi,
FoxPeter-5t/GDYzpMLSELgA04lAiVw
Hi Rob,
On Mon, Feb 27, 2017 at 12:57 PM, Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
>> +Required properties:
>> +
>> + - "compatible": must be "sensirion,sht15".
>> + - "data-gpios": GPIO connected to the data line.
>> + - "clk-gpios": GPIO connected to the clock line.
>
> Looks like this device is I2C perhaps? Though I'm not sure the waveforms
> before and after transactions are compliant.
No, the SHT15 datasheet is very clear that the device does not operate
in I2C mode:
"The sensor cannot be addressed by I2C protocol".
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4 2/2] hwmon: (sht15) Add device tree support
2017-02-27 16:46 ` Fabio Estevam
(?)
@ 2017-02-27 17:31 ` Rob Herring
-1 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2017-02-27 17:31 UTC (permalink / raw)
To: Fabio Estevam
Cc: Marco Franchi, Guenter Roeck, devicetree, linux-hwmon,
Marco Antonio Franchi, FoxPeter
On Mon, Feb 27, 2017 at 10:46 AM, Fabio Estevam <festevam@gmail.com> wrote:
> Hi Rob,
>
> On Mon, Feb 27, 2017 at 12:57 PM, Rob Herring <robh@kernel.org> wrote:
>
>>> +Required properties:
>>> +
>>> + - "compatible": must be "sensirion,sht15".
>>> + - "data-gpios": GPIO connected to the data line.
>>> + - "clk-gpios": GPIO connected to the clock line.
>>
>> Looks like this device is I2C perhaps? Though I'm not sure the waveforms
>> before and after transactions are compliant.
>
> No, the SHT15 datasheet is very clear that the device does not operate
> in I2C mode:
> "The sensor cannot be addressed by I2C protocol".
I missed that since it is under "Power Pins" section... As our "great"
leader says: Sad.
Acked-by: Rob Herring <robh@kernel.org>
BTW, looks like they fixed that with the SHT20.
Rob
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4 1/2] dt: Add vendor prefix for Sensirion
2017-02-27 15:58 ` Rob Herring
@ 2017-02-27 17:32 ` Rob Herring
0 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2017-02-27 17:32 UTC (permalink / raw)
To: Guenter Roeck
Cc: Marco Franchi, devicetree, linux-hwmon, Marco Antonio Franchi, FoxPeter
On Mon, Feb 27, 2017 at 9:58 AM, Rob Herring <robh@kernel.org> wrote:
> On Thu, Feb 16, 2017 at 06:43:51AM -0800, Guenter Roeck wrote:
>> On 02/16/2017 04:23 AM, Marco Franchi wrote:
>> > Sensirion is a sensor manufacturer, providing relative humidity sensors,
>> > temperature sensor and flow sensor solutions.
>> >
>> > Signed-off-by: Marco Franchi <marco.franchi@nxp.com>
>>
>> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
>>
>> Wonder who should queue this up. Rob ?
>
> You can apply with the rest of the series.
>
> Acked-by: Rob Herring <robh@kernel.org>
Actually, looks like there are 2 different patches adding this, so
I'll take this one.
Rob
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2017-02-27 17:32 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-16 12:23 [PATCH v4 2/2] hwmon: (sht15) Add device tree support Marco Franchi
2017-02-16 12:23 ` Marco Franchi
2017-02-16 12:23 ` [PATCH v4 1/2] dt: Add vendor prefix for Sensirion Marco Franchi
2017-02-16 12:23 ` Marco Franchi
2017-02-16 14:43 ` Guenter Roeck
2017-02-16 14:43 ` Guenter Roeck
2017-02-27 15:58 ` Rob Herring
2017-02-27 17:32 ` Rob Herring
2017-02-16 12:53 ` [PATCH v4 2/2] hwmon: (sht15) Add device tree support Fabio Estevam
2017-02-16 12:53 ` Fabio Estevam
2017-02-16 14:48 ` Guenter Roeck
2017-02-27 15:57 ` Rob Herring
2017-02-27 15:57 ` Rob Herring
2017-02-27 16:46 ` Fabio Estevam
2017-02-27 16:46 ` Fabio Estevam
2017-02-27 17:31 ` Rob Herring
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.