From: Irina Tirdea <irina.tirdea@intel.com>
To: Jonathan Cameron <jic23@kernel.org>, linux-iio@vger.kernel.org
Cc: Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald <pmeerw@pmeerw.net>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
linux-kernel@vger.kernel.org, Denis CIOCCA <denis.ciocca@st.com>,
Irina Tirdea <irina.tirdea@intel.com>
Subject: [PATCH] iio: gyro: bmi055 gyro sensor driver
Date: Tue, 2 Sep 2014 13:59:57 +0300 [thread overview]
Message-ID: <1409655597-28781-1-git-send-email-irina.tirdea@intel.com> (raw)
Add support for the BMI055 gyroscope sensor. BMI055 is a package
consisting of an acceleration sensor and a gyroscope. This patch
adds support for the gyroscope only.
Spec downloaded from:
http://ae-bst.resource.bosch.com/media/products/dokumente/bmi055/BST-BMI055-DS000-06.pdf
The BMI055 gyroscope uses the same register definition as BMG160,
but does not specify a temp register. However, the temp register
seems to be working in the same way as for BMG160, so this patch
does not remove the temp channel for BMI055.
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/gyro/Kconfig | 2 +-
drivers/iio/gyro/bmg160.c | 39 +++++++++++++++++++++++++++------------
2 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/drivers/iio/gyro/Kconfig b/drivers/iio/gyro/Kconfig
index d630ae9..b3d0e94 100644
--- a/drivers/iio/gyro/Kconfig
+++ b/drivers/iio/gyro/Kconfig
@@ -56,7 +56,7 @@ config BMG160
select IIO_TRIGGERED_BUFFER if IIO_BUFFER
help
Say yes here to build support for Bosch BMG160 Tri-axis Gyro Sensor
- driver.
+ driver. This driver also supports BMI055 gyroscope.
This driver can also be built as a module. If so, the module
will be called bmg160.
diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160.c
index 80f92a6..7524698 100644
--- a/drivers/iio/gyro/bmg160.c
+++ b/drivers/iio/gyro/bmg160.c
@@ -947,10 +947,10 @@ static irqreturn_t bmg160_data_rdy_trig_poll(int irq, void *private)
}
-static int bmg160_acpi_gpio_probe(struct i2c_client *client,
- struct bmg160_data *data)
+static int bmg160_gpio_probe(struct i2c_client *client,
+ struct bmg160_data *data)
+
{
- const struct acpi_device_id *id;
struct device *dev;
struct gpio_desc *gpio;
int ret;
@@ -959,12 +959,6 @@ static int bmg160_acpi_gpio_probe(struct i2c_client *client,
return -EINVAL;
dev = &client->dev;
- if (!ACPI_HANDLE(dev))
- return -ENODEV;
-
- id = acpi_match_device(dev->driver->acpi_match_table, dev);
- if (!id)
- return -ENODEV;
/* data ready gpio interrupt pin */
gpio = devm_gpiod_get_index(dev, BMG160_GPIO_NAME, 0);
@@ -984,12 +978,24 @@ static int bmg160_acpi_gpio_probe(struct i2c_client *client,
return ret;
}
+static const char *bmg160_match_acpi_device(struct device *dev)
+{
+ const struct acpi_device_id *id;
+
+ id = acpi_match_device(dev->driver->acpi_match_table, dev);
+ if (!id)
+ return NULL;
+
+ return dev_name(dev);
+}
+
static int bmg160_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct bmg160_data *data;
struct iio_dev *indio_dev;
int ret;
+ const char *name = NULL;
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
if (!indio_dev)
@@ -1005,15 +1011,21 @@ static int bmg160_probe(struct i2c_client *client,
mutex_init(&data->mutex);
+ if (id)
+ name = id->name;
+
+ if (ACPI_HANDLE(&client->dev))
+ name = bmg160_match_acpi_device(&client->dev);
+
indio_dev->dev.parent = &client->dev;
indio_dev->channels = bmg160_channels;
indio_dev->num_channels = ARRAY_SIZE(bmg160_channels);
- indio_dev->name = BMG160_DRV_NAME;
+ indio_dev->name = name;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &bmg160_info;
if (client->irq <= 0)
- client->irq = bmg160_acpi_gpio_probe(client, data);
+ client->irq = bmg160_gpio_probe(client, data);
if (client->irq > 0) {
ret = devm_request_threaded_irq(&client->dev,
@@ -1183,12 +1195,15 @@ static const struct dev_pm_ops bmg160_pm_ops = {
static const struct acpi_device_id bmg160_acpi_match[] = {
{"BMG0160", 0},
- { },
+ {"BMI055B", 0},
+ {},
};
+
MODULE_DEVICE_TABLE(acpi, bmg160_acpi_match);
static const struct i2c_device_id bmg160_id[] = {
{"bmg160", 0},
+ {"bmi055_gyro", 0},
{}
};
--
1.7.9.5
next reply other threads:[~2014-09-02 10:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-02 10:59 Irina Tirdea [this message]
2014-09-14 17:42 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1409655597-28781-1-git-send-email-irina.tirdea@intel.com \
--to=irina.tirdea@intel.com \
--cc=denis.ciocca@st.com \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
--cc=srinivas.pandruvada@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®