static int max17135_vcom_set_voltage(struct regulator_dev *reg, int minuV, int uV, unsigned *selector) { struct max17135 *max17135 = rdev_get_drvdata(reg); unsigned int reg_val; int vcom_read; if ((uV < vcom_data[max17135->pass_num-1].vcom_min_uV) || (uV > vcom_data[max17135->pass_num-1].vcom_max_uV)) return -EINVAL; max17135_reg_read(REG_MAX17135_DVR, ®_val); /* * Only program VCOM if it is not set to the desired value. * Programming VCOM excessively degrades ability to keep * DVR register value persistent. */ vcom_read = vcom_rs_to_uV(reg_val, max17135->pass_num-1); if (vcom_read != max17135->vcom_uV) { reg_val &= ~BITFMASK(DVR); reg_val |= BITFVAL(DVR, vcom_uV_to_rs(uV, max17135->pass_num-1)); max17135_reg_write(REG_MAX17135_DVR, reg_val); reg_val = BITFVAL(CTRL_DVR, true); /* shift to correct bit */ return max17135_reg_write(REG_MAX17135_PRGM_CTRL, reg_val); } return 0; }
static int tps6518x_vcom_set_voltage(struct regulator_dev *reg, int minuV, int uV) { struct tps6518x *tps6518x = rdev_get_drvdata(reg); unsigned int cur_reg_val; /* current register value to modify */ unsigned int new_reg_val; /* new register value to write */ int retval; /* * this will not work on tps65182 */ if (tps6518x->revID == 65182) { //printk("%s %s %d RETURN ERROR 65182! \n",__FILE__,__func__,__LINE__); return 0; } ///del,compare for patch:TPS6518x-unable-to-set-VCOM.patch if ((-uV) < 200000) { //printk("%s %s %d too small return uV=%ld\n",__FILE__,__func__,__LINE__,uV); return 0; } //printk(" tps vcom uV=%ld \n",uV); switch (tps6518x->revID & 15) { case 0 : /* TPS65180 */ case 1 : /* TPS65181 */ case 4 : /* TPS65180-rev1 */ tps6518x_reg_read(REG_TPS65180_VCOM_ADJUST,&cur_reg_val); new_reg_val = to_reg_val(cur_reg_val, BITFMASK(VCOM_SET), BITFVAL(VCOM_SET, vcom_uV_to_rs(uV))); retval = tps6518x_reg_write(REG_TPS65180_VCOM_ADJUST, new_reg_val); break; case 5 : /* TPS65185 */ case 6 : /* TPS65186 */ retval = tps6518x_reg_write(REG_TPS65185_VCOM1, vcom2_uV_to_rs(uV) & 255); tps6518x_reg_read( REG_TPS65185_VCOM2,&cur_reg_val); new_reg_val = to_reg_val(cur_reg_val, BITFMASK(VCOM2_SET), BITFVAL(VCOM2_SET, vcom2_uV_to_rs(uV)/256)); retval = tps6518x_reg_write(REG_TPS65185_VCOM2, new_reg_val); break; default : retval = -1; } return retval; }
static int fp9928_vcom_set_voltage(struct regulator_dev *reg, int minuV, int uV) { u8 reg_val; if ((uV < vcom_data.vcom_min_uV) || (uV > vcom_data.vcom_max_uV)) { pr_err("Warning : supported VCOM voltage range : -2501mv ~ -302mv\n"); return -EINVAL; } reg_val = vcom_uV_to_rs(uV); fp9928_i2c_device_write(REG_VCOM_SETTING, reg_val); msleep(10); fp9928_i2c_device_read(REG_VCOM_SETTING, ®_val); pr_info("read register raw value : %d\n", reg_val); pr_info("Set VCOM output voltage to %dmV\n", uV / 1000); return 0; }