iio: imu: adis: Add self_test_reg variable
authorNuno Sá <nuno.sa@analog.com>
Mon, 10 Feb 2020 13:26:02 +0000 (15:26 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 8 Mar 2020 17:28:30 +0000 (17:28 +0000)
This patch adds a dedicated self_test_reg variable. This is also a step
to let new drivers make use of `adis_initial_startup()`. Some devices
use MSG_CTRL reg to request a self_test command while others use the
GLOB_CMD register.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/accel/adis16201.c
drivers/iio/accel/adis16209.c
drivers/iio/gyro/adis16136.c
drivers/iio/gyro/adis16260.c
drivers/iio/imu/adis.c
drivers/iio/imu/adis16400.c
drivers/iio/imu/adis16460.c
drivers/iio/imu/adis16480.c
drivers/staging/iio/accel/adis16203.c
drivers/staging/iio/accel/adis16240.c
include/linux/iio/imu/adis.h

index 0f0f27a8184ef5409485da52e4ef8d9c93831367..4154e7396bbe76f83bb6ffe68a87d8940f02086e 100644 (file)
@@ -246,6 +246,7 @@ static const struct adis_data adis16201_data = {
        .diag_stat_reg = ADIS16201_DIAG_STAT_REG,
 
        .self_test_mask = ADIS16201_MSC_CTRL_SELF_TEST_EN,
+       .self_test_reg = ADIS16201_MSC_CTRL_REG,
        .self_test_no_autoclear = true,
        .timeouts = &adis16201_timeouts,
 
index c6dbd2424e10cd6a9fa23cf8d72d6cbc89c8429e..31d45e7c54857a5d5e1e3c7d93bd2654ef6fc373 100644 (file)
@@ -256,6 +256,7 @@ static const struct adis_data adis16209_data = {
        .diag_stat_reg = ADIS16209_STAT_REG,
 
        .self_test_mask = ADIS16209_MSC_CTRL_SELF_TEST_EN,
+       .self_test_reg = ADIS16209_MSC_CTRL_REG,
        .self_test_no_autoclear = true,
        .timeouts = &adis16209_timeouts,
 
index 1db1131e5c6744354e03bd1d5b3104a428e2502b..a4c967a5fc5c6c90eb0f44acd2008775adea7185 100644 (file)
@@ -471,6 +471,7 @@ static const char * const adis16136_status_error_msgs[] = {
        .diag_stat_reg = ADIS16136_REG_DIAG_STAT,                       \
        .glob_cmd_reg = ADIS16136_REG_GLOB_CMD,                         \
        .msc_ctrl_reg = ADIS16136_REG_MSC_CTRL,                         \
+       .self_test_reg = ADIS16136_REG_MSC_CTRL,                        \
        .self_test_mask = ADIS16136_MSC_CTRL_SELF_TEST,                 \
        .read_delay = 10,                                               \
        .write_delay = 10,                                              \
index be09b3e5910ce7ea1ec579724f023932cdcb290f..9823573e811a58797a012dc7d96ed626d6bb25f2 100644 (file)
@@ -346,6 +346,7 @@ static const struct adis_data adis16260_data = {
        .diag_stat_reg = ADIS16260_DIAG_STAT,
 
        .self_test_mask = ADIS16260_MSC_CTRL_MEM_TEST,
+       .self_test_reg = ADIS16260_MSC_CTRL,
        .timeouts = &adis16260_timeouts,
 
        .status_error_msgs = adis1620_status_error_msgs,
index e4897dad34ab2e08ebbc15e449fe435973adf684..f7845a90f3765c8df616e12da5004384dad38228 100644 (file)
@@ -346,8 +346,8 @@ static int adis_self_test(struct adis *adis)
        int ret;
        const struct adis_timeout *timeouts = adis->data->timeouts;
 
-       ret = __adis_write_reg_16(adis, adis->data->msc_ctrl_reg,
-                       adis->data->self_test_mask);
+       ret = __adis_write_reg_16(adis, adis->data->self_test_reg,
+                                 adis->data->self_test_mask);
        if (ret) {
                dev_err(&adis->spi->dev, "Failed to initiate self test: %d\n",
                        ret);
@@ -359,7 +359,7 @@ static int adis_self_test(struct adis *adis)
        ret = __adis_check_status(adis);
 
        if (adis->data->self_test_no_autoclear)
-               __adis_write_reg_16(adis, adis->data->msc_ctrl_reg, 0x00);
+               __adis_write_reg_16(adis, adis->data->self_test_reg, 0x00);
 
        return ret;
 }
index 1c0770e03ec957e798777d2dfb3940e6dd63e167..05e70c1c48359d8e1d9af7ee19feb5648cda931d 100644 (file)
@@ -956,6 +956,7 @@ static const char * const adis16400_status_error_msgs[] = {
        .read_delay = 50,                                               \
        .write_delay = 50,                                              \
        .self_test_mask = ADIS16400_MSC_CTRL_MEM_TEST,                  \
+       .self_test_reg = ADIS16400_MSC_CTRL,                            \
        .status_error_msgs = adis16400_status_error_msgs,               \
        .status_error_mask = BIT(ADIS16400_DIAG_STAT_ZACCL_FAIL) |      \
                BIT(ADIS16400_DIAG_STAT_YACCL_FAIL) |                   \
index 9539cfe4a259912cb7cdd7becfeffe8e451465d0..42fa473c6d81110ffc350be003b8a1bed6a5983b 100644 (file)
@@ -392,6 +392,8 @@ static const struct adis_timeout adis16460_timeouts = {
 static const struct adis_data adis16460_data = {
        .diag_stat_reg = ADIS16460_REG_DIAG_STAT,
        .glob_cmd_reg = ADIS16460_REG_GLOB_CMD,
+       .self_test_mask = BIT(2),
+       .self_test_reg = ADIS16460_REG_GLOB_CMD,
        .has_paging = false,
        .read_delay = 5,
        .write_delay = 5,
index 4c4de1b62769fe8c472a1c1f45e7366bb6a2f9cd..acbe1701fc2df6969cd1f7a9cbc832db3418cc5f 100644 (file)
@@ -830,6 +830,7 @@ static int adis16480_enable_irq(struct adis *adis, bool enable);
        .read_delay = 5,                                                \
        .write_delay = 5,                                               \
        .self_test_mask = BIT(1),                                       \
+       .self_test_reg = ADIS16480_REG_GLOB_CMD,                        \
        .status_error_msgs = adis16480_status_error_msgs,               \
        .status_error_mask = BIT(ADIS16480_DIAG_STAT_XGYRO_FAIL) |      \
                BIT(ADIS16480_DIAG_STAT_YGYRO_FAIL) |                   \
index 39dfe3f7f2542371ea97f283bc927f59b837bbf0..fef52d9b53467db9118fb4a53b8621304824343c 100644 (file)
@@ -250,6 +250,7 @@ static const struct adis_data adis16203_data = {
        .diag_stat_reg = ADIS16203_DIAG_STAT,
 
        .self_test_mask = ADIS16203_MSC_CTRL_SELF_TEST_EN,
+       .self_test_reg = ADIS16203_MSC_CTRL,
        .self_test_no_autoclear = true,
        .timeouts = &adis16203_timeouts,
 
index 39eb8364aa95907d978245fbca6e502759a0a7d9..8bd35c6c56a1bfa04c9858d2c7d77173d7e84f55 100644 (file)
@@ -373,6 +373,7 @@ static const struct adis_data adis16240_data = {
        .diag_stat_reg = ADIS16240_DIAG_STAT,
 
        .self_test_mask = ADIS16240_MSC_CTRL_SELF_TEST_EN,
+       .self_test_reg = ADIS16240_MSC_CTRL,
        .self_test_no_autoclear = true,
        .timeouts = &adis16240_timeouts,
 
index 15e75670f9230b196b826c40c975b8a67f483650..b7feca4e5f263cbc9b3c119d2a4b98b11214c5ca 100644 (file)
@@ -41,6 +41,7 @@ struct adis_timeout {
  * @glob_cmd_reg: Register address of the GLOB_CMD register
  * @msc_ctrl_reg: Register address of the MSC_CTRL register
  * @diag_stat_reg: Register address of the DIAG_STAT register
+ * @self_test_reg: Register address to request self test command
  * @status_error_msgs: Array of error messgaes
  * @status_error_mask:
  * @timeouts: Chip specific delays
@@ -55,6 +56,7 @@ struct adis_data {
        unsigned int diag_stat_reg;
 
        unsigned int self_test_mask;
+       unsigned int self_test_reg;
        bool self_test_no_autoclear;
        const struct adis_timeout *timeouts;