Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drivers/spi/Kconfig.cdns
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

config SPI_CDNS
bool "Cadence SPI controller driver"
default y
depends on DT_HAS_CDNS_SPI_ENABLED
help
Enable the SPI peripherals based on Cadence IP6524
52 changes: 9 additions & 43 deletions drivers/spi/spi_cdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ struct spi_cdns_cfg {
uint32_t clock_frequency;
uint32_t ext_clock;
irq_config_func_t irq_config;
#ifdef CONFIG_PINCTRL
const struct pinctrl_dev_config *pcfg;
#endif
uint8_t fifo_width;
uint16_t rx_fifo_depth;
uint16_t tx_fifo_depth;
Expand Down Expand Up @@ -573,7 +570,6 @@ static void spi_cdns_isr(const struct device *dev)
spi_cdns_cs_control(dev, false);
}
pm_device_busy_clear(dev);
pm_device_runtime_put(dev);
}
#endif

Expand Down Expand Up @@ -642,7 +638,6 @@ static int spi_cdns_transceive(const struct device *dev, const struct spi_config

spi_context_lock(&data->ctx, asynchronous, cb, userdata, config);

pm_device_runtime_get(dev);
pm_device_busy_set(dev);

spi_cdns_spi_enable(dev, false);
Expand Down Expand Up @@ -712,7 +707,6 @@ static int spi_cdns_transceive(const struct device *dev, const struct spi_config
spi_cdns_cs_control(dev, false);
}
pm_device_busy_clear(dev);
pm_device_runtime_put(dev);
}

#ifdef CONFIG_SPI_SLAVE
Expand Down Expand Up @@ -795,39 +789,6 @@ static int spi_cdns_release(const struct device *dev, const struct spi_config *c
return 0;
}

#ifdef CONFIG_PM_DEVICE
static int spi_cdns_pm_action(const struct device *dev, enum pm_device_action action)
{
const struct spi_cdns_cfg *cfg = dev->config;
int ret;

switch (action) {
case PM_DEVICE_ACTION_RESUME:
/* TODO: Enable SPI Clock */
#ifdef CONFIG_PINCTRL
ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT);
if (ret < 0) {
return ret;
}
#endif
break;
case PM_DEVICE_ACTION_SUSPEND:
/* TODO: Disable SPI Clock */
#ifdef CONFIG_PINCTRL
ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_SLEEP);
if (ret < 0) {
return ret;
}
#endif
break;
default:
ret = -ENOTSUP;
}

return ret;
}
#endif /* CONFIG_PM_DEVICE */

/**
* SPI driver API registered in Zephyr spi framework
*/
Expand All @@ -837,10 +798,13 @@ static DEVICE_API(spi, spi_cdns_api) = {
.transceive_async = spi_cdns_transceive_async,
#endif /* CONFIG_SPI_ASYNC */
.release = spi_cdns_release,
#ifdef CONFIG_SPI_RTIO
.iodev_submit = spi_rtio_iodev_default_submit,
#endif /* CONFIG_SPI_RTIO */
};

/* Set clock-frequency-ext to pclk / 5 if there is no clock-frequency-ext */
#define SPI_CLOCK_FREQUENCY_EXT(n) \
#define SPI_CLOCK_FREQUENCY_EXT(n) \
COND_CODE_1(DT_INST_NODE_HAS_PROP(n, clock_frequency_ext), \
(DT_INST_PROP(n, clock_frequency_ext)), \
(DT_INST_PROP(n, clock_frequency) / 5))
Expand All @@ -856,10 +820,12 @@ static DEVICE_API(spi, spi_cdns_api) = {
.irq_config = spi_cdns_irq_config_##n, \
.clock_frequency = DT_INST_PROP(n, clock_frequency), \
.ext_clock = SPI_CLOCK_FREQUENCY_EXT(n), \
.fifo_width = DT_INST_PROP(n, fifo_width), \
.tx_fifo_depth = DT_INST_PROP(n, tx_fifo_depth), \
.rx_fifo_depth = DT_INST_PROP(n, rx_fifo_depth), \
}; \
SPI_DEVICE_DT_INST_DEFINE(n, spi_cdns_init, spi_cdns_pm_action, &spi_cdns_data_##n, \
&spi_cdns_cfg_##n, POST_KERNEL, CONFIG_SPI_INIT_PRIORITY, \
&spi_cdns_api); \
SPI_DEVICE_DT_INST_DEFINE(n, spi_cdns_init, NULL, &spi_cdns_data_##n, &spi_cdns_cfg_##n, \
POST_KERNEL, CONFIG_SPI_INIT_PRIORITY, &spi_cdns_api); \
static void spi_cdns_irq_config_##n(void) \
{ \
IRQ_CONNECT(DT_INST_IRQN(n), DT_INST_IRQ(n, priority), spi_cdns_isr, \
Expand Down
Loading