1512d1027SAndreas Herrmann /* 2512d1027SAndreas Herrmann * fam15h_power.c - AMD Family 15h processor power monitoring 3512d1027SAndreas Herrmann * 4512d1027SAndreas Herrmann * Copyright (c) 2011 Advanced Micro Devices, Inc. 5d034fbf0SAndreas Herrmann * Author: Andreas Herrmann <herrmann.der.user@googlemail.com> 6512d1027SAndreas Herrmann * 7512d1027SAndreas Herrmann * 8512d1027SAndreas Herrmann * This driver is free software; you can redistribute it and/or 9512d1027SAndreas Herrmann * modify it under the terms of the GNU General Public License; either 10512d1027SAndreas Herrmann * version 2 of the License, or (at your option) any later version. 11512d1027SAndreas Herrmann * 12512d1027SAndreas Herrmann * This driver is distributed in the hope that it will be useful, 13512d1027SAndreas Herrmann * but WITHOUT ANY WARRANTY; without even the implied warranty of 14512d1027SAndreas Herrmann * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15512d1027SAndreas Herrmann * See the GNU General Public License for more details. 16512d1027SAndreas Herrmann * 17512d1027SAndreas Herrmann * You should have received a copy of the GNU General Public License 18512d1027SAndreas Herrmann * along with this driver; if not, see <http://www.gnu.org/licenses/>. 19512d1027SAndreas Herrmann */ 20512d1027SAndreas Herrmann 21512d1027SAndreas Herrmann #include <linux/err.h> 22512d1027SAndreas Herrmann #include <linux/hwmon.h> 23512d1027SAndreas Herrmann #include <linux/hwmon-sysfs.h> 24512d1027SAndreas Herrmann #include <linux/init.h> 25512d1027SAndreas Herrmann #include <linux/module.h> 26512d1027SAndreas Herrmann #include <linux/pci.h> 27512d1027SAndreas Herrmann #include <linux/bitops.h> 28fa794344SHuang Rui #include <linux/cpu.h> 29fa794344SHuang Rui #include <linux/cpumask.h> 30512d1027SAndreas Herrmann #include <asm/processor.h> 313b5ea47dSHuang Rui #include <asm/msr.h> 32512d1027SAndreas Herrmann 33512d1027SAndreas Herrmann MODULE_DESCRIPTION("AMD Family 15h CPU processor power monitor"); 34d034fbf0SAndreas Herrmann MODULE_AUTHOR("Andreas Herrmann <herrmann.der.user@googlemail.com>"); 35512d1027SAndreas Herrmann MODULE_LICENSE("GPL"); 36512d1027SAndreas Herrmann 37512d1027SAndreas Herrmann /* D18F3 */ 38512d1027SAndreas Herrmann #define REG_NORTHBRIDGE_CAP 0xe8 39512d1027SAndreas Herrmann 40512d1027SAndreas Herrmann /* D18F4 */ 41512d1027SAndreas Herrmann #define REG_PROCESSOR_TDP 0x1b8 42512d1027SAndreas Herrmann 43512d1027SAndreas Herrmann /* D18F5 */ 44512d1027SAndreas Herrmann #define REG_TDP_RUNNING_AVERAGE 0xe0 45512d1027SAndreas Herrmann #define REG_TDP_LIMIT3 0xe8 46512d1027SAndreas Herrmann 477deb14b1SHuang Rui #define FAM15H_MIN_NUM_ATTRS 2 487deb14b1SHuang Rui #define FAM15H_NUM_GROUPS 2 49fa794344SHuang Rui #define MAX_CUS 8 507deb14b1SHuang Rui 51fa794344SHuang Rui #define MSR_F15H_CU_PWR_ACCUMULATOR 0xc001007a 523b5ea47dSHuang Rui #define MSR_F15H_CU_MAX_PWR_ACCUMULATOR 0xc001007b 53*cdb9e110SHuang Rui #define MSR_F15H_PTSC 0xc0010280 543b5ea47dSHuang Rui 55eff2a945SHuang Rui #define PCI_DEVICE_ID_AMD_15H_M70H_NB_F4 0x15b4 56eff2a945SHuang Rui 57512d1027SAndreas Herrmann struct fam15h_power_data { 58562dc973SAxel Lin struct pci_dev *pdev; 59512d1027SAndreas Herrmann unsigned int tdp_to_watts; 60512d1027SAndreas Herrmann unsigned int base_tdp; 61512d1027SAndreas Herrmann unsigned int processor_pwr_watts; 621ed32160SHuang Rui unsigned int cpu_pwr_sample_ratio; 637deb14b1SHuang Rui const struct attribute_group *groups[FAM15H_NUM_GROUPS]; 647deb14b1SHuang Rui struct attribute_group group; 653b5ea47dSHuang Rui /* maximum accumulated power of a compute unit */ 663b5ea47dSHuang Rui u64 max_cu_acc_power; 67fa794344SHuang Rui /* accumulated power of the compute units */ 68fa794344SHuang Rui u64 cu_acc_power[MAX_CUS]; 69*cdb9e110SHuang Rui /* performance timestamp counter */ 70*cdb9e110SHuang Rui u64 cpu_sw_pwr_ptsc[MAX_CUS]; 71512d1027SAndreas Herrmann }; 72512d1027SAndreas Herrmann 73512d1027SAndreas Herrmann static ssize_t show_power(struct device *dev, 74512d1027SAndreas Herrmann struct device_attribute *attr, char *buf) 75512d1027SAndreas Herrmann { 76512d1027SAndreas Herrmann u32 val, tdp_limit, running_avg_range; 77512d1027SAndreas Herrmann s32 running_avg_capture; 78512d1027SAndreas Herrmann u64 curr_pwr_watts; 79512d1027SAndreas Herrmann struct fam15h_power_data *data = dev_get_drvdata(dev); 80562dc973SAxel Lin struct pci_dev *f4 = data->pdev; 81512d1027SAndreas Herrmann 82512d1027SAndreas Herrmann pci_bus_read_config_dword(f4->bus, PCI_DEVFN(PCI_SLOT(f4->devfn), 5), 83512d1027SAndreas Herrmann REG_TDP_RUNNING_AVERAGE, &val); 84e9cd4d55SHuang Rui 85e9cd4d55SHuang Rui /* 86e9cd4d55SHuang Rui * On Carrizo and later platforms, TdpRunAvgAccCap bit field 87e9cd4d55SHuang Rui * is extended to 4:31 from 4:25. 88e9cd4d55SHuang Rui */ 89e9cd4d55SHuang Rui if (boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model >= 0x60) { 90e9cd4d55SHuang Rui running_avg_capture = val >> 4; 91e9cd4d55SHuang Rui running_avg_capture = sign_extend32(running_avg_capture, 27); 92e9cd4d55SHuang Rui } else { 93512d1027SAndreas Herrmann running_avg_capture = (val >> 4) & 0x3fffff; 94fc0900cbSAndreas Herrmann running_avg_capture = sign_extend32(running_avg_capture, 21); 95e9cd4d55SHuang Rui } 96e9cd4d55SHuang Rui 97941a956bSAndre Przywara running_avg_range = (val & 0xf) + 1; 98512d1027SAndreas Herrmann 99512d1027SAndreas Herrmann pci_bus_read_config_dword(f4->bus, PCI_DEVFN(PCI_SLOT(f4->devfn), 5), 100512d1027SAndreas Herrmann REG_TDP_LIMIT3, &val); 101512d1027SAndreas Herrmann 10260dee3caSGioh Kim /* 10360dee3caSGioh Kim * On Carrizo and later platforms, ApmTdpLimit bit field 10460dee3caSGioh Kim * is extended to 16:31 from 16:28. 10560dee3caSGioh Kim */ 10660dee3caSGioh Kim if (boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model >= 0x60) 107512d1027SAndreas Herrmann tdp_limit = val >> 16; 10860dee3caSGioh Kim else 10960dee3caSGioh Kim tdp_limit = (val >> 16) & 0x1fff; 11060dee3caSGioh Kim 11162867d49SGuenter Roeck curr_pwr_watts = ((u64)(tdp_limit + 11262867d49SGuenter Roeck data->base_tdp)) << running_avg_range; 113941a956bSAndre Przywara curr_pwr_watts -= running_avg_capture; 114512d1027SAndreas Herrmann curr_pwr_watts *= data->tdp_to_watts; 115512d1027SAndreas Herrmann 116512d1027SAndreas Herrmann /* 117512d1027SAndreas Herrmann * Convert to microWatt 118512d1027SAndreas Herrmann * 119512d1027SAndreas Herrmann * power is in Watt provided as fixed point integer with 120512d1027SAndreas Herrmann * scaling factor 1/(2^16). For conversion we use 121512d1027SAndreas Herrmann * (10^6)/(2^16) = 15625/(2^10) 122512d1027SAndreas Herrmann */ 123941a956bSAndre Przywara curr_pwr_watts = (curr_pwr_watts * 15625) >> (10 + running_avg_range); 124512d1027SAndreas Herrmann return sprintf(buf, "%u\n", (unsigned int) curr_pwr_watts); 125512d1027SAndreas Herrmann } 126512d1027SAndreas Herrmann static DEVICE_ATTR(power1_input, S_IRUGO, show_power, NULL); 127512d1027SAndreas Herrmann 128512d1027SAndreas Herrmann static ssize_t show_power_crit(struct device *dev, 129512d1027SAndreas Herrmann struct device_attribute *attr, char *buf) 130512d1027SAndreas Herrmann { 131512d1027SAndreas Herrmann struct fam15h_power_data *data = dev_get_drvdata(dev); 132512d1027SAndreas Herrmann 133512d1027SAndreas Herrmann return sprintf(buf, "%u\n", data->processor_pwr_watts); 134512d1027SAndreas Herrmann } 135512d1027SAndreas Herrmann static DEVICE_ATTR(power1_crit, S_IRUGO, show_power_crit, NULL); 136512d1027SAndreas Herrmann 137fa794344SHuang Rui static void do_read_registers_on_cu(void *_data) 138fa794344SHuang Rui { 139fa794344SHuang Rui struct fam15h_power_data *data = _data; 140fa794344SHuang Rui int cpu, cu; 141fa794344SHuang Rui 142fa794344SHuang Rui cpu = smp_processor_id(); 143fa794344SHuang Rui 144fa794344SHuang Rui /* 145fa794344SHuang Rui * With the new x86 topology modelling, cpu core id actually 146fa794344SHuang Rui * is compute unit id. 147fa794344SHuang Rui */ 148fa794344SHuang Rui cu = cpu_data(cpu).cpu_core_id; 149fa794344SHuang Rui 150fa794344SHuang Rui rdmsrl_safe(MSR_F15H_CU_PWR_ACCUMULATOR, &data->cu_acc_power[cu]); 151*cdb9e110SHuang Rui rdmsrl_safe(MSR_F15H_PTSC, &data->cpu_sw_pwr_ptsc[cu]); 152fa794344SHuang Rui } 153fa794344SHuang Rui 154fa794344SHuang Rui /* 155fa794344SHuang Rui * This function is only able to be called when CPUID 156fa794344SHuang Rui * Fn8000_0007:EDX[12] is set. 157fa794344SHuang Rui */ 158fa794344SHuang Rui static int read_registers(struct fam15h_power_data *data) 159fa794344SHuang Rui { 160fa794344SHuang Rui int this_cpu, ret, cpu; 161fa794344SHuang Rui int core, this_core; 162fa794344SHuang Rui cpumask_var_t mask; 163fa794344SHuang Rui 164fa794344SHuang Rui ret = zalloc_cpumask_var(&mask, GFP_KERNEL); 165fa794344SHuang Rui if (!ret) 166fa794344SHuang Rui return -ENOMEM; 167fa794344SHuang Rui 168fa794344SHuang Rui get_online_cpus(); 169fa794344SHuang Rui this_cpu = smp_processor_id(); 170fa794344SHuang Rui 171fa794344SHuang Rui /* 172fa794344SHuang Rui * Choose the first online core of each compute unit, and then 173fa794344SHuang Rui * read their MSR value of power and ptsc in a single IPI, 174fa794344SHuang Rui * because the MSR value of CPU core represent the compute 175fa794344SHuang Rui * unit's. 176fa794344SHuang Rui */ 177fa794344SHuang Rui core = -1; 178fa794344SHuang Rui 179fa794344SHuang Rui for_each_online_cpu(cpu) { 180fa794344SHuang Rui this_core = topology_core_id(cpu); 181fa794344SHuang Rui 182fa794344SHuang Rui if (this_core == core) 183fa794344SHuang Rui continue; 184fa794344SHuang Rui 185fa794344SHuang Rui core = this_core; 186fa794344SHuang Rui 187fa794344SHuang Rui /* get any CPU on this compute unit */ 188fa794344SHuang Rui cpumask_set_cpu(cpumask_any(topology_sibling_cpumask(cpu)), mask); 189fa794344SHuang Rui } 190fa794344SHuang Rui 191fa794344SHuang Rui if (cpumask_test_cpu(this_cpu, mask)) 192fa794344SHuang Rui do_read_registers_on_cu(data); 193fa794344SHuang Rui 194fa794344SHuang Rui smp_call_function_many(mask, do_read_registers_on_cu, data, true); 195fa794344SHuang Rui put_online_cpus(); 196fa794344SHuang Rui 197fa794344SHuang Rui free_cpumask_var(mask); 198fa794344SHuang Rui 199fa794344SHuang Rui return 0; 200fa794344SHuang Rui } 201fa794344SHuang Rui 2027deb14b1SHuang Rui static int fam15h_power_init_attrs(struct pci_dev *pdev, 2037deb14b1SHuang Rui struct fam15h_power_data *data) 204961a2378SAravind Gopalakrishnan { 2057deb14b1SHuang Rui int n = FAM15H_MIN_NUM_ATTRS; 2067deb14b1SHuang Rui struct attribute **fam15h_power_attrs; 20746f29c2bSHuang Rui struct cpuinfo_x86 *c = &boot_cpu_data; 2087deb14b1SHuang Rui 20946f29c2bSHuang Rui if (c->x86 == 0x15 && 21046f29c2bSHuang Rui (c->x86_model <= 0xf || 211eff2a945SHuang Rui (c->x86_model >= 0x60 && c->x86_model <= 0x7f))) 2127deb14b1SHuang Rui n += 1; 2137deb14b1SHuang Rui 2147deb14b1SHuang Rui fam15h_power_attrs = devm_kcalloc(&pdev->dev, n, 2157deb14b1SHuang Rui sizeof(*fam15h_power_attrs), 2167deb14b1SHuang Rui GFP_KERNEL); 2177deb14b1SHuang Rui 2187deb14b1SHuang Rui if (!fam15h_power_attrs) 2197deb14b1SHuang Rui return -ENOMEM; 2207deb14b1SHuang Rui 2217deb14b1SHuang Rui n = 0; 2227deb14b1SHuang Rui fam15h_power_attrs[n++] = &dev_attr_power1_crit.attr; 22346f29c2bSHuang Rui if (c->x86 == 0x15 && 22446f29c2bSHuang Rui (c->x86_model <= 0xf || 225eff2a945SHuang Rui (c->x86_model >= 0x60 && c->x86_model <= 0x7f))) 2267deb14b1SHuang Rui fam15h_power_attrs[n++] = &dev_attr_power1_input.attr; 2277deb14b1SHuang Rui 2287deb14b1SHuang Rui data->group.attrs = fam15h_power_attrs; 2297deb14b1SHuang Rui 230961a2378SAravind Gopalakrishnan return 0; 231961a2378SAravind Gopalakrishnan } 232961a2378SAravind Gopalakrishnan 233d83e92b3SHuang Rui static bool should_load_on_this_node(struct pci_dev *f4) 234512d1027SAndreas Herrmann { 235512d1027SAndreas Herrmann u32 val; 236512d1027SAndreas Herrmann 237512d1027SAndreas Herrmann pci_bus_read_config_dword(f4->bus, PCI_DEVFN(PCI_SLOT(f4->devfn), 3), 238512d1027SAndreas Herrmann REG_NORTHBRIDGE_CAP, &val); 239512d1027SAndreas Herrmann if ((val & BIT(29)) && ((val >> 30) & 3)) 240512d1027SAndreas Herrmann return false; 241512d1027SAndreas Herrmann 242512d1027SAndreas Herrmann return true; 243512d1027SAndreas Herrmann } 244512d1027SAndreas Herrmann 24500250ec9SAndre Przywara /* 24600250ec9SAndre Przywara * Newer BKDG versions have an updated recommendation on how to properly 24700250ec9SAndre Przywara * initialize the running average range (was: 0xE, now: 0x9). This avoids 24800250ec9SAndre Przywara * counter saturations resulting in bogus power readings. 24900250ec9SAndre Przywara * We correct this value ourselves to cope with older BIOSes. 25000250ec9SAndre Przywara */ 2515f0ecb90SAndreas Herrmann static const struct pci_device_id affected_device[] = { 252c3e40a99SGuenter Roeck { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) }, 253c3e40a99SGuenter Roeck { 0 } 254c3e40a99SGuenter Roeck }; 255c3e40a99SGuenter Roeck 2565f0ecb90SAndreas Herrmann static void tweak_runavg_range(struct pci_dev *pdev) 25700250ec9SAndre Przywara { 25800250ec9SAndre Przywara u32 val; 25900250ec9SAndre Przywara 26000250ec9SAndre Przywara /* 26100250ec9SAndre Przywara * let this quirk apply only to the current version of the 26200250ec9SAndre Przywara * northbridge, since future versions may change the behavior 26300250ec9SAndre Przywara */ 264c3e40a99SGuenter Roeck if (!pci_match_id(affected_device, pdev)) 26500250ec9SAndre Przywara return; 26600250ec9SAndre Przywara 26700250ec9SAndre Przywara pci_bus_read_config_dword(pdev->bus, 26800250ec9SAndre Przywara PCI_DEVFN(PCI_SLOT(pdev->devfn), 5), 26900250ec9SAndre Przywara REG_TDP_RUNNING_AVERAGE, &val); 27000250ec9SAndre Przywara if ((val & 0xf) != 0xe) 27100250ec9SAndre Przywara return; 27200250ec9SAndre Przywara 27300250ec9SAndre Przywara val &= ~0xf; 27400250ec9SAndre Przywara val |= 0x9; 27500250ec9SAndre Przywara pci_bus_write_config_dword(pdev->bus, 27600250ec9SAndre Przywara PCI_DEVFN(PCI_SLOT(pdev->devfn), 5), 27700250ec9SAndre Przywara REG_TDP_RUNNING_AVERAGE, val); 27800250ec9SAndre Przywara } 27900250ec9SAndre Przywara 2805f0ecb90SAndreas Herrmann #ifdef CONFIG_PM 2815f0ecb90SAndreas Herrmann static int fam15h_power_resume(struct pci_dev *pdev) 2825f0ecb90SAndreas Herrmann { 2835f0ecb90SAndreas Herrmann tweak_runavg_range(pdev); 2845f0ecb90SAndreas Herrmann return 0; 2855f0ecb90SAndreas Herrmann } 2865f0ecb90SAndreas Herrmann #else 2875f0ecb90SAndreas Herrmann #define fam15h_power_resume NULL 2885f0ecb90SAndreas Herrmann #endif 2895f0ecb90SAndreas Herrmann 2907deb14b1SHuang Rui static int fam15h_power_init_data(struct pci_dev *f4, 291512d1027SAndreas Herrmann struct fam15h_power_data *data) 292512d1027SAndreas Herrmann { 2931ed32160SHuang Rui u32 val, eax, ebx, ecx, edx; 294512d1027SAndreas Herrmann u64 tmp; 2957deb14b1SHuang Rui int ret; 296512d1027SAndreas Herrmann 297512d1027SAndreas Herrmann pci_read_config_dword(f4, REG_PROCESSOR_TDP, &val); 298512d1027SAndreas Herrmann data->base_tdp = val >> 16; 299512d1027SAndreas Herrmann tmp = val & 0xffff; 300512d1027SAndreas Herrmann 301512d1027SAndreas Herrmann pci_bus_read_config_dword(f4->bus, PCI_DEVFN(PCI_SLOT(f4->devfn), 5), 302512d1027SAndreas Herrmann REG_TDP_LIMIT3, &val); 303512d1027SAndreas Herrmann 304512d1027SAndreas Herrmann data->tdp_to_watts = ((val & 0x3ff) << 6) | ((val >> 10) & 0x3f); 305512d1027SAndreas Herrmann tmp *= data->tdp_to_watts; 306512d1027SAndreas Herrmann 307512d1027SAndreas Herrmann /* result not allowed to be >= 256W */ 308512d1027SAndreas Herrmann if ((tmp >> 16) >= 256) 309b55f3757SGuenter Roeck dev_warn(&f4->dev, 310b55f3757SGuenter Roeck "Bogus value for ProcessorPwrWatts (processor_pwr_watts>=%u)\n", 311512d1027SAndreas Herrmann (unsigned int) (tmp >> 16)); 312512d1027SAndreas Herrmann 313512d1027SAndreas Herrmann /* convert to microWatt */ 314512d1027SAndreas Herrmann data->processor_pwr_watts = (tmp * 15625) >> 10; 3151ed32160SHuang Rui 3167deb14b1SHuang Rui ret = fam15h_power_init_attrs(f4, data); 3177deb14b1SHuang Rui if (ret) 3187deb14b1SHuang Rui return ret; 3197deb14b1SHuang Rui 3201ed32160SHuang Rui cpuid(0x80000007, &eax, &ebx, &ecx, &edx); 3211ed32160SHuang Rui 3221ed32160SHuang Rui /* CPUID Fn8000_0007:EDX[12] indicates to support accumulated power */ 3231ed32160SHuang Rui if (!(edx & BIT(12))) 3247deb14b1SHuang Rui return 0; 3251ed32160SHuang Rui 3261ed32160SHuang Rui /* 3271ed32160SHuang Rui * determine the ratio of the compute unit power accumulator 3281ed32160SHuang Rui * sample period to the PTSC counter period by executing CPUID 3291ed32160SHuang Rui * Fn8000_0007:ECX 3301ed32160SHuang Rui */ 3311ed32160SHuang Rui data->cpu_pwr_sample_ratio = ecx; 3327deb14b1SHuang Rui 3333b5ea47dSHuang Rui if (rdmsrl_safe(MSR_F15H_CU_MAX_PWR_ACCUMULATOR, &tmp)) { 3343b5ea47dSHuang Rui pr_err("Failed to read max compute unit power accumulator MSR\n"); 3353b5ea47dSHuang Rui return -ENODEV; 3363b5ea47dSHuang Rui } 3373b5ea47dSHuang Rui 3383b5ea47dSHuang Rui data->max_cu_acc_power = tmp; 3393b5ea47dSHuang Rui 340fa794344SHuang Rui return read_registers(data); 341512d1027SAndreas Herrmann } 342512d1027SAndreas Herrmann 3436c931ae1SBill Pemberton static int fam15h_power_probe(struct pci_dev *pdev, 344512d1027SAndreas Herrmann const struct pci_device_id *id) 345512d1027SAndreas Herrmann { 346512d1027SAndreas Herrmann struct fam15h_power_data *data; 34787432a2eSGuenter Roeck struct device *dev = &pdev->dev; 348562dc973SAxel Lin struct device *hwmon_dev; 3497deb14b1SHuang Rui int ret; 350512d1027SAndreas Herrmann 35100250ec9SAndre Przywara /* 35200250ec9SAndre Przywara * though we ignore every other northbridge, we still have to 35300250ec9SAndre Przywara * do the tweaking on _each_ node in MCM processors as the counters 35400250ec9SAndre Przywara * are working hand-in-hand 35500250ec9SAndre Przywara */ 35600250ec9SAndre Przywara tweak_runavg_range(pdev); 35700250ec9SAndre Przywara 358d83e92b3SHuang Rui if (!should_load_on_this_node(pdev)) 35987432a2eSGuenter Roeck return -ENODEV; 360512d1027SAndreas Herrmann 36187432a2eSGuenter Roeck data = devm_kzalloc(dev, sizeof(struct fam15h_power_data), GFP_KERNEL); 36287432a2eSGuenter Roeck if (!data) 36387432a2eSGuenter Roeck return -ENOMEM; 36487432a2eSGuenter Roeck 3657deb14b1SHuang Rui ret = fam15h_power_init_data(pdev, data); 3667deb14b1SHuang Rui if (ret) 3677deb14b1SHuang Rui return ret; 3687deb14b1SHuang Rui 369562dc973SAxel Lin data->pdev = pdev; 370512d1027SAndreas Herrmann 3717deb14b1SHuang Rui data->groups[0] = &data->group; 3727deb14b1SHuang Rui 373562dc973SAxel Lin hwmon_dev = devm_hwmon_device_register_with_groups(dev, "fam15h_power", 374562dc973SAxel Lin data, 3757deb14b1SHuang Rui &data->groups[0]); 376562dc973SAxel Lin return PTR_ERR_OR_ZERO(hwmon_dev); 377512d1027SAndreas Herrmann } 378512d1027SAndreas Herrmann 379cd9bb056SJingoo Han static const struct pci_device_id fam15h_power_id_table[] = { 380512d1027SAndreas Herrmann { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) }, 3810a0039adSAravind Gopalakrishnan { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M30H_NB_F4) }, 3825dc08725SHuang Rui { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M60H_NB_F4) }, 383eff2a945SHuang Rui { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M70H_NB_F4) }, 38422e32f4fSBoris Ostrovsky { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F4) }, 3850bd52941SAravind Gopalakrishnan { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F4) }, 386512d1027SAndreas Herrmann {} 387512d1027SAndreas Herrmann }; 388512d1027SAndreas Herrmann MODULE_DEVICE_TABLE(pci, fam15h_power_id_table); 389512d1027SAndreas Herrmann 390512d1027SAndreas Herrmann static struct pci_driver fam15h_power_driver = { 391512d1027SAndreas Herrmann .name = "fam15h_power", 392512d1027SAndreas Herrmann .id_table = fam15h_power_id_table, 393512d1027SAndreas Herrmann .probe = fam15h_power_probe, 3945f0ecb90SAndreas Herrmann .resume = fam15h_power_resume, 395512d1027SAndreas Herrmann }; 396512d1027SAndreas Herrmann 397f71f5a55SAxel Lin module_pci_driver(fam15h_power_driver); 398