提交 75d4c6d2 编写于 作者: L Lorenzo Bianconi 提交者: Jonathan Cameron

iio: st_sensors: decouple irq1 configuration parameters from the irq2 ones

Separate data-ready configuration parameters for INT1 and INT2 pins in
st_sensor_data_ready_irq data structure. That change will be use to
properly support LIS2DW12 accel sensor.
Signed-off-by: NLorenzo Bianconi <lorenzo.bianconi@st.com>
Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: NJonathan Cameron <Jonathan.Cameron@huawei.com>
上级 e72a0601
...@@ -159,9 +159,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { ...@@ -159,9 +159,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
.mask = 0x80, .mask = 0x80,
}, },
.drdy_irq = { .drdy_irq = {
.addr = 0x22, .int1 = {
.mask_int1 = 0x10, .addr = 0x22,
.mask_int2 = 0x00, .mask = 0x10,
},
.addr_ihl = 0x25, .addr_ihl = 0x25,
.mask_ihl = 0x02, .mask_ihl = 0x02,
.stat_drdy = { .stat_drdy = {
...@@ -232,9 +233,14 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { ...@@ -232,9 +233,14 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
.mask = 0x80, .mask = 0x80,
}, },
.drdy_irq = { .drdy_irq = {
.addr = 0x22, .int1 = {
.mask_int1 = 0x02, .addr = 0x22,
.mask_int2 = 0x10, .mask = 0x02,
},
.int2 = {
.addr = 0x22,
.mask = 0x10,
},
.addr_ihl = 0x22, .addr_ihl = 0x22,
.mask_ihl = 0x80, .mask_ihl = 0x80,
.addr_od = 0x22, .addr_od = 0x22,
...@@ -319,9 +325,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { ...@@ -319,9 +325,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
.mask = 0x08, .mask = 0x08,
}, },
.drdy_irq = { .drdy_irq = {
.addr = 0x23, .int1 = {
.mask_int1 = 0x80, .addr = 0x23,
.mask_int2 = 0x00, .mask = 0x80,
},
.addr_ihl = 0x23, .addr_ihl = 0x23,
.mask_ihl = 0x40, .mask_ihl = 0x40,
.stat_drdy = { .stat_drdy = {
...@@ -396,8 +403,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { ...@@ -396,8 +403,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
.mask = 0x01, .mask = 0x01,
}, },
.drdy_irq = { .drdy_irq = {
.addr = 0x21, .int1 = {
.mask_int1 = 0x04, .addr = 0x21,
.mask = 0x04,
},
.stat_drdy = { .stat_drdy = {
.addr = ST_SENSORS_DEFAULT_STAT_ADDR, .addr = ST_SENSORS_DEFAULT_STAT_ADDR,
.mask = 0x07, .mask = 0x07,
...@@ -456,9 +465,14 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { ...@@ -456,9 +465,14 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
}, },
}, },
.drdy_irq = { .drdy_irq = {
.addr = 0x22, .int1 = {
.mask_int1 = 0x04, .addr = 0x22,
.mask_int2 = 0x20, .mask = 0x04,
},
.int2 = {
.addr = 0x22,
.mask = 0x20,
},
.addr_ihl = 0x22, .addr_ihl = 0x22,
.mask_ihl = 0x80, .mask_ihl = 0x80,
.addr_od = 0x22, .addr_od = 0x22,
...@@ -528,9 +542,14 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { ...@@ -528,9 +542,14 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
.mask = 0x80, .mask = 0x80,
}, },
.drdy_irq = { .drdy_irq = {
.addr = 0x22, .int1 = {
.mask_int1 = 0x02, .addr = 0x22,
.mask_int2 = 0x10, .mask = 0x02,
},
.int2 = {
.addr = 0x22,
.mask = 0x10,
},
.addr_ihl = 0x22, .addr_ihl = 0x22,
.mask_ihl = 0x80, .mask_ihl = 0x80,
}, },
...@@ -582,8 +601,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { ...@@ -582,8 +601,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
.bdu = { .bdu = {
}, },
.drdy_irq = { .drdy_irq = {
.addr = 0x21, .int1 = {
.mask_int1 = 0x04, .addr = 0x21,
.mask = 0x04,
},
.stat_drdy = { .stat_drdy = {
.addr = ST_SENSORS_DEFAULT_STAT_ADDR, .addr = ST_SENSORS_DEFAULT_STAT_ADDR,
.mask = 0x07, .mask = 0x07,
...@@ -653,9 +674,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { ...@@ -653,9 +674,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
}, },
}, },
.drdy_irq = { .drdy_irq = {
.addr = 0x22, .int1 = {
.mask_int1 = 0x10, .addr = 0x22,
.mask_int2 = 0x00, .mask = 0x10,
},
.addr_ihl = 0x25, .addr_ihl = 0x25,
.mask_ihl = 0x02, .mask_ihl = 0x02,
.stat_drdy = { .stat_drdy = {
......
...@@ -283,7 +283,8 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev, ...@@ -283,7 +283,8 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,
struct st_sensor_data *sdata = iio_priv(indio_dev); struct st_sensor_data *sdata = iio_priv(indio_dev);
/* Sensor does not support interrupts */ /* Sensor does not support interrupts */
if (sdata->sensor_settings->drdy_irq.addr == 0) { if (!sdata->sensor_settings->drdy_irq.int1.addr &&
!sdata->sensor_settings->drdy_irq.int2.addr) {
if (pdata->drdy_int_pin) if (pdata->drdy_int_pin)
dev_info(&indio_dev->dev, dev_info(&indio_dev->dev,
"DRDY on pin INT%d specified, but sensor " "DRDY on pin INT%d specified, but sensor "
...@@ -294,7 +295,7 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev, ...@@ -294,7 +295,7 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,
switch (pdata->drdy_int_pin) { switch (pdata->drdy_int_pin) {
case 1: case 1:
if (sdata->sensor_settings->drdy_irq.mask_int1 == 0) { if (!sdata->sensor_settings->drdy_irq.int1.mask) {
dev_err(&indio_dev->dev, dev_err(&indio_dev->dev,
"DRDY on INT1 not available.\n"); "DRDY on INT1 not available.\n");
return -EINVAL; return -EINVAL;
...@@ -302,7 +303,7 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev, ...@@ -302,7 +303,7 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,
sdata->drdy_int_pin = 1; sdata->drdy_int_pin = 1;
break; break;
case 2: case 2:
if (sdata->sensor_settings->drdy_irq.mask_int2 == 0) { if (!sdata->sensor_settings->drdy_irq.int2.mask) {
dev_err(&indio_dev->dev, dev_err(&indio_dev->dev,
"DRDY on INT2 not available.\n"); "DRDY on INT2 not available.\n");
return -EINVAL; return -EINVAL;
...@@ -460,10 +461,11 @@ EXPORT_SYMBOL(st_sensors_init_sensor); ...@@ -460,10 +461,11 @@ EXPORT_SYMBOL(st_sensors_init_sensor);
int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable) int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable)
{ {
int err; int err;
u8 drdy_mask; u8 drdy_addr, drdy_mask;
struct st_sensor_data *sdata = iio_priv(indio_dev); struct st_sensor_data *sdata = iio_priv(indio_dev);
if (!sdata->sensor_settings->drdy_irq.addr) { if (!sdata->sensor_settings->drdy_irq.int1.addr &&
!sdata->sensor_settings->drdy_irq.int2.addr) {
/* /*
* there are some devices (e.g. LIS3MDL) where drdy line is * there are some devices (e.g. LIS3MDL) where drdy line is
* routed to a given pin and it is not possible to select a * routed to a given pin and it is not possible to select a
...@@ -485,18 +487,20 @@ int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable) ...@@ -485,18 +487,20 @@ int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable)
goto st_accel_set_dataready_irq_error; goto st_accel_set_dataready_irq_error;
} }
if (sdata->drdy_int_pin == 1) if (sdata->drdy_int_pin == 1) {
drdy_mask = sdata->sensor_settings->drdy_irq.mask_int1; drdy_addr = sdata->sensor_settings->drdy_irq.int1.addr;
else drdy_mask = sdata->sensor_settings->drdy_irq.int1.mask;
drdy_mask = sdata->sensor_settings->drdy_irq.mask_int2; } else {
drdy_addr = sdata->sensor_settings->drdy_irq.int2.addr;
drdy_mask = sdata->sensor_settings->drdy_irq.int2.mask;
}
/* Flag to the poll function that the hardware trigger is in use */ /* Flag to the poll function that the hardware trigger is in use */
sdata->hw_irq_trigger = enable; sdata->hw_irq_trigger = enable;
/* Enable/Disable the interrupt generator for data ready. */ /* Enable/Disable the interrupt generator for data ready. */
err = st_sensors_write_data_with_mask(indio_dev, err = st_sensors_write_data_with_mask(indio_dev, drdy_addr,
sdata->sensor_settings->drdy_irq.addr, drdy_mask, (int)enable);
drdy_mask, (int)enable);
st_accel_set_dataready_irq_error: st_accel_set_dataready_irq_error:
return err; return err;
......
...@@ -111,8 +111,10 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = { ...@@ -111,8 +111,10 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = {
.mask = 0x80, .mask = 0x80,
}, },
.drdy_irq = { .drdy_irq = {
.addr = 0x22, .int2 = {
.mask_int2 = 0x08, .addr = 0x22,
.mask = 0x08,
},
/* /*
* The sensor has IHL (active low) and open * The sensor has IHL (active low) and open
* drain settings, but only for INT1 and not * drain settings, but only for INT1 and not
...@@ -184,8 +186,10 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = { ...@@ -184,8 +186,10 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = {
.mask = 0x80, .mask = 0x80,
}, },
.drdy_irq = { .drdy_irq = {
.addr = 0x22, .int2 = {
.mask_int2 = 0x08, .addr = 0x22,
.mask = 0x08,
},
/* /*
* The sensor has IHL (active low) and open * The sensor has IHL (active low) and open
* drain settings, but only for INT1 and not * drain settings, but only for INT1 and not
...@@ -252,8 +256,10 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = { ...@@ -252,8 +256,10 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = {
.mask = 0x80, .mask = 0x80,
}, },
.drdy_irq = { .drdy_irq = {
.addr = 0x22, .int2 = {
.mask_int2 = 0x08, .addr = 0x22,
.mask = 0x08,
},
/* /*
* The sensor has IHL (active low) and open * The sensor has IHL (active low) and open
* drain settings, but only for INT1 and not * drain settings, but only for INT1 and not
......
...@@ -362,8 +362,10 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = { ...@@ -362,8 +362,10 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
.mask = 0x10, .mask = 0x10,
}, },
.drdy_irq = { .drdy_irq = {
.addr = 0x62, .int1 = {
.mask_int1 = 0x01, .addr = 0x62,
.mask = 0x01,
},
.stat_drdy = { .stat_drdy = {
.addr = 0x67, .addr = 0x67,
.mask = 0x07, .mask = 0x07,
......
...@@ -280,9 +280,14 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { ...@@ -280,9 +280,14 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
.mask = 0x04, .mask = 0x04,
}, },
.drdy_irq = { .drdy_irq = {
.addr = 0x22, .int1 = {
.mask_int1 = 0x04, .addr = 0x22,
.mask_int2 = 0x20, .mask = 0x04,
},
.int2 = {
.addr = 0x22,
.mask = 0x20,
},
.addr_ihl = 0x22, .addr_ihl = 0x22,
.mask_ihl = 0x80, .mask_ihl = 0x80,
.addr_od = 0x22, .addr_od = 0x22,
...@@ -338,9 +343,6 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { ...@@ -338,9 +343,6 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
.addr = 0x20, .addr = 0x20,
.mask = 0x04, .mask = 0x04,
}, },
.drdy_irq = {
.addr = 0,
},
.multi_read_bit = true, .multi_read_bit = true,
.bootime = 2, .bootime = 2,
}, },
...@@ -391,9 +393,10 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { ...@@ -391,9 +393,10 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
.mask = 0x04, .mask = 0x04,
}, },
.drdy_irq = { .drdy_irq = {
.addr = 0x23, .int1 = {
.mask_int1 = 0x01, .addr = 0x23,
.mask_int2 = 0x00, .mask = 0x01,
},
.addr_ihl = 0x22, .addr_ihl = 0x22,
.mask_ihl = 0x80, .mask_ihl = 0x80,
.addr_od = 0x22, .addr_od = 0x22,
...@@ -455,9 +458,10 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { ...@@ -455,9 +458,10 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
.mask = 0x02, .mask = 0x02,
}, },
.drdy_irq = { .drdy_irq = {
.addr = 0x12, .int1 = {
.mask_int1 = 0x04, .addr = 0x12,
.mask_int2 = 0x00, .mask = 0x04,
},
.addr_ihl = 0x12, .addr_ihl = 0x12,
.mask_ihl = 0x80, .mask_ihl = 0x80,
.addr_od = 0x12, .addr_od = 0x12,
...@@ -614,7 +618,8 @@ int st_press_common_probe(struct iio_dev *indio_dev) ...@@ -614,7 +618,8 @@ int st_press_common_probe(struct iio_dev *indio_dev)
press_data->odr = press_data->sensor_settings->odr.odr_avl[0].hz; press_data->odr = press_data->sensor_settings->odr.odr_avl[0].hz;
/* Some devices don't support a data ready pin. */ /* Some devices don't support a data ready pin. */
if (!pdata && press_data->sensor_settings->drdy_irq.addr) if (!pdata && (press_data->sensor_settings->drdy_irq.int1.addr ||
press_data->sensor_settings->drdy_irq.int2.addr))
pdata = (struct st_sensors_platform_data *)&default_press_pdata; pdata = (struct st_sensors_platform_data *)&default_press_pdata;
err = st_sensors_init_sensor(indio_dev, press_data->dev->platform_data); err = st_sensors_init_sensor(indio_dev, press_data->dev->platform_data);
......
...@@ -132,9 +132,8 @@ struct st_sensor_das { ...@@ -132,9 +132,8 @@ struct st_sensor_das {
/** /**
* struct st_sensor_data_ready_irq - ST sensor device data-ready interrupt * struct st_sensor_data_ready_irq - ST sensor device data-ready interrupt
* @addr: address of the register. * struct int1 - data-ready configuration register for INT1 pin.
* @mask_int1: mask to enable/disable IRQ on INT1 pin. * struct int2 - data-ready configuration register for INT2 pin.
* @mask_int2: mask to enable/disable IRQ on INT2 pin.
* @addr_ihl: address to enable/disable active low on the INT lines. * @addr_ihl: address to enable/disable active low on the INT lines.
* @mask_ihl: mask to enable/disable active low on the INT lines. * @mask_ihl: mask to enable/disable active low on the INT lines.
* @addr_od: address to enable/disable Open Drain on the INT lines. * @addr_od: address to enable/disable Open Drain on the INT lines.
...@@ -145,9 +144,14 @@ struct st_sensor_das { ...@@ -145,9 +144,14 @@ struct st_sensor_das {
* @en_mask: mask to write the on/off value for enable. * @en_mask: mask to write the on/off value for enable.
*/ */
struct st_sensor_data_ready_irq { struct st_sensor_data_ready_irq {
u8 addr; struct {
u8 mask_int1; u8 addr;
u8 mask_int2; u8 mask;
} int1;
struct {
u8 addr;
u8 mask;
} int2;
u8 addr_ihl; u8 addr_ihl;
u8 mask_ihl; u8 mask_ihl;
u8 addr_od; u8 addr_od;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册