From b57ed25e06b05e458da779bf73558344aabaafe4 Mon Sep 17 00:00:00 2001 From: Joakim Andersson Date: Fri, 19 Nov 2021 17:10:27 +0100 Subject: [PATCH] board: thingy53_nrf5340: Update outdated nrf21540 FEM pin configuration Update outdated nrf21540 FEM pins configuration. New pins have been added and the mcu selection is handled by the MPSL FEM module. The current setup would not work with TFM enabled since the mcu select code would not be included in the secure image. Since this is the responsebility of the MPSL FEM module remove it so that there is only one place that needs to be updated for TFM. Copy FEM pin configuration for Thingy:53 board from cpunet device tree configuration to the application device tree configuration so that it is added for both application and network core as documented in user guide for FEM in GPIO mode. Add nrf_radio_fem_spi node to application device tree configuration. This removes the GPIO_PULL_DOWN configuration which was not correct. Signed-off-by: Joakim Andersson --- boards/arm/thingy53_nrf5340/Kconfig | 7 --- boards/arm/thingy53_nrf5340/board.c | 45 ------------------- .../thingy53_nrf5340_common.dts | 5 ++- .../thingy53_nrf5340_cpunet.dts | 10 ++--- 4 files changed, 8 insertions(+), 59 deletions(-) diff --git a/boards/arm/thingy53_nrf5340/Kconfig b/boards/arm/thingy53_nrf5340/Kconfig index 1c2f80a67f0..74b496e2dc3 100644 --- a/boards/arm/thingy53_nrf5340/Kconfig +++ b/boards/arm/thingy53_nrf5340/Kconfig @@ -3,13 +3,6 @@ # Copyright (c) 2021 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 -config THINGY53_MISO_WORKAROUND - bool "MISO workaround" - default SPI - help - Workaround SPI bus MISO issues. The workaround sets dedicated pin - high in order to avoid voltage drops on the SPI MISO line. - config THINGY53_INIT_PRIORITY int "Init priority" default 79 diff --git a/boards/arm/thingy53_nrf5340/board.c b/boards/arm/thingy53_nrf5340/board.c index fd154e6d681..9e1b62b9767 100644 --- a/boards/arm/thingy53_nrf5340/board.c +++ b/boards/arm/thingy53_nrf5340/board.c @@ -13,11 +13,6 @@ #include LOG_MODULE_REGISTER(thingy53_board_init); -#define NRF21540FEM_CTRL_NODE DT_NODELABEL(nrf21540fem_ctrl) -#define NRF21540FEM_CTRL_PDN_GPIO_NODE DT_GPIO_CTLR(NRF21540FEM_CTRL_NODE, pdn_gpios) -#define NRF21540FEM_CTRL_PDN_PIN DT_GPIO_PIN(NRF21540FEM_CTRL_NODE, pdn_gpios) -#define NRF21540FEM_CTRL_PDN_FLAGS DT_GPIO_FLAGS(NRF21540FEM_CTRL_NODE, pdn_gpios) - #define ADXL362_NODE DT_NODELABEL(adxl362) #define ADXL362_GPIO_NODE DT_SPI_DEV_CS_GPIOS_CTLR(ADXL362_NODE) #define ADXL362_CS DT_SPI_DEV_CS_GPIOS_PIN(ADXL362_NODE) @@ -28,11 +23,6 @@ LOG_MODULE_REGISTER(thingy53_board_init); #define BMI270_CS DT_SPI_DEV_CS_GPIOS_PIN(BMI270_NODE) #define BMI270_FLAGS DT_SPI_DEV_CS_GPIOS_FLAGS(BMI270_NODE) -#define NRF21540FEM_NODE DT_NODELABEL(nrf21540fem) -#define NRF21540FEM_GPIO_NODE DT_SPI_DEV_CS_GPIOS_CTLR(NRF21540FEM_NODE) -#define NRF21540FEM_CS DT_SPI_DEV_CS_GPIOS_PIN(NRF21540FEM_NODE) -#define NRF21540FEM_FLAGS DT_SPI_DEV_CS_GPIOS_FLAGS(NRF21540FEM_NODE) - /* Initialization chain of Thingy:53 board requires some delays before on board sensors * could be accessed after power up. In particular bme680 and bmm150 sensors require, * respectively 2ms and 1ms power on delay. In order to avoid delays sum, common delay is @@ -56,16 +46,6 @@ BUILD_ASSERT(CONFIG_THINGY53_INIT_PRIORITY < CONFIG_SENSOR_INIT_PRIORITY, static void enable_cpunet(void) { #if !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) - /* Give nRF21540fem control pins to NetworkMCU */ - nrf_gpio_pin_mcu_select(NRF_DT_GPIOS_TO_PSEL(NRF21540FEM_CTRL_NODE, tx_en_gpios), - GPIO_PIN_CNF_MCUSEL_NetworkMCU); /* TX_EN */ - nrf_gpio_pin_mcu_select(NRF_DT_GPIOS_TO_PSEL(NRF21540FEM_CTRL_NODE, pdn_gpios), - GPIO_PIN_CNF_MCUSEL_NetworkMCU); /* PDN */ - nrf_gpio_pin_mcu_select(NRF_DT_GPIOS_TO_PSEL(NRF21540FEM_CTRL_NODE, rx_en_gpios), - GPIO_PIN_CNF_MCUSEL_NetworkMCU); /* RX_EN */ - nrf_gpio_pin_mcu_select(NRF_DT_GPIOS_TO_PSEL(NRF21540FEM_CTRL_NODE, mode_gpios), - GPIO_PIN_CNF_MCUSEL_NetworkMCU); /* MODE */ - /* Retain nRF5340 Network MCU in Secure domain (bus * accesses by Network MCU will have Secure attribute set). */ @@ -95,20 +75,6 @@ static int setup(const struct device *dev) const struct device *gpio; int err; - gpio = DEVICE_DT_GET(NRF21540FEM_CTRL_PDN_GPIO_NODE); - if (!device_is_ready(gpio)) { - LOG_ERR("%s device not ready", gpio->name); - return -ENODEV; - } - err = gpio_pin_configure(gpio, NRF21540FEM_CTRL_PDN_PIN, - NRF21540FEM_CTRL_PDN_FLAGS | - IS_ENABLED(CONFIG_THINGY53_MISO_WORKAROUND) ? - GPIO_OUTPUT_ACTIVE : GPIO_OUTPUT_INACTIVE); - if (err < 0) { - LOG_ERR("Failed to configure NRF21540FEM PDN Pin"); - return err; - } - gpio = DEVICE_DT_GET(ADXL362_GPIO_NODE); if (!device_is_ready(gpio)) { LOG_ERR("%s device not ready", gpio->name); @@ -131,17 +97,6 @@ static int setup(const struct device *dev) return err; } - gpio = DEVICE_DT_GET(NRF21540FEM_GPIO_NODE); - if (!device_is_ready(gpio)) { - LOG_ERR("%s device not ready", gpio->name); - return -ENODEV; - } - err = gpio_pin_configure(gpio, NRF21540FEM_CS, NRF21540FEM_FLAGS | GPIO_OUTPUT_INACTIVE); - if (err < 0) { - LOG_ERR("Failed to configure NRF21540FEM CS Pin"); - return err; - } - if (IS_ENABLED(CONFIG_SENSOR)) { /* Initialization chain of Thingy:53 board requires some delays before on board * sensors could be accessed after power up. In particular bme680 and bmm150 diff --git a/boards/arm/thingy53_nrf5340/thingy53_nrf5340_common.dts b/boards/arm/thingy53_nrf5340/thingy53_nrf5340_common.dts index 5eb417d0d76..7409631e079 100644 --- a/boards/arm/thingy53_nrf5340/thingy53_nrf5340_common.dts +++ b/boards/arm/thingy53_nrf5340/thingy53_nrf5340_common.dts @@ -83,12 +83,13 @@ regulator-boot-on; }; - nrf21540fem_ctrl: nrf21540fem-ctrl { + nrf_radio_fem: fem { compatible = "nordic,nrf21540-fem"; rx-en-gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>; mode-gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>; pdn-gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>; tx-en-gpios = <&gpio0 30 GPIO_ACTIVE_HIGH>; + spi-if = <&nrf_radio_fem_spi>; }; aliases { @@ -180,7 +181,7 @@ int1-gpios = <&gpio0 23 0>; }; - nrf21540fem: spi-dev-nrf21540fem@2 { + nrf_radio_fem_spi: fem_spi@2 { compatible = "nordic,nrf21540-fem-spi"; status = "okay"; reg = <2>; diff --git a/boards/arm/thingy53_nrf5340/thingy53_nrf5340_cpunet.dts b/boards/arm/thingy53_nrf5340/thingy53_nrf5340_cpunet.dts index e1c9cdb00a8..da48526095b 100644 --- a/boards/arm/thingy53_nrf5340/thingy53_nrf5340_cpunet.dts +++ b/boards/arm/thingy53_nrf5340/thingy53_nrf5340_cpunet.dts @@ -50,12 +50,12 @@ }; }; - nrf_radio_fem: nrf21540_fem { + nrf_radio_fem: fem { compatible = "nordic,nrf21540-fem"; - rx-en-gpios = <&gpio1 11 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; - mode-gpios = <&gpio1 12 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; - pdn-gpios = <&gpio1 10 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; - tx-en-gpios = <&gpio0 30 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; + rx-en-gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>; + mode-gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>; + pdn-gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>; + tx-en-gpios = <&gpio0 30 GPIO_ACTIVE_HIGH>; }; aliases {