summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2019-03-02 15:19:13 +0800
committerchrome-bot <chrome-bot@chromium.org>2019-03-06 06:51:15 -0800
commit6e41e378b5973b3968977ca68101fcd775b98aba (patch)
treecf511e9f9d165a69e847a3caacacaa9b4d7c4294
parentaeefa957c949fac1325a66fbcc9d4b3c10de1c4f (diff)
downloadchrome-ec-6e41e378b5973b3968977ca68101fcd775b98aba.tar.gz
cr50: CCD flags not read correctly on first factory boot
During the first factory boot flow, the CCD flags are not read correctly. In this boot path, the ccd_config_loaded flag is not set until after the first calls to HOOK_CCD_CHANGE. Changed ccd_load_config() to always call HOOK_CCD_CHANGE after setting ccd_config_loaded flag. Changed ccd_save_config() so that it doesn't call HOOK_CCD_CHANGE if the ccd_config_loaded flag is not set. BUG=b:126971514 BRANCH=cr50 TEST=Erase the board ID, peform rollback to 0.0.22, and then upgrade to 4.14 firmware. On Wilco, confirmed that GPIO_FACTORY_MODE(GPIO_I2C_SCL_INA) is driven high during first factory boot flow. Change-Id: Ib6764085d2911abe330c7e580fd6b31bbfe6f89d Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1496679 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--common/ccd_config.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/common/ccd_config.c b/common/ccd_config.c
index 8569ab6beb..8896e9cde6 100644
--- a/common/ccd_config.c
+++ b/common/ccd_config.c
@@ -369,8 +369,7 @@ static void ccd_load_config(void)
CPRINTS("CCD using default config");
ccd_reset_config(CCD_RESET_TEST_LAB);
}
- ccd_config_loaded = 1;
- return;
+ goto ccd_is_loaded;
}
/* Copy the tuple data */
@@ -388,6 +387,7 @@ static void ccd_load_config(void)
ccd_reset_config(t->val_len < 2 ? CCD_RESET_TEST_LAB : 0);
}
+ccd_is_loaded:
ccd_config_loaded = 1;
/* Notify CCD users of configuration change */
@@ -410,8 +410,14 @@ static int ccd_save_config(void)
rv = writevars();
- /* Notify CCD users of configuration change */
- hook_notify(HOOK_CCD_CHANGE);
+ /*
+ * Notify CCD users of configuration change.
+ * Protect this notify with the ccd_config_loaded flag so recipients of
+ * HOOK_CCD_CHANGE don't call ccd_get/ccd_set before the CCD
+ * initialization is complete.
+ */
+ if (ccd_config_loaded)
+ hook_notify(HOOK_CCD_CHANGE);
return rv;
}