From 7c2197f2d84be4b8728e6480a1c0e6669baff171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Zadro=C5=BCniak?= Date: Tue, 28 Aug 2018 16:24:22 +0200 Subject: [PATCH] boards: nrf: uart: Moved UART pin configuration to DTS (nRF boards) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UART pins (TX, RX, RTS, CTS) are now configured in DTS files. RTS and CTS definitions are optional. If flow control is enabled and RTS/CTS pins are not defined, then compiler will issue an error message. Signed-off-by: Paweł Zadrożniak --- arch/arm/soc/nordic_nrf/nrf51/dts.fixup | 8 +++++ arch/arm/soc/nordic_nrf/nrf52/dts.fixup | 24 ++++++++++++++ .../arm/96b_carbon_nrf51/96b_carbon_nrf51.dts | 2 ++ .../96b_carbon_nrf51_defconfig | 2 -- boards/arm/96b_nitrogen/96b_nitrogen.dts | 4 +++ boards/arm/96b_nitrogen/Kconfig.defconfig | 16 ---------- boards/arm/bbc_microbit/Kconfig.defconfig | 10 ------ boards/arm/bbc_microbit/bbc_microbit.dts | 2 ++ boards/arm/curie_ble/Kconfig.defconfig | 16 ---------- boards/arm/curie_ble/curie_ble.dts | 4 +++ boards/arm/nrf51_ble400/Kconfig.defconfig | 16 ---------- boards/arm/nrf51_ble400/nrf51_ble400.dts | 4 +++ boards/arm/nrf51_blenano/Kconfig.defconfig | 16 ---------- boards/arm/nrf51_blenano/nrf51_blenano.dts | 4 +++ boards/arm/nrf51_pca10028/Kconfig.defconfig | 16 ---------- boards/arm/nrf51_pca10028/nrf51_pca10028.dts | 4 +++ boards/arm/nrf51_vbluno51/Kconfig.defconfig | 16 ---------- boards/arm/nrf51_vbluno51/nrf51_vbluno51.dts | 4 +++ .../arm/nrf52810_pca10040/Kconfig.defconfig | 16 ---------- .../nrf52810_pca10040/nrf52810_pca10040.dts | 4 +++ .../arm/nrf52840_pca10056/Kconfig.defconfig | 32 ------------------- .../nrf52840_pca10056/nrf52840_pca10056.dts | 8 +++++ .../arm/nrf52840_pca10059/Kconfig.defconfig | 16 ---------- .../nrf52840_pca10059/nrf52840_pca10059.dts | 4 +++ .../nrf52_adafruit_feather/Kconfig.defconfig | 16 ---------- .../nrf52_adafruit_feather.dts | 4 +++ boards/arm/nrf52_blenano2/Kconfig.defconfig | 16 ---------- boards/arm/nrf52_blenano2/nrf52_blenano2.dts | 4 +++ boards/arm/nrf52_pca10040/Kconfig.defconfig | 16 ---------- boards/arm/nrf52_pca10040/nrf52_pca10040.dts | 4 +++ boards/arm/nrf52_pca20020/Kconfig.defconfig | 10 ------ boards/arm/nrf52_pca20020/nrf52_pca20020.dts | 2 ++ boards/arm/nrf52_sparkfun/Kconfig.defconfig | 10 ------ boards/arm/nrf52_sparkfun/nrf52_sparkfun.dts | 2 ++ boards/arm/nrf52_vbluno52/Kconfig.defconfig | 16 ---------- boards/arm/nrf52_vbluno52/nrf52_vbluno52.dts | 4 +++ .../arm/quark_se_c1000_ble/Kconfig.defconfig | 16 ---------- .../quark_se_c1000_ble/quark_se_c1000_ble.dts | 4 +++ boards/arm/reel_board/Kconfig.defconfig | 16 ---------- boards/arm/reel_board/reel_board.dts | 4 +++ drivers/serial/Kconfig.nrfx | 30 ----------------- drivers/serial/uart_nrfx_uart.c | 26 +++++++++------ drivers/serial/uart_nrfx_uarte.c | 20 +++++++++--- dts/bindings/serial/nordic,nrf-uart.yaml | 24 ++++++++++++++ dts/bindings/serial/nordic,nrf-uarte.yaml | 24 ++++++++++++++ .../arm/nrf52840_pca10056/Kconfig.defconfig | 16 ---------- .../nrf52840_pca10056/nrf52840_pca10056.dts | 4 +++ 47 files changed, 188 insertions(+), 348 deletions(-) diff --git a/arch/arm/soc/nordic_nrf/nrf51/dts.fixup b/arch/arm/soc/nordic_nrf/nrf51/dts.fixup index b505d5e7ae4..8cb975f943c 100644 --- a/arch/arm/soc/nordic_nrf/nrf51/dts.fixup +++ b/arch/arm/soc/nordic_nrf/nrf51/dts.fixup @@ -11,6 +11,14 @@ #define CONFIG_UART_0_IRQ_NUM NORDIC_NRF_UART_40002000_IRQ_0 #define CONFIG_UART_0_BAUD_RATE NORDIC_NRF_UART_40002000_CURRENT_SPEED #define CONFIG_UART_0_NAME NORDIC_NRF_UART_40002000_LABEL +#define CONFIG_UART_0_TX_PIN NORDIC_NRF_UART_40002000_TX_PIN +#define CONFIG_UART_0_RX_PIN NORDIC_NRF_UART_40002000_RX_PIN +#if defined(NORDIC_NRF_UART_40002000_RTS_PIN) +#define CONFIG_UART_0_RTS_PIN NORDIC_NRF_UART_40002000_RTS_PIN +#endif +#if defined(NORDIC_NRF_UART_40002000_CTS_PIN) +#define CONFIG_UART_0_CTS_PIN NORDIC_NRF_UART_40002000_CTS_PIN +#endif #define FLASH_DEV_NAME NRF_NRF51_FLASH_CONTROLLER_4001E000_LABEL diff --git a/arch/arm/soc/nordic_nrf/nrf52/dts.fixup b/arch/arm/soc/nordic_nrf/nrf52/dts.fixup index 98e269a2698..65b588d36b9 100644 --- a/arch/arm/soc/nordic_nrf/nrf52/dts.fixup +++ b/arch/arm/soc/nordic_nrf/nrf52/dts.fixup @@ -12,12 +12,28 @@ #define CONFIG_UART_0_IRQ_NUM NORDIC_NRF_UARTE_40002000_IRQ_0 #define CONFIG_UART_0_BAUD_RATE NORDIC_NRF_UARTE_40002000_CURRENT_SPEED #define CONFIG_UART_0_NAME NORDIC_NRF_UARTE_40002000_LABEL +#define CONFIG_UART_0_TX_PIN NORDIC_NRF_UARTE_40002000_TX_PIN +#define CONFIG_UART_0_RX_PIN NORDIC_NRF_UARTE_40002000_RX_PIN + #if defined(NORDIC_NRF_UARTE_40002000_RTS_PIN) + #define CONFIG_UART_0_RTS_PIN NORDIC_NRF_UARTE_40002000_RTS_PIN + #endif + #if defined(NORDIC_NRF_UARTE_40002000_CTS_PIN) + #define CONFIG_UART_0_CTS_PIN NORDIC_NRF_UARTE_40002000_CTS_PIN + #endif #else #define CONFIG_UART_0_BASE NORDIC_NRF_UART_40002000_BASE_ADDRESS #define CONFIG_UART_0_IRQ_PRI NORDIC_NRF_UART_40002000_IRQ_0_PRIORITY #define CONFIG_UART_0_IRQ_NUM NORDIC_NRF_UART_40002000_IRQ_0 #define CONFIG_UART_0_BAUD_RATE NORDIC_NRF_UART_40002000_CURRENT_SPEED #define CONFIG_UART_0_NAME NORDIC_NRF_UART_40002000_LABEL +#define CONFIG_UART_0_TX_PIN NORDIC_NRF_UART_40002000_TX_PIN +#define CONFIG_UART_0_RX_PIN NORDIC_NRF_UART_40002000_RX_PIN + #if defined(NORDIC_NRF_UART_40002000_RTS_PIN) + #define CONFIG_UART_0_RTS_PIN NORDIC_NRF_UART_40002000_RTS_PIN + #endif + #if defined(NORDIC_NRF_UART_40002000_RTS_PIN) + #define CONFIG_UART_0_CTS_PIN NORDIC_NRF_UART_40002000_CTS_PIN + #endif #endif #define CONFIG_UART_1_BASE NORDIC_NRF_UARTE_40028000_BASE_ADDRESS @@ -25,6 +41,14 @@ #define CONFIG_UART_1_IRQ_NUM NORDIC_NRF_UARTE_40028000_IRQ_0 #define CONFIG_UART_1_BAUD_RATE NORDIC_NRF_UARTE_40028000_CURRENT_SPEED #define CONFIG_UART_1_NAME NORDIC_NRF_UARTE_40028000_LABEL +#define CONFIG_UART_1_TX_PIN NORDIC_NRF_UARTE_40028000_TX_PIN +#define CONFIG_UART_1_RX_PIN NORDIC_NRF_UARTE_40028000_RX_PIN +#if defined(NORDIC_NRF_UARTE_40028000_RTS_PIN) +#define CONFIG_UART_1_RTS_PIN NORDIC_NRF_UARTE_40028000_RTS_PIN +#endif +#if defined(NORDIC_NRF_UARTE_40028000_CTS_PIN) +#define CONFIG_UART_1_CTS_PIN NORDIC_NRF_UARTE_40028000_CTS_PIN +#endif #define FLASH_DEV_NAME NRF_NRF52_FLASH_CONTROLLER_4001E000_LABEL diff --git a/boards/arm/96b_carbon_nrf51/96b_carbon_nrf51.dts b/boards/arm/96b_carbon_nrf51/96b_carbon_nrf51.dts index 1abf1ae9e1f..c062bda9662 100644 --- a/boards/arm/96b_carbon_nrf51/96b_carbon_nrf51.dts +++ b/boards/arm/96b_carbon_nrf51/96b_carbon_nrf51.dts @@ -30,6 +30,8 @@ &uart0 { current-speed = <115200>; status = "ok"; + tx-pin = <29>; + rx-pin = <11>; }; &spi1 { diff --git a/boards/arm/96b_carbon_nrf51/96b_carbon_nrf51_defconfig b/boards/arm/96b_carbon_nrf51/96b_carbon_nrf51_defconfig index 9fad340252a..0f75a4c9046 100644 --- a/boards/arm/96b_carbon_nrf51/96b_carbon_nrf51_defconfig +++ b/boards/arm/96b_carbon_nrf51/96b_carbon_nrf51_defconfig @@ -7,8 +7,6 @@ CONFIG_BOARD_96B_CARBON_NRF51=y # enable uart driver CONFIG_SERIAL=y CONFIG_UART_NRFX=y -CONFIG_UART_0_NRF_TX_PIN=29 -CONFIG_UART_0_NRF_RX_PIN=11 CONFIG_UART_0_NRF_UART=y # enable console diff --git a/boards/arm/96b_nitrogen/96b_nitrogen.dts b/boards/arm/96b_nitrogen/96b_nitrogen.dts index 752b40a41f6..e5a157da99c 100644 --- a/boards/arm/96b_nitrogen/96b_nitrogen.dts +++ b/boards/arm/96b_nitrogen/96b_nitrogen.dts @@ -31,6 +31,10 @@ compatible = "nordic,nrf-uart"; current-speed = <115200>; status = "ok"; + tx-pin = <13>; + rx-pin = <15>; + rts-pin = <12>; + cts-pin = <14>; }; &flash0 { diff --git a/boards/arm/96b_nitrogen/Kconfig.defconfig b/boards/arm/96b_nitrogen/Kconfig.defconfig index 27d4fec2d1a..68a11065091 100644 --- a/boards/arm/96b_nitrogen/Kconfig.defconfig +++ b/boards/arm/96b_nitrogen/Kconfig.defconfig @@ -9,20 +9,4 @@ if BOARD_96B_NITROGEN config BOARD default "96b_nitrogen" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 13 - -config UART_0_NRF_RX_PIN - default 15 - -config UART_0_NRF_RTS_PIN - default 12 - -config UART_0_NRF_CTS_PIN - default 14 - -endif # UART_NRFX - endif # BOARD_96B_NITROGEN diff --git a/boards/arm/bbc_microbit/Kconfig.defconfig b/boards/arm/bbc_microbit/Kconfig.defconfig index 7dedda29197..a04c16db130 100644 --- a/boards/arm/bbc_microbit/Kconfig.defconfig +++ b/boards/arm/bbc_microbit/Kconfig.defconfig @@ -9,16 +9,6 @@ if BOARD_BBC_MICROBIT config BOARD default "bbc_microbit" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 24 - -config UART_0_NRF_RX_PIN - default 25 - -endif # UART_NRFX - if I2C config I2C_NRFX diff --git a/boards/arm/bbc_microbit/bbc_microbit.dts b/boards/arm/bbc_microbit/bbc_microbit.dts index 4d28ea8ebe0..46b177bed0c 100644 --- a/boards/arm/bbc_microbit/bbc_microbit.dts +++ b/boards/arm/bbc_microbit/bbc_microbit.dts @@ -29,6 +29,8 @@ &uart0 { status = "ok"; current-speed = <115200>; + tx-pin = <24>; + rx-pin = <25>; }; &i2c0 { diff --git a/boards/arm/curie_ble/Kconfig.defconfig b/boards/arm/curie_ble/Kconfig.defconfig index 5c1a4120efe..6caa7e7039f 100644 --- a/boards/arm/curie_ble/Kconfig.defconfig +++ b/boards/arm/curie_ble/Kconfig.defconfig @@ -9,20 +9,4 @@ if BOARD_CURIE_BLE config BOARD default "curie_ble" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 9 - -config UART_0_NRF_RX_PIN - default 11 - -config UART_0_NRF_RTS_PIN - default 12 - -config UART_0_NRF_CTS_PIN - default 10 - -endif # UART_NRFX - endif # BOARD_CURIE_BLE diff --git a/boards/arm/curie_ble/curie_ble.dts b/boards/arm/curie_ble/curie_ble.dts index b0c1bd82de8..b6e0b4f9e2b 100644 --- a/boards/arm/curie_ble/curie_ble.dts +++ b/boards/arm/curie_ble/curie_ble.dts @@ -30,4 +30,8 @@ &uart0 { current-speed = <1000000>; status = "ok"; + tx-pin = <9>; + rx-pin = <11>; + rts-pin = <12>; + cts-pin = <10>; }; diff --git a/boards/arm/nrf51_ble400/Kconfig.defconfig b/boards/arm/nrf51_ble400/Kconfig.defconfig index e8b97e5b897..38ace52dcde 100644 --- a/boards/arm/nrf51_ble400/Kconfig.defconfig +++ b/boards/arm/nrf51_ble400/Kconfig.defconfig @@ -9,20 +9,4 @@ if BOARD_NRF51_BLE400 config BOARD default "nrf51_ble400" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 9 - -config UART_0_NRF_RX_PIN - default 11 - -config UART_0_NRF_RTS_PIN - default 8 - -config UART_0_NRF_CTS_PIN - default 10 - -endif # UART_NRFX - endif # BOARD_NRF51_BLE400 diff --git a/boards/arm/nrf51_ble400/nrf51_ble400.dts b/boards/arm/nrf51_ble400/nrf51_ble400.dts index 6eacc72a7f0..06f50d6092a 100644 --- a/boards/arm/nrf51_ble400/nrf51_ble400.dts +++ b/boards/arm/nrf51_ble400/nrf51_ble400.dts @@ -29,4 +29,8 @@ &uart0 { current-speed = <115200>; status = "ok"; + tx-pin = <9>; + rx-pin = <11>; + rts-pin = <8>; + cts-pin = <10>; }; diff --git a/boards/arm/nrf51_blenano/Kconfig.defconfig b/boards/arm/nrf51_blenano/Kconfig.defconfig index 199a9c4c3e9..d3524f68e49 100644 --- a/boards/arm/nrf51_blenano/Kconfig.defconfig +++ b/boards/arm/nrf51_blenano/Kconfig.defconfig @@ -9,20 +9,4 @@ if BOARD_NRF51_BLENANO config BOARD default "nrf51_blenano" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 9 - -config UART_0_NRF_RX_PIN - default 11 - -config UART_0_NRF_RTS_PIN - default 8 - -config UART_0_NRF_CTS_PIN - default 10 - -endif # UART_NRFX - endif # BOARD_NRF51_BLENANO diff --git a/boards/arm/nrf51_blenano/nrf51_blenano.dts b/boards/arm/nrf51_blenano/nrf51_blenano.dts index 1d5b2f061ee..86b9d9d9a56 100644 --- a/boards/arm/nrf51_blenano/nrf51_blenano.dts +++ b/boards/arm/nrf51_blenano/nrf51_blenano.dts @@ -30,4 +30,8 @@ &uart0 { current-speed = <115200>; status = "ok"; + tx-pin = <9>; + rx-pin = <11>; + rts-pin = <8>; + cts-pin = <10>; }; diff --git a/boards/arm/nrf51_pca10028/Kconfig.defconfig b/boards/arm/nrf51_pca10028/Kconfig.defconfig index 469dd09b611..70c405bfff3 100644 --- a/boards/arm/nrf51_pca10028/Kconfig.defconfig +++ b/boards/arm/nrf51_pca10028/Kconfig.defconfig @@ -9,20 +9,4 @@ if BOARD_NRF51_PCA10028 config BOARD default "nrf51_pca10028" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 9 - -config UART_0_NRF_RX_PIN - default 11 - -config UART_0_NRF_RTS_PIN - default 8 - -config UART_0_NRF_CTS_PIN - default 10 - -endif # UART_NRFX - endif # BOARD_NRF51_PCA10028 diff --git a/boards/arm/nrf51_pca10028/nrf51_pca10028.dts b/boards/arm/nrf51_pca10028/nrf51_pca10028.dts index c5e2072e181..ca3dea0d11e 100644 --- a/boards/arm/nrf51_pca10028/nrf51_pca10028.dts +++ b/boards/arm/nrf51_pca10028/nrf51_pca10028.dts @@ -91,6 +91,10 @@ &uart0 { current-speed = <115200>; status = "ok"; + tx-pin = <9>; + rx-pin = <11>; + rts-pin = <8>; + cts-pin = <10>; }; &i2c0 { diff --git a/boards/arm/nrf51_vbluno51/Kconfig.defconfig b/boards/arm/nrf51_vbluno51/Kconfig.defconfig index f2d48d61327..15b83bffaac 100644 --- a/boards/arm/nrf51_vbluno51/Kconfig.defconfig +++ b/boards/arm/nrf51_vbluno51/Kconfig.defconfig @@ -9,22 +9,6 @@ if BOARD_NRF51_VBLUNO51 config BOARD default "nrf51_vbluno51" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 10 - -config UART_0_NRF_RX_PIN - default 11 - -config UART_0_NRF_RTS_PIN - default 12 - -config UART_0_NRF_CTS_PIN - default 13 - -endif # UART_NRFX - if I2C config I2C_NRFX diff --git a/boards/arm/nrf51_vbluno51/nrf51_vbluno51.dts b/boards/arm/nrf51_vbluno51/nrf51_vbluno51.dts index bb48956a386..a30f3d3b60f 100644 --- a/boards/arm/nrf51_vbluno51/nrf51_vbluno51.dts +++ b/boards/arm/nrf51_vbluno51/nrf51_vbluno51.dts @@ -30,6 +30,10 @@ &uart0 { current-speed = <115200>; status = "ok"; + tx-pin = <10>; + rx-pin = <11>; + rts-pin = <12>; + cts-pin = <13>; }; &i2c0 { diff --git a/boards/arm/nrf52810_pca10040/Kconfig.defconfig b/boards/arm/nrf52810_pca10040/Kconfig.defconfig index 9b4864c1fa2..35db560f4b1 100644 --- a/boards/arm/nrf52810_pca10040/Kconfig.defconfig +++ b/boards/arm/nrf52810_pca10040/Kconfig.defconfig @@ -9,20 +9,4 @@ if BOARD_NRF52810_PCA10040 config BOARD default "nrf52810_pca10040" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 6 - -config UART_0_NRF_RX_PIN - default 8 - -config UART_0_NRF_RTS_PIN - default 5 - -config UART_0_NRF_CTS_PIN - default 7 - -endif # UART_NRFX - endif # BOARD_NRF52810_PCA10040 diff --git a/boards/arm/nrf52810_pca10040/nrf52810_pca10040.dts b/boards/arm/nrf52810_pca10040/nrf52810_pca10040.dts index 7e315f654a7..078e5c836a3 100644 --- a/boards/arm/nrf52810_pca10040/nrf52810_pca10040.dts +++ b/boards/arm/nrf52810_pca10040/nrf52810_pca10040.dts @@ -93,6 +93,10 @@ &uart0 { status = "ok"; current-speed = <115200>; + tx-pin = <6>; + rx-pin = <8>; + rts-pin = <5>; + cts-pin = <7>; }; &i2c0 { diff --git a/boards/arm/nrf52840_pca10056/Kconfig.defconfig b/boards/arm/nrf52840_pca10056/Kconfig.defconfig index 568ee5c8abc..e6f9bbedec1 100644 --- a/boards/arm/nrf52840_pca10056/Kconfig.defconfig +++ b/boards/arm/nrf52840_pca10056/Kconfig.defconfig @@ -9,38 +9,6 @@ if BOARD_NRF52840_PCA10056 config BOARD default "nrf52840_pca10056" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 6 - -config UART_0_NRF_RX_PIN - default 8 - -config UART_0_NRF_RTS_PIN - default 5 - -config UART_0_NRF_CTS_PIN - default 7 - -if MODEM_WNCM14A2A - -config UART_1_NRF_TX_PIN - default 46 - -config UART_1_NRF_RX_PIN - default 45 - -config UART_1_NRF_RTS_PIN - default 44 - -config UART_1_NRF_CTS_PIN - default 47 - -endif # MODEM_WCN14A2A - -endif # UART_NRFX - if USB config USB_NRF52840 diff --git a/boards/arm/nrf52840_pca10056/nrf52840_pca10056.dts b/boards/arm/nrf52840_pca10056/nrf52840_pca10056.dts index 6e99779c105..9ed9621b708 100644 --- a/boards/arm/nrf52840_pca10056/nrf52840_pca10056.dts +++ b/boards/arm/nrf52840_pca10056/nrf52840_pca10056.dts @@ -96,12 +96,20 @@ compatible = "nordic,nrf-uart"; current-speed = <115200>; status = "ok"; + tx-pin = <6>; + rx-pin = <8>; + rts-pin = <5>; + cts-pin = <7>; }; #ifdef CONFIG_UART_1_NRF_UARTE &uart1 { current-speed = <115200>; status = "ok"; + tx-pin = <46>; + rx-pin = <45>; + rts-pin = <44>; + cts-pin = <47>; #ifdef CONFIG_MODEM_WNCM14A2A wncm14a2a { diff --git a/boards/arm/nrf52840_pca10059/Kconfig.defconfig b/boards/arm/nrf52840_pca10059/Kconfig.defconfig index deb7711f625..2ea0670b453 100644 --- a/boards/arm/nrf52840_pca10059/Kconfig.defconfig +++ b/boards/arm/nrf52840_pca10059/Kconfig.defconfig @@ -9,22 +9,6 @@ if BOARD_NRF52840_PCA10059 config BOARD default "nrf52840_pca10059" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 20 - -config UART_0_NRF_RX_PIN - default 24 - -config UART_0_NRF_RTS_PIN - default 17 - -config UART_0_NRF_CTS_PIN - default 22 - -endif # UART_NRFX - if USB config USB_NRF52840 diff --git a/boards/arm/nrf52840_pca10059/nrf52840_pca10059.dts b/boards/arm/nrf52840_pca10059/nrf52840_pca10059.dts index 16b6ac9d84e..3f975cc0232 100644 --- a/boards/arm/nrf52840_pca10059/nrf52840_pca10059.dts +++ b/boards/arm/nrf52840_pca10059/nrf52840_pca10059.dts @@ -82,6 +82,10 @@ compatible = "nordic,nrf-uarte"; current-speed = <115200>; status = "ok"; + tx-pin = <20>; + rx-pin = <24>; + rts-pin = <17>; + cts-pin = <22>; }; &i2c0 { diff --git a/boards/arm/nrf52_adafruit_feather/Kconfig.defconfig b/boards/arm/nrf52_adafruit_feather/Kconfig.defconfig index 029255e0da6..87e92f95308 100644 --- a/boards/arm/nrf52_adafruit_feather/Kconfig.defconfig +++ b/boards/arm/nrf52_adafruit_feather/Kconfig.defconfig @@ -9,20 +9,4 @@ if BOARD_NRF52_ADAFRUIT_FEATHER config BOARD default "nrf52_adafruit_feather" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 6 - -config UART_0_NRF_RX_PIN - default 8 - -config UART_0_NRF_RTS_PIN - default 5 - -config UART_0_NRF_CTS_PIN - default 7 - -endif # UART_NRFX - endif # BOARD_NRF52_ADAFRUIT_FEATHER diff --git a/boards/arm/nrf52_adafruit_feather/nrf52_adafruit_feather.dts b/boards/arm/nrf52_adafruit_feather/nrf52_adafruit_feather.dts index 0c1ac05abd4..3d9ca29a142 100644 --- a/boards/arm/nrf52_adafruit_feather/nrf52_adafruit_feather.dts +++ b/boards/arm/nrf52_adafruit_feather/nrf52_adafruit_feather.dts @@ -35,6 +35,10 @@ compatible = "nordic,nrf-uart"; current-speed = <115200>; status = "ok"; + tx-pin = <6>; + rx-pin = <8>; + rts-pin = <5>; + cts-pin = <7>; }; &i2c0 { diff --git a/boards/arm/nrf52_blenano2/Kconfig.defconfig b/boards/arm/nrf52_blenano2/Kconfig.defconfig index b06e8db7be1..c9c104d1b9b 100644 --- a/boards/arm/nrf52_blenano2/Kconfig.defconfig +++ b/boards/arm/nrf52_blenano2/Kconfig.defconfig @@ -9,22 +9,6 @@ if BOARD_NRF52_BLENANO2 config BOARD default "nrf52_blenano2" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 29 - -config UART_0_NRF_RX_PIN - default 30 - -config UART_0_NRF_RTS_PIN - default 2 - -config UART_0_NRF_CTS_PIN - default 28 - -endif # UART_NRFX - if I2C config I2C_NRFX diff --git a/boards/arm/nrf52_blenano2/nrf52_blenano2.dts b/boards/arm/nrf52_blenano2/nrf52_blenano2.dts index 88d2337563e..6c8c40f38e4 100644 --- a/boards/arm/nrf52_blenano2/nrf52_blenano2.dts +++ b/boards/arm/nrf52_blenano2/nrf52_blenano2.dts @@ -31,6 +31,10 @@ compatible = "nordic,nrf-uart"; current-speed = <115200>; status = "ok"; + tx-pin = <29>; + rx-pin = <30>; + rts-pin = <2>; + cts-pin = <28>; }; &i2c0 { diff --git a/boards/arm/nrf52_pca10040/Kconfig.defconfig b/boards/arm/nrf52_pca10040/Kconfig.defconfig index 45b541e43ef..f603c96f12f 100644 --- a/boards/arm/nrf52_pca10040/Kconfig.defconfig +++ b/boards/arm/nrf52_pca10040/Kconfig.defconfig @@ -9,20 +9,4 @@ if BOARD_NRF52_PCA10040 config BOARD default "nrf52_pca10040" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 6 - -config UART_0_NRF_RX_PIN - default 8 - -config UART_0_NRF_RTS_PIN - default 5 - -config UART_0_NRF_CTS_PIN - default 7 - -endif # UART_NRFX - endif # BOARD_NRF52_PCA10040 diff --git a/boards/arm/nrf52_pca10040/nrf52_pca10040.dts b/boards/arm/nrf52_pca10040/nrf52_pca10040.dts index c46fc053479..753722f2306 100644 --- a/boards/arm/nrf52_pca10040/nrf52_pca10040.dts +++ b/boards/arm/nrf52_pca10040/nrf52_pca10040.dts @@ -93,6 +93,10 @@ status = "ok"; compatible = "nordic,nrf-uart"; current-speed = <115200>; + tx-pin = <6>; + rx-pin = <8>; + rts-pin = <5>; + cts-pin = <7>; }; &i2c0 { diff --git a/boards/arm/nrf52_pca20020/Kconfig.defconfig b/boards/arm/nrf52_pca20020/Kconfig.defconfig index 181570d8e9c..45675787a0f 100644 --- a/boards/arm/nrf52_pca20020/Kconfig.defconfig +++ b/boards/arm/nrf52_pca20020/Kconfig.defconfig @@ -9,16 +9,6 @@ if BOARD_NRF52_PCA20020 config BOARD default "nrf52_pca20020" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 3 - -config UART_0_NRF_RX_PIN - default 2 - -endif # UART_NRFX - config I2C def_bool y diff --git a/boards/arm/nrf52_pca20020/nrf52_pca20020.dts b/boards/arm/nrf52_pca20020/nrf52_pca20020.dts index d8197b27ef7..4ed31dace02 100644 --- a/boards/arm/nrf52_pca20020/nrf52_pca20020.dts +++ b/boards/arm/nrf52_pca20020/nrf52_pca20020.dts @@ -37,6 +37,8 @@ status = "ok"; compatible = "nordic,nrf-uart"; current-speed = <115200>; + tx-pin = <3>; + rx-pin = <2>; }; &i2c0 { diff --git a/boards/arm/nrf52_sparkfun/Kconfig.defconfig b/boards/arm/nrf52_sparkfun/Kconfig.defconfig index 51fc7791a37..997c2acc590 100644 --- a/boards/arm/nrf52_sparkfun/Kconfig.defconfig +++ b/boards/arm/nrf52_sparkfun/Kconfig.defconfig @@ -10,14 +10,4 @@ if BOARD_NRF52_SPARKFUN config BOARD default "nrf52_sparkfun" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 27 - -config UART_0_NRF_RX_PIN - default 26 - -endif # UART_NRFX - endif # BOARD_NRF52_SPARKFUN diff --git a/boards/arm/nrf52_sparkfun/nrf52_sparkfun.dts b/boards/arm/nrf52_sparkfun/nrf52_sparkfun.dts index 1671c48ee56..2b953865ce4 100644 --- a/boards/arm/nrf52_sparkfun/nrf52_sparkfun.dts +++ b/boards/arm/nrf52_sparkfun/nrf52_sparkfun.dts @@ -32,6 +32,8 @@ compatible = "nordic,nrf-uart"; current-speed = <115200>; status = "ok"; + tx-pin = <27>; + rx-pin = <26>; }; &flash0 { diff --git a/boards/arm/nrf52_vbluno52/Kconfig.defconfig b/boards/arm/nrf52_vbluno52/Kconfig.defconfig index 2ba8336b64a..dd0bdd5d8a4 100644 --- a/boards/arm/nrf52_vbluno52/Kconfig.defconfig +++ b/boards/arm/nrf52_vbluno52/Kconfig.defconfig @@ -9,22 +9,6 @@ if BOARD_NRF52_VBLUNO52 config BOARD default "nrf52_vbluno52" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 6 - -config UART_0_NRF_RX_PIN - default 8 - -config UART_0_NRF_RTS_PIN - default 5 - -config UART_0_NRF_CTS_PIN - default 7 - -endif # UART_NRFX - if I2C config I2C_NRFX diff --git a/boards/arm/nrf52_vbluno52/nrf52_vbluno52.dts b/boards/arm/nrf52_vbluno52/nrf52_vbluno52.dts index 56541db58d8..7515589fffd 100644 --- a/boards/arm/nrf52_vbluno52/nrf52_vbluno52.dts +++ b/boards/arm/nrf52_vbluno52/nrf52_vbluno52.dts @@ -31,6 +31,10 @@ status = "ok"; compatible = "nordic,nrf-uart"; current-speed = <115200>; + tx-pin = <6>; + rx-pin = <8>; + rts-pin = <5>; + cts-pin = <7>; }; &i2c0 { diff --git a/boards/arm/quark_se_c1000_ble/Kconfig.defconfig b/boards/arm/quark_se_c1000_ble/Kconfig.defconfig index 87e4e97871e..d29b7c56893 100644 --- a/boards/arm/quark_se_c1000_ble/Kconfig.defconfig +++ b/boards/arm/quark_se_c1000_ble/Kconfig.defconfig @@ -9,20 +9,4 @@ if BOARD_QUARK_SE_C1000_BLE config BOARD default "quark_se_c1000_ble" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 9 - -config UART_0_NRF_RX_PIN - default 11 - -config UART_0_NRF_RTS_PIN - default 8 - -config UART_0_NRF_CTS_PIN - default 10 - -endif # UART_NRFX - endif # BOARD_QUARK_SE_C1000_BLE diff --git a/boards/arm/quark_se_c1000_ble/quark_se_c1000_ble.dts b/boards/arm/quark_se_c1000_ble/quark_se_c1000_ble.dts index b561d29e3b2..9b684094ab2 100644 --- a/boards/arm/quark_se_c1000_ble/quark_se_c1000_ble.dts +++ b/boards/arm/quark_se_c1000_ble/quark_se_c1000_ble.dts @@ -30,4 +30,8 @@ &uart0 { status = "ok"; current-speed = <1000000>; + tx-pin = <9>; + rx-pin = <11>; + rts-pin = <8>; + cts-pin = <10>; }; diff --git a/boards/arm/reel_board/Kconfig.defconfig b/boards/arm/reel_board/Kconfig.defconfig index bef37ee3d9c..f993241c19f 100644 --- a/boards/arm/reel_board/Kconfig.defconfig +++ b/boards/arm/reel_board/Kconfig.defconfig @@ -9,22 +9,6 @@ if BOARD_REEL_BOARD config BOARD default "reel_board" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 6 - -config UART_0_NRF_RX_PIN - default 8 - -config UART_0_NRF_RTS_PIN - default 5 - -config UART_0_NRF_CTS_PIN - default 7 - -endif # UART_NRFX - config I2C def_bool y diff --git a/boards/arm/reel_board/reel_board.dts b/boards/arm/reel_board/reel_board.dts index d3036a64898..79634a8a17d 100644 --- a/boards/arm/reel_board/reel_board.dts +++ b/boards/arm/reel_board/reel_board.dts @@ -75,6 +75,10 @@ compatible = "nordic,nrf-uart"; current-speed = <115200>; status = "ok"; + tx-pin = <6>; + rx-pin = <8>; + rts-pin = <5>; + cts-pin = <7>; }; &i2c0 { diff --git a/drivers/serial/Kconfig.nrfx b/drivers/serial/Kconfig.nrfx index 7a81d15bf45..434660c9957 100644 --- a/drivers/serial/Kconfig.nrfx +++ b/drivers/serial/Kconfig.nrfx @@ -59,36 +59,6 @@ config UART_0_NRF_FLOW_CONTROL Enable flow control. If selected, additionally two pins, RTS and CTS have to be configured. -config UART_0_NRF_TX_PIN - int "TX Pin Number" - range 0 47 if SOC_NRF52840_QIAA - range 0 31 - help - The GPIO pin to use for TX. - -config UART_0_NRF_RX_PIN - int "RX Pin Number" - range 0 47 if SOC_NRF52840_QIAA - range 0 31 - help - The GPIO pin to use for RX. - -config UART_0_NRF_CTS_PIN - int "CTS Pin Number" - range 0 47 if SOC_NRF52840_QIAA - range 0 31 - depends on UART_0_NRF_FLOW_CONTROL - help - The GPIO pin to use for CTS. - -config UART_0_NRF_RTS_PIN - int "RTS Pin Number" - range 0 47 if SOC_NRF52840_QIAA - range 0 31 - depends on UART_0_NRF_FLOW_CONTROL - help - The GPIO pin to use for RTS. - config UART_0_NRF_TX_BUFFER_SIZE int "Size of RAM buffer" depends on UART_0_NRF_UARTE diff --git a/drivers/serial/uart_nrfx_uart.c b/drivers/serial/uart_nrfx_uart.c index c469276d68f..a520b41c9c6 100644 --- a/drivers/serial/uart_nrfx_uart.c +++ b/drivers/serial/uart_nrfx_uart.c @@ -404,27 +404,33 @@ static int uart_nrfx_init(struct device *dev) /* Setting default height state of the TX PIN to avoid glitches * on the line during peripheral activation/deactivation. */ - nrf_gpio_pin_write(CONFIG_UART_0_NRF_TX_PIN, 1); - nrf_gpio_cfg_output(CONFIG_UART_0_NRF_TX_PIN); + nrf_gpio_pin_write(CONFIG_UART_0_TX_PIN, 1); + nrf_gpio_cfg_output(CONFIG_UART_0_TX_PIN); - nrf_gpio_cfg_input(CONFIG_UART_0_NRF_RX_PIN, NRF_GPIO_PIN_NOPULL); + nrf_gpio_cfg_input(CONFIG_UART_0_RX_PIN, NRF_GPIO_PIN_NOPULL); nrf_uart_txrx_pins_set(uart0_addr, - CONFIG_UART_0_NRF_TX_PIN, - CONFIG_UART_0_NRF_RX_PIN); + CONFIG_UART_0_TX_PIN, + CONFIG_UART_0_RX_PIN); #ifdef CONFIG_UART_0_NRF_FLOW_CONTROL +#ifndef CONFIG_UART_0_RTS_PIN +#error Flow control for UART0 is enabled, but RTS pin is not defined. +#endif +#ifndef CONFIG_UART_0_CTS_PIN +#error Flow control for UART0 is enabled, but CTS pin is not defined. +#endif /* Setting default height state of the RTS PIN to avoid glitches * on the line during peripheral activation/deactivation. */ - nrf_gpio_pin_write(CONFIG_UART_0_NRF_RTS_PIN, 1); - nrf_gpio_cfg_output(CONFIG_UART_0_NRF_RTS_PIN); + nrf_gpio_pin_write(CONFIG_UART_0_RTS_PIN, 1); + nrf_gpio_cfg_output(CONFIG_UART_0_RTS_PIN); - nrf_gpio_cfg_input(CONFIG_UART_0_NRF_CTS_PIN, NRF_GPIO_PIN_NOPULL); + nrf_gpio_cfg_input(CONFIG_UART_0_CTS_PIN, NRF_GPIO_PIN_NOPULL); nrf_uart_hwfc_pins_set(uart0_addr, - CONFIG_UART_0_NRF_RTS_PIN, - CONFIG_UART_0_NRF_CTS_PIN); + CONFIG_UART_0_RTS_PIN, + CONFIG_UART_0_CTS_PIN); #endif /* CONFIG_UART_0_NRF_FLOW_CONTROL */ nrf_uart_configure(uart0_addr, diff --git a/drivers/serial/uart_nrfx_uarte.c b/drivers/serial/uart_nrfx_uarte.c index 2ec586a5a93..c155bc346f1 100644 --- a/drivers/serial/uart_nrfx_uarte.c +++ b/drivers/serial/uart_nrfx_uarte.c @@ -515,8 +515,8 @@ static int uarte_instance_init(struct device *dev, static int uarte_##idx##_init(struct device *dev) \ { \ const struct uarte_init_config init_config = { \ - .pseltxd = CONFIG_UART_##idx##_NRF_TX_PIN, \ - .pselrxd = CONFIG_UART_##idx##_NRF_RX_PIN, \ + .pseltxd = CONFIG_UART_##idx##_TX_PIN, \ + .pselrxd = CONFIG_UART_##idx##_RX_PIN, \ UARTE_##idx##_NRF_HWFC_CONFIG \ .parity = UARTE_##idx##_NRF_PARITY_BIT, \ .baudrate = CONFIG_UART_##idx##_BAUD_RATE \ @@ -536,8 +536,8 @@ static int uarte_instance_init(struct device *dev, &uart_nrfx_uarte_driver_api) #define UARTE_NRF_HWFC_ENABLED(idx) \ - .pselcts = CONFIG_UART_##idx##_NRF_CTS_PIN, \ - .pselrts = CONFIG_UART_##idx##_NRF_RTS_PIN, \ + .pselcts = CONFIG_UART_##idx##_CTS_PIN, \ + .pselrts = CONFIG_UART_##idx##_RTS_PIN, \ .hwfc = NRF_UARTE_HWFC_ENABLED, #define UARTE_NRF_HWFC_DISABLED \ .pselcts = NRF_UARTE_PSEL_DISCONNECTED, \ @@ -584,6 +584,12 @@ static int uarte_instance_init(struct device *dev, #ifdef CONFIG_UART_0_NRF_FLOW_CONTROL #define UARTE_0_NRF_HWFC_CONFIG UARTE_NRF_HWFC_ENABLED(0) + #ifndef CONFIG_UART_0_RTS_PIN + #error Flow control for UARTE0 is enabled, but RTS pin is not defined. + #endif + #ifndef CONFIG_UART_0_CTS_PIN + #error Flow control for UARTE0 is enabled, but CTS pin is not defined. + #endif #else #define UARTE_0_NRF_HWFC_CONFIG UARTE_NRF_HWFC_DISABLED #endif /* CONFIG_UART_0_NRF_FLOW_CONTROL */ @@ -614,6 +620,12 @@ static int uarte_instance_init(struct device *dev, #ifdef CONFIG_UART_1_NRF_FLOW_CONTROL #define UARTE_1_NRF_HWFC_CONFIG UARTE_NRF_HWFC_ENABLED(1) + #ifndef CONFIG_UART_1_RTS_PIN + #error Flow control for UARTE0 is enabled, but RTS pin is not defined. + #endif + #ifndef CONFIG_UART_1_CTS_PIN + #error Flow control for UARTE0 is enabled, but CTS pin is not defined. + #endif #else #define UARTE_1_NRF_HWFC_CONFIG UARTE_NRF_HWFC_DISABLED #endif /* CONFIG_UART_1_NRF_FLOW_CONTROL */ diff --git a/dts/bindings/serial/nordic,nrf-uart.yaml b/dts/bindings/serial/nordic,nrf-uart.yaml index dc0b574c729..4025b165164 100644 --- a/dts/bindings/serial/nordic,nrf-uart.yaml +++ b/dts/bindings/serial/nordic,nrf-uart.yaml @@ -27,4 +27,28 @@ properties: category: required description: required interrupts generation: define + + tx-pin: + type: int + description: TX pin + generation: define + category: required + + rx-pin: + type: int + description: RX pin + generation: define + category: required + + rts-pin: + type: int + description: RTS pin + generation: define + category: optional + + cts-pin: + type: int + description: CTS pin + generation: define + category: optional ... diff --git a/dts/bindings/serial/nordic,nrf-uarte.yaml b/dts/bindings/serial/nordic,nrf-uarte.yaml index c8c37fa79d6..9e18bfc6765 100644 --- a/dts/bindings/serial/nordic,nrf-uarte.yaml +++ b/dts/bindings/serial/nordic,nrf-uarte.yaml @@ -27,4 +27,28 @@ properties: category: required description: required interrupts generation: define + + tx-pin: + type: int + description: TX pin + generation: define + category: required + + rx-pin: + type: int + description: RX pin + generation: define + category: required + + rts-pin: + type: int + description: RTS pin + generation: define + category: optional + + cts-pin: + type: int + description: CTS pin + generation: define + category: optional ... diff --git a/samples/application_development/out_of_tree_board/boards/arm/nrf52840_pca10056/Kconfig.defconfig b/samples/application_development/out_of_tree_board/boards/arm/nrf52840_pca10056/Kconfig.defconfig index 63df730f6e4..b34b4796c73 100644 --- a/samples/application_development/out_of_tree_board/boards/arm/nrf52840_pca10056/Kconfig.defconfig +++ b/samples/application_development/out_of_tree_board/boards/arm/nrf52840_pca10056/Kconfig.defconfig @@ -9,22 +9,6 @@ if BOARD_NRF52840_PCA10056 config BOARD default "nrf52840_pca10056" -if UART_NRFX - -config UART_0_NRF_TX_PIN - default 6 - -config UART_0_NRF_RX_PIN - default 8 - -config UART_0_NRF_RTS_PIN - default 5 - -config UART_0_NRF_CTS_PIN - default 7 - -endif # UART_NRFX - if USB config USB_NRF52840 diff --git a/samples/application_development/out_of_tree_board/boards/arm/nrf52840_pca10056/nrf52840_pca10056.dts b/samples/application_development/out_of_tree_board/boards/arm/nrf52840_pca10056/nrf52840_pca10056.dts index 26376052f34..56f078dd1f8 100644 --- a/samples/application_development/out_of_tree_board/boards/arm/nrf52840_pca10056/nrf52840_pca10056.dts +++ b/samples/application_development/out_of_tree_board/boards/arm/nrf52840_pca10056/nrf52840_pca10056.dts @@ -35,6 +35,10 @@ compatible = "nordic,nrf-uart"; current-speed = <115200>; status = "ok"; + tx-pin = <6>; + rx-pin = <8>; + rts-pin = <5>; + cts-pin = <7>; }; &flash0 {