linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] iio: st_sensors: Support ACPI probe for st_sensors
@ 2016-11-24  5:33 Shrirang Bagul
  2016-11-24  5:33 ` [PATCH 1/3] iio: st_sensors: match sensors using ACPI handle Shrirang Bagul
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Shrirang Bagul @ 2016-11-24  5:33 UTC (permalink / raw)
  To: jic23
  Cc: knaack.h, lars, pmeerw, denis.ciocca, tiberiu.a.breana,
	lorenzo.bianconi83, linus.walleij, gregor.boirie, linux-iio,
	linux-kernel, Shrirang Bagul

Hi,

These patches are based on available work in iio git repository
(git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git) "testing"
branch.

Compatible strings don't exist on ACPI based systems. This patchset adds
probe support by reading ACPI unique identifiers from platform bios for
st_pressure and st_accel sensor drivers. Some of these sensors are present
on Dell IoT gateways.

Thanks,
Shrirang

Shrirang Bagul (3):
  iio: st_sensors: match sensors using ACPI handle
  iio: st_accel: Support sensor i2c probe using acpi
  iio: st_pressure: Support i2c probe using acpi

 drivers/iio/accel/st_accel.h                   | 18 +++++++
 drivers/iio/accel/st_accel_i2c.c               | 73 +++++++++++++++++---------
 drivers/iio/common/st_sensors/st_sensors_i2c.c | 20 +++++++
 drivers/iio/pressure/st_pressure.h             |  8 +++
 drivers/iio/pressure/st_pressure_i2c.c         | 51 +++++++++++++-----
 include/linux/iio/common/st_sensors_i2c.h      |  9 ++++
 6 files changed, 142 insertions(+), 37 deletions(-)

-- 
2.9.3

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

* [PATCH 1/3] iio: st_sensors: match sensors using ACPI handle
  2016-11-24  5:33 [PATCH 0/3] iio: st_sensors: Support ACPI probe for st_sensors Shrirang Bagul
@ 2016-11-24  5:33 ` Shrirang Bagul
  2016-11-27 11:15   ` Jonathan Cameron
  2016-11-24  5:33 ` [PATCH 2/3] iio: st_accel: Support sensor i2c probe using acpi Shrirang Bagul
  2016-11-24  5:33 ` [PATCH 3/3] iio: st_pressure: Support " Shrirang Bagul
  2 siblings, 1 reply; 13+ messages in thread
From: Shrirang Bagul @ 2016-11-24  5:33 UTC (permalink / raw)
  To: jic23
  Cc: knaack.h, lars, pmeerw, denis.ciocca, tiberiu.a.breana,
	lorenzo.bianconi83, linus.walleij, gregor.boirie, linux-iio,
	linux-kernel, Shrirang Bagul

Add support to match st sensors using information passed from ACPI DST
tables.

Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
---
 drivers/iio/common/st_sensors/st_sensors_i2c.c | 20 ++++++++++++++++++++
 include/linux/iio/common/st_sensors_i2c.h      |  9 +++++++++
 2 files changed, 29 insertions(+)

diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c
index b43aa36..c83df4d 100644
--- a/drivers/iio/common/st_sensors/st_sensors_i2c.c
+++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c
@@ -13,6 +13,7 @@
 #include <linux/slab.h>
 #include <linux/iio/iio.h>
 #include <linux/of_device.h>
+#include <linux/acpi.h>
 
 #include <linux/iio/common/st_sensors_i2c.h>
 
@@ -107,6 +108,25 @@ void st_sensors_of_i2c_probe(struct i2c_client *client,
 EXPORT_SYMBOL(st_sensors_of_i2c_probe);
 #endif
 
+#ifdef CONFIG_ACPI
+int st_sensors_match_acpi_device(struct device *dev)
+{
+	const struct acpi_device_id *acpi_id;
+	kernel_ulong_t driver_data = 0;
+
+	if (ACPI_HANDLE(dev)) {
+		acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev);
+		if (!acpi_id) {
+			dev_err(dev, "No driver data\n");
+			return -EINVAL;
+		}
+		driver_data = acpi_id->driver_data;
+	}
+	return driver_data;
+}
+EXPORT_SYMBOL(st_sensors_match_acpi_device);
+#endif
+
 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
 MODULE_DESCRIPTION("STMicroelectronics ST-sensors i2c driver");
 MODULE_LICENSE("GPL v2");
diff --git a/include/linux/iio/common/st_sensors_i2c.h b/include/linux/iio/common/st_sensors_i2c.h
index 1796af0..254de3c 100644
--- a/include/linux/iio/common/st_sensors_i2c.h
+++ b/include/linux/iio/common/st_sensors_i2c.h
@@ -28,4 +28,13 @@ static inline void st_sensors_of_i2c_probe(struct i2c_client *client,
 }
 #endif
 
+#ifdef CONFIG_ACPI
+int st_sensors_match_acpi_device(struct device *dev);
+#else
+static inline int st_sensors_match_acpi_device(struct device *dev)
+{
+	return -ENODEV;
+}
+#endif
+
 #endif /* ST_SENSORS_I2C_H */
-- 
2.9.3

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

* [PATCH 2/3] iio: st_accel: Support sensor i2c probe using acpi
  2016-11-24  5:33 [PATCH 0/3] iio: st_sensors: Support ACPI probe for st_sensors Shrirang Bagul
  2016-11-24  5:33 ` [PATCH 1/3] iio: st_sensors: match sensors using ACPI handle Shrirang Bagul
