boards: arm: particle_*: enable PCB antenna on startup

All three boards use a Skyworks SPDT switch to control whether the
antenna is connected to a PCB antenna or an external u.FL connector.
None of them power up in a state that properly enables an antenna.
Add startup code to configure for the PCB antenna.

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/14123

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
[mike@foundries.io: adjusted code to use Zephyr GPIO APIs.  boron is
now also based on DTS.]
Signed-off-by: Michael Scott <mike@foundries.io>
This commit is contained in:
Peter A. Bigot 2019-04-11 14:46:45 -05:00 committed by Anas Nashif
parent 190c43ee5f
commit be4c6ddd9c
11 changed files with 212 additions and 3 deletions

View file

@ -0,0 +1,4 @@
# SPDX-License-Identifier: Apache-2.0
zephyr_library()
zephyr_library_sources(board.c)

View file

@ -0,0 +1,56 @@
/*
* Copyright (c) 2019 Peter Bigot Consulting, LLC
* Copyright (c) 2019 Foundries.io
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <init.h>
#include <gpio.h>
#include "board.h"
static inline void external_antenna(bool on)
{
struct device *ufl_gpio_dev, *pcb_gpio_dev;
ufl_gpio_dev = device_get_binding(SKY_UFLn_GPIO_NAME);
if (!ufl_gpio_dev) {
return;
}
pcb_gpio_dev = device_get_binding(SKY_PCBn_GPIO_NAME);
if (!pcb_gpio_dev) {
return;
}
gpio_pin_configure(ufl_gpio_dev, SKY_UFLn_GPIO_PIN,
GPIO_DIR_OUT | SKY_UFLn_GPIO_FLAGS);
gpio_pin_configure(pcb_gpio_dev, SKY_PCBn_GPIO_PIN,
GPIO_DIR_OUT | SKY_PCBn_GPIO_FLAGS);
if (on) {
gpio_pin_write(ufl_gpio_dev, SKY_UFLn_GPIO_PIN, 1);
gpio_pin_write(pcb_gpio_dev, SKY_PCBn_GPIO_PIN, 0);
} else {
gpio_pin_write(ufl_gpio_dev, SKY_UFLn_GPIO_PIN, 0);
gpio_pin_write(pcb_gpio_dev, SKY_PCBn_GPIO_PIN, 1);
}
}
static int board_particle_argon_init(struct device *dev)
{
ARG_UNUSED(dev);
/*
* On power-up the SKY13351 is left uncontrolled, so neither
* PCB nor external antenna is selected. Select the PCB
* antenna.
*/
external_antenna(false);
return 0;
}
/* needs to be done after GPIO driver init */
SYS_INIT(board_particle_argon_init, POST_KERNEL,
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);

View file

@ -0,0 +1,18 @@
/*
* Copyright (c) 2019 Foundries.io
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __INC_BOARD_H
#define __INC_BOARD_H
/* SKYWORKS SKY13351 antenna selection settings */
#define SKY_UFLn_GPIO_NAME DT_SKYWORKS_SKY13351_0_VCTL1_GPIOS_CONTROLLER
#define SKY_UFLn_GPIO_FLAGS DT_SKYWORKS_SKY13351_0_VCTL1_GPIOS_FLAGS
#define SKY_UFLn_GPIO_PIN DT_SKYWORKS_SKY13351_0_VCTL1_GPIOS_PIN
#define SKY_PCBn_GPIO_NAME DT_SKYWORKS_SKY13351_0_VCTL2_GPIOS_CONTROLLER
#define SKY_PCBn_GPIO_FLAGS DT_SKYWORKS_SKY13351_0_VCTL2_GPIOS_FLAGS
#define SKY_PCBn_GPIO_PIN DT_SKYWORKS_SKY13351_0_VCTL2_GPIOS_PIN
#endif /* __INC_BOARD_H */

View file

