misc: ft8xx: convert to gpio_dt_spec
Convert SPI usage to `struct gpio_dt_spec`. Signed-off-by: Kumar Gala <galak@kernel.org>
This commit is contained in:
parent
a2ffdaf2b9
commit
06bd942191
1 changed files with 7 additions and 10 deletions
|
@ -23,8 +23,7 @@ static const struct spi_dt_spec spi = SPI_DT_SPEC_INST_GET(0,
|
|||
0);
|
||||
|
||||
/* GPIO int line */
|
||||
#define IRQ_PIN DT_GPIO_PIN(NODE_ID, irq_gpios)
|
||||
static const struct device *int_ft8xx_dev;
|
||||
static const struct gpio_dt_spec irq_gpio = GPIO_DT_SPEC_INST_GET(0, irq_gpios);
|
||||
|
||||
static struct gpio_callback irq_cb_data;
|
||||
|
||||
|
@ -64,25 +63,23 @@ int ft8xx_drv_init(void)
|
|||
/* TODO: Verify if such entry in DTS is present.
|
||||
* If not, use polling mode.
|
||||
*/
|
||||
int_ft8xx_dev = device_get_binding(DT_GPIO_LABEL(NODE_ID, irq_gpios));
|
||||
if (!int_ft8xx_dev) {
|
||||
if (!device_is_ready(irq_gpio.port)) {
|
||||
LOG_ERR("GPIO device %s is not ready", irq_gpio.port->name);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = gpio_pin_configure(int_ft8xx_dev, IRQ_PIN,
|
||||
GPIO_INPUT | DT_GPIO_FLAGS(NODE_ID, irq_gpios));
|
||||
ret = gpio_pin_configure_dt(&irq_gpio, GPIO_INPUT);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = gpio_pin_interrupt_configure(int_ft8xx_dev, IRQ_PIN,
|
||||
GPIO_INT_EDGE_TO_ACTIVE);
|
||||
ret = gpio_pin_interrupt_configure_dt(&irq_gpio, GPIO_INT_EDGE_TO_ACTIVE);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
gpio_init_callback(&irq_cb_data, ft8xx_drv_irq_triggered, BIT(IRQ_PIN));
|
||||
gpio_add_callback(int_ft8xx_dev, &irq_cb_data);
|
||||
gpio_init_callback(&irq_cb_data, ft8xx_drv_irq_triggered, BIT(irq_gpio.pin));
|
||||
gpio_add_callback(irq_gpio.port, &irq_cb_data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue