[PATCH 0/3][Xenial SRU]UBUNTU: SAUCE: Add ACPI probe support for ST

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 0/3][Xenial SRU]UBUNTU: SAUCE: Add ACPI probe support for ST

Shrirang Bagul
BugLink: http://bugs.launchpad.net/bugs/1650123

Dell Caracalla Edge gateway is an ACPI based system, there are no
compatible strings from DT to match and probe corresponding drivers. Add
support use of unique identifiers provided by ACPI for ST Micro IIO drivers
(accelerometers and pressure sensors) instead.

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                   | 19 +++++++
 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, 143 insertions(+), 37 deletions(-)

--
2.9.3


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/3][Xenial SRU]UBUNTU: SAUCE: iio: st_sensors: match sensors using ACPI handle

Shrirang Bagul
BugLink: http://bugs.launchpad.net/bugs/1650123

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

Signed-off-by: Shrirang Bagul <[hidden email]>
Signed-off-by: Jonathan Cameron <[hidden email]>
(cherry picked from commit 3dc59262f76241b342316bbac8b5ffe138995b2d)
(source: git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git)
Signed-off-by: Shrirang Bagul <[hidden email]>
---
 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 98cfee29..63e573c 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 <[hidden email]>");
 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


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 2/3][Xenial SRU]UBUNTU: SAUCE: iio: st_accel: Support sensor i2c probe using acpi

Shrirang Bagul
In reply to this post by Shrirang Bagul
BugLink: http://bugs.launchpad.net/bugs/1650123

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 <[hidden email]>
Signed-off-by: Jonathan Cameron <[hidden email]>
(cherry picked from commit 89a2a93f3bf1e0d3168d454fe7fa207be981cb83)
(source: git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git)
Signed-off-by: Shrirang Bagul <[hidden email]>
---
 drivers/iio/accel/st_accel.h     | 19 +++++++++++
 drivers/iio/accel/st_accel_i2c.c | 73 +++++++++++++++++++++++++++-------------
 2 files changed, 68 insertions(+), 24 deletions(-)

diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
index 25ea008..3ad44ce 100644
--- a/drivers/iio/accel/st_accel.h
+++ b/drivers/iio/accel/st_accel.h
@@ -14,6 +14,25 @@
 #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"
 #define LIS3DH_ACCEL_DEV_NAME "lis3dh"
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


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 3/3][Xenial SRU]UBUNTU: SAUCE: iio: st_pressure: Support i2c probe using acpi

Shrirang Bagul
In reply to this post by Shrirang Bagul
BugLink: http://bugs.launchpad.net/bugs/1650123

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 <[hidden email]>
Signed-off-by: Jonathan Cameron <[hidden email]>
(cherry picked from commit 9d317724cfeb9b64acf57028183e307bea39e4e6)
(source: git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git)
Signed-off-by: Shrirang Bagul <[hidden email]>
---
 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..7d995937 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


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

NAK: [PATCH 0/3][Xenial SRU]UBUNTU: SAUCE: Add ACPI probe support for ST

Tim Gardner-2
In reply to this post by Shrirang Bagul
Resend when these patches have at least made it into linux-next.

--
Tim Gardner [hidden email]

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Re: NAK: [PATCH 0/3][Xenial SRU]UBUNTU: SAUCE: Add ACPI probe support for ST

Shrirang Bagul
These patches have been reviewed and merged into the maintainers tree.
Would prefer to wait till they make it to linux-next; but, these patches
are necessary if we are to support the accelerometer and pressure sensor on Dell
Caracalla Edge IoT Gateways. These systems are supposed to start shipping with a
signed Ubuntu Xenial kernel in the 2nd week of Jan 2017.
Looks like we are at an impasse here, what is the best course of action to be
followed in this situation?

On Thu, 2016-12-15 at 07:36 -0700, Tim Gardner wrote:
> Resend when these patches have at least made it into linux-next.
>

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK: [PATCH 0/3][Xenial SRU]UBUNTU: SAUCE: Add ACPI probe support for ST

Tim Gardner-2
On 12/15/2016 09:35 PM, Shrirang Bagul wrote:

> These patches have been reviewed and merged into the maintainers tree.
> Would prefer to wait till they make it to linux-next; but, these patches
> are necessary if we are to support the accelerometer and pressure sensor on Dell
> Caracalla Edge IoT Gateways. These systems are supposed to start shipping with a
> signed Ubuntu Xenial kernel in the 2nd week of Jan 2017.
> Looks like we are at an impasse here, what is the best course of action to be
> followed in this situation?
>
> On Thu, 2016-12-15 at 07:36 -0700, Tim Gardner wrote:
>> Resend when these patches have at least made it into linux-next.
>>

OK, these seem pretty low risk.
--
Tim Gardner [hidden email]

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

NAK: [PATCH 2/3][Xenial SRU]UBUNTU: SAUCE: iio: st_accel: Support sensor i2c probe using acpi

Luis Henriques
In reply to this post by Shrirang Bagul
On Thu, Dec 15, 2016 at 06:18:33PM +0800, Shrirang Bagul wrote:
> BugLink: http://bugs.launchpad.net/bugs/1650123
>
> Add support to probe st_accel sensors on i2c bus using ACPI. Compatible
> strings are not avaialable on ACPI based systems.
>

