1
0
Fork 0

MLK-13982: 4.9 rebase: EPDC does not work

The Linux kernel regulator core implementation does not accept negative
voltage values; all negative values are treated as errors.

The problem with the EPDC is that the panel uses a negative voltage
regulator which fails to be enabled by the regulator core. This issue has
slipped up until the 4.9 rebase because the voltage range [min, max] was
checked against only when min = max. This has been fixed in 4.9, resulting
in errors in the VCOM regulator driver.

The fix is to use the negative values when communicating with the hardware,
but send only positive values to the regulator core.

This patch sends the absolute value to the regulator core and transforms
the received value (from the regulator core) to negative one before sending
it to hardware.

Fix device tree to deal with negative voltage regulator values by setting
min_value = -real_max_value and vice versa. Boards affected:
- imx6dl-sabresd
- imx6ull-14x14-ddr3-arm2
- imx7d-12x12-lpddr3-arm2
- imx7d-sdb
- imx6sll-evk
- imx6sl-evk
- imx6sll-lpddr3-arm2

Signed-off-by: Cristina Ciocan <cristina-mihaela.ciocan@nxp.com>
[Arul: Fix merge conflicts]
Signed-off-by: Arulpandiyan Vadivel <arulpandiyan_vadivel@mentor.com>

[Robby: split original patch to driver and dts part. this is driver part.]
Signed-off-by: Robby Cai <robby.cai@nxp.com>
5.4-rM2-2.2.x-imx-squashed
Cristina Ciocan 2017-02-27 12:04:17 +02:00 committed by Dong Aisheng
parent d562e283fa
commit 72eceaad82
1 changed files with 24 additions and 5 deletions

View File

@ -165,6 +165,12 @@ static inline int vcom_rs_to_uV(int rs, int pass_num)
- (vcom_data[pass_num].vcom_step_uV * rs);
}
/*
* This function should only be called with positive voltage values because
* negative ones are considered errors by the regulator core implementation.
*
* The given positive value if the absolute value of the desired negative one.
*/
static int max17135_vcom_set_voltage(struct regulator_dev *reg,
int minuV, int uV, unsigned *selector)
{
@ -172,6 +178,9 @@ static int max17135_vcom_set_voltage(struct regulator_dev *reg,
unsigned int reg_val;
int vcom_read;
/* Transform uV for our negative land values */
uV = -uV;
if ((uV < vcom_data[max17135->pass_num-1].vcom_min_uV)
|| (uV > vcom_data[max17135->pass_num-1].vcom_max_uV))
return -EINVAL;
@ -197,18 +206,29 @@ static int max17135_vcom_set_voltage(struct regulator_dev *reg,
return 0;
}
/*
* This function should only return positive voltage values because negative
* ones are considered errors by the regulator core implementation.
*/
static int max17135_vcom_get_voltage(struct regulator_dev *reg)
{
struct max17135 *max17135 = rdev_get_drvdata(reg);
unsigned int reg_val;
int uV;
max17135_reg_read(REG_MAX17135_DVR, &reg_val);
return vcom_rs_to_uV(BITFEXT(reg_val, DVR), max17135->pass_num-1);
uV = vcom_rs_to_uV(BITFEXT(reg_val, DVR), max17135->pass_num-1);
/* Transform uV to positive value */
uV = -uV;
return uV;
}
static int max17135_vcom_enable(struct regulator_dev *reg)
{
struct max17135 *max17135 = rdev_get_drvdata(reg);
int uV;
/*
* Check to see if we need to set the VCOM voltage.
@ -216,10 +236,9 @@ static int max17135_vcom_enable(struct regulator_dev *reg)
* 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);
uV = (-1) * max17135->vcom_uV;
max17135_vcom_set_voltage(reg, uV, uV, NULL);
max17135->vcom_setup = true;
}