diff options
author | Simon Glass <sjg@chromium.org> | 2021-01-07 14:37:33 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-09 05:11:07 +0000 |
commit | 6a5f6eb994f99fce764c5dedd834222eb82a28d1 (patch) | |
tree | d447f72c75a4209c3777e99a87f177d966980aa9 /baseboard | |
parent | 195d2d925def5f98e088b8b5ee2b1d61e3dc7040 (diff) | |
download | chrome-ec-6a5f6eb994f99fce764c5dedd834222eb82a28d1.tar.gz |
volteer: Separate out some baseboard USB-C config code
These three functions are needed by the charger task and are currently
not compiled on Zephyr. Move them out into their own file so that they
can be.
Update the isl9241 interface slightly to add a needed define.
BUG=b:175434113
BRANCH=none
TEST=make BOARD=volteer -j30
build volteer on zephyr
Change-Id: Ia28c406c865003d8aec1c31add590bfdef57601d
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2617038
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'baseboard')
-rw-r--r-- | baseboard/volteer/baseboard.c | 55 | ||||
-rw-r--r-- | baseboard/volteer/build.mk | 1 | ||||
-rw-r--r-- | baseboard/volteer/usbc_config.c | 76 |
3 files changed, 77 insertions, 55 deletions
diff --git a/baseboard/volteer/baseboard.c b/baseboard/volteer/baseboard.c index b08c5b4dd1..5552809c84 100644 --- a/baseboard/volteer/baseboard.c +++ b/baseboard/volteer/baseboard.c @@ -136,43 +136,6 @@ const struct temp_sensor_t temp_sensors[] = { }; BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); -/******************************************************************************/ -void tcpc_alert_event(enum gpio_signal signal) -{ - /* TODO: b/140572591 - check correct operation for Volteer */ - - int port = -1; - - switch (signal) { - case GPIO_USB_C0_TCPC_INT_ODL: - port = USBC_PORT_C0; - break; - case GPIO_USB_C1_TCPC_INT_ODL: - port = USBC_PORT_C1; - break; - default: - return; - } - - schedule_deferred_pd_interrupt(port); -} - -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); - break; - - case GPIO_USB_C1_BC12_INT_ODL: - task_set_event(TASK_ID_USB_CHG_P1, USB_CHG_EVENT_BC12); - break; - - default: - break; - } -} - static void baseboard_init(void) { /* Enable monitoring of the PROCHOT input to the EC */ @@ -218,21 +181,3 @@ static void cbi_init(void) } DECLARE_HOOK(HOOK_INIT, cbi_init, HOOK_PRIO_FIRST); -/** - * Return if VBUS is too low - */ -int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state) -{ - int voltage; - - if (charger_get_vbus_voltage(port, &voltage)) - voltage = 0; - - /* - * For legacy BC1.2 charging with CONFIG_CHARGE_RAMP_SW, ramp up input - * current until voltage drops to the minimum input voltage of the - * charger, 4.096V. - */ - return voltage < ISL9241_BC12_MIN_VOLTAGE; -} - diff --git a/baseboard/volteer/build.mk b/baseboard/volteer/build.mk index 5bb01f6abc..ae17954a69 100644 --- a/baseboard/volteer/build.mk +++ b/baseboard/volteer/build.mk @@ -12,3 +12,4 @@ baseboard-y+=charger.o baseboard-y+=usb_pd_policy.o baseboard-y+=cbi_ec_fw_config.o baseboard-y+=cbi_ssfc.o +baseboard-y+=usbc_config.o diff --git a/baseboard/volteer/usbc_config.c b/baseboard/volteer/usbc_config.c new file mode 100644 index 0000000000..79b06d2ac0 --- /dev/null +++ b/baseboard/volteer/usbc_config.c @@ -0,0 +1,76 @@ +/* Copyright 2021 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Volteer family-specific USB-C configuration */ + +#include "common.h" +#include "charge_manager.h" +#include "charge_ramp.h" +#include "charge_state.h" +#include "gpio.h" +#include "task.h" +#ifdef CONFIG_ZEPHYR +#include "usbc_config.h" +#endif +#include "usbc_ppc.h" +#include "usb_pd.h" +#include "usb_charge.h" +#include "util.h" +#include "driver/charger/isl9241_public.h" + +/******************************************************************************/ +void tcpc_alert_event(enum gpio_signal signal) +{ + /* TODO: b/140572591 - check correct operation for Volteer */ + + int port = -1; + + switch (signal) { + case GPIO_USB_C0_TCPC_INT_ODL: + port = USBC_PORT_C0; + break; + case GPIO_USB_C1_TCPC_INT_ODL: + port = USBC_PORT_C1; + break; + default: + return; + } + + schedule_deferred_pd_interrupt(port); +} + +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); + break; + + case GPIO_USB_C1_BC12_INT_ODL: + task_set_event(TASK_ID_USB_CHG_P1, USB_CHG_EVENT_BC12); + break; + + default: + break; + } +} + +/** + * Return if VBUS is too low + */ +int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state) +{ + int voltage; + + if (charger_get_vbus_voltage(port, &voltage)) + voltage = 0; + + /* + * For legacy BC1.2 charging with CONFIG_CHARGE_RAMP_SW, ramp up input + * current until voltage drops to the minimum input voltage of the + * charger, 4.096V. + */ + return voltage < ISL9241_BC12_MIN_VOLTAGE; +} |