summaryrefslogtreecommitdiff
path: root/driver/bc12
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2017-10-16 16:12:33 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-10-23 04:28:23 -0700
commit61a6a3814fe61c40bc733794c8a89640e668033d (patch)
treefa4f2771605bbb9499bd9013f45cd80b97c3e8a1 /driver/bc12
parentb6733343abb6d9b7ce7446b94f312dab51d46fac (diff)
downloadchrome-ec-61a6a3814fe61c40bc733794c8a89640e668033d.tar.gz
bq24392: Make chip_en active low.
The GPIO that turns on Vbus for the BQ24392 is active low. This commit changes the driver to make it clear that the enable is active low. Additionally, the 5V rail is turned on prior to performing detection and will be turned off if the AP is off. For zoombini, since the chipset task can also control the 5V rail, CONFIG_POWER_PP5000_CONTROL is enabled to do so in a task-safe way. BUG=b:65992382, b:65991615 BRANCH=None TEST=Verify that Vbus is turned on and the BQ24392 can output high on charge detect pin. Change-Id: Ib96ef9736ccc7fa285a3642ec6f3824a1df8f931 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/676762 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'driver/bc12')
-rw-r--r--driver/bc12/bq24392.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/driver/bc12/bq24392.c b/driver/bc12/bq24392.c
index db8a3702b1..23e9e99eb0 100644
--- a/driver/bc12/bq24392.c
+++ b/driver/bc12/bq24392.c
@@ -12,9 +12,13 @@
* the system will have to charge ramp.
*/
+#include "cannonlake.h"
#include "charge_manager.h"
+#include "chipset.h"
#include "common.h"
+#include "console.h"
#include "gpio.h"
+#include "power.h"
#include "task.h"
#include "tcpm.h"
#include "timer.h"
@@ -22,17 +26,17 @@
#include "util.h"
struct bq24392_pins {
- enum gpio_signal chip_enable;
+ enum gpio_signal chip_enable_l;
enum gpio_signal chg_det;
};
static const struct bq24392_pins pin_tbl[] = {
- { GPIO_USB_C0_BC12_VBUS_ON, GPIO_USB_C0_BC12_CHG_DET },
+ { GPIO_USB_C0_BC12_VBUS_ON_L, GPIO_USB_C0_BC12_CHG_DET },
#ifdef HAS_TASK_USB_CHG_P1
- { GPIO_USB_C1_BC12_VBUS_ON, GPIO_USB_C1_BC12_CHG_DET },
+ { GPIO_USB_C1_BC12_VBUS_ON_L, GPIO_USB_C1_BC12_CHG_DET },
#endif
#ifdef HAS_TASK_USB_CHG_P2
- { GPIO_USB_C2_BC12_VBUS_ON, GPIO_USB_C2_BC12_CHG_DET },
+ { GPIO_USB_C2_BC12_VBUS_ON_L, GPIO_USB_C2_BC12_CHG_DET },
#endif
};
@@ -47,9 +51,9 @@ static void bc12_detect(const int port)
/*
* Enable the IC to begin detection and connect switches if
- * necessary.
+ * necessary. Note, the value is 0 because the enable is active low.
*/
- gpio_set_level(pin_tbl[port].chip_enable, 1);
+ gpio_set_level(pin_tbl[port].chip_enable_l, 0);
new_chg.voltage = USB_CHARGER_VOLTAGE_MV;
#if defined(CONFIG_CHARGE_RAMP_SW) || defined(CONFIG_CHARGE_RAMP_HW)
@@ -88,7 +92,7 @@ static void power_down_ic(const int port)
struct charge_port_info no_chg = { 0 };
/* Turn off the IC. */
- gpio_set_level(pin_tbl[port].chip_enable, 0);
+ gpio_set_level(pin_tbl[port].chip_enable_l, 1);
/* Let charge manager know there's no more charge available. */
charge_manager_update_charge(CHARGE_SUPPLIER_OTHER, port, &no_chg);
@@ -109,10 +113,23 @@ static void detect_or_power_down_ic(const int port)
vbus_present = pd_snk_is_vbus_provided(port);
#endif /* !defined(CONFIG_USB_PD_VBUS_DETECT_TCPC) */
- if (vbus_present)
+ if (vbus_present) {
+ /* Turn on the 5V rail to allow the chip to be powered. */
+#ifdef CONFIG_POWER_PP5000_CONTROL
+ power_5v_enable(task_get_current(), 1);
+#else
+ gpio_set_level(GPIO_EN_PP5000, 1);
+#endif
bc12_detect(port);
- else
+ } else {
power_down_ic(port);
+#ifdef CONFIG_POWER_PP5000_CONTROL
+ /* Issue a request to turn off the rail. */
+ power_5v_enable(task_get_current(), 0);
+#else
+ gpio_set_level(GPIO_EN_PP5000, 0);
+#endif
+ }
}
void usb_charger_task(void *u)