2019-04-12 03:46:45 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Peter Bigot Consulting, LLC
|
|
|
|
* Copyright (c) 2019 Foundries.io
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2022-05-06 16:56:39 +08:00
|
|
|
#include <zephyr/init.h>
|
|
|
|
#include <zephyr/drivers/gpio.h>
|
2022-07-02 18:23:36 +08:00
|
|
|
|
|
|
|
#define SKY_UFLn_GPIO_SPEC GPIO_DT_SPEC_GET(DT_NODELABEL(sky13351), vctl1_gpios)
|
|
|
|
#define SKY_PCBn_GPIO_SPEC GPIO_DT_SPEC_GET(DT_NODELABEL(sky13351), vctl2_gpios)
|
2019-04-12 03:46:45 +08:00
|
|
|
|
|
|
|
static inline void external_antenna(bool on)
|
|
|
|
{
|
2022-07-02 18:23:36 +08:00
|
|
|
struct gpio_dt_spec ufl_gpio = SKY_UFLn_GPIO_SPEC;
|
|
|
|
struct gpio_dt_spec pcb_gpio = SKY_PCBn_GPIO_SPEC;
|
2019-04-12 03:46:45 +08:00
|
|
|
|
2022-07-02 18:23:36 +08:00
|
|
|
if (!device_is_ready(ufl_gpio.port)) {
|
2019-04-12 03:46:45 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-02 18:23:36 +08:00
|
|
|
if (!device_is_ready(pcb_gpio.port)) {
|
2019-04-12 03:46:45 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-02 18:23:36 +08:00
|
|
|
gpio_pin_configure_dt(&ufl_gpio, (on ? GPIO_OUTPUT_ACTIVE : GPIO_OUTPUT_INACTIVE));
|
|
|
|
gpio_pin_configure_dt(&pcb_gpio, (on ? GPIO_OUTPUT_INACTIVE : GPIO_OUTPUT_ACTIVE));
|
2019-04-12 03:46:45 +08:00
|
|
|
}
|
|
|
|
|
2020-05-01 02:33:38 +08:00
|
|
|
static int board_particle_xenon_init(const struct device *dev)
|
2019-04-12 03:46:45 +08:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-03-26 22:41:38 +08:00
|
|
|
/* needs to be done after GPIO driver init, which is at
|
|
|
|
* POST_KERNEL:KERNEL_INIT_PRIORITY_DEFAULT.
|
|
|
|
*/
|
|
|
|
SYS_INIT(board_particle_xenon_init, POST_KERNEL, 99);
|