devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V5 0/6] iio: accel: bmi088: support BMI085 BMI090L
@ 2022-05-26 13:33 LI Qingwu
  2022-05-26 13:33 ` [PATCH V5 1/6] iio: accel: bmi088: Modified the scale calculate LI Qingwu
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: LI Qingwu @ 2022-05-26 13:33 UTC (permalink / raw)
  To: jic23, lars, mchehab+huawei, ardeleanalex, linux-iio,
	linux-kernel, Qing-wu.Li, robh+dt, mike.looijmans, devicetree
  Cc: 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 v5: 
- Fix the issue of 'undeclared function FIELD_GET'
  Reported-by: kernel test robot <lkp@intel.com>


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         | 97 +++++++++++++++----
 drivers/iio/accel/bmi088-accel-spi.c          | 17 +++-
 drivers/iio/accel/bmi088-accel.h              |  9 +-
 4 files changed, 101 insertions(+), 24 deletions(-)

-- 
2.25.1


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

* [PATCH V5 1/6] iio: accel: bmi088: Modified the scale calculate
  2022-05-26 13:33 [PATCH V5 0/6] iio: accel: bmi088: support BMI085 BMI090L LI Qingwu
@ 2022-05-26 13:33 ` LI Qingwu
  2022-05-26 13:33 ` [PATCH V5 2/6] iio: accel: bmi088: Make it possible to config scales LI Qingwu
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: LI Qingwu @ 2022-05-26 13:33 UTC (permalink / raw)
  To: jic23, lars, mchehab+huawei, ardeleanalex, linux-iio,
	linux-kernel, Qing-wu.Li, robh+dt, mike.looijmans, devicetree
  Cc: 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 scales from formula to a list, the scales in the list are
calculated as 9.8/32768*pow(2,reg41+1)*1.5, refer to datasheet 5.3.4.
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 | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c
index d74465214feb..fd812802b71d 100644
--- a/drivers/iio/accel/bmi088-accel-core.c
+++ b/drivers/iio/accel/bmi088-accel-core.c
@@ -6,6 +6,7 @@
  * Copyright (c) 2018-2021, Topic Embedded Products
  */
 
+#include <linux/bitfield.h>
 #include <linux/delay.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -73,6 +74,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 +122,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 +284,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 +335,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 +438,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, 1794}, {0, 3589}, {0, 7178}},
 	},
 };
 
-- 
2.25.1


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

* [PATCH V5 2/6] iio: accel: bmi088: Make it possible to config scales
  2022-05-26 13:33 [PATCH V5 0/6] iio: accel: bmi088: support BMI085 BMI090L LI Qingwu
  2022-05-26 13:33 ` [PATCH V5 1/6] iio: accel: bmi088: Modified the scale calculate LI Qingwu
@ 2022-05-26 13:33 ` LI Qingwu
  2022-05-26 13:33 ` [PATCH V5 3/6] iio: accel: bmi088: modified the device name LI Qingwu
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: LI Qingwu @ 2022-05-26 13:33 UTC (permalink / raw)
  To: jic23, lars, mchehab+huawei, ardeleanalex, linux-iio,
	linux-kernel, Qing-wu.Li, robh+dt, mike.looijmans, devicetree
  Cc: 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 fd812802b71d..73c1e2aecd7e 100644
--- a/drivers/iio/accel/bmi088-accel-core.c
+++ b/drivers/iio/accel/bmi088-accel-core.c
@@ -240,6 +240,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;
@@ -373,7 +388,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;
@@ -393,6 +414,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)
@@ -414,7 +444,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] 11+ messages in thread

* [PATCH V5 3/6] iio: accel: bmi088: modified the device name
  2022-05-26 13:33 [PATCH V5 0/6] iio: accel: bmi088: support BMI085 BMI090L LI Qingwu
  2022-05-26 13:33 ` [PATCH V5 1/6] iio: accel: bmi088: Modified the scale calculate LI Qingwu
  2022-05-26 13:33 ` [PATCH V5 2/6] iio: accel: bmi088: Make it possible to config scales LI Qingwu
