Skip to contentSkip to conversation

iio: imu: Add initial support for Bosch BMI160

PATCH Superseded Daniel Baluta 2 participants 2 messages Apr 5, 2016 – Apr 6, 2016 IIO

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 iio: imu: Add initial support for Bosch BMI160

BMI160 is an Inertial Measurement Unit (IMU) which provides acceleration and angular rate measurement. It also offers a secondary I2C interface for connecting a magnetometer sensor (usually BMM160).

Current driver offers support for accelerometer and gyroscope readings via sysfs or via buffer interface using an external trigger (e.g. hrtimer). Data is retrieved from IMU via I2C or SPI interface.

Datasheet is at:

	http://www.mouser.com/ds/2/783/BST-BMI160-DS000-07-786474.pdf

---
Changes since v1:
* addressed comments from Jonathan and Peter
* fixed Kconfig spelling
* shared bmi160_regmap_config between i2c and spi modules
* clarify timeouts unit (useconds)
* use sizeof(_le16) consistently
* 1 -> true
* clarify documentation references to datasheet

 drivers/iio/imu/Kconfig              |   2 +
 drivers/iio/imu/Makefile             |   1 +
 drivers/iio/imu/bmi160/Kconfig       |  32 ++
 drivers/iio/imu/bmi160/Makefile      |   6 +
 drivers/iio/imu/bmi160/bmi160.h      |  10 +
 drivers/iio/imu/bmi160/bmi160_core.c | 594 +++++++++++++++++++++++++++++++++++
 drivers/iio/imu/bmi160/bmi160_i2c.c  |  71 +++++
 drivers/iio/imu/bmi160/bmi160_spi.c  |  62 ++++
 8 files changed, 778 insertions(+)
 create mode 100644 drivers/iio/imu/bmi160/Kconfig
 create mode 100644 drivers/iio/imu/bmi160/Makefile
 create mode 100644 drivers/iio/imu/bmi160/bmi160.h
 create mode 100644 drivers/iio/imu/bmi160/bmi160_core.c
 create mode 100644 drivers/iio/imu/bmi160/bmi160_i2c.c
 create mode 100644 drivers/iio/imu/bmi160/bmi160_spi.c
drivers/iio/imu/Kconfig +2 -0
index 5e610f7..1f1ad41 100644
@@ -25,6 +25,8 @@ config ADIS16480
 	  Say yes here to build support for Analog Devices ADIS16375, ADIS16480,
 	  ADIS16485, ADIS16488 inertial sensors.
 
+source "drivers/iio/imu/bmi160/Kconfig"
+
 config KMX61
 	tristate "Kionix KMX61 6-axis accelerometer and magnetometer"
 	depends on I2C
drivers/iio/imu/Makefile +1 -0
index e1e6e3d..c71bcd3 100644
@@ -13,6 +13,7 @@ adis_lib-$(CONFIG_IIO_ADIS_LIB_BUFFER) += adis_trigger.o
 adis_lib-$(CONFIG_IIO_ADIS_LIB_BUFFER) += adis_buffer.o
 obj-$(CONFIG_IIO_ADIS_LIB) += adis_lib.o
 
+obj-y += bmi160/
 obj-y += inv_mpu6050/
 
 obj-$(CONFIG_KMX61) += kmx61.o
