]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iio: kx022a: Support ROHM KX134ACR-LBZ
authorMatti Vaittinen <mazziesaccount@gmail.com>
Thu, 28 Nov 2024 09:02:45 +0000 (11:02 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 7 Dec 2024 17:51:52 +0000 (17:51 +0000)
The register interface of the ROHM KX134ACR-LBZ accelerometer is
almost identical to the KX132ACR-LBZ. The main difference between these
accelerometers is that the KX134ACR-LBZ supports different G-ranges. The
driver can model this by informing different scale to users. Also, the
content of the "who_am_I" register is different.

Add an ID and scales for the KX134ACR-LBZ.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/27c43c595de1f3f698ace671922d4f5a48c3cd54.1732783834.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/accel/kionix-kx022a-i2c.c
drivers/iio/accel/kionix-kx022a-spi.c
drivers/iio/accel/kionix-kx022a.c
drivers/iio/accel/kionix-kx022a.h

index b39a43ecadffb0045c596aaa4ebe30e363057e1b..79ee733510cf26b18cf47c35cbe8493ab4e6cb0b 100644 (file)
@@ -39,6 +39,7 @@ 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 },
+       { .name = "kx134acr-lbz", .driver_data = (kernel_ulong_t)&kx134acr_chip_info },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, kx022a_i2c_id);
@@ -47,6 +48,7 @@ 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 },
+       { .compatible = "rohm,kx134acr-lbz", .data = &kx134acr_chip_info },
        { }
 };
 MODULE_DEVICE_TABLE(of, kx022a_of_match);
index c38a47806a0006cf0e80f8a6f3207864dc998422..6ae44660a8f8912204b468545ef25b7cb23f28cb 100644 (file)
@@ -39,6 +39,7 @@ 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 },
+       { .name = "kx134acr-lbz", .driver_data = (kernel_ulong_t)&kx134acr_chip_info },
        { }
 };
 MODULE_DEVICE_TABLE(spi, kx022a_id);
@@ -47,6 +48,7 @@ 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 },
+       { .compatible = "rohm,kx134acr-lbz", .data = &kx134acr_chip_info },
        { }
 };
 MODULE_DEVICE_TABLE(of, kx022a_of_match);
index 06859483cb132b2866050590375ebef3637a0275..2ae6f4242c88aad7751c9130a464af7b336f6dd8 100644 (file)
@@ -408,6 +408,14 @@ static const int kx022a_scale_table[][2] = {
        { 0, 4788403 },
 };
 
+/* KX134ACR-LBZ ranges are (+/-) 8, 16, 32, 64 G */
+static const int kx134acr_lbz_scale_table[][2] = {
+       { 0, 2394202 },
+       { 0, 4788403 },
+       { 0, 9576807 },
+       { 0, 19153613 },
+};
+
 static int kx022a_read_avail(struct iio_dev *indio_dev,
                             struct iio_chan_spec const *chan,
                             const int **vals, int *type, int *length,
@@ -1236,6 +1244,34 @@ const struct kx022a_chip_info kx132acr_chip_info = {
 };
 EXPORT_SYMBOL_NS_GPL(kx132acr_chip_info, "IIO_KX022A");
 
+const struct kx022a_chip_info kx134acr_chip_info = {
+       .name                           = "kx134acr-lbz",
+       .regmap_config                  = &kx022a_regmap_config,
+       .channels                       = kx022a_channels,
+       .num_channels                   = ARRAY_SIZE(kx022a_channels),
+       .scale_table                    = kx134acr_lbz_scale_table,
+       .scale_table_size               = ARRAY_SIZE(kx134acr_lbz_scale_table) *
+                                         ARRAY_SIZE(kx134acr_lbz_scale_table[0]),
+       .fifo_length                    = KX022A_FIFO_LENGTH,
+       .who                            = KX022A_REG_WHO,
+       .id                             = KX134ACR_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(kx134acr_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"};
index 36e9d9de8c134e7d5479d6ca3cbf82b61417bc94..ea32fd252a38a344637cca120843fa99efcd193b 100644 (file)
@@ -14,6 +14,7 @@
 #define KX022A_REG_WHO         0x0f
 #define KX022A_ID              0xc8
 #define KX132ACR_LBZ_ID                0xd8
+#define KX134ACR_LBZ_ID                0xcc
 
 #define KX022A_REG_CNTL2       0x19
 #define KX022A_MASK_SRST       BIT(7)
@@ -190,5 +191,6 @@ int kx022a_probe_internal(struct device *dev, const struct kx022a_chip_info *chi
 extern 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;
+extern const struct kx022a_chip_info kx134acr_chip_info;
 
 #endif