blob: 2d776909f6b10a723a4ee547edfc8a87fe99b9fc [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 *
Timothy Pearson9c810662015-01-30 23:47:45 -06004 * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering
Marc Jones8ae8c882007-12-19 01:32:08 +00005 * Copyright (C) 2007 Advanced Micro Devices, Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Marc Jones8ae8c882007-12-19 01:32:08 +000015 */
16
Kyösti Mälkkif0a13ce2013-12-08 07:20:48 +020017#include <stdint.h>
Marc Jones8ae8c882007-12-19 01:32:08 +000018#include <cpu/amd/microcode.h>
Marc Jones8ae8c882007-12-19 01:32:08 +000019
Timothy Pearson9c810662015-01-30 23:47:45 -060020struct id_mapping {
21 uint32_t orig_id;
22 uint16_t new_id;
23};
24
25static u16 get_equivalent_processor_rev_id(u32 orig_id) {
26 static const struct id_mapping id_mapping_table[] = {
Timothy Pearson730a0432015-10-16 13:51:51 -050027 /* Family 10h */
Timothy Pearson9c810662015-01-30 23:47:45 -060028 { 0x100f00, 0x1000 },
29 { 0x100f01, 0x1000 },
30 { 0x100f02, 0x1000 },
31 { 0x100f20, 0x1020 },
Nicolas Reinecke09088392015-02-11 23:01:17 +010032 { 0x100f21, 0x1020 }, /* DR-B1 */
33 { 0x100f2A, 0x1020 }, /* DR-BA */
34 { 0x100f22, 0x1022 }, /* DR-B2 */
35 { 0x100f23, 0x1022 }, /* DR-B3 */
36 { 0x100f42, 0x1041 }, /* RB-C2 */
37 { 0x100f43, 0x1043 }, /* RB-C3 */
38 { 0x100f52, 0x1041 }, /* BL-C2 */
39 { 0x100f62, 0x1062 }, /* DA-C2 */
40 { 0x100f63, 0x1043 }, /* DA-C3 */
41 { 0x100f81, 0x1081 }, /* HY-D1 */
Timothy Pearson730a0432015-10-16 13:51:51 -050042 { 0x100f91, 0x1081 }, /* HY-D1 */
Nicolas Reinecke09088392015-02-11 23:01:17 +010043 { 0x100fa0, 0x10A0 }, /* PH-E0 */
Timothy Pearson9c810662015-01-30 23:47:45 -060044
Timothy Pearson730a0432015-10-16 13:51:51 -050045 /* Family 15h */
46 { 0x600f12, 0x6012 }, /* OR-B2 */
47 { 0x600f20, 0x6020 }, /* OR-C0 */
48
Timothy Pearson9c810662015-01-30 23:47:45 -060049 /* Array terminator */
50 { 0xffffff, 0x0000 },
Marc Jones8ae8c882007-12-19 01:32:08 +000051 };
52
53 u32 new_id;
54 int i;
55
56 new_id = 0;
57
Nicolas Reinecke09088392015-02-11 23:01:17 +010058 for (i = 0; id_mapping_table[i].orig_id != 0xffffff; i++) {
Timothy Pearson9c810662015-01-30 23:47:45 -060059 if (id_mapping_table[i].orig_id == orig_id) {
60 new_id = id_mapping_table[i].new_id;
Marc Jones8ae8c882007-12-19 01:32:08 +000061 break;
62 }
63 }
64
65 return new_id;
66
67}
68
69void update_microcode(u32 cpu_deviceid)
70{
Kyösti Mälkki5fe1fb7a2013-12-08 07:21:05 +020071 u32 equivalent_processor_rev_id = get_equivalent_processor_rev_id(cpu_deviceid);
72 amd_update_microcode_from_cbfs(equivalent_processor_rev_id);
Marc Jones8ae8c882007-12-19 01:32:08 +000073}