@ -13,6 +13,12 @@
model = "Particle Argon";
compatible = "particle,argon", "particle,feather",
"nordic,nrf52840-qiaa", "nordic,nrf52840";
sky13351 {
compatible = "skyworks,sky13351";
vctl1-gpios = <&gpio0 25 0>;
vctl2-gpios = <&gpio0 2 0>;
};
};
&uart1 { /* ESP32 */

View file

@ -1,18 +1,44 @@
/*
* Copyright (c) 2019 Foundries.io
* Copyright (c) 2019 Peter Bigot Consulting, LLC
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <init.h>
#include "board.h"
#include <gpio.h>
#include "board.h"
static int particle_boron_init(struct device *dev)
static inline void external_antenna(bool on)
{
struct device *ant_sel_gpio_dev;
/*
* On power-up the SKY13351 is left uncontrolled, so neither
* PCB nor external antenna is selected. Select the PCB
* antenna.
*/
ant_sel_gpio_dev = device_get_binding(ANT_SEL_GPIO_NAME);
if (!ant_sel_gpio_dev) {
return;
}
gpio_pin_configure(ant_sel_gpio_dev, ANT_SEL_GPIO_PIN,
GPIO_DIR_OUT | ANT_SEL_GPIO_FLAGS);
if (on) {
gpio_pin_write(ant_sel_gpio_dev, ANT_SEL_GPIO_PIN, 1);
} else {
gpio_pin_write(ant_sel_gpio_dev, ANT_SEL_GPIO_PIN, 0);
}
}
static int board_particle_boron_init(struct device *dev)
{
ARG_UNUSED(dev);
external_antenna(false);
#if defined(CONFIG_MODEM_UBLOX_SARA_R4)
struct device *gpio_dev;
@ -32,4 +58,5 @@ static int particle_boron_init(struct device *dev)
}
/* needs to be done after GPIO driver init */
SYS_INIT(particle_boron_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
SYS_INIT(board_particle_boron_init, POST_KERNEL,
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);

View file

@ -14,4 +14,9 @@
/* pin used to detect V_INT (buffer power) */
#define V_INT_DETECT_GPIO_PIN 2
/* SKYWORKS SKY13351 antenna selection settings (only use vctl1) */
#define ANT_SEL_GPIO_NAME DT_SKYWORKS_SKY13351_0_VCTL1_GPIOS_CONTROLLER
#define ANT_SEL_GPIO_FLAGS DT_SKYWORKS_SKY13351_0_VCTL1_GPIOS_FLAGS
#define ANT_SEL_GPIO_PIN DT_SKYWORKS_SKY13351_0_VCTL1_GPIOS_PIN
#endif /* __INC_BOARD_H */

View file

@ -13,6 +13,15 @@
model = "Particle Boron";
compatible = "particle,boron", "particle,feather",
"nordic,nrf52840-qiaa", "nordic,nrf52840";
sky13351 {
compatible = "skyworks,sky13351";
vctl1-gpios = <&gpio0 7 0>;
/* on Boron VCTL2 is inverted VCTL1 signal via SN74LVC1G04
* single inverter gate -- requires a definition below,
* but is not used in board.c */
vctl2-gpios = <&gpio0 7 0>;
};
};
&i2c1 { /* power monitoring */

View file

@ -0,0 +1,4 @@
# SPDX-License-Identifier: Apache-2.0
zephyr_library()
zephyr_library_sources(board.c)

View file

@ -0,0 +1,56 @@
/*
* Copyright (c) 2019 Peter Bigot Consulting, LLC
* Copyright (c) 2019 Foundries.io
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <init.h>
#include <gpio.h>
#include "board.h"
static inline void external_antenna(bool on)
{
struct device *ufl_gpio_dev, *pcb_gpio_dev;
ufl_gpio_dev = device_get_binding(SKY_UFLn_GPIO_NAME);
if (!ufl_gpio_dev) {
return;
}
pcb_gpio_dev = device_get_binding(SKY_PCBn_GPIO_NAME);
if (!pcb_gpio_dev) {
return;
}
gpio_pin_configure(ufl_gpio_dev, SKY_UFLn_GPIO_PIN,
GPIO_DIR_OUT | SKY_UFLn_GPIO_FLAGS);
gpio_pin_configure(pcb_gpio_dev, SKY_PCBn_GPIO_PIN,
GPIO_DIR_OUT | SKY_PCBn_GPIO_FLAGS);
if (on) {
gpio_pin_write(ufl_gpio_dev, SKY_UFLn_GPIO_PIN, 1);
gpio_pin_write(pcb_gpio_dev, SKY_PCBn_GPIO_PIN, 0);
} else {
gpio_pin_write(ufl_gpio_dev, SKY_UFLn_GPIO_PIN, 0);
gpio_pin_write(pcb_gpio_dev, SKY_PCBn_GPIO_PIN, 1);
}
}
static int board_particle_xenon_init(struct device *dev)
{
ARG_UNUSED(dev);
/*
* On power-up the SKY13351 is left uncontrolled, so neither
* PCB nor external antenna is selected. Select the PCB
* antenna.
*/
external_antenna(false);
return 0;
}
/* needs to be done after GPIO driver init */
SYS_INIT(board_particle_xenon_init, POST_KERNEL,
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);

View file

@ -0,0 +1,18 @@
/*
* Copyright (c) 2019 Foundries.io
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __INC_BOARD_H
#define __INC_BOARD_H
/* SKYWORKS SKY13351 antenna selection settings */
#define SKY_UFLn_GPIO_NAME DT_SKYWORKS_SKY13351_0_VCTL1_GPIOS_CONTROLLER
#define SKY_UFLn_GPIO_FLAGS DT_SKYWORKS_SKY13351_0_VCTL1_GPIOS_FLAGS
#define SKY_UFLn_GPIO_PIN DT_SKYWORKS_SKY13351_0_VCTL1_GPIOS_PIN
#define SKY_PCBn_GPIO_NAME DT_SKYWORKS_SKY13351_0_VCTL2_GPIOS_CONTROLLER
#define SKY_PCBn_GPIO_FLAGS DT_SKYWORKS_SKY13351_0_VCTL2_GPIOS_FLAGS
#define SKY_PCBn_GPIO_PIN DT_SKYWORKS_SKY13351_0_VCTL2_GPIOS_PIN
#endif /* __INC_BOARD_H */

View file

@ -13,4 +13,10 @@
model = "Particle Xenon";
compatible = "particle,xenon", "particle,feather",
"nordic,nrf52840-qiaa", "nordic,nrf52840";
sky13351 {
compatible = "skyworks,sky13351";
vctl1-gpios = <&gpio0 24 0>;
vctl2-gpios = <&gpio0 25 0>;
};
};