@ 2016-11-24  5:33 ` Shrirang Bagul
  2016-11-24 14:26   ` Linus Walleij
  2016-11-24  5:33 ` [PATCH 3/3] iio: st_pressure: Support " Shrirang Bagul
  2 siblings, 1 reply; 13+ messages in thread
From: Shrirang Bagul @ 2016-11-24  5:33 UTC (permalink / raw)
  To: jic23
  Cc: knaack.h, lars, pmeerw, denis.ciocca, tiberiu.a.breana,
	lorenzo.bianconi83, linus.walleij, gregor.boirie, linux-iio,
	linux-kernel, Shrirang Bagul

Add support to probe st_accel sensors on i2c bus using ACPI. Compatible
strings are not avaialable on ACPI based systems.

Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
---
 drivers/iio/accel/st_accel.h     | 18 ++++++++++
 drivers/iio/accel/st_accel_i2c.c | 73 +++++++++++++++++++++++++++-------------
 2 files changed, 67 insertions(+), 24 deletions(-)

diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
index 7c23168..3ad44ce 100644
--- a/drivers/iio/accel/st_accel.h
+++ b/drivers/iio/accel/st_accel.h
@@ -14,6 +14,24 @@
 #include <linux/types.h>
 #include <linux/iio/common/st_sensors.h>
 
+enum st_accel_type {
+	LSM303DLH,
+	LSM303DLHC,
+	LIS3DH,
+	LSM330D,
+	LSM330DL,
+	LSM330DLC,
+	LIS331DLH,
+	LSM303DL,
+	LSM303DLM,
+	LSM330,
+	LSM303AGR,
+	LIS2DH12,
+	LIS3L02DQ,
+	LNG2DM,
+	ST_ACCEL_MAX,
+};
+
 #define H3LIS331DL_DRIVER_NAME		"h3lis331dl_accel"
 #define LIS3LV02DL_ACCEL_DEV_NAME	"lis3lv02dl_accel"
 #define LSM303DLHC_ACCEL_DEV_NAME	"lsm303dlhc_accel"
diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c
index c0f8867..2840649 100644
--- a/drivers/iio/accel/st_accel_i2c.c
+++ b/drivers/iio/accel/st_accel_i2c.c
@@ -11,6 +11,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/acpi.h>
 #include <linux/i2c.h>
 #include <linux/iio/iio.h>
 
@@ -95,25 +96,67 @@ MODULE_DEVICE_TABLE(of, st_accel_of_match);
 #define st_accel_of_match NULL
 #endif
 
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id st_accel_acpi_match[] = {
+	{"SMO8A90", LNG2DM},
+	{ },
+};
+MODULE_DEVICE_TABLE(acpi, st_accel_acpi_match);
+#else
+#define st_accel_acpi_match NULL
+#endif
+
+static const struct i2c_device_id st_accel_id_table[] = {
+	{ LSM303DLH_ACCEL_DEV_NAME, LSM303DLH },
+	{ LSM303DLHC_ACCEL_DEV_NAME, LSM303DLHC },
+	{ LIS3DH_ACCEL_DEV_NAME, LIS3DH },
+	{ LSM330D_ACCEL_DEV_NAME, LSM330D },
+	{ LSM330DL_ACCEL_DEV_NAME, LSM330DL },
+	{ LSM330DLC_ACCEL_DEV_NAME, LSM330DLC },
+	{ LIS331DLH_ACCEL_DEV_NAME, LIS331DLH },
+	{ LSM303DL_ACCEL_DEV_NAME, LSM303DL },
+	{ LSM303DLM_ACCEL_DEV_NAME, LSM303DLM },
+	{ LSM330_ACCEL_DEV_NAME, LSM330 },
+	{ LSM303AGR_ACCEL_DEV_NAME, LSM303AGR },
+	{ LIS2DH12_ACCEL_DEV_NAME, LIS2DH12 },
+	{ LIS3L02DQ_ACCEL_DEV_NAME, LIS3L02DQ },
+	{ LNG2DM_ACCEL_DEV_NAME, LNG2DM },
+	{},
+};
+MODULE_DEVICE_TABLE(i2c, st_accel_id_table);
+
 static int st_accel_i2c_probe(struct i2c_client *client,
 						const struct i2c_device_id *id)
 {
 	struct iio_dev *indio_dev;
 	struct st_sensor_data *adata;
-	int err;
+	int ret;
 
 	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*adata));
 	if (!indio_dev)
 		return -ENOMEM;
 
 	adata = iio_priv(indio_dev);
-	st_sensors_of_i2c_probe(client, st_accel_of_match);
+
+	if (client->dev.of_node) {
+		st_sensors_of_i2c_probe(client, st_accel_of_match);
+	} else if (ACPI_HANDLE(&client->dev)) {
+		ret = st_sensors_match_acpi_device(&client->dev);
+		if ((ret < 0) || (ret >= ST_ACCEL_MAX))
+			return -ENODEV;
+
+		strncpy(client->name, st_accel_id_table[ret].name,
+				sizeof(client->name));
+		client->name[sizeof(client->name) - 1] = '\0';
+	} else if (!id)
+		return -ENODEV;
+
 
 	st_sensors_i2c_configure(indio_dev, client, adata);
 
-	err = st_accel_common_probe(indio_dev);
-	if (err < 0)
-		return err;
+	ret = st_accel_common_probe(indio_dev);
+	if (ret < 0)
+		return ret;
 
 	return 0;
 }
@@ -125,29 +168,11 @@ static int st_accel_i2c_remove(struct i2c_client *client)
 	return 0;
 }
 
-static const struct i2c_device_id st_accel_id_table[] = {
-	{ LSM303DLH_ACCEL_DEV_NAME },
-	{ LSM303DLHC_ACCEL_DEV_NAME },
-	{ LIS3DH_ACCEL_DEV_NAME },
-	{ LSM330D_ACCEL_DEV_NAME },
-	{ LSM330DL_ACCEL_DEV_NAME },
-	{ LSM330DLC_ACCEL_DEV_NAME },
-	{ LIS331DLH_ACCEL_DEV_NAME },
-	{ LSM303DL_ACCEL_DEV_NAME },
-	{ LSM303DLM_ACCEL_DEV_NAME },
-	{ LSM330_ACCEL_DEV_NAME },
-	{ LSM303AGR_ACCEL_DEV_NAME },
-	{ LIS2DH12_ACCEL_DEV_NAME },
-	{ LIS3L02DQ_ACCEL_DEV_NAME },
-	{ LNG2DM_ACCEL_DEV_NAME },
-	{},
-};
-MODULE_DEVICE_TABLE(i2c, st_accel_id_table);
-
 static struct i2c_driver st_accel_driver = {
 	.driver = {
 		.name = "st-accel-i2c",
 		.of_match_table = of_match_ptr(st_accel_of_match),
+		.acpi_match_table = ACPI_PTR(st_accel_acpi_match),
 	},
 	.probe = st_accel_i2c_probe,
 	.remove = st_accel_i2c_remove,
-- 
2.9.3

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

* [PATCH 3/3] iio: st_pressure: Support i2c probe using acpi
  2016-11-24  5:33 [PATCH 0/3] iio: st_sensors: Support ACPI probe for st_sensors Shrirang Bagul
  2016-11-24  5:33 ` [PATCH 1/3] iio: st_sensors: match sensors using ACPI handle Shrirang Bagul
  2016-11-24  5:33 ` [PATCH 2/3] iio: st_accel: Support sensor i2c probe using acpi Shrirang Bagul
@ 2016-11-24  5:33 ` Shrirang Bagul
  2016-11-24 14:28   ` Linus Walleij
  2 siblings, 1 reply; 13+ messages in thread
From: Shrirang Bagul @ 2016-11-24  5:33 UTC (permalink / raw)
  To: jic23
  Cc: knaack.h, lars, pmeerw, denis.ciocca, tiberiu.a.breana,
	lorenzo.bianconi83, linus.walleij, gregor.boirie, linux-iio,
	linux-kernel, Shrirang Bagul

Compatible strings are not available on ACPI based systems. This patch adds
support to use DSDT information read from platform BIOS instead for probing
st pressure sensors.

Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
---
 drivers/iio/pressure/st_pressure.h     |  8 ++++++
 drivers/iio/pressure/st_pressure_i2c.c | 51 +++++++++++++++++++++++++---------
 2 files changed, 46 insertions(+), 13 deletions(-)

diff --git a/drivers/iio/pressure/st_pressure.h b/drivers/iio/pressure/st_pressure.h
index 903a21e..7d99593 100644
--- a/drivers/iio/pressure/st_pressure.h
+++ b/drivers/iio/pressure/st_pressure.h
@@ -14,6 +14,14 @@
 #include <linux/types.h>
 #include <linux/iio/common/st_sensors.h>
 
+enum st_press_type {
+	LPS001WP,
+	LPS25H,
+	LPS331AP,
+	LPS22HB,
+	ST_PRESS_MAX,
+};
+
 #define LPS001WP_PRESS_DEV_NAME		"lps001wp"
 #define LPS25H_PRESS_DEV_NAME		"lps25h"
 #define LPS331AP_PRESS_DEV_NAME		"lps331ap"
diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c
index ed18701..17417a4 100644
--- a/drivers/iio/pressure/st_pressure_i2c.c
+++ b/drivers/iio/pressure/st_pressure_i2c.c
@@ -11,6 +11,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/acpi.h>
 #include <linux/i2c.h>
 #include <linux/iio/iio.h>
 
@@ -43,25 +44,56 @@ MODULE_DEVICE_TABLE(of, st_press_of_match);
 #define st_press_of_match NULL
 #endif
 
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id st_press_acpi_match[] = {
+	{"SNO9210", LPS22HB},
+	{ },
+};
+MODULE_DEVICE_TABLE(acpi, st_press_acpi_match);
+#else
+#define st_press_acpi_match NULL
+#endif
+
+static const struct i2c_device_id st_press_id_table[] = {
+	{ LPS001WP_PRESS_DEV_NAME, LPS001WP },
+	{ LPS25H_PRESS_DEV_NAME,  LPS25H },
+	{ LPS331AP_PRESS_DEV_NAME, LPS331AP },
+	{ LPS22HB_PRESS_DEV_NAME, LPS22HB },
+	{},
+};
+MODULE_DEVICE_TABLE(i2c, st_press_id_table);
+
 static int st_press_i2c_probe(struct i2c_client *client,
 						const struct i2c_device_id *id)
 {
 	struct iio_dev *indio_dev;
 	struct st_sensor_data *press_data;
-	int err;
+	int ret;
 
 	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*press_data));
 	if (!indio_dev)
 		return -ENOMEM;
 
 	press_data = iio_priv(indio_dev);
-	st_sensors_of_i2c_probe(client, st_press_of_match);
+
+	if (client->dev.of_node) {
+		st_sensors_of_i2c_probe(client, st_press_of_match);
+	} else if (ACPI_HANDLE(&client->dev)) {
+		ret = st_sensors_match_acpi_device(&client->dev);
+		if ((ret < 0) || (ret >= ST_PRESS_MAX))
+			return -ENODEV;
+
+		strncpy(client->name, st_press_id_table[ret].name,
+				sizeof(client->name));
+		client->name[sizeof(client->name) - 1] = '\0';
+	} else if (!id)
+		return -ENODEV;
 
 	st_sensors_i2c_configure(indio_dev, client, press_data);
 
-	err = st_press_common_probe(indio_dev);
-	if (err < 0)
-		return err;
+	ret = st_press_common_probe(indio_dev);
+	if (ret < 0)
+		return ret;
 
 	return 0;
 }
@@ -73,18 +105,11 @@ static int st_press_i2c_remove(struct i2c_client *client)
 	return 0;
 }
 
-static const struct i2c_device_id st_press_id_table[] = {
-	{ LPS001WP_PRESS_DEV_NAME },
-	{ LPS25H_PRESS_DEV_NAME },
-	{ LPS331AP_PRESS_DEV_NAME },
-	{},
-};
-MODULE_DEVICE_TABLE(i2c, st_press_id_table);
-
 static struct i2c_driver st_press_driver = {
 	.driver = {
 		.name = "st-press-i2c",
 		.of_match_table = of_match_ptr(st_press_of_match),
+		.acpi_match_table = ACPI_PTR(st_press_acpi_match),
 	},
 	.probe = st_press_i2c_probe,
 	.remove = st_press_i2c_remove,
-- 
2.9.3

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

* Re: [PATCH 2/3] iio: st_accel: Support sensor i2c probe using acpi
  2016-11-24  5:33 ` [PATCH 2/3] iio: st_accel: Support sensor i2c probe using acpi Shrirang Bagul
