iio: accel: bmc150: Add support for BMA253/BMA254
Subsystems (2)
v3 cover iio: accel: bmc150: Add support for BMA253/BMA254
The Bosch BMA253 accelerometer is very similar to both BMA254 and BMA255. The current situation is very confusing: BMA254 is supported by the bma180 driver, but BMA255 is supported by the bmc150-accel driver.
It turns out the bma180 and bmc150-accel drivers have quite some overlap, and BMA253/BMA254 would be a bit better supported in bmc150-accel (which has support for the motion trigger/interrupt).
This series adds BMA253 support to bmc150-accel and also moves BMA254 over to bmc150, removing some unnecessary code from the bma180 driver.
In v2 I also sneaked in a small fix for the scale table of BMA222 to simplify backporting for the stable people.
---
Changes in v3:
- Add new "iio: accel: bmc150: Clarify combo modules in Kconfig" patch
- Sort "one-line" chip name lists as well, not just multi-line ones
v2: https://lore.kernel.org/linux-iio/[email protected]/
Changes in v2:
- Add new "iio: accel: bmc150: Fix bma222 scale unit" patch at the beginning so the stable people can backport it without conflicts
- Add Reviewed-by: from Hans and Andy for all previous patches
- Add patch 3 and 4 to have all the chip lists in a consistent order
- Fix last patch to also drop BMA254 from the file header in bma180.c
v1: https://lore.kernel.org/linux-iio/[email protected]/
Stephan Gerhold (10):
iio: accel: bmc150: Fix bma222 scale unit
iio: accel: bmc150: Clarify combo modules in Kconfig
iio: accel: bmc150: Drop misleading/duplicate chip identifiers
iio: accel: bmc150: Drop duplicated documentation of supported chips
iio: accel: bmc150: Sort all chip names alphabetically / by chip ID
dt-bindings: iio: accel: bma255: Document bosch,bma253
iio: accel: bmc150: Add device IDs for BMA253
dt-bindings: iio: bma255: Allow multiple interrupts
dt-bindings: iio: accel: bma180/bma255: Move bma254 to bma255 schema
iio: accel: bma180/bmc150: Move BMA254 to bmc150-accel driver
.../bindings/iio/accel/bosch,bma180.yaml | 3 +- .../bindings/iio/accel/bosch,bma255.yaml | 9 +- drivers/iio/accel/Kconfig | 11 ++- drivers/iio/accel/bma180.c | 92 +++---------------- drivers/iio/accel/bmc150-accel-core.c | 87 ++++++------------ drivers/iio/accel/bmc150-accel-i2c.c | 52 +++++------ drivers/iio/accel/bmc150-accel-spi.c | 31 ++++--- drivers/iio/accel/bmc150-accel.h | 10 -- 8 files changed, 98 insertions(+), 197 deletions(-)
Signature · 1 line
2.32.0
PATCH v3 1/10 iio: accel: bmc150: Fix bma222 scale unit
According to sysfs-bus-iio documentation the unit for accelerometer values after applying scale/offset should be m/s^2, not g, which explains why the scale values for the other variants in bmc150-accel do not match exactly the values given in the datasheet.
To get the correct values, we need to multiply the BMA222 scale values by g = 9.80665 m/s^2.
---
Added this patch in v2 to avoid conflicts later in case this should be backported to a stable kernel.
--- drivers/iio/accel/bmc150-accel-core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/iio/accel/bmc150-accel-core.c +5 -4
@@ -1145,11 +1145,12 @@ static const struct bmc150_accel_chip_info bmc150_accel_chip_info_tbl[] = {/* * The datasheet page 17 says: * 15.6, 31.3, 62.5 and 125 mg per LSB. +* IIO unit is m/s^2 so multiply by g = 9.80665 m/s^2. */ - .scale_table = { {156000, BMC150_ACCEL_DEF_RANGE_2G}, - {313000, BMC150_ACCEL_DEF_RANGE_4G}, - {625000, BMC150_ACCEL_DEF_RANGE_8G}, - {1250000, BMC150_ACCEL_DEF_RANGE_16G} }, + .scale_table = { {152984, BMC150_ACCEL_DEF_RANGE_2G}, + {306948, BMC150_ACCEL_DEF_RANGE_4G}, + {612916, BMC150_ACCEL_DEF_RANGE_8G}, + {1225831, BMC150_ACCEL_DEF_RANGE_16G} }, }, [bma222e] = { .name = "BMA222E",
Signature · 1 line
2.32.0
PATCH v3 2/10 iio: accel: bmc150: Clarify combo modules in Kconfig
In reply to Stephan GerholdThe Kconfig option currently says that all Bosch accelerometers supported by the bmc150-accel driver are combo chips with both accelerometer and magnetometer. This is wrong: actually only BMC150 is such a combo. The BMA* variants only contain an accelerometer and the BMI055 actually is a accelerometer + gyroscope combo.
Clarify this in the help text and also make the list of supported variants complete and sorted for consistency.
---
New patch in v3 after discussion in
[PATCH v2 4/9] iio: accel: bmc150: Sort all chip names alphabetically / by chip ID
--- drivers/iio/accel/Kconfig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iio/accel/Kconfig +5 -2
@@ -143,9 +143,12 @@ config BMC150_ACCEL select BMC150_ACCEL_SPI if SPI help Say yes here to build support for the following Bosch accelerometers: - BMC150, BMI055, BMA250E, BMA222E, BMA255, BMA280. + BMA222, BMA222E, BMA250E, BMA255, BMA280, BMC150, BMI055. + + Note that some of these are combo modules: + - BMC150: accelerometer and magnetometer + - BMI055: accelerometer and gyroscope - This is a combo module with both accelerometer and magnetometer. This driver is only implementing accelerometer part, which has its own address and register map.
Signature · 1 line
2.32.0
PATCH v3 3/10 iio: accel: bmc150: Drop misleading/duplicate chip identifiers
In reply to Stephan GerholdCommit 0ad4bf370176 ("iio:accel:bmc150-accel: Use the chip ID to detect sensor variant") stopped using the I2C/ACPI match data to look up the bmc150_accel_chip_info. However, the bmc150_accel_chip_info_tbl remained as-is, with multiple entries with the same chip_id (e.g. 0xFA for BMC150/BMI055/BMA255). This is redundant now because actually the driver will always select the first entry with a matching chip_id.
So even if a device probes e.g. with BMA0255 it will end up using the chip_info for BMC150. And in general that's fine for now, the entries for BMC150/BMI055/BMA255 were exactly the same anyway (except for the name, which is replaced with the more accurate one later).
But in this case it's misleading because it suggests that one should add even more entries with the same chip_id when adding support for new variants. Let's make that more clear by removing the enum with the chip identifiers entirely and instead have only one entry per chip_id.
Note that we may need to bring back some mechanism to differentiate between different chips with the same chip_id in the future. For example, BMA250 (currently supported by the bma180 driver) has the same chip_id = 0x03 as BMA222 even though they have different channel sizes (8 bits vs 10 bits). But in any case, that mechanism would need to look quite different from what we have right now.
---
Changes in v3: Sort combined chip names in chip info table
--- drivers/iio/accel/bmc150-accel-core.c | 34 ++++++--------------------- drivers/iio/accel/bmc150-accel-i2c.c | 30 +++++++++++------------ drivers/iio/accel/bmc150-accel-spi.c | 30 +++++++++++------------ drivers/iio/accel/bmc150-accel.h | 10 -------- 4 files changed, 37 insertions(+), 67 deletions(-)
drivers/iio/accel/bmc150-accel-core.c +7 -27
@@ -1097,28 +1097,8 @@ static const struct iio_chan_spec bma280_accel_channels[] =BMC150_ACCEL_CHANNELS (14 );static const struct bmc150_accel_chip_info bmc150_accel_chip_info_tbl[] = { - [bmc150] = { - .name ="BMC150A" , - .chip_id =0xFA , - .channels = bmc150_accel_channels, - .num_channels =ARRAY_SIZE (bmc150_accel_channels), - .scale_table = { {9610 ,BMC150_ACCEL_DEF_RANGE_2G }, - {19122 ,BMC150_ACCEL_DEF_RANGE_4G }, - {38344 ,BMC150_ACCEL_DEF_RANGE_8G }, - {76590 ,BMC150_ACCEL_DEF_RANGE_16G } }, - }, - [bmi055] = { - .name ="BMI055A" , - .chip_id =0xFA , - .channels = bmc150_accel_channels, - .num_channels =ARRAY_SIZE (bmc150_accel_channels), - .scale_table = { {9610 ,BMC150_ACCEL_DEF_RANGE_2G }, - {19122 ,BMC150_ACCEL_DEF_RANGE_4G }, - {38344 ,BMC150_ACCEL_DEF_RANGE_8G }, - {76590 ,BMC150_ACCEL_DEF_RANGE_16G } }, - }, - [bma255] = { - .name ="BMA0255" , + { + .name ="BMA255/BMC150/BMI055" , .chip_id =0xFA , .channels = bmc150_accel_channels, .num_channels =ARRAY_SIZE (bmc150_accel_channels),
@@ -1127,7 +1107,7 @@ static const struct bmc150_accel_chip_info bmc150_accel_chip_info_tbl[] = { {38344, BMC150_ACCEL_DEF_RANGE_8G}, {76590, BMC150_ACCEL_DEF_RANGE_16G} }, }, - [bma250e] = { + { .name = "BMA250E", .chip_id = 0xF9, .channels = bma250e_accel_channels,
@@ -1137,7 +1117,7 @@ static const struct bmc150_accel_chip_info bmc150_accel_chip_info_tbl[] = { {153277, BMC150_ACCEL_DEF_RANGE_8G}, {306457, BMC150_ACCEL_DEF_RANGE_16G} }, }, - [bma222] = { + { .name = "BMA222", .chip_id = 0x03, .channels = bma222e_accel_channels,
@@ -1152,7 +1132,7 @@ static const struct bmc150_accel_chip_info bmc150_accel_chip_info_tbl[] = { {612916, BMC150_ACCEL_DEF_RANGE_8G}, {1225831, BMC150_ACCEL_DEF_RANGE_16G} }, }, - [bma222e] = { + { .name = "BMA222E", .chip_id = 0xF8, .channels = bma222e_accel_channels,
@@ -1162,8 +1142,8 @@ static const struct bmc150_accel_chip_info bmc150_accel_chip_info_tbl[] = { {612915, BMC150_ACCEL_DEF_RANGE_8G}, {1225831, BMC150_ACCEL_DEF_RANGE_16G} }, }, - [bma280] = { - .name ="BMA0280" , + { + .name = "BMA280", .chip_id = 0xFB, .channels = bma280_accel_channels, .num_channels = ARRAY_SIZE(bma280_accel_channels),
drivers/iio/accel/bmc150-accel-i2c.c +15 -15
@@ -221,14 +221,14 @@ static int bmc150_accel_remove(struct i2c_client *client) }static const struct acpi_device_id bmc150_accel_acpi_match[] = { - {"BSBA0150" , bmc150}, - {"BMC150A" , bmc150}, - {"BMI055A" , bmi055}, - {"BMA0255" , bma255}, - {"BMA250E" , bma250e}, - {"BMA222" , bma222}, - {"BMA222E" , bma222e}, - {"BMA0280" , bma280}, + {"BSBA0150" }, + {"BMC150A" }, + {"BMI055A" }, + {"BMA0255" }, + {"BMA250E" }, + {"BMA222" }, + {"BMA222E" }, + {"BMA0280" }, {"BOSC0200" }, {"DUAL250E" }, { },
@@ -236,13 +236,13 @@ static const struct acpi_device_id bmc150_accel_acpi_match[] = {MODULE_DEVICE_TABLE (acpi, bmc150_accel_acpi_match);static const struct i2c_device_id bmc150_accel_id[] = { - {"bmc150_accel" , bmc150}, - {"bmi055_accel" , bmi055}, - {"bma255" , bma255}, - {"bma250e" , bma250e}, - {"bma222" , bma222}, - {"bma222e" , bma222e}, - {"bma280" , bma280}, + {"bmc150_accel" }, + {"bmi055_accel" }, + {"bma255" }, + {"bma250e" }, + {"bma222" }, + {"bma222e" }, + {"bma280" }, {} };
drivers/iio/accel/bmc150-accel-spi.c +15 -15
@@ -34,26 +34,26 @@ static int bmc150_accel_remove(struct spi_device *spi) }static const struct acpi_device_id bmc150_accel_acpi_match[] = { - {"BSBA0150" , bmc150}, - {"BMC150A" , bmc150}, - {"BMI055A" , bmi055}, - {"BMA0255" , bma255}, - {"BMA250E" , bma250e}, - {"BMA222" , bma222}, - {"BMA222E" , bma222e}, - {"BMA0280" , bma280}, + {"BSBA0150" }, + {"BMC150A" }, + {"BMI055A" }, + {"BMA0255" }, + {"BMA250E" }, + {"BMA222" }, + {"BMA222E" }, + {"BMA0280" }, { }, };MODULE_DEVICE_TABLE (acpi, bmc150_accel_acpi_match);static const struct spi_device_id bmc150_accel_id[] = { - {"bmc150_accel" , bmc150}, - {"bmi055_accel" , bmi055}, - {"bma255" , bma255}, - {"bma250e" , bma250e}, - {"bma222" , bma222}, - {"bma222e" , bma222e}, - {"bma280" , bma280}, + {"bmc150_accel" }, + {"bmi055_accel" }, + {"bma255" }, + {"bma250e" }, + {"bma222" }, + {"bma222e" }, + {"bma280" }, {} };MODULE_DEVICE_TABLE (spi, bmc150_accel_id);
drivers/iio/accel/bmc150-accel.h +0 -10
@@ -68,16 +68,6 @@ struct bmc150_accel_data {struct iio_mount_matrix orientation; }; -enum { - bmc150, - bmi055, - bma255, - bma250e, - bma222, - bma222e, - bma280, -}; -int bmc150_accel_core_probe (struct device *dev,struct regmap *regmap,int irq,const char *name,bool block_supported);int bmc150_accel_core_remove (struct device *dev);
Signature · 1 line
2.32.0
PATCH v3 4/10 iio: accel: bmc150: Drop duplicated documentation of supported chips
In reply to Stephan GerholdThe chips supported by the bmc150-accel driver are clearly documented in Kconfig, in the bmc150_accel_chip_info_tbl as well as in all the device ID tables in the I2C/SPI drivers. It's easy to forget to update the lists in the file header. Drop those entirely to reduce the amount of changes required to add new chip variants.
---
Changes in v3: Add Andy's Reviewed-by
New patch in v2. Originally I tried to reorder those too but then it caused conflicts in all my following patches so I'm not convinced it's worth to try and keep those up to date.
--- drivers/iio/accel/bmc150-accel-core.c | 10 +--------- drivers/iio/accel/bmc150-accel-i2c.c | 10 +--------- 2 files changed, 2 insertions(+), 18 deletions(-)
drivers/iio/accel/bmc150-accel-core.c +1 -9
@@ -1,14 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* 3-axis accelerometer driver supporting following Bosch-Sensortec chips: -* - BMC150 -* - BMI055 -* - BMA255 -* - BMA250E -* - BMA222 -* - BMA222E -* - BMA280 -* +* 3-axis accelerometer driver supporting many Bosch-Sensortec chips * Copyright (c) 2014, Intel Corporation. */
drivers/iio/accel/bmc150-accel-i2c.c +1 -9
@@ -1,14 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* 3-axis accelerometer driver supporting following I2C Bosch-Sensortec chips: -* - BMC150 -* - BMI055 -* - BMA255 -* - BMA250E -* - BMA222 -* - BMA222E -* - BMA280 -* +* 3-axis accelerometer driver supporting many I2C Bosch-Sensortec chips * Copyright (c) 2014, Intel Corporation. */
Signature · 1 line
2.32.0
PATCH v3 5/10 iio: accel: bmc150: Sort all chip names alphabetically / by chip ID
In reply to Stephan GerholdRight now all the device IDs are listed in seemingly random order, make this consistent by ordering those alphabetically. Also, order bmc150_accel_chip_info_tbl by chip ID for the same reason.
---
Changes in v3: Move Kconfig changes into extra patch to clarify
which chips are combos
New patch in v2.
--- drivers/iio/accel/bmc150-accel-core.c | 40 +++++++++++++-------------- drivers/iio/accel/bmc150-accel-i2c.c | 26 ++++++++--------- drivers/iio/accel/bmc150-accel-spi.c | 18 ++++++------ 3 files changed, 42 insertions(+), 42 deletions(-)
drivers/iio/accel/bmc150-accel-core.c +20 -20
@@ -1089,26 +1089,6 @@ static const struct iio_chan_spec bma280_accel_channels[] =BMC150_ACCEL_CHANNELS (14 );static const struct bmc150_accel_chip_info bmc150_accel_chip_info_tbl[] = { - { - .name ="BMA255/BMC150/BMI055" , - .chip_id =0xFA , - .channels = bmc150_accel_channels, - .num_channels =ARRAY_SIZE (bmc150_accel_channels), - .scale_table = { {9610 ,BMC150_ACCEL_DEF_RANGE_2G }, - {19122 ,BMC150_ACCEL_DEF_RANGE_4G }, - {38344 ,BMC150_ACCEL_DEF_RANGE_8G }, - {76590 ,BMC150_ACCEL_DEF_RANGE_16G } }, - }, - { - .name ="BMA250E" , - .chip_id =0xF9 , - .channels = bma250e_accel_channels, - .num_channels =ARRAY_SIZE (bma250e_accel_channels), - .scale_table = { {38344 ,BMC150_ACCEL_DEF_RANGE_2G }, - {76590 ,BMC150_ACCEL_DEF_RANGE_4G }, - {153277 ,BMC150_ACCEL_DEF_RANGE_8G }, - {306457 ,BMC150_ACCEL_DEF_RANGE_16G } }, - }, { .name ="BMA222" , .chip_id =0x03 ,
@@ -1134,6 +1114,26 @@ static const struct bmc150_accel_chip_info bmc150_accel_chip_info_tbl[] = { {612915, BMC150_ACCEL_DEF_RANGE_8G}, {1225831, BMC150_ACCEL_DEF_RANGE_16G} }, }, + { + .name = "BMA250E", + .chip_id = 0xF9, + .channels = bma250e_accel_channels, + .num_channels = ARRAY_SIZE(bma250e_accel_channels), + .scale_table = { {38344, BMC150_ACCEL_DEF_RANGE_2G}, + {76590, BMC150_ACCEL_DEF_RANGE_4G}, + {153277, BMC150_ACCEL_DEF_RANGE_8G}, + {306457, BMC150_ACCEL_DEF_RANGE_16G} }, + }, + { + .name = "BMA255/BMC150/BMI055", + .chip_id = 0xFA, + .channels = bmc150_accel_channels, + .num_channels = ARRAY_SIZE(bmc150_accel_channels), + .scale_table = { {9610, BMC150_ACCEL_DEF_RANGE_2G}, + {19122, BMC150_ACCEL_DEF_RANGE_4G}, + {38344, BMC150_ACCEL_DEF_RANGE_8G}, + {76590, BMC150_ACCEL_DEF_RANGE_16G} }, + }, { .name = "BMA280", .chip_id = 0xFB,
drivers/iio/accel/bmc150-accel-i2c.c +13 -13
@@ -213,41 +213,41 @@ static int bmc150_accel_remove(struct i2c_client *client) }static const struct acpi_device_id bmc150_accel_acpi_match[] = { - {"BSBA0150" }, - {"BMC150A" }, - {"BMI055A" }, {"BMA0255" }, - {"BMA250E" }, + {"BMA0280" }, {"BMA222" }, {"BMA222E" }, - {"BMA0280" }, + {"BMA250E" }, + {"BMC150A" }, + {"BMI055A" }, {"BOSC0200" }, + {"BSBA0150" }, {"DUAL250E" }, { }, };MODULE_DEVICE_TABLE (acpi, bmc150_accel_acpi_match);static const struct i2c_device_id bmc150_accel_id[] = { - {"bmc150_accel" }, - {"bmi055_accel" }, - {"bma255" }, - {"bma250e" }, {"bma222" }, {"bma222e" }, + {"bma250e" }, + {"bma255" }, {"bma280" }, + {"bmc150_accel" }, + {"bmi055_accel" }, {} };MODULE_DEVICE_TABLE (i2c, bmc150_accel_id);static const struct of_device_id bmc150_accel_of_match[] = { - { .compatible ="bosch,bmc150_accel" }, - { .compatible ="bosch,bmi055_accel" }, - { .compatible ="bosch,bma255" }, - { .compatible ="bosch,bma250e" }, { .compatible ="bosch,bma222" }, { .compatible ="bosch,bma222e" }, + { .compatible ="bosch,bma250e" }, + { .compatible ="bosch,bma255" }, { .compatible ="bosch,bma280" }, + { .compatible ="bosch,bmc150_accel" }, + { .compatible ="bosch,bmi055_accel" }, { }, };MODULE_DEVICE_TABLE (of, bmc150_accel_of_match);
drivers/iio/accel/bmc150-accel-spi.c +9 -9
@@ -34,26 +34,26 @@ static int bmc150_accel_remove(struct spi_device *spi) }static const struct acpi_device_id bmc150_accel_acpi_match[] = { - {"BSBA0150" }, - {"BMC150A" }, - {"BMI055A" }, {"BMA0255" }, - {"BMA250E" }, + {"BMA0280" }, {"BMA222" }, {"BMA222E" }, - {"BMA0280" }, + {"BMA250E" }, + {"BMC150A" }, + {"BMI055A" }, + {"BSBA0150" }, { }, };MODULE_DEVICE_TABLE (acpi, bmc150_accel_acpi_match);static const struct spi_device_id bmc150_accel_id[] = { - {"bmc150_accel" }, - {"bmi055_accel" }, - {"bma255" }, - {"bma250e" }, {"bma222" }, {"bma222e" }, + {"bma250e" }, + {"bma255" }, {"bma280" }, + {"bmc150_accel" }, + {"bmi055_accel" }, {} };MODULE_DEVICE_TABLE (spi, bmc150_accel_id);
Signature · 1 line
2.32.0
PATCH v3 6/10 dt-bindings: iio: accel: bma255: Document bosch,bma253
In reply to Stephan GerholdBMA253 is mostly like BMA255 that is already supported by the bmc150-accel driver. Document an extra bosch,bma253 compatible for it.
--- Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml +1 -0
@@ -18,6 +18,7 @@ properties: enum: - bosch,bmc150_accel - bosch,bmi055_accel + - bosch,bma253 - bosch,bma255 - bosch,bma250e - bosch,bma222
Signature · 1 line
2.32.0
PATCH v3 7/10 iio: accel: bmc150: Add device IDs for BMA253
In reply to Stephan GerholdBMA253 is mostly like BMA255 and has exactly the same register layout as used by the bmc150-accel driver as far I can tell. Making it work is as simple as adding new device IDs for it since it has the same chip_id = 0xFA (250) as BMA255 and others.
--- drivers/iio/accel/Kconfig | 2 +- drivers/iio/accel/bmc150-accel-core.c | 2 +- drivers/iio/accel/bmc150-accel-i2c.c | 2 ++ drivers/iio/accel/bmc150-accel-spi.c | 1 + 4 files changed, 5 insertions(+), 2 deletions(-)
drivers/iio/accel/Kconfig +1 -1
@@ -143,7 +143,7 @@ config BMC150_ACCEL select BMC150_ACCEL_SPI if SPI help Say yes here to build support for the following Bosch accelerometers: - BMA222, BMA222E, BMA250E, BMA255, BMA280, BMC150, BMI055. + BMA222, BMA222E, BMA250E, BMA253, BMA255, BMA280, BMC150, BMI055. Note that some of these are combo modules: - BMC150: accelerometer and magnetometer
drivers/iio/accel/bmc150-accel-core.c +1 -1
@@ -1125,7 +1125,7 @@ static const struct bmc150_accel_chip_info bmc150_accel_chip_info_tbl[] = { {306457, BMC150_ACCEL_DEF_RANGE_16G} }, }, { - .name = "BMA255/BMC150/BMI055", + .name = "BMA253/BMA255/BMC150/BMI055", .chip_id = 0xFA, .channels = bmc150_accel_channels, .num_channels = ARRAY_SIZE(bmc150_accel_channels),
drivers/iio/accel/bmc150-accel-i2c.c +2 -0
@@ -231,6 +231,7 @@ static const struct i2c_device_id bmc150_accel_id[] = { {"bma222"}, {"bma222e"}, {"bma250e"}, + {"bma253"}, {"bma255"}, {"bma280"}, {"bmc150_accel"},
@@ -244,6 +245,7 @@ static const struct of_device_id bmc150_accel_of_match[] = { { .compatible = "bosch,bma222" }, { .compatible = "bosch,bma222e" }, { .compatible = "bosch,bma250e" }, + { .compatible = "bosch,bma253" }, { .compatible = "bosch,bma255" }, { .compatible = "bosch,bma280" }, { .compatible = "bosch,bmc150_accel" },
drivers/iio/accel/bmc150-accel-spi.c +1 -0
@@ -50,6 +50,7 @@ static const struct spi_device_id bmc150_accel_id[] = { {"bma222"}, {"bma222e"}, {"bma250e"}, + {"bma253"}, {"bma255"}, {"bma280"}, {"bmc150_accel"},
Signature · 1 line
2.32.0
PATCH v3 8/10 dt-bindings: iio: bma255: Allow multiple interrupts
In reply to Stephan GerholdBMA253 has two interrupt pins (INT1 and INT2) that can be configured independently. At the moment the bmc150-accel driver does not make use of them but it might be able to in the future, so it's useful to already specify all available interrupts in the device tree.
Set maxItems: 2 for interrupts to allow specifying a second one. This is necessary as preparation to move the bosch,bma254 compatible from bosch,bma180.yaml to bosch,bma255.yaml since bma180 allows two interrupts, but BMA254 is better supported by the bmc150-accel driver.
--- .../devicetree/bindings/iio/accel/bosch,bma255.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml +6 -1
@@ -32,7 +32,12 @@ properties: vddio-supply: true interrupts: - maxItems: 1 + minItems: 1 + maxItems: 2 + description: | + The first interrupt listed must be the one connected to the INT1 pin, + the second (optional) interrupt listed must be the one connected to the + INT2 pin (if available). mount-matrix: description: an optional 3x3 mounting rotation matrix.
Signature · 1 line
2.32.0
Jonathan Cameron
maintainerRe: [PATCH v3 08/10] dt-bindings: iio: bma255: Allow multiple interrupts
Quoted 23 lines · On Fri, 11 Jun 2021 10:09:01 +0200 Stephan Gerhold <[email protected]> wrote:
BMA253 has two interrupt pins (INT1 and INT2) that can be configured independently. At the moment the bmc150-accel driver does not make use of them but it might be able to in the future, so it's useful to already specify all available interrupts in the device tree.
Set maxItems: 2 for interrupts to allow specifying a second one. This is necessary as preparation to move the bosch,bma254 compatible from bosch,bma180.yaml to bosch,bma255.yaml since bma180 allows two interrupts, but BMA254 is better supported by the bmc150-accel driver.
Reviewed-by Linus Walleij <[email protected]>Reviewed-by Hans de Goede <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>Signed-off-by Stephan Gerhold <[email protected]>--- .../devicetree/bindings/iio/accel/bosch,bma255.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml +0
-0
Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml properties: · line 40
Quoted 10 lines
Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml +6
-1@@ -32,7 +32,12 @@ properties: vddio-supply: true interrupts: - maxItems: 1 + minItems: 1 + maxItems: 2 + description: | + The first interrupt listed must be the one connected to the INT1 pin, + the second (optional) interrupt listed must be the one connected to the + INT2 pin (if available).
As this is a direct copy from the bma180 binding and we are moving devices from one to the other, we need to support this as the default. Longer term, from the bma253 datasheet, it look looks the two pins are equally capable so if we get a board where only the int2 pin is connected then we will need to use interrupt-names to distinguish the two (as we do in other drivers).
Another thing to note is that we don't have to have separate binding docs just because we have separate drivers. At somepoint we might want to consider just fusing the two docs.
Anyhow, work for another day!
Jonathan
Quoted 3 lines
Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml +0
-0mount-matrix: description: an optional 3x3 mounting rotation matrix.
Re: [PATCH v3 08/10] dt-bindings: iio: bma255: Allow multiple interrupts
Quoted 28 lines · Jonathan Cameron
Quoted 25 lines · On Fri, 11 Jun 2021 10:09:01 +0200 Stephan Gerhold <[email protected]> wrote:
BMA253 has two interrupt pins (INT1 and INT2) that can be configured independently. At the moment the bmc150-accel driver does not make use of them but it might be able to in the future, so it's useful to already specify all available interrupts in the device tree.
Set maxItems: 2 for interrupts to allow specifying a second one. This is necessary as preparation to move the bosch,bma254 compatible from bosch,bma180.yaml to bosch,bma255.yaml since bma180 allows two interrupts, but BMA254 is better supported by the bmc150-accel driver.
Reviewed-by Linus Walleij <[email protected]>Reviewed-by Hans de Goede <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>Signed-off-by Stephan Gerhold <[email protected]>--- .../devicetree/bindings/iio/accel/bosch,bma255.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml +0
-0@@ -32,7 +32,12 @@ properties: vddio-supply: true
Quoted 15 lines
Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml properties: · line 40
Quoted 8 lines
Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml +6
-1interrupts: - maxItems: 1 + minItems: 1 + maxItems: 2 + description: | + The first interrupt listed must be the one connected to the INT1 pin, + the second (optional) interrupt listed must be the one connected to the + INT2 pin (if available).As this is a direct copy from the bma180 binding and we are moving devices from one to the other, we need to support this as the default. Longer term, from the bma253 datasheet, it look looks the two pins are equally capable so if we get a board where only the int2 pin is connected then we will need to use interrupt-names to distinguish the two (as we do in other drivers).
This kind of sounds like a strange board layout in general. But what's worse is that for some reason even Bosch thought this is a "good" idea so they released the BMC156 [1]. It works just like the BMC150 but has only a single interrupt pin. One would expect that would be INT1, but nope, it's INT2 of course. :-)
I have a device with BMC156 where this is the case, so I guess I need to make bmc150-accel use INT2 somehow (without specifying INT1). It might be easiest if we treat this the same way as the case that you mentioned, i.e. everyone with BMC156 would specify the interrupt-names explicitly to have a consistent meaning of the device tree.
[1]: https://www.mouser.de/datasheet/2/783/BST-BMC156-DS000-1509546.pdf
Quoted 4 lines
Another thing to note is that we don't have to have separate binding docs just because we have separate drivers. At somepoint we might want to consider just fusing the two docs.
Good point! I might do that together with the BMC156 changes. :)
Thanks!
Stephan
Jonathan Cameron
maintainerRe: [PATCH v3 08/10] dt-bindings: iio: bma255: Allow multiple interrupts
Quoted 51 lines · On Fri, 11 Jun 2021 20:21:05 +0200 Stephan Gerhold <[email protected]> wrote:
Quoted 28 lines · Jonathan Cameron
Quoted 25 lines · On Fri, 11 Jun 2021 10:09:01 +0200 Stephan Gerhold <[email protected]> wrote:
BMA253 has two interrupt pins (INT1 and INT2) that can be configured independently. At the moment the bmc150-accel driver does not make use of them but it might be able to in the future, so it's useful to already specify all available interrupts in the device tree.
Set maxItems: 2 for interrupts to allow specifying a second one. This is necessary as preparation to move the bosch,bma254 compatible from bosch,bma180.yaml to bosch,bma255.yaml since bma180 allows two interrupts, but BMA254 is better supported by the bmc150-accel driver.
Reviewed-by Linus Walleij <[email protected]>Reviewed-by Hans de Goede <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>Signed-off-by Stephan Gerhold <[email protected]>--- .../devicetree/bindings/iio/accel/bosch,bma255.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml +0
-0@@ -32,7 +32,12 @@ properties: vddio-supply: trueQuoted 15 lines
Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml properties: · line 40
Quoted 8 lines
Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml +6
-1interrupts: - maxItems: 1 + minItems: 1 + maxItems: 2 + description: | + The first interrupt listed must be the one connected to the INT1 pin, + the second (optional) interrupt listed must be the one connected to the + INT2 pin (if available).As this is a direct copy from the bma180 binding and we are moving devices from one to the other, we need to support this as the default. Longer term, from the bma253 datasheet, it look looks the two pins are equally capable so if we get a board where only the int2 pin is connected then we will need to use interrupt-names to distinguish the two (as we do in other drivers).
This kind of sounds like a strange board layout in general. But what's worse is that for some reason even Bosch thought this is a "good" idea so they released the BMC156 [1]. It works just like the BMC150 but has only a single interrupt pin. One would expect that would be INT1, but nope, it's INT2 of course. :-)
Quoted 5 lines
I have a device with BMC156 where this is the case, so I guess I need to make bmc150-accel use INT2 somehow (without specifying INT1). It might be easiest if we treat this the same way as the case that you mentioned, i.e. everyone with BMC156 would specify the interrupt-names explicitly to have a consistent meaning of the device tree.
That will really confuse people who think they just have one interrupt so why do they need the name! You'll have to special case that delight in the driver.
Quoted 9 lines
[1]: https://www.mouser.de/datasheet/2/783/BST-BMC156-DS000-1509546.pdf
Quoted 4 lines
Another thing to note is that we don't have to have separate binding docs just because we have separate drivers. At somepoint we might want to consider just fusing the two docs.
Good point! I might do that together with the BMC156 changes. :)
Great. Best of all you can drop me as maintainer the combined binding ;)
Jonathan
Quoted 3 lines
Thanks!
Stephan
Re: [PATCH v3 08/10] dt-bindings: iio: bma255: Allow multiple interrupts
Quoted 60 lines · Jonathan Cameron
Quoted 51 lines · On Fri, 11 Jun 2021 20:21:05 +0200 Stephan Gerhold <[email protected]> wrote:
Quoted 28 lines · Jonathan Cameron
Quoted 25 lines · On Fri, 11 Jun 2021 10:09:01 +0200 Stephan Gerhold <[email protected]> wrote:
BMA253 has two interrupt pins (INT1 and INT2) that can be configured independently. At the moment the bmc150-accel driver does not make use of them but it might be able to in the future, so it's useful to already specify all available interrupts in the device tree.
Set maxItems: 2 for interrupts to allow specifying a second one. This is necessary as preparation to move the bosch,bma254 compatible from bosch,bma180.yaml to bosch,bma255.yaml since bma180 allows two interrupts, but BMA254 is better supported by the bmc150-accel driver.
Reviewed-by Linus Walleij <[email protected]>Reviewed-by Hans de Goede <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>Signed-off-by Stephan Gerhold <[email protected]>--- .../devicetree/bindings/iio/accel/bosch,bma255.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml +0
-0@@ -32,7 +32,12 @@ properties: vddio-supply: trueQuoted 15 lines
Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml properties: · line 40
Quoted 8 lines
Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml +6
-1interrupts: - maxItems: 1 + minItems: 1 + maxItems: 2 + description: | + The first interrupt listed must be the one connected to the INT1 pin, + the second (optional) interrupt listed must be the one connected to the + INT2 pin (if available).As this is a direct copy from the bma180 binding and we are moving devices from one to the other, we need to support this as the default. Longer term, from the bma253 datasheet, it look looks the two pins are equally capable so if we get a board where only the int2 pin is connected then we will need to use interrupt-names to distinguish the two (as we do in other drivers).
This kind of sounds like a strange board layout in general. But what's worse is that for some reason even Bosch thought this is a "good" idea so they released the BMC156 [1]. It works just like the BMC150 but has only a single interrupt pin. One would expect that would be INT1, but nope, it's INT2 of course. :-)
Quoted 5 lines
I have a device with BMC156 where this is the case, so I guess I need to make bmc150-accel use INT2 somehow (without specifying INT1). It might be easiest if we treat this the same way as the case that you mentioned, i.e. everyone with BMC156 would specify the interrupt-names explicitly to have a consistent meaning of the device tree.
Quoted 4 lines
That will really confuse people who think they just have one interrupt so why do they need the name! You'll have to special case that delight in the driver.
Okay, good that we discussed this before then. :)
I was unsure if it would be better to special case it for BMC156 *or* add support for the interrupt-names, but perhaps I'm just going to do *both* then. (Special case it for BMC156, look at interrupt-names for all others.)
Thanks!
Stephan
PATCH v3 9/10 dt-bindings: iio: accel: bma180/bma255: Move bma254 to bma255 schema
In reply to Stephan GerholdBMA254 is very similar to BMA253/BMA255 which are both supported by the bmc150-accel driver. In general, there is quite some overlap between the bma180 and bmc150-accel driver, but the bmc150-accel driver has a few more features (e.g. motion trigger/interrupt).
Let's move bma254 over to the bma255 schema (bmc150-accel driver).
--- Documentation/devicetree/bindings/iio/accel/bosch,bma180.yaml | 3 +-- Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml | 1 + 2 files changed, 2 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/iio/accel/bosch,bma180.yaml +1 -2
@@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/iio/accel/bosch,bma180.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: Bosch BMA023 / BMA150/ BMA180 / BMA25x / SMB380 triaxial accelerometers +title: Bosch BMA023 / BMA150/ BMA180 / BMA250 / SMB380 triaxial accelerometers maintainers: - Jonathan Cameron <[email protected]>
@@ -21,7 +21,6 @@ properties: - bosch,bma150 - bosch,bma180 - bosch,bma250 - - bosch,bma254 - bosch,smb380 reg:
Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml +1 -0
@@ -19,6 +19,7 @@ properties: - bosch,bmc150_accel - bosch,bmi055_accel - bosch,bma253 + - bosch,bma254 - bosch,bma255 - bosch,bma250e - bosch,bma222
Signature · 1 line
2.32.0
PATCH v3 10/10 iio: accel: bma180/bmc150: Move BMA254 to bmc150-accel driver
In reply to Stephan GerholdCommit c1d1c4a62db5 ("iio: accel: bma180: BMA254 support") added BMA254 support to the bma180 driver and changed some naming to BMA25x to make it easier to add support for BMA253 and BMA255.
Unfortunately, there is quite some overlap between the bma180 driver and the bmc150-accel driver. Back when the commit was made, the bmc150-accel driver actually already had support for BMA255, and adding support for BMA254 would have been as simple as adding a new compatible to bmc150-accel.
The bmc150-accel driver is a bit better for BMA254 since it also supports the motion trigger/interrupt functionality. Fortunately, moving BMA254 support over to bmc150-accel is fairly simple because the drivers have compatible device tree bindings.
Revert most of the changes for BMA254 support in bma180 and move BMA254 over to bmc150-accel. This has the following advantages:
- Support for motion trigger/interrupt
- Fix incorrect scale values (BMA254 currently uses the same as BMA250 but actually they're different because of 10 vs 12 bits data size)
- Less code than before :)
BMA250 could be potentially also moved but it's more complicated because its chip_id conflicts with the one for BMA222 in bmc150-accel. Perhaps there are also other register differences, I did not investigate further yet (and I have no way to test it).
---
Changes in v3: Sort chip list in BMA180 Kconfig text Changes in v2: Also drop BMA254 comment from file header in bma180.c
Note that the similarity between bma180 and bmc150-accel has already caused a lot of confusion in the past. See e.g. [1] where Hans accidentally added BMA250E support to bma180 even though that was already supported in bmc150-accel.
Having BMA250 in bma180 and BMA250E in bmc150-accel was also discussed before in [2] but for some reason back then the conclusion was that they are different enough to justify that.
Also note that this patch only applies cleanly on top of the "iio: accel: bma180: Fix BMA25x bandwidth register values" patch [3] that I sent earlier, which is not present in togreg/testing at the moment (only in fixes-togreg).
[1]: https://lore.kernel.org/linux-iio/[email protected]/
[2]: https://lore.kernel.org/linux-iio/[email protected]/
[3]: https://lore.kernel.org/linux-iio/[email protected]/
--- drivers/iio/accel/Kconfig | 6 +- drivers/iio/accel/bma180.c | 92 ++++----------------------- drivers/iio/accel/bmc150-accel-core.c | 2 +- drivers/iio/accel/bmc150-accel-i2c.c | 2 + 4 files changed, 18 insertions(+), 84 deletions(-)
drivers/iio/accel/Kconfig +3 -3
@@ -89,13 +89,13 @@ config ADXL372_I2C module will be called adxl372_i2c. config BMA180 - tristate "Bosch BMA023/BMA1x0/BMA25x 3-Axis Accelerometer Driver" + tristate "Bosch BMA023/BMA1x0/BMA250 3-Axis Accelerometer Driver" depends on I2C && INPUT_BMA150=n select IIO_BUFFER select IIO_TRIGGERED_BUFFER help Say Y here if you want to build a driver for the Bosch BMA023, BMA150 - BMA180, SMB380, or BMA25x triaxial acceleration sensor. + BMA180, BMA250 or SMB380 triaxial acceleration sensor. To compile this driver as a module, choose M here: the module will be called bma180.
@@ -143,7 +143,7 @@ config BMC150_ACCEL select BMC150_ACCEL_SPI if SPI help Say yes here to build support for the following Bosch accelerometers: - BMA222, BMA222E, BMA250E, BMA253, BMA255, BMA280, BMC150, BMI055. + BMA222, BMA222E, BMA250E, BMA253, BMA254, BMA255, BMA280, BMC150, BMI055. Note that some of these are combo modules: - BMC150: accelerometer and magnetometer
drivers/iio/accel/bma180.c +12 -80
182 lines not on this page · raw message
drivers/iio/accel/bmc150-accel-core.c +1 -1
@@ -1125,7 +1125,7 @@ static const struct bmc150_accel_chip_info bmc150_accel_chip_info_tbl[] = { {306457, BMC150_ACCEL_DEF_RANGE_16G} }, }, { - .name = "BMA253/BMA255/BMC150/BMI055", + .name = "BMA253/BMA254/BMA255/BMC150/BMI055", .chip_id = 0xFA, .channels = bmc150_accel_channels, .num_channels = ARRAY_SIZE(bmc150_accel_channels),
drivers/iio/accel/bmc150-accel-i2c.c +2 -0
@@ -232,6 +232,7 @@ static const struct i2c_device_id bmc150_accel_id[] = { {"bma222e"}, {"bma250e"}, {"bma253"}, + {"bma254"}, {"bma255"}, {"bma280"}, {"bmc150_accel"},
@@ -246,6 +247,7 @@ static const struct of_device_id bmc150_accel_of_match[] = { { .compatible = "bosch,bma222e" }, { .compatible = "bosch,bma250e" }, { .compatible = "bosch,bma253" }, + { .compatible = "bosch,bma254" }, { .compatible = "bosch,bma255" }, { .compatible = "bosch,bma280" }, { .compatible = "bosch,bmc150_accel" },
Signature · 1 line
2.32.0
Jonathan Cameron
maintainerQuoted 8 lines · On Fri, 11 Jun 2021 10:08:53 +0200 Stephan Gerhold <[email protected]> wrote:
The Bosch BMA253 accelerometer is very similar to both BMA254 and BMA255. The current situation is very confusing: BMA254 is supported by the bma180 driver, but BMA255 is supported by the bmc150-accel driver.
It turns out the bma180 and bmc150-accel drivers have quite some overlap, and BMA253/BMA254 would be a bit better supported in bmc150-accel (which has support for the motion trigger/interrupt).
Quoted 5 lines
This series adds BMA253 support to bmc150-accel and also moves BMA254 over to bmc150, removing some unnecessary code from the bma180 driver.
In v2 I also sneaked in a small fix for the scale table of BMA222 to simplify backporting for the stable people.
After cheating a bit and pulling the dependency across from my fixes-togreg branch (along with the other patches that were there), I can now apply this.
So applied to the fixes-togreg branch of iio.git and pushed out as testing for 0-day to have a quick poke at it before I let this going into linux-next.
Thanks,
Jonathan
Quoted 38 lines
---
Changes in v3:
- Add new "iio: accel: bmc150: Clarify combo modules inKconfig" patch
- Sort "one-line" chip name lists as well, not just multi-line onesv2: https://lore.kernel.org/linux-iio/[email protected]/
Changes in v2:
- Add new "iio: accel: bmc150: Fix bma222 scale unit" patch at the beginning so the stable people can backport it without conflicts
- Add Reviewed-by: from Hans and Andy for all previous patches
- Add patch 3 and 4 to have all the chip lists in a consistent order
- Fix last patch to also drop BMA254 from the file header inbma180.cv1: https://lore.kernel.org/linux-iio/[email protected]/
Stephan Gerhold (10):
iio: accel: bmc150: Fix bma222 scale unit
iio: accel: bmc150: Clarify combo modules inKconfig
iio: accel: bmc150: Drop misleading/duplicate chip identifiers
iio: accel: bmc150: Drop duplicated documentation of supported chips
iio: accel: bmc150: Sort all chip names alphabetically / by chip ID
dt-bindings: iio: accel: bma255: Document bosch,bma253
iio: accel: bmc150: Add device IDs for BMA253
dt-bindings: iio: bma255: Allow multiple interrupts
dt-bindings: iio: accel: bma180/bma255: Move bma254 to bma255 schema
iio: accel: bma180/bmc150: Move BMA254 to bmc150-accel driver.../bindings/iio/accel/bosch,bma180.yaml | 3 +- .../bindings/iio/accel/bosch,bma255.yaml | 9 +- drivers/iio/accel/Kconfig | 11 ++- drivers/iio/accel/bma180.c | 92 +++---------------- drivers/iio/accel/bmc150-accel-core.c | 87 ++++++------------ drivers/iio/accel/bmc150-accel-i2c.c | 52 +++++------ drivers/iio/accel/bmc150-accel-spi.c | 31 ++++--- drivers/iio/accel/bmc150-accel.h | 10 -- 8 files changed, 98 insertions(+), 197 deletions(-)