Tristan Hsieh has uploaded this change for review. ( https://review.coreboot.org/29062
Change subject: google/kukui: Add board id support ......................................................................
google/kukui: Add board id support
Get board id from AUXIN4 and ram code from AUXIN3.
BUG=b:80501386 BRANCH=none TEST=AUXIN4 is 0.074v and AUXIN3 is 0.212v on P0. AUXIN4 is 0.212v and AUXIN3 is 0.212v on P1.
Change-Id: I50533e851d2fae66ae8c5e4e1aa36708d9058e94 Signed-off-by: Tristan Shieh tristan.shieh@mediatek.com --- M src/mainboard/google/kukui/Makefile.inc A src/mainboard/google/kukui/boardid.c 2 files changed, 63 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/29062/1
diff --git a/src/mainboard/google/kukui/Makefile.inc b/src/mainboard/google/kukui/Makefile.inc index aa6bf11..a98541a 100644 --- a/src/mainboard/google/kukui/Makefile.inc +++ b/src/mainboard/google/kukui/Makefile.inc @@ -1,3 +1,4 @@ +bootblock-y += boardid.c bootblock-y += bootblock.c bootblock-y += chromeos.c bootblock-y += memlayout.ld @@ -6,10 +7,12 @@ verstage-y += chromeos.c verstage-y += memlayout.ld
+romstage-y += boardid.c romstage-y += chromeos.c romstage-y += memlayout.ld romstage-y += romstage.c
+ramstage-y += boardid.c ramstage-y += chromeos.c ramstage-y += mainboard.c ramstage-y += memlayout.ld diff --git a/src/mainboard/google/kukui/boardid.c b/src/mainboard/google/kukui/boardid.c new file mode 100644 index 0000000..82d4915 --- /dev/null +++ b/src/mainboard/google/kukui/boardid.c @@ -0,0 +1,60 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2018 MediaTek Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <boardid.h> +#include <soc/auxadc.h> + +static uint32_t get_board_id(void) +{ + int auxin4 = auxadc_get_voltage(4); + + if ((auxin4 > 64000) && (auxin4 < 84000)) /* 74mv +/- 10mv */ + return 0; + + if ((auxin4 > 202000) && (auxin4 < 222000)) /* 212mv +/- 10mv */ + return 1; + + return BOARD_ID_UNKNOWN; +} + +uint32_t board_id(void) +{ + static uint32_t cached_board_id = BOARD_ID_UNKNOWN; + + if (cached_board_id == BOARD_ID_UNKNOWN) + cached_board_id = get_board_id(); + + return cached_board_id; +} + +static uint32_t get_ram_code(void) +{ + int auxin3 = auxadc_get_voltage(3); + + if ((auxin3 > 202000) && (auxin3 < 222000)) /* 212mv +/- 10mv */ + return 0; + + return BOARD_ID_UNKNOWN; +} + +uint32_t ram_code(void) +{ + static uint32_t cached_ram_code = BOARD_ID_UNKNOWN; + + if (cached_ram_code == BOARD_ID_UNKNOWN) + cached_ram_code = get_ram_code(); + + return cached_ram_code; +}