drivers: sensor: Convert fxas21002 to new gpio api
Converts the fxas21002 sensor driver to the new gpio api. Updates device trees for all boards with this sensor to active low gpio interrupts by default. Tested on the hexiwear_k64 board. Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
This commit is contained in:
parent
b0ad7bb594
commit
0f38786889
6 changed files with 21 additions and 8 deletions
|
@ -100,8 +100,8 @@
|
|||
compatible = "nxp,fxas21002";
|
||||
reg = <0x20>;
|
||||
label = "FXAS21002";
|
||||
int1-gpios = <&gpiod 1 0>;
|
||||
int2-gpios = <&gpioc 18 0>;
|
||||
int1-gpios = <&gpiod 1 GPIO_ACTIVE_LOW>;
|
||||
int2-gpios = <&gpioc 18 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
compatible = "nxp,fxas21002";
|
||||
reg = <0x20>;
|
||||
label = "FXAS21002";
|
||||
int1-gpios = <&gpio7 0 0>;
|
||||
int1-gpios = <&gpio7 0 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
@ -293,9 +293,11 @@ static const struct fxas21002_config fxas21002_config = {
|
|||
#ifdef CONFIG_FXAS21002_DRDY_INT1
|
||||
.gpio_name = DT_INST_0_NXP_FXAS21002_INT1_GPIOS_CONTROLLER,
|
||||
.gpio_pin = DT_INST_0_NXP_FXAS21002_INT1_GPIOS_PIN,
|
||||
.gpio_flags = DT_INST_0_NXP_FXAS21002_INT1_GPIOS_FLAGS,
|
||||
#else
|
||||
.gpio_name = DT_INST_0_NXP_FXAS21002_INT2_GPIOS_CONTROLLER,
|
||||
.gpio_pin = DT_INST_0_NXP_FXAS21002_INT2_GPIOS_PIN,
|
||||
.gpio_flags = DT_INST_0_NXP_FXAS21002_INT2_GPIOS_FLAGS,
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -61,6 +61,7 @@ struct fxas21002_config {
|
|||
#ifdef CONFIG_FXAS21002_TRIGGER
|
||||
char *gpio_name;
|
||||
u8_t gpio_pin;
|
||||
gpio_devicetree_flags_t gpio_flags;
|
||||
#endif
|
||||
u8_t i2c_address;
|
||||
u8_t whoami;
|
||||
|
|
|
@ -21,7 +21,8 @@ static void fxas21002_gpio_callback(struct device *dev,
|
|||
return;
|
||||
}
|
||||
|
||||
gpio_pin_disable_callback(dev, data->gpio_pin);
|
||||
gpio_pin_interrupt_configure(data->gpio, data->gpio_pin,
|
||||
GPIO_INT_DISABLE);
|
||||
|
||||
#if defined(CONFIG_FXAS21002_TRIGGER_OWN_THREAD)
|
||||
k_sem_give(&data->trig_sem);
|
||||
|
@ -68,7 +69,8 @@ static void fxas21002_handle_int(void *arg)
|
|||
fxas21002_handle_drdy_int(dev);
|
||||
}
|
||||
|
||||
gpio_pin_enable_callback(data->gpio, config->gpio_pin);
|
||||
gpio_pin_interrupt_configure(data->gpio, config->gpio_pin,
|
||||
GPIO_INT_EDGE_TO_ACTIVE);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FXAS21002_TRIGGER_OWN_THREAD
|
||||
|
@ -206,15 +208,15 @@ int fxas21002_trigger_init(struct device *dev)
|
|||
data->gpio_pin = config->gpio_pin;
|
||||
|
||||
gpio_pin_configure(data->gpio, config->gpio_pin,
|
||||
GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
|
||||
GPIO_INT_ACTIVE_LOW | GPIO_INT_DEBOUNCE);
|
||||
GPIO_INPUT | config->gpio_flags);
|
||||
|
||||
gpio_init_callback(&data->gpio_cb, fxas21002_gpio_callback,
|
||||
BIT(config->gpio_pin));
|
||||
|
||||
gpio_add_callback(data->gpio, &data->gpio_cb);
|
||||
|
||||
gpio_pin_enable_callback(data->gpio, config->gpio_pin);
|
||||
gpio_pin_interrupt_configure(data->gpio, config->gpio_pin,
|
||||
GPIO_INT_EDGE_TO_ACTIVE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,15 @@ properties:
|
|||
int1-gpios:
|
||||
type: phandle-array
|
||||
required: false
|
||||
description: INT1 pin
|
||||
This pin defaults to active low when produced by the sensor.
|
||||
The property value should ensure the flags properly describe
|
||||
the signal that is presented to the driver.
|
||||
|
||||
int2-gpios:
|
||||
type: phandle-array
|
||||
required: false
|
||||
description: INT2 pin
|
||||
This pin defaults to active low when produced by the sensor.
|
||||
The property value should ensure the flags properly describe
|
||||
the signal that is presented to the driver.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue