summaryrefslogtreecommitdiff
path: root/src/mainboard/amd/bettong/boardid.c
blob: 21d04762041d3dfaafb822fafd10ca91d376ed9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * This file is part of the coreboot project.
 *
 * Copyright (C) 2015 Advanced Micro Devices, 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.
 */

#include <stdint.h>
#include <amdblocks/acpimmio.h>
#include <device/mmio.h>
#include <southbridge/amd/common/amd_defs.h>
#include <boardid.h>

/**
 *Bettong uses 3 GPIO(5-7) pins to identify board.
 *The GPIO ports are mapped to MMIO space.
 *The GPIO value and board version are mapped as follow:
 *GPIO5 GPIO6 GPIO7 Version
 *  0     0     0      A
 *  0     0     1      B
 *  ......
 *  1     1     1      H
 */
uint32_t board_id(void)
{
	u8  value = 0;
	u8  boardrev = 0;
	char boardid;

	value = gpio0_read8((7 << 2) + 2); /* agpio7: board_id2 */
	boardrev = value & 1;
	value = gpio0_read8((6 << 2) + 2); /* agpio6: board_id1 */
	boardrev |= (value & 1) << 1;
	value = gpio0_read8((5 << 2) + 2); /* agpio5: board_id0 */
	boardrev |= (value & 1) << 2;

	boardid = 'A' + boardrev;

	return boardid;
}