summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/samus/extpower.c6
-rw-r--r--board/samus/power_sequence.c23
-rw-r--r--common/usb_pd_protocol.c9
3 files changed, 36 insertions, 2 deletions
diff --git a/board/samus/extpower.c b/board/samus/extpower.c
index 60f97a4da2..9262c06d17 100644
--- a/board/samus/extpower.c
+++ b/board/samus/extpower.c
@@ -31,12 +31,18 @@ static void extpower_deferred(void)
if (extpower && !extpower_prev) {
charger_discharge_on_ac(0);
+ /* If in G3, enable PP5000 for accurate sensing of CC */
+ if (chipset_in_state(CHIPSET_STATE_HARD_OFF))
+ gpio_set_level(GPIO_PP5000_EN, 1);
} else if (extpower && extpower_prev) {
/* glitch on AC_PRESENT, attempt to recover from backboost */
charger_discharge_on_ac(1);
charger_discharge_on_ac(0);
} else {
charger_discharge_on_ac(1);
+ /* If in G3, make sure PP5000 is off when no AC */
+ if (chipset_in_state(CHIPSET_STATE_HARD_OFF))
+ gpio_set_level(GPIO_PP5000_EN, 0);
}
extpower_prev = extpower;
diff --git a/board/samus/power_sequence.c b/board/samus/power_sequence.c
index ffa8999b0a..b5d2e9a176 100644
--- a/board/samus/power_sequence.c
+++ b/board/samus/power_sequence.c
@@ -9,6 +9,7 @@
#include "chipset.h"
#include "common.h"
#include "console.h"
+#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
#include "host_command.h"
@@ -85,7 +86,12 @@ static void chipset_force_g3(void)
gpio_set_level(GPIO_PP1800_EN, 0);
gpio_set_level(GPIO_PP3300_DSW_GATED_EN, 0);
gpio_set_level(GPIO_PP5000_USB_EN, 0);
- gpio_set_level(GPIO_PP5000_EN, 0);
+ /*
+ * Don't disable PP5000 if AC is attached because we need
+ * it for accurate CC line voltage measurement on PD MCU.
+ */
+ if (!extpower_is_present())
+ gpio_set_level(GPIO_PP5000_EN, 0);
gpio_set_level(GPIO_PCH_RSMRST_L, 0);
gpio_set_level(GPIO_PCH_DPWROK, 0);
gpio_set_level(GPIO_PP3300_DSW_EN, 0);
@@ -468,7 +474,13 @@ enum power_state power_handle_state(enum power_state state)
/* Turn off power rails enabled in S5 */
gpio_set_level(GPIO_PP1050_EN, 0);
- gpio_set_level(GPIO_PP5000_EN, 0);
+
+ /*
+ * Don't disable PP5000 if AC is attached because we need
+ * it for accurate CC line voltage measurement on PD MCU.
+ */
+ if (!extpower_is_present())
+ gpio_set_level(GPIO_PP5000_EN, 0);
/* Disable 3.3V DSW */
gpio_set_level(GPIO_PP3300_DSW_EN, 0);
@@ -491,6 +503,13 @@ int lb_power(int enabled)
return 0;
/*
+ * Don't disable PP5000 if AC is attached because we need it for
+ * accurate CC line voltage measurement on PD MCU.
+ */
+ if (!enabled && extpower_is_present())
+ return 0;
+
+ /*
* If the AP is off, we can still turn the lightbar on briefly.
* When turning on, we have to wait for the rails to come up fully
* before we the lightbar ICs will respond. There's not a reliable
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 952d7066c8..82a3e5a91c 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -1972,6 +1972,15 @@ void pd_task(void)
#ifdef CONFIG_CHARGE_MANAGER
timeout = PD_T_SINK_ADJ - PD_T_DEBOUNCE;
+ /*
+ * If we didn't come from disconnected, must have
+ * come from some path that did not set typec
+ * current limit. So, set to 0 so that we guarantee
+ * this is revised below.
+ */
+ if (pd[port].last_state != PD_STATE_SNK_DISCONNECTED)
+ typec_curr = 0;
+
/* Check if CC pull-up has changed */
cc1_volt = pd_adc_read(port, pd[port].polarity);
if (typec_curr != get_typec_current_limit(cc1_volt)) {