board: stm32pm1: update USB-C power detection algorithm on DK boards
authorPatrice Chotard <patrice.chotard@st.com>
Fri, 16 Oct 2020 07:28:59 +0000 (09:28 +0200)
committerPatrick Delaunay <patrick.delaunay@foss.st.com>
Wed, 13 Jan 2021 08:52:58 +0000 (09:52 +0100)
commit42082bc61b4646ef1e61ad01cfb4ffefc457db75
treea07a503071d188e3dce124a1e32f4dd55402a310
parent8396408e795cdf34fc8f622a01fdfb867fc05e54
board: stm32pm1: update USB-C power detection algorithm on DK boards

USB-C power supply which are Power Delivery compliant (USB-PD) are able
to provide different voltage/current (for example 5V/3A 9V/3A 12V/2.25A...)

In this case, the power supply need to negotiate the voltage/current to
use with the device using CC1/CC2 USB-C signals.

If this negotiation occurs during ADC measurement (done also on CC1/CC2
USB-C signals) some ADC acquisition can be corrupted which cause wrong
power supply current detection.

To avoid this, the power supply current detection algorithm is updated
as following:
  - perform an ADC measurement, if a 3A current is detected, continue the
    boot process.
  - else, wait 20ms (max tPDDebounce duration) to ensure that USB-PD
    negotiation is done and perform another ADC measurement.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
board/st/stm32mp1/stm32mp1.c