Skip to content

Commit

Permalink
[nrf noup] drivers: spi_dw: Bring back custom EXMIF peripheral handling
Browse files Browse the repository at this point in the history
This commit brings back modifications from these reverted commits:
- 9a11615
- 0f83f86
slightly adjusted so that the EXMIF peripheral is still by default
handled by the mspi_dw peripheral, and in cases where this is not
possible because something still does not work correctly, one can
switch temporarily to the old solution based on the tweaked spi_dw
driver.

Signed-off-by: Andrzej Głąbek <[email protected]>
  • Loading branch information
anangl committed Dec 17, 2024
1 parent 0587a64 commit 10c8dc1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
32 changes: 31 additions & 1 deletion drivers/spi/spi_dw.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ LOG_MODULE_REGISTER(spi_dw);
#include <zephyr/drivers/pinctrl.h>
#endif

#ifdef CONFIG_HAS_NRFX
#include <nrfx.h>
#endif

#ifdef CONFIG_SOC_NRF54H20_GPD
#include <nrf/gpd.h>
#endif

static inline bool spi_dw_is_slave(struct spi_dw_data *spi)
{
return (IS_ENABLED(CONFIG_SPI_SLAVE) &&
Expand Down Expand Up @@ -258,6 +266,7 @@ static int spi_dw_configure(const struct device *dev,
/* Baud rate and Slave select, for master only */
write_baudr(dev, SPI_DW_CLK_DIVIDER(info->clock_frequency,
config->frequency));
write_ser(dev, BIT(config->slave));
}

if (spi_dw_is_slave(spi)) {
Expand Down Expand Up @@ -500,6 +509,10 @@ void spi_dw_isr(const struct device *dev)
uint32_t int_status;
int error;

#ifdef CONFIG_HAS_NRFX
NRF_EXMIF->EVENTS_CORE = 0;
#endif

int_status = read_isr(dev);

LOG_DBG("SPI %p int_status 0x%x - (tx: %d, rx: %d)", dev, int_status,
Expand Down Expand Up @@ -548,6 +561,18 @@ int spi_dw_init(const struct device *dev)

DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE);

#ifdef CONFIG_HAS_NRFX
NRF_EXMIF->INTENSET = BIT(0);
NRF_EXMIF->TASKS_START = 1;

#ifdef CONFIG_SOC_NRF54H20_GPD
err = nrf_gpd_request(NRF_GPD_FAST_ACTIVE1);
if (err < 0) {
return err;
}
#endif
#endif

info->config_func();

/* Masking interrupt and making sure controller is disabled */
Expand All @@ -566,6 +591,11 @@ int spi_dw_init(const struct device *dev)
return 0;
}

#define REG_ADDR(inst) \
COND_CODE_1(DT_NODE_HAS_COMPAT(DT_DRV_INST(inst), nordic_nrf_exmif_spi), \
(Z_DEVICE_MMIO_NAMED_ROM_INITIALIZER(core, DT_DRV_INST(inst))), \
(DEVICE_MMIO_ROM_INIT(DT_DRV_INST(inst))))

Check notice on line 597 in drivers/spi/spi_dw.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/spi/spi_dw.c:597 -#define REG_ADDR(inst) \ - COND_CODE_1(DT_NODE_HAS_COMPAT(DT_DRV_INST(inst), nordic_nrf_exmif_spi), \ - (Z_DEVICE_MMIO_NAMED_ROM_INITIALIZER(core, DT_DRV_INST(inst))), \ +#define REG_ADDR(inst) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(DT_DRV_INST(inst), nordic_nrf_exmif_spi), \ + (Z_DEVICE_MMIO_NAMED_ROM_INITIALIZER(core, DT_DRV_INST(inst))), \

#define SPI_CFG_IRQS_SINGLE_ERR_LINE(inst) \
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(inst, rx_avail, irq), \
DT_INST_IRQ_BY_NAME(inst, rx_avail, priority), \
Expand Down Expand Up @@ -638,7 +668,7 @@ COND_CODE_1(IS_EQ(DT_NUM_IRQS(DT_DRV_INST(inst)), 1), \
SPI_CONTEXT_CS_GPIOS_INITIALIZE(DT_DRV_INST(inst), ctx) \
}; \
static const struct spi_dw_config spi_dw_config_##inst = { \
DEVICE_MMIO_ROM_INIT(DT_DRV_INST(inst)), \
REG_ADDR(inst), \
.clock_frequency = COND_CODE_1( \
DT_NODE_HAS_PROP(DT_INST_PHANDLE(inst, clocks), clock_frequency), \
(DT_INST_PROP_BY_PHANDLE(inst, clocks, clock_frequency)), \
Expand Down
8 changes: 8 additions & 0 deletions dts/bindings/spi/nordic,nrf-exmif-spi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

description: Nordic External Memory Interface (EXMIF) used in SPI mode only

compatible: "nordic,nrf-exmif-spi"

include: snps,designware-spi.yaml

0 comments on commit 10c8dc1

Please sign in to comment.