This patch does not apply.  Please re-submit.  And note that SRU cycle
*has* already started, so please make sure you submit it quickly!

Cheers,
--
Luís


> Signed-off-by: Shrirang Bagul <[hidden email]>
> Signed-off-by: Jonathan Cameron <[hidden email]>
> (cherry picked from commit 89a2a93f3bf1e0d3168d454fe7fa207be981cb83)
> (source: git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git)
> Signed-off-by: Shrirang Bagul <[hidden email]>
> ---
>  drivers/iio/accel/st_accel.h     | 19 +++++++++++
>  drivers/iio/accel/st_accel_i2c.c | 73 +++++++++++++++++++++++++++-------------
>  2 files changed, 68 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
> index 25ea008..3ad44ce 100644
> --- a/drivers/iio/accel/st_accel.h
> +++ b/drivers/iio/accel/st_accel.h
> @@ -14,6 +14,25 @@
>  #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"
>  #define LIS3DH_ACCEL_DEV_NAME "lis3dh"
> 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
>
>
> --
> kernel-team mailing list
> [hidden email]
> https://lists.ubuntu.com/mailman/listinfo/kernel-team

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

UBUNTU: SAUCE: Add ACPI probe support for ST (V2)

Tim Gardner-2
Fixed up Patch 2 as it would not apply. Possibly a consequence of patch grouping
and order of application. Also added configs for these new sensors.

rtg

[PATCH 1/4] UBUNTU: SAUCE: iio: st_sensors: match sensors using ACPI
[PATCH 2/4] UBUNTU: SAUCE: iio: st_accel: Support sensor i2c probe
[PATCH 3/4] UBUNTU: SAUCE: iio: st_pressure: Support i2c probe using
[PATCH 4/4] UBUNTU: [Config] CONFIG_HTS221=m, CONFIG_HTS221_I2C=m,

rtg


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/4] UBUNTU: SAUCE: iio: st_sensors: match sensors using ACPI handle

Tim Gardner-2
From: Shrirang Bagul <[hidden email]>

BugLink: http://bugs.launchpad.net/bugs/1650123

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

Signed-off-by: Shrirang Bagul <[hidden email]>
Signed-off-by: Jonathan Cameron <[hidden email]>
(cherry picked from commit 3dc59262f76241b342316bbac8b5ffe138995b2d)
(source: git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git)
Signed-off-by: Shrirang Bagul <[hidden email]>
Signed-off-by: Tim Gardner <[hidden email]>
---
 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 98cfee29..63e573c 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 <[hidden email]>");
 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.7.4


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 2/4] UBUNTU: SAUCE: iio: st_accel: Support sensor i2c probe using acpi

Tim Gardner-2
In reply to this post by Tim Gardner-2
BugLink: http://bugs.launchpad.net/bugs/1650123

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 <[hidden email]>
Signed-off-by: Jonathan Cameron <[hidden email]>
(cherry picked from commit 89a2a93f3bf1e0d3168d454fe7fa207be981cb83)
(source: git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git)
Signed-off-by: Shrirang Bagul <[hidden email]>
Signed-off-by: Tim Gardner <[hidden email]>
---
 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.7.4


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 3/4] UBUNTU: SAUCE: iio: st_pressure: Support i2c probe using acpi

Tim Gardner-2
In reply to this post by Tim Gardner-2
From: Shrirang Bagul <[hidden email]>

BugLink: http://bugs.launchpad.net/bugs/1650123

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 <[hidden email]>
Signed-off-by: Jonathan Cameron <[hidden email]>
(cherry picked from commit 9d317724cfeb9b64acf57028183e307bea39e4e6)
(source: git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git)
Signed-off-by: Shrirang Bagul <[hidden email]>
Signed-off-by: Tim Gardner <[hidden email]>
---
 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.7.4


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 4/4] UBUNTU: [Config] CONFIG_HTS221=m, CONFIG_HTS221_I2C=m, CONFIG_HTS221_SPI=m

Tim Gardner-2
In reply to this post by Tim Gardner-2
BugLink: http://bugs.launchpad.net/bugs/1650123

Signed-off-by: Tim Gardner <[hidden email]>
---
 debian.master/config/config.common.ubuntu | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/debian.master/config/config.common.ubuntu b/debian.master/config/config.common.ubuntu
index 81cf556..4d8dd32 100644
--- a/debian.master/config/config.common.ubuntu
+++ b/debian.master/config/config.common.ubuntu
@@ -3154,6 +3154,9 @@ CONFIG_HSU_DMA=m
 CONFIG_HSU_DMA_PCI=m
 CONFIG_HTC_EGPIO=y
 CONFIG_HTC_I2CPLD=y
+CONFIG_HTS221=m
+CONFIG_HTS221_I2C=m
+CONFIG_HTS221_SPI=m
 CONFIG_HTU21=m
 CONFIG_HT_IRQ=y
 CONFIG_HUGETLBFS=y
--
2.7.4


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK && APPLIED: UBUNTU: SAUCE: Add ACPI probe support for ST (V2)

Luis Henriques
In reply to this post by Tim Gardner-2
Applied to xenial master-next branch.

Cheers,
--
Luís

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team

signature.asc (836 bytes) Download Attachment