/* Maxim 8973 chip information */ struct max8973_chip { struct device *dev; struct regulator_desc desc; struct regmap *regmap; bool enable_external_control; struct gpio_desc *dvs_gpiod; int lru_index[MAX8973_MAX_VOUT_REG]; int curr_vout_val[MAX8973_MAX_VOUT_REG]; int curr_vout_reg; int curr_gpio_val; struct regulator_ops ops; enum device_id id; int junction_temp_warning; int irq; struct thermal_zone_device *tz_device;
};
/* * find_voltage_set_register: Find new voltage configuration register (VOUT). * The finding of the new VOUT register will be based on the LRU mechanism. * Each VOUT register will have different voltage configured . This * Function will look if any of the VOUT register have requested voltage set * or not. * - If it is already there then it will make that register as most * recently used and return as found so that caller need not to set * the VOUT register but need to set the proper gpios to select this * VOUT register. * - If requested voltage is not found then it will use the least * recently mechanism to get new VOUT register for new configuration * and will return not_found so that caller need to set new VOUT * register and then gpios (both).
*/ staticbool find_voltage_set_register(struct max8973_chip *tps, int req_vsel, int *vout_reg, int *gpio_val)
{ int i; bool found = false; int new_vout_reg = tps->lru_index[MAX8973_MAX_VOUT_REG - 1]; int found_index = MAX8973_MAX_VOUT_REG - 1;
for (i = 0; i < MAX8973_MAX_VOUT_REG; ++i) { if (tps->curr_vout_val[tps->lru_index[i]] == req_vsel) {
new_vout_reg = tps->lru_index[i];
found_index = i;
found = true; goto update_lru_index;
}
}
update_lru_index: for (i = found_index; i > 0; i--)
tps->lru_index[i] = tps->lru_index[i - 1];
ret = regmap_read(max->regmap, max->curr_vout_reg, &data); if (ret < 0) {
dev_err(max->dev, "register %d read failed, err = %d\n",
max->curr_vout_reg, ret); return ret;
} return data & MAX8973_VOUT_MASK;
}
staticint max8973_dcdc_set_voltage_sel(struct regulator_dev *rdev, unsigned vsel)
{ struct max8973_chip *max = rdev_get_drvdata(rdev); int ret; bool found = false; int vout_reg = max->curr_vout_reg; int gpio_val = max->curr_gpio_val;
/* * If gpios are available to select the VOUT register then least * recently used register for new configuration.
*/ if (max->dvs_gpiod)
found = find_voltage_set_register(max, vsel,
&vout_reg, &gpio_val);
staticint max8973_set_current_limit(struct regulator_dev *rdev, int min_ua, int max_ua)
{ struct max8973_chip *max = rdev_get_drvdata(rdev); unsignedint val; int ret;
if (max_ua <= 9000000)
val = MAX8973_CKKADV_TRIP_75mV_PER_US; elseif (max_ua <= 12000000)
val = MAX8973_CKKADV_TRIP_150mV_PER_US; else
val = MAX8973_CKKADV_TRIP_DISABLE;
/* If external control is enabled then disable EN bit */ if (max->enable_external_control && (max->id == MAX8973)) {
ret = regmap_update_bits(max->regmap, MAX8973_VOUT,
MAX8973_VOUT_ENABLE, 0); if (ret < 0)
dev_err(max->dev, "register %d update failed, err = %d",
MAX8973_VOUT, ret);
} return ret;
}
staticint max8973_thermal_read_temp(struct thermal_zone_device *tz, int *temp)
{ struct max8973_chip *mchip = thermal_zone_device_priv(tz); unsignedint val; int ret;
ret = regmap_read(mchip->regmap, MAX8973_CHIPID1, &val); if (ret < 0) {
dev_err(mchip->dev, "Failed to read register CHIPID1, %d", ret); return ret;
}
/* * Initialize the lru index with vout_reg id * The index 0 will be most recently used and
* set with the max->curr_vout_reg */ for (i = 0; i < MAX8973_MAX_VOUT_REG; ++i)
max->lru_index[i] = i;
max->lru_index[0] = max->curr_vout_reg;
max->lru_index[max->curr_vout_reg] = 0;
} else { /* * If there is no DVS GPIO, the VOUT register * address is fixed.
*/
max->ops.set_voltage_sel = regulator_set_voltage_sel_regmap;
max->ops.get_voltage_sel = regulator_get_voltage_sel_regmap;
max->desc.vsel_reg = max->curr_vout_reg;
max->desc.vsel_mask = MAX8973_VOUT_MASK;
}
if (pdata_from_dt)
pdata->reg_init_data = of_get_regulator_init_data(&client->dev,
client->dev.of_node, &max->desc);
case MAX77621: /* * We do not let the core switch this regulator on/off, * we just leave it on.
*/
gpiod = devm_gpiod_get_optional(&client->dev, "maxim,enable",
GPIOD_OUT_HIGH); if (IS_ERR(gpiod)) return PTR_ERR(gpiod); if (gpiod)
max->enable_external_control = true;
/* * Register the regulators * Turn the GPIO descriptor over to the regulator core for * lifecycle management if we pass an ena_gpiod.
*/ if (config.ena_gpiod)
devm_gpiod_unhinge(&client->dev, config.ena_gpiod);
rdev = devm_regulator_register(&client->dev, &max->desc, &config); if (IS_ERR(rdev)) {
ret = PTR_ERR(rdev);
dev_err(max->dev, "regulator register failed, err %d\n", ret); return ret;
}
MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
MODULE_DESCRIPTION("MAX8973 voltage regulator driver");
MODULE_LICENSE("GPL v2");
Messung V0.5 in Prozent
¤ 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.0.17Bemerkung:
(vorverarbeitet am 2026-04-26)
¤
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.