From 38c6a96e4470b3a6afb276a862ec77c0265f5a40 Mon Sep 17 00:00:00 2001 From: Caveh Jalali Date: Wed, 17 Feb 2021 02:46:43 -0800 Subject: common: Add board_is_usb_pd_port_present function This adds a new overridable function to check if a USB PD port exists on a system. This is preferred over using board_get_usb_pd_port_count() or CONFIG_USB_PD_PORT_MAX_COUNT because it handles sparse port numbering. The "missing" port no longer needs to be the highest numbered port and call sites no longer need to implement the special checks for this case. BRANCH=none BUG=b:173575131 TEST=buildall passes Change-Id: I3f74eddd99c6901b42ce05bab6f2bdd545127d1a Signed-off-by: Caveh Jalali Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2700313 Commit-Queue: Keith Short Reviewed-by: Abe Levkoy --- include/usb_pd.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/usb_pd.h') diff --git a/include/usb_pd.h b/include/usb_pd.h index a31fefbc3d..71d2449753 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -2899,6 +2899,15 @@ __override_proto uint8_t get_dp_pin_mode(int port); */ __override_proto uint8_t board_get_usb_pd_port_count(void); +/** + * Return true if specified PD port is present. This is similar to + * checking CONFIG_USB_PD_PORT_MAX_COUNT but handles sparse numbering. + * + * @param port USB-C port number + * + * @return true if port is present. + */ +__override_proto bool board_is_usb_pd_port_present(int port); /** * Resets external PD chips including TCPCs and MCUs. -- cgit v1.2.1