Skip to content

Commit c3b06f2

Browse files
author
Patrice Chotard
committed
board: stm32pm1: Fix board_check_usb_power()
Depending of plugged power source (computer, wall charger, ...) it can happen that we got the following message: "****************************************************" "* USB TYPE-C charger not compliant with *" "* specification *" "****************************************************" " " "### ERROR ### Please RESET the board ### " This issue has been detected on STM32MP135f-DK board. It's due to max_uV and min_uV value are initialized at beginning of board_check_usb_power() and can then be used for the 2 iteration of adc_measurement(). In some cases, max_uV/min_uV values issued of the first adc_measurement() iteration are used as input of the second adc_measurement() iteration, which can lead to incoherent pair of min_uV/max_uV values. To ensure that adc_measurement() returns coherent value for max_uV and min_uV, initialize max_uV and min_uV at each loop start. Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Change-Id: I37a715d0e8614c0ca5658cce21d5034bfaae6393 Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/u-boot/+/558130 ACI: CIBUILD <MDG-smet-aci-builds@list.st.com>
1 parent a3643a2 commit c3b06f2

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

board/st/stm32mp1/stm32mp1.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,8 @@ static int adc_measurement(ofnode node, int adc_count, int *min_uV, int *max_uV)
372372
static int board_check_usb_power(void)
373373
{
374374
ofnode node;
375-
int max_uV = 0;
376-
int min_uV = USB_START_HIGH_THRESHOLD_UV;
375+
int max_uV;
376+
int min_uV;
377377
int adc_count, ret;
378378
u32 nb_blink;
379379
u8 i;
@@ -401,6 +401,9 @@ static int board_check_usb_power(void)
401401

402402
/* perform maximum of 2 ADC measurements to detect power supply current */
403403
for (i = 0; i < 2; i++) {
404+
max_uV = 0;
405+
min_uV = USB_START_HIGH_THRESHOLD_UV;
406+
404407
ret = adc_measurement(node, adc_count, &min_uV, &max_uV);
405408
if (ret)
406409
return ret;

0 commit comments

Comments
 (0)