]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: imu: st_lsm6dsx: check if pull_up is located in primary page
authorLorenzo Bianconi <lorenzo@kernel.org>
Sat, 14 Dec 2019 16:52:56 +0000 (17:52 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 29 Dec 2019 15:20:06 +0000 (15:20 +0000)
Check if the pull up 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

index bd1c77d16147ba57e8156145c08077d5e6d6a3ba..4974f6fafd533a81fc7353e279b26687d382ae4f 100644 (file)
@@ -189,7 +189,11 @@ struct st_lsm6dsx_shub_settings {
                u8 addr;
                u8 mask;
        } master_en;
-       struct st_lsm6dsx_reg pullup_en;
+       struct {
+               bool sec_page;
+               u8 addr;
+               u8 mask;
+       } pullup_en;
        struct st_lsm6dsx_reg aux_sens;
        struct st_lsm6dsx_reg wr_once;
        u8 num_ext_dev;
index b8cfea977968220fba3d5e4e08897393a946fa7f..b5e9f71be0857303bd89018998c09df1d7ee1a60 100644 (file)
@@ -873,6 +873,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
                                .mask = BIT(2),
                        },
                        .pullup_en = {
+                               .sec_page = true,
                                .addr = 0x14,
                                .mask = BIT(3),
                        },
@@ -1249,6 +1250,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
                                .mask = BIT(2),
                        },
                        .pullup_en = {
+                               .sec_page = true,
                                .addr = 0x14,
                                .mask = BIT(3),
                        },
@@ -1864,16 +1866,19 @@ static int st_lsm6dsx_init_shub(struct st_lsm6dsx_hw *hw)
        pdata = (struct st_sensors_platform_data *)dev->platform_data;
        if ((dev_fwnode(dev) && device_property_read_bool(dev, "st,pullups")) ||
            (pdata && pdata->pullups)) {
-               err = st_lsm6dsx_set_page(hw, true);
-               if (err < 0)
-                       return err;
+               if (hub_settings->pullup_en.sec_page) {
+                       err = st_lsm6dsx_set_page(hw, true);
+                       if (err < 0)
+                               return err;
+               }
 
                data = ST_LSM6DSX_SHIFT_VAL(1, hub_settings->pullup_en.mask);
                err = regmap_update_bits(hw->regmap,
                                         hub_settings->pullup_en.addr,
                                         hub_settings->pullup_en.mask, data);
 
-               st_lsm6dsx_set_page(hw, false);
+               if (hub_settings->pullup_en.sec_page)
+                       st_lsm6dsx_set_page(hw, false);
 
                if (err < 0)
                        return err;