Add I2C driver for Bosch BMI270 IMU
Subsystems (3)
Alex Lanzano
maintainercover Add I2C driver for Bosch BMI270 IMU
Add basic I2C support for the Bosch BMI270 IMU.
References:
https://www.bosch-sensortec.com/products/motion-sensors/imus/bmi270/
---
Alex Lanzano (2):
dt-bindings: iio: imu: add bmi270 bindings
iio: imu: Add i2c driver for bmi270 imu
.../bindings/iio/imu/bosch,bmi270.yaml | 80 +++++ MAINTAINERS | 7 + drivers/iio/imu/Kconfig | 1 + drivers/iio/imu/Makefile | 1 + drivers/iio/imu/bmi270/Kconfig | 22 ++ drivers/iio/imu/bmi270/Makefile | 6 + drivers/iio/imu/bmi270/bmi270.h | 18 + drivers/iio/imu/bmi270/bmi270_core.c | 322 ++++++++++++++++++ drivers/iio/imu/bmi270/bmi270_i2c.c | 56 +++ 9 files changed, 513 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml create mode 100644 drivers/iio/imu/bmi270/Kconfig create mode 100644 drivers/iio/imu/bmi270/Makefile create mode 100644 drivers/iio/imu/bmi270/bmi270.h create mode 100644 drivers/iio/imu/bmi270/bmi270_core.c create mode 100644 drivers/iio/imu/bmi270/bmi270_i2c.c
Signature · 1 line
2.46.0
Alex Lanzano
maintainerPATCH 1/2 dt-bindings: iio: imu: add bmi270 bindings
Add device tree bindings for the bmi270 IMU
--- .../bindings/iio/imu/bosch,bmi270.yaml | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml
Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml new file +80 -0
@@ -0,0 +1,80 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/imu/bosch,bmi270.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Bosch BMI270 6-Axis IMU + +maintainers: + - Alex Lanzano <[email protected]> + +description: | + BMI270 is a 6-axis inertial measurement unit that can measure acceleration and + angular velocity. The sensor also supports configurable interrupt events such + as motion, step counter, and wrist motion gestures. The sensor can communicate + I2C or SPI. + https://www.bosch-sensortec.com/products/motion-sensors/imus/bmi270/ + +properties: + compatible: + const: bosch,bmi270 + + reg: + maxItems: 1 + + vdd-supply: true + vddio-supply: true + + interrupts: + minItems: 1 + maxItems: 2 + + interrupt-names: + minItems: 1 + maxItems: 2 + items: + enum: + - INT1 + - INT2 + + drive-open-drain: + description: + set if the specified interrupt pin should be configured as + open drain. If not set, defaults to push-pull. + + mount-matrix: + description: + an optional 3x3 mounting rotation matrix. + +required: + - compatible + - reg + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +unevaluatedProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + imu@68 { + compatible = "bosch,bmi270"; + reg = <0x68>; + }; + }; + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + bmi270@0 { + compatible = "bosch,bmi270"; + reg = <0>; + spi-max-frequency = <10000000>; + }; + };
Signature · 1 line
2.46.0
Re: [PATCH 1/2] dt-bindings: iio: imu: add bmi270 bindings
Quoted 56 lines · Alex Lanzano
Add device tree bindings for the bmi270 IMU
Signed-off-by Alex Lanzano <[email protected]>--- .../bindings/iio/imu/bosch,bmi270.yaml | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yamlDocumentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml new file +42
-0@@ -0,0 +1,80 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/imu/bosch,bmi270.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Bosch BMI270 6-Axis IMU + +maintainers: + - Alex Lanzano <[email protected]> + +description: | + BMI270 is a 6-axis inertial measurement unit that can measure acceleration and + angular velocity. The sensor also supports configurable interrupt events such + as motion, step counter, and wrist motion gestures. The sensor can communicate + I2C or SPI. + https://www.bosch-sensortec.com/products/motion-sensors/imus/bmi270/ + +properties: + compatible: + const: bosch,bmi270 + + reg: + maxItems: 1 + + vdd-supply: true + vddio-supply: true + + interrupts: + minItems: 1 + maxItems: 2 + + interrupt-names: + minItems: 1 + maxItems: 2 + items: + enum: + - INT1 + - INT2 + + drive-open-drain: + description:
Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml line 52
Quoted 10 lines
Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml new file +10
-0+ set if the specified interrupt pin should be configured as + open drain. If not set, defaults to push-pull. + + mount-matrix: + description: + an optional 3x3 mounting rotation matrix. + +required: + - compatible + - reg
Device can operate without power provided?
Quoted 7 lines
Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml new file +7
-0+ +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +unevaluatedProperties: false + +examples:
Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml line 69
Quoted 10 lines
Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml new file +10
-0+ - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + imu@68 { + compatible = "bosch,bmi270"; + reg = <0x68>; + }; + };
Keep just one, complete example. You miss here several properties.
Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml line 71
Quoted 2 lines
Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml new file +2
-0+ - | + spi {
Not much differences in this example, but if you want to keep it, then make it complete and fix the node name,
Node names should be generic. See also an explanation and list of examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
Best regards,
Krzysztof
Alex Lanzano
maintainerRe: [PATCH 1/2] dt-bindings: iio: imu: add bmi270 bindings
Quoted 61 lines · Krzysztof Kozlowski
Quoted 60 lines · Alex Lanzano
Add device tree bindings for the bmi270 IMU
Signed-off-by Alex Lanzano <[email protected]>--- .../bindings/iio/imu/bosch,bmi270.yaml | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yamlDocumentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml new file +46
-0@@ -0,0 +1,80 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/imu/bosch,bmi270.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Bosch BMI270 6-Axis IMU + +maintainers: + - Alex Lanzano <[email protected]> + +description: | + BMI270 is a 6-axis inertial measurement unit that can measure acceleration and + angular velocity. The sensor also supports configurable interrupt events such + as motion, step counter, and wrist motion gestures. The sensor can communicate + I2C or SPI. + https://www.bosch-sensortec.com/products/motion-sensors/imus/bmi270/ + +properties: + compatible: + const: bosch,bmi270 + + reg: + maxItems: 1 + + vdd-supply: true + vddio-supply: true + + interrupts: + minItems: 1 + maxItems: 2 + + interrupt-names: + minItems: 1 + maxItems: 2 + items: + enum: + - INT1 + - INT2 + + drive-open-drain: + description: + set if the specified interrupt pin should be configured as + open drain. If not set, defaults to push-pull. + + mount-matrix:
Quoted 9 lines
Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml line 52
Quoted 6 lines
Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml new file +6
-0+ description: + an optional 3x3 mounting rotation matrix. + +required: + - compatible + - regDevice can operate without power provided?
Will fix!
Quoted 26 lines
Quoted 7 lines
Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml new file +7
-0+ +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +unevaluatedProperties: false + +examples:Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml line 69
Quoted 10 lines
Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml new file +10
-0+ - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + imu@68 { + compatible = "bosch,bmi270"; + reg = <0x68>; + }; + };Keep just one, complete example. You miss here several properties.
Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml line 71
Quoted 2 lines
Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml new file +2
-0+ - | + spi {Not much differences in this example, but if you want to keep it, then make it complete and fix the node name,
Quoted 7 lines
Node names should be generic. See also an explanation and list of examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendationBest regards,
Krzysztof
I'll make more complete examples in v2. Thank you for the review! Much appreciated.
Alex Lanzano
maintainerPATCH 2/2 iio: imu: Add i2c driver for bmi270 imu
In reply to Alex LanzanoAdd initial i2c support for the Bosch BMI270 6-axis IMU. Provides raw read access to acceleration and angle velocity measurements via iio channels. Device configuration requires firmware provided by Bosch and is requested and load from userspace.
--- MAINTAINERS | 7 + drivers/iio/imu/Kconfig | 1 + drivers/iio/imu/Makefile | 1 + drivers/iio/imu/bmi270/Kconfig | 22 ++ drivers/iio/imu/bmi270/Makefile | 6 + drivers/iio/imu/bmi270/bmi270.h | 18 ++ drivers/iio/imu/bmi270/bmi270_core.c | 322 +++++++++++++++++++++++++++ drivers/iio/imu/bmi270/bmi270_i2c.c | 56 +++++ 8 files changed, 433 insertions(+) create mode 100644 drivers/iio/imu/bmi270/Kconfig create mode 100644 drivers/iio/imu/bmi270/Makefile create mode 100644 drivers/iio/imu/bmi270/bmi270.h create mode 100644 drivers/iio/imu/bmi270/bmi270_core.c create mode 100644 drivers/iio/imu/bmi270/bmi270_i2c.c
MAINTAINERS +7 -0
@@ -3966,6 +3966,13 @@ S: Maintained F: Documentation/devicetree/bindings/iio/accel/bosch,bma400.yaml F: drivers/iio/accel/bma400* +BOSCH SENSORTEC BMI270 IMU IIO DRIVER +M: Alex Lanzano <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/iio/imu/bosch,bmi270.yaml +F: drivers/iio/imu/bmi270/ + BOSCH SENSORTEC BMI323 IMU IIO DRIVER M: Jagath Jog J <[email protected]> L: [email protected]
drivers/iio/imu/Kconfig +1 -0
@@ -53,6 +53,7 @@ config ADIS16480 ADIS16485, ADIS16488 inertial sensors. source "drivers/iio/imu/bmi160/Kconfig" +source "drivers/iio/imu/bmi270/Kconfig" source "drivers/iio/imu/bmi323/Kconfig" source "drivers/iio/imu/bno055/Kconfig"
drivers/iio/imu/Makefile +1 -0
@@ -15,6 +15,7 @@ adis_lib-$(CONFIG_IIO_ADIS_LIB_BUFFER) += adis_buffer.o obj-$(CONFIG_IIO_ADIS_LIB) += adis_lib.o obj-y += bmi160/ +obj-y += bmi270/ obj-y += bmi323/ obj-y += bno055/
drivers/iio/imu/bmi270/Kconfig new file +22 -0
@@ -0,0 +1,22 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# BMI270 IMU driver +# + +config BMI270 + tristate + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + +config BMI270_I2C + tristate "Bosch BMI270 I2C driver" + depends on I2C + select BMI270 + select REGMAP_I2C + help + Enable support for the Bosch BMI270 6-Axis IMU connected to I2C + interface. + + This driver can also be built as a module. If so, the module will be + called bmi270_i2c. +
drivers/iio/imu/bmi270/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for Bosch BMI270 IMU +# +obj-$(CONFIG_BMI270) += bmi270_core.o +obj-$(CONFIG_BMI270_I2C) += bmi270_i2c.o
drivers/iio/imu/bmi270/bmi270.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ + +#ifndef BMI270_H_ +#define BMI270_H_ + +#include <linux/iio/iio.h> + +struct bmi270_data { +struct device *dev; +struct regmap *regmap; +}; + +extern const struct regmap_config bmi270_regmap_config; + +int bmi270_core_probe (struct device *dev,struct regmap *regmap, +const char *name,bool use_spi); + +#endif /* BMI270_H_ */
drivers/iio/imu/bmi270/bmi270_core.c new file +322 -0
322 lines not on this page · raw message
drivers/iio/imu/bmi270/bmi270_i2c.c new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
2.46.0