From 5fccbce99e7db312e2e3caf806c438c9b04c0a8f Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 21 Nov 2013 00:46:56 -0800 Subject: [PATCH] nyan: Add some code for reading the board ID. We can use that to figure out which revision of nyan we're running on and make some small adjustments for the differences in hardware. BUG=None TEST=Built and booted on both versions of nyan. BRANCH=None Change-Id: Iaedbc36dcc8e27b95b1e1ec5687bd9592c49d775 Signed-off-by: Gabe Black Reviewed-on: https://chromium-review.googlesource.com/177488 Reviewed-by: David Hendricks Reviewed-by: Tom Warren Reviewed-by: Ronald Minnich Commit-Queue: Gabe Black Tested-by: Gabe Black --- src/mainboard/google/nyan/Makefile.inc | 1 + src/mainboard/google/nyan/boardid.c | 38 ++++++++++++++++++++++++++ src/mainboard/google/nyan/boardid.h | 27 ++++++++++++++++++ src/mainboard/google/nyan/bootblock.c | 7 +++++ 4 files changed, 73 insertions(+) create mode 100644 src/mainboard/google/nyan/boardid.c create mode 100644 src/mainboard/google/nyan/boardid.h diff --git a/src/mainboard/google/nyan/Makefile.inc b/src/mainboard/google/nyan/Makefile.inc index f154a3b8da..d02465d6bf 100644 --- a/src/mainboard/google/nyan/Makefile.inc +++ b/src/mainboard/google/nyan/Makefile.inc @@ -27,6 +27,7 @@ $(obj)/generated/bct.cfg: subdirs-y += bct +bootblock-y += boardid.c bootblock-y += bootblock.c bootblock-y += pmic.c diff --git a/src/mainboard/google/nyan/boardid.c b/src/mainboard/google/nyan/boardid.c new file mode 100644 index 0000000000..18d920b6f5 --- /dev/null +++ b/src/mainboard/google/nyan/boardid.c @@ -0,0 +1,38 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2013 Google 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +#include "boardid.h" + +uint8_t board_id(void) +{ + static int id = -1; + + if (id < 0) { + id = gpio_get_in_value(GPIO(Q3)) << 0 | + gpio_get_in_value(GPIO(T1)) << 1 | + gpio_get_in_value(GPIO(X1)) << 2 | + gpio_get_in_value(GPIO(X4)) << 3; + printk(BIOS_SPEW, "Board ID: %#x.\n", id); + } + + return id; +} diff --git a/src/mainboard/google/nyan/boardid.h b/src/mainboard/google/nyan/boardid.h new file mode 100644 index 0000000000..b65f54337e --- /dev/null +++ b/src/mainboard/google/nyan/boardid.h @@ -0,0 +1,27 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2013 Google 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __MAINBOARD_GOOGLE_NYAN_BOARDID_H__ +#define __MAINBOARD_GOOGLE_NYAN_BOARDID_H__ + +#include + +uint8_t board_id(void); + +#endif /* __MAINBOARD_GOOGLE_NYAN_BOARDID_H__ */ diff --git a/src/mainboard/google/nyan/bootblock.c b/src/mainboard/google/nyan/bootblock.c index e5ae58d77a..0761aedb7b 100644 --- a/src/mainboard/google/nyan/bootblock.c +++ b/src/mainboard/google/nyan/bootblock.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include /* FIXME: move back to soc code? */ @@ -55,6 +56,12 @@ void bootblock_mainboard_init(void) CLK_H_I2C5 | CLK_H_APBDMA, 0, CLK_V_MSELECT, 0, 0); + // Board ID GPIOs, bits 0-3. + gpio_input(GPIO(Q3)); + gpio_input(GPIO(T1)); + gpio_input(GPIO(X1)); + gpio_input(GPIO(X4)); + // I2C5 (PMU) clock. pinmux_set_config(PINMUX_PWR_I2C_SCL_INDEX, PINMUX_PWR_I2C_SCL_FUNC_I2CPMU | PINMUX_INPUT_ENABLE);