@ 2016-11-24 14:26   ` Linus Walleij
  2016-11-27 11:14     ` Jonathan Cameron
  0 siblings, 1 reply; 13+ messages in thread
From: Linus Walleij @ 2016-11-24 14:26 UTC (permalink / raw)
  To: Shrirang Bagul
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, Denis CIOCCA, Tiberiu Breana, Lorenzo Bianconi,
	Gregor Boirie, linux-iio, linux-kernel

On Thu, Nov 24, 2016 at 6:33 AM, Shrirang Bagul
<shrirang.bagul@canonical.com> wrote:

> Add support to probe st_accel sensors on i2c bus using ACPI. Compatible
> strings are not avaialable on ACPI based systems.
>
> Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
(...)

> +#ifdef CONFIG_ACPI
> +static const struct acpi_device_id st_accel_acpi_match[] = {
> +       {"SMO8A90", LNG2DM},
> +       { },
> +};

Why is ACPI only supporting one out of 14 devices?

Surely there are some out-of-tree ACPI platforms using one
or more of the others?

Apart from that it looks nice.

Yours,
Linus Walleij

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

* Re: [PATCH 3/3] iio: st_pressure: Support i2c probe using acpi
  2016-11-24  5:33 ` [PATCH 3/3] iio: st_pressure: Support " Shrirang Bagul
@ 2016-11-24 14:28   ` Linus Walleij
  2016-11-27 11:12     ` Jonathan Cameron
  0 siblings, 1 reply; 13+ messages in thread
From: Linus Walleij @ 2016-11-24 14:28 UTC (permalink / raw)
  To: Shrirang Bagul
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, Denis CIOCCA, Tiberiu Breana, Lorenzo Bianconi,
	Gregor Boirie, linux-iio, linux-kernel

On Thu, Nov 24, 2016 at 6:33 AM, Shrirang Bagul
<shrirang.bagul@canonical.com> wrote:

> Compatible strings are not available on ACPI based systems. This patch adds
> support to use DSDT information read from platform BIOS instead for probing
> st pressure sensors.
>
> Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
(...)
> +#ifdef CONFIG_ACPI
> +static const struct acpi_device_id st_press_acpi_match[] = {
> +       {"SNO9210", LPS22HB},
> +       { },
> +};

Same comment. One sensor only supported by ACPI really?

Take a wider look.

Yours,
Linus Walleij

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

* Re: [PATCH 3/3] iio: st_pressure: Support i2c probe using acpi
  2016-11-24 14:28   ` Linus Walleij