drivers/iio/imu/bmi160/Kconfig new file +32 -0
new file mode 100644
index 0000000..005c17c
@@ -0,0 +1,32 @@
+#
+# BMI160 IMU driver
+#
+
+config BMI160
+	tristate
+	select IIO_BUFFER
+	select IIO_TRIGGERED_BUFFER
+
+config BMI160_I2C
+	tristate "Bosch BMI160 I2C driver"
+	depends on I2C
+	select BMI160
+	select REGMAP_I2C
+	help
+	  If you say yes here you get support for BMI160 IMU on I2C with
+	  accelerometer, gyroscope and external BMG160 magnetometer.
+
+	  This driver can also be built as a module. If so, the module will be
+	  called bmi160_i2c.
+
+config BMI160_SPI
+	tristate "Bosch BMI160 SPI driver"
+	depends on SPI
+	select BMI160
+	select REGMAP_SPI
+	help
+	  If you say yes here you get support for BMI160 IMU on SPI with
+	  accelerometer, gyroscope and external BMG160 magnetometer.
+
+	  This driver can also be built as a module. If so, the module will be
+	  called bmi160_spi.
drivers/iio/imu/bmi160/Makefile new file +6 -0
new file mode 100644
index 0000000..10365e4
@@ -0,0 +1,6 @@
+#
+# Makefile for Bosch BMI160 IMU
+#
+obj-$(CONFIG_BMI160) += bmi160_core.o
+obj-$(CONFIG_BMI160_I2C) += bmi160_i2c.o
+obj-$(CONFIG_BMI160_SPI) += bmi160_spi.o
drivers/iio/imu/bmi160/bmi160.h new file +10 -0
new file mode 100644
index 0000000..d2ae6ed
@@ -0,0 +1,10 @@
+#ifndef BMI160_H_
+#define BMI160_H_
+
+extern const struct regmap_config bmi160_regmap_config;
+
+int bmi160_core_probe(struct device *dev, struct regmap *regmap,
+		      const char *name, bool use_spi);
+void bmi160_core_remove(struct device *dev);
+
+#endif  /* BMI160_H_ */
drivers/iio/imu/bmi160/bmi160_core.c new file +594 -0

594 lines not on this page · raw message

drivers/iio/imu/bmi160/bmi160_i2c.c new file +71 -0

71 lines not on this page · raw message

drivers/iio/imu/bmi160/bmi160_spi.c new file +62 -0

62 lines not on this page · raw message

Signature · 1 line
2.5.0
#1 lore raw
reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…

Hi Daniel,

[auto build test ERROR on iio/togreg]
[also build test ERROR on v4.6-rc2 next-20160405]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Daniel-Baluta/iio-imu-Add-initial-support-for-Bosch-BMI160/20160405-233813
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
config: openrisc-allyesconfig (attached as .config)

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=openrisc

All errors (new ones prefixed by >>):

drivers/iio/imu/bmi160/bmi160_i2c.c:50:1: warning: data definition has no type or storage class drivers/iio/imu/bmi160/bmi160_i2c.c:50:1: error: type defaults to 'int' in declaration of 'MODULE_DEVICE_TABLE' drivers/iio/imu/bmi160/bmi160_i2c.c:50:1: warning: parameter names (without types) in function declaration drivers/iio/imu/bmi160/bmi160_i2c.c:56:1: warning: data definition has no type or storage class drivers/iio/imu/bmi160/bmi160_i2c.c:56:1: error: type defaults to 'int' in declaration of 'MODULE_DEVICE_TABLE' drivers/iio/imu/bmi160/bmi160_i2c.c:56:1: warning: parameter names (without types) in function declaration drivers/iio/imu/bmi160/bmi160_i2c.c:67:1: warning: data definition has no type or storage class drivers/iio/imu/bmi160/bmi160_i2c.c:67:1: error: type defaults to 'int' in declaration of 'module_init' drivers/iio/imu/bmi160/bmi160_i2c.c:67:1: warning: parameter names (without types) in function declaration drivers/iio/imu/bmi160/bmi160_i2c.c:67:1: warning: data definition has no type or storage class drivers/iio/imu/bmi160/bmi160_i2c.c:67:1: error: type defaults to 'int' in declaration of 'module_exit' drivers/iio/imu/bmi160/bmi160_i2c.c:67:1: warning: parameter names (without types) in function declaration drivers/iio/imu/bmi160/bmi160_i2c.c:69:15: error: expected declaration specifiers or '...' before string constant drivers/iio/imu/bmi160/bmi160_i2c.c:69:1: warning: data definition has no type or storage class

>> drivers/iio/imu/bmi160/bmi160_i2c.c:69:1: error: type defaults to 'int' in declaration of 'MODULE_AUTHOR'
>> drivers/iio/imu/bmi160/bmi160_i2c.c:69:15: error: function declaration isn't a prototype
   drivers/iio/imu/bmi160/bmi160_i2c.c:70:20: error: expected declaration specifiers or '...' before string constant
   drivers/iio/imu/bmi160/bmi160_i2c.c:70:1: warning: data definition has no type or storage class
