static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) { struct twlreg_info *info = rdev_get_drvdata(rdev); int mV = info->table[index]; return IS_UNSUP(mV) ? 0 : (LDO_MV(mV) * 1000); }
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){ printk("%s : %s uV=%d\n",__func__,rdev->desc->name,uV); return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, vsel); } } return -EDOM; }
static int twl4030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV, unsigned *selector) { 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; if (min_uV <= uV && uV <= max_uV) { *selector = vsel; return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, vsel); } } return -EDOM; }
static int audio_power_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) { struct sprd_audio_power_info *info = rdev_get_drvdata(rdev); int vsel; BUG_ON(!info->v_table); for (vsel = 0; vsel < info->v_table_len; vsel++) { int mV = info->v_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) { sp_asoc_pr_dbg("%s: %dus\n", __func__, uV); sprd_power_u_bits(info, info->v_reg, info->v_mask << info->v_shift, vsel << info->v_shift); return vsel; } } return -EDOM; }
static int __init twl4030reg_init(void) { unsigned i, j; /* determine min/max voltage constraints, taking into account * whether set_voltage() will use the "unsupported" settings */ for (i = 0; i < ARRAY_SIZE(twl4030_regs); i++) { struct twlreg_info *info = twl4030_regs + i; const u16 *table; /* fixed-voltage regulators */ if (!info->table_len) continue; /* LDO regulators: */ for (j = 0, table = info->table; j < info->table_len; j++, table++) { u16 mV = *table; if (IS_UNSUP(mV)) continue; mV = LDO_MV(mV); if (info->min_mV == 0 || info->min_mV > mV) info->min_mV = mV; if (info->max_mV < mV) info->max_mV = mV; } } return platform_driver_register(&twl4030reg_driver); }
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); }
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; }