Exemplo n.º 1
0
static int pm800_set_voltage(struct regulator_dev *rdev,
			     int min_uv, int max_uv, unsigned *selector)
{
	struct pm800_regulator_info *info = rdev_get_drvdata(rdev);
	int ret, old_selector = -1, best_val = 0;

	if (!info)
		return -EINVAL;

	if (info->desc.id == PM800_ID_VOUTSW)
		return 0;

	ret = regulator_map_voltage_iterate(rdev, min_uv, max_uv);
	if (ret >= 0) {
		best_val = rdev->desc->ops->list_voltage(rdev, ret);
		if (min_uv <= best_val && max_uv >= best_val) {
			*selector = ret;
			if (old_selector == *selector)
				ret = 0;
			else
				ret = regulator_set_voltage_sel_regmap(rdev, ret);
		} else {
			ret = -EINVAL;
		}
	} else {
		ret = -EINVAL;
	}

	return ret;
}
Exemplo n.º 2
0
static int tps80031_ldo_map_voltage(struct regulator_dev *rdev,
				    int min_uV, int max_uV)
{
	struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
	struct device *parent = to_tps80031_dev(rdev);

	/* Check for valid setting for TPS80031 or TPS80032-ES1.0 */
	if ((ri->rinfo->desc.id == TPS80031_REGULATOR_LDO2) &&
			(ri->device_flags & TRACK_MODE_ENABLE)) {
		if (((tps80031_get_chip_info(parent) == TPS80031) ||
			((tps80031_get_chip_info(parent) == TPS80032) &&
			(tps80031_get_pmu_version(parent) == 0x0)))) {
			return regulator_map_voltage_iterate(rdev, min_uV,
							     max_uV);
		}
	}

	return regulator_map_voltage_linear(rdev, min_uV, max_uV);
}