]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: imu: st_lsm6dsx: move wakeup event enable mask to event_src
authorFrancesco Lavra <flavra@baylibre.com>
Mon, 1 Dec 2025 10:00:12 +0000 (11:00 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 21 Dec 2025 11:10:26 +0000 (11:10 +0000)
The mask value being assigned to the irq1_func and irq2_func fields of the
irq_config struct is specific to a single event source (i.e. the wakeup
event), and as such it should be separate from the definition of the
interrupt function registers, which cover multiple event sources.
In preparation for adding support for more event types, change the
irq1_func and irq2_func type from an {address, mask} pair to an address,
and move the mask value to a new field of struct st_lsm6dsx_event_src. No
functional changes.

Signed-off-by: Francesco Lavra <flavra@baylibre.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Acked-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 bd2f25cebdf846bd7263705eba3ed2773403c03b..137e385110b5098206bb0a066eaabdac36584af8 100644 (file)
@@ -267,6 +267,7 @@ enum st_lsm6dsx_event_id {
 
 struct st_lsm6dsx_event_src {
        struct st_lsm6dsx_reg value;
+       u8 enable_mask;
        struct st_lsm6dsx_reg status;
        u8 status_x_mask;
        u8 status_y_mask;
@@ -361,8 +362,8 @@ struct st_lsm6dsx_settings {
        struct {
                struct st_lsm6dsx_reg irq1;
                struct st_lsm6dsx_reg irq2;
-               struct st_lsm6dsx_reg irq1_func;
-               struct st_lsm6dsx_reg irq2_func;
+               u8 irq1_func;
+               u8 irq2_func;
                struct st_lsm6dsx_reg lir;
                struct st_lsm6dsx_reg clear_on_read;
                struct st_lsm6dsx_reg hla;
@@ -461,7 +462,7 @@ struct st_lsm6dsx_hw {
        u8 ts_sip;
        u8 sip;
 
-       const struct st_lsm6dsx_reg *irq_routing;
+       u8 irq_routing;
        u8 event_threshold;
        u8 enable_event;
 
index 1dc3d4b41b0b982ed0602d0421cc3099c0e66b84..39ae79991b914cc6a02dfda69f47a15b5fca8ff2 100644 (file)
@@ -319,14 +319,8 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
                                .addr = 0x58,
                                .mask = BIT(0),
                        },
-                       .irq1_func = {
-                               .addr = 0x5e,
-                               .mask = BIT(5),
-                       },
-                       .irq2_func = {
-                               .addr = 0x5f,
-                               .mask = BIT(5),
-                       },
+                       .irq1_func = 0x5e,
+                       .irq2_func = 0x5f,
                        .hla = {
                                .addr = 0x12,
                                .mask = BIT(5),
@@ -385,6 +379,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
                                                .addr = 0x5b,
                                                .mask = GENMASK(5, 0),
                                        },
+                                       .enable_mask = BIT(5),
                                        .status = {
                                                .addr = 0x1b,
                                                .mask = BIT(3),
@@ -491,14 +486,8 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
                                .addr = 0x58,
                                .mask = BIT(0),
                        },
-                       .irq1_func = {
-                               .addr = 0x5e,
-                               .mask = BIT(5),
-                       },
-                       .irq2_func = {
-                               .addr = 0x5f,
-                               .mask = BIT(5),
-                       },
+                       .irq1_func = 0x5e,
+                       .irq2_func = 0x5f,
                        .hla = {
                                .addr = 0x12,
                                .mask = BIT(5),
@@ -557,6 +546,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
                                                .addr = 0x5b,
                                                .mask = GENMASK(5, 0),
                                        },
+                                       .enable_mask = BIT(5),
                                        .status = {
                                                .addr = 0x1b,
                                                .mask = BIT(3),
@@ -693,14 +683,8 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
                                .addr = 0x58,
                                .mask = BIT(0),
                        },
-                       .irq1_func = {
-                               .addr = 0x5e,
-                               .mask = BIT(5),
-                       },
-                       .irq2_func = {
-                               .addr = 0x5f,
-                               .mask = BIT(5),
-                       },
+                       .irq1_func = 0x5e,
+                       .irq2_func = 0x5f,
                        .hla = {
                                .addr = 0x12,
                                .mask = BIT(5),
@@ -800,6 +784,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
                                                .addr = 0x5b,
                                                .mask = GENMASK(5, 0),
                                        },
+                                       .enable_mask = BIT(5),
                                        .status = {
                                                .addr = 0x1b,
                                                .mask = BIT(3),
@@ -948,14 +933,8 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
                                .addr = 0x56,
                                .mask = BIT(6),
                        },
-                       .irq1_func = {
-                               .addr = 0x5e,
-                               .mask = BIT(5),
-                       },
-                       .irq2_func = {
-                               .addr = 0x5f,
-                               .mask = BIT(5),
-                       },
+                       .irq1_func = 0x5e,
+                       .irq2_func = 0x5f,
                        .hla = {
                                .addr = 0x12,
                                .mask = BIT(5),
@@ -1045,6 +1024,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
                                                .addr = 0x5b,
                                                .mask = GENMASK(5, 0),
                                        },
+                                       .enable_mask = BIT(5),
                                        .status = {
                                                .addr = 0x1b,
                                                .mask = BIT(3),
@@ -1169,14 +1149,8 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
                                .addr = 0x56,
                                .mask = BIT(6),
                        },
-                       .irq1_func = {
-                               .addr = 0x5e,
-                               .mask = BIT(5),
-                       },
-                       .irq2_func = {
-                               .addr = 0x5f,
-                               .mask = BIT(5),
-                       },
+                       .irq1_func = 0x5e,
+                       .irq2_func = 0x5f,
                        .hla = {
                                .addr = 0x12,
                                .mask = BIT(5),
@@ -1234,6 +1208,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
                                                .addr = 0x5b,
                                                .mask = GENMASK(5, 0),
                                        },
+                                       .enable_mask = BIT(5),
                                        .status = {
                                                .addr = 0x1b,
                                                .mask = BIT(3),
@@ -1352,14 +1327,8 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
                                .addr = 0x56,
                                .mask = BIT(0),
                        },
-                       .irq1_func = {
-                               .addr = 0x5e,
-                               .mask = BIT(5),
-                       },
-                       .irq2_func = {
-                               .addr = 0x5f,
-                               .mask = BIT(5),
-                       },
+                       .irq1_func = 0x5e,
+                       .irq2_func = 0x5f,
                        .hla = {
                                .addr = 0x03,
                                .mask = BIT(4),
@@ -1448,6 +1417,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
                                                .addr = 0x5b,
                                                .mask = GENMASK(5, 0),
                                        },
+                                       .enable_mask = BIT(5),
                                        .status = {
                                                .addr = 0x45,
                                                .mask = BIT(3),
@@ -1908,10 +1878,11 @@ static int st_lsm6dsx_write_raw(struct iio_dev *iio_dev,
 static int st_lsm6dsx_event_setup(struct st_lsm6dsx_hw *hw, bool state)
 {
        const struct st_lsm6dsx_reg *reg;
+       const struct st_lsm6dsx_event_src *src;
        unsigned int data;
        int err;
 
-       if (!hw->settings->irq_config.irq1_func.addr)
+       if (!hw->irq_routing)
                return -ENOTSUPP;
 
        reg = &hw->settings->event_settings.enable_reg;
@@ -1924,9 +1895,10 @@ static int st_lsm6dsx_event_setup(struct st_lsm6dsx_hw *hw, bool state)
        }
 
        /* Enable wakeup interrupt */
-       data = ST_LSM6DSX_SHIFT_VAL(state, hw->irq_routing->mask);
-       return st_lsm6dsx_update_bits_locked(hw, hw->irq_routing->addr,
-                                            hw->irq_routing->mask, data);
+       src = &hw->settings->event_settings.sources[ST_LSM6DSX_EVENT_WAKEUP];
+       data = ST_LSM6DSX_SHIFT_VAL(state, src->enable_mask);
+       return st_lsm6dsx_update_bits_locked(hw, hw->irq_routing,
+                                            src->enable_mask, data);
 }
 
 static int st_lsm6dsx_read_event(struct iio_dev *iio_dev,
@@ -2180,11 +2152,11 @@ st_lsm6dsx_get_drdy_reg(struct st_lsm6dsx_hw *hw,
 
        switch (drdy_pin) {
        case 1:
-               hw->irq_routing = &hw->settings->irq_config.irq1_func;
+               hw->irq_routing = hw->settings->irq_config.irq1_func;
                *drdy_reg = &hw->settings->irq_config.irq1;
                break;
        case 2:
-               hw->irq_routing = &hw->settings->irq_config.irq2_func;
+               hw->irq_routing = hw->settings->irq_config.irq2_func;
                *drdy_reg = &hw->settings->irq_config.irq2;
                break;
        default: