mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 17:41:54 +00:00
kevin: Add USB charger tasks
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. Verify USB-C / PD charger detection continues to function. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I268bc6ec6b8a6a9b7340a5cb2b0d651b1b1659ce Reviewed-on: https://chromium-review.googlesource.com/349242 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
d5f676953e
commit
98d7bc87df
@@ -34,6 +34,7 @@
|
||||
#include "spi.h"
|
||||
#include "switch.h"
|
||||
#include "task.h"
|
||||
#include "tcpm.h"
|
||||
#include "timer.h"
|
||||
#include "thermal.h"
|
||||
#include "usb_charge.h"
|
||||
@@ -157,6 +158,12 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
|
||||
{I2C_PORT_TCPC1, FUSB302_I2C_SLAVE_ADDR, &fusb302_tcpm_drv},
|
||||
};
|
||||
|
||||
static const enum bd99955_charge_port
|
||||
pd_port_to_bd99955_port[CONFIG_USB_PD_PORT_COUNT] = {
|
||||
[0] = BD99955_CHARGE_PORT_VBUS,
|
||||
[1] = BD99955_CHARGE_PORT_VCC,
|
||||
};
|
||||
|
||||
void board_reset_pd_mcu(void)
|
||||
{
|
||||
}
|
||||
@@ -180,11 +187,8 @@ int board_set_active_charge_port(int charge_port)
|
||||
CPRINTS("New chg p%d", charge_port);
|
||||
|
||||
switch (charge_port) {
|
||||
case 0:
|
||||
bd99955_port = BD99955_CHARGE_PORT_VBUS;
|
||||
break;
|
||||
case 1:
|
||||
bd99955_port = BD99955_CHARGE_PORT_VCC;
|
||||
case 0: case 1:
|
||||
bd99955_port = pd_port_to_bd99955_port[charge_port];
|
||||
break;
|
||||
case CHARGE_PORT_NONE:
|
||||
bd99955_port = BD99955_CHARGE_PORT_NONE;
|
||||
@@ -209,36 +213,13 @@ int extpower_is_present(void)
|
||||
return bd99955_is_vbus_provided(BD99955_CHARGE_PORT_BOTH);
|
||||
}
|
||||
|
||||
int pd_snk_is_vbus_provided(int port)
|
||||
{
|
||||
return bd99955_is_vbus_provided(pd_port_to_bd99955_port[port]);
|
||||
}
|
||||
|
||||
static void board_init(void)
|
||||
{
|
||||
struct charge_port_info charge_none;
|
||||
int i;
|
||||
|
||||
/* Initialize all pericom charge suppliers to 0 */
|
||||
charge_none.voltage = USB_CHARGER_VOLTAGE_MV;
|
||||
charge_none.current = 0;
|
||||
/* TODO: Implement BC1.2 + VBUS detection */
|
||||
for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) {
|
||||
charge_manager_update_charge(CHARGE_SUPPLIER_PROPRIETARY,
|
||||
i,
|
||||
&charge_none);
|
||||
charge_manager_update_charge(CHARGE_SUPPLIER_BC12_CDP,
|
||||
i,
|
||||
&charge_none);
|
||||
charge_manager_update_charge(CHARGE_SUPPLIER_BC12_DCP,
|
||||
i,
|
||||
&charge_none);
|
||||
charge_manager_update_charge(CHARGE_SUPPLIER_BC12_SDP,
|
||||
i,
|
||||
&charge_none);
|
||||
charge_manager_update_charge(CHARGE_SUPPLIER_OTHER,
|
||||
i,
|
||||
&charge_none);
|
||||
charge_manager_update_charge(CHARGE_SUPPLIER_VBUS,
|
||||
i,
|
||||
&charge_none);
|
||||
}
|
||||
|
||||
/* Sensor Init */
|
||||
gpio_config_module(MODULE_SPI_MASTER, 1);
|
||||
spi_enable(CONFIG_SPI_ACCEL_PORT, 1);
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#define CONFIG_CHARGER_BD99955
|
||||
#define CONFIG_CHARGER_INPUT_CURRENT 512
|
||||
#define CONFIG_CHARGER_V2
|
||||
#define CONFIG_USB_CHARGER
|
||||
|
||||
/* Motion Sensors */
|
||||
#define CONFIG_ACCEL_BMA255
|
||||
@@ -65,6 +66,7 @@
|
||||
/* USB PD config */
|
||||
#define CONFIG_CHARGE_MANAGER
|
||||
#define CONFIG_USB_POWER_DELIVERY
|
||||
#define CONFIG_USB_PD_5V_EN_ACTIVE_LOW
|
||||
#define CONFIG_USB_PD_ALT_MODE
|
||||
#define CONFIG_USB_PD_ALT_MODE_DFP
|
||||
#define CONFIG_USB_PD_CUSTOM_VDM
|
||||
@@ -73,7 +75,7 @@
|
||||
#define CONFIG_USB_PD_LOG_SIZE 512
|
||||
#define CONFIG_USB_PD_PORT_COUNT 2
|
||||
#define CONFIG_USB_PD_TCPM_FUSB302
|
||||
#define CONFIG_USB_PD_VBUS_DETECT_TCPC
|
||||
#define CONFIG_USB_PD_VBUS_DETECT_CHARGER
|
||||
/* TODO: Enable TRY_SRC */
|
||||
#undef CONFIG_USB_PD_TRY_SRC
|
||||
|
||||
@@ -135,7 +137,6 @@
|
||||
EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEY_PRESSED) |\
|
||||
EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC))
|
||||
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
|
||||
enum adc_channel {
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
#define CONFIG_TASK_LIST \
|
||||
TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \
|
||||
TASK_ALWAYS(USB_CHG_P0, usb_charger_task, NULL, TASK_STACK_SIZE) \
|
||||
TASK_ALWAYS(USB_CHG_P1, usb_charger_task, NULL, 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(MOTIONSENSE, motion_sense_task, NULL, VENTI_TASK_STACK_SIZE) \
|
||||
|
||||
@@ -93,8 +93,8 @@ GPIO(LID_ACCEL_INT_L, PIN(C, 7), GPIO_INPUT | GPIO_PULL_UP)
|
||||
/* KSO2 is inverted */
|
||||
GPIO(KBD_KSO2, PIN(1, 7), GPIO_OUT_LOW)
|
||||
|
||||
GPIO(C0_VOUT_EN_L, PIN(D, 3), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN)
|
||||
GPIO(C1_VOUT_EN_L, PIN(D, 2), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN)
|
||||
GPIO(USB_C0_5V_EN_L, PIN(D, 3), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN)
|
||||
GPIO(USB_C1_5V_EN_L, PIN(D, 2), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN)
|
||||
|
||||
GPIO(ENTERING_RW, PIN(7, 6), GPIO_OUT_LOW)
|
||||
GPIO(SYS_RST_L, PIN(6, 1), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN)
|
||||
@@ -104,6 +104,7 @@ GPIO(EC_BOARD_ID_EN_L, PIN(3, 5), GPIO_OUT_HIGH)
|
||||
GPIO(USB_DP_HPD, PIN(6, 6), GPIO_OUT_LOW)
|
||||
GPIO(CHARGER_RESET_L, PIN(0, 1), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN)
|
||||
GPIO(CR50_RESET_L, PIN(0, 2), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN)
|
||||
/* TODO: Detect VBUS changes from charger interrupt and wake charger task. */
|
||||
GPIO(CHARGER_INT_L, PIN(3, 3), GPIO_INPUT)
|
||||
GPIO(EC_BATT_PRES_L, PIN(3, 4), GPIO_INPUT)
|
||||
GPIO(LID_360_L, PIN(3, 6), GPIO_INPUT | GPIO_SEL_1P8V)
|
||||
|
||||
@@ -55,8 +55,8 @@ int pd_set_power_supply_ready(int port)
|
||||
bd99955_select_input_port(BD99955_CHARGE_PORT_NONE);
|
||||
|
||||
/* Provide VBUS */
|
||||
gpio_set_level(port ? GPIO_C1_VOUT_EN_L :
|
||||
GPIO_C0_VOUT_EN_L, 0);
|
||||
gpio_set_level(port ? GPIO_USB_C1_5V_EN_L :
|
||||
GPIO_USB_C0_5V_EN_L, 0);
|
||||
|
||||
/* notify host of power info change */
|
||||
pd_send_host_event(PD_EVENT_POWER_CHANGE);
|
||||
@@ -67,8 +67,8 @@ int pd_set_power_supply_ready(int port)
|
||||
void pd_power_supply_reset(int port)
|
||||
{
|
||||
/* Disable VBUS */
|
||||
gpio_set_level(port ? GPIO_C1_VOUT_EN_L :
|
||||
GPIO_C0_VOUT_EN_L, 1);
|
||||
gpio_set_level(port ? GPIO_USB_C1_5V_EN_L :
|
||||
GPIO_USB_C0_5V_EN_L, 1);
|
||||
|
||||
/* notify host of power info change */
|
||||
pd_send_host_event(PD_EVENT_POWER_CHANGE);
|
||||
|
||||
Reference in New Issue
Block a user