// SPDX-License-Identifier: GPL-2.0+ // // max77693.c - Regulator driver for the Maxim 77693 and 77843 // // Copyright (C) 2013-2015 Samsung Electronics // Jonghwa Lee <jonghwa3.lee@samsung.com> // Krzysztof Kozlowski <krzk@kernel.org> // // This driver is based on max77686.c
/* * ID for MAX77843 regulators. * There is no need for such for MAX77693.
*/ enum max77843_regulator_type {
MAX77843_SAFEOUT1 = 0,
MAX77843_SAFEOUT2,
MAX77843_CHARGER,
/* * MAX77693 CHARGER regulator - Min : 20mA, Max : 2580mA, step : 20mA * 0x00, 0x01, 0x2, 0x03 = 60 mA * 0x04 ~ 0x7E = (60 + (X - 3) * 20) mA * Actually for MAX77693 the driver manipulates the maximum input current, * not the fast charge current (output). This should be fixed. * * On MAX77843 the calculation formula is the same (except values). * Fortunately it properly manipulates the fast charge current.
*/ staticint max77693_chg_get_current_limit(struct regulator_dev *rdev)
{ conststruct chg_reg_data *reg_data = rdev_get_drvdata(rdev); unsignedint chg_min_uA = rdev->constraints->min_uA; unsignedint chg_max_uA = rdev->constraints->max_uA; unsignedint reg, sel; unsignedint val; int ret;
ret = regmap_read(rdev->regmap, reg_data->linear_reg, ®); if (ret < 0) return ret;
sel = reg & reg_data->linear_mask;
/* the first four codes for charger current are all 60mA */ if (sel <= reg_data->min_sel)
sel = 0; else
sel -= reg_data->min_sel;
val = chg_min_uA + reg_data->uA_step * sel; if (val > chg_max_uA) return -EINVAL;
return val;
}
staticint max77693_chg_set_current_limit(struct regulator_dev *rdev, int min_uA, int max_uA)
{ conststruct chg_reg_data *reg_data = rdev_get_drvdata(rdev); unsignedint chg_min_uA = rdev->constraints->min_uA; int sel = 0;
while (chg_min_uA + reg_data->uA_step * sel < min_uA)
sel++;
if (chg_min_uA + reg_data->uA_step * sel > max_uA) return -EINVAL;
/* the first four codes for charger current are all 60mA */
sel += reg_data->min_sel;
return regmap_write(rdev->regmap, reg_data->linear_reg, sel);
} /* end of CHARGER regulator ops */
/* Returns regmap suitable for given regulator on chosen device */ staticstruct regmap *max77693_get_regmap(enum max77693_types type, struct max77693_dev *max77693, int reg_id)
{ if (type == TYPE_MAX77693) return max77693->regmap;
/* Else: TYPE_MAX77843 */ switch (reg_id) { case MAX77843_SAFEOUT1: case MAX77843_SAFEOUT2: return max77693->regmap; case MAX77843_CHARGER: return max77693->regmap_chg; default: return max77693->regmap;
}
}
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.