summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--baseboard/dedede/baseboard.c29
-rw-r--r--common/extpower_common.c4
-rw-r--r--common/usb_common.c4
-rw-r--r--driver/charger/sm5803.c2
-rw-r--r--driver/tcpm/tcpci.c3
-rw-r--r--include/extpower.h8
-rw-r--r--include/usb_pd.h6
7 files changed, 31 insertions, 25 deletions
diff --git a/baseboard/dedede/baseboard.c b/baseboard/dedede/baseboard.c
index 898791e7ce..3754f04b36 100644
--- a/baseboard/dedede/baseboard.c
+++ b/baseboard/dedede/baseboard.c
@@ -8,6 +8,8 @@
#include "adc.h"
#include "board_config.h"
#include "cbi_fw_config.h"
+#include "charger/isl923x_public.h"
+#include "charger/sm5803.h"
#include "chipset.h"
#include "common.h"
#include "extpower.h"
@@ -104,7 +106,7 @@ __override void board_after_rsmrst(int rsmrst)
* can call this function once it detects a VBUS presence change with which we
* can trigger the HOOK_AC_CHANGE hook.
*/
-__override void board_vbus_present_change(void)
+__override void board_check_extpower(void)
{
static int last_extpower_present;
int extpower_present = extpower_is_present();
@@ -277,18 +279,23 @@ int board_is_i2c_port_powered(int port)
int extpower_is_present(void)
{
- int vbus_present = 0;
int port;
+ int rv;
+ bool acok;
+ enum ec_error_list (*check_acok)(int port, bool *acok);
+
+ if (IS_ENABLED(CONFIG_CHARGER_RAA489000))
+ check_acok = raa489000_is_acok;
+ else if (IS_ENABLED(CONFIG_CHARGER_SM5803))
+ check_acok = sm5803_is_acok;
+
+ for (port = 0; port < board_get_usb_pd_port_count(); port++) {
+ rv = check_acok(port, &acok);
+ if ((rv == EC_SUCCESS) && acok)
+ return 1;
+ }
- /*
- * Boards define pd_snk_is_vbus_provided() with something appropriate
- * for their hardware
- */
- for (port = 0; port < board_get_usb_pd_port_count(); port++)
- if (pd_get_power_role(port) == PD_ROLE_SINK)
- vbus_present |= pd_snk_is_vbus_provided(port);
-
- return vbus_present;
+ return 0;
}
__override uint32_t board_override_feature_flags0(uint32_t flags0)
diff --git a/common/extpower_common.c b/common/extpower_common.c
index 453bab3a2c..9021b77626 100644
--- a/common/extpower_common.c
+++ b/common/extpower_common.c
@@ -7,6 +7,10 @@
#include "hooks.h"
#include "host_command.h"
+__overridable void board_check_extpower(void)
+{
+}
+
void extpower_handle_update(int is_present)
{
uint8_t *memmap_batt_flags;
diff --git a/common/usb_common.c b/common/usb_common.c
index 2e1030ea9a..4f9e17fa4f 100644
--- a/common/usb_common.c
+++ b/common/usb_common.c
@@ -46,10 +46,6 @@
*/
#define MIN_BATTERY_FOR_PD_UPGRADE_MAH 100 /* mAH */
-__overridable void board_vbus_present_change(void)
-{
-}
-
#if defined(CONFIG_CMD_PD) && defined(CONFIG_CMD_PD_FLASH)
int hex8tou32(char *str, uint32_t *val)
{
diff --git a/driver/charger/sm5803.c b/driver/charger/sm5803.c
index d4a20826a7..dd19cdb567 100644
--- a/driver/charger/sm5803.c
+++ b/driver/charger/sm5803.c
@@ -1080,7 +1080,7 @@ void sm5803_handle_interrupt(int chgnum)
/* Update extpower if VCHGPWR changes. */
if (int_reg & SM5803_INT2_VCHGPWR)
- board_vbus_present_change();
+ board_check_extpower();
/* TODO(b/159376384): Take action on fatal BFET power alert. */
rv = main_read8(chgnum, SM5803_REG_INT3_REQ, &int_reg);
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index 340388a869..df499351f1 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -1135,9 +1135,6 @@ static void tcpci_check_vbus_changed(int port, int alert, uint32_t *pd_event)
if (pd_event)
*pd_event |= TASK_EVENT_WAKE;
}
-
- if (pwr_status & TCPC_REG_POWER_STATUS_VBUS_DET)
- board_vbus_present_change();
}
}
diff --git a/include/extpower.h b/include/extpower.h
index b2b57943ca..1e9f7976e6 100644
--- a/include/extpower.h
+++ b/include/extpower.h
@@ -8,9 +8,17 @@
#ifndef __CROS_EC_EXTPOWER_H
#define __CROS_EC_EXTPOWER_H
+#include "common.h"
+
enum gpio_signal; /* from gpio_signal.h */
/**
+ * Run board specific code to update extpower status. The default
+ * implementation does nothing, but a board may override it.
+ */
+__override_proto void board_check_extpower(void);
+
+/**
* Return non-zero if external power is present.
*/
int extpower_is_present(void);
diff --git a/include/usb_pd.h b/include/usb_pd.h
index c0472e283b..ba29e04c86 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -3327,12 +3327,6 @@ __override_proto int svdm_tbt_compat_attention(int port, uint32_t *payload);
__override_proto enum ec_pd_port_location board_get_pd_port_location(int port);
-/**
- * Can be called whenever VBUS presence changes. The default implementation
- * does nothing, but a board may override it.
- */
-__override_proto void board_vbus_present_change(void);
-
/****************************************************************************
* TCPC CC/Rp Management
*/