1 /* 2 * Copyright (c) 2018 Aapo Vienamo 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/init.h> 8 #include <zephyr/drivers/gpio.h> 9 #include <zephyr/kernel.h> 10 11 static const struct gpio_dt_spec ccs_gpio = 12 GPIO_DT_SPEC_GET(DT_NODELABEL(ccs_pwr), enable_gpios); 13 pwr_ctrl_init(void)14static int pwr_ctrl_init(void) 15 { 16 int ret; 17 18 if (!gpio_is_ready_dt(&ccs_gpio)) { 19 return -ENODEV; 20 } 21 22 ret = gpio_pin_configure_dt(&ccs_gpio, GPIO_OUTPUT_HIGH); 23 if (ret < 0) { 24 return ret; 25 } 26 27 k_sleep(K_MSEC(1)); /* Wait for the rail to come up and stabilize */ 28 29 return 0; 30 } 31 32 33 #if CONFIG_SENSOR_INIT_PRIORITY <= CONFIG_BOARD_CCS_VDD_PWR_CTRL_INIT_PRIORITY 34 #error BOARD_CCS_VDD_PWR_CTRL_INIT_PRIORITY must be lower than SENSOR_INIT_PRIORITY 35 #endif 36 37 SYS_INIT(pwr_ctrl_init, POST_KERNEL, 38 CONFIG_BOARD_CCS_VDD_PWR_CTRL_INIT_PRIORITY); 39