summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2020-07-23 22:50:54 -0600
committerCommit Bot <commit-bot@chromium.org>2020-07-28 04:09:00 +0000
commita787987e6a2cc7878ee9d58a6431d365a3fb195d (patch)
tree0228687d6f69e560cd1f1ae447f5edbf1d32cd0b
parentaaab7ae298c52c0e71f91b30ef78a46a06df54eb (diff)
downloadchrome-ec-a787987e6a2cc7878ee9d58a6431d365a3fb195d.tar.gz
Dedede: Move extpower_is_present() to baseboard
This consolidates dedede boards to use a baseboard extpower_is_present() and also adds the condition to verify that the port is sinking, instead of providing Vbus. It also converts the RAA489000 boards to use the cached Vbus presence in pd_snk_is_vbus_provided(). BRANCH=None BUG=None TEST=on waddledoo and waddledee, verify "AC on" prints when a charger or charge-through servo v4 is plugged in, verify no "AC on" prints when a dongle is plugged in Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I5941da789a4e810f6d8cc40cef4d32a5a03c5662 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2317062 Tested-by: Devin Lu <Devin.Lu@quantatw.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--baseboard/dedede/baseboard.c17
-rw-r--r--board/boten/board.c5
-rw-r--r--board/drawcia/board.c5
-rw-r--r--board/madoo/board.c11
-rw-r--r--board/magolor/board.c11
-rw-r--r--board/waddledee/board.c5
-rw-r--r--board/waddledoo/board.c11
-rw-r--r--board/wheelie/board.c11
8 files changed, 20 insertions, 56 deletions
diff --git a/baseboard/dedede/baseboard.c b/baseboard/dedede/baseboard.c
index 6ec8b42742..251db7d120 100644
--- a/baseboard/dedede/baseboard.c
+++ b/baseboard/dedede/baseboard.c
@@ -15,6 +15,7 @@
#include "host_command.h"
#include "intel_x86.h"
#include "system.h"
+#include "usb_pd.h"
/******************************************************************************/
/*
@@ -242,3 +243,19 @@ int board_is_i2c_port_powered(int port)
/* Sensor rails are off in S5/G3 */
return chipset_in_state(CHIPSET_STATE_ANY_OFF) ? 0 : 1;
}
+
+int extpower_is_present(void)
+{
+ int vbus_present = 0;
+ int port;
+
+ /*
+ * 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;
+}
diff --git a/board/boten/board.c b/board/boten/board.c
index 520d69d1bb..bf7fdb17bf 100644
--- a/board/boten/board.c
+++ b/board/boten/board.c
@@ -188,11 +188,6 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-int extpower_is_present(void)
-{
- return pd_check_vbus_level(0, VBUS_PRESENT);
-}
-
void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
int charge_mv)
{
diff --git a/board/drawcia/board.c b/board/drawcia/board.c
index a9468ae475..03c55da24d 100644
--- a/board/drawcia/board.c
+++ b/board/drawcia/board.c
@@ -336,11 +336,6 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-int extpower_is_present(void)
-{
- return sm5803_is_vbus_present(0) || sm5803_is_vbus_present(1);
-}
-
void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
int charge_mv)
{
diff --git a/board/madoo/board.c b/board/madoo/board.c
index 41e93fc8ef..b88467484d 100644
--- a/board/madoo/board.c
+++ b/board/madoo/board.c
@@ -444,12 +444,6 @@ struct motion_sensor_t motion_sensors[] = {
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
-int extpower_is_present(void)
-{
- return pd_check_vbus_level(0, VBUS_PRESENT) ||
- pd_check_vbus_level(1, VBUS_PRESENT);
-}
-
__override void ocpc_get_pid_constants(int *kp, int *kp_div,
int *ki, int *ki_div,
int *kd, int *kd_div)
@@ -477,10 +471,7 @@ __override void ocpc_get_pid_constants(int *kp, int *kp_div,
int pd_snk_is_vbus_provided(int port)
{
- int regval = 0;
-
- tcpc_read(port, TCPC_REG_POWER_STATUS, &regval);
- return regval & TCPC_REG_POWER_STATUS_VBUS_PRES;
+ return pd_check_vbus_level(port, VBUS_PRESENT);
}
const struct charger_config_t chg_chips[] = {
diff --git a/board/magolor/board.c b/board/magolor/board.c
index 54c0e58d3c..56daee0d46 100644
--- a/board/magolor/board.c
+++ b/board/magolor/board.c
@@ -373,12 +373,6 @@ struct motion_sensor_t motion_sensors[] = {
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
-int extpower_is_present(void)
-{
- return pd_check_vbus_level(0, VBUS_PRESENT) ||
- pd_check_vbus_level(1, VBUS_PRESENT);
-}
-
__override void ocpc_get_pid_constants(int *kp, int *kp_div,
int *ki, int *ki_div,
int *kd, int *kd_div)
@@ -406,10 +400,7 @@ __override void ocpc_get_pid_constants(int *kp, int *kp_div,
int pd_snk_is_vbus_provided(int port)
{
- int regval = 0;
-
- tcpc_read(port, TCPC_REG_POWER_STATUS, &regval);
- return regval & TCPC_REG_POWER_STATUS_VBUS_PRES;
+ return pd_check_vbus_level(port, VBUS_PRESENT);
}
const struct charger_config_t chg_chips[] = {
diff --git a/board/waddledee/board.c b/board/waddledee/board.c
index c3e6858de6..90eb0b9d18 100644
--- a/board/waddledee/board.c
+++ b/board/waddledee/board.c
@@ -311,11 +311,6 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-int extpower_is_present(void)
-{
- return sm5803_is_vbus_present(0) || sm5803_is_vbus_present(1);
-}
-
void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
int charge_mv)
{
diff --git a/board/waddledoo/board.c b/board/waddledoo/board.c
index cc505bb16a..085ae07f44 100644
--- a/board/waddledoo/board.c
+++ b/board/waddledoo/board.c
@@ -446,12 +446,6 @@ struct motion_sensor_t motion_sensors[] = {
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
-int extpower_is_present(void)
-{
- return pd_check_vbus_level(0, VBUS_PRESENT) ||
- pd_check_vbus_level(1, VBUS_PRESENT);
-}
-
__override void ocpc_get_pid_constants(int *kp, int *kp_div,
int *ki, int *ki_div,
int *kd, int *kd_div)
@@ -479,10 +473,7 @@ __override void ocpc_get_pid_constants(int *kp, int *kp_div,
int pd_snk_is_vbus_provided(int port)
{
- int regval = 0;
-
- tcpc_read(port, TCPC_REG_POWER_STATUS, &regval);
- return regval & TCPC_REG_POWER_STATUS_VBUS_PRES;
+ return pd_check_vbus_level(port, VBUS_PRESENT);
}
const struct charger_config_t chg_chips[] = {
diff --git a/board/wheelie/board.c b/board/wheelie/board.c
index 22f6bca2f0..ab1cb03942 100644
--- a/board/wheelie/board.c
+++ b/board/wheelie/board.c
@@ -228,17 +228,6 @@ uint16_t tcpc_get_alert_status(void)
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)
{