Skip to content

Commit ce8a013

Browse files
committed
drivers: mspi: mspi_dw: Add CONFIG_MSPI_DW_DMA
CONFIG_MSPI_DW_DMA is used to disable the DMA specific code for the mspi_dw.c driver during build-time. Signed-off-by: <David Jewsbury [email protected]>
1 parent ca68f2b commit ce8a013

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

drivers/mspi/Kconfig.dw

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ config MSPI_DW
66
default y
77
depends on DT_HAS_SNPS_DESIGNWARE_SSI_ENABLED
88
select PINCTRL if $(dt_compat_any_has_prop,$(DT_COMPAT_SNPS_DESIGNWARE_SSI),pinctrl-0)
9+
10+
config MSPI_DW_DMA
11+
bool "DesignWare SSI controller DMA support"
12+
default n
13+
depends on MSPI_DW

drivers/mspi/mspi_dw.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ struct mspi_dw_data {
4545
uint32_t ctrlr0;
4646
uint32_t spi_ctrlr0;
4747
uint32_t baudr;
48+
#if defined(CONFIG_MSPI_DW_DMA)
4849
uint32_t dma_cr;
50+
#endif
4951

5052
#if defined(CONFIG_MSPI_XIP)
5153
uint32_t xip_freq;
@@ -70,7 +72,10 @@ struct mspi_dw_data {
7072
/* For locking of controller configuration. */
7173
struct k_sem cfg_lock;
7274
struct mspi_xfer xfer;
75+
#if defined(CONFIG_MSPI_DW_DMA)
76+
7377
void * dma_transfer_list;
78+
#endif
7479
/* Flag to track if async transfer is in progress */
7580
/* TODO: Change to atomic variable when concurrent transactions are supported*/
7681
volatile bool async_in_progress;
@@ -96,9 +101,11 @@ DEFINE_MM_REG_RD(isr, 0x30)
96101
DEFINE_MM_REG_RD(risr, 0x34)
97102
DEFINE_MM_REG_RD_WR(dr, 0x60)
98103
DEFINE_MM_REG_WR(spi_ctrlr0, 0xf4)
104+
#if defined(CONFIG_MSPI_DW_DMA)
99105
DEFINE_MM_REG_WR(dmacr, 0x4C)
100106
DEFINE_MM_REG_WR(dmatdlr, 0x50)
101107
DEFINE_MM_REG_WR(dmardlr, 0x54)
108+
#endif
102109

103110
#if defined(CONFIG_MSPI_XIP)
104111
DEFINE_MM_REG_WR(xip_incr_inst, 0x100)
@@ -271,16 +278,18 @@ static void mspi_dw_isr(const struct device *dev)
271278
&dev_data->xfer.packets[dev_data->packets_done];
272279
bool finished = false;
273280
int rc;
274-
bool dma_irq = vendor_specific_read_dma_irq(dev, dev->config);
275281

276282
uint32_t int_status = read_isr(dev);
277-
283+
#if defined(CONFIG_MSPI_DW_DMA)
284+
bool dma_irq = vendor_specific_read_dma_irq(dev, dev->config);
278285
if(xfer.xfer_mode == MSPI_DMA && dma_irq) {
279286
/* No need to read FIFO by CPU */
280287
finished = true;
281288
}
282289
else {
283-
290+
#else
291+
{
292+
#endif
284293
if (packet->dir == MSPI_TX) {
285294
if (dev_data->buf_pos < dev_data->buf_end) {
286295
if (int_status & ISR_TXEIS_BIT) {
@@ -373,14 +382,15 @@ static void mspi_dw_isr(const struct device *dev)
373382
k_sem_give(&dev_data->finished);
374383
}
375384

376-
385+
#if defined(CONFIG_MSPI_DW_DMA)
377386
/* Free transfer list saved to heap */
378387
if (dev_data->xfer.xfer_mode == MSPI_DMA && dev_data->dma_transfer_list){
379388
vendor_specific_free_dma_transfer_list(dev, dev_data);
380389
dev_data->dma_transfer_list = NULL;
381390
}
382391

383392
}
393+
#endif
384394

385395
vendor_specific_irq_clear(dev, dev->config);
386396
}
@@ -844,6 +854,7 @@ static void tx_control_field(const struct device *dev,
844854
} while (shift);
845855
}
846856

857+
#if defined(CONFIG_MSPI_DW_DMA)
847858
static int start_next_packet_dma(const struct device *dev, k_timeout_t timeout)
848859
{
849860
const struct mspi_dw_config *dev_config = dev->config;
@@ -978,6 +989,7 @@ static int start_next_packet_dma(const struct device *dev, k_timeout_t timeout)
978989

979990
return rc;
980991
}
992+
#endif /* CONFIG_MSPI_DW_DMA */
981993

982994
/**
983995
* @brief Start next packet using PIO (FIFO) mode
@@ -1263,7 +1275,12 @@ static int start_next_packet(const struct device *dev, k_timeout_t timeout)
12631275
struct mspi_dw_data * dev_data = dev->data;
12641276
switch (dev_data->xfer.xfer_mode) {
12651277
case MSPI_DMA:
1278+
#ifdef CONFIG_MSPI_DW_DMA
12661279
return start_next_packet_dma(dev, timeout);
1280+
#else
1281+
LOG_ERR("CONFIG_MSPI_DW_DMA not enabled");
1282+
return -ENOTSUP;
1283+
#endif
12671284
case MSPI_PIO:
12681285
return start_next_packet_pio(dev, timeout);
12691286
default:
@@ -1705,11 +1722,12 @@ static DEVICE_API(mspi, drv_api) = {
17051722
7 * TX_FIFO_DEPTH(inst) / 8 - 1), \
17061723
.rx_fifo_threshold = \
17071724
DT_INST_PROP_OR(inst, rx_fifo_threshold, \
1708-
1 * RX_FIFO_DEPTH(inst) / 8 - 1), \
1725+
1 * RX_FIFO_DEPTH(inst) / 8 - 1) \
1726+
IF_ENABLED(CONFIG_MSPI_DW_DMA, (, \
17091727
.dma_tx_data_level = \
17101728
DT_INST_PROP_OR(inst, dma_transmit_data_level, 0), \
17111729
.dma_rx_data_level = \
1712-
DT_INST_PROP_OR(inst, dma_recieve_data_level, 0)
1730+
DT_INST_PROP_OR(inst, dma_recieve_data_level, 0)))
17131731
#define MSPI_DW_INST(inst) \
17141732
PM_DEVICE_DT_INST_DEFINE(inst, dev_pm_action_cb); \
17151733
IF_ENABLED(CONFIG_PINCTRL, (PINCTRL_DT_INST_DEFINE(inst);)) \

drivers/mspi/mspi_dw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,10 @@ struct mspi_dw_config {
273273
uint8_t max_queued_dummy_bytes;
274274
uint8_t tx_fifo_threshold;
275275
uint8_t rx_fifo_threshold;
276+
#ifdef CONFIG_MSPI_DW_DMA
276277
uint8_t dma_tx_data_level;
277278
uint8_t dma_rx_data_level;
279+
#endif
278280
DECLARE_REG_ACCESS();
279281
bool sw_multi_periph;
280282
enum mspi_op_mode op_mode;

0 commit comments

Comments
 (0)