1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2014 Freescale Semiconductor, Inc.
14 #ifdef CONFIG_FSL_LSCH2
15 #include <asm/arch/immap_lsch2.h>
16 #elif defined(CONFIG_FSL_LSCH3)
17 #include <asm/arch/immap_lsch3.h>
19 #include <asm/immap_85xx.h>
21 #include <linux/delay.h>
24 int __weak i2c_multiplexer_select_vid_channel(u8 channel)
30 * Compensate for a board specific voltage drop between regulator and SoC
31 * return a value in mV
33 int __weak board_vdd_drop_compensation(void)
39 * Board specific settings for specific voltage value
41 int __weak board_adjust_vdd(int vdd)
46 #if defined(CONFIG_VOL_MONITOR_IR36021_SET) || \
47 defined(CONFIG_VOL_MONITOR_IR36021_READ)
49 * Get the i2c address configuration for the IR regulator chip
51 * There are some variance in the RDB HW regarding the I2C address configuration
52 * for the IR regulator chip, which is likely a problem of external resistor
53 * accuracy. So we just check each address in a hopefully non-intrusive mode
54 * and use the first one that seems to work
56 * The IR chip can show up under the following addresses:
57 * 0x08 (Verified on T1040RDB-PA,T4240RDB-PB,X-T4240RDB-16GPA)
58 * 0x09 (Verified on T1040RDB-PA)
59 * 0x38 (Verified on T2080QDS, T2081QDS, T4240RDB)
61 static int find_ir_chip_on_i2c(void)
67 const int ir_i2c_addr[] = {0x38, 0x08, 0x09};
72 /* Check all the address */
73 for (i = 0; i < (sizeof(ir_i2c_addr)/sizeof(ir_i2c_addr[0])); i++) {
74 i2caddress = ir_i2c_addr[i];
76 ret = i2c_read(i2caddress,
77 IR36021_MFR_ID_OFFSET, 1, (void *)&byte,
80 ret = i2c_get_chip_for_busnum(0, i2caddress, 1, &dev);
82 ret = dm_i2c_read(dev, IR36021_MFR_ID_OFFSET,
83 (void *)&byte, sizeof(byte));
85 if ((ret >= 0) && (byte == IR36021_MFR_ID))
92 /* Maximum loop count waiting for new voltage to take effect */
93 #define MAX_LOOP_WAIT_NEW_VOL 100
94 /* Maximum loop count waiting for the voltage to be stable */
95 #define MAX_LOOP_WAIT_VOL_STABLE 100
97 * read_voltage from sensor on I2C bus
98 * We use average of 4 readings, waiting for WAIT_FOR_ADC before
101 #define NUM_READINGS 4 /* prefer to be power of 2 for efficiency */
103 /* If an INA220 chip is available, we can use it to read back the voltage
104 * as it may have a higher accuracy than the IR chip for the same purpose
106 #ifdef CONFIG_VOL_MONITOR_INA220
107 #define WAIT_FOR_ADC 532 /* wait for 532 microseconds for ADC */
108 #define ADC_MIN_ACCURACY 4
110 #define WAIT_FOR_ADC 138 /* wait for 138 microseconds for ADC */
111 #define ADC_MIN_ACCURACY 4
114 #ifdef CONFIG_VOL_MONITOR_INA220
115 static int read_voltage_from_INA220(int i2caddress)
117 int i, ret, voltage_read = 0;
124 for (i = 0; i < NUM_READINGS; i++) {
125 #ifndef CONFIG_DM_I2C
126 ret = i2c_read(I2C_VOL_MONITOR_ADDR,
127 I2C_VOL_MONITOR_BUS_V_OFFSET, 1,
130 ret = i2c_get_chip_for_busnum(0, I2C_VOL_MONITOR_ADDR, 1, &dev);
132 ret = dm_i2c_read(dev, I2C_VOL_MONITOR_BUS_V_OFFSET,
136 printf("VID: failed to read core voltage\n");
139 vol_mon = (buf[0] << 8) | buf[1];
140 if (vol_mon & I2C_VOL_MONITOR_BUS_V_OVF) {
141 printf("VID: Core voltage sensor error\n");
144 debug("VID: bus voltage reads 0x%04x\n", vol_mon);
146 voltage_read += (vol_mon >> I2C_VOL_MONITOR_BUS_V_SHIFT) * 4;
147 udelay(WAIT_FOR_ADC);
149 /* calculate the average */
150 voltage_read /= NUM_READINGS;
156 /* read voltage from IR */
157 #ifdef CONFIG_VOL_MONITOR_IR36021_READ
158 static int read_voltage_from_IR(int i2caddress)
160 int i, ret, voltage_read = 0;
167 for (i = 0; i < NUM_READINGS; i++) {
168 #ifndef CONFIG_DM_I2C
169 ret = i2c_read(i2caddress,
170 IR36021_LOOP1_VOUT_OFFSET,
173 ret = i2c_get_chip_for_busnum(0, i2caddress, 1, &dev);
175 ret = dm_i2c_read(dev, IR36021_LOOP1_VOUT_OFFSET,
179 printf("VID: failed to read vcpu\n");
184 printf("VID: Core voltage sensor error\n");
187 debug("VID: bus voltage reads 0x%02x\n", vol_mon);
188 /* Resolution is 1/128V. We scale up here to get 1/128mV
189 * and divide at the end
191 voltage_read += vol_mon * 1000;
192 udelay(WAIT_FOR_ADC);
194 /* Scale down to the real mV as IR resolution is 1/128V, rounding up */
195 voltage_read = DIV_ROUND_UP(voltage_read, 128);
197 /* calculate the average */
198 voltage_read /= NUM_READINGS;
200 /* Compensate for a board specific voltage drop between regulator and
201 * SoC before converting into an IR VID value
203 voltage_read -= board_vdd_drop_compensation();
209 #ifdef CONFIG_VOL_MONITOR_LTC3882_READ
210 /* read the current value of the LTC Regulator Voltage */
211 static int read_voltage_from_LTC(int i2caddress)
214 u8 chan = PWM_CHANNEL0;
216 #ifndef CONFIG_DM_I2C
217 /* select the PAGE 0 using PMBus commands PAGE for VDD*/
218 ret = i2c_write(I2C_VOL_MONITOR_ADDR,
219 PMBUS_CMD_PAGE, 1, &chan, 1);
223 ret = i2c_get_chip_for_busnum(0, I2C_VOL_MONITOR_ADDR, 1, &dev);
225 ret = dm_i2c_write(dev, PMBUS_CMD_PAGE, &chan, 1);
228 printf("VID: failed to select VDD Page 0\n");
232 #ifndef CONFIG_DM_I2C
233 /*read the output voltage using PMBus command READ_VOUT*/
234 ret = i2c_read(I2C_VOL_MONITOR_ADDR,
235 PMBUS_CMD_READ_VOUT, 1, (void *)&vcode, 2);
237 ret = dm_i2c_read(dev, PMBUS_CMD_READ_VOUT, (void *)&vcode, 2);
239 printf("VID: failed to read the volatge\n");
244 printf("VID: failed to read the volatge\n");
248 /* Scale down to the real mV as LTC resolution is 1/4096V,rounding up */
249 vcode = DIV_ROUND_UP(vcode * 1000, 4096);
255 static int read_voltage(int i2caddress)
258 #ifdef CONFIG_VOL_MONITOR_INA220
259 voltage_read = read_voltage_from_INA220(i2caddress);
260 #elif defined CONFIG_VOL_MONITOR_IR36021_READ
261 voltage_read = read_voltage_from_IR(i2caddress);
262 #elif defined CONFIG_VOL_MONITOR_LTC3882_READ
263 voltage_read = read_voltage_from_LTC(i2caddress);
270 #ifdef CONFIG_VOL_MONITOR_IR36021_SET
272 * We need to calculate how long before the voltage stops to drop
273 * or increase. It returns with the loop count. Each loop takes
274 * several readings (WAIT_FOR_ADC)
276 static int wait_for_new_voltage(int vdd, int i2caddress)
278 int timeout, vdd_current;
280 vdd_current = read_voltage(i2caddress);
281 /* wait until voltage starts to reach the target. Voltage slew
282 * rates by typical regulators will always lead to stable readings
283 * within each fairly long ADC interval in comparison to the
284 * intended voltage delta change until the target voltage is
285 * reached. The fairly small voltage delta change to any target
286 * VID voltage also means that this function will always complete
287 * within few iterations. If the timeout was ever reached, it would
288 * point to a serious failure in the regulator system.
291 abs(vdd - vdd_current) > (IR_VDD_STEP_UP + IR_VDD_STEP_DOWN) &&
292 timeout < MAX_LOOP_WAIT_NEW_VOL; timeout++) {
293 vdd_current = read_voltage(i2caddress);
295 if (timeout >= MAX_LOOP_WAIT_NEW_VOL) {
296 printf("VID: Voltage adjustment timeout\n");
303 * this function keeps reading the voltage until it is stable or until the
306 static int wait_for_voltage_stable(int i2caddress)
308 int timeout, vdd_current, vdd;
310 vdd = read_voltage(i2caddress);
311 udelay(NUM_READINGS * WAIT_FOR_ADC);
313 /* wait until voltage is stable */
314 vdd_current = read_voltage(i2caddress);
315 /* The maximum timeout is
316 * MAX_LOOP_WAIT_VOL_STABLE * NUM_READINGS * WAIT_FOR_ADC
318 for (timeout = MAX_LOOP_WAIT_VOL_STABLE;
319 abs(vdd - vdd_current) > ADC_MIN_ACCURACY &&
320 timeout > 0; timeout--) {
322 udelay(NUM_READINGS * WAIT_FOR_ADC);
323 vdd_current = read_voltage(i2caddress);
330 /* Set the voltage to the IR chip */
331 static int set_voltage_to_IR(int i2caddress, int vdd)
337 /* Compensate for a board specific voltage drop between regulator and
338 * SoC before converting into an IR VID value
340 vdd += board_vdd_drop_compensation();
341 #ifdef CONFIG_FSL_LSCH2
342 vid = DIV_ROUND_UP(vdd - 265, 5);
344 vid = DIV_ROUND_UP(vdd - 245, 5);
347 #ifndef CONFIG_DM_I2C
348 ret = i2c_write(i2caddress, IR36021_LOOP1_MANUAL_ID_OFFSET,
349 1, (void *)&vid, sizeof(vid));
353 ret = i2c_get_chip_for_busnum(0, i2caddress, 1, &dev);
355 ret = dm_i2c_write(dev, IR36021_LOOP1_MANUAL_ID_OFFSET,
356 (void *)&vid, sizeof(vid));
360 printf("VID: failed to write VID\n");
363 wait = wait_for_new_voltage(vdd, i2caddress);
366 debug("VID: Waited %d us\n", wait * NUM_READINGS * WAIT_FOR_ADC);
368 vdd_last = wait_for_voltage_stable(i2caddress);
371 debug("VID: Current voltage is %d mV\n", vdd_last);
377 #ifdef CONFIG_VOL_MONITOR_LTC3882_SET
378 /* this function sets the VDD and returns the value set */
379 static int set_voltage_to_LTC(int i2caddress, int vdd)
381 int ret, vdd_last, vdd_target = vdd;
382 int count = 100, temp = 0;
385 /* Scale up to the LTC resolution is 1/4096V */
386 vdd = (vdd * 4096) / 1000;
388 /* 5-byte buffer which needs to be sent following the
389 * PMBus command PAGE_PLUS_WRITE.
391 u8 buff[5] = {0x04, PWM_CHANNEL0, PMBUS_CMD_VOUT_COMMAND,
392 vdd & 0xFF, (vdd & 0xFF00) >> 8};
394 /* Write the desired voltage code to the regulator */
395 #ifndef CONFIG_DM_I2C
396 /* Check write protect state */
397 ret = i2c_read(I2C_VOL_MONITOR_ADDR,
398 PMBUS_CMD_WRITE_PROTECT, 1,
399 (void *)&value, sizeof(value));
403 if (value != EN_WRITE_ALL_CMD) {
404 value = EN_WRITE_ALL_CMD;
405 ret = i2c_write(I2C_VOL_MONITOR_ADDR,
406 PMBUS_CMD_WRITE_PROTECT, 1,
407 (void *)&value, sizeof(value));
412 ret = i2c_write(I2C_VOL_MONITOR_ADDR,
413 PMBUS_CMD_PAGE_PLUS_WRITE, 1,
414 (void *)&buff, sizeof(buff));
418 ret = i2c_get_chip_for_busnum(0, I2C_VOL_MONITOR_ADDR, 1, &dev);
420 /* Check write protect state */
421 ret = dm_i2c_read(dev,
422 PMBUS_CMD_WRITE_PROTECT,
423 (void *)&value, sizeof(value));
427 if (value != EN_WRITE_ALL_CMD) {
428 value = EN_WRITE_ALL_CMD;
429 ret = dm_i2c_write(dev,
430 PMBUS_CMD_WRITE_PROTECT,
431 (void *)&value, sizeof(value));
436 ret = dm_i2c_write(dev, PMBUS_CMD_PAGE_PLUS_WRITE,
437 (void *)&buff, sizeof(buff));
442 printf("VID: I2C failed to write to the volatge regulator\n");
446 /* Wait for the volatge to get to the desired value */
448 vdd_last = read_voltage_from_LTC(i2caddress);
450 printf("VID: Couldn't read sensor abort VID adjust\n");
454 temp = vdd_last - vdd_target;
455 } while ((abs(temp) > 2) && (count > 0));
461 static int set_voltage(int i2caddress, int vdd)
465 #ifdef CONFIG_VOL_MONITOR_IR36021_SET
466 vdd_last = set_voltage_to_IR(i2caddress, vdd);
467 #elif defined CONFIG_VOL_MONITOR_LTC3882_SET
468 vdd_last = set_voltage_to_LTC(i2caddress, vdd);
470 #error Specific voltage monitor must be defined
475 #ifdef CONFIG_FSL_LSCH3
476 int adjust_vdd(ulong vdd_override)
478 int re_enable = disable_interrupts();
479 struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
481 #if defined(CONFIG_VOL_MONITOR_IR36021_SET) || \
482 defined(CONFIG_VOL_MONITOR_IR36021_READ)
487 int vdd_target, vdd_current, vdd_last;
488 int ret, i2caddress = 0;
489 unsigned long vdd_string_override;
491 #if defined(CONFIG_ARCH_LX2160A) || defined(CONFIG_ARCH_LX2162A)
492 static const u16 vdd[32] = {
527 #ifdef CONFIG_ARCH_LS1088A
528 static const uint16_t vdd[32] = {
564 static const uint16_t vdd[32] = {
605 ret = i2c_multiplexer_select_vid_channel(I2C_MUX_CH_VOL_MONITOR);
607 debug("VID: I2C failed to switch channel\n");
611 #if defined(CONFIG_VOL_MONITOR_IR36021_SET) || \
612 defined(CONFIG_VOL_MONITOR_IR36021_READ)
613 ret = find_ir_chip_on_i2c();
615 printf("VID: Could not find voltage regulator on I2C.\n");
620 debug("VID: IR Chip found on I2C address 0x%02x\n", i2caddress);
623 /* check IR chip work on Intel mode*/
624 #ifndef CONFIG_DM_I2C
625 ret = i2c_read(i2caddress,
626 IR36021_INTEL_MODE_OOFSET,
631 ret = i2c_get_chip_for_busnum(0, i2caddress, 1, &dev);
633 ret = dm_i2c_read(dev, IR36021_INTEL_MODE_OOFSET,
637 printf("VID: failed to read IR chip mode.\n");
642 if ((buf & IR36021_MODE_MASK) != IR36021_INTEL_MODE) {
643 printf("VID: IR Chip is not used in Intel mode.\n");
649 /* get the voltage ID from fuse status register */
650 fusesr = in_le32(&gur->dcfg_fusesr);
651 vid = (fusesr >> FSL_CHASSIS3_DCFG_FUSESR_ALTVID_SHIFT) &
652 FSL_CHASSIS3_DCFG_FUSESR_ALTVID_MASK;
653 if ((vid == 0) || (vid == FSL_CHASSIS3_DCFG_FUSESR_ALTVID_MASK)) {
654 vid = (fusesr >> FSL_CHASSIS3_DCFG_FUSESR_VID_SHIFT) &
655 FSL_CHASSIS3_DCFG_FUSESR_VID_MASK;
657 vdd_target = vdd[vid];
659 /* check override variable for overriding VDD */
660 vdd_string = env_get(CONFIG_VID_FLS_ENV);
661 if (vdd_override == 0 && vdd_string &&
662 !strict_strtoul(vdd_string, 10, &vdd_string_override))
663 vdd_override = vdd_string_override;
665 if (vdd_override >= VDD_MV_MIN && vdd_override <= VDD_MV_MAX) {
666 vdd_target = vdd_override * 10; /* convert to 1/10 mV */
667 debug("VDD override is %lu\n", vdd_override);
668 } else if (vdd_override != 0) {
669 printf("Invalid value.\n");
672 /* divide and round up by 10 to get a value in mV */
673 vdd_target = DIV_ROUND_UP(vdd_target, 10);
674 if (vdd_target == 0) {
675 debug("VID: VID not used\n");
678 } else if (vdd_target < VDD_MV_MIN || vdd_target > VDD_MV_MAX) {
679 /* Check vdd_target is in valid range */
680 printf("VID: Target VID %d mV is not in range.\n",
685 debug("VID: vid = %d mV\n", vdd_target);
689 * Read voltage monitor to check real voltage.
691 vdd_last = read_voltage(i2caddress);
693 printf("VID: Couldn't read sensor abort VID adjustment\n");
697 vdd_current = vdd_last;
698 debug("VID: Core voltage is currently at %d mV\n", vdd_last);
700 #ifdef CONFIG_VOL_MONITOR_LTC3882_SET
701 /* Set the target voltage */
702 vdd_last = vdd_current = set_voltage(i2caddress, vdd_target);
705 * Adjust voltage to at or one step above target.
706 * As measurements are less precise than setting the values
707 * we may run through dummy steps that cancel each other
708 * when stepping up and then down.
710 while (vdd_last > 0 &&
711 vdd_last < vdd_target) {
712 vdd_current += IR_VDD_STEP_UP;
713 vdd_last = set_voltage(i2caddress, vdd_current);
715 while (vdd_last > 0 &&
716 vdd_last > vdd_target + (IR_VDD_STEP_DOWN - 1)) {
717 vdd_current -= IR_VDD_STEP_DOWN;
718 vdd_last = set_voltage(i2caddress, vdd_current);
722 if (board_adjust_vdd(vdd_target) < 0) {
728 printf("VID: Core voltage after adjustment is at %d mV\n",
735 i2c_multiplexer_select_vid_channel(I2C_MUX_CH_DEFAULT);
738 #else /* !CONFIG_FSL_LSCH3 */
739 int adjust_vdd(ulong vdd_override)
741 int re_enable = disable_interrupts();
742 #if defined(CONFIG_FSL_LSCH2)
743 struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
745 ccsr_gur_t __iomem *gur =
746 (void __iomem *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
750 int vdd_target, vdd_current, vdd_last;
752 unsigned long vdd_string_override;
754 static const uint16_t vdd[32] = {
787 ret = i2c_multiplexer_select_vid_channel(I2C_MUX_CH_VOL_MONITOR);
789 debug("VID: I2C failed to switch channel\n");
793 #if defined(CONFIG_VOL_MONITOR_IR36021_SET) || \
794 defined(CONFIG_VOL_MONITOR_IR36021_READ)
795 ret = find_ir_chip_on_i2c();
797 printf("VID: Could not find voltage regulator on I2C.\n");
802 debug("VID: IR Chip found on I2C address 0x%02x\n", i2caddress);
805 /* check IR chip work on Intel mode*/
806 #ifndef CONFIG_DM_I2C
807 ret = i2c_read(i2caddress,
808 IR36021_INTEL_MODE_OOFSET,
813 ret = i2c_get_chip_for_busnum(0, i2caddress, 1, &dev);
815 ret = dm_i2c_read(dev, IR36021_INTEL_MODE_OOFSET,
819 printf("VID: failed to read IR chip mode.\n");
823 if ((buf & IR36021_MODE_MASK) != IR36021_INTEL_MODE) {
824 printf("VID: IR Chip is not used in Intel mode.\n");
830 /* get the voltage ID from fuse status register */
831 fusesr = in_be32(&gur->dcfg_fusesr);
833 * VID is used according to the table below
834 * ---------------------------------------
836 * |-------------------------------------|
837 * | 5b00000 | 5b00001-5b11110 | 5b11111 |
838 * ---------------+---------+-----------------+---------|
839 * | D | 5b00000 | NO VID | VID = DA_V | NO VID |
840 * | A |----------+---------+-----------------+---------|
841 * | _ | 5b00001 |VID = | VID = |VID = |
842 * | V | ~ | DA_V_ALT| DA_V_ALT | DA_A_VLT|
843 * | _ | 5b11110 | | | |
844 * | A |----------+---------+-----------------+---------|
845 * | L | 5b11111 | No VID | VID = DA_V | NO VID |
847 * ------------------------------------------------------
849 #ifdef CONFIG_FSL_LSCH2
850 vid = (fusesr >> FSL_CHASSIS2_DCFG_FUSESR_ALTVID_SHIFT) &
851 FSL_CHASSIS2_DCFG_FUSESR_ALTVID_MASK;
852 if ((vid == 0) || (vid == FSL_CHASSIS2_DCFG_FUSESR_ALTVID_MASK)) {
853 vid = (fusesr >> FSL_CHASSIS2_DCFG_FUSESR_VID_SHIFT) &
854 FSL_CHASSIS2_DCFG_FUSESR_VID_MASK;
857 vid = (fusesr >> FSL_CORENET_DCFG_FUSESR_ALTVID_SHIFT) &
858 FSL_CORENET_DCFG_FUSESR_ALTVID_MASK;
859 if ((vid == 0) || (vid == FSL_CORENET_DCFG_FUSESR_ALTVID_MASK)) {
860 vid = (fusesr >> FSL_CORENET_DCFG_FUSESR_VID_SHIFT) &
861 FSL_CORENET_DCFG_FUSESR_VID_MASK;
864 vdd_target = vdd[vid];
866 /* check override variable for overriding VDD */
867 vdd_string = env_get(CONFIG_VID_FLS_ENV);
868 if (vdd_override == 0 && vdd_string &&
869 !strict_strtoul(vdd_string, 10, &vdd_string_override))
870 vdd_override = vdd_string_override;
871 if (vdd_override >= VDD_MV_MIN && vdd_override <= VDD_MV_MAX) {
872 vdd_target = vdd_override * 10; /* convert to 1/10 mV */
873 debug("VDD override is %lu\n", vdd_override);
874 } else if (vdd_override != 0) {
875 printf("Invalid value.\n");
877 if (vdd_target == 0) {
878 debug("VID: VID not used\n");
882 /* divide and round up by 10 to get a value in mV */
883 vdd_target = DIV_ROUND_UP(vdd_target, 10);
884 debug("VID: vid = %d mV\n", vdd_target);
888 * Read voltage monitor to check real voltage.
890 vdd_last = read_voltage(i2caddress);
892 printf("VID: Couldn't read sensor abort VID adjustment\n");
896 vdd_current = vdd_last;
897 debug("VID: Core voltage is currently at %d mV\n", vdd_last);
899 * Adjust voltage to at or one step above target.
900 * As measurements are less precise than setting the values
901 * we may run through dummy steps that cancel each other
902 * when stepping up and then down.
904 while (vdd_last > 0 &&
905 vdd_last < vdd_target) {
906 vdd_current += IR_VDD_STEP_UP;
907 vdd_last = set_voltage(i2caddress, vdd_current);
909 while (vdd_last > 0 &&
910 vdd_last > vdd_target + (IR_VDD_STEP_DOWN - 1)) {
911 vdd_current -= IR_VDD_STEP_DOWN;
912 vdd_last = set_voltage(i2caddress, vdd_current);
916 printf("VID: Core voltage after adjustment is at %d mV\n",
924 i2c_multiplexer_select_vid_channel(I2C_MUX_CH_DEFAULT);
930 static int print_vdd(void)
932 int vdd_last, ret, i2caddress = 0;
934 ret = i2c_multiplexer_select_vid_channel(I2C_MUX_CH_VOL_MONITOR);
936 debug("VID : I2c failed to switch channel\n");
939 #if defined(CONFIG_VOL_MONITOR_IR36021_SET) || \
940 defined(CONFIG_VOL_MONITOR_IR36021_READ)
941 ret = find_ir_chip_on_i2c();
943 printf("VID: Could not find voltage regulator on I2C.\n");
947 debug("VID: IR Chip found on I2C address 0x%02x\n", i2caddress);
952 * Read voltage monitor to check real voltage.
954 vdd_last = read_voltage(i2caddress);
956 printf("VID: Couldn't read sensor abort VID adjustment\n");
959 printf("VID: Core voltage is at %d mV\n", vdd_last);
961 i2c_multiplexer_select_vid_channel(I2C_MUX_CH_DEFAULT);
963 return ret < 0 ? -1 : 0;
967 static int do_vdd_override(struct cmd_tbl *cmdtp,
974 return CMD_RET_USAGE;
976 if (!strict_strtoul(argv[1], 10, &override))
977 adjust_vdd(override); /* the value is checked by callee */
979 return CMD_RET_USAGE;
983 static int do_vdd_read(struct cmd_tbl *cmdtp, int flag, int argc,
987 return CMD_RET_USAGE;
994 vdd_override, 2, 0, do_vdd_override,
996 " - override with the voltage specified in mV, eg. 1050"
1000 vdd_read, 1, 0, do_vdd_read,
1002 " - Read the voltage specified in mV"