summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2019-02-05 17:42:32 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-02-19 22:15:19 -0800
commit3e9fe80cd030bd72d831f763f2ac873fe3f4c339 (patch)
treea8560ac71a800c9008a4ff5bc3186436cd927036
parent3e8588095bb0dda2aabc11fd7439083c073953f3 (diff)
downloadchrome-ec-3e9fe80cd030bd72d831f763f2ac873fe3f4c339.tar.gz
hatch: Enable bc1.2 support
This CL adds the config options and GPIO signals and interrupt handler required for bc1.2 for the pi3usb8201 chip. BUG=b:123995100 BRANCH=none TEST=Verified that bc1.2 detection occurs following connecting a charger and a EC reboot. Verified that the D+/D- switches are closed in both client and host mode as expected. Change-Id: I43ca74f02d2515dc4dfa3dd8dc689d719779e4b5 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/1459822 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
-rw-r--r--baseboard/hatch/baseboard.c17
-rw-r--r--baseboard/hatch/baseboard.h6
-rw-r--r--board/hatch/board.c18
-rw-r--r--board/hatch/ec.tasklist2
-rw-r--r--board/hatch/gpio.inc2
5 files changed, 44 insertions, 1 deletions
diff --git a/baseboard/hatch/baseboard.c b/baseboard/hatch/baseboard.c
index 326e1eb036..f1932989f2 100644
--- a/baseboard/hatch/baseboard.c
+++ b/baseboard/hatch/baseboard.c
@@ -10,6 +10,7 @@
#include "charge_state_v2.h"
#include "chipset.h"
#include "console.h"
+#include "driver/bc12/pi3usb9201.h"
#include "driver/ppc/sn5s330.h"
#include "driver/tcpm/anx7447.h"
#include "driver/tcpm/ps8xxx.h"
@@ -188,6 +189,18 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
}
};
+const struct pi3usb2901_config_t pi3usb2901_bc12_chips[] = {
+ [USB_PD_PORT_TCPC_0] = {
+ .i2c_port = I2C_PORT_PPC0,
+ .i2c_addr = PI3USB9201_I2C_ADDR_3,
+ },
+
+ [USB_PD_PORT_TCPC_1] = {
+ .i2c_port = I2C_PORT_TCPC1,
+ .i2c_addr = PI3USB9201_I2C_ADDR_3,
+ },
+};
+
/* GPIO to enable/disable the USB Type-A port. */
const int usb_port_enable[CONFIG_USB_PORT_POWER_SMART_PORT_COUNT] = {
GPIO_EN_USB_A_5V,
@@ -207,6 +220,10 @@ void baseboard_tcpc_init(void)
/* Enable HDMI HPD interrupt. */
gpio_enable_interrupt(GPIO_HDMI_CONN_HPD);
+
+ /* Enable BC 1.2 interrupts */
+ gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_ODL);
+ gpio_enable_interrupt(GPIO_USB_C1_BC12_INT_ODL);
}
DECLARE_HOOK(HOOK_INIT, baseboard_tcpc_init, HOOK_PRIO_INIT_I2C + 1);
diff --git a/baseboard/hatch/baseboard.h b/baseboard/hatch/baseboard.h
index bab9147ae0..9095973e1e 100644
--- a/baseboard/hatch/baseboard.h
+++ b/baseboard/hatch/baseboard.h
@@ -49,7 +49,7 @@
/* Common charger defines */
#define CONFIG_CHARGE_MANAGER
-/* #define CONFIG_CHARGE_RAMP_HW */
+#define CONFIG_CHARGE_RAMP_HW
#define CONFIG_CHARGER
#define CONFIG_CHARGER_BQ25710
#define CONFIG_CHARGER_DISCHARGE_ON_AC
@@ -98,6 +98,10 @@
#define CONFIG_CMD_PD_CONTROL
#define CONFIG_CMD_PPC_DUMP
+/* BC 1.2 */
+#define CONFIG_USB_CHARGER
+#define CONFIG_BC12_DETECT_PI3USB9201
+
/* USB Type A Features */
#define CONFIG_USB_PORT_POWER_SMART
#undef CONFIG_USB_PORT_POWER_SMART_PORT_COUNT
diff --git a/board/hatch/board.c b/board/hatch/board.c
index 21ff639892..9bac034d31 100644
--- a/board/hatch/board.c
+++ b/board/hatch/board.c
@@ -24,10 +24,12 @@
#include "spi.h"
#include "switch.h"
#include "system.h"
+#include "task.h"
#include "temp_sensor.h"
#include "thermal.h"
#include "thermistor.h"
#include "uart.h"
+#include "usb_charge.h"
#include "usb_pd.h"
#include "usbc_ppc.h"
#include "util.h"
@@ -74,6 +76,22 @@ static void hdmi_hpd_interrupt(enum gpio_signal signal)
baseboard_mst_enable_control(MST_HDMI, gpio_get_level(signal));
}
+static void bc12_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_USB_C0_BC12_INT_ODL:
+ task_set_event(TASK_ID_USB_CHG_P0, USB_CHG_EVENT_BC12, 0);
+ break;
+
+ case GPIO_USB_C1_BC12_INT_ODL:
+ task_set_event(TASK_ID_USB_CHG_P1, USB_CHG_EVENT_BC12, 0);
+ break;
+
+ default:
+ break;
+ }
+}
+
#include "gpio_list.h" /* Must come after other header files. */
/******************************************************************************/
diff --git a/board/hatch/ec.tasklist b/board/hatch/ec.tasklist
index c7d1ef8c9e..55f289ad47 100644
--- a/board/hatch/ec.tasklist
+++ b/board/hatch/ec.tasklist
@@ -22,6 +22,8 @@
#define CONFIG_TASK_LIST \
TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \
+ TASK_ALWAYS(USB_CHG_P0, usb_charger_task, 0, LARGER_TASK_STACK_SIZE) \
+ TASK_ALWAYS(USB_CHG_P1, usb_charger_task, 1, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(CHARGER, charger_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_NOTEST(CHIPSET, chipset_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, TASK_STACK_SIZE) \
diff --git a/board/hatch/gpio.inc b/board/hatch/gpio.inc
index d6e77f795a..cf2fb6a840 100644
--- a/board/hatch/gpio.inc
+++ b/board/hatch/gpio.inc
@@ -28,6 +28,8 @@ GPIO_INT(USB_C0_PPC_INT_ODL, PIN(E, 0), GPIO_INT_FALLING, ppc_interrupt)
GPIO_INT(USB_C1_PPC_INT_ODL, PIN(A, 2), GPIO_INT_FALLING, ppc_interrupt)
GPIO_INT(USB_C0_TCPC_INT_ODL, PIN(6, 2), GPIO_INT_FALLING, tcpc_alert_event)
GPIO_INT(USB_C1_TCPC_INT_ODL, PIN(F, 5), GPIO_INT_FALLING, tcpc_alert_event)
+GPIO_INT(USB_C0_BC12_INT_ODL, PIN(9, 5), GPIO_INT_FALLING, bc12_interrupt)
+GPIO_INT(USB_C1_BC12_INT_ODL, PIN(E, 4), GPIO_INT_FALLING, bc12_interrupt)
GPIO_INT(HDMI_CONN_HPD, PIN(7, 2), GPIO_INT_BOTH, hdmi_hpd_interrupt)
/*