blob: 4a2db4e4d4cd5b75f76979276e52a998d6748191 [file] [log] [blame]
Marc Jones8ae8c882007-12-19 01:32:08 +00001/*
Stefan Reinauer7e61e452008-01-18 10:35:56 +00002 * This file is part of the coreboot project.
Marc Jones8ae8c882007-12-19 01:32:08 +00003 *
Marc Jones8ae8c882007-12-19 01:32:08 +00004 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
Marc Jones8ae8c882007-12-19 01:32:08 +000012 */
13
Kyösti Mälkkif0a13ce2013-12-08 07:20:48 +020014#include <stdint.h>
Marc Jones8ae8c882007-12-19 01:32:08 +000015#include <cpu/amd/microcode.h>
Marc Jones8ae8c882007-12-19 01:32:08 +000016
Timothy Pearson9c810662015-01-30 23:47:45 -060017struct id_mapping {
Elyes HAOUAS2765a892016-09-01 19:44:56 +020018 uint32_t orig_id;
19 uint16_t new_id;
Timothy Pearson9c810662015-01-30 23:47:45 -060020};
21
22static u16 get_equivalent_processor_rev_id(u32 orig_id) {
23 static const struct id_mapping id_mapping_table[] = {
Timothy Pearson730a0432015-10-16 13:51:51 -050024 /* Family 10h */
Timothy Pearson9c810662015-01-30 23:47:45 -060025 { 0x100f00, 0x1000 },
26 { 0x100f01, 0x1000 },
27 { 0x100f02, 0x1000 },
28 { 0x100f20, 0x1020 },
Nicolas Reinecke09088392015-02-11 23:01:17 +010029 { 0x100f21, 0x1020 }, /* DR-B1 */
30 { 0x100f2A, 0x1020 }, /* DR-BA */
31 { 0x100f22, 0x1022 }, /* DR-B2 */
32 { 0x100f23, 0x1022 }, /* DR-B3 */
33 { 0x100f42, 0x1041 }, /* RB-C2 */
34 { 0x100f43, 0x1043 }, /* RB-C3 */
35 { 0x100f52, 0x1041 }, /* BL-C2 */
36 { 0x100f62, 0x1062 }, /* DA-C2 */
37 { 0x100f63, 0x1043 }, /* DA-C3 */
38 { 0x100f81, 0x1081 }, /* HY-D1 */
Timothy Pearson730a0432015-10-16 13:51:51 -050039 { 0x100f91, 0x1081 }, /* HY-D1 */
Nicolas Reinecke09088392015-02-11 23:01:17 +010040 { 0x100fa0, 0x10A0 }, /* PH-E0 */
Timothy Pearson9c810662015-01-30 23:47:45 -060041
Timothy Pearson730a0432015-10-16 13:51:51 -050042 /* Family 15h */
43 { 0x600f12, 0x6012 }, /* OR-B2 */
44 { 0x600f20, 0x6020 }, /* OR-C0 */
45
Timothy Pearson9c810662015-01-30 23:47:45 -060046 /* Array terminator */
47 { 0xffffff, 0x0000 },
Marc Jones8ae8c882007-12-19 01:32:08 +000048 };
49
50 u32 new_id;
51 int i;
52
53 new_id = 0;
54
Nicolas Reinecke09088392015-02-11 23:01:17 +010055 for (i = 0; id_mapping_table[i].orig_id != 0xffffff; i++) {
Timothy Pearson9c810662015-01-30 23:47:45 -060056 if (id_mapping_table[i].orig_id == orig_id) {
57 new_id = id_mapping_table[i].new_id;
Marc Jones8ae8c882007-12-19 01:32:08 +000058 break;
59 }
60 }
61
62 return new_id;
63
64}
65
66void update_microcode(u32 cpu_deviceid)
67{
Kyösti Mälkki5fe1fb7a2013-12-08 07:21:05 +020068 u32 equivalent_processor_rev_id = get_equivalent_processor_rev_id(cpu_deviceid);
69 amd_update_microcode_from_cbfs(equivalent_processor_rev_id);
Marc Jones8ae8c882007-12-19 01:32:08 +000070}