boards: actinius_*: change all boards to use common/actinius lib

This changes all Actinius boards to use the helper lib in
`boards/common/actinius` for setting up common init values
such as SIM Select and Charger Enable.

Signed-off-by: Alex Tsamakos <alex@actinius.com>
This commit is contained in:
Alex Tsamakos 2022-12-15 04:22:37 +01:00 committed by Marti Bolivar
commit c348fb51c9
12 changed files with 9 additions and 209 deletions

View file

@ -5,6 +5,4 @@
zephyr_library()
if (CONFIG_BOARD_ACTINIUS_ICARUS_NS)
zephyr_library_sources(board.c)
endif()
add_subdirectory(${ZEPHYR_BASE}/boards/common/actinius actinius_common)

View file

@ -1,12 +0,0 @@
# Actinius Icarus board configuration
# Copyright (c) 2019 Actinius
# SPDX-License-Identifier: Apache-2.0
if BOARD_ACTINIUS_ICARUS || BOARD_ACTINIUS_ICARUS_NS
module = BOARD_ICARUS
module-str = Board Control
source "subsys/logging/Kconfig.template.log_config"
endif # BOARD_ACTINIUS_ICARUS || BOARD_ACTINIUS_ICARUS_NS

View file

@ -8,6 +8,8 @@ if BOARD_ACTINIUS_ICARUS || BOARD_ACTINIUS_ICARUS_NS
config BOARD
default "actinius_icarus"
source "boards/common/actinius/Kconfig"
# For the secure version of the board the firmware is linked at the beginning
# of the flash, or into the code-partition defined in DT if it is intended to
# be loaded by MCUboot. If the secure firmware is to be combined with a non-

View file

@ -1,86 +0,0 @@
/*
* Copyright (c) 2019-2022 Actinius
*
* SPDX-License-Identifier: Apache-2.0
*/
#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_LOG_LEVEL);
#define CHARGER_ENABLE_NODE DT_NODELABEL(charger_enable)
static int set_sim_select_pin(void)
{
const struct gpio_dt_spec sim =
GPIO_DT_SPEC_GET(DT_NODELABEL(sim_select), sim_gpios);
if (!device_is_ready(sim.port)) {
LOG_ERR("The SIM Select Pin port is not ready");
return -ENODEV;
}
if (DT_ENUM_IDX(DT_NODELABEL(sim_select), sim) == 0) {
(void)gpio_pin_configure_dt(&sim, GPIO_OUTPUT_HIGH);
LOG_INF("eSIM is selected");
} else {
(void)gpio_pin_configure_dt(&sim, GPIO_OUTPUT_LOW);
LOG_INF("External SIM is selected");
}
return 0;
}
#if DT_NODE_EXISTS(CHARGER_ENABLE_NODE)
static int set_charger_enable_pin(void)
{
const struct gpio_dt_spec charger_en =
GPIO_DT_SPEC_GET(CHARGER_ENABLE_NODE, gpios);
if (!device_is_ready(charger_en.port)) {
LOG_ERR("The Charger Enable Pin port is not ready");
return -ENODEV;
}
if (DT_ENUM_IDX(CHARGER_ENABLE_NODE, charger) == 0) {
(void)gpio_pin_configure_dt(&charger_en, GPIO_OUTPUT_LOW);
LOG_INF("Charger is set to auto");
} else {
(void)gpio_pin_configure_dt(&charger_en, GPIO_OUTPUT_HIGH);
LOG_INF("Charger is disabled");
}
return 0;
}
#endif /* DT_NODE_EXISTS(CHARGER_ENABLE_NODE) */
static int board_actinius_icarus_init(const struct device *dev)
{
ARG_UNUSED(dev);
int result;
result = set_sim_select_pin();
if (result < 0) {
LOG_ERR("Failed to set the SIM Select Pin (error: %d)", result);
/* do not return so that the rest of the init process is attempted */
}
#if DT_NODE_EXISTS(CHARGER_ENABLE_NODE)
result = set_charger_enable_pin();
if (result < 0) {
LOG_ERR("Failed to set the Charger Enable Pin (error: %d)", result);
/* do not return so that the rest of the init process is attempted */
}
#endif /* DT_NODE_EXISTS(CHARGER_ENABLE_NODE) */
return result;
}
/* Needs to happen after GPIO driver init */
SYS_INIT(board_actinius_icarus_init, POST_KERNEL, 99);

View file