@ 2022-05-26 13:33 ` LI Qingwu
  2022-05-26 13:33 ` [PATCH V5 4/6] iio: accel: bmi088: Add support for bmi085 accel LI Qingwu
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: LI Qingwu @ 2022-05-26 13:33 UTC (permalink / raw)
  To: jic23, lars, mchehab+huawei, ardeleanalex, linux-iio,
	linux-kernel, Qing-wu.Li, robh+dt, mike.looijmans, devicetree
  Cc: 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 73c1e2aecd7e..f6e44b36f5fc 100644
--- a/drivers/iio/accel/bmi088-accel-core.c
+++ b/drivers/iio/accel/bmi088-accel-core.c
@@ -389,6 +389,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;
@@ -464,8 +465,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),
@@ -484,12 +485,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);
 
@@ -515,22 +519,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;
@@ -545,13 +550,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 06d99d9949f3..c77aec01bc67 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 void bmi088_accel_remove(struct spi_device *spi)
@@ -61,8 +61,14 @@ static void bmi088_accel_remove(struct spi_device *spi)
 	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 5d40c7cf1cbc..65338a1bf97d 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);
 void bmi088_accel_core_remove(struct device *dev);
 
 #endif /* BMI088_ACCEL_H */
-- 
2.25.1


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

* [PATCH V5 4/6] iio: accel: bmi088: Add support for bmi085 accel
  2022-05-26 13:33 [PATCH V5 0/6] iio: accel: bmi088: support BMI085 BMI090L LI Qingwu
                   ` (2 preceding siblings ...)
  2022-05-26 13:33 ` [PATCH V5 3/6] iio: accel: bmi088: modified the device name LI Qingwu
@ 2022-05-26 13:33 ` LI Qingwu
  2022-05-26 13:33 ` [PATCH V5 5/6] iio: accel: bmi088: Add support for bmi090l accel LI Qingwu
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: LI Qingwu @ 2022-05-26 13:33 UTC (permalink / raw)
  To: jic23, lars, mchehab+huawei, ardeleanalex, linux-iio,
	linux-kernel, Qing-wu.Li, robh+dt, mike.looijmans, devicetree
  Cc: 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.
Unlike BMI088, the BMI085 accelerometer ranges are +/-2, 4, 6,
and 8g, the scales are calculated as 9.8/32768*pow(2,reg41+1).

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 f6e44b36f5fc..f6ecb081456b 100644
--- a/drivers/iio/accel/bmi088-accel-core.c
+++ b/drivers/iio/accel/bmi088-accel-core.c
@@ -465,6 +465,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 c77aec01bc67..b14a1e5b986a 100644
--- a/drivers/iio/accel/bmi088-accel-spi.c
+++ b/drivers/iio/accel/bmi088-accel-spi.c
@@ -62,12 +62,14 @@ static void 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 65338a1bf97d..044999eb4fd6 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] 11+ messages in thread

* [PATCH V5 5/6] iio: accel: bmi088: Add support for bmi090l accel
  2022-05-26 13:33 [PATCH V5 0/6] iio: accel: bmi088: support BMI085 BMI090L LI Qingwu
                   ` (3 preceding siblings ...)
  2022-05-26 13:33 ` [PATCH V5 4/6] iio: accel: bmi088: Add support for bmi085 accel LI Qingwu
