Remove some duplicate #include files (trivial).
[coreboot.git] / src / cpu / amd / model_fxx / model_fxx_update_microcode.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2005 Advanced Micro Devices, Inc.
5  * Copyright (C) 2010 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; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
20  */
21
22 #include <console/console.h>
23 #include <device/device.h>
24 #include <device/pci.h>
25 #include <string.h>
26 #include <cpu/amd/microcode.h>
27
28 static uint8_t microcode_updates[] __attribute__ ((aligned(16))) = {
29
30 #if CONFIG_K8_REV_F_SUPPORT == 0
31         #include "microcode_rev_c.h"
32         #include "microcode_rev_d.h"
33         #include "microcode_rev_e.h"
34 #endif
35
36 #if CONFIG_K8_REV_F_SUPPORT == 1
37 //      #include "microcode_rev_f.h"
38 #endif
39         /*  Dummy terminator  */
40         0x0, 0x0, 0x0, 0x0,
41         0x0, 0x0, 0x0, 0x0,
42         0x0, 0x0, 0x0, 0x0,
43         0x0, 0x0, 0x0, 0x0,
44 };
45
46 static unsigned get_equivalent_processor_rev_id(unsigned orig_id) {
47         static unsigned id_mapping_table[] = {
48         #if CONFIG_K8_REV_F_SUPPORT == 0
49                 0x0f48, 0x0048,
50                 0x0f58, 0x0048,
51
52                 0x0f4a, 0x004a,
53                 0x0f5a, 0x004a,
54                 0x0f7a, 0x004a,
55                 0x0f82, 0x004a,
56                 0x0fc0, 0x004a,
57                 0x0ff0, 0x004a,
58
59                 0x10f50, 0x0150,
60                 0x10f70, 0x0150,
61                 0x10f80, 0x0150,
62                 0x10fc0, 0x0150,
63                 0x10ff0, 0x0150,
64
65                 0x20f10, 0x0210,
66                 0x20f12, 0x0210,
67                 0x20f32, 0x0210,
68                 0x20fb1, 0x0210,
69         #endif
70
71         #if CONFIG_K8_REV_F_SUPPORT == 1
72
73         #endif
74
75         };
76
77         unsigned new_id;
78         int i;
79
80         new_id = 0;
81
82         for(i=0; i<sizeof(id_mapping_table); i+=2 ) {
83                 if(id_mapping_table[i]==orig_id) {
84                         new_id = id_mapping_table[i+1];
85                         break;
86                 }
87         }
88
89         return new_id;
90 }
91
92 void model_fxx_update_microcode(unsigned cpu_deviceid)
93 {
94         unsigned equivalent_processor_rev_id;
95
96         /* Update the microcode */
97         equivalent_processor_rev_id = get_equivalent_processor_rev_id(cpu_deviceid );
98         if(equivalent_processor_rev_id != 0)
99                 amd_update_microcode(microcode_updates, equivalent_processor_rev_id);
100 }