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 <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2021-11-19 17:10:27 +01:00 committed by Carles Cufí
commit b57ed25e06
4 changed files with 8 additions and 59 deletions

View file

@ -3,13 +3,6 @@
# Copyright (c) 2021 Nordic Semiconductor ASA # Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0 # 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 config THINGY53_INIT_PRIORITY
int "Init priority" int "Init priority"
default 79 default 79

View file

@ -13,11 +13,6 @@
#include <logging/log.h> #include <logging/log.h>
LOG_MODULE_REGISTER(thingy53_board_init); 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_NODE DT_NODELABEL(adxl362)
#define ADXL362_GPIO_NODE DT_SPI_DEV_CS_GPIOS_CTLR(ADXL362_NODE) #define ADXL362_GPIO_NODE DT_SPI_DEV_CS_GPIOS_CTLR(ADXL362_NODE)
#define ADXL362_CS DT_SPI_DEV_CS_GPIOS_PIN(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_CS DT_SPI_DEV_CS_GPIOS_PIN(BMI270_NODE)
#define BMI270_FLAGS DT_SPI_DEV_CS_GPIOS_FLAGS(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 /* 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, * 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 * 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) static void enable_cpunet(void)
{ {
#if !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) #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 /* Retain nRF5340 Network MCU in Secure domain (bus
* accesses by Network MCU will have Secure attribute set). * accesses by Network MCU will have Secure attribute set).
*/ */
@ -95,20 +75,6 @@ static int setup(const struct device *dev)
const struct device *gpio; const struct device *gpio;
int err; 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); gpio = DEVICE_DT_GET(ADXL362_GPIO_NODE);
if (!device_is_ready(gpio)) { if (!device_is_ready(gpio)) {
LOG_ERR("%s device not ready", gpio->name); LOG_ERR("%s device not ready", gpio->name);
@ -131,17 +97,6 @@ static int setup(const struct device *dev)
return err; 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)) { if (IS_ENABLED(CONFIG_SENSOR)) {
/* Initialization chain of Thingy:53 board requires some delays before on board /* 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 could be accessed after power up. In particular bme680 and bmm150

View file

@ -83,12 +83,13 @@
regulator-boot-on; regulator-boot-on;
}; };
nrf21540fem_ctrl: nrf21540fem-ctrl { nrf_radio_fem: fem {
compatible = "nordic,nrf21540-fem"; compatible = "nordic,nrf21540-fem";
rx-en-gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>; rx-en-gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>;
mode-gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>; mode-gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
pdn-gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>; pdn-gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
tx-en-gpios = <&gpio0 30 GPIO_ACTIVE_HIGH>; tx-en-gpios = <&gpio0 30 GPIO_ACTIVE_HIGH>;
spi-if = <&nrf_radio_fem_spi>;
}; };
aliases { aliases {
@ -180,7 +181,7 @@
int1-gpios = <&gpio0 23 0>; int1-gpios = <&gpio0 23 0>;
}; };
nrf21540fem: spi-dev-nrf21540fem@2 { nrf_radio_fem_spi: fem_spi@2 {
compatible = "nordic,nrf21540-fem-spi"; compatible = "nordic,nrf21540-fem-spi";
status = "okay"; status = "okay";
reg = <2>; reg = <2>;

View file

@ -50,12 +50,12 @@
}; };
}; };
nrf_radio_fem: nrf21540_fem { nrf_radio_fem: fem {
compatible = "nordic,nrf21540-fem"; compatible = "nordic,nrf21540-fem";
rx-en-gpios = <&gpio1 11 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; rx-en-gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>;
mode-gpios = <&gpio1 12 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; mode-gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
pdn-gpios = <&gpio1 10 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; pdn-gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
tx-en-gpios = <&gpio0 30 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; tx-en-gpios = <&gpio0 30 GPIO_ACTIVE_HIGH>;
}; };
aliases { aliases {