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);