* [PATCH] iio: accel: bma180: Add ACPI enumeration support
@ 2017-04-21 7:38 Hans de Goede
2017-04-26 6:40 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Hans de Goede @ 2017-04-21 7:38 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Hans de Goede, linux-acpi, Lars-Peter Clausen,
Peter Meerwald-Stadler, linux-iio
Some x86 tablets use the bms250 accelerometer, add support for this.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/iio/accel/bma180.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
index 0890934..5c75190 100644
--- a/drivers/iio/accel/bma180.c
+++ b/drivers/iio/accel/bma180.c
@@ -14,6 +14,7 @@
* BMA250: 7-bit I2C slave address 0x18 or 0x19
*/
+#include <linux/acpi.h>
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
@@ -705,6 +706,8 @@ static const struct iio_trigger_ops bma180_trigger_ops = {
static int bma180_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
+ struct device *dev = &client->dev;
+ const struct acpi_device_id *acpi_id;
struct bma180_data *data;
struct iio_dev *indio_dev;
int ret;
@@ -716,7 +719,15 @@ static int bma180_probe(struct i2c_client *client,
data = iio_priv(indio_dev);
i2c_set_clientdata(client, indio_dev);
data->client = client;
- data->part_info = &bma180_part_info[id->driver_data];
+ if (id) {
+ data->part_info = &bma180_part_info[id->driver_data];
+ } else {
+ acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev);
+ if (!acpi_id)
+ return -ENODEV;
+
+ data->part_info = &bma180_part_info[acpi_id->driver_data];
+ }
ret = data->part_info->chip_config(data);
if (ret < 0)
@@ -836,6 +847,12 @@ static SIMPLE_DEV_PM_OPS(bma180_pm_ops, bma180_suspend, bma180_resume);
#define BMA180_PM_OPS NULL
#endif
+static const struct acpi_device_id bma180_acpi_match[] = {
+ { "BMA250E", BMA250 },
+ { }
+};
+MODULE_DEVICE_TABLE(acpi, bma180_acpi_match);
+
static struct i2c_device_id bma180_ids[] = {
{ "bma180", BMA180 },
{ "bma250", BMA250 },
@@ -847,6 +864,7 @@ MODULE_DEVICE_TABLE(i2c, bma180_ids);
static struct i2c_driver bma180_driver = {
.driver = {
.name = "bma180",
+ .acpi_match_table = ACPI_PTR(bma180_acpi_match),
.pm = BMA180_PM_OPS,
},
.probe = bma180_probe,
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: accel: bma180: Add ACPI enumeration support
2017-04-21 7:38 [PATCH] iio: accel: bma180: Add ACPI enumeration support Hans de Goede
@ 2017-04-26 6:40 ` Jonathan Cameron
2017-05-16 8:09 ` Hans de Goede
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2017-04-26 6:40 UTC (permalink / raw)
To: Hans de Goede
Cc: linux-acpi, Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio
On 21/04/17 08:38, Hans de Goede wrote:
> Some x86 tablets use the bms250 accelerometer, add support for this.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Hi Hans,
Would you mind rebasing this on the latest iio.git togreg branch?
(which should be the same as linux-next by now if that is easier)
Some OF bindings got added in the recent cycle that make it not
apply cleanly.
Thanks,
Jonathan
> ---
> drivers/iio/accel/bma180.c | 20 +++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
> index 0890934..5c75190 100644
> --- a/drivers/iio/accel/bma180.c
> +++ b/drivers/iio/accel/bma180.c
> @@ -14,6 +14,7 @@
> * BMA250: 7-bit I2C slave address 0x18 or 0x19
> */
>
> +#include <linux/acpi.h>
> #include <linux/module.h>
> #include <linux/i2c.h>
> #include <linux/interrupt.h>
> @@ -705,6 +706,8 @@ static const struct iio_trigger_ops bma180_trigger_ops = {
> static int bma180_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> + struct device *dev = &client->dev;
> + const struct acpi_device_id *acpi_id;
> struct bma180_data *data;
> struct iio_dev *indio_dev;
> int ret;
> @@ -716,7 +719,15 @@ static int bma180_probe(struct i2c_client *client,
> data = iio_priv(indio_dev);
> i2c_set_clientdata(client, indio_dev);
> data->client = client;
> - data->part_info = &bma180_part_info[id->driver_data];
> + if (id) {
> + data->part_info = &bma180_part_info[id->driver_data];
> + } else {
> + acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev);
> + if (!acpi_id)
> + return -ENODEV;
> +
> + data->part_info = &bma180_part_info[acpi_id->driver_data];
> + }
>
> ret = data->part_info->chip_config(data);
> if (ret < 0)
> @@ -836,6 +847,12 @@ static SIMPLE_DEV_PM_OPS(bma180_pm_ops, bma180_suspend, bma180_resume);
> #define BMA180_PM_OPS NULL
> #endif
>
> +static const struct acpi_device_id bma180_acpi_match[] = {
> + { "BMA250E", BMA250 },
> + { }
> +};
> +MODULE_DEVICE_TABLE(acpi, bma180_acpi_match);
> +
> static struct i2c_device_id bma180_ids[] = {
> { "bma180", BMA180 },
> { "bma250", BMA250 },
> @@ -847,6 +864,7 @@ MODULE_DEVICE_TABLE(i2c, bma180_ids);
> static struct i2c_driver bma180_driver = {
> .driver = {
> .name = "bma180",
> + .acpi_match_table = ACPI_PTR(bma180_acpi_match),
> .pm = BMA180_PM_OPS,
> },
> .probe = bma180_probe,
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: accel: bma180: Add ACPI enumeration support
2017-04-26 6:40 ` Jonathan Cameron
@ 2017-05-16 8:09 ` Hans de Goede
0 siblings, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2017-05-16 8:09 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-acpi, Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio
Hi,
On 26-04-17 08:40, Jonathan Cameron wrote:
> On 21/04/17 08:38, Hans de Goede wrote:
>> Some x86 tablets use the bms250 accelerometer, add support for this.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> Hi Hans,
>
> Would you mind rebasing this on the latest iio.git togreg branch?
> (which should be the same as linux-next by now if that is easier)
> Some OF bindings got added in the recent cycle that make it not
> apply cleanly.
Sure I can rebase,, actually I just tested a rebased version and noticed:
[ 20.705333] bma180 i2c-BMA250E:00: failed to config the chip
Which is because the BMA250E and BMA250 are not the same chip
as I thought. So v2 is going to be 2 patches one to add support
for the BMA250E (it is compatible but reports a different chip-id)
and another one actually adding the ACPI enumeration support
for it.
Regards,
Hans
>
> Thanks,
>
> Jonathan
>> ---
>> drivers/iio/accel/bma180.c | 20 +++++++++++++++++++-
>> 1 file changed, 19 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
>> index 0890934..5c75190 100644
>> --- a/drivers/iio/accel/bma180.c
>> +++ b/drivers/iio/accel/bma180.c
>> @@ -14,6 +14,7 @@
>> * BMA250: 7-bit I2C slave address 0x18 or 0x19
>> */
>>
>> +#include <linux/acpi.h>
>> #include <linux/module.h>
>> #include <linux/i2c.h>
>> #include <linux/interrupt.h>
>> @@ -705,6 +706,8 @@ static const struct iio_trigger_ops bma180_trigger_ops = {
>> static int bma180_probe(struct i2c_client *client,
>> const struct i2c_device_id *id)
>> {
>> + struct device *dev = &client->dev;
>> + const struct acpi_device_id *acpi_id;
>> struct bma180_data *data;
>> struct iio_dev *indio_dev;
>> int ret;
>> @@ -716,7 +719,15 @@ static int bma180_probe(struct i2c_client *client,
>> data = iio_priv(indio_dev);
>> i2c_set_clientdata(client, indio_dev);
>> data->client = client;
>> - data->part_info = &bma180_part_info[id->driver_data];
>> + if (id) {
>> + data->part_info = &bma180_part_info[id->driver_data];
>> + } else {
>> + acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev);
>> + if (!acpi_id)
>> + return -ENODEV;
>> +
>> + data->part_info = &bma180_part_info[acpi_id->driver_data];
>> + }
>>
>> ret = data->part_info->chip_config(data);
>> if (ret < 0)
>> @@ -836,6 +847,12 @@ static SIMPLE_DEV_PM_OPS(bma180_pm_ops, bma180_suspend, bma180_resume);
>> #define BMA180_PM_OPS NULL
>> #endif
>>
>> +static const struct acpi_device_id bma180_acpi_match[] = {
>> + { "BMA250E", BMA250 },
>> + { }
>> +};
>> +MODULE_DEVICE_TABLE(acpi, bma180_acpi_match);
>> +
>> static struct i2c_device_id bma180_ids[] = {
>> { "bma180", BMA180 },
>> { "bma250", BMA250 },
>> @@ -847,6 +864,7 @@ MODULE_DEVICE_TABLE(i2c, bma180_ids);
>> static struct i2c_driver bma180_driver = {
>> .driver = {
>> .name = "bma180",
>> + .acpi_match_table = ACPI_PTR(bma180_acpi_match),
>> .pm = BMA180_PM_OPS,
>> },
>> .probe = bma180_probe,
>>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-16 8:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-21 7:38 [PATCH] iio: accel: bma180: Add ACPI enumeration support Hans de Goede
2017-04-26 6:40 ` Jonathan Cameron
2017-05-16 8:09 ` Hans de Goede
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.