charge_manager: Support no-BC1.2 configuration

If BC1.2 isn't supported, don't waste space + time checking for inputs
that don't exist.

BUG=chromium:759880
BRANCH=None
TEST=`make buildall -j`

Change-Id: I47e81451abd79a67a666d1859faf2610ee5c941a
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/663838
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
This commit is contained in:
Shawn Nematbakhsh
2017-09-13 10:47:37 -07:00
committed by chrome-bot
parent 86d5eb9b0a
commit c781609bfd
5 changed files with 12 additions and 33 deletions

View File

@@ -14,7 +14,6 @@
#include "button.h"
#include "charge_manager.h"
#include "charge_state.h"
#include "charge_ramp.h"
#include "charger.h"
#include "chipset.h"
#include "console.h"

View File

@@ -56,7 +56,6 @@
/* USB-A config */
/* USB PD config */
#define CONFIG_USB_CHARGER
#define CONFIG_USB_PD_DUAL_ROLE
#define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0
#define CONFIG_USB_PD_PORT_COUNT 2

View File

@@ -281,9 +281,6 @@ DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN,
static void board_init(void)
{
int i;
struct charge_port_info charge_none;
/* Enable TCPC alert interrupts */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_L);
@@ -297,34 +294,6 @@ static void board_init(void)
/* Sensor Init */
if (system_jumped_to_this_image() && chipset_in_state(CHIPSET_STATE_ON))
board_spi_enable();
/*
* Even if we don't support BC 1.2, we still need to initialize
* non-PD/USB-C charge suppliers to make charge manager seeded.
*/
charge_none.voltage = 0;
charge_none.current = 0;
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);
}
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);

View File

@@ -35,12 +35,14 @@ test_mockable const int supplier_priority[] = {
[CHARGE_SUPPLIER_DEDICATED] = 0,
#endif
[CHARGE_SUPPLIER_TYPEC] = 1,
#ifdef CHARGE_MANAGER_BC12
[CHARGE_SUPPLIER_PROPRIETARY] = 1,
[CHARGE_SUPPLIER_BC12_DCP] = 2,
[CHARGE_SUPPLIER_BC12_CDP] = 3,
[CHARGE_SUPPLIER_BC12_SDP] = 4,
[CHARGE_SUPPLIER_OTHER] = 5,
[CHARGE_SUPPLIER_VBUS] = 6
#endif
};
BUILD_ASSERT(ARRAY_SIZE(supplier_priority) == CHARGE_SUPPLIER_COUNT);
@@ -274,6 +276,7 @@ static void charge_manager_fill_power_info(int port,
case CHARGE_SUPPLIER_TYPEC:
r->type = USB_CHG_TYPE_C;
break;
#ifdef CHARGE_MANAGER_BC12
case CHARGE_SUPPLIER_PROPRIETARY:
r->type = USB_CHG_TYPE_PROPRIETARY;
break;
@@ -289,6 +292,7 @@ static void charge_manager_fill_power_info(int port,
case CHARGE_SUPPLIER_VBUS:
r->type = USB_CHG_TYPE_VBUS;
break;
#endif
#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0
case CHARGE_SUPPLIER_DEDICATED:
r->type = USB_CHG_TYPE_DEDICATED;

View File

@@ -17,6 +17,12 @@
#define CHARGE_CURRENT_UNINITIALIZED -1
#define CHARGE_VOLTAGE_UNINITIALIZED -1
/* Only track BC1.2 charge current if we support BC1.2 charging */
#if defined(HAS_TASK_USB_CHG) || defined(HAS_TASK_USB_CHG_P0) || \
defined(TEST_BUILD)
#define CHARGE_MANAGER_BC12
#endif
/**
* Time to delay for detecting the charger type (must be long enough for BC1.2
* driver to get supplier information and notify charge manager).
@@ -27,12 +33,14 @@
enum charge_supplier {
CHARGE_SUPPLIER_PD,
CHARGE_SUPPLIER_TYPEC,
#ifdef CHARGE_MANAGER_BC12
CHARGE_SUPPLIER_BC12_DCP,
CHARGE_SUPPLIER_BC12_CDP,
CHARGE_SUPPLIER_BC12_SDP,
CHARGE_SUPPLIER_PROPRIETARY,
CHARGE_SUPPLIER_OTHER,
CHARGE_SUPPLIER_VBUS,
#endif /* CHARGE_MANAGER_BC12 */
#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0
CHARGE_SUPPLIER_DEDICATED,
#endif