1 /*
2 * Copyright (c) 2025 Renesas Electronics Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <zephyr/init.h>
8 #include <zephyr/drivers/gpio.h>
9 #include <zephyr/devicetree.h>
10 #include <zephyr/logging/log.h>
11
12 LOG_MODULE_REGISTER(board_control, CONFIG_LOG_DEFAULT_LEVEL);
13
14 #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(i3c0)) && defined(CONFIG_I3C)
i3c_init(void)15 static int i3c_init(void)
16 {
17 const struct gpio_dt_spec i3c_pullup_gpios[2] = {
18 GPIO_DT_SPEC_GET_BY_IDX(DT_PATH(zephyr_user), i3c_pullup_gpios, 0),
19 GPIO_DT_SPEC_GET_BY_IDX(DT_PATH(zephyr_user), i3c_pullup_gpios, 1),
20 };
21
22 if (!gpio_is_ready_dt(&i3c_pullup_gpios[0]) || !gpio_is_ready_dt(&i3c_pullup_gpios[1])) {
23 LOG_ERR("I3C pull-up control is not ready");
24 return -ENODEV;
25 }
26
27 if (gpio_pin_configure_dt(&i3c_pullup_gpios[0], GPIO_INPUT) ||
28 gpio_pin_configure_dt(&i3c_pullup_gpios[1], GPIO_INPUT)) {
29 LOG_ERR("Failed to configure pull-up control");
30 return -EIO;
31 }
32
33 return 0;
34 }
35
36 SYS_INIT(i3c_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
37 #endif
38