On 11/29/2017 10:31 PM, Rajesh Bhagat wrote: > Restructures common driver to support LTC3882 voltage regulator > chip. > > Signed-off-by: Ashish Kumar <ashish.ku...@nxp.com> > Signed-off-by: Rajesh Bhagat <rajesh.bha...@nxp.com> > --- > Changes in v7: > > None >
<snip> > +static int set_voltage_to_LTC(int i2caddress, int vdd) > +{ > + int ret, vdd_last, vdd_target = vdd; > + > + /* Scale up to the LTC resolution is 1/4096V */ > + vdd = (vdd * 4096) / 1000; > + > + /* 5-byte buffer which needs to be sent following the > + * PMBus command PAGE_PLUS_WRITE. > + */ > + u8 buff[5] = {0x04, PWM_CHANNEL0, PMBUS_CMD_VOUT_COMMAND, > + vdd & 0xFF, (vdd & 0xFF00) >> 8}; > + > + /* Write the desired voltage code to the regulator */ > + ret = i2c_write(I2C_VOL_MONITOR_ADDR, > + PMBUS_CMD_PAGE_PLUS_WRITE, 1, (void *)&buff, 5); > + if (ret) { > + printf("VID: I2C failed to write to the volatge regulator\n"); > + return -1; > + } > + > + /* Wait for the volatge to get to the desired value */ > + do { > + vdd_last = read_voltage_from_LTC(i2caddress); > + if (vdd_last < 0) { > + printf("VID: Couldn't read sensor abort VID adjust\n"); > + return -1; > + } > + } while (vdd_last != vdd_target); nitpick Insert a blank line before return. > + return vdd_last; > +} York _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot