summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2016-06-02 12:59:11 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-06-02 22:25:46 -0700
commitfcc09a2b7d1d63ada5900bdc0a3206c748f7cbdd (patch)
treed842170f0949feafbe71064a13c678f77ef3f7ce /common
parent4b680119cc1de2dda7c0b625c4fea1d1e964189a (diff)
downloadchrome-ec-fcc09a2b7d1d63ada5900bdc0a3206c748f7cbdd.tar.gz
usb_charger: Support inverted 5V_EN GPIO polarity
Kevin uses inverted polarity (low = enable 5V output), so add a new CONFIG to support this. BUG=chrome-os-partner:53777 BRANCH=None TEST=Manual on Kevin. Enable USB charger tasks, verify that VBUS is properly detected on no-battery case. Change-Id: Ifb3e5fa9db1973d9826435712711f0cb0fd1d3a5 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/349260 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/usb_charger.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/common/usb_charger.c b/common/usb_charger.c
index 67dd612e36..a6b580072b 100644
--- a/common/usb_charger.c
+++ b/common/usb_charger.c
@@ -38,13 +38,19 @@ static void update_vbus_supplier(int port, int vbus_level)
}
}
+#ifdef CONFIG_USB_PD_5V_EN_ACTIVE_LOW
+#define USB_5V_EN(port) !gpio_get_level(GPIO_USB_C##port##_5V_EN_L)
+#else
+#define USB_5V_EN(port) gpio_get_level(GPIO_USB_C##port##_5V_EN)
+#endif
+
int usb_charger_port_is_sourcing_vbus(int port)
{
if (port == 0)
- return gpio_get_level(GPIO_USB_C0_5V_EN);
+ return USB_5V_EN(0);
#if CONFIG_USB_PD_PORT_COUNT >= 2
else if (port == 1)
- return gpio_get_level(GPIO_USB_C1_5V_EN);
+ return USB_5V_EN(1);
#endif
/* Not a valid port */
return 0;