struct device_node *node __free(device_node) =
of_get_child_by_name(chip->dev->of_node, "regulators"); if (!node) {
dev_err(chip->dev, "regulators node not found\n"); return -ENODEV;
}
matches = devm_kcalloc(chip->dev, chip->info->num_outputs, sizeof(*matches), GFP_KERNEL); if (!matches) return -ENOMEM;
for (i = 0; i < chip->info->num_outputs; ++i)
matches[i].name = max20086_output_names[i];
ret = of_regulator_match(chip->dev, node, matches,
chip->info->num_outputs); if (ret < 0) {
dev_err(chip->dev, "Failed to match regulators\n"); return -EINVAL;
}
*boot_on = false;
for (i = 0; i < chip->info->num_outputs; i++) { struct max20086_regulator *reg = &chip->regulators[i];
chip->regmap = devm_regmap_init_i2c(i2c, &max20086_regmap_config); if (IS_ERR(chip->regmap)) {
ret = PTR_ERR(chip->regmap);
dev_err(chip->dev, "Failed to allocate register map: %d\n", ret); return ret;
}
ret = max20086_parse_regulators_dt(chip, &boot_on); if (ret < 0) return ret;
ret = max20086_detect(chip); if (ret < 0) return ret;
/* Until IRQ support is added, just disable all interrupts. */
ret = regmap_update_bits(chip->regmap, MAX20086_REG_MASK,
MAX20086_INT_DISABLE_ALL,
MAX20086_INT_DISABLE_ALL); if (ret < 0) {
dev_err(chip->dev, "Failed to disable interrupts: %d\n", ret); return ret;
}
/* * Get the enable GPIO. If any of the outputs is marked as being * enabled at boot, request the GPIO with an initial high state to * avoid disabling outputs that may have been turned on by the boot * loader. Otherwise, request it with a low state to enter lower-power * shutdown.
*/
flags = boot_on ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
chip->ena_gpiod = devm_gpiod_get_optional(chip->dev, "enable", flags); if (IS_ERR(chip->ena_gpiod)) {
ret = PTR_ERR(chip->ena_gpiod);
dev_err(chip->dev, "Failed to get enable GPIO: %d\n", ret); return ret;
}
ret = max20086_regulators_register(chip); if (ret < 0) {
dev_err(chip->dev, "Failed to register regulators: %d\n", ret); return ret;
}
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.