From e075905bfafc7588176baf0c3c4fd29cc9ec4ace Mon Sep 17 00:00:00 2001 From: Andreas Herrmann Date: Tue, 31 May 2011 08:09:54 +0200 Subject: x86info: Add support for AMD CPU family 14h Signed-off-by: Andreas Herrmann --- AMD/identify.c | 93 ++++++++++++++++++++++++++++++++++++++++------------------ AMD/powernow.c | 48 +++++++++++++++++++++++++++--- AMD/revision.h | 5 ++++ connector.c | 1 + x86info.h | 1 + 5 files changed, 116 insertions(+), 32 deletions(-) diff --git a/AMD/identify.c b/AMD/identify.c index f8da94a..056ea9c 100644 --- a/AMD/identify.c +++ b/AMD/identify.c @@ -91,26 +91,36 @@ static void set_connector(struct cpudata *c) cpuid(c->number, 0x80000001, &eax, &ebx, &ecx, &edx); pkg_id = (ebx >> 28) & 0xf; - switch (pkg_id) { - case 0: - c->connector = CONN_SOCKET_F_R2; - break; - case 1: - c->connector = CONN_SOCKET_AM3; - break; - case 2: - c->connector = CONN_SOCKET_S1G3; - break; - case 3: - c->connector = CONN_SOCKET_G34; - break; - case 4: - c->connector = CONN_SOCKET_ASB2; - break; - case 5: - c->connector = CONN_SOCKET_C32; - default: - c->connector = 0; + if ((family(c) == 0x10) || (family(c) == 0x11)) { + switch (pkg_id) { + case 0: + c->connector = CONN_SOCKET_F_R2; + break; + case 1: + c->connector = CONN_SOCKET_AM3; + break; + case 2: + c->connector = CONN_SOCKET_S1G3; + break; + case 3: + c->connector = CONN_SOCKET_G34; + break; + case 4: + c->connector = CONN_SOCKET_ASB2; + break; + case 5: + c->connector = CONN_SOCKET_C32; + default: + c->connector = 0; + } + } else if (family(c) == 0x14) { + switch (pkg_id) { + case 0: + c->connector = CONN_SOCKET_FT1; + break; + default: + c->connector = 0; + } } } @@ -143,6 +153,21 @@ static void set_fam11h_revinfo(int id, struct cpudata *c) set_connector(c); } +static void set_fam14h_revinfo(int id, struct cpudata *c) +{ + const char *p; + + p = get_fam14h_revision_name(id); + if (p) + snprintf(c->name, CPU_NAME_LEN, + "AMD C/E/G-Series Processor (%s)", p); + else + snprintf(c->name, CPU_NAME_LEN, "Unknown CPU"); + + + set_connector(c); +} + static void do_assoc(unsigned long assoc) { switch (assoc & 0xff) { @@ -378,14 +403,26 @@ void Identify_AMD(struct cpudata *cpu) cpu->efamily = 0; } - if (family(cpu) == 0xf) { - set_k8_revinfo(eax, cpu); - return; - } else if (family(cpu) == 0x10) { - set_fam10h_revinfo(eax, cpu); - return; - } else if (family(cpu) == 0x11) { - set_fam11h_revinfo(eax, cpu); + if (family(cpu) >= 0xf) { + switch family(cpu) { + case 0xf: + set_k8_revinfo(eax, cpu); + break; + case 0x10: + set_fam10h_revinfo(eax, cpu); + break; + case 0x11: + set_fam11h_revinfo(eax, cpu); + break; + case 0x14: + set_fam14h_revinfo(eax, cpu); + break; + default: + printf("Unknown CPU family: 0x%x\n", + family(cpu)); + break; + } + return; } diff --git a/AMD/powernow.c b/AMD/powernow.c index e2b18d8..0dc9c0b 100644 --- a/AMD/powernow.c +++ b/AMD/powernow.c @@ -132,6 +132,33 @@ static int get_did(int family, union msr_pstate pstate) return t; } +static int get_main_pll_fid(void) +{ + struct pci_filter filter_nb_misc = { -1, -1, -1, -1, 0x1022, 0x1703}; + struct pci_access *pacc; + struct pci_dev *z = NULL; + u8 val; + + pacc = pci_alloc(); + pci_init(pacc); + pci_scan_bus(pacc); + + for (z=pacc->devices; z; z=z->next) { + if (pci_filter_match(&filter_nb_misc, z)) + break; + } + + val = 0; + if (z) { + val = pci_read_byte(z, 0xd4); + val &= 0x3f; + } + + pci_cleanup(pacc); + + return val; +} + static int get_cof(int family, union msr_pstate pstate) { int t; @@ -141,16 +168,27 @@ static int get_cof(int family, union msr_pstate pstate) t = 0x10; fid = pstate.bits.fid; - if (family == 0x11) + if (family == 0x10) + goto out; + + if (family == 0x11) { t = 0x8; + goto out; + } + + if (family == 0x14) { + fid = get_main_pll_fid(); //from PCI + return (((fid + 0x10) *100) * 4 / did); + } + out: return ((100 * (fid + t)) >> did); } static int get_num_boost_states(void) { struct pci_filter filter_nb_link = { -1, -1, -1, -1, 0x1022, 0}; - int dev_ids[3] = {0x1204}; + int dev_ids[3] = {0x1204, 0x1704}; struct pci_access *pacc; struct pci_dev *z = NULL; u8 val; @@ -218,13 +256,15 @@ static void decode_pstates(struct cpudata *cpu, int has_cpb) i); return; } - if (i < boost_states) + if (i < boost_states) { printf("Pstate-Pb%d: %dMHz (boost state)\n", i, get_cof(fam, pstate)); - else + } else if (pstate.bits.en) { + /* show information only if pstate is enabled */ printf("Pstate-P%d: %dMHz%s\n", i - boost_states, get_cof(fam, pstate), (i == pscur) ? " (current)" : ""); + } } printf("\n"); } diff --git a/AMD/revision.h b/AMD/revision.h index 577b967..bc98c71 100644 --- a/AMD/revision.h +++ b/AMD/revision.h @@ -147,4 +147,9 @@ struct id_string fam11h_revisions[] = { }; get_name(fam11h_revision, int, fam11h_revisions); +struct id_string fam14h_revisions[] = { + {0x00500f10, "ON-B0"}, +}; +get_name(fam14h_revision, int, fam14h_revisions); + #endif /* _amd_revision_h_ */ diff --git a/connector.c b/connector.c index 9877569..030fd69 100644 --- a/connector.c +++ b/connector.c @@ -39,6 +39,7 @@ static struct { {CONN_SOCKET_G34, "Socket G34"}, {CONN_SOCKET_ASB2, "Socket ASB2"}, {CONN_SOCKET_C32, "Socket C32"}, + {CONN_SOCKET_FT1, "Socket FT1"}, /* Intel specific sockets */ {CONN_SOCKET_57B, "Socket 5/7 (320 Pin PGA)"}, {CONN_MOBILE_7, "Mobile Module (320 Lead TCP)"}, diff --git a/x86info.h b/x86info.h index 93aa8f1..3f4f295 100644 --- a/x86info.h +++ b/x86info.h @@ -58,6 +58,7 @@ enum connector { CONN_SOCKET_G34, CONN_SOCKET_ASB2, CONN_SOCKET_C32, + CONN_SOCKET_FT1, }; #define CPU_NAME_LEN 80 -- cgit v1.2.3