int axp221_set_eldo(int eldo_num, unsigned int mvolt) { int ret; u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100); u8 addr, bits; switch (eldo_num) { case 3: addr = AXP221_ELDO3_CTRL; bits = AXP221_OUTPUT_CTRL2_ELDO3_EN; break; case 2: addr = AXP221_ELDO2_CTRL; bits = AXP221_OUTPUT_CTRL2_ELDO2_EN; break; case 1: addr = AXP221_ELDO1_CTRL; bits = AXP221_OUTPUT_CTRL2_ELDO1_EN; break; default: return -EINVAL; } if (mvolt == 0) return axp221_clrbits(AXP221_OUTPUT_CTRL2, bits); ret = pmic_bus_write(addr, cfg); if (ret) return ret; return axp221_setbits(AXP221_OUTPUT_CTRL2, bits); }
int axp_set_dcdc4(unsigned int mvolt) { int ret; u8 cfg = axp221_mvolt_to_cfg(mvolt, 600, 1540, 20); if (mvolt == 0) return pmic_bus_clrbits(AXP221_OUTPUT_CTRL1, AXP221_OUTPUT_CTRL1_DCDC4_EN); ret = pmic_bus_write(AXP221_DCDC4_CTRL, cfg); if (ret) return ret; return pmic_bus_setbits(AXP221_OUTPUT_CTRL1, AXP221_OUTPUT_CTRL1_DCDC4_EN); }
int axp_set_aldo3(unsigned int mvolt) { int ret; u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100); if (mvolt == 0) return pmic_bus_clrbits(AXP221_OUTPUT_CTRL3, AXP221_OUTPUT_CTRL3_ALDO3_EN); ret = pmic_bus_write(AXP221_ALDO3_CTRL, cfg); if (ret) return ret; return pmic_bus_setbits(AXP221_OUTPUT_CTRL3, AXP221_OUTPUT_CTRL3_ALDO3_EN); }
int axp221_set_dldo4(unsigned int mvolt) { int ret; u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100); if (mvolt == 0) return axp221_clrbits(AXP221_OUTPUT_CTRL2, AXP221_OUTPUT_CTRL2_DLDO4_EN); ret = pmic_bus_write(AXP221_DLDO4_CTRL, cfg); if (ret) return ret; return axp221_setbits(AXP221_OUTPUT_CTRL2, AXP221_OUTPUT_CTRL2_DLDO4_EN); }
int axp221_set_dcdc5(unsigned int mvolt) { int ret; u8 cfg = axp221_mvolt_to_cfg(mvolt, 1000, 2550, 50); if (mvolt == 0) return axp221_clrbits(AXP221_OUTPUT_CTRL1, AXP221_OUTPUT_CTRL1_DCDC5_EN); ret = pmic_bus_write(AXP221_DCDC5_CTRL, cfg); if (ret) return ret; return axp221_setbits(AXP221_OUTPUT_CTRL1, AXP221_OUTPUT_CTRL1_DCDC5_EN); }
int axp_set_eldo(int eldo_num, unsigned int mvolt) { int ret; u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100); if (eldo_num < 1 || eldo_num > 3) return -EINVAL; if (mvolt == 0) return pmic_bus_clrbits(AXP221_OUTPUT_CTRL2, AXP221_OUTPUT_CTRL2_ELDO1_EN << (eldo_num - 1)); ret = pmic_bus_write(AXP221_ELDO1_CTRL + (eldo_num - 1), cfg); if (ret) return ret; return pmic_bus_setbits(AXP221_OUTPUT_CTRL2, AXP221_OUTPUT_CTRL2_ELDO1_EN << (eldo_num - 1)); }
int axp_set_dcdc1(unsigned int mvolt) { int ret; u8 cfg = axp221_mvolt_to_cfg(mvolt, 1600, 3400, 100); if (mvolt == 0) return pmic_bus_clrbits(AXP221_OUTPUT_CTRL1, AXP221_OUTPUT_CTRL1_DCDC1_EN); ret = pmic_bus_write(AXP221_DCDC1_CTRL, cfg); if (ret) return ret; ret = pmic_bus_setbits(AXP221_OUTPUT_CTRL2, AXP221_OUTPUT_CTRL2_DCDC1SW_EN); if (ret) return ret; return pmic_bus_setbits(AXP221_OUTPUT_CTRL1, AXP221_OUTPUT_CTRL1_DCDC1_EN); }