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, &reg_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 max17135_vcom_get_voltage(struct regulator_dev *reg)
{
	struct max17135 *max17135 = rdev_get_drvdata(reg);
	unsigned int reg_val;

	max17135_reg_read(REG_MAX17135_DVR, &reg_val);
	return vcom_rs_to_uV(BITFEXT(reg_val, DVR), max17135->pass_num-1);
}
Example #3
0
static int fp9928_vcom_get_voltage(struct regulator_dev *reg)
{
	u8 reg_val;
	int vol_val;

	fp9928_i2c_device_read(REG_VCOM_SETTING, &reg_val);

	vol_val = vcom_rs_to_uV(reg_val);	

	if (vol_val < vcom_data.vcom_min_uV) {
		vol_val = vcom_data.vcom_min_uV;
	}
	
	return vol_val;
}
Example #4
0
static int tps6518x_vcom_get_voltage(struct regulator_dev *reg)
{
	struct tps6518x *tps6518x = rdev_get_drvdata(reg);
	unsigned int cur_reg_val; /* current register value */
	unsigned int cur_reg2_val; /* current register value */
	unsigned int cur_fld_val; /* current bitfield value*/
	int vcomValue;


	/*
	* this will not work on tps65182
	*/
	if (tps6518x->revID == 65182)
		return 0;

	switch (tps6518x->revID & 15)
	{
	case 0 : /* TPS65180 */
	case 1 : /* TPS65181 */
	case 4 : /* TPS65180-rev1 */
		tps6518x_reg_read(REG_TPS65180_VCOM_ADJUST, &cur_reg_val);
		cur_fld_val = BITFEXT(cur_reg_val, VCOM_SET);
		vcomValue = vcom_rs_to_uV(cur_fld_val);
		break;
	case 5 : /* TPS65185 */
	case 6 : /* TPS65186 */
		tps6518x_reg_read(REG_TPS65185_VCOM1,&cur_reg_val);
		tps6518x_reg_read(REG_TPS65185_VCOM2,&cur_reg2_val);
		cur_reg_val |= 256 * (1 & cur_reg2_val);
		vcomValue = vcom2_rs_to_uV(cur_reg_val);
		break;
	default:
		vcomValue = 0;
	}

	return vcomValue;

}