Skip to content

Commit 9ea3110

Browse files
committed
mpsl: fem: Replace label comparison with device tree macros
This tidies up the MPSL FEM GPIO configuration code to use device tree macros rather than checking the string of the GPIO port to detemine a pin mapping Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
1 parent 20f189b commit 9ea3110

File tree

5 files changed

+14
-78
lines changed

5 files changed

+14
-78
lines changed

subsys/mpsl/fem/common/include/mpsl_fem_utils.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@
1818
*/
1919
void mpsl_fem_extended_pin_to_mpsl_fem_pin(uint32_t pin_num, mpsl_fem_pin_t *p_fem_pin);
2020

21-
#else // !defined(CONFIG_MPSL_FEM_PIN_FORWARDER)
22-
23-
/** @brief Embeds GPIO port number into GPIO pin number.
24-
*
25-
* @param[inout] pin Pointer to be filled with updated GPIO pin number.
26-
* @param[in] lbl Label property from a gpio phandle-array property the update
27-
* should be done for.
28-
*/
29-
void mpsl_fem_pin_extend_with_port(uint8_t *pin, const char *lbl);
30-
3121
#endif /* !defined(CONFIG_MPSL_FEM_PIN_FORWARDER) */
3222

3323
#endif /* MPSL_FEM_UTILS_H__ */

subsys/mpsl/fem/common/mpsl_fem_utils.c

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,4 @@ void mpsl_fem_extended_pin_to_mpsl_fem_pin(uint32_t pin_num, mpsl_fem_pin_t *p_f
2525
p_fem_pin->port_pin = pin_num;
2626
}
2727

28-
#else
29-
30-
void mpsl_fem_pin_extend_with_port(uint8_t *pin, const char *lbl)
31-
{
32-
/* The pin numbering in the FEM configuration API follows the
33-
* convention:
34-
* pin numbers 0..31 correspond to the gpio0 port
35-
* pin numbers 32..63 correspond to the gpio1 port
36-
*
37-
* Values obtained from devicetree are here adjusted to the ranges
38-
* given above.
39-
*/
40-
41-
#if DT_NODE_HAS_STATUS(DT_NODELABEL(gpio0), okay)
42-
if (strcmp(lbl, UTIL_CAT(DT_NODELABEL(gpio0), _FULL_NAME)) == 0) {
43-
return;
44-
}
45-
#endif
46-
47-
#if DT_NODE_HAS_STATUS(DT_NODELABEL(gpio1), okay)
48-
if (strcmp(lbl, UTIL_CAT(DT_NODELABEL(gpio1), _FULL_NAME)) == 0) {
49-
*pin += 32;
50-
return;
51-
}
52-
#endif
53-
(void)pin;
54-
55-
__ASSERT(false, "Unknown GPIO port");
56-
}
57-
5828
#endif /* !defined(CONFIG_MPSL_FEM_PIN_FORWARDER) */

subsys/mpsl/fem/nrf21540_gpio/mpsl_fem_nrf21540_gpio.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -288,42 +288,32 @@ static int mpsl_fem_host_init(const struct device *dev)
288288
ARG_UNUSED(dev);
289289

290290
#if DT_NODE_HAS_PROP(DT_NODELABEL(nrf_radio_fem), tx_en_gpios)
291-
uint8_t tx_en_pin = DT_GPIO_PIN(DT_NODELABEL(nrf_radio_fem), tx_en_gpios);
291+
uint8_t tx_en_pin = NRF_DT_GPIOS_TO_PSEL(DT_NODELABEL(nrf_radio_fem), tx_en_gpios);
292292

293-
mpsl_fem_pin_extend_with_port(
294-
&tx_en_pin, UTIL_CAT(DT_GPIO_CTLR(DT_NODELABEL(nrf_radio_fem), tx_en_gpios), _FULL_NAME));
295293
soc_secure_gpio_pin_mcu_select(tx_en_pin, NRF_GPIO_PIN_MCUSEL_NETWORK);
296294
#endif
297295

298296
#if DT_NODE_HAS_PROP(DT_NODELABEL(nrf_radio_fem), rx_en_gpios)
299-
uint8_t rx_en_pin = DT_GPIO_PIN(DT_NODELABEL(nrf_radio_fem), rx_en_gpios);
297+
uint8_t rx_en_pin = NRF_DT_GPIOS_TO_PSEL(DT_NODELABEL(nrf_radio_fem), rx_en_gpios);
300298

301-
mpsl_fem_pin_extend_with_port(
302-
&rx_en_pin, UTIL_CAT(DT_GPIO_CTLR(DT_NODELABEL(nrf_radio_fem), rx_en_gpios), _FULL_NAME));
303299
soc_secure_gpio_pin_mcu_select(rx_en_pin, NRF_GPIO_PIN_MCUSEL_NETWORK);
304300
#endif
305301

