cr50: Add check for pullups on both pair of strap pins

The current strap pin logic was checking for case of no pullup
resistors detected on either pair of strap pins, but did not check
explicitly for at least one pullup on each pair or strap pins. This
condition, which isn't expected, is an invalid configuration and
therefore can't be used to determine either SPI vs I2C or as a table
lookup entry.

BRANCH=none
BUG=chrome-os-partner:59833
TEST=manual
Tested on Eve which has 4.7k pullup resistors to PP3300_A this rail is
not going down as expected. The result is that a pullup is read on
DIOA6 which is expected and strong pullups are read on
DIOA9|DIOA1. With this CL the strapping pin logic produces the
folloiwng output:
--- UART initialized after reboot ---
[Reset cause: hard]
[Image: RW_B, 0.0.14/DEV/cr50_v1.1.5933-18d527f
 tpm2:v0.0.286-21er-linux.mtv.corp.go]
[0.004160 Inits done]
[0.005476 Invalid strap pins! default properties = 0x42]

Change-Id: Ibe85bc55d62b4c060b6c39629a225edc6d1dc341
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/433146
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@google.com>
This commit is contained in:
Scott
2017-01-24 19:23:43 -08:00
committed by chrome-bot
parent 4c06e1f963
commit a4bddf7f21

View File

@@ -151,7 +151,8 @@ const struct strap_desc strap_regs[] = {
{ GPIO_STRAP_B1, GOFFSET(PINMUX, DIOA12_SEL), GC_PINMUX_DIOA12_SEL, },
};
#define BOARD_PORPERTIES_DEFAULT (BOARD_SLAVE_CONFIG_I2C | BOARD_USE_PLT_RESET)
#define BOARD_PROPERTIES_DEFAULT (BOARD_SLAVE_CONFIG_I2C | BOARD_USE_PLT_RESET \
| BOARD_USB_AP)
static struct board_cfg board_cfg_table[] = {
/* Kevin/Gru: DI0A9 = 5k PD, DIOA1 = 1M PU */
{ 0x02, BOARD_SLAVE_CONFIG_SPI | BOARD_NEEDS_SYS_RST_PULL_UP },
@@ -914,7 +915,8 @@ static int get_strap_config(uint8_t *config)
enum strap_list s0;
int lvl;
int flags;
uint8_t pullup_bits;
uint8_t pull_a;
uint8_t pull_b;
/*
* There are 4 pins that are used to determine Cr50 board strapping
@@ -1017,12 +1019,13 @@ static int get_strap_config(uint8_t *config)
* config table entries.
*/
pullup_bits = *config & 0xaa;
if (!pullup_bits)
return EC_ERROR_UNKNOWN;
pull_a = *config & 0xa0;
pull_b = *config & 0xa;
if ((!pull_a && !pull_b) || (pull_a && pull_b))
return EC_ERROR_INVAL;
/* Now that I2C vs SPI is known, mask the unused strap bits. */
*config &= pullup_bits & 0xa ? 0xf : 0xf0;
*config &= *config & 0xa ? 0xf : 0xf0;
return EC_SUCCESS;
}
@@ -1055,9 +1058,10 @@ static void init_board_properties(void)
* table entry. For this case default to I2C with
* platform reset and don't store in long life register.
*/
CPRINTS("No pullup on strap pins detected!");
/* Save this configuration setting */
board_properties = BOARD_PORPERTIES_DEFAULT;
board_properties = BOARD_PROPERTIES_DEFAULT;
CPRINTS("Invalid strap pins! Default properties = 0x%x",
board_properties);
return;
}
@@ -1096,7 +1100,7 @@ static void init_board_properties(void)
* returned EC_SUCCESS.
*/
properties = config & 0xa ? BOARD_SLAVE_CONFIG_SPI :
BOARD_PORPERTIES_DEFAULT;
BOARD_PROPERTIES_DEFAULT;
CPRINTS("strap_cfg 0x%x has no table entry, prop = 0x%x",
config, properties);
}