CC Ma | 86933f8 | 2015-07-31 17:10:58 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2015 MediaTek 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 | |
| 20 | #include <boardid.h> |
| 21 | #include <gpio.h> |
| 22 | #include <console/console.h> |
| 23 | #include <stdlib.h> |
| 24 | #include "gpio.h" |
| 25 | |
| 26 | static int board_id_value = -1; |
| 27 | |
| 28 | static uint8_t get_board_id(void) |
| 29 | { |
| 30 | uint8_t bid = 0; |
| 31 | static gpio_t pins[] = {[2] = BOARD_ID_2, [1] = BOARD_ID_1, |
| 32 | [0] = BOARD_ID_0}; |
| 33 | |
| 34 | bid = gpio_base2_value(pins, ARRAY_SIZE(pins)); |
| 35 | |
| 36 | printk(BIOS_INFO, "Board ID %d\n", bid); |
| 37 | |
| 38 | return bid; |
| 39 | } |
| 40 | |
| 41 | uint8_t board_id(void) |
| 42 | { |
| 43 | if (board_id_value < 0) |
| 44 | board_id_value = get_board_id(); |
| 45 | |
| 46 | return board_id_value; |
| 47 | } |
| 48 | |
| 49 | uint32_t ram_code(void) |
| 50 | { |
| 51 | uint32_t code; |
| 52 | static gpio_t pins[] = {[3] = RAM_ID_3, [2] = RAM_ID_2, [1] = RAM_ID_1, |
| 53 | [0] = RAM_ID_0}; |
| 54 | |
| 55 | code = gpio_base2_value(pins, ARRAY_SIZE(pins)); |
| 56 | |
| 57 | printk(BIOS_INFO, "RAM Config: %u\n", code); |
| 58 | |
| 59 | return code; |
| 60 | } |