@ 2022-05-26 13:33 ` LI Qingwu
  2022-05-26 13:33 ` [PATCH V5 6/6] dt-bindings: iio: accel: Add bmi085 and bmi090l bindings LI Qingwu
  2022-06-03 15:51 ` [PATCH V5 0/6] iio: accel: bmi088: support BMI085 BMI090L Jonathan Cameron
  6 siblings, 0 replies; 11+ messages in thread
From: LI Qingwu @ 2022-05-26 13:33 UTC (permalink / raw)
  To: jic23, lars, mchehab+huawei, ardeleanalex, linux-iio,
	linux-kernel, Qing-wu.Li, robh+dt, mike.looijmans, devicetree
  Cc: 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 f6ecb081456b..a4e95cf63fab 100644
--- a/drivers/iio/accel/bmi088-accel-core.c
+++ b/drivers/iio/accel/bmi088-accel-core.c
@@ -479,6 +479,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, 1794}, {0, 3589}, {0, 7178}},
 	},
+	[BOSCH_BMI090L] = {
+		.name = "bmi090l-accel",
+		.chip_id = 0x1A,
+		.channels = bmi088_accel_channels,
+		.num_channels = ARRAY_SIZE(bmi088_accel_channels),
+		.scale_table = {{0, 897}, {0, 1794}, {0, 3589}, {0, 7178}},
+	},
 };
 
 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 b14a1e5b986a..8aa25138f098 100644
--- a/drivers/iio/accel/bmi088-accel-spi.c
+++ b/drivers/iio/accel/bmi088-accel-spi.c
@@ -64,6 +64,7 @@ static void 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 044999eb4fd6..80cd396a3141 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] 11+ messages in thread

* [PATCH V5 6/6] dt-bindings: iio: accel: Add bmi085 and bmi090l bindings
  2022-05-26 13:33 [PATCH V5 0/6] iio: accel: bmi088: support BMI085 BMI090L LI Qingwu
                   ` (4 preceding siblings ...)
  2022-05-26 13:33 ` [PATCH V5 5/6] iio: accel: bmi088: Add support for bmi090l accel LI Qingwu
@ 2022-05-26 13:33 ` LI Qingwu
  2022-06-02 13:57   ` Rob Herring
  2022-06-03 15:51 ` [PATCH V5 0/6] iio: accel: bmi088: support BMI085 BMI090L Jonathan Cameron
  6 siblings, 1 reply; 11+ messages in thread
From: LI Qingwu @ 2022-05-26 13:33 UTC (permalink / raw)
  To: jic23, lars, mchehab+huawei, ardeleanalex, linux-iio,
	linux-kernel, Qing-wu.Li, robh+dt, mike.looijmans, devicetree
  Cc: 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] 11+ messages in thread

* Re: [PATCH V5 6/6] dt-bindings: iio: accel: Add bmi085 and bmi090l bindings
  2022-05-26 13:33 ` [PATCH V5 6/6] dt-bindings: iio: accel: Add bmi085 and bmi090l bindings LI Qingwu
@ 2022-06-02 13:57   ` Rob Herring
  2022-06-03  7:32     ` LI Qingwu
  0 siblings, 1 reply; 11+ messages in thread
From: Rob Herring @ 2022-06-02 13:57 UTC (permalink / raw)
  To: LI Qingwu
  Cc: jic23, lars, mchehab+huawei, ardeleanalex, linux-iio,
	linux-kernel, mike.looijmans, devicetree, thomas.haemmerle

On Thu, May 26, 2022 at 01:33:59PM +0000, LI Qingwu wrote:
> 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

blank line here. These aren't part of the tags.

With that,

Acked-by: Rob Herring <robh@kernel.org>

> 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	[flat|nested] 11+ messages in thread

* RE: [PATCH V5 6/6] dt-bindings: iio: accel: Add bmi085 and bmi090l bindings
  2022-06-02 13:57   ` Rob Herring
@ 2022-06-03  7:32     ` LI Qingwu
  2022-06-03 15:38       ` Jonathan Cameron
  0 siblings, 1 reply; 11+ messages in thread
From: LI Qingwu @ 2022-06-03  7:32 UTC (permalink / raw)
  To: Rob Herring
  Cc: jic23, lars, mchehab+huawei, ardeleanalex, linux-iio,
	linux-kernel, mike.looijmans, devicetree, HAEMMERLE Thomas



