summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott <scollyer@chromium.org>2016-08-04 10:02:18 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-08-05 16:00:08 -0700
commitabb826e237b65e31f79121623b20fbd37f79b6e0 (patch)
treef107516b6c557fcb477fc9867c1af103ce8e1f9d
parentfdfa29b1678cd04ef15f62d1b5df7c828204dd91 (diff)
downloadchrome-ec-abb826e237b65e31f79121623b20fbd37f79b6e0.tar.gz
Cr50: Read slave config pins always if board properties are not set
Previously, the strapping configuration pins were only being read following a POR reset event. In all other cases, the strapping configuration was presumed to be stored in a long life register. An issue with this method is that when Cr50 FW is upgraded (via Suzyq), there is no POR reset event until either the battery becomes fully discharged, or the battery is manually disconnected. Without a POR, following a FW upgrade, the long life register will contain 0 and so neither the SPI interface (on Kevin/Gru) or I2C interface (on Reef) will be properly initialized. Come to think of it, the contents of the scratch register should never be zero unless this is a power on event, or a restart after migration from the version not setting the scratch register. Let's read the scratch register always if its contents are zero. BRANCH=none BUG=chrome-os-partner:50728 TEST=manual Via the Cr50 console, cleared the long life register with temp console command. Then executed a FW upgrade with Suzyq and verified that the strapping pins are read and the correct value is stored in the long life register. Note that 'reboot' commands from either the Cr50 or EC console do not cause a hard reboot. Change-Id: I1b3aa92552b14bde9bda848aa3dc4c8221ce73a9 Signed-off-by: Scott <scollyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/366390 Commit-Ready: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Scott Collyer <scollyer@chromium.org>
-rw-r--r--board/cr50/board.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/board/cr50/board.c b/board/cr50/board.c
index bcb5c6dae7..9d383f5b26 100644
--- a/board/cr50/board.c
+++ b/board/cr50/board.c
@@ -505,10 +505,15 @@ void board_update_device_state(enum device_type device)
static void detect_slave_config(void)
{
- uint32_t properties = 0;
+ uint32_t properties;
- /* Check for power on reset */
- if (system_get_reset_flags() & RESET_FLAG_POWER_ON) {
+ properties = GREG32(PMU, LONG_LIFE_SCRATCH1);
+
+ /*
+ * This must be a power on reset or maybe restart due to a software
+ * update from a version not setting the register.
+ */
+ if (!properties) {
/* Read DIOA1 strap pin */
if (gpio_get_level(GPIO_STRAP0))
/* Strap is pulled high -> Kevin SPI TPM option */
@@ -516,16 +521,19 @@ static void detect_slave_config(void)
else
/* Strap is low -> Reef I2C TPM option */
properties |= BOARD_SLAVE_CONFIG_I2C;
- /* Write enable bit for LONG_LIFE_SCRATCH1 register */
+
+ /*
+ * Now save the properties value for future use.
+ *
+ * First enable write access to the LONG_LIFE_SCRATCH1 register.
+ */
GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG1, 1);
- /* Save type in LONG_LIFE register */
+ /* Save properties in LONG_LIFE register */
GREG32(PMU, LONG_LIFE_SCRATCH1) = properties;
- /* Clear enable bit of LONG_LIFE_SCRATCH1 register */
+ /* Disabel write access to the LONG_LIFE_SCRATCH1 register */
GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG1, 0);
- } else {
- /* Not a power on reset, so can read what was discovered */
- properties = GREG32(PMU, LONG_LIFE_SCRATCH1);
}
+
/* Save this configuration setting */
board_properties = properties;
}