static int max17135_vcom_enable(struct regulator_dev *reg) { struct max17135 *max17135 = rdev_get_drvdata(reg); /* * Check to see if we need to set the VCOM voltage. * Should only be done one time. And, we can * only change vcom voltage if we have been enabled. */ if (!max17135->vcom_setup && max17135_is_power_good(max17135)) { max17135_vcom_set_voltage(reg, max17135->vcom_uV, max17135->vcom_uV, NULL); max17135->vcom_setup = true; } /* enable VCOM regulator output */ if (max17135->pass_num == 1) gpio_set_value(max17135->gpio_pmic_vcom_ctrl, 1); else { unsigned int reg_val; max17135_reg_read(REG_MAX17135_ENABLE, ®_val); reg_val &= ~BITFMASK(VCOM_ENABLE); reg_val |= BITFVAL(VCOM_ENABLE, 1); /* shift to correct bit */ max17135_reg_write(REG_MAX17135_ENABLE, reg_val); } return 0; }
static int max17135_wait_power_good(struct max17135 *max17135) { int i; for (i = 0; i < max17135->max_wait * 3; i++) { if (max17135_is_power_good(max17135)) return 0; msleep(1); } return -ETIMEDOUT; }