Skip to content

Commit 53cdfeb

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 <andrzej.glabek@nordicsemi.no> (cherry picked from commit c3c1692)
1 parent 2bac83b commit 53cdfeb

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-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: 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)) {
@@ -512,6 +521,10 @@ void spi_dw_isr(const struct device *dev)
512521
uint32_t int_status;
513522
int error;
514523

524+
#ifdef CONFIG_HAS_NRFX
525+
NRF_EXMIF->EVENTS_CORE = 0;
526+
#endif
527+
515528
int_status = read_isr(dev);
516529

517530
LOG_DBG("SPI %p int_status 0x%x - (tx: %d, rx: %d)", dev, int_status,
@@ -560,6 +573,18 @@ int spi_dw_init(const struct device *dev)
560573

561574
DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE);
562575

576+
#ifdef CONFIG_HAS_NRFX
577+
NRF_EXMIF->INTENSET = BIT(0);
578+
NRF_EXMIF->TASKS_START = 1;
579+
580+
#ifdef CONFIG_SOC_NRF54H20_GPD
581+
err = nrf_gpd_request(NRF_GPD_FAST_ACTIVE1);
582+
if (err < 0) {
583+
return err;
584+
}
585+
#endif
586+
#endif
587+
563588
info->config_func();
564589

565590
/* Masking interrupt and making sure controller is disabled */
@@ -584,6 +609,11 @@ int spi_dw_init(const struct device *dev)
584609
return 0;
585610
}
586611

612+
#define REG_ADDR(inst) \
613+
COND_CODE_1(DT_NODE_HAS_COMPAT(DT_DRV_INST(inst), nordic_nrf_exmif_spi), \
614+
(Z_DEVICE_MMIO_NAMED_ROM_INITIALIZER(core, DT_DRV_INST(inst))), \
615+
(DEVICE_MMIO_ROM_INIT(DT_DRV_INST(inst))))
616+
587617
#define SPI_CFG_IRQS_SINGLE_ERR_LINE(inst) \
588618
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(inst, rx_avail, irq), \
589619
DT_INST_IRQ_BY_NAME(inst, rx_avail, priority), \
@@ -656,7 +686,7 @@ COND_CODE_1(IS_EQ(DT_NUM_IRQS(DT_DRV_INST(inst)), 1), \
656686
SPI_CONTEXT_CS_GPIOS_INITIALIZE(DT_DRV_INST(inst), ctx) \
657687
}; \
658688
static const struct spi_dw_config spi_dw_config_##inst = { \
659-
DEVICE_MMIO_ROM_INIT(DT_DRV_INST(inst)), \
689+
REG_ADDR(inst), \
660690
.clock_frequency = COND_CODE_1( \
661691
DT_NODE_HAS_PROP(DT_INST_PHANDLE(inst, clocks), clock_frequency), \
662692
(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)