1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2014 Freescale Semiconductor, Inc.
13 #ifdef CONFIG_FSL_LSCH2
14 #include <asm/arch/immap_lsch2.h>
15 #elif defined(CONFIG_FSL_LSCH3)
16 #include <asm/arch/immap_lsch3.h>
18 #include <asm/immap_85xx.h>
20 #include <linux/delay.h>
23 int __weak i2c_multiplexer_select_vid_channel(u8 channel)
29 * Compensate for a board specific voltage drop between regulator and SoC
30 * return a value in mV
32 int __weak board_vdd_drop_compensation(void)
38 * Board specific settings for specific voltage value
40 int __weak board_adjust_vdd(int vdd)
45 #if defined(CONFIG_VOL_MONITOR_IR36021_SET) || \
46 defined(CONFIG_VOL_MONITOR_IR36021_READ)
48 * Get the i2c address configuration for the IR regulator chip
50 * There are some variance in the RDB HW regarding the I2C address configuration
51 * for the IR regulator chip, which is likely a problem of external resistor
52 * accuracy. So we just check each address in a hopefully non-intrusive mode
53 * and use the first one that seems to work
55 * The IR chip can show up under the following addresses:
56 * 0x08 (Verified on T1040RDB-PA,T4240RDB-PB,X-T4240RDB-16GPA)
57 * 0x09 (Verified on T1040RDB-PA)
58 * 0x38 (Verified on T2080QDS, T2081QDS, T4240RDB)
60 static int find_ir_chip_on_i2c(void)
66 const int ir_i2c_addr[] = {0x38, 0x08, 0x09};
71 /* Check all the address */
72 for (i = 0; i < (sizeof(ir_i2c_addr)/sizeof(ir_i2c_addr[0])); i++) {
73 i2caddress = ir_i2c_addr[i];
75 ret = i2c_read(i2caddress,
76 IR36021_MFR_ID_OFFSET, 1, (void *)&byte,
79 ret = i2c_get_chip_for_busnum(0, i2caddress, 1, &dev);
81 ret = dm_i2c_read(dev, IR36021_MFR_ID_OFFSET,
82 (void *)&byte, sizeof(byte));
84 if ((ret >= 0) && (byte == IR36021_MFR_ID))
91 /* Maximum loop count waiting for new voltage to take effect */
92 #define MAX_LOOP_WAIT_NEW_VOL 100
93 /* Maximum loop count waiting for the voltage to be stable */
94 #define MAX_LOOP_WAIT_VOL_STABLE 100
96 * read_voltage from sensor on I2C bus
97 * We use average of 4 readings, waiting for WAIT_FOR_ADC before
100 #define NUM_READINGS 4 /* prefer to be power of 2 for efficiency */
102 /* If an INA220 chip is available, we can use it to read back the voltage
103 * as it may have a higher accuracy than the IR chip for the same purpose
105 #ifdef CONFIG_VOL_MONITOR_INA220
106 #define WAIT_FOR_ADC 532 /* wait for 532 microseconds for ADC */
107 #define ADC_MIN_ACCURACY 4
109 #define WAIT_FOR_ADC 138 /* wait for 138 microseconds for ADC */
110 #define ADC_MIN_ACCURACY 4
113 #ifdef CONFIG_VOL_MONITOR_INA220
114 static int read_voltage_from_INA220(int i2caddress)
116 int i, ret, voltage_read = 0;
123 for (i = 0; i < NUM_READINGS; i++) {
124 #ifndef CONFIG_DM_I2C
125 ret = i2c_read(I2C_VOL_MONITOR_ADDR,
126 I2C_VOL_MONITOR_BUS_V_OFFSET, 1,
129 ret = i2c_get_chip_for_busnum(0, I2C_VOL_MONITOR_ADDR, 1, &dev);
131 ret = dm_i2c_read(dev, I2C_VOL_MONITOR_BUS_V_OFFSET,
135 printf("VID: failed to read core voltage\n");
138 vol_mon = (buf[0] << 8) | buf[1];
139 if (vol_mon & I2C_VOL_MONITOR_BUS_V_OVF) {
140 printf("VID: Core voltage sensor error\n");
143 debug("VID: bus voltage reads 0x%04x\n", vol_mon);
145 voltage_read += (vol_mon >> I2C_VOL_MONITOR_BUS_V_SHIFT) * 4;
146 udelay(WAIT_FOR_ADC);
148 /* calculate the average */
149 voltage_read /= NUM_READINGS;
155 /* read voltage from IR */
156 #ifdef CONFIG_VOL_MONITOR_IR36021_READ
157 static int read_voltage_from_IR(int i2caddress)
159 int i, ret, voltage_read = 0;
166 for (i = 0; i < NUM_READINGS; i++) {
167 #ifndef CONFIG_DM_I2C
168 ret = i2c_read(i2caddress,
169 IR36021_LOOP1_VOUT_OFFSET,
172 ret = i2c_get_chip_for_busnum(0, i2caddress, 1, &dev);
174 ret = dm_i2c_read(dev, IR36021_LOOP1_VOUT_OFFSET,
178 printf("VID: failed to read vcpu\n");
183 printf("VID: Core voltage sensor error\n");
186 debug("VID: bus voltage reads 0x%02x\n", vol_mon);
187 /* Resolution is 1/128V. We scale up here to get 1/128mV
188 * and divide at the end
190 voltage_read += vol_mon * 1000;
191 udelay(WAIT_FOR_ADC);
193 /* Scale down to the real mV as IR resolution is 1/128V, rounding up */
194 voltage_read = DIV_ROUND_UP(voltage_read, 128);
196 /* calculate the average */
197 voltage_read /= NUM_READINGS;
199 /* Compensate for a board specific voltage drop between regulator and
200 * SoC before converting into an IR VID value
202 voltage_read -= board_vdd_drop_compensation();
208 #ifdef CONFIG_VOL_MONITOR_LTC3882_READ
209 /* read the current value of the LTC Regulator Voltage */
210 static int read_voltage_from_LTC(int i2caddress)
213 u8 chan = PWM_CHANNEL0;
215 #ifndef CONFIG_DM_I2C
216 /* select the PAGE 0 using PMBus commands PAGE for VDD*/
217 ret = i2c_write(I2C_VOL_MONITOR_ADDR,
218 PMBUS_CMD_PAGE, 1, &chan, 1);
222 ret = i2c_get_chip_for_busnum(0, I2C_VOL_MONITOR_ADDR, 1, &dev);
224 ret = dm_i2c_write(dev, PMBUS_CMD_PAGE, &chan, 1);
227 printf("VID: failed to select VDD Page 0\n");
231 #ifndef CONFIG_DM_I2C
232 /*read the output voltage using PMBus command READ_VOUT*/
233 ret = i2c_read(I2C_VOL_MONITOR_ADDR,
234 PMBUS_CMD_READ_VOUT, 1, (void *)&vcode, 2);
236 ret = dm_i2c_read(dev, PMBUS_CMD_READ_VOUT, (void *)&vcode, 2);
238 printf("VID: failed to read the volatge\n");
243 printf("VID: failed to read the volatge\n");
247 /* Scale down to the real mV as LTC resolution is 1/4096V,rounding up */
248 vcode = DIV_ROUND_UP(vcode * 1000, 4096);
254 static int read_voltage(int i2caddress)
257 #ifdef CONFIG_VOL_MONITOR_INA220
258 voltage_read = read_voltage_from_INA220(i2caddress);
259 #elif defined CONFIG_VOL_MONITOR_IR36021_READ
260 voltage_read = read_voltage_from_IR(i2caddress);
261 #elif defined CONFIG_VOL_MONITOR_LTC3882_READ
262 voltage_read = read_voltage_from_LTC(i2caddress);
269 #ifdef CONFIG_VOL_MONITOR_IR36021_SET
271 * We need to calculate how long before the voltage stops to drop
272 * or increase. It returns with the loop count. Each loop takes
273 * several readings (WAIT_FOR_ADC)
275 static int wait_for_new_voltage(int vdd, int i2caddress)
277 int timeout, vdd_current;
279 vdd_current = read_voltage(i2caddress);
280 /* wait until voltage starts to reach the target. Voltage slew
281 * rates by typical regulators will always lead to stable readings
282 * within each fairly long ADC interval in comparison to the
283 * intended voltage delta change until the target voltage is
284 * reached. The fairly small voltage delta change to any target
285 * VID voltage also means that this function will always complete
286 * within few iterations. If the timeout was ever reached, it would
287 * point to a serious failure in the regulator system.
290 abs(vdd - vdd_current) > (IR_VDD_STEP_UP + IR_VDD_STEP_DOWN) &&
291 timeout < MAX_LOOP_WAIT_NEW_VOL; timeout++) {
292 vdd_current = read_voltage(i2caddress);
294 if (timeout >= MAX_LOOP_WAIT_NEW_VOL) {
295 printf("VID: Voltage adjustment timeout\n");
302 * this function keeps reading the voltage until it is stable or until the
305 static int wait_for_voltage_stable(int i2caddress)
307 int timeout, vdd_current, vdd;
309 vdd = read_voltage(i2caddress);
310 udelay(NUM_READINGS * WAIT_FOR_ADC);
312 /* wait until voltage is stable */
313 vdd_current = read_voltage(i2caddress);
314 /* The maximum timeout is
315 * MAX_LOOP_WAIT_VOL_STABLE * NUM_READINGS * WAIT_FOR_ADC
317 for (timeout = MAX_LOOP_WAIT_VOL_STABLE;
318 abs(vdd - vdd_current) > ADC_MIN_ACCURACY &&
319 timeout > 0; timeout--) {
321 udelay(NUM_READINGS * WAIT_FOR_ADC);
322 vdd_current = read_voltage(i2caddress);
329 /* Set the voltage to the IR chip */
330 static int set_voltage_to_IR(int i2caddress, int vdd)
336 /* Compensate for a board specific voltage drop between regulator and
337 * SoC before converting into an IR VID value
339 vdd += board_vdd_drop_compensation();
340 #ifdef CONFIG_FSL_LSCH2
341 vid = DIV_ROUND_UP(vdd - 265, 5);
343 vid = DIV_ROUND_UP(vdd - 245, 5);
346 #ifndef CONFIG_DM_I2C
347 ret = i2c_write(i2caddress, IR36021_LOOP1_MANUAL_ID_OFFSET,
348 1, (void *)&vid, sizeof(vid));
352 ret = i2c_get_chip_for_busnum(0, i2caddress, 1, &dev);
354 ret = dm_i2c_write(dev, IR36021_LOOP1_MANUAL_ID_OFFSET,
355 (void *)&vid, sizeof(vid));
359 printf("VID: failed to write VID\n");
362 wait = wait_for_new_voltage(vdd, i2caddress);
365 debug("VID: Waited %d us\n", wait * NUM_READINGS * WAIT_FOR_ADC);
367 vdd_last = wait_for_voltage_stable(i2caddress);
370 debug("VID: Current voltage is %d mV\n", vdd_last);
376 #ifdef CONFIG_VOL_MONITOR_LTC3882_SET
377 /* this function sets the VDD and returns the value set */
378 static int set_voltage_to_LTC(int i2caddress, int vdd)
380 int ret, vdd_last, vdd_target = vdd;
381 int count = 100, temp = 0;
384 /* Scale up to the LTC resolution is 1/4096V */
385 vdd = (vdd * 4096) / 1000;
387 /* 5-byte buffer which needs to be sent following the
388 * PMBus command PAGE_PLUS_WRITE.
390 u8 buff[5] = {0x04, PWM_CHANNEL0, PMBUS_CMD_VOUT_COMMAND,
391 vdd & 0xFF, (vdd & 0xFF00) >> 8};
393 /* Write the desired voltage code to the regulator */
394 #ifndef CONFIG_DM_I2C
395 /* Check write protect state */
396 ret = i2c_read(I2C_VOL_MONITOR_ADDR,
397 PMBUS_CMD_WRITE_PROTECT, 1,
398 (void *)&value, sizeof(value));
402 if (value != EN_WRITE_ALL_CMD) {
403 value = EN_WRITE_ALL_CMD;
404 ret = i2c_write(I2C_VOL_MONITOR_ADDR,
405 PMBUS_CMD_WRITE_PROTECT, 1,
406 (void *)&value, sizeof(value));
411 ret = i2c_write(I2C_VOL_MONITOR_ADDR,
412 PMBUS_CMD_PAGE_PLUS_WRITE, 1,
413 (void *)&buff, sizeof(buff));
417 ret = i2c_get_chip_for_busnum(0, I2C_VOL_MONITOR_ADDR, 1, &dev);
419 /* Check write protect state */
420 ret = dm_i2c_read(dev,
421 PMBUS_CMD_WRITE_PROTECT,
422 (void *)&value, sizeof(value));
426 if (value != EN_WRITE_ALL_CMD) {
427 value = EN_WRITE_ALL_CMD;
428 ret = dm_i2c_write(dev,
429 PMBUS_CMD_WRITE_PROTECT,
430 (void *)&value, sizeof(value));
435 ret = dm_i2c_write(dev, PMBUS_CMD_PAGE_PLUS_WRITE,
436 (void *)&buff, sizeof(buff));
441 printf("VID: I2C failed to write to the volatge regulator\n");
445 /* Wait for the volatge to get to the desired value */
447 vdd_last = read_voltage_from_LTC(i2caddress);
449 printf("VID: Couldn't read sensor abort VID adjust\n");
453 temp = vdd_last - vdd_target;
454 } while ((abs(temp) > 2) && (count > 0));
460 static int set_voltage(int i2caddress, int vdd)
464 #ifdef CONFIG_VOL_MONITOR_IR36021_SET
465 vdd_last = set_voltage_to_IR(i2caddress, vdd);
466 #elif defined CONFIG_VOL_MONITOR_LTC3882_SET
467 vdd_last = set_voltage_to_LTC(i2caddress, vdd);
469 #error Specific voltage monitor must be defined
474 #ifdef CONFIG_FSL_LSCH3
475 int adjust_vdd(ulong vdd_override)
477 int re_enable = disable_interrupts();
478 struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
480 #if defined(CONFIG_VOL_MONITOR_IR36021_SET) || \
481 defined(CONFIG_VOL_MONITOR_IR36021_READ)
486 int vdd_target, vdd_current, vdd_last;
488 unsigned long vdd_string_override;
490 #ifdef CONFIG_ARCH_LX2160A
491 static const u16 vdd[32] = {
526 #ifdef CONFIG_ARCH_LS1088A
527 static const uint16_t vdd[32] = {
563 static const uint16_t vdd[32] = {
604 ret = i2c_multiplexer_select_vid_channel(I2C_MUX_CH_VOL_MONITOR);
606 debug("VID: I2C failed to switch channel\n");
610 #if defined(CONFIG_VOL_MONITOR_IR36021_SET) || \
611 defined(CONFIG_VOL_MONITOR_IR36021_READ)
612 ret = find_ir_chip_on_i2c();
614 printf("VID: Could not find voltage regulator on I2C.\n");
619 debug("VID: IR Chip found on I2C address 0x%02x\n", i2caddress);
622 /* check IR chip work on Intel mode*/
623 #ifndef CONFIG_DM_I2C
624 ret = i2c_read(i2caddress,
625 IR36021_INTEL_MODE_OOFSET,
630 ret = i2c_get_chip_for_busnum(0, i2caddress, 1, &dev);
632 ret = dm_i2c_read(dev, IR36021_INTEL_MODE_OOFSET,
636 printf("VID: failed to read IR chip mode.\n");
641 if ((buf & IR36021_MODE_MASK) != IR36021_INTEL_MODE) {
642 printf("VID: IR Chip is not used in Intel mode.\n");
648 /* get the voltage ID from fuse status register */
649 fusesr = in_le32(&gur->dcfg_fusesr);
650 vid = (fusesr >> FSL_CHASSIS3_DCFG_FUSESR_ALTVID_SHIFT) &
651 FSL_CHASSIS3_DCFG_FUSESR_ALTVID_MASK;
652 if ((vid == 0) || (vid == FSL_CHASSIS3_DCFG_FUSESR_ALTVID_MASK)) {
653 vid = (fusesr >> FSL_CHASSIS3_DCFG_FUSESR_VID_SHIFT) &
654 FSL_CHASSIS3_DCFG_FUSESR_VID_MASK;
656 vdd_target = vdd[vid];
658 /* check override variable for overriding VDD */
659 vdd_string = env_get(CONFIG_VID_FLS_ENV);
660 if (vdd_override == 0 && vdd_string &&
661 !strict_strtoul(vdd_string, 10, &vdd_string_override))
662 vdd_override = vdd_string_override;
664 if (vdd_override >= VDD_MV_MIN && vdd_override <= VDD_MV_MAX) {
665 vdd_target = vdd_override * 10; /* convert to 1/10 mV */
666 debug("VDD override is %lu\n", vdd_override);
667 } else if (vdd_override != 0) {
668 printf("Invalid value.\n");
671 /* divide and round up by 10 to get a value in mV */
672 vdd_target = DIV_ROUND_UP(vdd_target, 10);
673 if (vdd_target == 0) {
674 debug("VID: VID not used\n");
677 } else if (vdd_target < VDD_MV_MIN || vdd_target > VDD_MV_MAX) {
678 /* Check vdd_target is in valid range */
679 printf("VID: Target VID %d mV is not in range.\n",
684 debug("VID: vid = %d mV\n", vdd_target);
688 * Read voltage monitor to check real voltage.
690 vdd_last = read_voltage(i2caddress);
692 printf("VID: Couldn't read sensor abort VID adjustment\n");
696 vdd_current = vdd_last;
697 debug("VID: Core voltage is currently at %d mV\n", vdd_last);
699 #ifdef CONFIG_VOL_MONITOR_LTC3882_SET
700 /* Set the target voltage */
701 vdd_last = vdd_current = set_voltage(i2caddress, vdd_target);
704 * Adjust voltage to at or one step above target.
705 * As measurements are less precise than setting the values
706 * we may run through dummy steps that cancel each other
707 * when stepping up and then down.
709 while (vdd_last > 0 &&
710 vdd_last < vdd_target) {
711 vdd_current += IR_VDD_STEP_UP;
712 vdd_last = set_voltage(i2caddress, vdd_current);
714 while (vdd_last > 0 &&
715 vdd_last > vdd_target + (IR_VDD_STEP_DOWN - 1)) {
716 vdd_current -= IR_VDD_STEP_DOWN;
717 vdd_last = set_voltage(i2caddress, vdd_current);
721 if (board_adjust_vdd(vdd_target) < 0) {
727 printf("VID: Core voltage after adjustment is at %d mV\n",
734 i2c_multiplexer_select_vid_channel(I2C_MUX_CH_DEFAULT);
737 #else /* !CONFIG_FSL_LSCH3 */
738 int adjust_vdd(ulong vdd_override)
740 int re_enable = disable_interrupts();
741 #if defined(CONFIG_FSL_LSCH2)
742 struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
744 ccsr_gur_t __iomem *gur =
745 (void __iomem *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
749 int vdd_target, vdd_current, vdd_last;
751 unsigned long vdd_string_override;
753 static const uint16_t vdd[32] = {
786 ret = i2c_multiplexer_select_vid_channel(I2C_MUX_CH_VOL_MONITOR);
788 debug("VID: I2C failed to switch channel\n");
792 #if defined(CONFIG_VOL_MONITOR_IR36021_SET) || \
793 defined(CONFIG_VOL_MONITOR_IR36021_READ)
794 ret = find_ir_chip_on_i2c();
796 printf("VID: Could not find voltage regulator on I2C.\n");
801 debug("VID: IR Chip found on I2C address 0x%02x\n", i2caddress);
804 /* check IR chip work on Intel mode*/
805 #ifndef CONFIG_DM_I2C
806 ret = i2c_read(i2caddress,
807 IR36021_INTEL_MODE_OOFSET,
812 ret = i2c_get_chip_for_busnum(0, i2caddress, 1, &dev);
814 ret = dm_i2c_read(dev, IR36021_INTEL_MODE_OOFSET,
818 printf("VID: failed to read IR chip mode.\n");
822 if ((buf & IR36021_MODE_MASK) != IR36021_INTEL_MODE) {
823 printf("VID: IR Chip is not used in Intel mode.\n");
829 /* get the voltage ID from fuse status register */
830 fusesr = in_be32(&gur->dcfg_fusesr);
832 * VID is used according to the table below
833 * ---------------------------------------
835 * |-------------------------------------|
836 * | 5b00000 | 5b00001-5b11110 | 5b11111 |
837 * ---------------+---------+-----------------+---------|
838 * | D | 5b00000 | NO VID | VID = DA_V | NO VID |
839 * | A |----------+---------+-----------------+---------|
840 * | _ | 5b00001 |VID = | VID = |VID = |
841 * | V | ~ | DA_V_ALT| DA_V_ALT | DA_A_VLT|
842 * | _ | 5b11110 | | | |
843 * | A |----------+---------+-----------------+---------|
844 * | L | 5b11111 | No VID | VID = DA_V | NO VID |
846 * ------------------------------------------------------
848 #ifdef CONFIG_FSL_LSCH2
849 vid = (fusesr >> FSL_CHASSIS2_DCFG_FUSESR_ALTVID_SHIFT) &
850 FSL_CHASSIS2_DCFG_FUSESR_ALTVID_MASK;
851 if ((vid == 0) || (vid == FSL_CHASSIS2_DCFG_FUSESR_ALTVID_MASK)) {
852 vid = (fusesr >> FSL_CHASSIS2_DCFG_FUSESR_VID_SHIFT) &
853 FSL_CHASSIS2_DCFG_FUSESR_VID_MASK;
856 vid = (fusesr >> FSL_CORENET_DCFG_FUSESR_ALTVID_SHIFT) &
857 FSL_CORENET_DCFG_FUSESR_ALTVID_MASK;
858 if ((vid == 0) || (vid == FSL_CORENET_DCFG_FUSESR_ALTVID_MASK)) {
859 vid = (fusesr >> FSL_CORENET_DCFG_FUSESR_VID_SHIFT) &
860 FSL_CORENET_DCFG_FUSESR_VID_MASK;
863 vdd_target = vdd[vid];
865 /* check override variable for overriding VDD */
866 vdd_string = env_get(CONFIG_VID_FLS_ENV);
867 if (vdd_override == 0 && vdd_string &&
868 !strict_strtoul(vdd_string, 10, &vdd_string_override))
869 vdd_override = vdd_string_override;
870 if (vdd_override >= VDD_MV_MIN && vdd_override <= VDD_MV_MAX) {
871 vdd_target = vdd_override * 10; /* convert to 1/10 mV */
872 debug("VDD override is %lu\n", vdd_override);
873 } else if (vdd_override != 0) {
874 printf("Invalid value.\n");
876 if (vdd_target == 0) {
877 debug("VID: VID not used\n");
881 /* divide and round up by 10 to get a value in mV */
882 vdd_target = DIV_ROUND_UP(vdd_target, 10);
883 debug("VID: vid = %d mV\n", vdd_target);
887 * Read voltage monitor to check real voltage.
889 vdd_last = read_voltage(i2caddress);
891 printf("VID: Couldn't read sensor abort VID adjustment\n");
895 vdd_current = vdd_last;
896 debug("VID: Core voltage is currently at %d mV\n", vdd_last);
898 * Adjust voltage to at or one step above target.
899 * As measurements are less precise than setting the values
900 * we may run through dummy steps that cancel each other
901 * when stepping up and then down.
903 while (vdd_last > 0 &&
904 vdd_last < vdd_target) {
905 vdd_current += IR_VDD_STEP_UP;
906 vdd_last = set_voltage(i2caddress, vdd_current);
908 while (vdd_last > 0 &&
909 vdd_last > vdd_target + (IR_VDD_STEP_DOWN - 1)) {
910 vdd_current -= IR_VDD_STEP_DOWN;
911 vdd_last = set_voltage(i2caddress, vdd_current);
915 printf("VID: Core voltage after adjustment is at %d mV\n",
923 i2c_multiplexer_select_vid_channel(I2C_MUX_CH_DEFAULT);
929 static int print_vdd(void)
931 int vdd_last, ret, i2caddress = 0;
933 ret = i2c_multiplexer_select_vid_channel(I2C_MUX_CH_VOL_MONITOR);
935 debug("VID : I2c failed to switch channel\n");
938 #if defined(CONFIG_VOL_MONITOR_IR36021_SET) || \
939 defined(CONFIG_VOL_MONITOR_IR36021_READ)
940 ret = find_ir_chip_on_i2c();
942 printf("VID: Could not find voltage regulator on I2C.\n");
946 debug("VID: IR Chip found on I2C address 0x%02x\n", i2caddress);
951 * Read voltage monitor to check real voltage.
953 vdd_last = read_voltage(i2caddress);
955 printf("VID: Couldn't read sensor abort VID adjustment\n");
958 printf("VID: Core voltage is at %d mV\n", vdd_last);
960 i2c_multiplexer_select_vid_channel(I2C_MUX_CH_DEFAULT);
962 return ret < 0 ? -1 : 0;
966 static int do_vdd_override(struct cmd_tbl *cmdtp,
973 return CMD_RET_USAGE;
975 if (!strict_strtoul(argv[1], 10, &override))
976 adjust_vdd(override); /* the value is checked by callee */
978 return CMD_RET_USAGE;
982 static int do_vdd_read(struct cmd_tbl *cmdtp, int flag, int argc,
986 return CMD_RET_USAGE;
993 vdd_override, 2, 0, do_vdd_override,
995 " - override with the voltage specified in mV, eg. 1050"
999 vdd_read, 1, 0, do_vdd_read,
1001 " - Read the voltage specified in mV"