Skip to content

Commit

Permalink
Bluetooth: Controller: Remove unused nRF21 FEM SPI CSN control
Browse files Browse the repository at this point in the history
Remove unused nRF21 FEM SPI CSN control as the Zephyr
Controller does not implementation SPI control for Tx/Rx
nor for Tx gain settings.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
  • Loading branch information
cvinayak committed Sep 26, 2024
1 parent 655a5fb commit b61372e
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,10 @@
pdn-gpios = <&arduino_header 15 GPIO_ACTIVE_HIGH>; /* D9 */
ant-sel-gpios = <&arduino_header 10 GPIO_ACTIVE_HIGH>; /* D4 */
mode-gpios = <&arduino_header 8 GPIO_ACTIVE_HIGH>; /* D2 */
spi-if = <&nrf_radio_fem_spi>;
supply-voltage-mv = <3000>;
};
};

&spi0 {
/* status = "okay"; */
cs-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>; /* D10 */

nrf_radio_fem_spi: nrf21540_fem_spi@0 {
compatible = "nordic,nrf21540-fem-spi";
/* status = "okay"; */
reg = <0>;
spi-max-frequency = <8000000>;
};
};

&radio {
fem = <&nrf_radio_fem>;
};
55 changes: 0 additions & 55 deletions subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ BUILD_ASSERT(NRF_DT_GPIOTE_INST(FEM_NODE, HAL_RADIO_GPIO_PA_PROP) ==
static const nrfx_gpiote_t gpiote_pdn = NRFX_GPIOTE_INSTANCE(
NRF_DT_GPIOTE_INST(FEM_NODE, pdn_gpios));
static uint8_t gpiote_ch_pdn;
static const nrfx_gpiote_t gpiote_csn = NRFX_GPIOTE_INSTANCE(
NRF_DT_GPIOTE_INST(DT_BUS(FEM_SPI_DEV_NODE), cs_gpios));
static uint8_t gpiote_ch_csn;
#endif

/* These headers require the above gpiote-related variables to be declared. */
Expand Down Expand Up @@ -134,20 +131,6 @@ BUILD_ASSERT(!BAD_FLAGS(NRF_GPIO_LNA_FLAGS),
NRF_DT_CHECK_GPIO_CTLR_IS_SOC(FEM_NODE, pdn_gpios, "pdn-gpios");
#endif /* DT_NODE_HAS_PROP(FEM_NODE, pdn_gpios) */

/* CSN is special because it comes from the spi-if property. */
#if defined(HAL_RADIO_FEM_NRF21540_HAS_CSN)
#define NRF_GPIO_CSN_CTLR DT_SPI_DEV_CS_GPIOS_CTLR(FEM_SPI_DEV_NODE)
#define NRF_GPIO_CSN ((NRF_GPIO_Type *)DT_REG_ADDR(NRF_GPIO_CSN_CTLR))
#define NRF_GPIO_CSN_PIN DT_SPI_DEV_CS_GPIOS_PIN(FEM_SPI_DEV_NODE)
#define NRF_GPIO_CSN_FLAGS DT_SPI_DEV_CS_GPIOS_FLAGS(FEM_SPI_DEV_NODE)
#define NRF_GPIO_CSN_PSEL (NRF_GPIO_CSN_PIN + \
(DT_PROP(NRF_GPIO_CSN_CTLR, port) << 5))
BUILD_ASSERT(DT_NODE_HAS_COMPAT(NRF_GPIO_CSN_CTLR, nordic_nrf_gpio),
"fem node " DT_NODE_PATH(FEM_NODE) " has a spi-if property, "
" but the chip select pin is not on the SoC. Check cs-gpios in "
DT_NODE_PATH(DT_BUS(FEM_SPI_DEV_NODE)));
#endif /* HAL_RADIO_FEM_NRF21540_HAS_CSN */

#endif /* HAL_RADIO_FEM_IS_NRF21540 */

/* CTEINLINE S0_MASK for periodic advertising PUDs. It allows to accept all types of extended
Expand Down Expand Up @@ -208,15 +191,6 @@ void radio_setup(void)
}
#endif /* NRF_GPIO_PDN_PIN */

#if defined(NRF_GPIO_CSN_PIN)
NRF_GPIO_CSN->DIRSET = BIT(NRF_GPIO_CSN_PIN);
if (ACTIVE_LOW(NRF_GPIO_CSN_FLAGS)) {
NRF_GPIO_CSN->OUTSET = BIT(NRF_GPIO_CSN_PIN);
} else {
NRF_GPIO_CSN->OUTCLR = BIT(NRF_GPIO_CSN_PIN);
}
#endif /* NRF_GPIO_CSN_PIN */

hal_radio_ram_prio_setup();
}

