Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 1 | /* |
Stefan Reinauer | 7e61e45 | 2008-01-18 10:35:56 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 3 | * |
Timothy Pearson | 9c81066 | 2015-01-30 23:47:45 -0600 | [diff] [blame] | 4 | * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 5 | * 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 Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
Kyösti Mälkki | f0a13ce | 2013-12-08 07:20:48 +0200 | [diff] [blame] | 17 | #include <stdint.h> |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 18 | #include <cpu/amd/microcode.h> |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 19 | |
Timothy Pearson | 9c81066 | 2015-01-30 23:47:45 -0600 | [diff] [blame] | 20 | struct id_mapping { |
| 21 | uint32_t orig_id; |
| 22 | uint16_t new_id; |
| 23 | }; |
| 24 | |
| 25 | static u16 get_equivalent_processor_rev_id(u32 orig_id) { |
| 26 | static const struct id_mapping id_mapping_table[] = { |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 27 | /* Family 10h */ |
Timothy Pearson | 9c81066 | 2015-01-30 23:47:45 -0600 | [diff] [blame] | 28 | { 0x100f00, 0x1000 }, |
| 29 | { 0x100f01, 0x1000 }, |
| 30 | { 0x100f02, 0x1000 }, |
| 31 | { 0x100f20, 0x1020 }, |
Nicolas Reinecke | 0908839 | 2015-02-11 23:01:17 +0100 | [diff] [blame] | 32 | { 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 Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 42 | { 0x100f91, 0x1081 }, /* HY-D1 */ |
Nicolas Reinecke | 0908839 | 2015-02-11 23:01:17 +0100 | [diff] [blame] | 43 | { 0x100fa0, 0x10A0 }, /* PH-E0 */ |
Timothy Pearson | 9c81066 | 2015-01-30 23:47:45 -0600 | [diff] [blame] | 44 | |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 45 | /* Family 15h */ |
| 46 | { 0x600f12, 0x6012 }, /* OR-B2 */ |
| 47 | { 0x600f20, 0x6020 }, /* OR-C0 */ |
| 48 | |
Timothy Pearson | 9c81066 | 2015-01-30 23:47:45 -0600 | [diff] [blame] | 49 | /* Array terminator */ |
| 50 | { 0xffffff, 0x0000 }, |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | u32 new_id; |
| 54 | int i; |
| 55 | |
| 56 | new_id = 0; |
| 57 | |
Nicolas Reinecke | 0908839 | 2015-02-11 23:01:17 +0100 | [diff] [blame] | 58 | for (i = 0; id_mapping_table[i].orig_id != 0xffffff; i++) { |
Timothy Pearson | 9c81066 | 2015-01-30 23:47:45 -0600 | [diff] [blame] | 59 | if (id_mapping_table[i].orig_id == orig_id) { |
| 60 | new_id = id_mapping_table[i].new_id; |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 61 | break; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | return new_id; |
| 66 | |
| 67 | } |
| 68 | |
| 69 | void update_microcode(u32 cpu_deviceid) |
| 70 | { |
Kyösti Mälkki | 5fe1fb7a | 2013-12-08 07:21:05 +0200 | [diff] [blame] | 71 | u32 equivalent_processor_rev_id = get_equivalent_processor_rev_id(cpu_deviceid); |
| 72 | amd_update_microcode_from_cbfs(equivalent_processor_rev_id); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 73 | } |