diff options
author | Aaron Durbin <adurbin@chromium.org> | 2014-08-28 12:51:07 -0500 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2015-03-27 08:03:49 +0100 |
commit | 2223c4f3edb58748a8359a17eb923a6b57cc884f (patch) | |
tree | 61483e99d246013c306d582798e0be9d61548e26 /src | |
parent | 20772a84781ac69288a39c3624caebed15693025 (diff) |
ryu: normalize board id
Instead of relying on the encoding of gpio_get_in_tristate_values()
normalize the ids.
BUG=chrome-os-partner:31602
BRANCH=None
TEST=Built and noted correct output w/ coresponding correct device
tree selected in depthcharge.
Change-Id: I6fc712aceb56d701725759503b9cfa1061ed25d7
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 1037d473f35613bf39a4b27a9c1ade718b852c0d
Original-Change-Id: I7d5449bc14e776fd9faa86af0f80690c3d9ae92d
Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/214840
Original-Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: http://review.coreboot.org/9004
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/mainboard/google/rush_ryu/boardid.c | 61 | ||||
-rw-r--r-- | src/mainboard/google/rush_ryu/gpio.h | 15 |
2 files changed, 72 insertions, 4 deletions
diff --git a/src/mainboard/google/rush_ryu/boardid.c b/src/mainboard/google/rush_ryu/boardid.c index 42a51bd0cf..1aa7c16831 100644 --- a/src/mainboard/google/rush_ryu/boardid.c +++ b/src/mainboard/google/rush_ryu/boardid.c @@ -22,17 +22,72 @@ #include <stdlib.h> #include <boardid.h> +#include "gpio.h" + +/* + * +------------------+---------+ + * | BD_ID_STRAP[1:0] | PHASE | + * +------------------+---------+ + * | 00 | PROTO0 | + * +------------------+---------+ + * | 01 | PROTO1 | + * +------------------+---------+ + * | 0Z | EVT | + * +------------------+---------+ + * | 10 | DVT | + * +------------------+---------+ + * | 11 | PVT | + * +------------------+---------+ + * | 1Z | MP | + * +------------------+---------+ + * | Z0 | | + * +------------------+---------+ + * | Z1 | | + * +------------------+---------+ + * | ZZ | | + * +------------------+---------+ + */ +struct id_to_str { + const char *str; + int tri_state_value; + int normalized_id; +}; + +static const struct id_to_str bdid_map[] = { + { "PROTO 0", 0x00, BOARD_ID_PROTO_0 }, + { "PROTO 1", 0x01, BOARD_ID_PROTO_1 }, + { "EVT", 0x02, BOARD_ID_EVT }, + { "DVT", 0x04, BOARD_ID_DVT }, + { "PVT", 0x05, BOARD_ID_PVT }, + { "MP", 0x06, BOARD_ID_MP }, + { "Z0", 0x08, -1 }, + { "Z1", 0x09, -1 }, + { "ZZ", 0x0a, -1 }, +}; uint8_t board_id(void) { static int id = -1; if (id < 0) { - gpio_t gpio[] = {GPIO(Q3), GPIO(Q4)}; + const char *idstr = "Unknown"; + int i; + int tristate_id; + gpio_t gpio[] = { BD_ID0, BD_ID1 }; + + tristate_id = gpio_get_in_tristate_values(gpio, + ARRAY_SIZE(gpio), 0); - id = gpio_get_in_tristate_values(gpio, ARRAY_SIZE(gpio), 0); + for (i = 0; i < ARRAY_SIZE(bdid_map); i++) { + if (tristate_id != bdid_map[i].tri_state_value) + continue; + idstr = bdid_map[i].str; + id = bdid_map[i].normalized_id; + break; + } - printk(BIOS_SPEW, "Board TRISTATE ID: %#x.\n", id); + printk(BIOS_SPEW, "Board ID: '%s' %d (%#x)\n", idstr, id, + tristate_id); } return id; } diff --git a/src/mainboard/google/rush_ryu/gpio.h b/src/mainboard/google/rush_ryu/gpio.h index 532b92c85f..9b51a58116 100644 --- a/src/mainboard/google/rush_ryu/gpio.h +++ b/src/mainboard/google/rush_ryu/gpio.h @@ -22,8 +22,21 @@ #include <soc/nvidia/tegra132/gpio.h> -/* LTE modem related GPIOs */ +/* Board ID definitions. */ enum { + BOARD_ID_PROTO_0 = 0, + BOARD_ID_PROTO_1 = 1, + BOARD_ID_EVT = 2, + BOARD_ID_DVT = 3, + BOARD_ID_PVT = 4, + BOARD_ID_MP = 5, +}; + +enum { + /* Board ID related GPIOS. */ + BD_ID0 = GPIO(Q3), + BD_ID1 = GPIO(Q4), + /* LTE modem related GPIOs */ MODEM_RESET = GPIO(S3), MODEM_PWR_ON = GPIO(S4), MDM_DET = GPIO(V1), |