diff --git a/drivers/misc/ft8xx/ft8xx_drv.c b/drivers/misc/ft8xx/ft8xx_drv.c index 65afb0224b9..548d5b1d334 100644 --- a/drivers/misc/ft8xx/ft8xx_drv.c +++ b/drivers/misc/ft8xx/ft8xx_drv.c @@ -18,13 +18,9 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); #define NODE_ID DT_INST(0, DT_DRV_COMPAT) /* SPI device */ -static const struct device *spi_ft8xx_dev; -static struct spi_cs_control cs_ctrl; -static const struct spi_config spi_cfg = { - .frequency = 8000000UL, - .operation = SPI_WORD_SET(8) | SPI_OP_MODE_MASTER, - .cs = &cs_ctrl, -}; +static const struct spi_dt_spec spi = SPI_DT_SPEC_INST_GET(0, + SPI_WORD_SET(8) | SPI_OP_MODE_MASTER, + 0); /* GPIO int line */ #define IRQ_PIN DT_GPIO_PIN(NODE_ID, irq_gpios) @@ -60,16 +56,8 @@ int ft8xx_drv_init(void) { int ret; - cs_ctrl = (struct spi_cs_control){ - .gpio_dev = device_get_binding( - DT_SPI_DEV_CS_GPIOS_LABEL(NODE_ID)), - .gpio_pin = DT_SPI_DEV_CS_GPIOS_PIN(NODE_ID), - .gpio_dt_flags = DT_SPI_DEV_CS_GPIOS_FLAGS(NODE_ID), - .delay = 0, - }; - - spi_ft8xx_dev = device_get_binding(DT_BUS_LABEL(NODE_ID)); - if (!spi_ft8xx_dev) { + if (!spi_is_ready(&spi)) { + LOG_ERR("SPI bus %s not ready", spi.bus->name); return -ENODEV; } @@ -124,7 +112,7 @@ int ft8xx_drv_write(uint32_t address, const uint8_t *data, unsigned int length) .count = 2, }; - ret = spi_write(spi_ft8xx_dev, &spi_cfg, &tx_bufs); + ret = spi_write_dt(&spi, &tx_bufs); if (ret < 0) { LOG_ERR("SPI write error: %d", ret); } @@ -167,7 +155,7 @@ int ft8xx_drv_read(uint32_t address, uint8_t *data, unsigned int length) .count = 2, }; - ret = spi_transceive(spi_ft8xx_dev, &spi_cfg, &tx_bufs, &rx_bufs); + ret = spi_transceive_dt(&spi, &tx_bufs, &rx_bufs); if (ret < 0) { LOG_ERR("SPI transceive error: %d", ret); } @@ -193,7 +181,7 @@ int ft8xx_drv_command(uint8_t command) .count = 1, }; - ret = spi_write(spi_ft8xx_dev, &spi_cfg, &tx_bufs); + ret = spi_write_dt(&spi, &tx_bufs); if (ret < 0) { LOG_ERR("SPI command error: %d", ret); }