iio: humidity: hts221: support active-low interrupts
Add support for active low interrupts (IRQF_TRIGGER_LOW and IRQF_TRIGGER_FALLING). Configure the device as active high or low according to the requested irq line. Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
committed by
Jonathan Cameron
parent
e3e25446a3
commit
e7b4b45e1e
@@ -61,6 +61,7 @@ struct hts221_hw {
|
|||||||
extern const struct dev_pm_ops hts221_pm_ops;
|
extern const struct dev_pm_ops hts221_pm_ops;
|
||||||
|
|
||||||
int hts221_config_drdy(struct hts221_hw *hw, bool enable);
|
int hts221_config_drdy(struct hts221_hw *hw, bool enable);
|
||||||
|
int hts221_write_with_mask(struct hts221_hw *hw, u8 addr, u8 mask, u8 val);
|
||||||
int hts221_probe(struct iio_dev *iio_dev);
|
int hts221_probe(struct iio_dev *iio_dev);
|
||||||
int hts221_set_enable(struct hts221_hw *hw, bool enable);
|
int hts221_set_enable(struct hts221_hw *hw, bool enable);
|
||||||
int hts221_allocate_buffers(struct hts221_hw *hw);
|
int hts221_allocate_buffers(struct hts221_hw *hw);
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include "hts221.h"
|
#include "hts221.h"
|
||||||
|
|
||||||
|
#define HTS221_REG_DRDY_HL_ADDR 0x22
|
||||||
|
#define HTS221_REG_DRDY_HL_MASK BIT(7)
|
||||||
#define HTS221_REG_STATUS_ADDR 0x27
|
#define HTS221_REG_STATUS_ADDR 0x27
|
||||||
#define HTS221_RH_DRDY_MASK BIT(1)
|
#define HTS221_RH_DRDY_MASK BIT(1)
|
||||||
#define HTS221_TEMP_DRDY_MASK BIT(0)
|
#define HTS221_TEMP_DRDY_MASK BIT(0)
|
||||||
@@ -67,6 +69,7 @@ static irqreturn_t hts221_trigger_handler_thread(int irq, void *private)
|
|||||||
int hts221_allocate_trigger(struct hts221_hw *hw)
|
int hts221_allocate_trigger(struct hts221_hw *hw)
|
||||||
{
|
{
|
||||||
struct iio_dev *iio_dev = iio_priv_to_dev(hw);
|
struct iio_dev *iio_dev = iio_priv_to_dev(hw);
|
||||||
|
bool irq_active_low = false;
|
||||||
unsigned long irq_type;
|
unsigned long irq_type;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
@@ -76,6 +79,10 @@ int hts221_allocate_trigger(struct hts221_hw *hw)
|
|||||||
case IRQF_TRIGGER_HIGH:
|
case IRQF_TRIGGER_HIGH:
|
||||||
case IRQF_TRIGGER_RISING:
|
case IRQF_TRIGGER_RISING:
|
||||||
break;
|
break;
|
||||||
|
case IRQF_TRIGGER_LOW:
|
||||||
|
case IRQF_TRIGGER_FALLING:
|
||||||
|
irq_active_low = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
dev_info(hw->dev,
|
dev_info(hw->dev,
|
||||||
"mode %lx unsupported, using IRQF_TRIGGER_RISING\n",
|
"mode %lx unsupported, using IRQF_TRIGGER_RISING\n",
|
||||||
@@ -84,6 +91,10 @@ int hts221_allocate_trigger(struct hts221_hw *hw)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = hts221_write_with_mask(hw, HTS221_REG_DRDY_HL_ADDR,
|
||||||
|
HTS221_REG_DRDY_HL_MASK, irq_active_low);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
err = devm_request_threaded_irq(hw->dev, hw->irq, NULL,
|
err = devm_request_threaded_irq(hw->dev, hw->irq, NULL,
|
||||||
hts221_trigger_handler_thread,
|
hts221_trigger_handler_thread,
|
||||||
irq_type | IRQF_ONESHOT,
|
irq_type | IRQF_ONESHOT,
|
||||||
|
|||||||
@@ -135,8 +135,7 @@ static const struct iio_chan_spec hts221_channels[] = {
|
|||||||
IIO_CHAN_SOFT_TIMESTAMP(2),
|
IIO_CHAN_SOFT_TIMESTAMP(2),
|
||||||
};
|
};
|
||||||
|
|
||||||
static int hts221_write_with_mask(struct hts221_hw *hw, u8 addr, u8 mask,
|
int hts221_write_with_mask(struct hts221_hw *hw, u8 addr, u8 mask, u8 val)
|
||||||
u8 val)
|
|
||||||
{
|
{
|
||||||
u8 data;
|
u8 data;
|
||||||
int err;
|
int err;
|
||||||
|
|||||||
Reference in New Issue
Block a user