[U-Boot] [RESEND PATCH v7 06/10] board: common: vid: Add support for LTC3882 voltage regulator chip

York Sun york.sun at nxp.com
Fri Dec 8 17:23:47 UTC 2017


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.Kumar at nxp.com>
> Signed-off-by: Rajesh Bhagat <rajesh.bhagat at 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


More information about the U-Boot mailing list