@ 2016-11-27 11:12     ` Jonathan Cameron
  2016-11-29  4:25       ` Shrirang Bagul
  0 siblings, 1 reply; 13+ messages in thread
From: Jonathan Cameron @ 2016-11-27 11:12 UTC (permalink / raw)
  To: Linus Walleij, Shrirang Bagul
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald, Denis CIOCCA,
	Tiberiu Breana, Lorenzo Bianconi, Gregor Boirie, linux-iio,
	linux-kernel

On 24/11/16 14:28, Linus Walleij wrote:
> On Thu, Nov 24, 2016 at 6:33 AM, Shrirang Bagul
> <shrirang.bagul@canonical.com> wrote:
> 
>> Compatible strings are not available on ACPI based systems. This patch adds
>> support to use DSDT information read from platform BIOS instead for probing
>> st pressure sensors.
>>
>> Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
> (...)
>> +#ifdef CONFIG_ACPI
>> +static const struct acpi_device_id st_press_acpi_match[] = {
>> +       {"SNO9210", LPS22HB},
>> +       { },
>> +};
> 
> Same comment. One sensor only supported by ACPI really?
As demonstrated by this one, they are often registered under effectively random names!
Digging out those random names and associating them with a particular chip is always
going to be a non trivial job.

Hence I'm happy to take these as they stand.  We can add more entries when we come
across them.
> 
> Take a wider look.
Shirang has done a good job identifying this one and sending it upstream.
Be nice Linus and don't try to get him to do all the hard work ;)

