Skip to content

Commit 4103c82

Browse files
bjarki-andreasenkartben
authored andcommitted
drivers: pinctrl: add support for nrf twis pins
Add support for TWIS pins to nrf pinctrl. Signed-off-by: Bjarki Arge Andreasen <[email protected]>
1 parent 341f781 commit 4103c82

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

drivers/pinctrl/pinctrl_nrf.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ static const nrf_gpio_pin_drive_t drive_modes[NRF_DRIVE_COUNT] = {
9494
#define NRF_PSEL_QSPI(reg, line) ((NRF_QSPI_Type *)reg)->PSEL.line
9595
#endif
9696

97+
#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_twis) || defined(CONFIG_NRFX_TWIS)
98+
#include <hal/nrf_twis.h>
99+
#define NRF_PSEL_TWIS(reg, line) ((NRF_TWIS_Type *)reg)->PSEL.line
100+
#endif
101+
97102
int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt,
98103
uintptr_t reg)
99104
{
@@ -351,6 +356,24 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt,
351356
input = NRF_GPIO_PIN_INPUT_CONNECT;
352357
break;
353358
#endif /* DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_can) */
359+
#if defined(NRF_PSEL_TWIS)
360+
case NRF_FUN_TWIS_SCL:
361+
NRF_PSEL_TWIS(reg, SCL) = psel;
362+
if (drive == NRF_GPIO_PIN_S0S1) {
363+
drive = NRF_GPIO_PIN_S0D1;
364+
}
365+
dir = NRF_GPIO_PIN_DIR_INPUT;
366+
input = NRF_GPIO_PIN_INPUT_CONNECT;
367+
break;
368+
case NRF_FUN_TWIS_SDA:
369+
NRF_PSEL_TWIS(reg, SDA) = psel;
370+
if (drive == NRF_GPIO_PIN_S0S1) {
371+
drive = NRF_GPIO_PIN_S0D1;
372+
}
373+
dir = NRF_GPIO_PIN_DIR_INPUT;
374+
input = NRF_GPIO_PIN_INPUT_CONNECT;
375+
break;
376+
#endif /* defined(NRF_PSEL_TWIS) */
354377
default:
355378
return -ENOTSUP;
356379
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@
162162
#define NRF_FUN_CAN_TX 46U
163163
/** CAN RX */
164164
#define NRF_FUN_CAN_RX 47U
165+
/** TWIS SCL */
166+
#define NRF_FUN_TWIS_SCL 48U
167+
/** TWIS SDA */
168+
#define NRF_FUN_TWIS_SDA 49U
165169

166170
/** @} */
167171

0 commit comments

Comments
 (0)