306302
#if DT_NODE_HAS_PROP(DT_NODELABEL(nrf_radio_fem), pdn_gpios)
307-
uint8_t pdn_pin = DT_GPIO_PIN(DT_NODELABEL(nrf_radio_fem), pdn_gpios);
303+
uint8_t pdn_pin = NRF_DT_GPIOS_TO_PSEL(DT_NODELABEL(nrf_radio_fem), pdn_gpios);
308304

309-
mpsl_fem_pin_extend_with_port(
310-
&pdn_pin, UTIL_CAT(DT_GPIO_CTLR(DT_NODELABEL(nrf_radio_fem), pdn_gpios), _FULL_NAME));
311305
soc_secure_gpio_pin_mcu_select(pdn_pin, NRF_GPIO_PIN_MCUSEL_NETWORK);
312306
#endif
313307

314308
#if DT_NODE_HAS_PROP(DT_NODELABEL(nrf_radio_fem), mode_gpios)
315-
uint8_t mode_pin = DT_GPIO_PIN(DT_NODELABEL(nrf_radio_fem), mode_gpios);
309+
uint8_t mode_pin = NRF_DT_GPIOS_TO_PSEL(DT_NODELABEL(nrf_radio_fem), mode_gpios);
316310

317-
mpsl_fem_pin_extend_with_port(
318-
&mode_pin, UTIL_CAT(DT_GPIO_CTLR(DT_NODELABEL(nrf_radio_fem), mode_gpios), _FULL_NAME));
319311
soc_secure_gpio_pin_mcu_select(mode_pin, NRF_GPIO_PIN_MCUSEL_NETWORK);
320312
#endif
321313

322314
#if DT_NODE_HAS_PROP(DT_NODELABEL(nrf_radio_fem), ant_sel_gpios)
323-
uint8_t ant_sel_pin = DT_GPIO_PIN(DT_NODELABEL(nrf_radio_fem), ant_sel_gpios);
315+
uint8_t ant_sel_pin = NRF_DT_GPIOS_TO_PSEL(DT_NODELABEL(nrf_radio_fem), ant_sel_gpios);
324316

325-
mpsl_fem_pin_extend_with_port(
326-
&ant_sel_pin, UTIL_CAT(DT_GPIO_CTLR(DT_NODELABEL(nrf_radio_fem), ant_sel_gpios), _FULL_NAME));
327317
soc_secure_gpio_pin_mcu_select(ant_sel_pin, NRF_GPIO_PIN_MCUSEL_NETWORK);
328318
#endif
329319

subsys/mpsl/fem/nrf21540_gpio_spi/mpsl_fem_nrf21540_gpio_spi.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,9 @@ static void fem_host_init_spi(void)
424424
#endif /* CONFIG_PINCTRL */
425425

426426
/* configure cs pin */
427-
uint8_t cs_pin = DT_SPI_DEV_CS_GPIOS_PIN(MPSL_FEM_SPI_IF);
427+
uint8_t cs_pin = NRF_DT_GPIOS_TO_PSEL_BY_IDX(DT_BUS(MPSL_FEM_SPI_IF), cs_gpios,
428+
DT_REG_ADDR(MPSL_FEM_SPI_IF));
428429

429-
mpsl_fem_pin_extend_with_port(&cs_pin, DT_SPI_DEV_CS_GPIOS_LABEL(MPSL_FEM_SPI_IF));
430430
soc_secure_gpio_pin_mcu_select(cs_pin, NRF_GPIO_PIN_MCUSEL_NETWORK);
431431
#endif /* DT_NODE_HAS_STATUS(MPSL_FEM_SPI_IF, okay) */
432432
}
@@ -436,42 +436,32 @@ static int mpsl_fem_host_init(const struct device *dev)
436436
ARG_UNUSED(dev);
437437

438438
#if DT_NODE_HAS_PROP(DT_NODELABEL(nrf_radio_fem), tx_en_gpios)
439-
uint8_t tx_en_pin = DT_GPIO_PIN(DT_NODELABEL(nrf_radio_fem), tx_en_gpios);
439+
uint8_t tx_en_pin = NRF_DT_GPIOS_TO_PSEL(DT_NODELABEL(nrf_radio_fem), tx_en_gpios);
440440

441-
mpsl_fem_pin_extend_with_port(
442-
&tx_en_pin, DT_GPIO_LABEL(DT_NODELABEL(nrf_radio_fem), tx_en_gpios));
443441
soc_secure_gpio_pin_mcu_select(tx_en_pin, NRF_GPIO_PIN_MCUSEL_NETWORK);
444442
#endif
445443

446444
#if DT_NODE_HAS_PROP(DT_NODELABEL(nrf_radio_fem), rx_en_gpios)
447-
uint8_t rx_en_pin = DT_GPIO_PIN(DT_NODELABEL(nrf_radio_fem), rx_en_gpios);
445+
uint8_t rx_en_pin = NRF_DT_GPIOS_TO_PSEL(DT_NODELABEL(nrf_radio_fem), rx_en_gpios);
448446

