All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V3 0/6] iio: accel: bmi088: support BMI085 BMI090L
@ 2022-05-18 15:04 LI Qingwu
  2022-05-18 15:04 ` [PATCH V3 1/6] iio: accel: bmi088: Modified the scale calculate LI Qingwu
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: LI Qingwu @ 2022-05-18 15:04 UTC (permalink / raw)
  To: jic23, lars, mchehab+huawei, ardeleanalex, linux-iio,
	linux-kernel, Qing-wu.Li, robh+dt, mike.looijmans, devicetree,
	thomas.haemmerle

Modified the units after application of scale from 100*m/s^2 to m/s^2,
since the units in the ABI documents are m/s^2.
Add supports for the BMI085 accelerometer.
Add supports for the BMI090L accelerometer.
Make it possible to config scales.

Change in V3: 

Use FIELD_GET for checking register range. Reorder the chip info and 
dt-bindings alphabetical. Add of_id_table. Modify the logic of loading
sensor chip info. If the device was found in the table but the device 
tree binding is different, the driver will carry on with the detected
chip with a warning. If no matching device was found, the driver load
the binding chip.


LI Qingwu (6):
  iio: accel: bmi088: Modified the scale calculate
  iio: accel: bmi088: Make it possible to config scales
  iio: accel: bmi088: modified the device name
  iio: accel: bmi088: Add support for bmi085 accel
  iio: accel: bmi088: Add support for bmi090l accel
  dt-bindings: iio: accel: Add bmi085 and bmi090l bindings

 .../bindings/iio/accel/bosch,bmi088.yaml      |  2 +
 drivers/iio/accel/bmi088-accel-core.c         | 96 +++++++++++++++----
 drivers/iio/accel/bmi088-accel-spi.c          | 17 +++-
 drivers/iio/accel/bmi088-accel.h              |  9 +-
 4 files changed, 100 insertions(+), 24 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH V3 1/6] iio: accel: bmi088: Modified the scale calculate
  2022-05-18 15:04 [PATCH V3 0/6] iio: accel: bmi088: support BMI085 BMI090L LI Qingwu
@ 2022-05-18 15:04 ` LI Qingwu
  2022-05-18 15:04 ` [PATCH V3 2/6] iio: accel: bmi088: Make it possible to config scales LI Qingwu
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: LI Qingwu @ 2022-05-18 15:04 UTC (permalink / raw)
  To: jic23, lars, mchehab+huawei, ardeleanalex, linux-iio,
	linux-kernel, Qing-wu.Li, robh+dt, mike.looijmans, devicetree,
	thomas.haemmerle

The units after application of scale are 100*m/s^2,
The scale calculation is only for the device
with the range of 3, 6, 12, and 24g,
but some other chips have a range of 2, 4, 6, and 8g.

Modified the formula to a scale list.
The scales in the list are calculated by 1/sensitivity*9.8.
The new units after the application of scale are m/s^2.

Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
---
 drivers/iio/accel/bmi088-accel-core.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c
index a06dae5c971d..21bddee869af 100644
--- a/drivers/iio/accel/bmi088-accel-core.c
+++ b/drivers/iio/accel/bmi088-accel-core.c
@@ -73,6 +73,8 @@
 #define BMI088_ACCEL_FIFO_MODE_FIFO			0x40
 #define BMI088_ACCEL_FIFO_MODE_STREAM			0x80
 
+#define BMIO088_ACCEL_ACC_RANGE_MSK			GENMASK(1, 0)
+
 enum bmi088_accel_axis {
 	AXIS_X,
 	AXIS_Y,
@@ -119,6 +121,7 @@ struct bmi088_accel_chip_info {
 	u8 chip_id;
 	const struct iio_chan_spec *channels;
 	int num_channels;
+	const int scale_table[4][2];
 };
 
 struct bmi088_accel_data {
@@ -280,6 +283,7 @@ static int bmi088_accel_read_raw(struct iio_dev *indio_dev,
 	struct bmi088_accel_data *data = iio_priv(indio_dev);
 	struct device *dev = regmap_get_device(data->regmap);
 	int ret;
+	int reg;
 
 	switch (mask) {
 	case IIO_CHAN_INFO_RAW:
@@ -330,13 +334,14 @@ static int bmi088_accel_read_raw(struct iio_dev *indio_dev,
 				return ret;
 
 			ret = regmap_read(data->regmap,
-					  BMI088_ACCEL_REG_ACC_RANGE, val);
+					  BMI088_ACCEL_REG_ACC_RANGE, &reg);
 			if (ret)
 				goto out_read_raw_pm_put;
 
-			*val2 = 15 - (*val & 0x3);
-			*val = 3 * 980;
-			ret = IIO_VAL_FRACTIONAL_LOG2;
+			reg = FIELD_GET(BMIO088_ACCEL_ACC_RANGE_MSK, reg);
+			*val  = data->chip_info->scale_table[reg][0];
+			*val2 = data->chip_info->scale_table[reg][1];
+			ret = IIO_VAL_INT_PLUS_MICRO;
 
 			goto out_read_raw_pm_put;
 		default:
@@ -432,6 +437,7 @@ static const struct bmi088_accel_chip_info bmi088_accel_chip_info_tbl[] = {
 		.chip_id = 0x1E,
 		.channels = bmi088_accel_channels,
 		.num_channels = ARRAY_SIZE(bmi088_accel_channels),
+		.scale_table = {{0, 897}, {0, 1795}, {0, 3590}, {0, 7179}},
 	},
 };
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH V3 2/6] iio: accel: bmi088: Make it possible to config scales
  2022-05-18 15:04 [PATCH V3 0/6] iio: accel: bmi088: support BMI085 BMI090L LI Qingwu
  2022-05-18 15:04 ` [PATCH V3 1/6] iio: accel: bmi088: Modified the scale calculate LI Qingwu
