summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2021-04-01 07:40:30 +1100
committerCommit Bot <commit-bot@chromium.org>2021-04-01 21:32:13 +0000
commitf38daf612e9bd788791191dfd17940d757d303fa (patch)
tree2c2ce0120df584cecebca2c93ea4d58bdc796081
parent27c3bf4011f017b296fe3c49ae35ff6d9960b962 (diff)
downloadchrome-ec-stabilize-13895.B-cr50_stab.tar.gz
add 'atboot' arg to rddkeepalivestabilize-13895.B-cr50_stab
Add 'atboot' arg to rddkeepalive that can be used to store rddkeepalive across cr50 resets. The atboot flag gets cleared with rddkeepalive disable. BUG=b:144724216 TEST=manual # Verify 'rddkeepalive disable' is unchanged rddkeepalive disable Using actual Rdd state rddkeepalive Rdd: connected # Verify 'rddkeepalive enable' is unchanged rddkeepalive enable Forcing Rdd detect keepalive rddkeepalive Rdd: keepalive # Verify 'rddkeepalive disable' disables keepalive rddkeepalive disable Using actual Rdd state rddkeepalive Rdd: connected ccd ... Flags: 0x000000 # Verify 'rddkeepalive enable atboot' enables keepalive and sets # the atboot flag. rddkeepalive enable atboot Forcing Rdd detect keepalive atboot. rddkeepalive Rdd: keepalive (atboot) # check the ccd rddkeepalive atboot flag (0x80000) ccd ... Flags: 0x080000 reboot ... rddkeepalive Rdd: keepalive (atboot) ccd ... Flags: 0x080000 # Verify this new string doesn't break dut-control dut-control cr50.ccd_keepalive_en ccd_keepalive_en:on # 'rddkeepalive enable' doesn't touch the atboot flag rddkeepalive enable Forcing Rdd detect keepalive rddkeepalive Rdd: keepalive (atboot) # 'rddkeepalive disable' clears it. rddkeepalive disable Using actual Rdd state rddkeepalive Rdd: connected Change-Id: I10227e335a5de6ed73290ff5be2e65892913de35 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2799441 Reviewed-by: Namyoon Woo <namyoon@chromium.org>
-rw-r--r--board/cr50/board.c1
-rw-r--r--chip/g/rdd.c25
-rw-r--r--common/ccd_config.c1
-rw-r--r--include/ccd_config.h3
4 files changed, 26 insertions, 4 deletions
diff --git a/board/cr50/board.c b/board/cr50/board.c
index 4dc20f8b8c..047613969a 100644
--- a/board/cr50/board.c
+++ b/board/cr50/board.c
@@ -849,6 +849,7 @@ static void board_init(void)
* used for battery cutoff software support on detachable devices.
*/
init_ac_detect();
+ /* Reads ccd_flag. Must be done after ccd_config_init. */
init_rdd_state();
/* Initialize write protect. Must be after CCD config init. */
diff --git a/chip/g/rdd.c b/chip/g/rdd.c
index 4e17cab29a..140414ec3b 100644
--- a/chip/g/rdd.c
+++ b/chip/g/rdd.c
@@ -3,6 +3,7 @@
* found in the LICENSE file.
*/
+#include "ccd_config.h"
#include "clock.h"
#include "console.h"
#include "gpio.h"
@@ -54,8 +55,10 @@ uint8_t rdd_is_detected(void)
void print_rdd_state(void)
{
- ccprintf("Rdd: %s\n",
- force_detected ? "keepalive" : device_state_name(state));
+ ccprintf("Rdd: %s%s\n",
+ force_detected ? "keepalive" : device_state_name(state),
+ ccd_get_flag(CCD_FLAG_RDDKEEPALIVE_AT_BOOT) ? " (atboot)" :
+ "");
}
/**
@@ -205,6 +208,12 @@ void init_rdd_state(void)
task_enable_irq(GC_IRQNUM_RDD0_INTR_DEBUG_STATE_DETECTED_INT);
GWRITE_FIELD(RDD, INT_STATE, INTR_DEBUG_STATE_DETECTED, 1);
GWRITE_FIELD(RDD, INT_ENABLE, INTR_DEBUG_STATE_DETECTED, 1);
+
+ /* Restore the rddkeepalive atboot state from the ccd flags. */
+ force_detected = ccd_get_flag(CCD_FLAG_RDDKEEPALIVE_AT_BOOT);
+
+ if (force_detected)
+ hook_call_deferred(&rdd_connect_data, 0);
}
static int command_rdd_keepalive(int argc, char **argv)
@@ -219,15 +228,23 @@ static int command_rdd_keepalive(int argc, char **argv)
if (force_detected) {
/* Force Rdd detect */
- ccprintf("Forcing Rdd detect keepalive\n");
+ ccprintf("Forcing Rdd detect keepalive");
+
+ if (argc > 2 && !strcasecmp(argv[2], "atboot")) {
+ /* Change rddkeeplalive at boot to match */
+ ccprintf(" atboot");
+ ccd_set_flag(CCD_FLAG_RDDKEEPALIVE_AT_BOOT, 1);
+ }
+ ccprintf("\n");
hook_call_deferred(&rdd_connect_data, 0);
} else {
/* Go back to actual hardware state */
ccprintf("Using actual Rdd state\n");
+ ccd_set_flag(CCD_FLAG_RDDKEEPALIVE_AT_BOOT, 0);
}
return EC_SUCCESS;
}
DECLARE_SAFE_CONSOLE_COMMAND(rddkeepalive, command_rdd_keepalive,
- "[BOOLEAN]",
+ "[BOOLEAN] [atboot]",
"Get Rdd state or force keepalive");
diff --git a/common/ccd_config.c b/common/ccd_config.c
index f83789a26f..5d9907a4b4 100644
--- a/common/ccd_config.c
+++ b/common/ccd_config.c
@@ -95,6 +95,7 @@ static const uint8_t k_ccd_config = NVMEM_VAR_CCD_CONFIG;
/* Flags which can be set via ccd_set_flag() */
static const uint32_t k_public_flags =
+ CCD_FLAG_RDDKEEPALIVE_AT_BOOT |
CCD_FLAG_OVERRIDE_WP_AT_BOOT |
CCD_FLAG_OVERRIDE_WP_STATE_ENABLED |
CCD_FLAG_OVERRIDE_BATT_AT_BOOT |
diff --git a/include/ccd_config.h b/include/ccd_config.h
index a3d4410244..60abe472e9 100644
--- a/include/ccd_config.h
+++ b/include/ccd_config.h
@@ -54,6 +54,9 @@ enum ccd_flag {
* in ccd_config.c.
*/
+ /* Enable Rddkeepalive at boot */
+ CCD_FLAG_RDDKEEPALIVE_AT_BOOT = BIT(19),
+
/* Override BATT_PRES_L at boot */
CCD_FLAG_OVERRIDE_BATT_AT_BOOT = BIT(20),