Skip to content

Commit 2b52ec2

Browse files
ananglbjarki-andreasen
authored andcommitted
[nrf noup] drivers: spi_dw: Bring back custom EXMIF peripheral handling
This commit brings back modifications from these reverted commits: - f68b2ed - e606246 slightly adjusted so that the EXMIF peripheral is still by default handled by the mspi_dw driver, and in cases where this driver cannot be used because something still does not work correctly, one can switch to the old solution based on the tweaked spi_dw driver. Signed-off-by: Andrzej Głąbek <[email protected]> (cherry picked from commit c3c1692) Signed-off-by: Bjarki Arge Andreasen <[email protected]>
1 parent ccb2d5a commit 2b52ec2

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

drivers/pinctrl/pinctrl_nrf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,8 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt,
531531
input = NRF_GPIO_PIN_INPUT_CONNECT;
532532
break;
533533
#endif /* DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_can) */
534-
#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_exmif)
534+
#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_exmif) || \
535+
DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_exmif_spi)
535536
/* Pin routing is controlled by secure domain, via UICR */
536537
case NRF_FUN_EXMIF_CK:
537538
case NRF_FUN_EXMIF_DQ0:

drivers/spi/spi_dw.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ LOG_MODULE_REGISTER(spi_dw);
4141
#include <zephyr/drivers/pinctrl.h>
4242
#endif
4343

44+
#ifdef CONFIG_HAS_NRFX
45+
#include <nrfx.h>
46+
#endif
47+
4448
static inline bool spi_dw_is_slave(struct spi_dw_data *spi)
4549
{
4650
return (IS_ENABLED(CONFIG_SPI_SLAVE) &&
@@ -258,6 +262,7 @@ static int spi_dw_configure(const struct device *dev,
258262
/* Baud rate and Slave select, for master only */
259263
write_baudr(dev, SPI_DW_CLK_DIVIDER(info->clock_frequency,
260264
config->frequency));
265+
write_ser(dev, BIT(config->slave));
261266
}
262267

263268
if (spi_dw_is_slave(spi)) {
@@ -512,6 +517,10 @@ void spi_dw_isr(const struct device *dev)
512517
uint32_t int_status;
513518
int error;
514519

520+
#ifdef CONFIG_HAS_NRFX
521+
NRF_EXMIF->EVENTS_CORE = 0;
522+
#endif
523+
515524
int_status = read_isr(dev);
516525

517526
LOG_DBG("SPI %p int_status 0x%x - (tx: %d, rx: %d)", dev, int_status,
@@ -560,6 +569,11 @@ int spi_dw_init(const struct device *dev)
560569

561570
DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE);
562571

572+
#ifdef CONFIG_HAS_NRFX
573+
NRF_EXMIF->INTENSET = BIT(0);
574+
NRF_EXMIF->TASKS_START = 1;
575+
#endif
576+
563577
info->config_func();
564578

565579
/* Masking interrupt and making sure controller is disabled */
@@ -584,6 +598,11 @@ int spi_dw_init(const struct device *dev)
584598
return 0;
585599
}
586600

601+
#define REG_ADDR(inst) \
602+
COND_CODE_1(DT_NODE_HAS_COMPAT(DT_DRV_INST(inst), nordic_nrf_exmif_spi), \
603+
(Z_DEVICE_MMIO_NAMED_ROM_INITIALIZER(core, DT_DRV_INST(inst))), \
604+
(DEVICE_MMIO_ROM_INIT(DT_DRV_INST(inst))))
605+
587606
#define SPI_CFG_IRQS_SINGLE_ERR_LINE(inst) \
588607
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(inst, rx_avail, irq), \
589608
DT_INST_IRQ_BY_NAME(inst, rx_avail, priority), \
@@ -656,7 +675,7 @@ COND_CODE_1(IS_EQ(DT_NUM_IRQS(DT_DRV_INST(inst)), 1), \
656675
SPI_CONTEXT_CS_GPIOS_INITIALIZE(DT_DRV_INST(inst), ctx) \
657676
}; \
658677
static const struct spi_dw_config spi_dw_config_##inst = { \
659-
DEVICE_MMIO_ROM_INIT(DT_DRV_INST(inst)), \
678+
REG_ADDR(inst), \
660679
.clock_frequency = COND_CODE_1( \
661680
DT_NODE_HAS_PROP(DT_INST_PHANDLE(inst, clocks), clock_frequency), \
662681
(DT_INST_PROP_BY_PHANDLE(inst, clocks, clock_frequency)), \
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2024 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: Nordic External Memory Interface (EXMIF) used in SPI mode only
5+
6+
compatible: "nordic,nrf-exmif-spi"
7+
8+
include: snps,designware-spi.yaml

0 commit comments

Comments
 (0)