diff options
author | Randall Spangler <rspangler@chromium.org> | 2017-08-09 16:19:47 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-09-06 19:12:57 -0700 |
commit | a285acd36f898a394b82b8cb865bf60922f7ae2c (patch) | |
tree | 117091f392a81186032eec773fbbb4fb6e9ebf30 /common | |
parent | 0d97809b44ad35fbddb0d72f18f5cffbe58e8824 (diff) | |
download | chrome-ec-a285acd36f898a394b82b8cb865bf60922f7ae2c.tar.gz |
cr50: Consolidate CCD device enable
Currently, the Cr50 state machines (EC, AP, RDD, bitbang, etc.) manage
their own enabling and disabling of the ports (UART, SPI, etc.) This
is tricky because the rules for when ports should be enabled are
non-trivial and must be applied in the correct order. In additionl
the changes all need to be serialized, so that the hardware ends up in
the correct state even if multiple state machines are changing
simultaneously.
Consolidate all of that into chip/g/rdd.c. The debug command for it
is now 'ccdstate', which just prints the state machines. This will
allow subsequent renaming of the 'ccdopen', etc. commands to 'ccd
open', etc.
Also include UART bit-banging into that state which must be
consistent. Previously, it was possible for bit-banging to leave UART
TX connected, instead of returning it to the previous state.
Use better names for CCD config fields for UART. I'd had them backwards.
BUG=b:62537474
BRANCH=cr50
TEST=manual, with a CR50_DEV=1 image
1) No servo or CCD
Pull SERVO_DETECT low (disconnected)
Pull CCD_MODE_L high (disabled)
Pull EC_DETECT and AP_DETECT high (on)
Reboot. RX is enabled even if cables are disconnected so we buffer.
ccdstate -> UARTAP UARTEC
Pull EC_DETECT low.
ccdstate -> UARTAP
Pull EC_DETECT high and AP_DETECT low.
ccdstate -> UARTEC
Pull AP_DETECT high.
ccdstate -> UARTAP UARTEC
2) Servo only still allows UART RX
Pull SERVO_DETECT high (connected).
ccdstate -> UARTAP UARTEC
3) Both servo and CCD prioritizes servo.
Pull CCD_MODE_L low (enabled).
ccdstate -> UARTAP UARTEC
Reboot, to make sure servo wins at boot time.
ccdstate -> UARTAP UARTEC
Bit-banging doesn't work when servo is connected.
bitbang 2 9600 even -> superseded by servo
bitbang -> disabled
ccdstate -> UARTAP UARTEC
4) CCD only allows more ports and remembers we wanted to bit-bang
Pull SERVO_DETECT low.
ccdstate --> UARTAP+TX UARTEC+BB I2C SPI
bitbang 2 disable
ccdstate --> UARTAP+TX UARTEC+TX I2C SPI
Reboot and see we don't take over servo ports until we're
sure servo isn't present.
ccdstate --> UARTAP UARTEC (for first second)
ccdstate --> UARTAP+TX UARTEC+TX I2C SPI (after that)
5) Bit-banging takes over ECTX
bitbang 2 9600 even
bitbang -> baud rate 9600, parity even
ccdstate -> UARTAP+TX UARTEC+BB I2C SPI
bitbang 2 disable
ccdstate -> UARTAP+TX UARTEC+TX I2C SPI
6) Permissions work. Allow easy access to full console and ccdopen:
ccdset OpenNoTPMWipe always
ccdset OpenNoLongPP always
ccdset GscFullConsole always
Default when locked is full AP UART EC RO, no I2C or SPI
ccdlock
ccdstate -> UARTAP+TX UARTEC
No EC transmit permission means no bit-banging
bitbang 2 9600 even
bitbang -> disabled
ccdstate -> UARTAP+TX UARTEC
But it remembers that we wanted to
ccdopen
ccdstate -> UARTAP+TX UARTEC+BB I2C SPI
bitbang 2 disable
ccdstate -> UARTAP+TX UARTEC+TX I2C SPI
Try turning on/off permissions
ccdset UartGscTxECRx always
ccdlock
ccdstate -> UARTAP+TX UARTEC+TX
No read means no write either
ccdset UartGscRxECTx ifopened
ccdlock
ccdstate -> UARTAP+TX
ccdopen
ccdset UartGscRXAPTx ifopened
ccdlock
ccdstate -> (nothing)
Check AP transmit permissions too
ccdopen
ccdset UartGscRxAPTx always
ccdset UartGscTxAPRx ifopened
ccdlock
ccdstate -> UARTAP
Check I2C
ccdopen
ccdset I2C always
ccdlock
ccdstate -> UARTAP I2C
SPI port is enabled if either EC or AP flash is allowed
ccdopen
ccdset flashap always
ccdlock
ccdstate -> UARTAP I2C SPI
ccdopen
ccdset flashec always
ccdset flashap ifopened
ccdlock
ccdstate -> UARTAP I2C SPI
Back to defaults
ccdoops
Change-Id: I641f7ab2354570812e3fb37b470de32e5bd10db7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/615928
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/ccd_config.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/common/ccd_config.c b/common/ccd_config.c index a0dcf83dde..cc4e7729d2 100644 --- a/common/ccd_config.c +++ b/common/ccd_config.c @@ -118,17 +118,17 @@ static const uint32_t k_public_flags = /* List of CCD capability info; must be in same order as enum ccd_capability */ static const struct ccd_capability_info cap_info[CCD_CAP_COUNT] = { - {"UartAPTX", CCD_CAP_STATE_ALWAYS}, - {"UartAPRX", CCD_CAP_STATE_ALWAYS}, - {"UartECTX", CCD_CAP_STATE_ALWAYS}, - {"UartECRX", CCD_CAP_STATE_IF_OPENED}, + {"UartGscRxAPTx", CCD_CAP_STATE_ALWAYS}, + {"UartGscTxAPRx", CCD_CAP_STATE_ALWAYS}, + {"UartGscRxECTx", CCD_CAP_STATE_ALWAYS}, + {"UartGscTxECRx", CCD_CAP_STATE_IF_OPENED}, {"FlashAP", CCD_CAP_STATE_IF_OPENED}, {"FlashEC", CCD_CAP_STATE_IF_OPENED}, - {"WPOverride", CCD_CAP_STATE_IF_OPENED}, + {"OverrideWP", CCD_CAP_STATE_IF_OPENED}, {"RebootECAP", CCD_CAP_STATE_IF_OPENED}, - {"Cr50FullConsole", CCD_CAP_STATE_IF_OPENED}, + {"GscFullConsole", CCD_CAP_STATE_IF_OPENED}, {"UnlockNoReboot", CCD_CAP_STATE_ALWAYS}, {"UnlockNoShortPP", CCD_CAP_STATE_ALWAYS}, {"OpenNoTPMWipe", CCD_CAP_STATE_IF_OPENED}, @@ -508,7 +508,7 @@ static int ccd_reset_config(unsigned flags) * that's kinda meaningless because we set a * well-defined password below. */ - if (i == CCD_CAP_CR50_RESTRICTED_CONSOLE) + if (i == CCD_CAP_GSC_RESTRICTED_CONSOLE) continue; raw_set_cap(i, CCD_CAP_STATE_ALWAYS); |