summaryrefslogtreecommitdiff
path: root/board/lazor/board.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-03-22 15:56:13 +1300
committerCommit Bot <commit-bot@chromium.org>2021-03-24 04:53:26 +0000
commit60278c000562205e9795fe4b91594b6514d9c344 (patch)
treeef11ee94909d5a2ee2fbcb93677268a19b3492c2 /board/lazor/board.c
parentf29b02cb6132e874873c0cfee692cb877ec98522 (diff)
downloadchrome-ec-60278c000562205e9795fe4b91594b6514d9c344.tar.gz
lazor: Move some USB-C/charger handlers to usbc_config
Move some of these functions into the common file so that Zephyr can build them also. This covers the block at the bottom of the file, to make it easy to review. BUG=b:183296099 BRANCH=none TEST=make BOARD=lazor -j4 Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: I1cc7f241ca1529aa0c87c2d868afe799c0ee6ca6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2777639 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'board/lazor/board.c')
-rw-r--r--board/lazor/board.c130
1 files changed, 0 insertions, 130 deletions
diff --git a/board/lazor/board.c b/board/lazor/board.c
index 74ef41ad92..d8b1e6ec6c 100644
--- a/board/lazor/board.c
+++ b/board/lazor/board.c
@@ -8,8 +8,6 @@
#include "adc_chip.h"
#include "battery_fuel_gauge.h"
#include "button.h"
-#include "charge_manager.h"
-#include "charge_state.h"
#include "extpower.h"
#include "driver/accel_bma2x2.h"
#include "driver/accelgyro_bmi_common.h"
@@ -629,131 +627,3 @@ static void board_chipset_resume(void)
pwm_enable(PWM_CH_DISPLIGHT, 1);
}
DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT);
-
-void board_reset_pd_mcu(void)
-{
- cprints(CC_USB, "Resetting TCPCs...");
- cflush();
-
- gpio_set_level(GPIO_USB_C0_PD_RST_L, 0);
- gpio_set_level(GPIO_USB_C1_PD_RST_L, 0);
- msleep(PS8XXX_RESET_DELAY_MS);
- gpio_set_level(GPIO_USB_C0_PD_RST_L, 1);
- gpio_set_level(GPIO_USB_C1_PD_RST_L, 1);
-}
-
-void board_set_tcpc_power_mode(int port, int mode)
-{
- /* Ignore the "mode" to turn the chip on. We can only do a reset. */
- if (mode)
- return;
-
- board_reset_pd_mcu();
-}
-
-int board_vbus_sink_enable(int port, int enable)
-{
- /* Both ports are controlled by PPC SN5S330 */
- return ppc_vbus_sink_enable(port, enable);
-}
-
-int board_is_sourcing_vbus(int port)
-{
- /* Both ports are controlled by PPC SN5S330 */
- return ppc_is_sourcing_vbus(port);
-}
-
-void board_overcurrent_event(int port, int is_overcurrented)
-{
- /* TODO(b/120231371): Notify AP */
- CPRINTS("p%d: overcurrent!", port);
-}
-
-int board_set_active_charge_port(int port)
-{
- int is_real_port = (port >= 0 &&
- port < CONFIG_USB_PD_PORT_MAX_COUNT);
- int i;
-
- if (!is_real_port && port != CHARGE_PORT_NONE)
- return EC_ERROR_INVAL;
-
- if (port == CHARGE_PORT_NONE) {
- CPRINTS("Disabling all charging port");
-
- /* Disable all ports. */
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
- /*
- * Do not return early if one fails otherwise we can
- * get into a boot loop assertion failure.
- */
- if (board_vbus_sink_enable(i, 0))
- CPRINTS("Disabling p%d sink path failed.", i);
- }
-
- return EC_SUCCESS;
- }
-
- /* Check if the port is sourcing VBUS. */
- if (board_is_sourcing_vbus(port)) {
- CPRINTS("Skip enable p%d", port);
- return EC_ERROR_INVAL;
- }
-
-
- CPRINTS("New charge port: p%d", port);
-
- /*
- * Turn off the other ports' sink path FETs, before enabling the
- * requested charge port.
- */
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
- if (i == port)
- continue;
-
- if (board_vbus_sink_enable(i, 0))
- CPRINTS("p%d: sink path disable failed.", i);
- }
-
- /* Enable requested charge port. */
- if (board_vbus_sink_enable(port, 1)) {
- CPRINTS("p%d: sink path enable failed.", port);
- return EC_ERROR_UNKNOWN;
- }
-
- return EC_SUCCESS;
-}
-
-void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- /*
- * Ignore lower charge ceiling on PD transition if our battery is
- * critical, as we may brownout.
- */
- if (supplier == CHARGE_SUPPLIER_PD &&
- charge_ma < 1500 &&
- charge_get_percent() < CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON) {
- CPRINTS("Using max ilim %d", max_ma);
- charge_ma = max_ma;
- }
-
- charge_set_input_current_limit(MAX(charge_ma,
- CONFIG_CHARGER_INPUT_CURRENT),
- charge_mv);
-}
-
-uint16_t tcpc_get_alert_status(void)
-{
- uint16_t status = 0;
-
- if (!gpio_get_level(GPIO_USB_C0_PD_INT_ODL))
- if (gpio_get_level(GPIO_USB_C0_PD_RST_L))
- status |= PD_STATUS_TCPC_ALERT_0;
- if (!gpio_get_level(GPIO_USB_C1_PD_INT_ODL))
- if (gpio_get_level(GPIO_USB_C1_PD_RST_L))
- status |= PD_STATUS_TCPC_ALERT_1;
-
- return status;
-}
-