449-
mpsl_fem_pin_extend_with_port(
450-
&rx_en_pin, DT_GPIO_LABEL(DT_NODELABEL(nrf_radio_fem), rx_en_gpios));
451447
soc_secure_gpio_pin_mcu_select(rx_en_pin, NRF_GPIO_PIN_MCUSEL_NETWORK);
452448
#endif
453449

454450
#if DT_NODE_HAS_PROP(DT_NODELABEL(nrf_radio_fem), pdn_gpios)
455-
uint8_t pdn_pin = DT_GPIO_PIN(DT_NODELABEL(nrf_radio_fem), pdn_gpios);
451+
uint8_t pdn_pin = NRF_DT_GPIOS_TO_PSEL(DT_NODELABEL(nrf_radio_fem), pdn_gpios);
456452

457-
mpsl_fem_pin_extend_with_port(
458-
&pdn_pin, DT_GPIO_LABEL(DT_NODELABEL(nrf_radio_fem), pdn_gpios));
459453
soc_secure_gpio_pin_mcu_select(pdn_pin, NRF_GPIO_PIN_MCUSEL_NETWORK);
460454
#endif
461455

462456
#if DT_NODE_HAS_PROP(DT_NODELABEL(nrf_radio_fem), mode_gpios)
463-
uint8_t mode_pin = DT_GPIO_PIN(DT_NODELABEL(nrf_radio_fem), mode_gpios);
457+
uint8_t mode_pin = NRF_DT_GPIOS_TO_PSEL(DT_NODELABEL(nrf_radio_fem), mode_gpios);
464458

465-
mpsl_fem_pin_extend_with_port(
466-
&mode_pin, DT_GPIO_LABEL(DT_NODELABEL(nrf_radio_fem), mode_gpios));
467459
soc_secure_gpio_pin_mcu_select(mode_pin, NRF_GPIO_PIN_MCUSEL_NETWORK);
468460
#endif
469461

470462
#if DT_NODE_HAS_PROP(DT_NODELABEL(nrf_radio_fem), ant_sel_gpios)
471-
uint8_t ant_sel_pin = DT_GPIO_PIN(DT_NODELABEL(nrf_radio_fem), ant_sel_gpios);
463+
uint8_t ant_sel_pin = NRF_DT_GPIOS_TO_PSEL(DT_NODELABEL(nrf_radio_fem), ant_sel_gpios);
472464

473-
mpsl_fem_pin_extend_with_port(
474-
&ant_sel_pin, DT_GPIO_LABEL(DT_NODELABEL(nrf_radio_fem), ant_sel_gpios));
475465
soc_secure_gpio_pin_mcu_select(ant_sel_pin, NRF_GPIO_PIN_MCUSEL_NETWORK);
476466
#endif
477467

subsys/mpsl/fem/simple_gpio/mpsl_fem_simple_gpio.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,18 +201,14 @@ static int mpsl_fem_host_init(const struct device *dev)
201201
ARG_UNUSED(dev);
202202

203203
#if DT_NODE_HAS_PROP(DT_NODELABEL(nrf_radio_fem), ctx_gpios)
204-
uint8_t ctx_pin = DT_GPIO_PIN(DT_NODELABEL(nrf_radio_fem), ctx_gpios);
204+
uint8_t ctx_pin = NRF_DT_GPIOS_TO_PSEL(DT_NODELABEL(nrf_radio_fem), ctx_gpios);
205205

206-
mpsl_fem_pin_extend_with_port(
207-
&ctx_pin, UTIL_CAT(DT_GPIO_CTLR(DT_NODELABEL(nrf_radio_fem), ctx_gpios), _FULL_NAME));
208206
soc_secure_gpio_pin_mcu_select(ctx_pin, NRF_GPIO_PIN_MCUSEL_NETWORK);
209207
#endif
210208

211209
#if DT_NODE_HAS_PROP(DT_NODELABEL(nrf_radio_fem), crx_gpios)
212-
uint8_t crx_pin = DT_GPIO_PIN(DT_NODELABEL(nrf_radio_fem), crx_gpios);
210+
uint8_t crx_pin = NRF_DT_GPIOS_TO_PSEL(DT_NODELABEL(nrf_radio_fem), crx_gpios);
213211

214-
mpsl_fem_pin_extend_with_port(
215-
&crx_pin, UTIL_CAT(DT_GPIO_CTLR(DT_NODELABEL(nrf_radio_fem), crx_gpios), _FULL_NAME));
216212
soc_secure_gpio_pin_mcu_select(crx_pin, NRF_GPIO_PIN_MCUSEL_NETWORK);
217213
#endif
218214

0 commit comments

Comments
 (0)