VCOM_reg: VCOM {
regulator-name = "VCOM";
- /* 2's-compliment, -4325000 */
- regulator-min-microvolt = <0xffbe0178>;
- /* 2's-compliment, -500000 */
- regulator-max-microvolt = <0xfff85ee0>;
+ /* Real max: -500000 */
+ regulator-max-microvolt = <4325000>;
+ /* Real min: -4325000 */
+ regulator-min-microvolt = <500000>;
};
VNEG_reg: VNEG {
VCOM_reg: VCOM {
regulator-name = "VCOM";
- /* 2's-compliment, -4325000 */
- regulator-min-microvolt = <0xffbe0178>;
- /* 2's-compliment, -500000 */
- regulator-max-microvolt = <0xfff85ee0>;
+ /* Real max value: -500000 */
+ regulator-max-microvolt = <4325000>;
+ /* Real min value: -4325000 */
+ regulator-min-microvolt = <500000>;
};
VNEG_reg: VNEG {
VCOM_reg: VCOM {
regulator-name = "VCOM";
- /* 2's-compliment, -4325000 */
- regulator-min-microvolt = <0xffbe0178>;
- /* 2's-compliment, -500000 */
- regulator-max-microvolt = <0xfff85ee0>;
+ /* Real max value: -500000 */
+ regulator-max-microvolt = <4325000>;
+ /* Real min value: -4325000 */
+ regulator-min-microvolt = <500000>;
};
VNEG_reg: VNEG {
VCOM_reg: VCOM {
regulator-name = "VCOM";
- /* 2's-compliment, -4325000 */
- regulator-min-microvolt = <0xffbe0178>;
- /* 2's-compliment, -500000 */
- regulator-max-microvolt = <0xfff85ee0>;
+ /* Real max value: -500000 */
+ regulator-max-microvolt = <4325000>;
+ /* Real min value: -4325000 */
+ regulator-min-microvolt = <500000>;
};
VNEG_reg: VNEG {
VCOM_reg: VCOM {
regulator-name = "VCOM";
- /* 2's-compliment, -4325000 */
- regulator-min-microvolt = <0xffbe0178>;
- /* 2's-compliment, -500000 */
- regulator-max-microvolt = <0xfff85ee0>;
+ /* Real max: -500000 */
+ regulator-max-microvolt = <4325000>;
+ /* Real min: -4325000 */
+ regulator-min-microvolt = <500000>;
};
VNEG_reg: VNEG {
VCOM_reg: VCOM {
regulator-name = "VCOM";
- /* 2's-compliment, -4325000 */
- regulator-min-microvolt = <0xffbe0178>;
- /* 2's-compliment, -500000 */
- regulator-max-microvolt = <0xfff85ee0>;
+ /* Real max value: -500000 */
+ regulator-max-microvolt = <4325000>;
+ /* Real min value: -4325000 */
+ regulator-min-microvolt = <500000>;
};
VNEG_reg: VNEG {
VCOM_reg: VCOM {
regulator-name = "VCOM";
- /* 2's-compliment, -4325000 */
- regulator-min-microvolt = <0xffbe0178>;
- /* 2's-compliment, -500000 */
- regulator-max-microvolt = <0xfff85ee0>;
+ /* Real max value: -500000 */
+ regulator-max-microvolt = <4325000>;
+ /* Real min value: -4325000 */
+ regulator-min-microvolt = <500000>;
};
VNEG_reg: VNEG {
- (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)
{
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;
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, ®_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.
* 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;
}