diff --git a/boards/arm/96b_wistrio/96b_wistrio.dts b/boards/arm/96b_wistrio/96b_wistrio.dts index fb35b811c01..d1188e14521 100644 --- a/boards/arm/96b_wistrio/96b_wistrio.dts +++ b/boards/arm/96b_wistrio/96b_wistrio.dts @@ -73,6 +73,7 @@ <&gpioh 0 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>, <&gpioc 13 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; spi-max-frequency = <1000000>; + power-amplifier-output = "pa-boost"; }; }; diff --git a/drivers/lora/Kconfig.sx1276 b/drivers/lora/Kconfig.sx1276 index a8853f12054..0da357c36a7 100644 --- a/drivers/lora/Kconfig.sx1276 +++ b/drivers/lora/Kconfig.sx1276 @@ -4,7 +4,7 @@ # SPDX-License-Identifier: Apache-2.0 # -menuconfig LORA_SX1276 +config LORA_SX1276 bool "Semtech SX1276 driver" select HAS_SEMTECH_RADIO_DRIVERS select HAS_SEMTECH_LORAMAC @@ -12,22 +12,3 @@ menuconfig LORA_SX1276 depends on SPI help Enable LoRa driver for Semtech SX1276. - -choice - prompt "SX1276 PA Output pin" - default PA_BOOST_PIN - depends on LORA_SX1276 - help - Antenna connection type. - -config PA_RFO_PIN - bool "PA_RFO_PIN" - help - Antenna connected to PA_RFO pin. - -config PA_BOOST_PIN - bool "PA_BOOST_PIN" - help - Antenna connected to PA_BOOST pin. - -endchoice diff --git a/drivers/lora/sx1276.c b/drivers/lora/sx1276.c index 6d25e93cebb..095f2919ddc 100644 --- a/drivers/lora/sx1276.c +++ b/drivers/lora/sx1276.c @@ -23,6 +23,15 @@ LOG_MODULE_REGISTER(sx1276); #define GPIO_RESET_FLAGS DT_INST_GPIO_FLAGS(0, reset_gpios) #define GPIO_CS_PIN DT_INST_SPI_DEV_CS_GPIOS_PIN(0) +#define PA_PIN DT_ENUM_IDX(DT_DRV_INST(0), \ + power_amplifier_output) + +/* + * Those macros must be in sync with 'power-amplifier-output' dts property. + */ +#define SX1276_PA_RFO 0 +#define SX1276_PA_BOOST 1 + #define SX1276_REG_PA_CONFIG 0x09 #define SX1276_REG_PA_DAC 0x4d #define SX1276_REG_VERSION 0x42 @@ -239,7 +248,7 @@ void SX1276SetRfTxPower(int8_t power) pa_dac &= RF_PADAC_20DBM_MASK; -#if defined CONFIG_PA_BOOST_PIN +#if PA_PIN == SX1276_PA_BOOST power = clamp_int8(power, 2, 20); pa_config |= RF_PACONFIG_PASELECT_PABOOST; @@ -250,7 +259,7 @@ void SX1276SetRfTxPower(int8_t power) pa_dac |= RF_PADAC_20DBM_OFF; pa_config |= (power - 2) & 0x0F; } -#elif CONFIG_PA_RFO_PIN +#elif PA_PIN == SX1276_PA_RFO power = clamp_int8(power, -4, 15); pa_dac |= RF_PADAC_20DBM_OFF; diff --git a/dts/bindings/lora/semtech,sx1276.yaml b/dts/bindings/lora/semtech,sx1276.yaml index 7b2d3f2a9a3..4bf724bc8df 100644 --- a/dts/bindings/lora/semtech,sx1276.yaml +++ b/dts/bindings/lora/semtech,sx1276.yaml @@ -1,4 +1,5 @@ # Copyright (c) 2019, Manivannan Sadhasivam +# Copyright (c) 2020, Grinn # SPDX-License-Identifier: Apache-2.0 description: Semtech SX1276 LoRa Modem @@ -24,3 +25,12 @@ properties: Up to six pins that produce service interrupts from the modem. These signals are normally active-high. + + power-amplifier-output: + type: string + required: true + description: | + Selects power amplifier output pin. + enum: + - "rfo" + - "pa-boost" diff --git a/tests/drivers/build_all/spi.dtsi b/tests/drivers/build_all/spi.dtsi index 9fa0a039961..0bccaa808ed 100644 --- a/tests/drivers/build_all/spi.dtsi +++ b/tests/drivers/build_all/spi.dtsi @@ -208,6 +208,7 @@ test_spi_sx1276: sx1276@13 { spi-max-frequency = <0>; reset-gpios = <&test_gpio 0 0>; dio-gpios = <&test_gpio 0 0>; + power-amplifier-output = "rfo"; }; test_spi_st7789v: st7789v@14 {