As such applied to the togreg branch of iio.git. Will be pushed out as testing for
the autobuilders to play with it.

Note there will be some weeks before I push this out as togreg (given merge window
is about to open) so plenty of time for others to take a look!

Thanks,

Jonathan
> 
> Yours,
> Linus Walleij
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH 2/3] iio: st_accel: Support sensor i2c probe using acpi
  2016-11-24 14:26   ` Linus Walleij
@ 2016-11-27 11:14     ` Jonathan Cameron
  2016-11-29  4:27       ` Shrirang Bagul
  0 siblings, 1 reply; 13+ messages in thread
From: Jonathan Cameron @ 2016-11-27 11:14 UTC (permalink / raw)
  To: Linus Walleij, Shrirang Bagul
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald, Denis CIOCCA,
	Tiberiu Breana, Lorenzo Bianconi, Gregor Boirie, linux-iio,
	linux-kernel

On 24/11/16 14:26, Linus Walleij wrote:
> On Thu, Nov 24, 2016 at 6:33 AM, Shrirang Bagul
> <shrirang.bagul@canonical.com> wrote:
> 
>> Add support to probe st_accel sensors on i2c bus using ACPI. Compatible
>> strings are not avaialable on ACPI based systems.
>>
>> Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
> (...)
> 
>> +#ifdef CONFIG_ACPI
>> +static const struct acpi_device_id st_accel_acpi_match[] = {
>> +       {"SMO8A90", LNG2DM},
>> +       { },
>> +};
> 
> Why is ACPI only supporting one out of 14 devices?
> 
> Surely there are some out-of-tree ACPI platforms using one
> or more of the others?
> 
> Apart from that it looks nice.
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Anyone know where the ACPI names come from? Is there some big
list somewhere to prevent clashes?

Jonathan
> 
> Yours,
> Linus Walleij
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH 1/3] iio: st_sensors: match sensors using ACPI handle
  2016-11-24  5:33 ` [PATCH 1/3] iio: st_sensors: match sensors using ACPI handle Shrirang Bagul