@ 2022-05-18 15:04 ` LI Qingwu
  2022-05-18 15:04 ` [PATCH V3 3/6] iio: accel: bmi088: modified the device name LI Qingwu
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: LI Qingwu @ 2022-05-18 15:04 UTC (permalink / raw)
  To: jic23, lars, mchehab+huawei, ardeleanalex, linux-iio,
	linux-kernel, Qing-wu.Li, robh+dt, mike.looijmans, devicetree,
	thomas.haemmerle

The sensor can set the scales by writing the range register 0x41,
The current driver has no interface to configure it.
The commit adds the interface for config the scales.

Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
---
 drivers/iio/accel/bmi088-accel-core.c | 33 ++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c
index 21bddee869af..563bcc311844 100644
--- a/drivers/iio/accel/bmi088-accel-core.c
+++ b/drivers/iio/accel/bmi088-accel-core.c
@@ -239,6 +239,21 @@ static int bmi088_accel_set_sample_freq(struct bmi088_accel_data *data, int val)
 				  BMI088_ACCEL_MODE_ODR_MASK, regval);
 }
 
+static int bmi088_accel_set_scale(struct bmi088_accel_data *data, int val, int val2)
+{
+	unsigned int i;
+
+	for (i = 0; i < 4; i++)
+		if (val  == data->chip_info->scale_table[i][0] &&
+		    val2 == data->chip_info->scale_table[i][1])
+			break;
+
+	if (i == 4)
+		return -EINVAL;
+
+	return regmap_write(data->regmap, BMI088_ACCEL_REG_ACC_RANGE, i);
+}
+
 static int bmi088_accel_get_temp(struct bmi088_accel_data *data, int *val)
 {
 	int ret;
@@ -372,7 +387,13 @@ static int bmi088_accel_read_avail(struct iio_dev *indio_dev,
 			     const int **vals, int *type, int *length,
 			     long mask)
 {
+	struct bmi088_accel_data *data = iio_priv(indio_dev);
 	switch (mask) {
+	case IIO_CHAN_INFO_SCALE:
+		*vals = (const int *)data->chip_info->scale_table;
+		*length = 8;
+		*type = IIO_VAL_INT_PLUS_MICRO;
+		return IIO_AVAIL_LIST;
 	case IIO_CHAN_INFO_SAMP_FREQ:
 		*type = IIO_VAL_INT_PLUS_MICRO;
 		*vals = bmi088_sample_freqs;
@@ -392,6 +413,15 @@ static int bmi088_accel_write_raw(struct iio_dev *indio_dev,
 	int ret;
 
 	switch (mask) {
+	case IIO_CHAN_INFO_SCALE:
+		ret = pm_runtime_resume_and_get(dev);
+		if (ret)
+			return ret;
+
+		ret = bmi088_accel_set_scale(data, val, val2);
+		pm_runtime_mark_last_busy(dev);
+		pm_runtime_put_autosuspend(dev);
+		return ret;
 	case IIO_CHAN_INFO_SAMP_FREQ:
 		ret = pm_runtime_resume_and_get(dev);
 		if (ret)
@@ -413,7 +443,8 @@ static int bmi088_accel_write_raw(struct iio_dev *indio_dev,
 	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
 	.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
 				BIT(IIO_CHAN_INFO_SAMP_FREQ), \
-	.info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SAMP_FREQ), \
+	.info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \
+				BIT(IIO_CHAN_INFO_SCALE), \
 	.scan_index = AXIS_##_axis, \
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH V3 3/6] iio: accel: bmi088: modified the device name
  2022-05-18 15:04 [PATCH V3 0/6] iio: accel: bmi088: support BMI085 BMI090L LI Qingwu
  2022-05-18 15:04 ` [PATCH V3 1/6] iio: accel: bmi088: Modified the scale calculate LI Qingwu
  2022-05-18 15:04 ` [PATCH V3 2/6] iio: accel: bmi088: Make it possible to config scales LI Qingwu
@ 2022-05-18 15:04 ` LI Qingwu
  2022-05-18 15:04 ` [PATCH V3 4/6] iio: accel: bmi088: Add support for bmi085 accel LI Qingwu
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: LI Qingwu @ 2022-05-18 15:04 UTC (permalink / raw)
  To: jic23, lars, mchehab+huawei, ardeleanalex, linux-iio,
	linux-kernel, Qing-wu.Li, robh+dt, mike.looijmans, devicetree,
	thomas.haemmerle

iio: accel: bmi088: modified the device name

It is possible to have multiple sensors connected on the same platform.
For support of different sensors, making it possible to obtain the
device name by reading the chip id. If the device was found in the
table but the device tree binding is different, the driver will carry
on with a warning. If no matching device was found, the driver load
the binding chip info.

Tested case, test with bmi085 and bmi090 patches applied:
connect 3 bmi090l to the system, and set device tree compatible:
spi2.0: compatible = "bosch,bmi090l-accel";
spi2.2: compatible = "bosch,bmi088-accel";
spi2.4: compatible = "bosch,bmi085-accel";

Get a warning for the mismatched devices:
bmi088_accel_spi spi2.2: unexpected chip id 0x1A
bmi088_accel_spi spi2.4: unexpected chip id 0x1A

Get the real present device name:
/sys/bus/iio/devices/iio:device1/name:bmi090l-accel
/sys/bus/iio/devices/iio:device3/name:bmi090l-accel
/sys/bus/iio/devices/iio:device5/name:bmi090l-accel

Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
---
 drivers/iio/accel/bmi088-accel-core.c | 35 +++++++++++++++------------
 drivers/iio/accel/bmi088-accel-spi.c  | 13 +++++++---
 drivers/iio/accel/bmi088-accel.h      |  7 +++++-
 3 files changed, 36 insertions(+), 19 deletions(-)

diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c
index 563bcc311844..c30c2d510b92 100644
--- a/drivers/iio/accel/bmi088-accel-core.c
+++ b/drivers/iio/accel/bmi088-accel-core.c
@@ -388,6 +388,7 @@ static int bmi088_accel_read_avail(struct iio_dev *indio_dev,
 			     long mask)
 {
 	struct bmi088_accel_data *data = iio_priv(indio_dev);
+
 	switch (mask) {
 	case IIO_CHAN_INFO_SCALE:
 		*vals = (const int *)data->chip_info->scale_table;
@@ -463,8 +464,8 @@ static const struct iio_chan_spec bmi088_accel_channels[] = {
 };
 
 static const struct bmi088_accel_chip_info bmi088_accel_chip_info_tbl[] = {
-	[0] = {
-		.name = "bmi088a",
+	[BOSCH_BMI088] = {
+		.name = "bmi088-accel",
 		.chip_id = 0x1E,
 		.channels = bmi088_accel_channels,
 		.num_channels = ARRAY_SIZE(bmi088_accel_channels),
@@ -483,12 +484,15 @@ static const unsigned long bmi088_accel_scan_masks[] = {
 	0
 };
 
-static int bmi088_accel_chip_init(struct bmi088_accel_data *data)
+static int bmi088_accel_chip_init(struct bmi088_accel_data *data, enum bmi_device_type type)
 {
 	struct device *dev = regmap_get_device(data->regmap);
 	int ret, i;
 	unsigned int val;
 
+	if (type >= BOSCH_UNKNOWN)
+		return -ENODEV;
+
 	/* Do a dummy read to enable SPI interface, won't harm I2C */
 	regmap_read(data->regmap, BMI088_ACCEL_REG_INT_STATUS, &val);
 
@@ -514,22 +518,23 @@ static int bmi088_accel_chip_init(struct bmi088_accel_data *data)
 	}
 
 	/* Validate chip ID */
-	for (i = 0; i < ARRAY_SIZE(bmi088_accel_chip_info_tbl); i++) {
-		if (bmi088_accel_chip_info_tbl[i].chip_id == val) {
-			data->chip_info = &bmi088_accel_chip_info_tbl[i];
+	for (i = 0; i < ARRAY_SIZE(bmi088_accel_chip_info_tbl); i++)
+		if (bmi088_accel_chip_info_tbl[i].chip_id == val)
 			break;
-		}
-	}
-	if (i == ARRAY_SIZE(bmi088_accel_chip_info_tbl)) {
-		dev_err(dev, "Invalid chip %x\n", val);
-		return -ENODEV;
-	}
+
+	if (i == ARRAY_SIZE(bmi088_accel_chip_info_tbl))
+		data->chip_info = &bmi088_accel_chip_info_tbl[type];
+	else
+		data->chip_info = &bmi088_accel_chip_info_tbl[i];
+
+	if (i != type)
+		dev_warn(dev, "unexpected chip id 0x%X\n", val);
 
 	return 0;
 }
 
 int bmi088_accel_core_probe(struct device *dev, struct regmap *regmap,
-	int irq, const char *name, bool block_supported)
+	int irq, enum bmi_device_type type)
 {
 	struct bmi088_accel_data *data;
 	struct iio_dev *indio_dev;
@@ -544,13 +549,13 @@ int bmi088_accel_core_probe(struct device *dev, struct regmap *regmap,
 
 	data->regmap = regmap;
 
-	ret = bmi088_accel_chip_init(data);
+	ret = bmi088_accel_chip_init(data, type);
 	if (ret)
 		return ret;
 
 	indio_dev->channels = data->chip_info->channels;
 	indio_dev->num_channels = data->chip_info->num_channels;
-	indio_dev->name = name ? name : data->chip_info->name;
+	indio_dev->name = data->chip_info->name;
 	indio_dev->available_scan_masks = bmi088_accel_scan_masks;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 	indio_dev->info = &bmi088_accel_info;
diff --git a/drivers/iio/accel/bmi088-accel-spi.c b/drivers/iio/accel/bmi088-accel-spi.c
index dd1e3f6cf211..24cdeb41d2a6 100644
--- a/drivers/iio/accel/bmi088-accel-spi.c
+++ b/drivers/iio/accel/bmi088-accel-spi.c
@@ -52,8 +52,8 @@ static int bmi088_accel_probe(struct spi_device *spi)
 		return PTR_ERR(regmap);
 	}
 
-	return bmi088_accel_core_probe(&spi->dev, regmap, spi->irq, id->name,
-				       true);
+	return bmi088_accel_core_probe(&spi->dev, regmap, spi->irq,
+					id->driver_data);
 }
 
 static int bmi088_accel_remove(struct spi_device *spi)
@@ -61,8 +61,14 @@ static int bmi088_accel_remove(struct spi_device *spi)
 	return bmi088_accel_core_remove(&spi->dev);
 }
 
+static const struct of_device_id bmi088_of_match[] = {
+	{ .compatible = "bosch,bmi088-accel" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, bmi088_of_match);
+
 static const struct spi_device_id bmi088_accel_id[] = {
-	{"bmi088-accel", },
+	{"bmi088-accel",  BOSCH_BMI088},
 	{}
 };
 MODULE_DEVICE_TABLE(spi, bmi088_accel_id);
@@ -71,6 +77,7 @@ static struct spi_driver bmi088_accel_driver = {
 	.driver = {
 		.name	= "bmi088_accel_spi",
 		.pm	= &bmi088_accel_pm_ops,
+		.of_match_table = bmi088_of_match,
 	},
 	.probe		= bmi088_accel_probe,
 	.remove		= bmi088_accel_remove,
diff --git a/drivers/iio/accel/bmi088-accel.h b/drivers/iio/accel/bmi088-accel.h
index 5c25f16b672c..b6a0281a847f 100644
--- a/drivers/iio/accel/bmi088-accel.h
+++ b/drivers/iio/accel/bmi088-accel.h
@@ -8,11 +8,16 @@
 
 struct device;
 
+enum bmi_device_type {
+	BOSCH_BMI088,
+	BOSCH_UNKNOWN,
+};
+
 extern const struct regmap_config bmi088_regmap_conf;
 extern const struct dev_pm_ops bmi088_accel_pm_ops;
 
 int bmi088_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
-			    const char *name, bool block_supported);
+			    enum bmi_device_type type);
 int bmi088_accel_core_remove(struct device *dev);
 
 #endif /* BMI088_ACCEL_H */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH V3 4/6] iio: accel: bmi088: Add support for bmi085 accel
  2022-05-18 15:04 [PATCH V3 0/6] iio: accel: bmi088: support BMI085 BMI090L LI Qingwu
                   ` (2 preceding siblings ...)
  2022-05-18 15:04 ` [PATCH V3 3/6] iio: accel: bmi088: modified the device name LI Qingwu
@ 2022-05-18 15:04 ` LI Qingwu
  2022-05-18 15:04 ` [PATCH V3 5/6] iio: accel: bmi088: Add support for bmi090l accel LI Qingwu
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: LI Qingwu @ 2022-05-18 15:04 UTC (permalink / raw)
  To: jic23, lars, mchehab+huawei, ardeleanalex, linux-iio,
	linux-kernel, Qing-wu.Li, robh+dt, mike.looijmans, devicetree,
	thomas.haemmerle

Add supports for BMI085, an Inertial Measurement Unit,
with an accelerometer and gyroscope.
The commit adds the accelerometer driver for the SPI interface.
The gyroscope part is already supported by the BMG160 driver.
Different from BMI088, the BMI085 accelerometer has the range of
+/-2, 4, 6, and 8g.

Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
---
 drivers/iio/accel/bmi088-accel-core.c | 7 +++++++
 drivers/iio/accel/bmi088-accel-spi.c  | 2 ++
 drivers/iio/accel/bmi088-accel.h      | 1 +
 3 files changed, 10 insertions(+)

diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c
index c30c2d510b92..d5e93ac7f1e1 100644
--- a/drivers/iio/accel/bmi088-accel-core.c
+++ b/drivers/iio/accel/bmi088-accel-core.c
@@ -464,6 +464,13 @@ static const struct iio_chan_spec bmi088_accel_channels[] = {
 };
 
 static const struct bmi088_accel_chip_info bmi088_accel_chip_info_tbl[] = {
+	[BOSCH_BMI085] = {
+		.name = "bmi085-accel",
+		.chip_id = 0x1F,
+		.channels = bmi088_accel_channels,
+		.num_channels = ARRAY_SIZE(bmi088_accel_channels),
+		.scale_table = {{0, 598}, {0, 1196}, {0, 2393}, {0, 4785}},
+	},
 	[BOSCH_BMI088] = {
 		.name = "bmi088-accel",
 		.chip_id = 0x1E,
diff --git a/drivers/iio/accel/bmi088-accel-spi.c b/drivers/iio/accel/bmi088-accel-spi.c
index 24cdeb41d2a6..f2cd70f362b8 100644
--- a/drivers/iio/accel/bmi088-accel-spi.c
+++ b/drivers/iio/accel/bmi088-accel-spi.c
@@ -62,12 +62,14 @@ static int bmi088_accel_remove(struct spi_device *spi)
 }
 
 static const struct of_device_id bmi088_of_match[] = {
+	{ .compatible = "bosch,bmi085-accel" },
 	{ .compatible = "bosch,bmi088-accel" },
 	{}
 };
 MODULE_DEVICE_TABLE(of, bmi088_of_match);
 
 static const struct spi_device_id bmi088_accel_id[] = {
+	{"bmi085-accel",  BOSCH_BMI085},
 	{"bmi088-accel",  BOSCH_BMI088},
 	{}
 };
diff --git a/drivers/iio/accel/bmi088-accel.h b/drivers/iio/accel/bmi088-accel.h
index b6a0281a847f..9b23f50c8271 100644
--- a/drivers/iio/accel/bmi088-accel.h
+++ b/drivers/iio/accel/bmi088-accel.h
@@ -9,6 +9,7 @@
 struct device;
 
 enum bmi_device_type {
+	BOSCH_BMI085,
 	BOSCH_BMI088,
 	BOSCH_UNKNOWN,
 };
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH V3 5/6] iio: accel: bmi088: Add support for bmi090l accel
  2022-05-18 15:04 [PATCH V3 0/6] iio: accel: bmi088: support BMI085 BMI090L LI Qingwu
                   ` (3 preceding siblings ...)
  2022-05-18 15:04 ` [PATCH V3 4/6] iio: accel: bmi088: Add support for bmi085 accel LI Qingwu
@ 2022-05-18 15:04 ` LI Qingwu
  2022-05-18 15:04 ` [PATCH V3 6/6] dt-bindings: iio: accel: Add bmi085 and bmi090l bindings LI Qingwu
  2022-05-22 11:37 ` [PATCH V3 0/6] iio: accel: bmi088: support BMI085 BMI090L Jonathan Cameron
  6 siblings, 0 replies; 8+ messages in thread
From: LI Qingwu @ 2022-05-18 15:04 UTC (permalink / raw)
  To: jic23, lars, mchehab+huawei, ardeleanalex, linux-iio,
	linux-kernel, Qing-wu.Li, robh+dt, mike.looijmans, devicetree,
	thomas.haemmerle

Add supports for BMI090L, it's a high-performance Inertial
Measurement Unit, with an accelerometer and gyroscope.
The commit adds the accelerometer driver for the SPI interface.
The gyroscope part is already supported by the BMG160 driver.
Same as BMI088, BMI090L have the range of +/-3, 6, 12, and 24g.

Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
---
 drivers/iio/accel/bmi088-accel-core.c | 7 +++++++
 drivers/iio/accel/bmi088-accel-spi.c  | 2 ++
 drivers/iio/accel/bmi088-accel.h      | 1 +
 3 files changed, 10 insertions(+)

diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c
index d5e93ac7f1e1..132781bfe872 100644
--- a/drivers/iio/accel/bmi088-accel-core.c
+++ b/drivers/iio/accel/bmi088-accel-core.c
@@ -478,6 +478,13 @@ static const struct bmi088_accel_chip_info bmi088_accel_chip_info_tbl[] = {
 		.num_channels = ARRAY_SIZE(bmi088_accel_channels),
 		.scale_table = {{0, 897}, {0, 1795}, {0, 3590}, {0, 7179}},
 	},
+	[BOSCH_BMI090L] = {
+		.name = "bmi090l-accel",
+		.chip_id = 0x1A,
+		.channels = bmi088_accel_channels,
+		.num_channels = ARRAY_SIZE(bmi088_accel_channels),
+		.scale_table = {{0, 897}, {0, 1795}, {0, 3590}, {0, 7179}},
+	},
 };
 
 static const struct iio_info bmi088_accel_info = {
diff --git a/drivers/iio/accel/bmi088-accel-spi.c b/drivers/iio/accel/bmi088-accel-spi.c
index f2cd70f362b8..a35de34399bd 100644
--- a/drivers/iio/accel/bmi088-accel-spi.c
+++ b/drivers/iio/accel/bmi088-accel-spi.c
@@ -64,6 +64,7 @@ static int bmi088_accel_remove(struct spi_device *spi)
 static const struct of_device_id bmi088_of_match[] = {
 	{ .compatible = "bosch,bmi085-accel" },
 	{ .compatible = "bosch,bmi088-accel" },
+	{ .compatible = "bosch,bmi090l-accel" },
 	{}
 };
 MODULE_DEVICE_TABLE(of, bmi088_of_match);
@@ -71,6 +72,7 @@ MODULE_DEVICE_TABLE(of, bmi088_of_match);
 static const struct spi_device_id bmi088_accel_id[] = {
 	{"bmi085-accel",  BOSCH_BMI085},
 	{"bmi088-accel",  BOSCH_BMI088},
+	{"bmi090l-accel", BOSCH_BMI090L},
 	{}
 };
 MODULE_DEVICE_TABLE(spi, bmi088_accel_id);
diff --git a/drivers/iio/accel/bmi088-accel.h b/drivers/iio/accel/bmi088-accel.h
index 9b23f50c8271..8ac9eec64d65 100644
--- a/drivers/iio/accel/bmi088-accel.h
+++ b/drivers/iio/accel/bmi088-accel.h
@@ -11,6 +11,7 @@ struct device;
 enum bmi_device_type {
 	BOSCH_BMI085,
 	BOSCH_BMI088,
+	BOSCH_BMI090L,
 	BOSCH_UNKNOWN,
 };
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH V3 6/6] dt-bindings: iio: accel: Add bmi085 and bmi090l bindings
  2022-05-18 15:04 [PATCH V3 0/6] iio: accel: bmi088: support BMI085 BMI090L LI Qingwu
                   ` (4 preceding siblings ...)
  2022-05-18 15:04 ` [PATCH V3 5/6] iio: accel: bmi088: Add support for bmi090l accel LI Qingwu
@ 2022-05-18 15:04 ` LI Qingwu
  2022-05-22 11:37 ` [PATCH V3 0/6] iio: accel: bmi088: support BMI085 BMI090L Jonathan Cameron
  6 siblings, 0 replies; 8+ messages in thread
From: LI Qingwu @ 2022-05-18 15:04 UTC (permalink / raw)
  To: jic23, lars, mchehab+huawei, ardeleanalex, linux-iio,
	linux-kernel, Qing-wu.Li, robh+dt, mike.looijmans, devicetree,
	thomas.haemmerle

Adds the device-tree bindings for the Bosch
BMI085 and BMI090L IMU, the accelerometer part.

Datasheet: https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmi085-ds001.pdf
Datasheet: https://media.digikey.com/pdf/Data%20Sheets/Bosch/BST-BMI090L-DS000-00.pdf
Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
---
 Documentation/devicetree/bindings/iio/accel/bosch,bmi088.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/accel/bosch,bmi088.yaml b/Documentation/devicetree/bindings/iio/accel/bosch,bmi088.yaml
index 911a1ae9c83f..272eb48eef5a 100644
--- a/Documentation/devicetree/bindings/iio/accel/bosch,bmi088.yaml
+++ b/Documentation/devicetree/bindings/iio/accel/bosch,bmi088.yaml
@@ -17,7 +17,9 @@ description: |
 properties:
   compatible:
     enum:
+      - bosch,bmi085-accel
       - bosch,bmi088-accel
+      - bosch,bmi090l-accel
 
   reg:
     maxItems: 1
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH V3 0/6] iio: accel: bmi088: support BMI085 BMI090L
  2022-05-18 15:04 [PATCH V3 0/6] iio: accel: bmi088: support BMI085 BMI090L LI Qingwu
                   ` (5 preceding siblings ...)
  2022-05-18 15:04 ` [PATCH V3 6/6] dt-bindings: iio: accel: Add bmi085 and bmi090l bindings LI Qingwu
@ 2022-05-22 11:37 ` Jonathan Cameron
  6 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2022-05-22 11:37 UTC (permalink / raw)
  To: LI Qingwu
  Cc: lars, mchehab+huawei, ardeleanalex, linux-iio, linux-kernel,
	robh+dt, mike.looijmans, devicetree, thomas.haemmerle

On Wed, 18 May 2022 15:04:19 +0000
LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn> wrote:

> Modified the units after application of scale from 100*m/s^2 to m/s^2,
> since the units in the ABI documents are m/s^2.
> Add supports for the BMI085 accelerometer.
> Add supports for the BMI090L accelerometer.
> Make it possible to config scales.
> 
> Change in V3: 
> 
> Use FIELD_GET for checking register range. Reorder the chip info and 
> dt-bindings alphabetical. Add of_id_table. Modify the logic of loading
> sensor chip info. If the device was found in the table but the device 
> tree binding is different, the driver will carry on with the detected
> chip with a warning. If no matching device was found, the driver load
> the binding chip.

All looks good to me. Unfortunately we've missed the 5.19 merge window
now as it will probably open shortly.  As such we have lots of time so
I'll leave this on list for a little longer for others to take a look at.
Thanks,

Jonathan

> 
> 
> LI Qingwu (6):
>   iio: accel: bmi088: Modified the scale calculate
>   iio: accel: bmi088: Make it possible to config scales
>   iio: accel: bmi088: modified the device name
>   iio: accel: bmi088: Add support for bmi085 accel
>   iio: accel: bmi088: Add support for bmi090l accel
>   dt-bindings: iio: accel: Add bmi085 and bmi090l bindings
> 
>  .../bindings/iio/accel/bosch,bmi088.yaml      |  2 +
>  drivers/iio/accel/bmi088-accel-core.c         | 96 +++++++++++++++----
>  drivers/iio/accel/bmi088-accel-spi.c          | 17 +++-
>  drivers/iio/accel/bmi088-accel.h              |  9 +-
>  4 files changed, 100 insertions(+), 24 deletions(-)
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-05-22 11:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-18 15:04 [PATCH V3 0/6] iio: accel: bmi088: support BMI085 BMI090L LI Qingwu
2022-05-18 15:04 ` [PATCH V3 1/6] iio: accel: bmi088: Modified the scale calculate LI Qingwu
2022-05-18 15:04 ` [PATCH V3 2/6] iio: accel: bmi088: Make it possible to config scales LI Qingwu
2022-05-18 15:04 ` [PATCH V3 3/6] iio: accel: bmi088: modified the device name LI Qingwu
2022-05-18 15:04 ` [PATCH V3 4/6] iio: accel: bmi088: Add support for bmi085 accel LI Qingwu
2022-05-18 15:04 ` [PATCH V3 5/6] iio: accel: bmi088: Add support for bmi090l accel LI Qingwu
2022-05-18 15:04 ` [PATCH V3 6/6] dt-bindings: iio: accel: Add bmi085 and bmi090l bindings LI Qingwu
2022-05-22 11:37 ` [PATCH V3 0/6] iio: accel: bmi088: support BMI085 BMI090L Jonathan Cameron

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.