Expand Down Expand Up @@ -1841,12 +1815,6 @@ int radio_gpio_pa_lna_init(void)
}
#endif

#if defined(NRF_GPIO_CSN_PIN)
if (nrfx_gpiote_channel_alloc(&gpiote_csn, &gpiote_ch_csn) != NRFX_SUCCESS) {
return -ENOMEM;
}
#endif

return 0;
}

Expand All @@ -1859,10 +1827,6 @@ void radio_gpio_pa_lna_deinit(void)
#if defined(NRF_GPIO_PDN_PIN)
(void)nrfx_gpiote_channel_free(&gpiote_pdn, gpiote_ch_pdn);
#endif

#if defined(NRF_GPIO_CSN_PIN)
(void)nrfx_gpiote_channel_free(&gpiote_csn, gpiote_ch_csn);
#endif
}

#if defined(HAL_RADIO_GPIO_HAVE_PA_PIN)
Expand All @@ -1881,7 +1845,6 @@ void radio_gpio_pa_setup(void)
#if defined(HAL_RADIO_FEM_IS_NRF21540)
hal_pa_ppi_setup();
radio_gpio_pdn_setup();
radio_gpio_csn_setup();
#endif
}
#endif /* HAL_RADIO_GPIO_HAVE_PA_PIN */
Expand All @@ -1902,7 +1865,6 @@ void radio_gpio_lna_setup(void)
#if defined(HAL_RADIO_FEM_IS_NRF21540)
hal_lna_ppi_setup();
radio_gpio_pdn_setup();
radio_gpio_csn_setup();
#endif
}

Expand All @@ -1922,22 +1884,6 @@ void radio_gpio_pdn_setup(void)
#endif /* NRF_GPIO_PDN_PIN */
}

void radio_gpio_csn_setup(void)
{
/* Note: the spi-if property is optional. */
#if defined(NRF_GPIO_CSN_PIN)
gpiote_csn.p_reg->CONFIG[gpiote_ch_csn] =
(GPIOTE_CONFIG_MODE_Task <<
GPIOTE_CONFIG_MODE_Pos) |
(NRF_GPIO_CSN_PSEL <<
GPIOTE_CONFIG_PSEL_Pos) |
(GPIOTE_CONFIG_POLARITY_Toggle <<
GPIOTE_CONFIG_POLARITY_Pos) |
(OUTINIT_INACTIVE(NRF_GPIO_CSN_FLAGS) <<
GPIOTE_CONFIG_OUTINIT_Pos);
#endif /* NRF_GPIO_CSN_PIN */
}

void radio_gpio_lna_on(void)
{
if (ACTIVE_LOW(NRF_GPIO_LNA_FLAGS)) {
Expand Down Expand Up @@ -1981,7 +1927,6 @@ void radio_gpio_pa_lna_disable(void)
BIT(HAL_DISABLE_FEM_PPI));
gpiote_palna.p_reg->CONFIG[gpiote_ch_palna] = 0;
gpiote_pdn.p_reg->CONFIG[gpiote_ch_pdn] = 0;
gpiote_csn.p_reg->CONFIG[gpiote_ch_csn] = 0;
#else
hal_radio_nrf_ppi_channels_disable(BIT(HAL_ENABLE_PALNA_PPI) |
BIT(HAL_DISABLE_PALNA_PPI));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ void radio_gpio_pa_lna_deinit(void);
void radio_gpio_pa_setup(void);
void radio_gpio_lna_setup(void);
void radio_gpio_pdn_setup(void);
void radio_gpio_csn_setup(void);
void radio_gpio_lna_on(void);
void radio_gpio_lna_off(void);
void radio_gpio_pa_lna_enable(uint32_t trx_us);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ static inline void hal_fem_ppi_setup(void)
hal_gpiote_tasks_setup(gpiote_pdn.p_reg, gpiote_ch_pdn,
IS_ENABLED(HAL_RADIO_GPIO_NRF21540_PDN_POL_INV),
HAL_ENABLE_FEM_PPI, HAL_DISABLE_FEM_PPI);

hal_gpiote_tasks_setup(gpiote_csn.p_reg, gpiote_ch_csn,
IS_ENABLED(HAL_RADIO_GPIO_NRF21540_CSN_POL_INV),
HAL_ENABLE_FEM_PPI, HAL_DISABLE_FEM_PPI);
}

