misc: ft8xx: convert to spi_dt_spec
Convert SPI usage to `struct spi_dt_spec`. Signed-off-by: Kumar Gala <galak@kernel.org>
This commit is contained in:
parent
5ca0bbac96
commit
a2ffdaf2b9
1 changed files with 8 additions and 20 deletions
|
@ -18,13 +18,9 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
|
||||||
#define NODE_ID DT_INST(0, DT_DRV_COMPAT)
|
#define NODE_ID DT_INST(0, DT_DRV_COMPAT)
|
||||||
|
|
||||||
/* SPI device */
|
/* SPI device */
|
||||||
static const struct device *spi_ft8xx_dev;
|
static const struct spi_dt_spec spi = SPI_DT_SPEC_INST_GET(0,
|
||||||
static struct spi_cs_control cs_ctrl;
|
SPI_WORD_SET(8) | SPI_OP_MODE_MASTER,
|
||||||
static const struct spi_config spi_cfg = {
|
0);
|
||||||
.frequency = 8000000UL,
|
|
||||||
.operation = SPI_WORD_SET(8) | SPI_OP_MODE_MASTER,
|
|
||||||
.cs = &cs_ctrl,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* GPIO int line */
|
/* GPIO int line */
|
||||||
#define IRQ_PIN DT_GPIO_PIN(NODE_ID, irq_gpios)
|
#define IRQ_PIN DT_GPIO_PIN(NODE_ID, irq_gpios)
|
||||||
|
@ -60,16 +56,8 @@ int ft8xx_drv_init(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
cs_ctrl = (struct spi_cs_control){
|
if (!spi_is_ready(&spi)) {
|
||||||
.gpio_dev = device_get_binding(
|
LOG_ERR("SPI bus %s not ready", spi.bus->name);
|
||||||
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) {
|
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +112,7 @@ int ft8xx_drv_write(uint32_t address, const uint8_t *data, unsigned int length)
|
||||||
.count = 2,
|
.count = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
ret = spi_write(spi_ft8xx_dev, &spi_cfg, &tx_bufs);
|
ret = spi_write_dt(&spi, &tx_bufs);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
LOG_ERR("SPI write error: %d", ret);
|
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,
|
.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) {
|
if (ret < 0) {
|
||||||
LOG_ERR("SPI transceive error: %d", ret);
|
LOG_ERR("SPI transceive error: %d", ret);
|
||||||
}
|
}
|
||||||
|
@ -193,7 +181,7 @@ int ft8xx_drv_command(uint8_t command)
|
||||||
.count = 1,
|
.count = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
ret = spi_write(spi_ft8xx_dev, &spi_cfg, &tx_bufs);
|
ret = spi_write_dt(&spi, &tx_bufs);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
LOG_ERR("SPI command error: %d", ret);
|
LOG_ERR("SPI command error: %d", ret);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue