diff --git a/sys/x86/cpufreq/hwpstate_amd.c b/sys/x86/cpufreq/hwpstate_amd.c --- a/sys/x86/cpufreq/hwpstate_amd.c +++ b/sys/x86/cpufreq/hwpstate_amd.c @@ -88,6 +88,13 @@ #define AMD_17H_CUR_DID(msr) (((msr) >> 8) & 0x3F) #define AMD_17H_CUR_FID(msr) ((msr) & 0xFF) +/* for 1Ah, AMD don't have DID */ +#define AMD_1AH_CUR_EN(msr) ((msr >> 63) & 0x01) +#define AMD_1AH_CUR_IDIV(msr) ((msr >> 30) & 0x03) +#define AMD_1AH_CUR_IDD(msr) ((msr >> 22) & 0xFF) +#define AMD_1AH_CUR_VID(msr) ((msr >> 14) & 0xFF) +#define AMD_1AH_CUR_FID(msr) ((msr) & 0xFFF) + #define HWPSTATE_DEBUG(dev, msg...) \ do { \ if (hwpstate_verbose) \ @@ -163,6 +170,20 @@ DRIVER_MODULE(hwpstate, cpu, hwpstate_driver, 0, 0); +static void +hwpstate_amd_div(int *val, int div) { + switch (div) { + case 3: /* divide by 1000 */ + *val /= 10; + case 2: /* divide by 100 */ + *val /= 10; + case 1: /* divide by 10 */ + *val /= 10; + case 0: /* divide by 1 */ + ; + } +} + /* * Go to Px-state on all cpus, considering the limit register (if so * configured). @@ -478,20 +499,23 @@ * section 2.5.2.1.6. */ hwpstate_set[i].power = AMD_17H_CUR_IDD(msr) * 1000; - switch (AMD_17H_CUR_IDIV(msr)) { - case 3: /* divide by 1000 */ - hwpstate_set[i].power /= 10; - case 2: /* divide by 100 */ - hwpstate_set[i].power /= 10; - case 1: /* divide by 10 */ - hwpstate_set[i].power /= 10; - case 0: /* divide by 1 */ - ; - } + hwpstate_amd_div(&hwpstate_set[i].power, AMD_17H_CUR_IDIV(msr)); hwpstate_set[i].power *= hwpstate_set[i].volts; /* Milli amps * milli volts to milli watts. */ hwpstate_set[i].power /= 1000; break; + case 0x1A: + fid = AMD_1AH_CUR_FID(msr); + /* amd don't use did in 1Ah */ + hwpstate_set[i].freq = fid; + if (fid > 0x0f) + hwpstate_set[i].freq *= 5; + hwpstate_set[i].volts = + (155000 - (625 * AMD_1AH_CUR_VID(msr))) / 100; + hwpstate_set[i].power = AMD_1AH_CUR_IDD(msr) * 1000; + hwpstate_amd_div(&hwpstate_set[i].power, AMD_1AH_CUR_IDIV(msr)); + hwpstate_set[i].power *= hwpstate_set[i].volts; + hwpstate_set[i].power /= 1000; default: HWPSTATE_DEBUG(dev, "get_info_from_msr: %s family" " 0x%02x CPUs are not supported yet\n",