#endif /* HAL_RADIO_FEM_IS_NRF21540 */
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,3 @@
#define HAL_RADIO_GPIO_NRF21540_PDN_POL_INV 1
#endif /* DT_GPIO_FLAGS(FEM_NODE, pdn_gpios) & GPIO_ACTIVE_LOW */
#endif /* FEM_HAS_PROP(pdn_gpios) */

#if FEM_HAS_PROP(spi_if)
/* This is the "SPI device" node, i.e. the one with compatible
* nordic,nrf21540-fem-spi.
*/
#define FEM_SPI_DEV_NODE DT_PHANDLE(FEM_NODE, spi_if)
/* If the SPI device node has a chip select gpio... */
#if DT_SPI_DEV_HAS_CS_GPIOS(FEM_SPI_DEV_NODE)
/* set a macro indicating that, and... */
#define HAL_RADIO_FEM_NRF21540_HAS_CSN 1
/* use it to get the CSN polarity. */
#if DT_SPI_DEV_CS_GPIOS_FLAGS(FEM_SPI_DEV_NODE) & GPIO_ACTIVE_LOW
#define HAL_RADIO_GPIO_NRF21540_CSN_POL_INV 1
#endif /* DT_SPI_DEV_CS_GPIOS_FLAGS(FEM_SPI_DEV_NODE) & GPIO_ACTIVE_LOW */
#endif /* DT_SPI_DEV_HAS_CS_GPIOS(FEM_SPI_DEV_NODE) */
#endif /* FEM_HAS_PROP(spi_if) */
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,16 @@ static inline void hal_lna_ppi_setup(void)

static inline void hal_fem_ppi_setup(void)
{
nrf_ppi_channel_and_fork_endpoint_setup(
nrf_ppi_channel_endpoint_setup(
NRF_PPI,
HAL_ENABLE_FEM_PPI,
(uint32_t)&(EVENT_TIMER->EVENTS_COMPARE[3]),
(uint32_t)&(gpiote_pdn.p_reg->TASKS_OUT[gpiote_ch_pdn]),
(uint32_t)&(gpiote_csn.p_reg->TASKS_OUT[gpiote_ch_csn]));
nrf_ppi_channel_and_fork_endpoint_setup(
(uint32_t)&(gpiote_pdn.p_reg->TASKS_OUT[gpiote_ch_pdn]));
nrf_ppi_channel_endpoint_setup(
NRF_PPI,
HAL_DISABLE_FEM_PPI,
(uint32_t)&(NRF_RADIO->EVENTS_DISABLED),
(uint32_t)&(gpiote_pdn.p_reg->TASKS_OUT[gpiote_ch_pdn]),
(uint32_t)&(gpiote_csn.p_reg->TASKS_OUT[gpiote_ch_csn]));
(uint32_t)&(gpiote_pdn.p_reg->TASKS_OUT[gpiote_ch_pdn]));
}

Check notice on line 49 in subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_ppi_gpiote.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_ppi_gpiote.h:49 - nrf_ppi_channel_endpoint_setup( - NRF_PPI, - HAL_ENABLE_FEM_PPI, - (uint32_t)&(EVENT_TIMER->EVENTS_COMPARE[3]), - (uint32_t)&(gpiote_pdn.p_reg->TASKS_OUT[gpiote_ch_pdn])); - nrf_ppi_channel_endpoint_setup( - NRF_PPI, - HAL_DISABLE_FEM_PPI, - (uint32_t)&(NRF_RADIO->EVENTS_DISABLED), - (uint32_t)&(gpiote_pdn.p_reg->TASKS_OUT[gpiote_ch_pdn])); + nrf_ppi_channel_endpoint_setup(NRF_PPI, HAL_ENABLE_FEM_PPI, + (uint32_t)&(EVENT_TIMER->EVENTS_COMPARE[3]), + (uint32_t)&(gpiote_pdn.p_reg->TASKS_OUT[gpiote_ch_pdn])); + nrf_ppi_channel_endpoint_setup(NRF_PPI, HAL_DISABLE_FEM_PPI, + (uint32_t)&(NRF_RADIO->EVENTS_DISABLED), + (uint32_t)&(gpiote_pdn.p_reg->TASKS_OUT[gpiote_ch_pdn]));

#endif /* HAL_RADIO_FEM_IS_NRF21540 */

0 comments on commit b61372e

Please sign in to comment.