1 /*
2  * Copyright (c) 2006-2023, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2023-09-23     GuEe-GUI     first version
9  */
10 
11 #include "regulator_dm.h"
12 
13 #ifdef RT_USING_OFW
regulator_ofw_parse(struct rt_ofw_node * np,struct rt_regulator_param * param)14 rt_err_t regulator_ofw_parse(struct rt_ofw_node *np, struct rt_regulator_param *param)
15 {
16     rt_uint32_t pval;
17 
18     param->name = rt_ofw_prop_read_raw(np, "regulator-name", RT_NULL);
19 
20     if (!rt_ofw_prop_read_u32(np, "regulator-min-microvolt", &pval))
21     {
22         param->min_uvolt = pval;
23     }
24 
25     if (!rt_ofw_prop_read_u32(np, "regulator-max-microvolt", &pval))
26     {
27         param->max_uvolt = pval;
28     }
29 
30     if (!rt_ofw_prop_read_u32(np, "regulator-min-microamp", &pval))
31     {
32         param->min_uamp = pval;
33     }
34 
35     if (!rt_ofw_prop_read_u32(np, "regulator-max-microamp", &pval))
36     {
37         param->max_uamp = pval;
38     }
39 
40     if (!rt_ofw_prop_read_u32(np, "regulator-ramp-delay", &pval))
41     {
42         param->ramp_delay = pval;
43     }
44 
45     if (!rt_ofw_prop_read_u32(np, "regulator-enable-ramp-delay", &pval))
46     {
47         param->enable_delay = pval;
48     }
49 
50     param->enable_active_high = rt_ofw_prop_read_bool(np, "enable-active-high");
51     param->boot_on = rt_ofw_prop_read_bool(np, "regulator-boot-on");
52     param->always_on = rt_ofw_prop_read_bool(np, "regulator-always-on");
53     param->soft_start = rt_ofw_prop_read_bool(np, "regulator-soft-start");
54     param->pull_down = rt_ofw_prop_read_bool(np, "regulator-pull-down");
55     param->over_current_protection = rt_ofw_prop_read_bool(np, "regulator-over-current-protection");
56 
57     return RT_EOK;
58 }
59 #endif /* RT_USING_OFW */
60