if (!of_property_read_u32(np, "regulator-min-microvolt", &pval))
constraints->min_uV = pval;
if (!of_property_read_u32(np, "regulator-max-microvolt", &pval))
constraints->max_uV = pval;
/* Voltage change possible? */ if (constraints->min_uV != constraints->max_uV)
constraints->valid_ops_mask |= REGULATOR_CHANGE_VOLTAGE;
/* Do we have a voltage range, if so try to apply it? */ if (constraints->min_uV && constraints->max_uV)
constraints->apply_uV = true;
if (!of_property_read_u32(np, "regulator-microvolt-offset", &pval))
constraints->uV_offset = pval; if (!of_property_read_u32(np, "regulator-min-microamp", &pval))
constraints->min_uA = pval; if (!of_property_read_u32(np, "regulator-max-microamp", &pval))
constraints->max_uA = pval;
if (!of_property_read_u32(np, "regulator-input-current-limit-microamp",
&pval))
constraints->ilim_uA = pval;
/* Current change possible? */ if (constraints->min_uA != constraints->max_uA)
constraints->valid_ops_mask |= REGULATOR_CHANGE_CURRENT;
if (!of_property_read_u32(np, "regulator-power-budget-milliwatt", &pval))
constraints->pw_budget_mW = pval;
constraints->boot_on = of_property_read_bool(np, "regulator-boot-on");
constraints->always_on = of_property_read_bool(np, "regulator-always-on"); if (!constraints->always_on) /* status change should be possible. */
constraints->valid_ops_mask |= REGULATOR_CHANGE_STATUS;
for (i = 0; i < ARRAY_SIZE(regulator_states); i++) { switch (i) { case PM_SUSPEND_MEM:
suspend_state = &constraints->state_mem; break; case PM_SUSPEND_MAX:
suspend_state = &constraints->state_disk; break; case PM_SUSPEND_STANDBY:
suspend_state = &constraints->state_standby; break; case PM_SUSPEND_ON: case PM_SUSPEND_TO_IDLE: default: continue;
}
suspend_np = of_get_child_by_name(np, regulator_states[i]); if (!suspend_np) continue; if (!suspend_state) {
of_node_put(suspend_np); continue;
}
if (!of_property_read_u32(suspend_np, "regulator-mode",
&pval)) { if (desc && desc->of_map_mode) {
mode = desc->of_map_mode(pval); if (mode == REGULATOR_MODE_INVALID)
pr_err("%pOFn: invalid mode %u\n",
np, pval); else
suspend_state->mode = mode;
} else {
pr_warn("%pOFn: mapping for mode %d not defined\n",
np, pval);
}
}
if (!of_property_read_u32(suspend_np, "regulator-suspend-min-microvolt", &pval))
suspend_state->min_uV = pval;
if (!of_property_read_u32(suspend_np, "regulator-suspend-max-microvolt", &pval))
suspend_state->max_uV = pval;
if (!of_property_read_u32(suspend_np, "regulator-suspend-microvolt", &pval))
suspend_state->uV = pval; else/* otherwise use min_uV as default suspend voltage */
suspend_state->uV = suspend_state->min_uV;
if (of_property_read_bool(suspend_np, "regulator-changeable-in-suspend"))
suspend_state->changeable = true;
if (i == PM_SUSPEND_MEM)
constraints->initial_state = PM_SUSPEND_MEM;
for (i = 0; i < num_matches; i++) { struct of_regulator_match *match = &matches[i];
match->init_data = NULL;
match->of_node = NULL;
}
for_each_child_of_node(node, child) {
name = of_get_property(child, "regulator-compatible", NULL); if (!name)
name = child->name; for (i = 0; i < num_matches; i++) { struct of_regulator_match *match = &matches[i]; if (match->of_node) continue;
if (strcmp(match->name, name)) continue;
match->init_data =
of_get_regulator_init_data(dev, child,
match->desc); if (!match->init_data) {
dev_err(dev, "failed to parse DT for regulator %pOFn\n",
child);
of_node_put(child); goto err_put;
}
match->of_node = of_node_get(child);
count++; break;
}
}
return count;
err_put: for (i = 0; i < num_matches; i++) { struct of_regulator_match *match = &matches[i];
if (!strcmp(desc->of_match, search->name)) return search;
}
if (!search) {
dev_dbg(dev, "Failed to find regulator container node '%s'\n",
desc->regulators_node); return NULL;
}
for_each_available_child_of_node(search, child) {
name = of_get_property(child, "regulator-compatible", NULL); if (!name) { if (!desc->of_match_full_name)
name = child->name; else
name = child->full_name;
}
for (i = 0; i < n_phandles; i++) { struct device_node *tmp = of_parse_phandle(src, "regulator-coupled-with", i);
if (!tmp) break;
/* found */ if (tmp == to_find)
found = true;
of_node_put(tmp);
if (found) {
*index = i; break;
}
}
return found;
}
/** *of_check_coupling_data-Parserdev'scouplingpropertiesandcheckdata *consistency *@rdev:pointertoregulator_devwhosedataischecked * *Functionchecksifallthefollowingconditionsaremet: *-rdev'smax_spreadisgreaterthan0 *-allcoupledregulatorshavethesamemax_spread *-allcoupledregulatorshavethesamenumberofregulator_devphandles *-allregulatorsarelinkedtoeachother * *Return:Trueifallconditionsaremet;falseotherwise.
*/ bool of_check_coupling_data(struct regulator_dev *rdev)
{ struct device_node *node = rdev->dev.of_node; int n_phandles = of_get_n_coupled(rdev); struct device_node *c_node; int index; int i; bool ret = true;
/* iterate over rdev's phandles */ for (i = 0; i < n_phandles; i++) { int max_spread = rdev->constraints->max_spread[i]; int c_max_spread, c_n_phandles;
if (max_spread <= 0) {
dev_err(&rdev->dev, "max_spread value invalid\n"); returnfalse;
}
strs = strlen(name); /* string need to be at minimum len(x-supply) */ if (strs < 8) return0; for (i = strs - 6; i > 0; i--) { /* find first '-' and check if right part is supply */ if (name[i] != '-') continue; if (strcmp(name + i + 1, "supply") != 0) return0; return i;
} return0;
}
/** *of_regulator_bulk_get_all-getmultipleregulatorconsumers * *@dev:Devicetosupply *@np:devicenodetosearchforconsumers *@consumers:Configurationofconsumers;clientsarestoredhere. * *Thishelperfunctionallowsdriverstogetseveralregulator *consumersinoneoperation.Ifanyoftheregulatorscannotbe *acquiredthenanyregulatorsthatwereallocatedwillbefreed *beforereturningtothecaller,and@consumerswillnotbe *changed. * *Return:Numberofregulatorsonsuccess,oranegativeerrornumber *onfailure.
*/ int of_regulator_bulk_get_all(struct device *dev, struct device_node *np, struct regulator_bulk_data **consumers)
{ int num_consumers = 0; struct regulator *tmp; struct regulator_bulk_data *_consumers = NULL; struct property *prop; int i, n = 0, ret; char name[64];
/* *firstpass:getnumbersofxxx-supply *secondpass:fillconsumers
*/
restart:
for_each_property_of_node(np, prop) {
i = is_supply_name(prop->name); if (i == 0) continue; if (!_consumers) {
num_consumers++; continue;
} else {
memcpy(name, prop->name, i);
name[i] = '\0';
tmp = regulator_get(dev, name); if (IS_ERR(tmp)) {
ret = PTR_ERR(tmp); goto error;
}
_consumers[n].consumer = tmp;
n++; continue;
}
} if (_consumers) {
*consumers = _consumers; return num_consumers;
} if (num_consumers == 0) return0;
_consumers = kmalloc_array(num_consumers, sizeof(struct regulator_bulk_data),
GFP_KERNEL); if (!_consumers) return -ENOMEM; goto restart;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.