static int twl4030ldo_get_voltage(struct regulator_dev *rdev)
{
	struct twlreg_info	*info = rdev_get_drvdata(rdev);
	int		vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER,
								VREG_VOLTAGE);

	if (vsel < 0)
		return vsel;

	vsel &= info->table_len - 1;
	return LDO_MV(info->table[vsel]) * 1000;
}
Ejemplo n.º 2
0
static int sprd_audio_power_get_voltage(struct regulator_dev *rdev)
{
    struct sprd_audio_power_info *info = rdev_get_drvdata(rdev);
    int vsel;

    sp_asoc_pr_dbg("%s Get Voltage\n", rdev->desc->name);

    if (!info->v_table) {
        return 0;
    }

    vsel = (sprd_power_read(info, info->v_reg) & info->v_mask)
           >> info->v_shift;
    return LDO_MV(info->v_table[vsel]) * 1000;
}
Ejemplo n.º 3
0
static int sprd_audio_power_list_voltage(struct regulator_dev *rdev,
        unsigned index)
{
    struct sprd_audio_power_info *info = rdev_get_drvdata(rdev);
    int mV;

    sp_asoc_pr_dbg("%s List Voltage\n", rdev->desc->name);

    if (!info->v_table) {
        return 0;
    }

    if (index >= info->v_table_len) {
        return 0;
    }

    mV = info->v_table[index];
    return IS_UNSUP(mV) ? 0 : (LDO_MV(mV) * 1000);
}
Ejemplo n.º 4
0
static int
twl4030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
{
	struct twlreg_info	*info = rdev_get_drvdata(rdev);
	int			vsel;

	for (vsel = 0; vsel < info->table_len; vsel++) {
		int mV = info->table[vsel];
		int uV;

		if (IS_UNSUP(mV))
			continue;
		uV = LDO_MV(mV) * 1000;

		/* use the first in-range value */
		if (min_uV <= uV && uV <= max_uV)
			return twl4030reg_write(info, VREG_DEDICATED, vsel);
	}

	return -EDOM;
}
static int
twl4030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
{
	struct twlreg_info	*info = rdev_get_drvdata(rdev);
	int			vsel;

	for (vsel = 0; vsel < info->table_len; vsel++) {
		int mV = info->table[vsel];
		int uV;

		if (IS_UNSUP(mV))
			continue;
		uV = LDO_MV(mV) * 1000;

		/* REVISIT for VAUX2, first match may not be best/lowest */

		/* use the first in-range value */
		if (min_uV <= uV && uV <= max_uV)
			return twlreg_write(info, TWL_MODULE_PM_RECEIVER,
							VREG_VOLTAGE, vsel);
	}

	return -EDOM;
}