@ 2016-11-27 11:15   ` Jonathan Cameron
  0 siblings, 0 replies; 13+ messages in thread
From: Jonathan Cameron @ 2016-11-27 11:15 UTC (permalink / raw)
  To: Shrirang Bagul
  Cc: knaack.h, lars, pmeerw, denis.ciocca, tiberiu.a.breana,
	lorenzo.bianconi83, linus.walleij, gregor.boirie, linux-iio,
	linux-kernel

On 24/11/16 05:33, Shrirang Bagul wrote:
> Add support to match st sensors using information passed from ACPI DST
> tables.
> 
> Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders
to play with it.

Presumably at somepoint this will need extending to cover the spi parts, but we 
can do that when it is relevant.

Thanks,

Jonathan
> ---
>  drivers/iio/common/st_sensors/st_sensors_i2c.c | 20 ++++++++++++++++++++
>  include/linux/iio/common/st_sensors_i2c.h      |  9 +++++++++
>  2 files changed, 29 insertions(+)
> 
> diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c
> index b43aa36..c83df4d 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_i2c.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c
> @@ -13,6 +13,7 @@
>  #include <linux/slab.h>
>  #include <linux/iio/iio.h>
>  #include <linux/of_device.h>
> +#include <linux/acpi.h>
>  
>  #include <linux/iio/common/st_sensors_i2c.h>
>  
> @@ -107,6 +108,25 @@ void st_sensors_of_i2c_probe(struct i2c_client *client,
>  EXPORT_SYMBOL(st_sensors_of_i2c_probe);
>  #endif
>  
> +#ifdef CONFIG_ACPI
> +int st_sensors_match_acpi_device(struct device *dev)
> +{
> +	const struct acpi_device_id *acpi_id;
> +	kernel_ulong_t driver_data = 0;
> +
> +	if (ACPI_HANDLE(dev)) {
> +		acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev);
> +		if (!acpi_id) {
> +			dev_err(dev, "No driver data\n");
> +			return -EINVAL;
> +		}
> +		driver_data = acpi_id->driver_data;
> +	}
> +	return driver_data;
> +}
> +EXPORT_SYMBOL(st_sensors_match_acpi_device);
> +#endif
> +
>  MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
>  MODULE_DESCRIPTION("STMicroelectronics ST-sensors i2c driver");
>  MODULE_LICENSE("GPL v2");
> diff --git a/include/linux/iio/common/st_sensors_i2c.h b/include/linux/iio/common/st_sensors_i2c.h
> index 1796af0..254de3c 100644
> --- a/include/linux/iio/common/st_sensors_i2c.h
> +++ b/include/linux/iio/common/st_sensors_i2c.h
> @@ -28,4 +28,13 @@ static inline void st_sensors_of_i2c_probe(struct i2c_client *client,
>  }
>  #endif
>  
> +#ifdef CONFIG_ACPI
> +int st_sensors_match_acpi_device(struct device *dev);
> +#else
> +static inline int st_sensors_match_acpi_device(struct device *dev)
> +{
> +	return -ENODEV;
> +}
> +#endif
> +
>  #endif /* ST_SENSORS_I2C_H */
> 

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

* Re: [PATCH 3/3] iio: st_pressure: Support i2c probe using acpi
  2016-11-27 11:12     ` Jonathan Cameron
