]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: imu: st_lsm6dsx: check if shub_output reg is located in primary page
authorLorenzo Bianconi <lorenzo@kernel.org>
Sat, 14 Dec 2019 16:52:57 +0000 (17:52 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 29 Dec 2019 15:20:07 +0000 (15:20 +0000)
Check if the sensor hub output register is located in the primary or in the
secondary memory page. This is a preliminary patch to support i2c master
controller on lsm6dsm devices

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c

index 4974f6fafd533a81fc7353e279b26687d382ae4f..001179e19ba707fb896aca9792157b517b275877 100644 (file)
@@ -197,7 +197,10 @@ struct st_lsm6dsx_shub_settings {
        struct st_lsm6dsx_reg aux_sens;
        struct st_lsm6dsx_reg wr_once;
        u8 num_ext_dev;
-       u8 shub_out;
+       struct {
+               bool sec_page;
+               u8 addr;
+       } shub_out;
        u8 slv0_addr;
        u8 dw_slv0_addr;
        u8 batch_en;
index b5e9f71be0857303bd89018998c09df1d7ee1a60..49ad70c589bd5b93d3ef63024f0b2d38205c3e39 100644 (file)
@@ -886,7 +886,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
                                .mask = BIT(6),
                        },
                        .num_ext_dev = 3,
-                       .shub_out = 0x02,
+                       .shub_out = {
+                               .sec_page = true,
+                               .addr = 0x02,
+                       },
                        .slv0_addr = 0x15,
                        .dw_slv0_addr = 0x21,
                        .batch_en = BIT(3),
@@ -1263,7 +1266,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
                                .mask = BIT(6),
                        },
                        .num_ext_dev = 3,
-                       .shub_out = 0x02,
+                       .shub_out = {
+                               .sec_page = true,
+                               .addr = 0x02,
+                       },
                        .slv0_addr = 0x15,
                        .dw_slv0_addr = 0x21,
                        .batch_en = BIT(3),
index 767482e61a1e22e61c6626a7903bc2c23795c1ce..ccc59682cb66c45ec1563f7cacb78d69e9b9ba53 100644 (file)
@@ -105,20 +105,27 @@ static void st_lsm6dsx_shub_wait_complete(struct st_lsm6dsx_hw *hw)
  *
  * Read st_lsm6dsx i2c controller register
  */
-static int st_lsm6dsx_shub_read_reg(struct st_lsm6dsx_hw *hw, u8 addr,
-                                   u8 *data, int len)
+static int
+st_lsm6dsx_shub_read_reg(struct st_lsm6dsx_hw *hw, u8 *data,
+                        int len)
 {
+       const struct st_lsm6dsx_shub_settings *hub_settings;
        int err;
 
        mutex_lock(&hw->page_lock);
 
-       err = st_lsm6dsx_set_page(hw, true);
-       if (err < 0)
-               goto out;
+       hub_settings = &hw->settings->shub_settings;
+       if (hub_settings->shub_out.sec_page) {
+               err = st_lsm6dsx_set_page(hw, true);
+               if (err < 0)
+                       goto out;
+       }
 
-       err = regmap_bulk_read(hw->regmap, addr, data, len);
+       err = regmap_bulk_read(hw->regmap, hub_settings->shub_out.addr,
+                              data, len);
 
-       st_lsm6dsx_set_page(hw, false);
+       if (hub_settings->shub_out.sec_page)
+               st_lsm6dsx_set_page(hw, false);
 out:
        mutex_unlock(&hw->page_lock);
 
@@ -236,8 +243,7 @@ st_lsm6dsx_shub_read(struct st_lsm6dsx_sensor *sensor, u8 addr,
 
        st_lsm6dsx_shub_wait_complete(hw);
 
-       err = st_lsm6dsx_shub_read_reg(hw, hub_settings->shub_out, data,
-                                      len & ST_LS6DSX_READ_OP_MASK);
+       err = st_lsm6dsx_shub_read_reg(hw, data, len & ST_LS6DSX_READ_OP_MASK);
 
        st_lsm6dsx_shub_master_enable(sensor, false);
 
@@ -719,9 +725,7 @@ st_lsm6dsx_shub_check_wai(struct st_lsm6dsx_hw *hw, u8 *i2c_addr,
 
                st_lsm6dsx_shub_wait_complete(hw);
 
-               err = st_lsm6dsx_shub_read_reg(hw,
-                                              hub_settings->shub_out,
-                                              &data, sizeof(data));
+               err = st_lsm6dsx_shub_read_reg(hw, &data, sizeof(data));
 
                st_lsm6dsx_shub_master_enable(sensor, false);