boards: arm: nrf9160_innblue22: use regulators

The board enabled power switches at init time, hardcoding switch
information in a board C file. This patch makes use of the regulator
infrastructure to describe such power switches in DT, making the board
specific C code obsolete. CONFIG_REGULATOR is only enabled if
CONFIG_SENSOR=y, as switches power sensors.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2022-06-27 11:16:36 +02:00 committed by Maureen Helm
commit fa0dc683fd
4 changed files with 12 additions and 44 deletions

View file

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

View file

@ -42,4 +42,7 @@ endif # BOARD_NRF9160_INNBLUE22_NS
config BT_HCI_VS
default y if BT
config REGULATOR
default y if SENSOR
endif # BOARD_NRF9160_INNBLUE22 || BOARD_NRF9160_INNBLUE22_NS

View file

@ -1,40 +0,0 @@
/*
* Copyright (c) 2020 InnBlue
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/init.h>
#include <zephyr/drivers/gpio.h>
#define VDD_5V0_PWR_CTRL_GPIO_PIN 21 /* ENABLE_5V0_BOOST --> speed sensor */
static int pwr_ctrl_init(const struct device *dev)
{
const struct device *gpio;
int err = -ENODEV;
/* Get handle of the GPIO device. */
gpio = DEVICE_DT_GET(DT_NODELABEL(gpio0));
if (!device_is_ready(gpio)) {
return -ENODEV;
}
/* Configure this pin as output. */
err = gpio_pin_configure(gpio, VDD_5V0_PWR_CTRL_GPIO_PIN,
GPIO_OUTPUT_ACTIVE);
if (err == 0) {
/* Write "1" to this pin. */
err = gpio_pin_set(gpio, VDD_5V0_PWR_CTRL_GPIO_PIN, 1);
}
/* Wait for the rail to come up and stabilize. */
k_sleep(K_MSEC(10));
/* Operation status? */
return (err);
}
SYS_INIT(pwr_ctrl_init, POST_KERNEL, 70);

View file

@ -45,6 +45,15 @@
};
};
en_5v0_boost: enable-5v0-boost {
compatible = "regulator-fixed-sync", "regulator-fixed";
label = "ENABLE_5V0_BOOST";
regulator-name = "en_5v0_boost";
enable-gpios = <&gpio0 21 GPIO_ACTIVE_HIGH>;
startup-delay-us = <10000>;
regulator-boot-on;
};
/* These aliases are provided for compatibility with samples */
aliases {
led0 = &red_led;