> -----Original Message-----
> From: Rob Herring <robh@kernel.org>
> Sent: Thursday, June 2, 2022 9:58 PM
> To: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
> Cc: jic23@kernel.org; lars@metafoo.de; mchehab+huawei@kernel.org;
> ardeleanalex@gmail.com; linux-iio@vger.kernel.org;
> linux-kernel@vger.kernel.org; mike.looijmans@topic.nl;
> devicetree@vger.kernel.org; HAEMMERLE Thomas
> <thomas.haemmerle@leica-geosystems.com>
> Subject: Re: [PATCH V5 6/6] dt-bindings: iio: accel: Add bmi085 and bmi090l
> bindings
> 
> This email is not from Hexagon's Office 365 instance. Please be careful while
> clicking links, opening attachments, or replying to this email.
> 
> 
> On Thu, May 26, 2022 at 01:33:59PM +0000, LI Qingwu wrote:
> > Adds the device-tree bindings for the Bosch
> > BMI085 and BMI090L IMU, the accelerometer part.
> >
> > Datasheet:
> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.bos
> ch-sensortec.com%2Fmedia%2Fboschsensortec%2Fdownloads%2Fdatasheets%
> 2Fbst-bmi085-ds001.pdf&amp;data=05%7C01%7C%7C6bb7d63d627c49b946c4
> 08da449fd9bf%7C1b16ab3eb8f64fe39f3e2db7fe549f6a%7C0%7C0%7C6378977
> 51065729986%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjo
> iV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdat
> a=K3PYyQAGsySCIjKuo1QRVm1HE0cuC3BVXbjuAwwhMjM%3D&amp;reserved=
> 0
> > Datasheet:
> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmedia.di
> gikey.com%2Fpdf%2FData%2520Sheets%2FBosch%2FBST-BMI090L-DS000-00.p
> df&amp;data=05%7C01%7C%7C6bb7d63d627c49b946c408da449fd9bf%7C1b1
> 6ab3eb8f64fe39f3e2db7fe549f6a%7C0%7C0%7C637897751065729986%7CUnk
> nown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1h
> aWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=8GfqaDLkn5whi%2F
> bsEH9UATPNkJVgsy859sIifJGv%2BHg%3D&amp;reserved=0
> 
> blank line here. These aren't part of the tags.
Thank you, Rob, I did check, the most datasheets are part of the tags,
and few of them has a blank line, do you agree to keep it?
> 
> With that,
> 
> Acked-by: Rob Herring <robh@kernel.org>
> 
> > 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	[flat|nested] 11+ messages in thread

* Re: [PATCH V5 6/6] dt-bindings: iio: accel: Add bmi085 and bmi090l bindings
  2022-06-03  7:32     ` LI Qingwu
@ 2022-06-03 15:38       ` Jonathan Cameron
  0 siblings, 0 replies; 11+ messages in thread
From: Jonathan Cameron @ 2022-06-03 15:38 UTC (permalink / raw)
  To: LI Qingwu
  Cc: Rob Herring, lars, mchehab+huawei, ardeleanalex, linux-iio,
	linux-kernel, mike.looijmans, devicetree, HAEMMERLE Thomas,
	Andy Shevchenko

On Fri, 3 Jun 2022 07:32:17 +0000
LI Qingwu <qing-wu.li@leica-geosystems.com.cn> wrote:

