summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorKarthikeyan Ramasubramanian <kramasub@google.com>2019-10-02 15:09:45 -0600
committerCommit Bot <commit-bot@chromium.org>2019-11-09 02:16:42 +0000
commit27db31e6d02a54d5706d8cb4d1b5db6ff757f659 (patch)
tree638e3c80f757205774cc62037b056dc9cab64132 /chip
parentffb96cd5ba990c8d6d91a044105eb225087781aa (diff)
downloadchrome-ec-27db31e6d02a54d5706d8cb4d1b5db6ff757f659.tar.gz
Add a board specific helper to return USB PD port count
Certain SKUs of certain boards have less number of USB PD ports than configured in CONFIG_USB_PD_PORT_MAX_COUNT. Hence define an overrideable board specific helper to return the number of USB PD ports. This helps to avoid initiating a PD firmware update in SKUs where there are less number of USB PD ports. Also update charge manager to ensure that absent/ invalid PD ports are skipped during port initialization and management. BUG=b:140816510, b:143196487 BRANCH=octopus TEST=make -j buildall; Boot to ChromeOS in bobba(2A + 2C config) and garg(2A + 1C + 1HDMI config). Change-Id: Ie345cef470ad878ec443ddf4797e5d17cfe1f61e Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1879338 Tested-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Karthikeyan Ramasubramanian <kramasub@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r--chip/mec1322/system.c26
-rw-r--r--chip/stm32/usb_pd_phy.c2
2 files changed, 21 insertions, 7 deletions
diff --git a/chip/mec1322/system.c b/chip/mec1322/system.c
index 6fa837f6f4..6dac6abfc6 100644
--- a/chip/mec1322/system.c
+++ b/chip/mec1322/system.c
@@ -17,6 +17,7 @@
#include "hooks.h"
#include "task.h"
#include "timer.h"
+#include "usb_pd.h"
#include "util.h"
#include "spi.h"
@@ -297,14 +298,27 @@ void system_hibernate(uint32_t seconds, uint32_t microseconds)
* Leave USB-C charging enabled in hibernate, in order to
* allow wake-on-plug. 5V enable must be pulled low.
*/
-#if CONFIG_USB_PD_PORT_MAX_COUNT > 0
- gpio_set_flags(GPIO_USB_C0_5V_EN, GPIO_PULL_DOWN | GPIO_INPUT);
- gpio_set_level(GPIO_USB_C0_CHARGE_EN_L, 0);
+ switch (board_get_usb_pd_port_count()) {
+#if CONFIG_USB_PD_PORT_MAX_COUNT >= 2
+ case 2:
+ gpio_set_flags(GPIO_USB_C1_5V_EN, GPIO_PULL_DOWN | GPIO_INPUT);
+ gpio_set_level(GPIO_USB_C1_CHARGE_EN_L, 0);
+ /* Fall through */
#endif
-#if CONFIG_USB_PD_PORT_MAX_COUNT > 1
- gpio_set_flags(GPIO_USB_C1_5V_EN, GPIO_PULL_DOWN | GPIO_INPUT);
- gpio_set_level(GPIO_USB_C1_CHARGE_EN_L, 0);
+#if CONFIG_USB_PD_PORT_MAX_COUNT >= 1
+ case 1:
+ gpio_set_flags(GPIO_USB_C0_5V_EN, GPIO_PULL_DOWN | GPIO_INPUT);
+ gpio_set_level(GPIO_USB_C0_CHARGE_EN_L, 0);
+ /* Fall through */
#endif
+ case 0:
+ /* Nothing to do but break */
+ break;
+ default:
+ /* More ports needs to be defined */
+ ASSERT(false);
+ break;
+ }
#endif /* CONFIG_USB_PD_PORT_MAX_COUNT */
if (hibernate_wake_pins_used > 0) {
diff --git a/chip/stm32/usb_pd_phy.c b/chip/stm32/usb_pd_phy.c
index 7296ae245f..426cac15d3 100644
--- a/chip/stm32/usb_pd_phy.c
+++ b/chip/stm32/usb_pd_phy.c
@@ -463,7 +463,7 @@ void pd_rx_handler(void)
}
#endif
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ for (i = 0; i < board_get_usb_pd_port_count(); i++) {
if (pending & EXTI_COMP_MASK(i)) {
rx_edge_ts[i][rx_edge_ts_idx[i]].val = get_time().val;
next_idx = (rx_edge_ts_idx[i] ==