@ 2016-11-29  4:25       ` Shrirang Bagul
  2016-11-30 13:04         ` Linus Walleij
  2016-11-30 17:20         ` Jonathan Cameron
  0 siblings, 2 replies; 13+ messages in thread
From: Shrirang Bagul @ 2016-11-29  4:25 UTC (permalink / raw)
  To: Jonathan Cameron, Linus Walleij
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald, Denis CIOCCA,
	Tiberiu Breana, Lorenzo Bianconi, Gregor Boirie, linux-iio,
	linux-kernel

On Sun, 2016-11-27 at 11:12 +0000, Jonathan Cameron wrote:
> On 24/11/16 14:28, Linus Walleij wrote:
> > On Thu, Nov 24, 2016 at 6:33 AM, Shrirang Bagul
> > <shrirang.bagul@canonical.com> wrote:
> > 
> > > Compatible strings are not available on ACPI based systems. This patch
> > > adds
> > > support to use DSDT information read from platform BIOS instead for
> > > probing
> > > st pressure sensors.
> > > 
> > > Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
> > 
> > (...)
> > > +#ifdef CONFIG_ACPI
> > > +static const struct acpi_device_id st_press_acpi_match[] = {
> > > +       {"SNO9210", LPS22HB},
> > > +       { },
> > > +};
> > 
> > Same comment. One sensor only supported by ACPI really?
> 
> As demonstrated by this one, they are often registered under effectively
> random names!
> Digging out those random names and associating them with a particular chip is
> always
> going to be a non trivial job.
> 
> Hence I'm happy to take these as they stand.  We can add more entries when we
> come
> across them.
> > 
> > Take a wider look.
Yes, I will.
> 
> Shirang has done a good job identifying this one and sending it upstream.
> Be nice Linus and don't try to get him to do all the hard work ;)
> 
> As such applied to the togreg branch of iio.git. Will be pushed out as testing
> for
> the autobuilders to play with it.
> 
> Note there will be some weeks before I push this out as togreg (given merge
> window
> is about to open) so plenty of time for others to take a look!
> 
> Thanks,
> 
> Jonathan
Thank you Jonathan. I'll follow-up on Linus's suggestion and try and identify
more of these sensors on some of the hardware we have in the lab. and try to add
support for some more devices.

Thanks,
Shrirang
> > 
> > Yours,
> > Linus Walleij
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> 
> 

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

* Re: [PATCH 2/3] iio: st_accel: Support sensor i2c probe using acpi
  2016-11-27 11:14     ` Jonathan Cameron
@ 2016-11-29  4:27       ` Shrirang Bagul
  0 siblings, 0 replies; 13+ messages in thread
From: Shrirang Bagul @ 2016-11-29  4:27 UTC (permalink / raw)
  To: Jonathan Cameron, Linus Walleij; +Cc: linux-iio, linux-kernel

On Sun, 2016-11-27 at 11:14 +0000, Jonathan Cameron wrote:
> On 24/11/16 14:26, Linus Walleij wrote:
> > On Thu, Nov 24, 2016 at 6:33 AM, Shrirang Bagul
> > <shrirang.bagul@canonical.com> wrote:
> > 
> > > Add support to probe st_accel sensors on i2c bus using ACPI. Compatible
> > > strings are not avaialable on ACPI based systems.
> > > 
> > > Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
> > 
> > (...)
> > 
> > > +#ifdef CONFIG_ACPI
> > > +static const struct acpi_device_id st_accel_acpi_match[] = {
> > > +       {"SMO8A90", LNG2DM},
> > > +       { },
> > > +};
> > 
> > Why is ACPI only supporting one out of 14 devices?
> > 
> > Surely there are some out-of-tree ACPI platforms using one
> > or more of the others?
> > 
> > Apart from that it looks nice.
> 
> Applied to the togreg branch of iio.git and pushed out as testing
> for the autobuilders to play with it.
> 
> Anyone know where the ACPI names come from? Is there some big
> list somewhere to prevent clashes?
> 
> Jonathan
I'll take a look at the HW in our lab and send patches to identify more st_accel
sensors used mostly on Dell laptops.

Shrirang
> > 
> > Yours,
> > Linus Walleij
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> 
> 

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

* Re: [PATCH 3/3] iio: st_pressure: Support i2c probe using acpi
  2016-11-29  4:25       ` Shrirang Bagul
@ 2016-11-30 13:04         ` Linus Walleij
  2016-11-30 17:20         ` Jonathan Cameron
  1 sibling, 0 replies; 13+ messages in thread
From: Linus Walleij @ 2016-11-30 13:04 UTC (permalink / raw)
  To: Shrirang Bagul
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, Denis CIOCCA, Tiberiu Breana, Lorenzo Bianconi,
	Gregor Boirie, linux-iio, linux-kernel