> > -----Original Message-----
> > From: Rob Herring <robh@kernel.org>
> > Sent: Thursday, June 2, 2022 9:58 PM
> > To: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
> > Cc: jic23@kernel.org; lars@metafoo.de; mchehab+huawei@kernel.org;
> > ardeleanalex@gmail.com; linux-iio@vger.kernel.org;
> > linux-kernel@vger.kernel.org; mike.looijmans@topic.nl;
> > devicetree@vger.kernel.org; HAEMMERLE Thomas
> > <thomas.haemmerle@leica-geosystems.com>
> > Subject: Re: [PATCH V5 6/6] dt-bindings: iio: accel: Add bmi085 and bmi090l
> > bindings
> > 
> > This email is not from Hexagon's Office 365 instance. Please be careful while
> > clicking links, opening attachments, or replying to this email.
> > 
> > 
> > On Thu, May 26, 2022 at 01:33:59PM +0000, LI Qingwu wrote:  
> > > Adds the device-tree bindings for the Bosch
> > > BMI085 and BMI090L IMU, the accelerometer part.
> > >
> > > Datasheet:  
> > https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.bos
> > ch-sensortec.com%2Fmedia%2Fboschsensortec%2Fdownloads%2Fdatasheets%
> > 2Fbst-bmi085-ds001.pdf&amp;data=05%7C01%7C%7C6bb7d63d627c49b946c4
> > 08da449fd9bf%7C1b16ab3eb8f64fe39f3e2db7fe549f6a%7C0%7C0%7C6378977
> > 51065729986%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjo
> > iV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdat
> > a=K3PYyQAGsySCIjKuo1QRVm1HE0cuC3BVXbjuAwwhMjM%3D&amp;reserved=
> > 0  
> > > Datasheet:  
> > https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmedia.di
> > gikey.com%2Fpdf%2FData%2520Sheets%2FBosch%2FBST-BMI090L-DS000-00.p
> > df&amp;data=05%7C01%7C%7C6bb7d63d627c49b946c408da449fd9bf%7C1b1
> > 6ab3eb8f64fe39f3e2db7fe549f6a%7C0%7C0%7C637897751065729986%7CUnk
> > nown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1h
> > aWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=8GfqaDLkn5whi%2F
> > bsEH9UATPNkJVgsy859sIifJGv%2BHg%3D&amp;reserved=0
> > 
> > blank line here. These aren't part of the tags.  
> Thank you, Rob, I did check, the most datasheets are part of the tags,
> and few of them has a blank line, do you agree to keep it?

Seems we have some disagreement on this.  Personally I thought they'd been
adopted as a standard tag block entry, though I can't immediately find
a clear statement of that. 

+CC Andy who has commented on this before.


> > 
> > With that,
> > 
> > Acked-by: Rob Herring <robh@kernel.org>
> >   
> > > 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	[flat|nested] 11+ messages in thread

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

On Thu, 26 May 2022 13:33:53 +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 v5: 
> - Fix the issue of 'undeclared function FIELD_GET'
>   Reported-by: kernel test robot <lkp@intel.com>

I've applied this series to the togreg branch of iio.git and pushed
out as testing.

Note I can rebase that tree still (and will do anyway to move to
rc1 or so once available) so we can resolve that question of
whether Datasheet is a tag or not in parallel with letting 0-day
see if it can find anything else we missed.

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         | 97 +++++++++++++++----
>  drivers/iio/accel/bmi088-accel-spi.c          | 17 +++-
>  drivers/iio/accel/bmi088-accel.h              |  9 +-
>  4 files changed, 101 insertions(+), 24 deletions(-)
> 


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

end of thread, other threads:[~2022-06-03 15:42 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-26 13:33 [PATCH V5 0/6] iio: accel: bmi088: support BMI085 BMI090L LI Qingwu
2022-05-26 13:33 ` [PATCH V5 1/6] iio: accel: bmi088: Modified the scale calculate LI Qingwu
2022-05-26 13:33 ` [PATCH V5 2/6] iio: accel: bmi088: Make it possible to config scales LI Qingwu
2022-05-26 13:33 ` [PATCH V5 3/6] iio: accel: bmi088: modified the device name LI Qingwu
2022-05-26 13:33 ` [PATCH V5 4/6] iio: accel: bmi088: Add support for bmi085 accel LI Qingwu
2022-05-26 13:33 ` [PATCH V5 5/6] iio: accel: bmi088: Add support for bmi090l accel LI Qingwu
2022-05-26 13:33 ` [PATCH V5 6/6] dt-bindings: iio: accel: Add bmi085 and bmi090l bindings LI Qingwu
2022-06-02 13:57   ` Rob Herring
2022-06-03  7:32     ` LI Qingwu
2022-06-03 15:38       ` Jonathan Cameron
2022-06-03 15:51 ` [PATCH V5 0/6] iio: accel: bmi088: support BMI085 BMI090L Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).