summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2020-04-15 16:10:18 -0600
committerCommit Bot <commit-bot@chromium.org>2020-04-21 20:49:00 +0000
commitd2b73ad856c4ba697a2dfd8c4bf4263ffc18a5ce (patch)
tree0057371a0638615ddd6d00b4529eb5b5bf905fcd
parented6bc5e1bc86bfa9bf5d436fd77c14ad4d6068cb (diff)
downloadchrome-ec-d2b73ad856c4ba697a2dfd8c4bf4263ffc18a5ce.tar.gz
Dedede: Move waddledee chips out of baseboard
Moves chip specifics (ex. charger, TCPC) from baseboard out to the waddledee board files in anticipation of Wheelie. BRANCH=None BUG=None TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I99bf33d683cc89e6508fbbe305cd0b4c05a53090 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2157949 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--baseboard/dedede/baseboard.h11
-rw-r--r--baseboard/dedede/variant_ec_it8320.c247
-rw-r--r--board/waddledee/board.c175
-rw-r--r--board/waddledee/board.h26
-rw-r--r--board/waddledee/build.mk2
-rw-r--r--board/waddledee/usb_pd_policy.c84
6 files changed, 280 insertions, 265 deletions
diff --git a/baseboard/dedede/baseboard.h b/baseboard/dedede/baseboard.h
index 5040d45b45..95900c03c1 100644
--- a/baseboard/dedede/baseboard.h
+++ b/baseboard/dedede/baseboard.h
@@ -56,18 +56,7 @@
#define CONFIG_ADC_VOLTAGE_COMPARATOR /* ITE ADC thresholds */
- #define CONFIG_CHARGER_SM5803 /* C0 and C1: Charger */
- #define CONFIG_FPU /* For charger calculations */
- #define CONFIG_USB_PD_VBUS_DETECT_CHARGER
- #define CONFIG_USB_PD_5V_CHARGER_CTRL
- #define CONFIG_CHARGER_OTG
-
#define CONFIG_DAC /* DAC for PSYS */
-
- #define CONFIG_USB_PD_TCPM_ITE_ON_CHIP /* C0: ITE EC TCPC */
- #define CONFIG_USB_PD_TCPM_ANX7447 /* C1: ANX TCPC + Mux */
- #define CONFIG_BC12_DETECT_PI3USB9201 /* BC 1.2 */
- #define CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT 1
#else
#error "Must define a VARIANT_DEDEDE_EC!"
#endif
diff --git a/baseboard/dedede/variant_ec_it8320.c b/baseboard/dedede/variant_ec_it8320.c
index ed1d13b360..62a5f3f32a 100644
--- a/baseboard/dedede/variant_ec_it8320.c
+++ b/baseboard/dedede/variant_ec_it8320.c
@@ -7,26 +7,14 @@
#include "adc_chip.h"
#include "atomic.h"
-#include "charge_manager.h"
-#include "charge_state_v2.h"
-#include "charger.h"
-#include "chipset.h"
#include "common.h"
#include "compile_time_macros.h"
#include "console.h"
-#include "driver/bc12/pi3usb9201.h"
-#include "driver/charger/sm5803.h"
-#include "driver/tcpm/anx7447.h"
-#include "driver/tcpm/it83xx_pd.h"
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
#include "power.h"
-#include "pwm.h"
-#include "pwm_chip.h"
#include "registers.h"
-#include "tcpci.h"
-#include "usb_pd_tcpm.h"
#define CPRINTUSB(format, args...) cprints(CC_USBCHARGE, format, ## args)
@@ -101,33 +89,6 @@ const struct vcmp_t vcmp_list[] = {
BUILD_ASSERT(ARRAY_SIZE(vcmp_list) <= CHIP_VCMP_COUNT);
BUILD_ASSERT(ARRAY_SIZE(vcmp_list) == VCMP_COUNT);
-/* BC12 chips */
-const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = {
- {
- .i2c_port = I2C_PORT_USB_C0,
- .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS,
- },
- {
- .i2c_port = I2C_PORT_SUB_USB_C1,
- .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS,
- },
-};
-
-/* Charger chips */
-const struct charger_config_t chg_chips[] = {
- [CHARGER_PRIMARY] = {
- .i2c_port = I2C_PORT_USB_C0,
- .i2c_addr_flags = SM5803_ADDR_CHARGER_FLAGS,
- .drv = &sm5803_drv,
- },
- [CHARGER_SECONDARY] = {
- .i2c_port = I2C_PORT_SUB_USB_C1,
- .i2c_addr_flags = SM5803_ADDR_CHARGER_FLAGS,
- .drv = &sm5803_drv,
- },
-};
-const unsigned int chg_cnt = ARRAY_SIZE(chg_chips);
-
/* I2C Ports */
const struct i2c_port_t i2c_ports[] = {
{
@@ -157,211 +118,3 @@ const struct i2c_port_t i2c_ports[] = {
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
-/* TCPCs */
-const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {
- .bus_type = EC_BUS_TYPE_EMBEDDED,
- .drv = &it83xx_tcpm_drv,
- },
- {
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_SUB_USB_C1,
- .addr_flags = AN7447_TCPC0_I2C_ADDR_FLAGS,
- },
- .drv = &anx7447_tcpm_drv,
- .flags = TCPC_FLAGS_TCPCI_REV2_0,
- },
-};
-
-uint16_t tcpc_get_alert_status(void)
-{
- /*
- * TCPC 0 is embedded in the EC and processes interrupts in the chip
- * code (it83xx/intc.c)
- */
-
- uint16_t status = 0;
- int regval;
-
- /* Check whether TCPC 1 pulled the shared interrupt line */
- if (!gpio_get_level(GPIO_USB_C1_INT_ODL)) {
- if (!tcpc_read16(1, TCPC_REG_ALERT, &regval)) {
- if (regval)
- status = PD_STATUS_TCPC_ALERT_1;
- }
- }
-
- return status;
-}
-
-int extpower_is_present(void)
-{
- int chg0 = 0;
- int chg1 = 0;
-
- sm5803_get_chg_det(0, &chg0);
- sm5803_get_chg_det(1, &chg1);
-
- return chg0 || chg1;
-}
-
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * TODO(b/151955431): Characterize the input current limit in case a
- * scaling needs to be applied here
- */
- charge_set_input_current_limit(icl, charge_mv);
-}
-
-int board_set_active_charge_port(int port)
-{
- int is_valid_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
- int p0_otg, p1_otg;
-
- if (!is_valid_port && port != CHARGE_PORT_NONE)
- return EC_ERROR_INVAL;
-
- /* TODO(b/147440290): charger functions should take chgnum */
- p0_otg = chg_chips[0].drv->is_sourcing_otg_power(0, 0);
- p1_otg = chg_chips[1].drv->is_sourcing_otg_power(1, 1);
-
- if (port == CHARGE_PORT_NONE) {
- CPRINTUSB("Disabling all charge ports");
-
- if (!p0_otg)
- chg_chips[0].drv->set_mode(0,
- CHARGE_FLAG_INHIBIT_CHARGE);
- if (!p1_otg)
- chg_chips[1].drv->set_mode(1,
- CHARGE_FLAG_INHIBIT_CHARGE);
-
- return EC_SUCCESS;
- }
-
- CPRINTUSB("New chg p%d", port);
-
- /*
- * Charger task will take care of enabling charging on the new charge
- * port. Here, we ensure the other port is not charging by changing
- * CHG_EN
- */
- if (port == 0) {
- if (p0_otg) {
- CPRINTUSB("Skip enable p%d", port);
- return EC_ERROR_INVAL;
- }
- if (!p1_otg) {
- chg_chips[1].drv->set_mode(1,
- CHARGE_FLAG_INHIBIT_CHARGE);
- }
- } else {
- if (p1_otg) {
- CPRINTUSB("Skip enable p%d", port);
- return EC_ERROR_INVAL;
- }
- if (!p0_otg) {
- chg_chips[0].drv->set_mode(0,
- CHARGE_FLAG_INHIBIT_CHARGE);
- }
- }
-
- return EC_SUCCESS;
-}
-
-/* Vconn control for integrated ITE TCPC */
-void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled)
-{
- /* Vconn control is only for port 0 */
- if (port)
- return;
-
- if (cc_pin == USBPD_CC_PIN_1)
- gpio_set_level(GPIO_EN_USB_C0_CC1_VCONN, !!enabled);
- else
- gpio_set_level(GPIO_EN_USB_C0_CC2_VCONN, !!enabled);
-}
-
-__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
-{
- int current;
-
- if (port < 0 || port > CONFIG_USB_PD_PORT_MAX_COUNT)
- return;
-
- current = (rp == TYPEC_RP_3A0) ? 3000 : 1500;
-
- chg_chips[port].drv->set_otg_current_voltage(port, current, 5000);
-}
-
-
-int pd_check_vconn_swap(int port)
-{
- /* Allow VCONN swaps if the AP is on */
- return chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON);
-}
-
-void pd_power_supply_reset(int port)
-{
- int prev_en;
-
- if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT)
- return;
-
- /* TODO(b/147440290): charger functions should take chgnum */
- prev_en = chg_chips[port].drv->is_sourcing_otg_power(port, port);
-
- /* Disable Vbus */
- chg_chips[port].drv->enable_otg_power(port, 0);
-
- /* Discharge Vbus if previously enabled */
- if (prev_en)
- sm5803_set_vbus_disch(port, 1);
-
-#ifdef CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT
- /* Give back the current quota we are no longer using */
- charge_manager_source_port(port, 0);
-#endif /* defined(CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT) */
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-}
-
-int pd_set_power_supply_ready(int port)
-{
- enum ec_error_list rv;
-
- /* Disable charging */
- rv = chg_chips[port].drv->set_mode(port, CHARGE_FLAG_INHIBIT_CHARGE);
- if (rv)
- return rv;
-
- /* Disable Vbus discharge */
- sm5803_set_vbus_disch(port, 0);
-
- /* Provide Vbus */
- chg_chips[port].drv->enable_otg_power(port, 1);
-
-#ifdef CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT
- /* Ensure we advertise the proper available current quota */
- charge_manager_source_port(port, 1);
-#endif /* defined(CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT) */
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-
- return EC_SUCCESS;
-}
-
-int pd_snk_is_vbus_provided(int port)
-{
- int chg_det = 0;
-
- sm5803_get_chg_det(port, &chg_det);
-
- return chg_det;
-}
diff --git a/board/waddledee/board.c b/board/waddledee/board.c
index 0abcb200c1..7699c99b3a 100644
--- a/board/waddledee/board.c
+++ b/board/waddledee/board.c
@@ -6,13 +6,18 @@
/* Waddledee board-specific configuration */
#include "button.h"
+#include "charge_manager.h"
+#include "charge_state_v2.h"
+#include "charger.h"
#include "driver/accel_lis2dh.h"
#include "driver/accelgyro_lsm6dsm.h"
+#include "driver/bc12/pi3usb9201.h"
#include "driver/charger/sm5803.h"
#include "driver/sync.h"
#include "driver/retimer/tusb544.h"
#include "driver/temp_sensor/thermistor.h"
#include "driver/tcpm/anx7447.h"
+#include "driver/tcpm/it83xx_pd.h"
#include "driver/usb_mux/it5205.h"
#include "gpio.h"
#include "hooks.h"
@@ -26,11 +31,13 @@
#include "switch.h"
#include "tablet_mode.h"
#include "task.h"
+#include "tcpci.h"
#include "temp_sensor.h"
#include "uart.h"
#include "usb_charge.h"
#include "usb_mux.h"
#include "usb_pd.h"
+#include "usb_pd_tcpm.h"
#define CPRINTUSB(format, args...) cprints(CC_USBCHARGE, format, ## args)
@@ -58,6 +65,50 @@ static void c0_ccsbu_ovp_interrupt(enum gpio_signal s)
/* Must come after other header files and interrupt handler declarations */
#include "gpio_list.h"
+/* BC 1.2 chips */
+const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = {
+ {
+ .i2c_port = I2C_PORT_USB_C0,
+ .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS,
+ },
+ {
+ .i2c_port = I2C_PORT_SUB_USB_C1,
+ .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS,
+ },
+};
+
+/* Charger chips */
+const struct charger_config_t chg_chips[] = {
+ [CHARGER_PRIMARY] = {
+ .i2c_port = I2C_PORT_USB_C0,
+ .i2c_addr_flags = SM5803_ADDR_CHARGER_FLAGS,
+ .drv = &sm5803_drv,
+ },
+ [CHARGER_SECONDARY] = {
+ .i2c_port = I2C_PORT_SUB_USB_C1,
+ .i2c_addr_flags = SM5803_ADDR_CHARGER_FLAGS,
+ .drv = &sm5803_drv,
+ },
+};
+const unsigned int chg_cnt = ARRAY_SIZE(chg_chips);
+
+/* TCPCs */
+const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+ {
+ .bus_type = EC_BUS_TYPE_EMBEDDED,
+ .drv = &it83xx_tcpm_drv,
+ },
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_SUB_USB_C1,
+ .addr_flags = AN7447_TCPC0_I2C_ADDR_FLAGS,
+ },
+ .drv = &anx7447_tcpm_drv,
+ .flags = TCPC_FLAGS_TCPCI_REV2_0,
+ },
+};
+
/* USB Retimer */
const struct usb_mux usbc1_retimer = {
.usb_port = 1,
@@ -123,6 +174,130 @@ __override void board_power_5v_enable(int enable)
CPRINTUSB("Failed to %sable sub rails!", enable ? "en" : "dis");
}
+uint16_t tcpc_get_alert_status(void)
+{
+ /*
+ * TCPC 0 is embedded in the EC and processes interrupts in the chip
+ * code (it83xx/intc.c)
+ */
+
+ uint16_t status = 0;
+ int regval;
+
+ /* Check whether TCPC 1 pulled the shared interrupt line */
+ if (!gpio_get_level(GPIO_USB_C1_INT_ODL)) {
+ if (!tcpc_read16(1, TCPC_REG_ALERT, &regval)) {
+ if (regval)
+ status = PD_STATUS_TCPC_ALERT_1;
+ }
+ }
+
+ return status;
+}
+
+int extpower_is_present(void)
+{
+ int chg0 = 0;
+ int chg1 = 0;
+
+ sm5803_get_chg_det(0, &chg0);
+ sm5803_get_chg_det(1, &chg1);
+
+ return chg0 || chg1;
+}
+
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
+ int charge_mv)
+{
+ int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
+
+ /*
+ * TODO(b/151955431): Characterize the input current limit in case a
+ * scaling needs to be applied here
+ */
+ charge_set_input_current_limit(icl, charge_mv);
+}
+
+int board_set_active_charge_port(int port)
+{
+ int is_valid_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
+ int p0_otg, p1_otg;
+
+ if (!is_valid_port && port != CHARGE_PORT_NONE)
+ return EC_ERROR_INVAL;
+
+ /* TODO(b/147440290): charger functions should take chgnum */
+ p0_otg = chg_chips[0].drv->is_sourcing_otg_power(0, 0);
+ p1_otg = chg_chips[1].drv->is_sourcing_otg_power(1, 1);
+
+ if (port == CHARGE_PORT_NONE) {
+ CPRINTUSB("Disabling all charge ports");
+
+ if (!p0_otg)
+ chg_chips[0].drv->set_mode(0,
+ CHARGE_FLAG_INHIBIT_CHARGE);
+ if (!p1_otg)
+ chg_chips[1].drv->set_mode(1,
+ CHARGE_FLAG_INHIBIT_CHARGE);
+
+ return EC_SUCCESS;
+ }
+
+ CPRINTUSB("New chg p%d", port);
+
+ /*
+ * Charger task will take care of enabling charging on the new charge
+ * port. Here, we ensure the other port is not charging by changing
+ * CHG_EN
+ */
+ if (port == 0) {
+ if (p0_otg) {
+ CPRINTUSB("Skip enable p%d", port);
+ return EC_ERROR_INVAL;
+ }
+ if (!p1_otg) {
+ chg_chips[1].drv->set_mode(1,
+ CHARGE_FLAG_INHIBIT_CHARGE);
+ }
+ } else {
+ if (p1_otg) {
+ CPRINTUSB("Skip enable p%d", port);
+ return EC_ERROR_INVAL;
+ }
+ if (!p0_otg) {
+ chg_chips[0].drv->set_mode(0,
+ CHARGE_FLAG_INHIBIT_CHARGE);
+ }
+ }
+
+ return EC_SUCCESS;
+}
+
+/* Vconn control for integrated ITE TCPC */
+void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled)
+{
+ /* Vconn control is only for port 0 */
+ if (port)
+ return;
+
+ if (cc_pin == USBPD_CC_PIN_1)
+ gpio_set_level(GPIO_EN_USB_C0_CC1_VCONN, !!enabled);
+ else
+ gpio_set_level(GPIO_EN_USB_C0_CC2_VCONN, !!enabled);
+}
+
+__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
+{
+ int current;
+
+ if (port < 0 || port > CONFIG_USB_PD_PORT_MAX_COUNT)
+ return;
+
+ current = (rp == TYPEC_RP_3A0) ? 3000 : 1500;
+
+ chg_chips[port].drv->set_otg_current_voltage(port, current, 5000);
+}
+
/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
const struct pwm_t pwm_channels[] = {
[PWM_CH_KBLIGHT] = {
diff --git a/board/waddledee/board.h b/board/waddledee/board.h
index 234e7f795b..560f8edec0 100644
--- a/board/waddledee/board.h
+++ b/board/waddledee/board.h
@@ -18,6 +18,16 @@
/* Battery */
#define CONFIG_BATTERY_FUEL_GAUGE
+/* BC 1.2 */
+#define CONFIG_BC12_DETECT_PI3USB9201
+
+/* Charger */
+#define CONFIG_CHARGER_SM5803 /* C0 and C1: Charger */
+#define CONFIG_FPU /* For charger calculations */
+#define CONFIG_USB_PD_VBUS_DETECT_CHARGER
+#define CONFIG_USB_PD_5V_CHARGER_CTRL
+#define CONFIG_CHARGER_OTG
+
/* LED */
#define CONFIG_LED_PWM_COUNT 1
@@ -47,12 +57,10 @@
#define CONFIG_TABLET_MODE_SWITCH
#define CONFIG_GMR_TABLET_MODE
-/* USB Mux and Retimer */
-#define CONFIG_USB_MUX_IT5205 /* C1: ITE Mux */
-#define I2C_PORT_USB_MUX I2C_PORT_USB_C0 /* Required for ITE Mux */
-
-#define CONFIG_USBC_RETIMER_TUSB544 /* C1 Redriver: TUSB544 */
-
+/* TCPC */
+#define CONFIG_USB_PD_TCPM_ITE_ON_CHIP /* C0: ITE EC TCPC */
+#define CONFIG_USB_PD_TCPM_ANX7447 /* C1: ANX TCPC + Mux */
+#define CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT 1
/* Thermistors */
#define CONFIG_TEMP_SENSOR
@@ -60,6 +68,12 @@
#define CONFIG_STEINHART_HART_3V3_51K1_47K_4050B
#define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_EN_PP3300_A
+/* USB Mux and Retimer */
+#define CONFIG_USB_MUX_IT5205 /* C1: ITE Mux */
+#define I2C_PORT_USB_MUX I2C_PORT_USB_C0 /* Required for ITE Mux */
+
+#define CONFIG_USBC_RETIMER_TUSB544 /* C1 Redriver: TUSB544 */
+
#ifndef __ASSEMBLER__
#include "gpio_signal.h"
diff --git a/board/waddledee/build.mk b/board/waddledee/build.mk
index 0450a2d57f..00e4e0bb5d 100644
--- a/board/waddledee/build.mk
+++ b/board/waddledee/build.mk
@@ -11,5 +11,5 @@ CHIP_FAMILY:=it8320
CHIP_VARIANT:=it8320dx
BASEBOARD:=dedede
-board-y=board.o led.o
+board-y=board.o led.o usb_pd_policy.o
board-$(CONFIG_BATTERY_SMART)+=battery.o
diff --git a/board/waddledee/usb_pd_policy.c b/board/waddledee/usb_pd_policy.c
new file mode 100644
index 0000000000..1611af23e0
--- /dev/null
+++ b/board/waddledee/usb_pd_policy.c
@@ -0,0 +1,84 @@
+/* Copyright 2020 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.
+ */
+
+#include "battery_smart.h"
+#include "charge_manager.h"
+#include "charger.h"
+#include "chipset.h"
+#include "common.h"
+#include "console.h"
+#include "driver/charger/sm5803.h"
+#include "driver/tcpm/tcpci.h"
+#include "usb_pd.h"
+
+#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args)
+
+int pd_check_vconn_swap(int port)
+{
+ /* Allow VCONN swaps if the AP is on */
+ return chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON);
+}
+
+void pd_power_supply_reset(int port)
+{
+ int prev_en;
+
+ if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT)
+ return;
+
+ /* TODO(b/147440290): charger functions should take chgnum */
+ prev_en = chg_chips[port].drv->is_sourcing_otg_power(port, port);
+
+ /* Disable Vbus */
+ chg_chips[port].drv->enable_otg_power(port, 0);
+
+ /* Discharge Vbus if previously enabled */
+ if (prev_en)
+ sm5803_set_vbus_disch(port, 1);
+
+#ifdef CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT
+ /* Give back the current quota we are no longer using */
+ charge_manager_source_port(port, 0);
+#endif /* defined(CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT) */
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+}
+
+int pd_set_power_supply_ready(int port)
+{
+ enum ec_error_list rv;
+
+ /* Disable charging */
+ rv = chg_chips[port].drv->set_mode(port, CHARGE_FLAG_INHIBIT_CHARGE);
+ if (rv)
+ return rv;
+
+ /* Disable Vbus discharge */
+ sm5803_set_vbus_disch(port, 0);
+
+ /* Provide Vbus */
+ chg_chips[port].drv->enable_otg_power(port, 1);
+
+#ifdef CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT
+ /* Ensure we advertise the proper available current quota */
+ charge_manager_source_port(port, 1);
+#endif /* defined(CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT) */
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+
+ return EC_SUCCESS;
+}
+
+int pd_snk_is_vbus_provided(int port)
+{
+ int chg_det = 0;
+
+ sm5803_get_chg_det(port, &chg_det);
+
+ return chg_det;
+}