driver/sensor: lis3mdl: update to use new GPIO API

Get rid of all the deprecated functions and definitions
replacing them with the new ones.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
This commit is contained in:
Armando Visconti 2020-01-16 13:26:54 +01:00 committed by Carles Cufí
commit b0ad7bb594
4 changed files with 21 additions and 10 deletions

View file

@ -22,7 +22,7 @@
lis3mdl-magn@1e {
compatible = "st,lis3mdl-magn";
reg = <0x1e>;
irq-gpios = <&arduino_header 4 0>; /* A4 */
irq-gpios = <&arduino_header 4 GPIO_ACTIVE_HIGH>; /* A4 */
label = "LIS3MDL";
};

View file

@ -33,8 +33,9 @@ int lis3mdl_trigger_set(struct device *dev,
drv_data->data_ready_trigger = *trig;
gpio_pin_enable_callback(drv_data->gpio,
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN);
gpio_pin_interrupt_configure(drv_data->gpio,
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN,
GPIO_INT_EDGE_TO_ACTIVE);
return 0;
}
@ -47,7 +48,9 @@ static void lis3mdl_gpio_callback(struct device *dev,
ARG_UNUSED(pins);
gpio_pin_disable_callback(dev, DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN);
gpio_pin_interrupt_configure(dev,
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN,
GPIO_INT_DISABLE);
#if defined(CONFIG_LIS3MDL_TRIGGER_OWN_THREAD)
k_sem_give(&drv_data->gpio_sem);
@ -66,8 +69,9 @@ static void lis3mdl_thread_cb(void *arg)
&drv_data->data_ready_trigger);
}
gpio_pin_enable_callback(drv_data->gpio,
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN);
gpio_pin_interrupt_configure(drv_data->gpio,
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN,
GPIO_INT_EDGE_TO_ACTIVE);
}
#ifdef CONFIG_LIS3MDL_TRIGGER_OWN_THREAD
@ -110,8 +114,8 @@ int lis3mdl_init_interrupt(struct device *dev)
gpio_pin_configure(drv_data->gpio,
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN,
GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
GPIO_INT_ACTIVE_HIGH | GPIO_INT_DEBOUNCE);
GPIO_INPUT |
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_FLAGS);
gpio_init_callback(&drv_data->gpio_cb,
lis3mdl_gpio_callback,
@ -148,8 +152,9 @@ int lis3mdl_init_interrupt(struct device *dev)
drv_data->dev = dev;
#endif
gpio_pin_enable_callback(drv_data->gpio,
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN);
gpio_pin_interrupt_configure(drv_data->gpio,
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN,
GPIO_INT_EDGE_TO_ACTIVE);
return 0;
}

View file

@ -11,3 +11,8 @@ properties:
irq-gpios:
required: false
type: phandle-array
description: DRDY pin
This pin defaults to active high when produced by the sensor.
The property value should ensure the flags properly describe
the signal that is presented to the driver.

View file

@ -125,6 +125,7 @@
#define DT_INST_0_ST_LIS3MDL_MAGN_BASE_ADDRESS 0x19
#define DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN 0
#define DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_CONTROLLER ""
#define DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_FLAGS 0
#endif
#ifndef DT_INST_0_ST_LPS25HB_PRESS_LABEL