blob: 1136f464f27c01117c2c0890bb7685400139ecef [file] [log] [blame]
CC Ma86933f82015-07-31 17:10:58 +08001/*
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.
CC Ma86933f82015-07-31 17:10:58 +080014 */
15
16#include <boardid.h>
17#include <gpio.h>
18#include <console/console.h>
19#include <stdlib.h>
20#include "gpio.h"
21
22static int board_id_value = -1;
23
24static uint8_t get_board_id(void)
25{
26 uint8_t bid = 0;
27 static gpio_t pins[] = {[2] = BOARD_ID_2, [1] = BOARD_ID_1,
28 [0] = BOARD_ID_0};
29
30 bid = gpio_base2_value(pins, ARRAY_SIZE(pins));
31
32 printk(BIOS_INFO, "Board ID %d\n", bid);
33
34 return bid;
35}
36
37uint8_t board_id(void)
38{
39 if (board_id_value < 0)
40 board_id_value = get_board_id();
41
42 return board_id_value;
43}
44
45uint32_t ram_code(void)
46{
47 uint32_t code;
48 static gpio_t pins[] = {[3] = RAM_ID_3, [2] = RAM_ID_2, [1] = RAM_ID_1,
49 [0] = RAM_ID_0};
50
51 code = gpio_base2_value(pins, ARRAY_SIZE(pins));
52
53 printk(BIOS_INFO, "RAM Config: %u\n", code);
54
55 return code;
56}