Skip to content

Commit 10c8dc1

Browse files
committed
[nrf noup] drivers: spi_dw: Bring back custom EXMIF peripheral handling
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]>
1 parent 0587a64 commit 10c8dc1

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

drivers/spi/spi_dw.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ 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+
48+
#ifdef CONFIG_SOC_NRF54H20_GPD
49+
#include <nrf/gpd.h>
50+
#endif
51+
4452
static inline bool spi_dw_is_slave(struct spi_dw_data *spi)
4553
{
4654
return (IS_ENABLED(CONFIG_SPI_SLAVE) &&
@@ -258,6 +266,7 @@ static int spi_dw_configure(const struct device *dev,
258266
/* Baud rate and Slave select, for master only */
259267
write_baudr(dev, SPI_DW_CLK_DIVIDER(info->clock_frequency,
260268
config->frequency));
269+
write_ser(dev, BIT(config->slave));
261270
}
262271

263272
if (spi_dw_is_slave(spi)) {
@@ -500,6 +509,10 @@ void spi_dw_isr(const struct device *dev)
500509
uint32_t int_status;
501510
int error;
502511

512+
#ifdef CONFIG_HAS_NRFX
513+
NRF_EXMIF->EVENTS_CORE = 0;
514+
#endif
515+
503516
int_status = read_isr(dev);
504517

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

549562
DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE);
550563

564+
#ifdef CONFIG_HAS_NRFX
565+
NRF_EXMIF->INTENSET = BIT(0);
566+
NRF_EXMIF->TASKS_START = 1;
567+
568+
#ifdef CONFIG_SOC_NRF54H20_GPD
569+
err = nrf_gpd_request(NRF_GPD_FAST_ACTIVE1);
570+
if (err < 0) {
571+
return err;
572+
}
573+
#endif
574+
#endif
575+
551576
info->config_func();
552577

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

594+
#define REG_ADDR(inst) \
595+
COND_CODE_1(DT_NODE_HAS_COMPAT(DT_DRV_INST(inst), nordic_nrf_exmif_spi), \
596+
(Z_DEVICE_MMIO_NAMED_ROM_INITIALIZER(core, DT_DRV_INST(inst))), \
597+
(DEVICE_MMIO_ROM_INIT(DT_DRV_INST(inst))))
598+
569599
#define SPI_CFG_IRQS_SINGLE_ERR_LINE(inst) \
570600
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(inst, rx_avail, irq), \
571601
DT_INST_IRQ_BY_NAME(inst, rx_avail, priority), \
@@ -638,7 +668,7 @@ COND_CODE_1(IS_EQ(DT_NUM_IRQS(DT_DRV_INST(inst)), 1), \
638668
SPI_CONTEXT_CS_GPIOS_INITIALIZE(DT_DRV_INST(inst), ctx) \
639669
}; \
640670
static const struct spi_dw_config spi_dw_config_##inst = { \
641-
DEVICE_MMIO_ROM_INIT(DT_DRV_INST(inst)), \
671+
REG_ADDR(inst), \
642672
.clock_frequency = COND_CODE_1( \
643673
DT_NODE_HAS_PROP(DT_INST_PHANDLE(inst, clocks), clock_frequency), \
644674
(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)