Julius Werner | 72001e7 | 2014-09-10 15:30:49 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2014 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
Julius Werner | 72001e7 | 2014-09-10 15:30:49 -0700 | [diff] [blame] | 20 | #include <boardid.h> |
Julius Werner | 7a453eb | 2014-10-20 13:14:55 -0700 | [diff] [blame] | 21 | #include <console/console.h> |
Julius Werner | eaa9c45 | 2014-09-24 15:40:49 -0700 | [diff] [blame] | 22 | #include <gpio.h> |
Julius Werner | 7a453eb | 2014-10-20 13:14:55 -0700 | [diff] [blame] | 23 | #include <stdlib.h> |
Julius Werner | 72001e7 | 2014-09-10 15:30:49 -0700 | [diff] [blame] | 24 | |
| 25 | uint8_t board_id(void) |
| 26 | { |
| 27 | static int id = -1; |
David Hendricks | a0abd51 | 2014-11-07 13:48:49 -0800 | [diff] [blame] | 28 | static gpio_t pins[] = {[3] = GPIO(2, A, 7), [2] = GPIO(2, A, 2), |
Julius Werner | 886d29b | 2014-09-24 15:40:49 -0700 | [diff] [blame] | 29 | [1] = GPIO(2, A, 1), [0] = GPIO(2, A, 0)}; /* GPIO2_A0 is LSB */ |
Julius Werner | 72001e7 | 2014-09-10 15:30:49 -0700 | [diff] [blame] | 30 | |
| 31 | if (id < 0) { |
David Hendricks | a0abd51 | 2014-11-07 13:48:49 -0800 | [diff] [blame] | 32 | id = gpio_base2_value(pins, ARRAY_SIZE(pins)); |
Julius Werner | 886d29b | 2014-09-24 15:40:49 -0700 | [diff] [blame] | 33 | printk(BIOS_SPEW, "Board ID: %d.\n", id); |
Julius Werner | 72001e7 | 2014-09-10 15:30:49 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | return id; |
| 37 | } |
David Hendricks | 539e856 | 2014-11-06 16:51:02 -0800 | [diff] [blame] | 38 | |
| 39 | uint32_t ram_code(void) |
| 40 | { |
| 41 | uint32_t code; |
| 42 | static gpio_t pins[] = {[3] = GPIO(8, A, 3), [2] = GPIO(8, A, 2), |
| 43 | [1] = GPIO(8, A, 1), [0] = GPIO(8, A, 0)}; /* GPIO8_A0 is LSB */ |
| 44 | |
| 45 | code = gpio_base2_value(pins, ARRAY_SIZE(pins)); |
| 46 | printk(BIOS_SPEW, "RAM Config: %u.\n", code); |
| 47 | |
| 48 | return code; |
| 49 | } |