1 /*
2  * Copyright (c) 2019 Foundries.io
3  * Copyright (c) 2019 Peter Bigot Consulting, LLC
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #include <zephyr/init.h>
9 #include <zephyr/drivers/gpio.h>
10 
11 #define ANT_UFLn_GPIO_SPEC	GPIO_DT_SPEC_GET(DT_NODELABEL(sky13351), vctl1_gpios)
12 
external_antenna(bool on)13 static inline void external_antenna(bool on)
14 {
15 	struct gpio_dt_spec ufl_gpio = ANT_UFLn_GPIO_SPEC;
16 
17 	/*
18 	 * On power-up the SKY13351 is left uncontrolled, so neither
19 	 * PCB nor external antenna is selected.  Select the PCB
20 	 * antenna.
21 	 */
22 	if (!gpio_is_ready_dt(&ufl_gpio)) {
23 		return;
24 	}
25 
26 	gpio_pin_configure_dt(&ufl_gpio, (on ? GPIO_OUTPUT_ACTIVE : GPIO_OUTPUT_INACTIVE));
27 }
28 
board_particle_boron_init(void)29 static int board_particle_boron_init(void)
30 {
31 	external_antenna(false);
32 
33 	return 0;
34 }
35 
36 SYS_INIT(board_particle_boron_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
37