From 9e79ca794904953cda23df3285579ea1a11c53ce Mon Sep 17 00:00:00 2001 From: Duncan Laurie Date: Fri, 22 Aug 2014 10:34:49 -0700 Subject: Support inverted ILIM_SEL for smart USB port power Some platforms may have active low ILIM_SEL that is per-port and the output needs to be inverted. BUG=chrome-os-partner:31549 BRANCH=samus TEST=emerge-samus chromeos-ec, not used until EVT Change-Id: I1e164d9aa46df119467113eb175e7deec4fd8a21 Signed-off-by: Duncan Laurie Reviewed-on: https://chromium-review.googlesource.com/213743 Reviewed-by: Alec Berg --- common/usb_port_power_smart.c | 11 +++++++++-- include/config.h | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/common/usb_port_power_smart.c b/common/usb_port_power_smart.c index 71390f45ab..9a8d3c7d75 100644 --- a/common/usb_port_power_smart.c +++ b/common/usb_port_power_smart.c @@ -66,10 +66,17 @@ static void usb_charge_set_enabled(int port_id, int en) static void usb_charge_set_ilim(int port_id, int sel) { -#ifdef CONFIG_USB_PORT_POWER_SMART_SIMPLE +#if defined(CONFIG_USB_PORT_POWER_SMART_SIMPLE) /* ILIM_SEL signal is shared and inverted */ - gpio_set_level(GPIO_USB_ILIM_SEL, sel ? 0 : 1); + gpio_set_level(GPIO_USB_ILIM_SEL, !sel); +#elif defined(CONFIG_USB_PORT_POWER_SMART_INVERTED) + /* ILIM_SEL signal is per-port and active low */ + if (port_id == 0) + gpio_set_level(GPIO_USB1_ILIM_SEL_L, !sel); + else + gpio_set_level(GPIO_USB2_ILIM_SEL_L, !sel); #else + /* ILIM_SEL is per-port and active high */ if (port_id == 0) gpio_set_level(GPIO_USB1_ILIM_SEL, sel); else diff --git a/include/config.h b/include/config.h index 2a5b6d6999..97a08aeb36 100644 --- a/include/config.h +++ b/include/config.h @@ -987,6 +987,12 @@ */ #undef CONFIG_USB_PORT_POWER_SMART_SIMPLE +/* + * Smart USB power control current limit pins may be inverted. In this case + * they are active low and the GPIO names will be GPIO_USBn_ILIM_SEL_L. + */ +#undef CONFIG_USB_PORT_POWER_SMART_INVERTED + /* Support the TSU6721 I2C smart switch */ #undef CONFIG_USB_SWITCH_TSU6721 -- cgit v1.2.1