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()
134 constraints->system_critical = of_property_read_bool(np, in of_get_regulation_constraints()
135 "system-critical-regulator"); in of_get_regulation_constraints()
137 if (of_property_read_bool(np, "regulator-allow-bypass")) in of_get_regulation_constraints()
138 constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS; in of_get_regulation_constraints()
140 if (of_property_read_bool(np, "regulator-allow-set-load")) in of_get_regulation_constraints()
141 constraints->valid_ops_mask |= REGULATOR_CHANGE_DRMS; in of_get_regulation_constraints()
143 ret = of_property_read_u32(np, "regulator-ramp-delay", &pval); in of_get_regulation_constraints()
146 constraints->ramp_delay = pval; in of_get_regulation_constraints()
148 constraints->ramp_disable = true; in of_get_regulation_constraints()
151 ret = of_property_read_u32(np, "regulator-settling-time-us", &pval); in of_get_regulation_constraints()
153 constraints->settling_time = pval; in of_get_regulation_constraints()
155 ret = of_property_read_u32(np, "regulator-settling-time-up-us", &pval); in of_get_regulation_constraints()
157 constraints->settling_time_up = pval; in of_get_regulation_constraints()
158 if (constraints->settling_time_up && constraints->settling_time) { in of_get_regulation_constraints()
159 …pr_warn("%pOFn: ambiguous configuration for settling time, ignoring 'regulator-settling-time-up-us… in of_get_regulation_constraints()
161 constraints->settling_time_up = 0; in of_get_regulation_constraints()
164 ret = of_property_read_u32(np, "regulator-settling-time-down-us", in of_get_regulation_constraints()
167 constraints->settling_time_down = pval; in of_get_regulation_constraints()
168 if (constraints->settling_time_down && constraints->settling_time) { in of_get_regulation_constraints()
169 …n("%pOFn: ambiguous configuration for settling time, ignoring 'regulator-settling-time-down-us'\n", in of_get_regulation_constraints()
171 constraints->settling_time_down = 0; in of_get_regulation_constraints()
174 ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval); in of_get_regulation_constraints()
176 constraints->enable_time = pval; in of_get_regulation_constraints()
178 ret = of_property_read_u32(np, "regulator-uv-survival-time-ms", &pval); in of_get_regulation_constraints()
180 constraints->uv_less_critical_window_ms = pval; in of_get_regulation_constraints()
182 constraints->uv_less_critical_window_ms = in of_get_regulation_constraints()
185 constraints->soft_start = of_property_read_bool(np, in of_get_regulation_constraints()
186 "regulator-soft-start"); in of_get_regulation_constraints()
187 ret = of_property_read_u32(np, "regulator-active-discharge", &pval); in of_get_regulation_constraints()
189 constraints->active_discharge = in of_get_regulation_constraints()
194 if (!of_property_read_u32(np, "regulator-initial-mode", &pval)) { in of_get_regulation_constraints()
195 if (desc && desc->of_map_mode) { in of_get_regulation_constraints()
196 mode = desc->of_map_mode(pval); in of_get_regulation_constraints()
200 constraints->initial_mode = mode; in of_get_regulation_constraints()
207 len = of_property_count_elems_of_size(np, "regulator-allowed-modes", in of_get_regulation_constraints()
210 if (desc && desc->of_map_mode) { in of_get_regulation_constraints()
213 "regulator-allowed-modes", i, &pval); in of_get_regulation_constraints()
219 mode = desc->of_map_mode(pval); in of_get_regulation_constraints()
221 pr_err("%pOFn: invalid regulator-allowed-modes element %u\n", in of_get_regulation_constraints()
224 constraints->valid_modes_mask |= mode; in of_get_regulation_constraints()
226 if (constraints->valid_modes_mask) in of_get_regulation_constraints()
227 constraints->valid_ops_mask in of_get_regulation_constraints()
234 if (!of_property_read_u32(np, "regulator-system-load", &pval)) in of_get_regulation_constraints()
235 constraints->system_load = pval; in of_get_regulation_constraints()
238 constraints->max_spread = devm_kzalloc(dev, in of_get_regulation_constraints()
239 sizeof(*constraints->max_spread) * n_phandles, in of_get_regulation_constraints()
242 if (!constraints->max_spread) in of_get_regulation_constraints()
243 return -ENOMEM; in of_get_regulation_constraints()
245 of_property_read_u32_array(np, "regulator-coupled-max-spread", in of_get_regulation_constraints()
246 constraints->max_spread, n_phandles); in of_get_regulation_constraints()
249 if (!of_property_read_u32(np, "regulator-max-step-microvolt", in of_get_regulation_constraints()
251 constraints->max_uV_step = pval; in of_get_regulation_constraints()
253 constraints->over_current_protection = of_property_read_bool(np, in of_get_regulation_constraints()
254 "regulator-over-current-protection"); in of_get_regulation_constraints()
261 suspend_state = &constraints->state_mem; in of_get_regulation_constraints()
264 suspend_state = &constraints->state_disk; in of_get_regulation_constraints()
267 suspend_state = &constraints->state_standby; in of_get_regulation_constraints()
283 if (!of_property_read_u32(suspend_np, "regulator-mode", in of_get_regulation_constraints()
285 if (desc && desc->of_map_mode) { in of_get_regulation_constraints()
286 mode = desc->of_map_mode(pval); in of_get_regulation_constraints()
291 suspend_state->mode = mode; in of_get_regulation_constraints()
299 "regulator-on-in-suspend")) in of_get_regulation_constraints()
300 suspend_state->enabled = ENABLE_IN_SUSPEND; in of_get_regulation_constraints()
302 "regulator-off-in-suspend")) in of_get_regulation_constraints()
303 suspend_state->enabled = DISABLE_IN_SUSPEND; in of_get_regulation_constraints()
306 "regulator-suspend-min-microvolt", &pval)) in of_get_regulation_constraints()
307 suspend_state->min_uV = pval; in of_get_regulation_constraints()
310 "regulator-suspend-max-microvolt", &pval)) in of_get_regulation_constraints()
311 suspend_state->max_uV = pval; in of_get_regulation_constraints()
314 "regulator-suspend-microvolt", &pval)) in of_get_regulation_constraints()
315 suspend_state->uV = pval; in of_get_regulation_constraints()
317 suspend_state->uV = suspend_state->min_uV; in of_get_regulation_constraints()
320 "regulator-changeable-in-suspend")) in of_get_regulation_constraints()
321 suspend_state->changeable = true; in of_get_regulation_constraints()
324 constraints->initial_state = PM_SUSPEND_MEM; in of_get_regulation_constraints()
335 * of_get_regulator_init_data - extract regulator_init_data structure info
337 * @node: regulator device node
341 * tree node, returns a pointer to the populated structure or NULL if memory
345 struct device_node *node, in of_get_regulator_init_data() argument
350 if (!node) in of_get_regulator_init_data()
357 if (of_get_regulation_constraints(dev, node, &init_data, desc)) in of_get_regulator_init_data()
374 for (i = 0; i < devm_matches->num_matches; i++) in devm_of_regulator_put_matches()
375 of_node_put(devm_matches->matches[i].of_node); in devm_of_regulator_put_matches()
379 * of_regulator_match - extract multiple regulator init data from device tree.
381 * @node: parent device node of the regulators
386 * parse regulator init data from the device tree. @node is expected to
387 * contain a set of child nodes, each providing the init data for one
388 * regulator. The data parsed from a child node will be matched to a regulator
389 * based on either the deprecated property regulator-compatible if present,
390 * or otherwise the child node's name. Note that the match table is modified
396 int of_regulator_match(struct device *dev, struct device_node *node, in of_regulator_match() argument
403 struct device_node *child; in of_regulator_match() local
406 if (!dev || !node) in of_regulator_match()
407 return -EINVAL; in of_regulator_match()
413 return -ENOMEM; in of_regulator_match()
415 devm_matches->matches = matches; in of_regulator_match()
416 devm_matches->num_matches = num_matches; in of_regulator_match()
422 match->init_data = NULL; in of_regulator_match()
423 match->of_node = NULL; in of_regulator_match()
426 for_each_child_of_node(node, child) { in of_regulator_match()
427 name = of_get_property(child, in of_regulator_match()
428 "regulator-compatible", NULL); in of_regulator_match()
430 name = child->name; in of_regulator_match()
433 if (match->of_node) in of_regulator_match()
436 if (strcmp(match->name, name)) in of_regulator_match()
439 match->init_data = in of_regulator_match()
440 of_get_regulator_init_data(dev, child, in of_regulator_match()
441 match->desc); in of_regulator_match()
442 if (!match->init_data) { in of_regulator_match()
445 child); in of_regulator_match()
446 of_node_put(child); in of_regulator_match()
447 return -EINVAL; in of_regulator_match()
449 match->of_node = of_node_get(child); in of_regulator_match()
463 struct device_node *search, *child; in regulator_of_get_init_node() local
466 if (!dev->of_node || !desc->of_match) in regulator_of_get_init_node()
469 if (desc->regulators_node) { in regulator_of_get_init_node()
470 search = of_get_child_by_name(dev->of_node, in regulator_of_get_init_node()
471 desc->regulators_node); in regulator_of_get_init_node()
473 search = of_node_get(dev->of_node); in regulator_of_get_init_node()
475 if (!strcmp(desc->of_match, search->name)) in regulator_of_get_init_node()
480 dev_dbg(dev, "Failed to find regulator container node '%s'\n", in regulator_of_get_init_node()
481 desc->regulators_node); in regulator_of_get_init_node()
485 for_each_available_child_of_node(search, child) { in regulator_of_get_init_node()
486 name = of_get_property(child, "regulator-compatible", NULL); in regulator_of_get_init_node()
488 if (!desc->of_match_full_name) in regulator_of_get_init_node()
489 name = child->name; in regulator_of_get_init_node()
491 name = child->full_name; in regulator_of_get_init_node()
494 if (!strcmp(desc->of_match, name)) { in regulator_of_get_init_node()
497 * 'of_node_get(child)' is already performed by the in regulator_of_get_init_node()
500 return child; in regulator_of_get_init_node()
512 struct device_node **node) in regulator_of_get_init_data() argument
514 struct device_node *child; in regulator_of_get_init_data() local
517 child = regulator_of_get_init_node(config->dev, desc); in regulator_of_get_init_data()
518 if (!child) in regulator_of_get_init_data()
521 init_data = of_get_regulator_init_data(dev, child, desc); in regulator_of_get_init_data()
523 dev_err(dev, "failed to parse DT for regulator %pOFn\n", child); in regulator_of_get_init_data()
527 if (desc->of_parse_cb) { in regulator_of_get_init_data()
530 ret = desc->of_parse_cb(child, desc, config); in regulator_of_get_init_data()
532 if (ret == -EPROBE_DEFER) { in regulator_of_get_init_data()
533 of_node_put(child); in regulator_of_get_init_data()
534 return ERR_PTR(-EPROBE_DEFER); in regulator_of_get_init_data()
538 child); in regulator_of_get_init_data()
543 *node = child; in regulator_of_get_init_data()
548 of_node_put(child); in regulator_of_get_init_data()
567 struct device_node *node = rdev->dev.of_node; in of_get_n_coupled() local
570 n_phandles = of_count_phandle_with_args(node, in of_get_n_coupled()
571 "regulator-coupled-with", in of_get_n_coupled()
577 /* Looks for "to_find" device_node in src's "regulator-coupled-with" property */
586 "regulator-coupled-with", in of_coupling_find_node()
591 "regulator-coupled-with", i); in of_coupling_find_node()
612 * of_check_coupling_data - Parse rdev's coupling properties and check data
617 * - rdev's max_spread is greater than 0
618 * - all coupled regulators have the same max_spread
619 * - all coupled regulators have the same number of regulator_dev phandles
620 * - all regulators are linked to each other
626 struct device_node *node = rdev->dev.of_node; in of_check_coupling_data() local
635 int max_spread = rdev->constraints->max_spread[i]; in of_check_coupling_data()
639 dev_err(&rdev->dev, "max_spread value invalid\n"); in of_check_coupling_data()
643 c_node = of_parse_phandle(node, in of_check_coupling_data()
644 "regulator-coupled-with", i); in of_check_coupling_data()
650 "regulator-coupled-with", in of_check_coupling_data()
654 dev_err(&rdev->dev, "number of coupled reg phandles mismatch\n"); in of_check_coupling_data()
659 if (!of_coupling_find_node(c_node, node, &index)) { in of_check_coupling_data()
660 dev_err(&rdev->dev, "missing 2-way linking for coupled regulators\n"); in of_check_coupling_data()
665 if (of_property_read_u32_index(c_node, "regulator-coupled-max-spread", in of_check_coupling_data()
672 dev_err(&rdev->dev, in of_check_coupling_data()
688 * of_parse_coupled_regulator() - Get regulator_dev pointer from rdev's property
690 * "regulator-coupled-with" property
699 struct device_node *node = rdev->dev.of_node; in of_parse_coupled_regulator() local
703 c_node = of_parse_phandle(node, "regulator-coupled-with", index); in of_parse_coupled_regulator()
715 * Check if name is a supply name according to the '*-supply' pattern
717 * return length of supply name without the -supply
724 /* string need to be at minimum len(x-supply) */ in is_supply_name()
727 for (i = strs - 6; i > 0; i--) { in is_supply_name()
728 /* find first '-' and check if right part is supply */ in is_supply_name()
729 if (name[i] != '-') in is_supply_name()
739 * of_regulator_bulk_get_all - get multiple regulator consumers
742 * @np: device node to search for consumers
764 * first pass: get numbers of xxx-supply in of_regulator_bulk_get_all()
769 i = is_supply_name(prop->name); in of_regulator_bulk_get_all()
776 memcpy(name, prop->name, i); in of_regulator_bulk_get_all()
780 ret = -EINVAL; in of_regulator_bulk_get_all()
796 return -ENOMEM; in of_regulator_bulk_get_all()
800 while (--n >= 0) in of_regulator_bulk_get_all()
801 regulator_put(consumers[n]->consumer); in of_regulator_bulk_get_all()