>> drivers/iio/imu/bmi160/bmi160_i2c.c:70:1: error: type defaults to 'int' in declaration of 'MODULE_DESCRIPTION'
   drivers/iio/imu/bmi160/bmi160_i2c.c:70:20: error: function declaration isn't a prototype
   drivers/iio/imu/bmi160/bmi160_i2c.c:71:16: error: expected declaration specifiers or '...' before string constant
   drivers/iio/imu/bmi160/bmi160_i2c.c:71:1: warning: data definition has no type or storage class
>> drivers/iio/imu/bmi160/bmi160_i2c.c:71:1: error: type defaults to 'int' in declaration of 'MODULE_LICENSE'

drivers/iio/imu/bmi160/bmi160_i2c.c:71:16: error: function declaration isn't a prototype drivers/iio/imu/bmi160/bmi160_i2c.c:67:1: warning: 'bmi160_i2c_driver_init' defined but not used
--
drivers/iio/imu/bmi160/bmi160_spi.c:41:1: warning: data definition has no type or storage class drivers/iio/imu/bmi160/bmi160_spi.c:41:1: error: type defaults to 'int' in declaration of 'MODULE_DEVICE_TABLE' drivers/iio/imu/bmi160/bmi160_spi.c:41:1: warning: parameter names (without types) in function declaration drivers/iio/imu/bmi160/bmi160_spi.c:47:1: warning: data definition has no type or storage class drivers/iio/imu/bmi160/bmi160_spi.c:47:1: error: type defaults to 'int' in declaration of 'MODULE_DEVICE_TABLE' drivers/iio/imu/bmi160/bmi160_spi.c:47:1: warning: parameter names (without types) in function declaration drivers/iio/imu/bmi160/bmi160_spi.c:58:1: warning: data definition has no type or storage class drivers/iio/imu/bmi160/bmi160_spi.c:58:1: error: type defaults to 'int' in declaration of 'module_init' drivers/iio/imu/bmi160/bmi160_spi.c:58:1: warning: parameter names (without types) in function declaration drivers/iio/imu/bmi160/bmi160_spi.c:58:1: warning: data definition has no type or storage class drivers/iio/imu/bmi160/bmi160_spi.c:58:1: error: type defaults to 'int' in declaration of 'module_exit' drivers/iio/imu/bmi160/bmi160_spi.c:58:1: warning: parameter names (without types) in function declaration drivers/iio/imu/bmi160/bmi160_spi.c:60:15: error: expected declaration specifiers or '...' before string constant drivers/iio/imu/bmi160/bmi160_spi.c:60:1: warning: data definition has no type or storage class

>> drivers/iio/imu/bmi160/bmi160_spi.c:60:1: error: type defaults to 'int' in declaration of 'MODULE_AUTHOR'
>> drivers/iio/imu/bmi160/bmi160_spi.c:60:15: error: function declaration isn't a prototype
   drivers/iio/imu/bmi160/bmi160_spi.c:61:20: error: expected declaration specifiers or '...' before string constant
   drivers/iio/imu/bmi160/bmi160_spi.c:61:1: warning: data definition has no type or storage class
>> drivers/iio/imu/bmi160/bmi160_spi.c:61:1: error: type defaults to 'int' in declaration of 'MODULE_DESCRIPTION'
   drivers/iio/imu/bmi160/bmi160_spi.c:61:20: error: function declaration isn't a prototype
   drivers/iio/imu/bmi160/bmi160_spi.c:62:16: error: expected declaration specifiers or '...' before string constant
   drivers/iio/imu/bmi160/bmi160_spi.c:62:1: warning: data definition has no type or storage class
>> drivers/iio/imu/bmi160/bmi160_spi.c:62:1: error: type defaults to 'int' in declaration of 'MODULE_LICENSE'

drivers/iio/imu/bmi160/bmi160_spi.c:62:16: error: function declaration isn't a prototype drivers/iio/imu/bmi160/bmi160_spi.c:58:1: warning: 'bmi160_spi_driver_init' defined but not used

vim +69 drivers/iio/imu/bmi160/bmi160_i2c.c

    63		.probe		= bmi160_i2c_probe,
    64		.remove		= bmi160_i2c_remove,
    65		.id_table	= bmi160_i2c_id,
    66	};
    67	module_i2c_driver(bmi160_i2c_driver);
    68	
  > 69	MODULE_AUTHOR("Daniel Baluta <[email protected]>");
  > 70	MODULE_DESCRIPTION("BMI160 I2C driver");
  > 71	MODULE_LICENSE("GPL v2");

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation