Skip to content

Commit db7849a

Browse files
ananglrlubos
authored andcommitted
[nrf fromtree] drivers: pinctrl_nrf: Add support for SPIM CSN pin function
Certain SPIM instances in nRF52/53/54L/54H Series provide hardware control of the CSN (chip select) line. Although the standard SPI drivers do not use this feature, it should be possible to configure this line through pinctrl in case some special driver needs this. Signed-off-by: Andrzej Głąbek <[email protected]> (cherry picked from commit ca79733)
1 parent 1001821 commit db7849a

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

drivers/pinctrl/pinctrl_nrf.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ static const nrf_gpio_pin_drive_t drive_modes[NRF_DRIVE_COUNT] = {
4646
#define NRF_PSEL_UART(reg, line) ((NRF_UARTE_Type *)reg)->PSEL.line
4747
#endif
4848

49-
#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_spi) || defined(CONFIG_NRFX_SPI)
50-
#define NRF_PSEL_SPIM(reg, line) ((NRF_SPI_Type *)reg)->PSEL##line
51-
#elif DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_spim) || defined(CONFIG_NRFX_SPIM)
49+
#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_spim) || defined(CONFIG_NRFX_SPIM)
5250
#include <hal/nrf_spim.h>
5351
#define NRF_PSEL_SPIM(reg, line) ((NRF_SPIM_Type *)reg)->PSEL.line
52+
#elif DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_spi) || defined(CONFIG_NRFX_SPI)
53+
#define NRF_PSEL_SPIM(reg, line) ((NRF_SPI_Type *)reg)->PSEL##line
5454
#endif
5555

5656
#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_spis) || defined(CONFIG_NRFX_SPIS)
@@ -277,6 +277,14 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt,
277277
dir = NRF_GPIO_PIN_DIR_INPUT;
278278
input = NRF_GPIO_PIN_INPUT_CONNECT;
279279
break;
280+
#if defined(NRF_SPIM_HAS_HW_CSN) && NRF_SPIM_HAS_HW_CSN
281+
case NRF_FUN_SPIM_CSN:
282+
NRF_PSEL_SPIM(reg, CSN) = psel;
283+
write = 1U;
284+
dir = NRF_GPIO_PIN_DIR_OUTPUT;
285+
input = NRF_GPIO_PIN_INPUT_DISCONNECT;
286+
break;
287+
#endif
280288
#endif /* defined(NRF_PSEL_SPIM) */
281289
#if defined(NRF_PSEL_SPIS)
282290
case NRF_FUN_SPIS_SCK:

include/zephyr/dt-bindings/pinctrl/nrf-pinctrl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@
242242
#define NRF_FUN_TDM_SDOUT 76U
243243
/** TDM MCK */
244244
#define NRF_FUN_TDM_MCK 77U
245+
/** SPI master CSN */
246+
#define NRF_FUN_SPIM_CSN 78U
245247

246248
/** @} */
247249

0 commit comments

Comments
 (0)