drivers: spi: nrfx: allow enabling DMA with the nRF52832 despite PAN 58
Add a Kconfig option to enable DMA for SPI with SOC_NRF52832 as long as it being disabled due to Product Anomaly Notice (PAN) 58 is explicitly overridden. This allows the SPIM driver to be enabled for the nRF52832 SoC for situations where PAN 58 is not a problem. Signed-off-by: Andrew Fernandes <andrew@fernandes.org>
This commit is contained in:
parent
86bd319d1f
commit
e96673dca7
3 changed files with 47 additions and 13 deletions
|
@ -14,6 +14,19 @@ menuconfig SPI_NRFX
|
||||||
|
|
||||||
if SPI_NRFX
|
if SPI_NRFX
|
||||||
|
|
||||||
|
config SOC_NRF52832_ALLOW_SPIM_DESPITE_PAN_58
|
||||||
|
depends on SOC_NRF52832
|
||||||
|
bool "Allow enabling the SPIM driver despite PAN 58"
|
||||||
|
help
|
||||||
|
Allow enabling the nRF SPI Master with EasyDMA, despite
|
||||||
|
Product Anomaly Notice 58 (SPIM: An additional byte is
|
||||||
|
clocked out when RXD.MAXCNT == 1 and TXD.MAXCNT <= 1).
|
||||||
|
Without this override, the SPI Master is only available
|
||||||
|
without EasyDMA. Note that the 'SPIM' and 'SPIS' drivers
|
||||||
|
use EasyDMA, while the 'SPI' driver does not. Use this
|
||||||
|
option ONLY if you are certain that transactions with
|
||||||
|
RXD.MAXCNT == 1 and TXD.MAXCNT <= 1 will NOT be executed.
|
||||||
|
|
||||||
# In most Nordic SoCs, SPI and TWI peripherals with the same instance number
|
# In most Nordic SoCs, SPI and TWI peripherals with the same instance number
|
||||||
# share certain resources and therefore cannot be used at the same time
|
# share certain resources and therefore cannot be used at the same time
|
||||||
# (in nRF91 Series this limitation concerns UART peripherals as well).
|
# (in nRF91 Series this limitation concerns UART peripherals as well).
|
||||||
|
@ -34,9 +47,10 @@ config SPI_0_NRF_SPI
|
||||||
|
|
||||||
config SPI_0_NRF_SPIM
|
config SPI_0_NRF_SPIM
|
||||||
bool "nRF SPIM 0"
|
bool "nRF SPIM 0"
|
||||||
# This driver is not available for nRF52832 because of the anomaly 58
|
# This driver is not available for nRF52832 because of Product Anomaly 58
|
||||||
# (SPIM: An additional byte is clocked out when RXD.MAXCNT = 1).
|
# (SPIM: An additional byte is clocked out when RXD.MAXCNT == 1 and TXD.MAXCNT <= 1)
|
||||||
depends on HAS_HW_NRF_SPIM0 && !SOC_NRF52832
|
# Allow the 'EasyDMA' driver only if this automatic safety-disable is overridden
|
||||||
|
depends on HAS_HW_NRF_SPIM0 && (!SOC_NRF52832 || SOC_NRF52832_ALLOW_SPIM_DESPITE_PAN_58)
|
||||||
select NRFX_SPIM
|
select NRFX_SPIM
|
||||||
help
|
help
|
||||||
Enable nRF SPI Master with EasyDMA on port 0.
|
Enable nRF SPI Master with EasyDMA on port 0.
|
||||||
|
@ -84,9 +98,10 @@ config SPI_1_NRF_SPI
|
||||||
|
|
||||||
config SPI_1_NRF_SPIM
|
config SPI_1_NRF_SPIM
|
||||||
bool "nRF SPIM 1"
|
bool "nRF SPIM 1"
|
||||||
# This driver is not available for nRF52832 because of the anomaly 58
|
# This driver is not available for nRF52832 because of Product Anomaly 58
|
||||||
# (SPIM: An additional byte is clocked out when RXD.MAXCNT = 1).
|
# (SPIM: An additional byte is clocked out when RXD.MAXCNT == 1 and TXD.MAXCNT <= 1)
|
||||||
depends on HAS_HW_NRF_SPIM1 && !SOC_NRF52832
|
# Allow the 'EasyDMA' driver only if this automatic safety-disable is overridden
|
||||||
|
depends on HAS_HW_NRF_SPIM1 && (!SOC_NRF52832 || SOC_NRF52832_ALLOW_SPIM_DESPITE_PAN_58)
|
||||||
select NRFX_SPIM
|
select NRFX_SPIM
|
||||||
help
|
help
|
||||||
Enable nRF SPI Master with EasyDMA on port 1.
|
Enable nRF SPI Master with EasyDMA on port 1.
|
||||||
|
@ -134,9 +149,10 @@ config SPI_2_NRF_SPI
|
||||||
|
|
||||||
config SPI_2_NRF_SPIM
|
config SPI_2_NRF_SPIM
|
||||||
bool "nRF SPIM 2"
|
bool "nRF SPIM 2"
|
||||||
# This driver is not available for nRF52832 because of the anomaly 58
|
# This driver is not available for nRF52832 because of Product Anomaly 58
|
||||||
# (SPIM: An additional byte is clocked out when RXD.MAXCNT = 1).
|
# (SPIM: An additional byte is clocked out when RXD.MAXCNT == 1 and TXD.MAXCNT <= 1)
|
||||||
depends on HAS_HW_NRF_SPIM2 && !SOC_NRF52832
|
# Allow the 'EasyDMA' driver only if this automatic safety-disable is overridden
|
||||||
|
depends on HAS_HW_NRF_SPIM2 && (!SOC_NRF52832 || SOC_NRF52832_ALLOW_SPIM_DESPITE_PAN_58)
|
||||||
select NRFX_SPIM
|
select NRFX_SPIM
|
||||||
help
|
help
|
||||||
Enable nRF SPI Master with EasyDMA on port 2.
|
Enable nRF SPI Master with EasyDMA on port 2.
|
||||||
|
|
|
@ -178,12 +178,22 @@ static void transfer_next_chunk(struct device *dev)
|
||||||
xfer.tx_length = spi_context_tx_buf_on(ctx) ? chunk_len : 0;
|
xfer.tx_length = spi_context_tx_buf_on(ctx) ? chunk_len : 0;
|
||||||
xfer.p_rx_buffer = ctx->rx_buf;
|
xfer.p_rx_buffer = ctx->rx_buf;
|
||||||
xfer.rx_length = spi_context_rx_buf_on(ctx) ? chunk_len : 0;
|
xfer.rx_length = spi_context_rx_buf_on(ctx) ? chunk_len : 0;
|
||||||
result = nrfx_spim_xfer(&dev_config->spim, &xfer, 0);
|
|
||||||
if (result == NRFX_SUCCESS) {
|
/* This SPIM driver is only used by the NRF52832 if
|
||||||
return;
|
SOC_NRF52832_ALLOW_SPIM_DESPITE_PAN_58 is enabled */
|
||||||
|
if (IS_ENABLED(CONFIG_SOC_NRF52832) &&
|
||||||
|
(xfer.rx_length == 1 && xfer.tx_length <= 1)) {
|
||||||
|
LOG_WRN("Transaction aborted since it would trigger nRF52832 PAN 58");
|
||||||
|
error = -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = -EIO;
|
if (!error) {
|
||||||
|
result = nrfx_spim_xfer(&dev_config->spim, &xfer, 0);
|
||||||
|
if (result == NRFX_SUCCESS) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
error = -EIO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spi_context_cs_control(ctx, false);
|
spi_context_cs_control(ctx, false);
|
||||||
|
|
|
@ -11,3 +11,11 @@ zephyr_sources_ifdef(CONFIG_SYS_POWER_MANAGEMENT
|
||||||
zephyr_sources_ifdef(CONFIG_ARM_MPU
|
zephyr_sources_ifdef(CONFIG_ARM_MPU
|
||||||
mpu_regions.c
|
mpu_regions.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(CONFIG_SOC_NRF52832)
|
||||||
|
if(CONFIG_SOC_NRF52832_ALLOW_SPIM_DESPITE_PAN_58)
|
||||||
|
if(CONFIG_SPI_0_NRF_SPIM or CONFIG_SPI_1_NRF_SPIM or CONFIG_SPI_2_NRF_SPIM)
|
||||||
|
message(WARNING "Both SOC_NRF52832_ALLOW_SPIM_DESPITE_PAN_58 and an NRF SPIM driver are enabled, therefore PAN 58 will apply if RXD.MAXCNT == 1 and TXD.MAXCNT <= 1")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue