Lines Matching +full:child +full:- +full:node

1 // SPDX-License-Identifier: GPL-2.0-or-later
19 [PM_SUSPEND_STANDBY] = "regulator-state-standby",
20 [PM_SUSPEND_MEM] = "regulator-state-mem",
21 [PM_SUSPEND_MAX] = "regulator-state-disk",
41 "regulator-oc-%s-microamp", in of_get_regulator_prot_limits()
42 "regulator-ov-%s-microvolt", in of_get_regulator_prot_limits()
43 "regulator-temp-%s-kelvin", in of_get_regulator_prot_limits()
44 "regulator-uv-%s-microvolt", in of_get_regulator_prot_limits()
47 &constraints->over_curr_limits, in of_get_regulator_prot_limits()
48 &constraints->over_voltage_limits, in of_get_regulator_prot_limits()
49 &constraints->temp_limits, in of_get_regulator_prot_limits()
50 &constraints->under_voltage_limits, in of_get_regulator_prot_limits()
63 &limits[i]->prot, &limits[i]->err, &limits[i]->warn, in of_get_regulator_prot_limits()
74 constraints->over_current_detection = set[0]; in of_get_regulator_prot_limits()
75 constraints->over_voltage_detection = set[1]; in of_get_regulator_prot_limits()
76 constraints->over_temp_detection = set[2]; in of_get_regulator_prot_limits()
77 constraints->under_voltage_detection = set[3]; in of_get_regulator_prot_limits()
85 struct regulation_constraints *constraints = &(*init_data)->constraints; in of_get_regulation_constraints()
93 n_phandles = of_count_phandle_with_args(np, "regulator-coupled-with", in of_get_regulation_constraints()
97 constraints->name = of_get_property(np, "regulator-name", NULL); in of_get_regulation_constraints()
99 if (!of_property_read_u32(np, "regulator-min-microvolt", &pval)) in of_get_regulation_constraints()
100 constraints->min_uV = pval; in of_get_regulation_constraints()
102 if (!of_property_read_u32(np, "regulator-max-microvolt", &pval)) in of_get_regulation_constraints()
103 constraints->max_uV = pval; in of_get_regulation_constraints()
106 if (constraints->min_uV != constraints->max_uV) in of_get_regulation_constraints()
107 constraints->valid_ops_mask |= REGULATOR_CHANGE_VOLTAGE; in of_get_regulation_constraints()
110 if (constraints->min_uV && constraints->max_uV) in of_get_regulation_constraints()
111 constraints->apply_uV = true; in of_get_regulation_constraints()
113 if (!of_property_read_u32(np, "regulator-microvolt-offset", &pval)) in of_get_regulation_constraints()
114 constraints->uV_offset = pval; in of_get_regulation_constraints()
115 if (!of_property_read_u32(np, "regulator-min-microamp", &pval)) in of_get_regulation_constraints()
116 constraints->min_uA = pval; in of_get_regulation_constraints()
117 if (!of_property_read_u32(np, "regulator-max-microamp", &pval)) in of_get_regulation_constraints()
118 constraints->max_uA = pval; in of_get_regulation_constraints()
120 if (!of_property_read_u32(np, "regulator-input-current-limit-microamp", in of_get_regulation_constraints()
122 constraints->ilim_uA = pval; in of_get_regulation_constraints()
125 if (constraints->min_uA != constraints->max_uA) in of_get_regulation_constraints()
126 constraints->valid_ops_mask |= REGULATOR_CHANGE_CURRENT; in of_get_regulation_constraints()
128 constraints->boot_on = of_property_read_bool(np, "regulator-boot-on"); in of_get_regulation_constraints()
129 constraints->always_on = of_property_read_bool(np, "regulator-always-on"); in of_get_regulation_constraints()
130 if (!constraints->always_on) /* status change should be possible. */ in of_get_regulation_constraints()
131 constraints->valid_ops_mask |= REGULATOR_CHANGE_STATUS; in of_get_regulation_constraints()
133 constraints->pull_down = of_property_read_bool(np, "regulator-pull-down"); in of_get_regulation_constraints()
135 if (of_property_read_bool(np, "regulator-allow-bypass")) in of_get_regulation_constraints()
136 constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS; in of_get_regulation_constraints()
138 if (of_property_read_bool(np, "regulator-allow-set-load")) in of_get_regulation_constraints()
139 constraints->valid_ops_mask |= REGULATOR_CHANGE_DRMS; in of_get_regulation_constraints()
141 ret = of_property_read_u32(np, "regulator-ramp-delay", &pval); in of_get_regulation_constraints()
144 constraints->ramp_delay = pval; in of_get_regulation_constraints()
146 constraints->ramp_disable = true; in of_get_regulation_constraints()
149 ret = of_property_read_u32(np, "regulator-settling-time-us", &pval); in of_get_regulation_constraints()
151 constraints->settling_time = pval; in of_get_regulation_constraints()
153 ret = of_property_read_u32(np, "regulator-settling-time-up-us", &pval); in of_get_regulation_constraints()
155 constraints->settling_time_up = pval; in of_get_regulation_constraints()
156 if (constraints->settling_time_up && constraints->settling_time) { in of_get_regulation_constraints()
157 …pr_warn("%pOFn: ambiguous configuration for settling time, ignoring 'regulator-settling-time-up-us… in of_get_regulation_constraints()
159 constraints->settling_time_up = 0; in of_get_regulation_constraints()
162 ret = of_property_read_u32(np, "regulator-settling-time-down-us", in of_get_regulation_constraints()
165 constraints->settling_time_down = pval; in of_get_regulation_constraints()
166 if (constraints->settling_time_down && constraints->settling_time) { in of_get_regulation_constraints()
167 …n("%pOFn: ambiguous configuration for settling time, ignoring 'regulator-settling-time-down-us'\n", in of_get_regulation_constraints()
169 constraints->settling_time_down = 0; in of_get_regulation_constraints()
172 ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval); in of_get_regulation_constraints()
174 constraints->enable_time = pval; in of_get_regulation_constraints()
176 constraints->soft_start = of_property_read_bool(np, in of_get_regulation_constraints()
177 "regulator-soft-start"); in of_get_regulation_constraints()
178 ret = of_property_read_u32(np, "regulator-active-discharge", &pval); in of_get_regulation_constraints()
180 constraints->active_discharge = in of_get_regulation_constraints()
185 if (!of_property_read_u32(np, "regulator-initial-mode", &pval)) { in of_get_regulation_constraints()
186 if (desc && desc->of_map_mode) { in of_get_regulation_constraints()
187 mode = desc->of_map_mode(pval); in of_get_regulation_constraints()
191 constraints->initial_mode = mode; in of_get_regulation_constraints()
198 len = of_property_count_elems_of_size(np, "regulator-allowed-modes", in of_get_regulation_constraints()
201 if (desc && desc->of_map_mode) { in of_get_regulation_constraints()
204 "regulator-allowed-modes", i, &pval); in of_get_regulation_constraints()
210 mode = desc->of_map_mode(pval); in of_get_regulation_constraints()
212 pr_err("%pOFn: invalid regulator-allowed-modes element %u\n", in of_get_regulation_constraints()
215 constraints->valid_modes_mask |= mode; in of_get_regulation_constraints()
217 if (constraints->valid_modes_mask) in of_get_regulation_constraints()
218 constraints->valid_ops_mask in of_get_regulation_constraints()
225 if (!of_property_read_u32(np, "regulator-system-load", &pval)) in of_get_regulation_constraints()
226 constraints->system_load = pval; in of_get_regulation_constraints()
229 constraints->max_spread = devm_kzalloc(dev, in of_get_regulation_constraints()
230 sizeof(*constraints->max_spread) * n_phandles, in of_get_regulation_constraints()
233 if (!constraints->max_spread) in of_get_regulation_constraints()
234 return -ENOMEM; in of_get_regulation_constraints()
236 of_property_read_u32_array(np, "regulator-coupled-max-spread", in of_get_regulation_constraints()
237 constraints->max_spread, n_phandles); in of_get_regulation_constraints()
240 if (!of_property_read_u32(np, "regulator-max-step-microvolt", in of_get_regulation_constraints()
242 constraints->max_uV_step = pval; in of_get_regulation_constraints()
244 constraints->over_current_protection = of_property_read_bool(np, in of_get_regulation_constraints()
245 "regulator-over-current-protection"); in of_get_regulation_constraints()
252 suspend_state = &constraints->state_mem; in of_get_regulation_constraints()
255 suspend_state = &constraints->state_disk; in of_get_regulation_constraints()
258 suspend_state = &constraints->state_standby; in of_get_regulation_constraints()
274 if (!of_property_read_u32(suspend_np, "regulator-mode", in of_get_regulation_constraints()
276 if (desc && desc->of_map_mode) { in of_get_regulation_constraints()
277 mode = desc->of_map_mode(pval); in of_get_regulation_constraints()
282 suspend_state->mode = mode; in of_get_regulation_constraints()
290 "regulator-on-in-suspend")) in of_get_regulation_constraints()
291 suspend_state->enabled = ENABLE_IN_SUSPEND; in of_get_regulation_constraints()
293 "regulator-off-in-suspend")) in of_get_regulation_constraints()
294 suspend_state->enabled = DISABLE_IN_SUSPEND; in of_get_regulation_constraints()
297 "regulator-suspend-min-microvolt", &pval)) in of_get_regulation_constraints()
298 suspend_state->min_uV = pval; in of_get_regulation_constraints()
301 "regulator-suspend-max-microvolt", &pval)) in of_get_regulation_constraints()
302 suspend_state->max_uV = pval; in of_get_regulation_constraints()
305 "regulator-suspend-microvolt", &pval)) in of_get_regulation_constraints()
306 suspend_state->uV = pval; in of_get_regulation_constraints()
308 suspend_state->uV = suspend_state->min_uV; in of_get_regulation_constraints()
311 "regulator-changeable-in-suspend")) in of_get_regulation_constraints()
312 suspend_state->changeable = true; in of_get_regulation_constraints()
315 constraints->initial_state = PM_SUSPEND_MEM; in of_get_regulation_constraints()
326 * of_get_regulator_init_data - extract regulator_init_data structure info
328 * @node: regulator device node
332 * tree node, returns a pointer to the populated structure or NULL if memory
336 struct device_node *node, in of_get_regulator_init_data() argument
341 if (!node) in of_get_regulator_init_data()
348 if (of_get_regulation_constraints(dev, node, &init_data, desc)) in of_get_regulator_init_data()
365 for (i = 0; i < devm_matches->num_matches; i++) in devm_of_regulator_put_matches()
366 of_node_put(devm_matches->matches[i].of_node); in devm_of_regulator_put_matches()
370 * of_regulator_match - extract multiple regulator init data from device tree.
372 * @node: parent device node of the regulators
377 * parse regulator init data from the device tree. @node is expected to
378 * contain a set of child nodes, each providing the init data for one
379 * regulator. The data parsed from a child node will be matched to a regulator
380 * based on either the deprecated property regulator-compatible if present,
381 * or otherwise the child node's name. Note that the match table is modified
387 int of_regulator_match(struct device *dev, struct device_node *node, in of_regulator_match() argument
394 struct device_node *child; in of_regulator_match() local
397 if (!dev || !node) in of_regulator_match()
398 return -EINVAL; in of_regulator_match()
404 return -ENOMEM; in of_regulator_match()
406 devm_matches->matches = matches; in of_regulator_match()
407 devm_matches->num_matches = num_matches; in of_regulator_match()
413 match->init_data = NULL; in of_regulator_match()
414 match->of_node = NULL; in of_regulator_match()
417 for_each_child_of_node(node, child) { in of_regulator_match()
418 name = of_get_property(child, in of_regulator_match()
419 "regulator-compatible", NULL); in of_regulator_match()
421 name = child->name; in of_regulator_match()
424 if (match->of_node) in of_regulator_match()
427 if (strcmp(match->name, name)) in of_regulator_match()
430 match->init_data = in of_regulator_match()
431 of_get_regulator_init_data(dev, child, in of_regulator_match()
432 match->desc); in of_regulator_match()
433 if (!match->init_data) { in of_regulator_match()
436 child); in of_regulator_match()
437 of_node_put(child); in of_regulator_match()
438 return -EINVAL; in of_regulator_match()
440 match->of_node = of_node_get(child); in of_regulator_match()
454 struct device_node *search, *child; in regulator_of_get_init_node() local
457 if (!dev->of_node || !desc->of_match) in regulator_of_get_init_node()
460 if (desc->regulators_node) { in regulator_of_get_init_node()
461 search = of_get_child_by_name(dev->of_node, in regulator_of_get_init_node()
462 desc->regulators_node); in regulator_of_get_init_node()
464 search = of_node_get(dev->of_node); in regulator_of_get_init_node()
466 if (!strcmp(desc->of_match, search->name)) in regulator_of_get_init_node()
471 dev_dbg(dev, "Failed to find regulator container node '%s'\n", in regulator_of_get_init_node()
472 desc->regulators_node); in regulator_of_get_init_node()
476 for_each_available_child_of_node(search, child) { in regulator_of_get_init_node()
477 name = of_get_property(child, "regulator-compatible", NULL); in regulator_of_get_init_node()
479 if (!desc->of_match_full_name) in regulator_of_get_init_node()
480 name = child->name; in regulator_of_get_init_node()
482 name = child->full_name; in regulator_of_get_init_node()
485 if (!strcmp(desc->of_match, name)) { in regulator_of_get_init_node()
488 * 'of_node_get(child)' is already performed by the in regulator_of_get_init_node()
491 return child; in regulator_of_get_init_node()
503 struct device_node **node) in regulator_of_get_init_data() argument
505 struct device_node *child; in regulator_of_get_init_data() local
508 child = regulator_of_get_init_node(config->dev, desc); in regulator_of_get_init_data()
509 if (!child) in regulator_of_get_init_data()
512 init_data = of_get_regulator_init_data(dev, child, desc); in regulator_of_get_init_data()
514 dev_err(dev, "failed to parse DT for regulator %pOFn\n", child); in regulator_of_get_init_data()
518 if (desc->of_parse_cb) { in regulator_of_get_init_data()
521 ret = desc->of_parse_cb(child, desc, config); in regulator_of_get_init_data()
523 if (ret == -EPROBE_DEFER) { in regulator_of_get_init_data()
524 of_node_put(child); in regulator_of_get_init_data()
525 return ERR_PTR(-EPROBE_DEFER); in regulator_of_get_init_data()
529 child); in regulator_of_get_init_data()
534 *node = child; in regulator_of_get_init_data()
539 of_node_put(child); in regulator_of_get_init_data()
558 struct device_node *node = rdev->dev.of_node; in of_get_n_coupled() local
561 n_phandles = of_count_phandle_with_args(node, in of_get_n_coupled()
562 "regulator-coupled-with", in of_get_n_coupled()
568 /* Looks for "to_find" device_node in src's "regulator-coupled-with" property */
577 "regulator-coupled-with", in of_coupling_find_node()
582 "regulator-coupled-with", i); in of_coupling_find_node()
603 * of_check_coupling_data - Parse rdev's coupling properties and check data
608 * - rdev's max_spread is greater than 0
609 * - all coupled regulators have the same max_spread
610 * - all coupled regulators have the same number of regulator_dev phandles
611 * - all regulators are linked to each other
617 struct device_node *node = rdev->dev.of_node; in of_check_coupling_data() local
626 int max_spread = rdev->constraints->max_spread[i]; in of_check_coupling_data()
630 dev_err(&rdev->dev, "max_spread value invalid\n"); in of_check_coupling_data()
634 c_node = of_parse_phandle(node, in of_check_coupling_data()
635 "regulator-coupled-with", i); in of_check_coupling_data()
641 "regulator-coupled-with", in of_check_coupling_data()
645 dev_err(&rdev->dev, "number of coupled reg phandles mismatch\n"); in of_check_coupling_data()
650 if (!of_coupling_find_node(c_node, node, &index)) { in of_check_coupling_data()
651 dev_err(&rdev->dev, "missing 2-way linking for coupled regulators\n"); in of_check_coupling_data()
656 if (of_property_read_u32_index(c_node, "regulator-coupled-max-spread", in of_check_coupling_data()
663 dev_err(&rdev->dev, in of_check_coupling_data()
679 * of_parse_coupled_regulator() - Get regulator_dev pointer from rdev's property
681 * "regulator-coupled-with" property
690 struct device_node *node = rdev->dev.of_node; in of_parse_coupled_regulator() local
694 c_node = of_parse_phandle(node, "regulator-coupled-with", index); in of_parse_coupled_regulator()
706 * Check if name is a supply name according to the '*-supply' pattern
708 * return length of supply name without the -supply
715 /* string need to be at minimum len(x-supply) */ in is_supply_name()
718 for (i = strs - 6; i > 0; i--) { in is_supply_name()
719 /* find first '-' and check if right part is supply */ in is_supply_name()
720 if (name[i] != '-') in is_supply_name()
730 * of_regulator_bulk_get_all - get multiple regulator consumers
733 * @np: device node to search for consumers
755 * first pass: get numbers of xxx-supply in of_regulator_bulk_get_all()
760 i = is_supply_name(prop->name); in of_regulator_bulk_get_all()
767 memcpy(name, prop->name, i); in of_regulator_bulk_get_all()
771 ret = -EINVAL; in of_regulator_bulk_get_all()
787 return -ENOMEM; in of_regulator_bulk_get_all()
791 while (--n >= 0) in of_regulator_bulk_get_all()
792 regulator_put(consumers[n]->consumer); in of_regulator_bulk_get_all()