MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / regulator_fixed_probe

Function regulator_fixed_probe

components/drivers/regulator/regulator-fixed.c:93–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91};
92
93static rt_err_t regulator_fixed_probe(struct rt_platform_device *pdev)
94{
95 rt_err_t err;
96 rt_uint32_t val;
97 struct rt_device *dev = &pdev->parent;
98 struct regulator_fixed *rf = rt_calloc(1, sizeof(*rf));
99 struct rt_regulator_node *rnp;
100
101 if (!rf)
102 {
103 return -RT_ENOMEM;
104 }
105
106 regulator_ofw_parse(dev->ofw_node, &rf->param);
107
108 rnp = &rf->parent;
109 rnp->supply_name = rf->param.name;
110 rnp->ops = &regulator_fixed_ops;
111 rnp->param = &rf->param;
112 rnp->dev = &pdev->parent;
113
114 rf->enable_pin = rt_pin_get_named_pin(dev, "enable", 0, RT_NULL, RT_NULL);
115
116 if (rf->enable_pin < 0)
117 {
118 rf->enable_pin = rt_pin_get_named_pin(dev, RT_NULL, 0, RT_NULL, RT_NULL);
119 }
120
121 if (rf->enable_pin < 0)
122 {
123 rf->enable_pin = -1;
124 }
125
126 rt_pin_ctrl_confs_apply(dev, 0);
127
128 if (!rt_dm_dev_prop_read_u32(dev, "startup-delay-us", &val))
129 {
130 rf->param.enable_delay = val;
131 }
132
133 if (!rt_dm_dev_prop_read_u32(dev, "off-on-delay-us", &val))
134 {
135 rf->param.off_on_delay = val;
136 }
137
138 if ((err = rt_regulator_register(rnp)))
139 {
140 goto _fail;
141 }
142
143 return RT_EOK;
144
145_fail:
146 rt_free(rf);
147
148 return err;
149}
150

Callers

nothing calls this directly

Calls 7

rt_callocFunction · 0.85
regulator_ofw_parseFunction · 0.85
rt_pin_get_named_pinFunction · 0.85
rt_pin_ctrl_confs_applyFunction · 0.85
rt_dm_dev_prop_read_u32Function · 0.85
rt_regulator_registerFunction · 0.85
rt_freeFunction · 0.85

Tested by

no test coverage detected