boards: arm: actinius_icarus_som: move sim selection to DT
Move sim selection to DT using a custom compatible and make use of gpio_dt_spec. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
0de24502a3
commit
be77889e07
5 changed files with 52 additions and 27 deletions
|
@ -5,11 +5,6 @@
|
|||
|
||||
if BOARD_ACTINIUS_ICARUS_SOM || BOARD_ACTINIUS_ICARUS_SOM_NS
|
||||
|
||||
config BOARD_SELECT_SIM_EXTERNAL
|
||||
bool "Use external SIM"
|
||||
help
|
||||
Use the external SIM for communication, instead of the eSIM
|
||||
|
||||
module = BOARD_ICARUS_SOM
|
||||
module-str = Board Control
|
||||
source "subsys/logging/Kconfig.template.log_config"
|
||||
|
|
|
@ -14,6 +14,12 @@
|
|||
zephyr,shell-uart = &uart0;
|
||||
zephyr,uart-mcumgr = &uart0;
|
||||
};
|
||||
|
||||
sim_select: sim-select {
|
||||
compatible = "sim-select";
|
||||
sim-gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>;
|
||||
sim = "esim";
|
||||
};
|
||||
};
|
||||
|
||||
&adc {
|
||||
|
|
|
@ -5,37 +5,30 @@
|
|||
*/
|
||||
|
||||
#include <zephyr/init.h>
|
||||
#include <zephyr/devicetree.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(board_control, CONFIG_BOARD_ICARUS_SOM_LOG_LEVEL);
|
||||
|
||||
#define SIM_SELECT_PIN 12
|
||||
|
||||
static void select_sim(void)
|
||||
{
|
||||
const struct device *port = device_get_binding(DT_LABEL(DT_NODELABEL(gpio0)));
|
||||
|
||||
if (!port) {
|
||||
LOG_ERR("Could not get GPIO Device Binding");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BOARD_SELECT_SIM_EXTERNAL
|
||||
gpio_pin_configure(port, SIM_SELECT_PIN, GPIO_OUTPUT_LOW);
|
||||
LOG_INF("External SIM is selected");
|
||||
#else
|
||||
gpio_pin_configure(port, SIM_SELECT_PIN, GPIO_OUTPUT_HIGH);
|
||||
LOG_INF("eSIM is selected");
|
||||
#endif
|
||||
}
|
||||
|
||||
static int board_actinius_icarus_som_init(const struct device *dev)
|
||||
{
|
||||
const struct gpio_dt_spec sim =
|
||||
GPIO_DT_SPEC_GET(DT_NODELABEL(sim_select), sim_gpios);
|
||||
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
select_sim();
|
||||
if (!device_is_ready(sim.port)) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (DT_ENUM_IDX(DT_NODELABEL(sim_select), sim) == 0) {
|
||||
(void)gpio_pin_configure_dt(&sim, GPIO_OUTPUT_INIT_HIGH);
|
||||
LOG_INF("eSIM is selected");
|
||||
} else {
|
||||
(void)gpio_pin_configure_dt(&sim, GPIO_OUTPUT_INIT_LOW);
|
||||
LOG_INF("External SIM is selected");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -90,6 +90,11 @@ hardware features:
|
|||
| ACCEL | st | lis2dh |
|
||||
+-----------+------------+----------------------+
|
||||
|
||||
SIM selection
|
||||
*************
|
||||
|
||||
The sim choice (eSIM or nano-SIM) can be configured in Devicetree by adjusting
|
||||
the ``sim`` property in the ``sim_select`` node.
|
||||
|
||||
Security components
|
||||
===================
|
||||
|
|
26
boards/arm/actinius_icarus_som/dts/bindings/sim-select.yaml
Normal file
26
boards/arm/actinius_icarus_som/dts/bindings/sim-select.yaml
Normal file
|
@ -0,0 +1,26 @@
|
|||
# Copyright (c) 2022 Nordic Semiconductor ASA
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
description: |
|
||||
The Icarus boards provide the user with 2 options regarding SIM usage for
|
||||
LTE-M/NB-IoT communication. Either using the on-board eSIM or using an
|
||||
external nano-SIM. The SIM can be selected using the SIM select pin given by
|
||||
the sim-gpios property by setting it to 0 (eSIM) or to 1 (external nano-SIM).
|
||||
|
||||
compatible: "sim-select"
|
||||
|
||||
include: base.yaml
|
||||
|
||||
properties:
|
||||
sim-gpios:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: Pin used to select the SIM
|
||||
|
||||
sim:
|
||||
type: string
|
||||
required: true
|
||||
enum:
|
||||
- "esim"
|
||||
- "external"
|
||||
description: SIM choice (eSIM or external nano-SIM)
|
Loading…
Add table
Add a link
Reference in a new issue