aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/gyro/bmg160.c
diff options
context:
space:
mode:
authorIrina Tirdea <irina.tirdea@intel.com>2014-02-09 06:59:00 -0500
committerJonathan Cameron <jic23@kernel.org>2014-09-14 13:40:42 -0400
commit3a0888edcffd9406f1cbbe240f4533e35db67e81 (patch)
treed5771be76c81b68ecfa4e14f93cda3fb5735fbe2 /drivers/iio/gyro/bmg160.c
parentc9bf2373da2144dec511503cebf5f8a63b0dcff3 (diff)
iio: gyro: bmi055 gyro sensor driver
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> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/gyro/bmg160.c')
-rw-r--r--drivers/iio/gyro/bmg160.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160.c
index 99acf361aa53..1f967e0d688e 100644
--- a/drivers/iio/gyro/bmg160.c
+++ b/drivers/iio/gyro/bmg160.c
@@ -949,10 +949,10 @@ static irqreturn_t bmg160_data_rdy_trig_poll(int irq, void *private)
949 949
950} 950}
951 951
952static int bmg160_acpi_gpio_probe(struct i2c_client *client, 952static int bmg160_gpio_probe(struct i2c_client *client,
953 struct bmg160_data *data) 953 struct bmg160_data *data)
954
954{ 955{
955 const struct acpi_device_id *id;
956 struct device *dev; 956 struct device *dev;
957 struct gpio_desc *gpio; 957 struct gpio_desc *gpio;
958 int ret; 958 int ret;
@@ -961,12 +961,6 @@ static int bmg160_acpi_gpio_probe(struct i2c_client *client,
961 return -EINVAL; 961 return -EINVAL;
962 962
963 dev = &client->dev; 963 dev = &client->dev;
964 if (!ACPI_HANDLE(dev))
965 return -ENODEV;
966
967 id = acpi_match_device(dev->driver->acpi_match_table, dev);
968 if (!id)
969 return -ENODEV;
970 964
971 /* data ready gpio interrupt pin */ 965 /* data ready gpio interrupt pin */
972 gpio = devm_gpiod_get_index(dev, BMG160_GPIO_NAME, 0); 966 gpio = devm_gpiod_get_index(dev, BMG160_GPIO_NAME, 0);
@@ -986,12 +980,24 @@ static int bmg160_acpi_gpio_probe(struct i2c_client *client,
986 return ret; 980 return ret;
987} 981}
988 982
983static const char *bmg160_match_acpi_device(struct device *dev)
984{
985 const struct acpi_device_id *id;
986
987 id = acpi_match_device(dev->driver->acpi_match_table, dev);
988 if (!id)
989 return NULL;
990
991 return dev_name(dev);
992}
993
989static int bmg160_probe(struct i2c_client *client, 994static int bmg160_probe(struct i2c_client *client,
990 const struct i2c_device_id *id) 995 const struct i2c_device_id *id)
991{ 996{
992 struct bmg160_data *data; 997 struct bmg160_data *data;
993 struct iio_dev *indio_dev; 998 struct iio_dev *indio_dev;
994 int ret; 999 int ret;
1000 const char *name = NULL;
995 1001
996 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); 1002 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
997 if (!indio_dev) 1003 if (!indio_dev)
@@ -1007,15 +1013,21 @@ static int bmg160_probe(struct i2c_client *client,
1007 1013
1008 mutex_init(&data->mutex); 1014 mutex_init(&data->mutex);
1009 1015
1016 if (id)
1017 name = id->name;
1018
1019 if (ACPI_HANDLE(&client->dev))
1020 name = bmg160_match_acpi_device(&client->dev);
1021
1010 indio_dev->dev.parent = &client->dev; 1022 indio_dev->dev.parent = &client->dev;
1011 indio_dev->channels = bmg160_channels; 1023 indio_dev->channels = bmg160_channels;
1012 indio_dev->num_channels = ARRAY_SIZE(bmg160_channels); 1024 indio_dev->num_channels = ARRAY_SIZE(bmg160_channels);
1013 indio_dev->name = BMG160_DRV_NAME; 1025 indio_dev->name = name;
1014 indio_dev->modes = INDIO_DIRECT_MODE; 1026 indio_dev->modes = INDIO_DIRECT_MODE;
1015 indio_dev->info = &bmg160_info; 1027 indio_dev->info = &bmg160_info;
1016 1028
1017 if (client->irq <= 0) 1029 if (client->irq <= 0)
1018 client->irq = bmg160_acpi_gpio_probe(client, data); 1030 client->irq = bmg160_gpio_probe(client, data);
1019 1031
1020 if (client->irq > 0) { 1032 if (client->irq > 0) {
1021 ret = devm_request_threaded_irq(&client->dev, 1033 ret = devm_request_threaded_irq(&client->dev,
@@ -1185,12 +1197,15 @@ static const struct dev_pm_ops bmg160_pm_ops = {
1185 1197
1186static const struct acpi_device_id bmg160_acpi_match[] = { 1198static const struct acpi_device_id bmg160_acpi_match[] = {
1187 {"BMG0160", 0}, 1199 {"BMG0160", 0},
1188 { }, 1200 {"BMI055B", 0},
1201 {},
1189}; 1202};
1203
1190MODULE_DEVICE_TABLE(acpi, bmg160_acpi_match); 1204MODULE_DEVICE_TABLE(acpi, bmg160_acpi_match);
1191 1205
1192static const struct i2c_device_id bmg160_id[] = { 1206static const struct i2c_device_id bmg160_id[] = {
1193 {"bmg160", 0}, 1207 {"bmg160", 0},
1208 {"bmi055_gyro", 0},
1194 {} 1209 {}
1195}; 1210};
1196 1211