On Tue, Nov 29, 2016 at 5:25 AM, Shrirang Bagul
<shrirang.bagul@canonical.com> wrote:

> Thank you Jonathan. I'll follow-up on Linus's suggestion and try and identify
> more of these sensors on some of the hardware we have in the lab. and try to add
> support for some more devices.

Thanks Shrirang, appreciated!

Yours,
Linus Walleij

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

* Re: [PATCH 3/3] iio: st_pressure: Support i2c probe using acpi
  2016-11-29  4:25       ` Shrirang Bagul
  2016-11-30 13:04         ` Linus Walleij
@ 2016-11-30 17:20         ` Jonathan Cameron
  1 sibling, 0 replies; 13+ messages in thread
From: Jonathan Cameron @ 2016-11-30 17:20 UTC (permalink / raw)
  To: Shrirang Bagul, Jonathan Cameron, Linus Walleij
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald, Denis CIOCCA,
	Tiberiu Breana, Lorenzo Bianconi, Gregor Boirie, linux-iio,
	linux-kernel



On 29 November 2016 04:25:03 GMT+00:00, Shrirang Bagul <shrirang.bagul@canonical.com> wrote:
>On Sun, 2016-11-27 at 11:12 +0000, Jonathan Cameron wrote:
>> On 24/11/16 14:28, Linus Walleij wrote:
>> > On Thu, Nov 24, 2016 at 6:33 AM, Shrirang Bagul
>> > <shrirang.bagul@canonical.com> wrote:
>> > 
>> > > Compatible strings are not available on ACPI based systems. This
>patch
>> > > adds
>> > > support to use DSDT information read from platform BIOS instead
>for
>> > > probing
>> > > st pressure sensors.
>> > > 
>> > > Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
>> > 
>> > (...)
>> > > +#ifdef CONFIG_ACPI
>> > > +static const struct acpi_device_id st_press_acpi_match[] = {
>> > > +       {"SNO9210", LPS22HB},
>> > > +       { },
>> > > +};
>> > 
>> > Same comment. One sensor only supported by ACPI really?
>> 
>> As demonstrated by this one, they are often registered under
>effectively
>> random names!
>> Digging out those random names and associating them with a particular
>chip is
>> always
>> going to be a non trivial job.
>> 
>> Hence I'm happy to take these as they stand.  We can add more entries
>when we
>> come
>> across them.
>> > 
>> > Take a wider look.
>Yes, I will.
>> 
>> Shirang has done a good job identifying this one and sending it
>upstream.
>> Be nice Linus and don't try to get him to do all the hard work ;)
>> 
>> As such applied to the togreg branch of iio.git. Will be pushed out
>as testing
>> for
>> the autobuilders to play with it.
>> 
>> Note there will be some weeks before I push this out as togreg (given
>merge
>> window
>> is about to open) so plenty of time for others to take a look!
>> 
>> Thanks,
>> 
>> Jonathan
>Thank you Jonathan. I'll follow-up on Linus's suggestion and try and
>identify
>more of these sensors on some of the hardware we have in the lab. and
>try to add
>support for some more devices.
Great! Thanks for looking into this.

J
>
>Thanks,
>Shrirang
>> > 
>> > Yours,
>> > Linus Walleij
>> > --
>> > To unsubscribe from this list: send the line "unsubscribe
>linux-iio" in
>> > the body of a message to majordomo@vger.kernel.org
>> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> > 
>> 
>> 

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

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

end of thread, other threads:[~2016-11-30 17:21 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-24  5:33 [PATCH 0/3] iio: st_sensors: Support ACPI probe for st_sensors Shrirang Bagul
2016-11-24  5:33 ` [PATCH 1/3] iio: st_sensors: match sensors using ACPI handle Shrirang Bagul
2016-11-27 11:15   ` Jonathan Cameron
2016-11-24  5:33 ` [PATCH 2/3] iio: st_accel: Support sensor i2c probe using acpi Shrirang Bagul
2016-11-24 14:26   ` Linus Walleij
2016-11-27 11:14     ` Jonathan Cameron
2016-11-29  4:27       ` Shrirang Bagul
2016-11-24  5:33 ` [PATCH 3/3] iio: st_pressure: Support " Shrirang Bagul
2016-11-24 14:28   ` Linus Walleij
2016-11-27 11:12     ` Jonathan Cameron
2016-11-29  4:25       ` Shrirang Bagul
2016-11-30 13:04         ` Linus Walleij
2016-11-30 17:20         ` Jonathan Cameron

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).