/* Common helper routine to turn on all WCNSS vregs e.g. IRIS, Riva */ static int wcnss_vregs_on(struct device *dev, struct vregs_info regulators[], uint size) { int i, rc = 0; for (i = 0; i < size; i++) { /* Get regulator source */ regulators[i].regulator = regulator_get(dev, regulators[i].name); if (IS_ERR(regulators[i].regulator)) { rc = PTR_ERR(regulators[i].regulator); pr_err("regulator get of %s failed (%d)\n", regulators[i].name, rc); goto fail; } regulators[i].state |= VREG_GET_REGULATOR_MASK; /* Set voltage to nominal. Exclude swtiches e.g. LVS */ if (regulators[i].nominal_min || regulators[i].max_voltage) { rc = regulator_set_voltage(regulators[i].regulator, regulators[i].nominal_min, regulators[i].max_voltage); if (rc) { pr_err("regulator_set_voltage(%s) failed (%d)\n", regulators[i].name, rc); goto fail; } regulators[i].state |= VREG_SET_VOLTAGE_MASK; } /* Vote for PWM/PFM mode if needed */ if (regulators[i].uA_load) { rc = regulator_set_optimum_mode(regulators[i].regulator, regulators[i].uA_load); if (rc < 0) { pr_err("regulator_set_optimum_mode(%s) failed (%d)\n", regulators[i].name, rc); goto fail; } regulators[i].state |= VREG_OPTIMUM_MODE_MASK; } /* Enable the regulator */ rc = regulator_enable(regulators[i].regulator); if (rc) { pr_err("vreg %s enable failed (%d)\n", regulators[i].name, rc); goto fail; } regulators[i].state |= VREG_ENABLE_MASK; } return rc; fail: wcnss_vregs_off(regulators, size); return rc; }
static void wcnss_riva_vregs_off(void) { wcnss_vregs_off(riva_vregs, ARRAY_SIZE(riva_vregs)); }
static void wcnss_iris_vregs_off(void) { wcnss_vregs_off(iris_vregs, ARRAY_SIZE(iris_vregs)); }