blob: 37542b67c57e4299738d609c3e44206be251304e [file] [log] [blame]
Peter Oruba80cc9f12008-07-28 18:44:22 +02001/*
2 * AMD CPU Microcode Update Driver for Linux
3 * Copyright (C) 2008 Advanced Micro Devices Inc.
4 *
5 * Author: Peter Oruba <peter.oruba@amd.com>
6 *
7 * Based on work by:
8 * Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
9 *
10 * This driver allows to upgrade microcode on AMD
11 * family 0x10 and 0x11 processors.
12 *
Andreas Herrmann2a3282a72008-12-16 19:08:53 +010013 * Licensed under the terms of the GNU General Public
Peter Oruba80cc9f12008-07-28 18:44:22 +020014 * License version 2. See file COPYING for details.
Ingo Molnar4bae1962009-03-11 11:19:46 +010015 */
Joe Perchesf58e1f52009-12-08 22:30:50 -080016
17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
Ingo Molnar4bae1962009-03-11 11:19:46 +010019#include <linux/firmware.h>
Peter Oruba80cc9f12008-07-28 18:44:22 +020020#include <linux/pci_ids.h>
Andreas Herrmannbe957762008-12-16 19:11:23 +010021#include <linux/uaccess.h>
Ingo Molnar4bae1962009-03-11 11:19:46 +010022#include <linux/vmalloc.h>
23#include <linux/kernel.h>
24#include <linux/module.h>
Ingo Molnar4bae1962009-03-11 11:19:46 +010025#include <linux/pci.h>
Peter Oruba80cc9f12008-07-28 18:44:22 +020026
Peter Oruba80cc9f12008-07-28 18:44:22 +020027#include <asm/microcode.h>
Ingo Molnar4bae1962009-03-11 11:19:46 +010028#include <asm/processor.h>
29#include <asm/msr.h>
Peter Oruba80cc9f12008-07-28 18:44:22 +020030
31MODULE_DESCRIPTION("AMD Microcode Update Driver");
Peter Oruba3c522042008-10-17 15:30:38 +020032MODULE_AUTHOR("Peter Oruba");
Ingo Molnar5d7b6052008-07-29 10:07:36 +020033MODULE_LICENSE("GPL v2");
Peter Oruba80cc9f12008-07-28 18:44:22 +020034
35#define UCODE_MAGIC 0x00414d44
36#define UCODE_EQUIV_CPU_TABLE_TYPE 0x00000000
37#define UCODE_UCODE_TYPE 0x00000001
38
Andreas Herrmannd1c84f72009-11-10 12:07:23 +010039const struct firmware *firmware;
Andreas Herrmann8cc23612009-11-17 08:06:38 +010040static int supported_cpu;
Andreas Herrmannd1c84f72009-11-10 12:07:23 +010041
Dmitry Adamushko18dbc912008-09-23 12:08:44 +020042struct equiv_cpu_entry {
Andreas Herrmann5549b942008-12-16 19:21:30 +010043 u32 installed_cpu;
44 u32 fixed_errata_mask;
45 u32 fixed_errata_compare;
46 u16 equiv_cpu;
47 u16 res;
48} __attribute__((packed));
Dmitry Adamushko18dbc912008-09-23 12:08:44 +020049
50struct microcode_header_amd {
Andreas Herrmann5549b942008-12-16 19:21:30 +010051 u32 data_code;
52 u32 patch_id;
53 u16 mc_patch_data_id;
54 u8 mc_patch_data_len;
55 u8 init_flag;
56 u32 mc_patch_data_checksum;
57 u32 nb_dev_id;
58 u32 sb_dev_id;
59 u16 processor_rev_id;
60 u8 nb_rev_id;
61 u8 sb_rev_id;
62 u8 bios_api_rev;
63 u8 reserved1[3];
64 u32 match_reg[8];
65} __attribute__((packed));
Dmitry Adamushko18dbc912008-09-23 12:08:44 +020066
67struct microcode_amd {
Ingo Molnar4bae1962009-03-11 11:19:46 +010068 struct microcode_header_amd hdr;
69 unsigned int mpb[0];
Dmitry Adamushko18dbc912008-09-23 12:08:44 +020070};
71
Andreas Herrmann6cc9b6d2008-12-16 19:17:45 +010072#define UCODE_MAX_SIZE 2048
73#define UCODE_CONTAINER_SECTION_HDR 8
74#define UCODE_CONTAINER_HEADER_SIZE 12
Peter Oruba80cc9f12008-07-28 18:44:22 +020075
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +020076static struct equiv_cpu_entry *equiv_cpu_table;
Peter Oruba80cc9f12008-07-28 18:44:22 +020077
Dmitry Adamushkod45de402008-08-20 00:22:26 +020078static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig)
Peter Oruba80cc9f12008-07-28 18:44:22 +020079{
Andreas Herrmann29d08872008-12-16 19:16:34 +010080 u32 dummy;
Peter Oruba80cc9f12008-07-28 18:44:22 +020081
Andreas Herrmann8cc23612009-11-17 08:06:38 +010082 if (!supported_cpu)
Dmitry Adamushkod45de402008-08-20 00:22:26 +020083 return -1;
Andreas Herrmann8cc23612009-11-17 08:06:38 +010084
85 memset(csig, 0, sizeof(*csig));
Andreas Herrmann29d08872008-12-16 19:16:34 +010086 rdmsr(MSR_AMD64_PATCH_LEVEL, csig->rev, dummy);
Joe Perchesf58e1f52009-12-08 22:30:50 -080087 pr_info("CPU%d: patch_level=0x%x\n", cpu, csig->rev);
Dmitry Adamushkod45de402008-08-20 00:22:26 +020088 return 0;
Peter Oruba80cc9f12008-07-28 18:44:22 +020089}
90
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +020091static int get_matching_microcode(int cpu, void *mc, int rev)
Peter Oruba80cc9f12008-07-28 18:44:22 +020092{
Peter Oruba80cc9f12008-07-28 18:44:22 +020093 struct microcode_header_amd *mc_header = mc;
Peter Oruba80cc9f12008-07-28 18:44:22 +020094 unsigned int current_cpu_id;
Andreas Herrmann5549b942008-12-16 19:21:30 +010095 u16 equiv_cpu_id = 0;
Peter Oruba80cc9f12008-07-28 18:44:22 +020096 unsigned int i = 0;
97
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +020098 BUG_ON(equiv_cpu_table == NULL);
Peter Oruba80cc9f12008-07-28 18:44:22 +020099 current_cpu_id = cpuid_eax(0x00000001);
100
101 while (equiv_cpu_table[i].installed_cpu != 0) {
102 if (current_cpu_id == equiv_cpu_table[i].installed_cpu) {
Andreas Herrmann5549b942008-12-16 19:21:30 +0100103 equiv_cpu_id = equiv_cpu_table[i].equiv_cpu;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200104 break;
105 }
106 i++;
107 }
108
Andreas Herrmann14c56942009-11-10 12:08:25 +0100109 if (!equiv_cpu_id)
Peter Oruba80cc9f12008-07-28 18:44:22 +0200110 return 0;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200111
Andreas Herrmann6e18da72009-10-29 14:47:42 +0100112 if (mc_header->processor_rev_id != equiv_cpu_id)
Peter Oruba80cc9f12008-07-28 18:44:22 +0200113 return 0;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200114
Andreas Herrmann98415302008-12-16 19:20:21 +0100115 /* ucode might be chipset specific -- currently we don't support this */
116 if (mc_header->nb_dev_id || mc_header->sb_dev_id) {
Joe Perchesf58e1f52009-12-08 22:30:50 -0800117 pr_err("CPU%d: loading of chipset specific code not yet supported\n",
118 cpu);
Andreas Herrmann98415302008-12-16 19:20:21 +0100119 return 0;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200120 }
121
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200122 if (mc_header->patch_id <= rev)
Peter Oruba80cc9f12008-07-28 18:44:22 +0200123 return 0;
124
Peter Oruba80cc9f12008-07-28 18:44:22 +0200125 return 1;
126}
127
Dmitry Adamushko871b72d2009-05-11 23:48:27 +0200128static int apply_microcode_amd(int cpu)
Peter Oruba80cc9f12008-07-28 18:44:22 +0200129{
Andreas Herrmann29d08872008-12-16 19:16:34 +0100130 u32 rev, dummy;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200131 int cpu_num = raw_smp_processor_id();
132 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
Dmitry Adamushko18dbc912008-09-23 12:08:44 +0200133 struct microcode_amd *mc_amd = uci->mc;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200134
135 /* We should bind the task to the CPU */
136 BUG_ON(cpu_num != cpu);
137
Dmitry Adamushko18dbc912008-09-23 12:08:44 +0200138 if (mc_amd == NULL)
Dmitry Adamushko871b72d2009-05-11 23:48:27 +0200139 return 0;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200140
Ingo Molnarf34a10b2008-12-19 01:36:14 +0100141 wrmsrl(MSR_AMD64_PATCH_LOADER, (u64)(long)&mc_amd->hdr.data_code);
Peter Oruba80cc9f12008-07-28 18:44:22 +0200142 /* get patch id after patching */
Andreas Herrmann29d08872008-12-16 19:16:34 +0100143 rdmsr(MSR_AMD64_PATCH_LEVEL, rev, dummy);
Peter Oruba80cc9f12008-07-28 18:44:22 +0200144
145 /* check current patch id and patch's id for match */
Dmitry Adamushko18dbc912008-09-23 12:08:44 +0200146 if (rev != mc_amd->hdr.patch_id) {
Joe Perchesf58e1f52009-12-08 22:30:50 -0800147 pr_err("CPU%d: update failed (for patch_level=0x%x)\n",
148 cpu, mc_amd->hdr.patch_id);
Dmitry Adamushko871b72d2009-05-11 23:48:27 +0200149 return -1;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200150 }
151
Joe Perchesf58e1f52009-12-08 22:30:50 -0800152 pr_info("CPU%d: updated (new patch_level=0x%x)\n", cpu, rev);
Dmitry Adamushkod45de402008-08-20 00:22:26 +0200153 uci->cpu_sig.rev = rev;
Dmitry Adamushko871b72d2009-05-11 23:48:27 +0200154
155 return 0;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200156}
157
Andreas Herrmann0657d9e2008-12-16 19:14:05 +0100158static int get_ucode_data(void *to, const u8 *from, size_t n)
159{
160 memcpy(to, from, n);
161 return 0;
162}
163
Ingo Molnar4bae1962009-03-11 11:19:46 +0100164static void *
165get_next_ucode(const u8 *buf, unsigned int size, unsigned int *mc_size)
Peter Oruba80cc9f12008-07-28 18:44:22 +0200166{
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200167 unsigned int total_size;
Peter Orubad4738792008-09-17 15:39:18 +0200168 u8 section_hdr[UCODE_CONTAINER_SECTION_HDR];
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200169 void *mc;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200170
Peter Orubad4738792008-09-17 15:39:18 +0200171 if (get_ucode_data(section_hdr, buf, UCODE_CONTAINER_SECTION_HDR))
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200172 return NULL;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200173
Peter Orubad4738792008-09-17 15:39:18 +0200174 if (section_hdr[0] != UCODE_UCODE_TYPE) {
Joe Perchesf58e1f52009-12-08 22:30:50 -0800175 pr_err("error: invalid type field in container file section header\n");
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200176 return NULL;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200177 }
178
Peter Orubad4738792008-09-17 15:39:18 +0200179 total_size = (unsigned long) (section_hdr[4] + (section_hdr[5] << 8));
Peter Oruba80cc9f12008-07-28 18:44:22 +0200180
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200181 if (total_size > size || total_size > UCODE_MAX_SIZE) {
Joe Perchesf58e1f52009-12-08 22:30:50 -0800182 pr_err("error: size mismatch\n");
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200183 return NULL;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200184 }
185
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200186 mc = vmalloc(UCODE_MAX_SIZE);
187 if (mc) {
188 memset(mc, 0, UCODE_MAX_SIZE);
Andreas Herrmannbe957762008-12-16 19:11:23 +0100189 if (get_ucode_data(mc, buf + UCODE_CONTAINER_SECTION_HDR,
190 total_size)) {
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200191 vfree(mc);
192 mc = NULL;
193 } else
Peter Orubad4738792008-09-17 15:39:18 +0200194 *mc_size = total_size + UCODE_CONTAINER_SECTION_HDR;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200195 }
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200196 return mc;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200197}
198
Andreas Herrmann0657d9e2008-12-16 19:14:05 +0100199static int install_equiv_cpu_table(const u8 *buf)
Peter Oruba80cc9f12008-07-28 18:44:22 +0200200{
Peter Orubab6cffde2008-09-17 15:05:52 +0200201 u8 *container_hdr[UCODE_CONTAINER_HEADER_SIZE];
202 unsigned int *buf_pos = (unsigned int *)container_hdr;
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200203 unsigned long size;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200204
Peter Orubab6cffde2008-09-17 15:05:52 +0200205 if (get_ucode_data(&container_hdr, buf, UCODE_CONTAINER_HEADER_SIZE))
Peter Oruba80cc9f12008-07-28 18:44:22 +0200206 return 0;
207
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200208 size = buf_pos[2];
Peter Oruba80cc9f12008-07-28 18:44:22 +0200209
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200210 if (buf_pos[1] != UCODE_EQUIV_CPU_TABLE_TYPE || !size) {
Joe Perchesf58e1f52009-12-08 22:30:50 -0800211 pr_err("error: invalid type field in container file section header\n");
Peter Oruba80cc9f12008-07-28 18:44:22 +0200212 return 0;
213 }
214
215 equiv_cpu_table = (struct equiv_cpu_entry *) vmalloc(size);
216 if (!equiv_cpu_table) {
Joe Perchesf58e1f52009-12-08 22:30:50 -0800217 pr_err("failed to allocate equivalent CPU table\n");
Peter Oruba80cc9f12008-07-28 18:44:22 +0200218 return 0;
219 }
220
Peter Orubab6cffde2008-09-17 15:05:52 +0200221 buf += UCODE_CONTAINER_HEADER_SIZE;
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200222 if (get_ucode_data(equiv_cpu_table, buf, size)) {
223 vfree(equiv_cpu_table);
224 return 0;
225 }
Peter Oruba80cc9f12008-07-28 18:44:22 +0200226
Peter Orubab6cffde2008-09-17 15:05:52 +0200227 return size + UCODE_CONTAINER_HEADER_SIZE; /* add header length */
Peter Oruba80cc9f12008-07-28 18:44:22 +0200228}
229
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200230static void free_equiv_cpu_table(void)
Peter Oruba80cc9f12008-07-28 18:44:22 +0200231{
Figo.zhangaeef50b2009-06-07 22:30:36 +0800232 vfree(equiv_cpu_table);
233 equiv_cpu_table = NULL;
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200234}
Peter Oruba80cc9f12008-07-28 18:44:22 +0200235
Dmitry Adamushko871b72d2009-05-11 23:48:27 +0200236static enum ucode_state
237generic_load_microcode(int cpu, const u8 *data, size_t size)
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200238{
239 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
Andreas Herrmann8c135202008-12-16 19:13:00 +0100240 const u8 *ucode_ptr = data;
241 void *new_mc = NULL;
242 void *mc;
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200243 int new_rev = uci->cpu_sig.rev;
244 unsigned int leftover;
245 unsigned long offset;
Dmitry Adamushko871b72d2009-05-11 23:48:27 +0200246 enum ucode_state state = UCODE_OK;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200247
Andreas Herrmann0657d9e2008-12-16 19:14:05 +0100248 offset = install_equiv_cpu_table(ucode_ptr);
Peter Oruba80cc9f12008-07-28 18:44:22 +0200249 if (!offset) {
Joe Perchesf58e1f52009-12-08 22:30:50 -0800250 pr_err("failed to create equivalent cpu table\n");
Dmitry Adamushko871b72d2009-05-11 23:48:27 +0200251 return UCODE_ERROR;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200252 }
253
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200254 ucode_ptr += offset;
255 leftover = size - offset;
256
257 while (leftover) {
Dmitry Adamushko2f9284e2008-09-23 22:56:35 +0200258 unsigned int uninitialized_var(mc_size);
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200259 struct microcode_header_amd *mc_header;
260
Andreas Herrmann0657d9e2008-12-16 19:14:05 +0100261 mc = get_next_ucode(ucode_ptr, leftover, &mc_size);
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200262 if (!mc)
Peter Oruba80cc9f12008-07-28 18:44:22 +0200263 break;
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200264
265 mc_header = (struct microcode_header_amd *)mc;
266 if (get_matching_microcode(cpu, mc, new_rev)) {
Figo.zhangaeef50b2009-06-07 22:30:36 +0800267 vfree(new_mc);
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200268 new_rev = mc_header->patch_id;
269 new_mc = mc;
Andreas Herrmannbe957762008-12-16 19:11:23 +0100270 } else
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200271 vfree(mc);
272
273 ucode_ptr += mc_size;
274 leftover -= mc_size;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200275 }
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200276
277 if (new_mc) {
278 if (!leftover) {
Figo.zhangaeef50b2009-06-07 22:30:36 +0800279 vfree(uci->mc);
Dmitry Adamushko18dbc912008-09-23 12:08:44 +0200280 uci->mc = new_mc;
Joe Perchesf58e1f52009-12-08 22:30:50 -0800281 pr_debug("CPU%d found a matching microcode update with version 0x%x (current=0x%x)\n",
Andreas Herrmannbe957762008-12-16 19:11:23 +0100282 cpu, new_rev, uci->cpu_sig.rev);
Dmitry Adamushko871b72d2009-05-11 23:48:27 +0200283 } else {
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200284 vfree(new_mc);
Dmitry Adamushko871b72d2009-05-11 23:48:27 +0200285 state = UCODE_ERROR;
286 }
287 } else
288 state = UCODE_NFOUND;
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200289
290 free_equiv_cpu_table();
291
Dmitry Adamushko871b72d2009-05-11 23:48:27 +0200292 return state;
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200293}
294
Dmitry Adamushko871b72d2009-05-11 23:48:27 +0200295static enum ucode_state request_microcode_fw(int cpu, struct device *device)
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200296{
Dmitry Adamushko871b72d2009-05-11 23:48:27 +0200297 enum ucode_state ret;
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200298
Andreas Herrmannd1c84f72009-11-10 12:07:23 +0100299 if (firmware == NULL)
Dmitry Adamushko871b72d2009-05-11 23:48:27 +0200300 return UCODE_NFOUND;
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200301
Borislav Petkov506f90e2009-10-29 14:45:52 +0100302 if (*(u32 *)firmware->data != UCODE_MAGIC) {
Joe Perchesf58e1f52009-12-08 22:30:50 -0800303 pr_err("invalid UCODE_MAGIC (0x%08x)\n",
Borislav Petkov506f90e2009-10-29 14:45:52 +0100304 *(u32 *)firmware->data);
305 return UCODE_ERROR;
306 }
307
Andreas Herrmann0657d9e2008-12-16 19:14:05 +0100308 ret = generic_load_microcode(cpu, firmware->data, firmware->size);
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200309
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200310 return ret;
311}
312
Dmitry Adamushko871b72d2009-05-11 23:48:27 +0200313static enum ucode_state
314request_microcode_user(int cpu, const void __user *buf, size_t size)
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200315{
Joe Perchesf58e1f52009-12-08 22:30:50 -0800316 pr_info("AMD microcode update via /dev/cpu/microcode not supported\n");
Dmitry Adamushko871b72d2009-05-11 23:48:27 +0200317 return UCODE_ERROR;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200318}
319
Peter Oruba80cc9f12008-07-28 18:44:22 +0200320static void microcode_fini_cpu_amd(int cpu)
321{
322 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
323
Dmitry Adamushko18dbc912008-09-23 12:08:44 +0200324 vfree(uci->mc);
325 uci->mc = NULL;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200326}
327
Andreas Herrmannd1c84f72009-11-10 12:07:23 +0100328void init_microcode_amd(struct device *device)
329{
330 const char *fw_name = "amd-ucode/microcode_amd.bin";
Andreas Herrmann8cc23612009-11-17 08:06:38 +0100331 struct cpuinfo_x86 *c = &boot_cpu_data;
332
333 WARN_ON(c->x86_vendor != X86_VENDOR_AMD);
334
335 if (c->x86 < 0x10) {
Joe Perchesf58e1f52009-12-08 22:30:50 -0800336 pr_warning("AMD CPU family 0x%x not supported\n", c->x86);
Andreas Herrmann8cc23612009-11-17 08:06:38 +0100337 return;
338 }
339 supported_cpu = 1;
340
Andreas Herrmannd1c84f72009-11-10 12:07:23 +0100341 if (request_firmware(&firmware, fw_name, device))
Joe Perchesf58e1f52009-12-08 22:30:50 -0800342 pr_err("failed to load file %s\n", fw_name);
Andreas Herrmannd1c84f72009-11-10 12:07:23 +0100343}
344
345void fini_microcode_amd(void)
346{
347 release_firmware(firmware);
348}
349
Peter Oruba80cc9f12008-07-28 18:44:22 +0200350static struct microcode_ops microcode_amd_ops = {
Andreas Herrmannd1c84f72009-11-10 12:07:23 +0100351 .init = init_microcode_amd,
352 .fini = fini_microcode_amd,
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200353 .request_microcode_user = request_microcode_user,
354 .request_microcode_fw = request_microcode_fw,
Peter Oruba80cc9f12008-07-28 18:44:22 +0200355 .collect_cpu_info = collect_cpu_info_amd,
356 .apply_microcode = apply_microcode_amd,
357 .microcode_fini_cpu = microcode_fini_cpu_amd,
358};
359
Dmitry Adamushko18dbc912008-09-23 12:08:44 +0200360struct microcode_ops * __init init_amd_microcode(void)
Peter Oruba80cc9f12008-07-28 18:44:22 +0200361{
Dmitry Adamushko18dbc912008-09-23 12:08:44 +0200362 return &microcode_amd_ops;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200363}