Timothy Pearson | ead8751 | 2015-02-20 12:47:52 -0600 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering |
| 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. |
Timothy Pearson | ead8751 | 2015-02-20 12:47:52 -0600 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <console/console.h> |
| 18 | |
| 19 | #include <arch/cpu.h> |
Damien Zammit | 75a3d1f | 2016-11-28 00:29:10 +1100 | [diff] [blame] | 20 | #include <arch/io.h> |
| 21 | #include "raminit.h" |
Timothy Pearson | ead8751 | 2015-02-20 12:47:52 -0600 | [diff] [blame] | 22 | #include <northbridge/amd/amdmct/amddefs.h> |
| 23 | |
| 24 | #ifndef __PRE_RAM__ |
| 25 | #include <include/device/pci_ops.h> |
| 26 | #include <include/device/pci_def.h> |
| 27 | u32 Get_NB32(u32 dev, u32 reg) |
| 28 | { |
| 29 | return pci_read_config32(dev_find_slot(0, PCI_DEV2DEVFN(dev)), reg); |
| 30 | } |
| 31 | #endif |
| 32 | |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 33 | uint64_t mctGetLogicalCPUID(u32 Node) |
Timothy Pearson | ead8751 | 2015-02-20 12:47:52 -0600 | [diff] [blame] | 34 | { |
| 35 | /* Converts the CPUID to a logical ID MASK that is used to check |
| 36 | CPU version support versions */ |
| 37 | u32 dev; |
| 38 | u32 val, valx; |
| 39 | u32 family, model, stepping; |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 40 | uint64_t ret; |
Timothy Pearson | ead8751 | 2015-02-20 12:47:52 -0600 | [diff] [blame] | 41 | |
| 42 | if (Node == 0xFF) { /* current node */ |
| 43 | val = cpuid_eax(0x80000001); |
| 44 | } else { |
| 45 | dev = PA_NBMISC(Node); |
| 46 | val = Get_NB32(dev, 0xfc); |
| 47 | } |
| 48 | |
| 49 | family = ((val >> 8) & 0x0f) + ((val >> 20) & 0xff); |
| 50 | model = ((val >> 4) & 0x0f) | ((val >> (16-4)) & 0xf0); |
| 51 | stepping = val & 0x0f; |
| 52 | |
| 53 | valx = (family << 12) | (model << 4) | (stepping); |
| 54 | |
| 55 | switch (valx) { |
| 56 | case 0x10000: |
| 57 | ret = AMD_DR_A0A; |
| 58 | break; |
| 59 | case 0x10001: |
| 60 | ret = AMD_DR_A1B; |
| 61 | break; |
| 62 | case 0x10002: |
| 63 | ret = AMD_DR_A2; |
| 64 | break; |
| 65 | case 0x10020: |
| 66 | ret = AMD_DR_B0; |
| 67 | break; |
| 68 | case 0x10021: |
| 69 | ret = AMD_DR_B1; |
| 70 | break; |
| 71 | case 0x10022: |
| 72 | ret = AMD_DR_B2; |
| 73 | break; |
| 74 | case 0x10023: |
| 75 | ret = AMD_DR_B3; |
| 76 | break; |
| 77 | case 0x10042: |
| 78 | ret = AMD_RB_C2; |
| 79 | break; |
| 80 | case 0x10043: |
| 81 | ret = AMD_RB_C3; |
| 82 | break; |
| 83 | case 0x10062: |
| 84 | ret = AMD_DA_C2; |
| 85 | break; |
| 86 | case 0x10063: |
| 87 | ret = AMD_DA_C3; |
| 88 | break; |
| 89 | case 0x10080: |
| 90 | ret = AMD_HY_D0; |
| 91 | break; |
| 92 | case 0x10081: |
| 93 | case 0x10091: |
| 94 | ret = AMD_HY_D1; |
| 95 | break; |
| 96 | case 0x100a0: |
| 97 | ret = AMD_PH_E0; |
| 98 | break; |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 99 | case 0x15012: |
| 100 | case 0x1501f: |
| 101 | ret = AMD_OR_B2; |
| 102 | break; |
| 103 | case 0x15020: |
Damien Zammit | 33aaa92 | 2016-02-10 14:01:36 +1100 | [diff] [blame] | 104 | case 0x15101: |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 105 | ret = AMD_OR_C0; |
| 106 | break; |
Timothy Pearson | ead8751 | 2015-02-20 12:47:52 -0600 | [diff] [blame] | 107 | default: |
| 108 | /* FIXME: mabe we should die() here. */ |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 109 | printk(BIOS_ERR, "FIXME! CPU Version unknown or not supported! %08x\n", valx); |
Timothy Pearson | ead8751 | 2015-02-20 12:47:52 -0600 | [diff] [blame] | 110 | ret = 0; |
| 111 | } |
| 112 | |
| 113 | return ret; |
| 114 | } |