Support ROHM KX132ACR-LBZ Accelerometer
Subsystems (3)
Matti Vaittinen
maintainercover Support ROHM KX132ACR-LBZ Accelerometer
The ROHM KX132ACR-LBZ is an accelerometer for industrial applications. It has a subset of KX022A (NOTE: Not KX132-1211) functionalities, dropping support for tap, free fall and tilt detection engines. Also, the register interface is an exact subset of what is found on KX022A (except the WHO_AM_I register value).
This series adds own DT compatible for the KX132ACR-LBZ and also own chip-info in driver to allow handling the different 'WHO_AM_I' value. The separation of the Kionix KX022A and ROHM KX132ACR-LBZ does also allow adding support for the KX022A tilt/free fall/tap engines which are not present on KX132ACR-LBZ.
Matti Vaittinen (2):
dt-bindings: iio: Add KX132ACR-LBZ accelerometer
iio: kx022a: Support ROHM KX132ACR-LBZ
.../bindings/iio/accel/kionix,kx022a.yaml | 10 +++--- drivers/iio/accel/kionix-kx022a-i2c.c | 4 ++- drivers/iio/accel/kionix-kx022a-spi.c | 4 ++- drivers/iio/accel/kionix-kx022a.c | 34 ++++++++++++++++++- drivers/iio/accel/kionix-kx022a.h | 2 ++ 5 files changed, 47 insertions(+), 7 deletions(-)
base-commit: 5e99f692d4e32e3250ab18d511894ca797407aec
Signature · 14 lines
2.41.0 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
Matti Vaittinen
maintainerPATCH 1/2 dt-bindings: iio: Add KX132ACR-LBZ accelerometer
ROHM KX132ACR-LBZ is an accelerometer for industrial applications. It has a subset of KX022A functionalities, dropping support for tap, free fall and tilt detection engines. Also, the register interface is an exact subset of what is found on KX022A.
Extend the kionix,kx022a.yaml file to support the KX132ACR-LBZ device
--- .../devicetree/bindings/iio/accel/kionix,kx022a.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml +6 -4
@@ -4,21 +4,23 @@ $id: http://devicetree.org/schemas/iio/accel/kionix,kx022a.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: ROHM/Kionix KX022A and KX132-1211 Accelerometers +title: ROHM/Kionix KX022A, KX132-1211 and KX132ACR-LBZ Accelerometers maintainers: - Matti Vaittinen <[email protected]> description: | - KX022A and KX132-1211 are 3-axis accelerometers supporting +/- 2G, 4G, 8G and - 16G ranges, variable output data-rates and a hardware-fifo buffering. - KX022A and KX132-1211 can be accessed either via I2C or SPI. + KX022A, KX132ACR-LBZ and KX132-1211 are 3-axis accelerometers supporting + +/- 2G, 4G, 8G and 16G ranges, variable output data-rates and a + hardware-fifo buffering. These accelerometers can be accessed either + via I2C or SPI. properties: compatible: enum: - kionix,kx022a - kionix,kx132-1211 + - rohm,kx132acr-lbz reg: maxItems: 1
Signature · 14 lines
2.41.0 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
Matti Vaittinen
maintainerPATCH 2/2 iio: kx022a: Support ROHM KX132ACR-LBZ
In reply to Matti Vaittinendt-bindings: iio: Add KX132ACR-LBZ accelerometer
ROHM KX132ACR-LBZ is an accelerometer for industrial applications. It has a subset of KX022A functionalities, dropping support for tap, free fall and tilt detection engines. Also, the register interface is an exact subset of what is found on KX022A (except the WHO_AM_I register value).
Add support for KX132ACR-LBZ.
--- drivers/iio/accel/kionix-kx022a-i2c.c | 4 +++- drivers/iio/accel/kionix-kx022a-spi.c | 4 +++- drivers/iio/accel/kionix-kx022a.c | 34 ++++++++++++++++++++++++++- drivers/iio/accel/kionix-kx022a.h | 2 ++ 4 files changed, 41 insertions(+), 3 deletions(-)
drivers/iio/accel/kionix-kx022a-i2c.c +3 -1
@@ -2,7 +2,7 @@/* * Copyright (C) 2022 ROHM Semiconductors * -* ROHM/KIONIX KX022A accelerometer driver +* ROHM/KIONIX accelerometer driver */ #include <linux/i2c.h>
@@ -38,6 +38,7 @@ static int kx022a_i2c_probe(struct i2c_client *i2c)static const struct i2c_device_id kx022a_i2c_id[] = { { .name ="kx022a" , .driver_data = (kernel_ulong_t)&kx022a_chip_info }, { .name ="kx132-1211" , .driver_data = (kernel_ulong_t)&kx132_chip_info }, + { .name ="kx132acr-lbz" , .driver_data = (kernel_ulong_t)&kx132acr_chip_info }, { } };MODULE_DEVICE_TABLE (i2c, kx022a_i2c_id);
@@ -45,6 +46,7 @@ MODULE_DEVICE_TABLE(i2c, kx022a_i2c_id);static const struct of_device_id kx022a_of_match[] = { { .compatible ="kionix,kx022a" , .data = &kx022a_chip_info }, { .compatible ="kionix,kx132-1211" , .data = &kx132_chip_info }, + { .compatible ="rohm,kx132acr-lbz" , .data = &kx132acr_chip_info }, { } };MODULE_DEVICE_TABLE (of, kx022a_of_match);
drivers/iio/accel/kionix-kx022a-spi.c +3 -1
@@ -2,7 +2,7 @@/* * Copyright (C) 2022 ROHM Semiconductors * -* ROHM/KIONIX KX022A accelerometer driver +* ROHM/KIONIX accelerometer driver */ #include <linux/interrupt.h>
@@ -38,6 +38,7 @@ static int kx022a_spi_probe(struct spi_device *spi)static const struct spi_device_id kx022a_id[] = { { .name ="kx022a" , .driver_data = (kernel_ulong_t)&kx022a_chip_info }, { .name ="kx132-1211" , .driver_data = (kernel_ulong_t)&kx132_chip_info }, + { .name ="kx132acr-lbz" , .driver_data = (kernel_ulong_t)&kx132acr_chip_info }, { } };MODULE_DEVICE_TABLE (spi, kx022a_id);
@@ -45,6 +46,7 @@ MODULE_DEVICE_TABLE(spi, kx022a_id);static const struct of_device_id kx022a_of_match[] = { { .compatible ="kionix,kx022a" , .data = &kx022a_chip_info }, { .compatible ="kionix,kx132-1211" , .data = &kx132_chip_info }, + { .compatible ="rohm,kx132acr-lbz" , .data = &kx132acr_chip_info }, { } };MODULE_DEVICE_TABLE (of, kx022a_of_match);
drivers/iio/accel/kionix-kx022a.c +33 -1
@@ -2,7 +2,7 @@/* * Copyright (C) 2022 ROHM Semiconductors * -* ROHM/KIONIX KX022A accelerometer driver +* ROHM/KIONIX accelerometer driver */ #include <linux/delay.h>
@@ -1188,6 +1188,38 @@ const struct kx022a_chip_info kx132_chip_info = { };EXPORT_SYMBOL_NS_GPL (kx132_chip_info,IIO_KX022A ); +/* +* Despite the naming, KX132ACR-LBZ is not similar to KX132-1211 but it is +* exact subset of KX022A. KX132ACR-LBZ is meant to be used for industrial +* applications and the tap/double tap, free fall and tilt engines were +* removed. Rest of the registers and functionalities (excluding the ID +* register) are exact match to what is found in KX022. +*/ +const struct kx022a_chip_info kx132acr_chip_info = { + .name ="kx132acr-lbz" , + .regmap_config = &kx022a_regmap_config, + .channels = kx022a_channels, + .num_channels =ARRAY_SIZE (kx022a_channels), + .fifo_length =KX022A_FIFO_LENGTH , + .who =KX022A_REG_WHO , + .id =KX132ACR_LBZ_ID , + .cntl =KX022A_REG_CNTL , + .cntl2 =KX022A_REG_CNTL2 , + .odcntl =KX022A_REG_ODCNTL , + .buf_cntl1 =KX022A_REG_BUF_CNTL1 , + .buf_cntl2 =KX022A_REG_BUF_CNTL2 , + .buf_clear =KX022A_REG_BUF_CLEAR , + .buf_status1 =KX022A_REG_BUF_STATUS_1 , + .buf_read =KX022A_REG_BUF_READ , + .inc1 =KX022A_REG_INC1 , + .inc4 =KX022A_REG_INC4 , + .inc5 =KX022A_REG_INC5 , + .inc6 =KX022A_REG_INC6 , + .xout_l =KX022A_REG_XOUT_L , + .get_fifo_bytes_available = kx022a_get_fifo_bytes_available, +}; +EXPORT_SYMBOL_NS_GPL (kx132acr_chip_info,IIO_KX022A ); +int kx022a_probe_internal (struct device *dev,const struct kx022a_chip_info *chip_info) {static const char *const regulator_names[] = {"io-vdd" ,"vdd" };
drivers/iio/accel/kionix-kx022a.h +2 -0
@@ -13,6 +13,7 @@#define KX022A_REG_WHO 0x0f#define KX022A_ID 0xc8 +#define KX132ACR_LBZ_ID 0xd8#define KX022A_REG_CNTL2 0x19#define KX022A_MASK_SRST BIT(7)
@@ -186,5 +187,6 @@ int kx022a_probe_internal(struct device *dev, const struct kx022a_chip_info *chiextern const struct kx022a_chip_info kx022a_chip_info;extern const struct kx022a_chip_info kx132_chip_info; +extern const struct kx022a_chip_info kx132acr_chip_info;#endif
Signature · 14 lines
2.41.0 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
Hello Matti,
Quoted 17 lines · Matti Vaittinen
The ROHM KX132ACR-LBZ is an accelerometer for industrial applications. It has a subset of KX022A (NOTE: Not KX132-1211) functionalities, dropping support for tap, free fall and tilt detection engines. Also, the register interface is an exact subset of what is found on KX022A (except the
WHO_AM_Iregister value).This series adds own DT compatible for the KX132ACR-LBZ and also own chip-info in driver to allow handling the different '
WHO_AM_I' value. The separation of the Kionix KX022A and ROHM KX132ACR-LBZ does also allow adding support for the KX022A tilt/free fall/tap engines which are not present on KX132ACR-LBZ.Matti Vaittinen (2):
dt-bindings: iio: Add KX132ACR-LBZ accelerometer
iio: kx022a: Support ROHM KX132ACR-LBZ
Quoted 7 lines
.../bindings/iio/accel/kionix,kx022a.yaml | 10 +++--- drivers/iio/accel/kionix-kx022a-i2c.c | 4 ++- drivers/iio/accel/kionix-kx022a-spi.c | 4 ++- drivers/iio/accel/kionix-kx022a.c | 34 ++++++++++++++++++- drivers/iio/accel/kionix-kx022a.h | 2 ++ 5 files changed, 47 insertions(+), 7 deletions(-)
You could also mention this device in the list of supported devices under drivers/iio/accel/Kconfig
--
Kind Regards
Mehdi Djait
Matti Vaittinen
maintainerQuoted 29 lines · Mehdi Djait
Hello Matti,
Quoted 17 lines · Matti Vaittinen
The ROHM KX132ACR-LBZ is an accelerometer for industrial applications. It has a subset of KX022A (NOTE: Not KX132-1211) functionalities, dropping support for tap, free fall and tilt detection engines. Also, the register interface is an exact subset of what is found on KX022A (except the
WHO_AM_Iregister value).This series adds own DT compatible for the KX132ACR-LBZ and also own chip-info in driver to allow handling the different '
WHO_AM_I' value. The separation of the Kionix KX022A and ROHM KX132ACR-LBZ does also allow adding support for the KX022A tilt/free fall/tap engines which are not present on KX132ACR-LBZ.Matti Vaittinen (2):
dt-bindings: iio: Add KX132ACR-LBZ accelerometer
iio: kx022a: Support ROHM KX132ACR-LBZQuoted 7 lines
.../bindings/iio/accel/kionix,kx022a.yaml | 10 +++--- drivers/iio/accel/kionix-kx022a-i2c.c | 4 ++- drivers/iio/accel/kionix-kx022a-spi.c | 4 ++- drivers/iio/accel/kionix-kx022a.c | 34 ++++++++++++++++++- drivers/iio/accel/kionix-kx022a.h | 2 ++ 5 files changed, 47 insertions(+), 7 deletions(-)
Quoted 2 lines
You could also mention this device in the list of supported devices under
drivers/iio/accel/Kconfig
Oh, indeed. Thanks Mehdi!
Yours,
-- Matti
Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~