Lines Matching +full:oc +full:- +full:delay +full:- +full:us

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 if (!of_property_read_u32(np, "regulator-power-budget-milliwatt", &pval)) in of_get_regulation_constraints()
129 constraints->pw_budget_mW = pval; in of_get_regulation_constraints()
131 constraints->boot_on = of_property_read_bool(np, "regulator-boot-on"); in of_get_regulation_constraints()
132 constraints->always_on = of_property_read_bool(np, "regulator-always-on"); in of_get_regulation_constraints()
133 if (!constraints->always_on) /* status change should be possible. */ in of_get_regulation_constraints()
134 constraints->valid_ops_mask |= REGULATOR_CHANGE_STATUS; in of_get_regulation_constraints()
136 constraints->pull_down = of_property_read_bool(np, "regulator-pull-down"); in of_get_regulation_constraints()
137 constraints->system_critical = of_property_read_bool(np, in of_get_regulation_constraints()
138 "system-critical-regulator"); in of_get_regulation_constraints()
140 if (of_property_read_bool(np, "regulator-allow-bypass")) in of_get_regulation_constraints()
141 constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS; in of_get_regulation_constraints()
143 if (of_property_read_bool(np, "regulator-allow-set-load")) in of_get_regulation_constraints()
144 constraints->valid_ops_mask |= REGULATOR_CHANGE_DRMS; in of_get_regulation_constraints()
146 ret = of_property_read_u32(np, "regulator-ramp-delay", &pval); in of_get_regulation_constraints()
149 constraints->ramp_delay = pval; in of_get_regulation_constraints()
151 constraints->ramp_disable = true; in of_get_regulation_constraints()
154 ret = of_property_read_u32(np, "regulator-settling-time-us", &pval); in of_get_regulation_constraints()
156 constraints->settling_time = pval; in of_get_regulation_constraints()
158 ret = of_property_read_u32(np, "regulator-settling-time-up-us", &pval); in of_get_regulation_constraints()
160 constraints->settling_time_up = pval; in of_get_regulation_constraints()
161 if (constraints->settling_time_up && constraints->settling_time) { in of_get_regulation_constraints()
162 …arn("%pOFn: ambiguous configuration for settling time, ignoring 'regulator-settling-time-up-us'\n", in of_get_regulation_constraints()
164 constraints->settling_time_up = 0; in of_get_regulation_constraints()
167 ret = of_property_read_u32(np, "regulator-settling-time-down-us", in of_get_regulation_constraints()
170 constraints->settling_time_down = pval; in of_get_regulation_constraints()
171 if (constraints->settling_time_down && constraints->settling_time) { in of_get_regulation_constraints()
172 …n("%pOFn: ambiguous configuration for settling time, ignoring 'regulator-settling-time-down-us'\n", in of_get_regulation_constraints()
174 constraints->settling_time_down = 0; in of_get_regulation_constraints()
177 ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval); in of_get_regulation_constraints()
179 constraints->enable_time = pval; in of_get_regulation_constraints()
181 ret = of_property_read_u32(np, "regulator-uv-less-critical-window-ms", &pval); in of_get_regulation_constraints()
183 constraints->uv_less_critical_window_ms = pval; in of_get_regulation_constraints()
185 constraints->uv_less_critical_window_ms = in of_get_regulation_constraints()
188 constraints->soft_start = of_property_read_bool(np, in of_get_regulation_constraints()
189 "regulator-soft-start"); in of_get_regulation_constraints()
190 ret = of_property_read_u32(np, "regulator-active-discharge", &pval); in of_get_regulation_constraints()
192 constraints->active_discharge = in of_get_regulation_constraints()
197 if (!of_property_read_u32(np, "regulator-initial-mode", &pval)) { in of_get_regulation_constraints()
198 if (desc && desc->of_map_mode) { in of_get_regulation_constraints()
199 mode = desc->of_map_mode(pval); in of_get_regulation_constraints()
203 constraints->initial_mode = mode; in of_get_regulation_constraints()
210 len = of_property_count_elems_of_size(np, "regulator-allowed-modes", in of_get_regulation_constraints()
213 if (desc && desc->of_map_mode) { in of_get_regulation_constraints()
216 "regulator-allowed-modes", i, &pval); in of_get_regulation_constraints()
222 mode = desc->of_map_mode(pval); in of_get_regulation_constraints()
224 pr_err("%pOFn: invalid regulator-allowed-modes element %u\n", in of_get_regulation_constraints()
227 constraints->valid_modes_mask |= mode; in of_get_regulation_constraints()
229 if (constraints->valid_modes_mask) in of_get_regulation_constraints()
230 constraints->valid_ops_mask in of_get_regulation_constraints()
237 if (!of_property_read_u32(np, "regulator-system-load", &pval)) in of_get_regulation_constraints()
238 constraints->system_load = pval; in of_get_regulation_constraints()
241 constraints->max_spread = devm_kzalloc(dev, in of_get_regulation_constraints()
242 sizeof(*constraints->max_spread) * n_phandles, in of_get_regulation_constraints()
245 if (!constraints->max_spread) in of_get_regulation_constraints()
246 return -ENOMEM; in of_get_regulation_constraints()
248 of_property_read_u32_array(np, "regulator-coupled-max-spread", in of_get_regulation_constraints()
249 constraints->max_spread, n_phandles); in of_get_regulation_constraints()
252 if (!of_property_read_u32(np, "regulator-max-step-microvolt", in of_get_regulation_constraints()
254 constraints->max_uV_step = pval; in of_get_regulation_constraints()
256 constraints->over_current_protection = of_property_read_bool(np, in of_get_regulation_constraints()
257 "regulator-over-current-protection"); in of_get_regulation_constraints()
264 suspend_state = &constraints->state_mem; in of_get_regulation_constraints()
267 suspend_state = &constraints->state_disk; in of_get_regulation_constraints()
270 suspend_state = &constraints->state_standby; in of_get_regulation_constraints()
286 if (!of_property_read_u32(suspend_np, "regulator-mode", in of_get_regulation_constraints()
288 if (desc && desc->of_map_mode) { in of_get_regulation_constraints()
289 mode = desc->of_map_mode(pval); in of_get_regulation_constraints()
294 suspend_state->mode = mode; in of_get_regulation_constraints()
302 "regulator-on-in-suspend")) in of_get_regulation_constraints()
303 suspend_state->enabled = ENABLE_IN_SUSPEND; in of_get_regulation_constraints()
305 "regulator-off-in-suspend")) in of_get_regulation_constraints()
306 suspend_state->enabled = DISABLE_IN_SUSPEND; in of_get_regulation_constraints()
309 "regulator-suspend-min-microvolt", &pval)) in of_get_regulation_constraints()
310 suspend_state->min_uV = pval; in of_get_regulation_constraints()
313 "regulator-suspend-max-microvolt", &pval)) in of_get_regulation_constraints()
314 suspend_state->max_uV = pval; in of_get_regulation_constraints()
317 "regulator-suspend-microvolt", &pval)) in of_get_regulation_constraints()
318 suspend_state->uV = pval; in of_get_regulation_constraints()
320 suspend_state->uV = suspend_state->min_uV; in of_get_regulation_constraints()
323 "regulator-changeable-in-suspend")) in of_get_regulation_constraints()
324 suspend_state->changeable = true; in of_get_regulation_constraints()
327 constraints->initial_state = PM_SUSPEND_MEM; in of_get_regulation_constraints()
338 * of_get_regulator_init_data - extract regulator_init_data structure info
379 for (i = 0; i < devm_matches->num_matches; i++) in devm_of_regulator_put_matches()
380 of_node_put(devm_matches->matches[i].of_node); in devm_of_regulator_put_matches()
384 * of_regulator_match - extract multiple regulator init data from device tree.
394 * based on either the deprecated property regulator-compatible if present,
412 return -EINVAL; in of_regulator_match()
418 return -ENOMEM; in of_regulator_match()
420 devm_matches->matches = matches; in of_regulator_match()
421 devm_matches->num_matches = num_matches; in of_regulator_match()
427 match->init_data = NULL; in of_regulator_match()
428 match->of_node = NULL; in of_regulator_match()
433 "regulator-compatible", NULL); in of_regulator_match()
435 name = child->name; in of_regulator_match()
438 if (match->of_node) in of_regulator_match()
441 if (strcmp(match->name, name)) in of_regulator_match()
444 match->init_data = in of_regulator_match()
446 match->desc); in of_regulator_match()
447 if (!match->init_data) { in of_regulator_match()
454 match->of_node = of_node_get(child); in of_regulator_match()
466 match->init_data = NULL; in of_regulator_match()
467 if (match->of_node) { in of_regulator_match()
468 of_node_put(match->of_node); in of_regulator_match()
469 match->of_node = NULL; in of_regulator_match()
472 return -EINVAL; in of_regulator_match()
483 if (!dev->of_node || !desc->of_match) in regulator_of_get_init_node()
486 if (desc->regulators_node) { in regulator_of_get_init_node()
487 search = of_get_child_by_name(dev->of_node, in regulator_of_get_init_node()
488 desc->regulators_node); in regulator_of_get_init_node()
490 search = of_node_get(dev->of_node); in regulator_of_get_init_node()
492 if (!strcmp(desc->of_match, search->name)) in regulator_of_get_init_node()
498 desc->regulators_node); in regulator_of_get_init_node()
503 name = of_get_property(child, "regulator-compatible", NULL); in regulator_of_get_init_node()
505 if (!desc->of_match_full_name) in regulator_of_get_init_node()
506 name = child->name; in regulator_of_get_init_node()
508 name = child->full_name; in regulator_of_get_init_node()
511 if (!strcmp(desc->of_match, name)) { in regulator_of_get_init_node()
534 child = regulator_of_get_init_node(config->dev, desc); in regulator_of_get_init_data()
544 if (desc->of_parse_cb) { in regulator_of_get_init_data()
547 ret = desc->of_parse_cb(child, desc, config); in regulator_of_get_init_data()
549 if (ret == -EPROBE_DEFER) { in regulator_of_get_init_data()
551 return ERR_PTR(-EPROBE_DEFER); in regulator_of_get_init_data()
571 * of_get_child_regulator - get a child regulator device node
574 * @prop_name: Combination regulator supply name and "-supply"
605 * of_get_regulator - get a regulator device node based on supply name
621 dev_dbg(dev, "Looking up %s-supply from device node %pOF\n", supply, node); in of_get_regulator()
623 snprintf(prop_name, 64, "%s-supply", supply); in of_get_regulator()
628 regnode = of_get_child_regulator(dev->of_node, prop_name); in of_get_regulator()
632 dev_dbg(dev, "Looking up %s property in node %pOF failed\n", prop_name, dev->of_node); in of_get_regulator()
646 * of_regulator_dev_lookup - lookup a regulator device with device tree only
660 * * -%ENODEV if lookup fails permanently.
661 * * -%EPROBE_DEFER if lookup could succeed in the future.
680 return ERR_PTR(-EPROBE_DEFER); in of_regulator_dev_lookup()
683 return ERR_PTR(-ENODEV); in of_regulator_dev_lookup()
701 * of_regulator_get_optional - get optional regulator via device tree lookup
727 struct device_node *node = rdev->dev.of_node; in of_get_n_coupled()
731 "regulator-coupled-with", in of_get_n_coupled()
737 /* Looks for "to_find" device_node in src's "regulator-coupled-with" property */
746 "regulator-coupled-with", in of_coupling_find_node()
751 "regulator-coupled-with", i); in of_coupling_find_node()
772 * of_check_coupling_data - Parse rdev's coupling properties and check data
777 * - rdev's max_spread is greater than 0
778 * - all coupled regulators have the same max_spread
779 * - all coupled regulators have the same number of regulator_dev phandles
780 * - all regulators are linked to each other
786 struct device_node *node = rdev->dev.of_node; in of_check_coupling_data()
795 int max_spread = rdev->constraints->max_spread[i]; in of_check_coupling_data()
799 dev_err(&rdev->dev, "max_spread value invalid\n"); in of_check_coupling_data()
804 "regulator-coupled-with", i); in of_check_coupling_data()
810 "regulator-coupled-with", in of_check_coupling_data()
814 dev_err(&rdev->dev, "number of coupled reg phandles mismatch\n"); in of_check_coupling_data()
820 dev_err(&rdev->dev, "missing 2-way linking for coupled regulators\n"); in of_check_coupling_data()
825 if (of_property_read_u32_index(c_node, "regulator-coupled-max-spread", in of_check_coupling_data()
832 dev_err(&rdev->dev, in of_check_coupling_data()
848 * of_parse_coupled_regulator() - Get regulator_dev pointer from rdev's property
850 * "regulator-coupled-with" property
859 struct device_node *node = rdev->dev.of_node; in of_parse_coupled_regulator()
863 c_node = of_parse_phandle(node, "regulator-coupled-with", index); in of_parse_coupled_regulator()
875 * Check if name is a supply name according to the '*-supply' pattern
877 * return length of supply name without the -supply
884 /* string need to be at minimum len(x-supply) */ in is_supply_name()
887 for (i = strs - 6; i > 0; i--) { in is_supply_name()
888 /* find first '-' and check if right part is supply */ in is_supply_name()
889 if (name[i] != '-') in is_supply_name()
899 * of_regulator_bulk_get_all - get multiple regulator consumers
925 * first pass: get numbers of xxx-supply in of_regulator_bulk_get_all()
930 i = is_supply_name(prop->name); in of_regulator_bulk_get_all()
937 memcpy(name, prop->name, i); in of_regulator_bulk_get_all()
959 return -ENOMEM; in of_regulator_bulk_get_all()
963 while (--n >= 0) in of_regulator_bulk_get_all()