@ -5,6 +5,4 @@
zephyr_library()
if (CONFIG_BOARD_ACTINIUS_ICARUS_BEE_NS)
zephyr_library_sources(board.c)
endif()
add_subdirectory(${ZEPHYR_BASE}/boards/common/actinius actinius_common)

View file

@ -1,12 +0,0 @@
# Actinius Icarus board configuration
# Copyright (c) 2021 Actinius
# SPDX-License-Identifier: Apache-2.0
if BOARD_ACTINIUS_ICARUS_BEE || BOARD_ACTINIUS_ICARUS_BEE_NS
module = BOARD_ICARUS_BEE
module-str = Board Control
source "subsys/logging/Kconfig.template.log_config"
endif # BOARD_ACTINIUS_ICARUS_BEE || BOARD_ACTINIUS_ICARUS_BEE_NS

View file

@ -8,6 +8,8 @@ if BOARD_ACTINIUS_ICARUS_BEE || BOARD_ACTINIUS_ICARUS_BEE_NS
config BOARD
default "actinius_icarus_bee"
source "boards/common/actinius/Kconfig"
# For the secure version of the board the firmware is linked at the beginning
# of the flash, or into the code-partition defined in DT if it is intended to
# be loaded by MCUboot. If the secure firmware is to be combined with a non-

View file

@ -1,39 +0,0 @@
/*
* Copyright (c) 2021-2022 Actinius
*
* SPDX-License-Identifier: Apache-2.0
*/
#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_BEE_LOG_LEVEL);
static int board_actinius_icarus_bee_init(const struct device *dev)
{
const struct gpio_dt_spec sim =
GPIO_DT_SPEC_GET(DT_NODELABEL(sim_select), sim_gpios);
ARG_UNUSED(dev);
if (!device_is_ready(sim.port)) {
LOG_ERR("The SIM Select Pin port is not ready");
return -ENODEV;
}
if (DT_ENUM_IDX(DT_NODELABEL(sim_select), sim) == 0) {
(void)gpio_pin_configure_dt(&sim, GPIO_OUTPUT_HIGH);
LOG_INF("eSIM is selected");
} else {
(void)gpio_pin_configure_dt(&sim, GPIO_OUTPUT_LOW);
LOG_INF("External SIM is selected");
}
return 0;
}
/* Needs to happen after GPIO driver init */
SYS_INIT(board_actinius_icarus_bee_init, POST_KERNEL, 99);

View file

@ -5,6 +5,4 @@
zephyr_library()
if (CONFIG_BOARD_ACTINIUS_ICARUS_SOM_NS)
zephyr_library_sources(board.c)
endif()
add_subdirectory(${ZEPHYR_BASE}/boards/common/actinius actinius_common)

View file

@ -1,12 +0,0 @@
# Actinius Icarus SoM board configuration
# Copyright (c) 2021 Actinius
# SPDX-License-Identifier: Apache-2.0
if BOARD_ACTINIUS_ICARUS_SOM || BOARD_ACTINIUS_ICARUS_SOM_NS
module = BOARD_ICARUS_SOM
module-str = Board Control
source "subsys/logging/Kconfig.template.log_config"
endif # BOARD_ACTINIUS_ICARUS_SOM || BOARD_ACTINIUS_ICARUS_SOM_NS

View file

@ -8,6 +8,8 @@ if BOARD_ACTINIUS_ICARUS_SOM || BOARD_ACTINIUS_ICARUS_SOM_NS
config BOARD
default "actinius_icarus_som"
source "boards/common/actinius/Kconfig"
# For the secure version of the board the firmware is linked at the beginning
# of the flash, or into the code-partition defined in DT if it is intended to
# be loaded by MCUboot. If the secure firmware is to be combined with a non-

View file

@ -1,39 +0,0 @@
/*
* Copyright (c) 2021-2022 Actinius
*
* SPDX-License-Identifier: Apache-2.0
*/
#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);
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);
if (!device_is_ready(sim.port)) {
LOG_ERR("The SIM Select Pin port is not ready");
return -ENODEV;
}
if (DT_ENUM_IDX(DT_NODELABEL(sim_select), sim) == 0) {
(void)gpio_pin_configure_dt(&sim, GPIO_OUTPUT_HIGH);
LOG_INF("eSIM is selected");
} else {
(void)gpio_pin_configure_dt(&sim, GPIO_OUTPUT_LOW);
LOG_INF("External SIM is selected");
}
return 0;
}
/* Needs to happen after GPIO driver init */
SYS_INIT(board_actinius_icarus_som_init, POST_KERNEL, 99);