common: Drop asm/global_data.h from common header
[platform/kernel/u-boot.git] / arch / x86 / cpu / intel_common / microcode.c
index eac5b78..4d8e1d2 100644 (file)
@@ -1,16 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2014 Google, Inc
  * Copyright (C) 2000 Ronald G. Minnich
  *
  * Microcode update for Intel PIII and later CPUs
- *
- * SPDX-License-Identifier:    GPL-2.0
  */
 
 #include <common.h>
 #include <errno.h>
 #include <fdtdec.h>
-#include <libfdt.h>
+#include <log.h>
+#include <asm/global_data.h>
+#include <linux/libfdt.h>
 #include <asm/cpu.h>
 #include <asm/microcode.h>
 #include <asm/msr.h>
@@ -44,8 +45,6 @@ static int microcode_decode_node(const void *blob, int node,
        update->data = fdt_getprop(blob, node, "data", &update->size);
        if (!update->data)
                return -ENOENT;
-       update->data += UCODE_HEADER_LEN;
-       update->size -= UCODE_HEADER_LEN;
 
        update->header_version = fdtdec_get_int(blob, node,
                                                "intel,header-version", 0);
@@ -125,6 +124,7 @@ static void microcode_read_cpu(struct microcode_update *cpu)
 int microcode_update_intel(void)
 {
        struct microcode_update cpu, update;
+       ulong address;
        const void *blob = gd->fdt_blob;
        int skipped;
        int count;
@@ -168,7 +168,8 @@ int microcode_update_intel(void)
                        skipped++;
                        continue;
                }
-               wrmsr(MSR_IA32_UCODE_WRITE, (ulong)update.data, 0);
+               address = (ulong)update.data + UCODE_HEADER_LEN;
+               wrmsr(MSR_IA32_UCODE_WRITE, address, 0);
                rev = microcode_read_rev();
                debug("microcode: updated to revision 0x%x date=%04x-%02x-%02x\n",
                      rev, update.date_code & 0xffff,
@@ -179,5 +180,9 @@ int microcode_update_intel(void)
                        return -EFAULT;
                }
                count++;
+               if (!ucode_base) {
+                       ucode_base = (ulong)update.data;
+                       ucode_size = update.size;
+               }
        } while (1);
 }