[PATCH] board: stm32pm1: Fix board_check_usb_power()
Patrice Chotard
patrice.chotard at foss.st.com
Tue Apr 14 11:06:50 CEST 2026
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().
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 at foss.st.com>
---
board/st/stm32mp1/stm32mp1.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 5f7c6822116..88ede4e3910 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -326,8 +326,8 @@ static int adc_measurement(ofnode node, int adc_count, int *min_uV, int *max_uV)
static int board_check_usb_power(void)
{
ofnode node;
- int max_uV = 0;
- int min_uV = USB_START_HIGH_THRESHOLD_UV;
+ int max_uV;
+ int min_uV;
int adc_count, ret;
u32 nb_blink;
u8 i;
@@ -358,6 +358,9 @@ static int board_check_usb_power(void)
/* perform maximum of 2 ADC measurements to detect power supply current */
for (i = 0; i < 2; i++) {
+ max_uV = 0;
+ min_uV = USB_START_HIGH_THRESHOLD_UV;
+
ret = adc_measurement(node, adc_count, &min_uV, &max_uV);
if (ret)
return ret;
---
base-commit: 88dc2788777babfd6322fa655df549a019aa1e69
change-id: 20260414-fix_usb_adc_meausurement-e4e9b7988ccb
Best regards,
--
Patrice Chotard <patrice.chotard at foss.st.com>
More information about the U-Boot
mailing list