1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * processor_thermal_device.c 4 * Copyright (c) 2014, Intel Corporation. 5 */ 6 #include <linux/kernel.h> 7 #include <linux/module.h> 8 #include <linux/init.h> 9 #include <linux/pci.h> 10 #include <linux/interrupt.h> 11 #include <linux/platform_device.h> 12 #include <linux/acpi.h> 13 #include <linux/thermal.h> 14 #include <linux/cpuhotplug.h> 15 #include <linux/intel_rapl.h> 16 #include "int340x_thermal_zone.h" 17 #include "../intel_soc_dts_iosf.h" 18 19 /* Broadwell-U/HSB thermal reporting device */ 20 #define PCI_DEVICE_ID_PROC_BDW_THERMAL 0x1603 21 #define PCI_DEVICE_ID_PROC_HSB_THERMAL 0x0A03 22 23 /* Skylake thermal reporting device */ 24 #define PCI_DEVICE_ID_PROC_SKL_THERMAL 0x1903 25 26 /* CannonLake thermal reporting device */ 27 #define PCI_DEVICE_ID_PROC_CNL_THERMAL 0x5a03 28 #define PCI_DEVICE_ID_PROC_CFL_THERMAL 0x3E83 29 30 /* Braswell thermal reporting device */ 31 #define PCI_DEVICE_ID_PROC_BSW_THERMAL 0x22DC 32 33 /* Broxton thermal reporting device */ 34 #define PCI_DEVICE_ID_PROC_BXT0_THERMAL 0x0A8C 35 #define PCI_DEVICE_ID_PROC_BXT1_THERMAL 0x1A8C 36 #define PCI_DEVICE_ID_PROC_BXTX_THERMAL 0x4A8C 37 #define PCI_DEVICE_ID_PROC_BXTP_THERMAL 0x5A8C 38 39 /* GeminiLake thermal reporting device */ 40 #define PCI_DEVICE_ID_PROC_GLK_THERMAL 0x318C 41 42 #define DRV_NAME "proc_thermal" 43 44 struct power_config { 45 u32 index; 46 u32 min_uw; 47 u32 max_uw; 48 u32 tmin_us; 49 u32 tmax_us; 50 u32 step_uw; 51 }; 52 53 struct proc_thermal_device { 54 struct device *dev; 55 struct acpi_device *adev; 56 struct power_config power_limits[2]; 57 struct int34x_thermal_zone *int340x_zone; 58 struct intel_soc_dts_sensors *soc_dts; 59 void __iomem *mmio_base; 60 }; 61 62 enum proc_thermal_emum_mode_type { 63 PROC_THERMAL_NONE, 64 PROC_THERMAL_PCI, 65 PROC_THERMAL_PLATFORM_DEV 66 }; 67 68 struct rapl_mmio_regs { 69 u64 reg_unit; 70 u64 regs[RAPL_DOMAIN_MAX][RAPL_DOMAIN_REG_MAX]; 71 int limits[RAPL_DOMAIN_MAX]; 72 }; 73 74 /* 75 * We can have only one type of enumeration, PCI or Platform, 76 * not both. So we don't need instance specific data. 77 */ 78 static enum proc_thermal_emum_mode_type proc_thermal_emum_mode = 79 PROC_THERMAL_NONE; 80 81 #define POWER_LIMIT_SHOW(index, suffix) \ 82 static ssize_t power_limit_##index##_##suffix##_show(struct device *dev, \ 83 struct device_attribute *attr, \ 84 char *buf) \ 85 { \ 86 struct proc_thermal_device *proc_dev = dev_get_drvdata(dev); \ 87 \ 88 if (proc_thermal_emum_mode == PROC_THERMAL_NONE) { \ 89 dev_warn(dev, "Attempted to get power limit before device was initialized!\n"); \ 90 return 0; \ 91 } \ 92 \ 93 return sprintf(buf, "%lu\n",\ 94 (unsigned long)proc_dev->power_limits[index].suffix * 1000); \ 95 } 96 97 POWER_LIMIT_SHOW(0, min_uw) 98 POWER_LIMIT_SHOW(0, max_uw) 99 POWER_LIMIT_SHOW(0, step_uw) 100 POWER_LIMIT_SHOW(0, tmin_us) 101 POWER_LIMIT_SHOW(0, tmax_us) 102 103 POWER_LIMIT_SHOW(1, min_uw) 104 POWER_LIMIT_SHOW(1, max_uw) 105 POWER_LIMIT_SHOW(1, step_uw) 106 POWER_LIMIT_SHOW(1, tmin_us) 107 POWER_LIMIT_SHOW(1, tmax_us) 108 109 static DEVICE_ATTR_RO(power_limit_0_min_uw); 110 static DEVICE_ATTR_RO(power_limit_0_max_uw); 111 static DEVICE_ATTR_RO(power_limit_0_step_uw); 112 static DEVICE_ATTR_RO(power_limit_0_tmin_us); 113 static DEVICE_ATTR_RO(power_limit_0_tmax_us); 114 115 static DEVICE_ATTR_RO(power_limit_1_min_uw); 116 static DEVICE_ATTR_RO(power_limit_1_max_uw); 117 static DEVICE_ATTR_RO(power_limit_1_step_uw); 118 static DEVICE_ATTR_RO(power_limit_1_tmin_us); 119 static DEVICE_ATTR_RO(power_limit_1_tmax_us); 120 121 static struct attribute *power_limit_attrs[] = { 122 &dev_attr_power_limit_0_min_uw.attr, 123 &dev_attr_power_limit_1_min_uw.attr, 124 &dev_attr_power_limit_0_max_uw.attr, 125 &dev_attr_power_limit_1_max_uw.attr, 126 &dev_attr_power_limit_0_step_uw.attr, 127 &dev_attr_power_limit_1_step_uw.attr, 128 &dev_attr_power_limit_0_tmin_us.attr, 129 &dev_attr_power_limit_1_tmin_us.attr, 130 &dev_attr_power_limit_0_tmax_us.attr, 131 &dev_attr_power_limit_1_tmax_us.attr, 132 NULL 133 }; 134 135 static const struct attribute_group power_limit_attribute_group = { 136 .attrs = power_limit_attrs, 137 .name = "power_limits" 138 }; 139 140 static int stored_tjmax; /* since it is fixed, we can have local storage */ 141 142 static int get_tjmax(void) 143 { 144 u32 eax, edx; 145 u32 val; 146 int err; 147 148 err = rdmsr_safe(MSR_IA32_TEMPERATURE_TARGET, &eax, &edx); 149 if (err) 150 return err; 151 152 val = (eax >> 16) & 0xff; 153 if (val) 154 return val; 155 156 return -EINVAL; 157 } 158 159 static int read_temp_msr(int *temp) 160 { 161 int cpu; 162 u32 eax, edx; 163 int err; 164 unsigned long curr_temp_off = 0; 165 166 *temp = 0; 167 168 for_each_online_cpu(cpu) { 169 err = rdmsr_safe_on_cpu(cpu, MSR_IA32_THERM_STATUS, &eax, 170 &edx); 171 if (err) 172 goto err_ret; 173 else { 174 if (eax & 0x80000000) { 175 curr_temp_off = (eax >> 16) & 0x7f; 176 if (!*temp || curr_temp_off < *temp) 177 *temp = curr_temp_off; 178 } else { 179 err = -EINVAL; 180 goto err_ret; 181 } 182 } 183 } 184 185 return 0; 186 err_ret: 187 return err; 188 } 189 190 static int proc_thermal_get_zone_temp(struct thermal_zone_device *zone, 191 int *temp) 192 { 193 int ret; 194 195 ret = read_temp_msr(temp); 196 if (!ret) 197 *temp = (stored_tjmax - *temp) * 1000; 198 199 return ret; 200 } 201 202 static struct thermal_zone_device_ops proc_thermal_local_ops = { 203 .get_temp = proc_thermal_get_zone_temp, 204 }; 205 206 static int proc_thermal_read_ppcc(struct proc_thermal_device *proc_priv) 207 { 208 int i; 209 acpi_status status; 210 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL }; 211 union acpi_object *elements, *ppcc; 212 union acpi_object *p; 213 int ret = 0; 214 215 status = acpi_evaluate_object(proc_priv->adev->handle, "PPCC", 216 NULL, &buf); 217 if (ACPI_FAILURE(status)) 218 return -ENODEV; 219 220 p = buf.pointer; 221 if (!p || (p->type != ACPI_TYPE_PACKAGE)) { 222 dev_err(proc_priv->dev, "Invalid PPCC data\n"); 223 ret = -EFAULT; 224 goto free_buffer; 225 } 226 227 if (!p->package.count) { 228 dev_err(proc_priv->dev, "Invalid PPCC package size\n"); 229 ret = -EFAULT; 230 goto free_buffer; 231 } 232 233 for (i = 0; i < min((int)p->package.count - 1, 2); ++i) { 234 elements = &(p->package.elements[i+1]); 235 if (elements->type != ACPI_TYPE_PACKAGE || 236 elements->package.count != 6) { 237 ret = -EFAULT; 238 goto free_buffer; 239 } 240 ppcc = elements->package.elements; 241 proc_priv->power_limits[i].index = ppcc[0].integer.value; 242 proc_priv->power_limits[i].min_uw = ppcc[1].integer.value; 243 proc_priv->power_limits[i].max_uw = ppcc[2].integer.value; 244 proc_priv->power_limits[i].tmin_us = ppcc[3].integer.value; 245 proc_priv->power_limits[i].tmax_us = ppcc[4].integer.value; 246 proc_priv->power_limits[i].step_uw = ppcc[5].integer.value; 247 } 248 249 free_buffer: 250 kfree(buf.pointer); 251 252 return ret; 253 } 254 255 #define PROC_POWER_CAPABILITY_CHANGED 0x83 256 static void proc_thermal_notify(acpi_handle handle, u32 event, void *data) 257 { 258 struct proc_thermal_device *proc_priv = data; 259 260 if (!proc_priv) 261 return; 262 263 switch (event) { 264 case PROC_POWER_CAPABILITY_CHANGED: 265 proc_thermal_read_ppcc(proc_priv); 266 int340x_thermal_zone_device_update(proc_priv->int340x_zone, 267 THERMAL_DEVICE_POWER_CAPABILITY_CHANGED); 268 break; 269 default: 270 dev_dbg(proc_priv->dev, "Unsupported event [0x%x]\n", event); 271 break; 272 } 273 } 274 275 276 static int proc_thermal_add(struct device *dev, 277 struct proc_thermal_device **priv) 278 { 279 struct proc_thermal_device *proc_priv; 280 struct acpi_device *adev; 281 acpi_status status; 282 unsigned long long tmp; 283 struct thermal_zone_device_ops *ops = NULL; 284 int ret; 285 286 adev = ACPI_COMPANION(dev); 287 if (!adev) 288 return -ENODEV; 289 290 proc_priv = devm_kzalloc(dev, sizeof(*proc_priv), GFP_KERNEL); 291 if (!proc_priv) 292 return -ENOMEM; 293 294 proc_priv->dev = dev; 295 proc_priv->adev = adev; 296 *priv = proc_priv; 297 298 ret = proc_thermal_read_ppcc(proc_priv); 299 if (ret) 300 return ret; 301 302 status = acpi_evaluate_integer(adev->handle, "_TMP", NULL, &tmp); 303 if (ACPI_FAILURE(status)) { 304 /* there is no _TMP method, add local method */ 305 stored_tjmax = get_tjmax(); 306 if (stored_tjmax > 0) 307 ops = &proc_thermal_local_ops; 308 } 309 310 proc_priv->int340x_zone = int340x_thermal_zone_add(adev, ops); 311 if (IS_ERR(proc_priv->int340x_zone)) { 312 return PTR_ERR(proc_priv->int340x_zone); 313 } else 314 ret = 0; 315 316 ret = acpi_install_notify_handler(adev->handle, ACPI_DEVICE_NOTIFY, 317 proc_thermal_notify, 318 (void *)proc_priv); 319 if (ret) 320 goto remove_zone; 321 322 return 0; 323 324 remove_zone: 325 int340x_thermal_zone_remove(proc_priv->int340x_zone); 326 327 return ret; 328 } 329 330 static void proc_thermal_remove(struct proc_thermal_device *proc_priv) 331 { 332 acpi_remove_notify_handler(proc_priv->adev->handle, 333 ACPI_DEVICE_NOTIFY, proc_thermal_notify); 334 int340x_thermal_zone_remove(proc_priv->int340x_zone); 335 sysfs_remove_group(&proc_priv->dev->kobj, 336 &power_limit_attribute_group); 337 } 338 339 static int int3401_add(struct platform_device *pdev) 340 { 341 struct proc_thermal_device *proc_priv; 342 int ret; 343 344 if (proc_thermal_emum_mode == PROC_THERMAL_PCI) { 345 dev_err(&pdev->dev, "error: enumerated as PCI dev\n"); 346 return -ENODEV; 347 } 348 349 ret = proc_thermal_add(&pdev->dev, &proc_priv); 350 if (ret) 351 return ret; 352 353 platform_set_drvdata(pdev, proc_priv); 354 proc_thermal_emum_mode = PROC_THERMAL_PLATFORM_DEV; 355 356 dev_info(&pdev->dev, "Creating sysfs group for PROC_THERMAL_PLATFORM_DEV\n"); 357 358 return sysfs_create_group(&pdev->dev.kobj, 359 &power_limit_attribute_group); 360 } 361 362 static int int3401_remove(struct platform_device *pdev) 363 { 364 proc_thermal_remove(platform_get_drvdata(pdev)); 365 366 return 0; 367 } 368 369 static irqreturn_t proc_thermal_pci_msi_irq(int irq, void *devid) 370 { 371 struct proc_thermal_device *proc_priv; 372 struct pci_dev *pdev = devid; 373 374 proc_priv = pci_get_drvdata(pdev); 375 376 intel_soc_dts_iosf_interrupt_handler(proc_priv->soc_dts); 377 378 return IRQ_HANDLED; 379 } 380 381 #ifdef CONFIG_PROC_THERMAL_MMIO_RAPL 382 383 #define MCHBAR 0 384 385 /* RAPL Support via MMIO interface */ 386 static struct rapl_if_priv rapl_mmio_priv; 387 388 static int rapl_mmio_cpu_online(unsigned int cpu) 389 { 390 struct rapl_package *rp; 391 392 /* mmio rapl supports package 0 only for now */ 393 if (topology_physical_package_id(cpu)) 394 return 0; 395 396 rp = rapl_find_package_domain(cpu, &rapl_mmio_priv); 397 if (!rp) { 398 rp = rapl_add_package(cpu, &rapl_mmio_priv); 399 if (IS_ERR(rp)) 400 return PTR_ERR(rp); 401 } 402 cpumask_set_cpu(cpu, &rp->cpumask); 403 return 0; 404 } 405 406 static int rapl_mmio_cpu_down_prep(unsigned int cpu) 407 { 408 struct rapl_package *rp; 409 int lead_cpu; 410 411 rp = rapl_find_package_domain(cpu, &rapl_mmio_priv); 412 if (!rp) 413 return 0; 414 415 cpumask_clear_cpu(cpu, &rp->cpumask); 416 lead_cpu = cpumask_first(&rp->cpumask); 417 if (lead_cpu >= nr_cpu_ids) 418 rapl_remove_package(rp); 419 else if (rp->lead_cpu == cpu) 420 rp->lead_cpu = lead_cpu; 421 return 0; 422 } 423 424 static int rapl_mmio_read_raw(int cpu, struct reg_action *ra) 425 { 426 if (!ra->reg) 427 return -EINVAL; 428 429 ra->value = readq((void __iomem *)ra->reg); 430 ra->value &= ra->mask; 431 return 0; 432 } 433 434 static int rapl_mmio_write_raw(int cpu, struct reg_action *ra) 435 { 436 u64 val; 437 438 if (!ra->reg) 439 return -EINVAL; 440 441 val = readq((void __iomem *)ra->reg); 442 val &= ~ra->mask; 443 val |= ra->value; 444 writeq(val, (void __iomem *)ra->reg); 445 return 0; 446 } 447 448 static int proc_thermal_rapl_add(struct pci_dev *pdev, 449 struct proc_thermal_device *proc_priv, 450 struct rapl_mmio_regs *rapl_regs) 451 { 452 enum rapl_domain_reg_id reg; 453 enum rapl_domain_type domain; 454 int ret; 455 456 if (!rapl_regs) 457 return 0; 458 459 ret = pcim_iomap_regions(pdev, 1 << MCHBAR, DRV_NAME); 460 if (ret) { 461 dev_err(&pdev->dev, "cannot reserve PCI memory region\n"); 462 return -ENOMEM; 463 } 464 465 proc_priv->mmio_base = pcim_iomap_table(pdev)[MCHBAR]; 466 467 for (domain = RAPL_DOMAIN_PACKAGE; domain < RAPL_DOMAIN_MAX; domain++) { 468 for (reg = RAPL_DOMAIN_REG_LIMIT; reg < RAPL_DOMAIN_REG_MAX; reg++) 469 if (rapl_regs->regs[domain][reg]) 470 rapl_mmio_priv.regs[domain][reg] = 471 (u64)proc_priv->mmio_base + 472 rapl_regs->regs[domain][reg]; 473 rapl_mmio_priv.limits[domain] = rapl_regs->limits[domain]; 474 } 475 rapl_mmio_priv.reg_unit = (u64)proc_priv->mmio_base + rapl_regs->reg_unit; 476 477 rapl_mmio_priv.read_raw = rapl_mmio_read_raw; 478 rapl_mmio_priv.write_raw = rapl_mmio_write_raw; 479 480 rapl_mmio_priv.control_type = powercap_register_control_type(NULL, "intel-rapl-mmio", NULL); 481 if (IS_ERR(rapl_mmio_priv.control_type)) { 482 pr_debug("failed to register powercap control_type.\n"); 483 return PTR_ERR(rapl_mmio_priv.control_type); 484 } 485 486 ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "powercap/rapl:online", 487 rapl_mmio_cpu_online, rapl_mmio_cpu_down_prep); 488 if (ret < 0) { 489 powercap_unregister_control_type(rapl_mmio_priv.control_type); 490 return ret; 491 } 492 rapl_mmio_priv.pcap_rapl_online = ret; 493 494 return 0; 495 } 496 497 static void proc_thermal_rapl_remove(void) 498 { 499 cpuhp_remove_state(rapl_mmio_priv.pcap_rapl_online); 500 powercap_unregister_control_type(rapl_mmio_priv.control_type); 501 } 502 503 static const struct rapl_mmio_regs rapl_mmio_hsw = { 504 .reg_unit = 0x5938, 505 .regs[RAPL_DOMAIN_PACKAGE] = { 0x59a0, 0x593c, 0x58f0, 0, 0x5930}, 506 .regs[RAPL_DOMAIN_DRAM] = { 0x58e0, 0x58e8, 0x58ec, 0, 0}, 507 .limits[RAPL_DOMAIN_PACKAGE] = 2, 508 .limits[RAPL_DOMAIN_DRAM] = 2, 509 }; 510 511 #else 512 513 static int proc_thermal_rapl_add(struct pci_dev *pdev, 514 struct proc_thermal_device *proc_priv, 515 struct rapl_mmio_regs *rapl_regs) 516 { 517 return 0; 518 } 519 static void proc_thermal_rapl_remove(void) {} 520 static const struct rapl_mmio_regs rapl_mmio_hsw; 521 522 #endif /* CONFIG_MMIO_RAPL */ 523 524 static int proc_thermal_pci_probe(struct pci_dev *pdev, 525 const struct pci_device_id *id) 526 { 527 struct proc_thermal_device *proc_priv; 528 int ret; 529 530 if (proc_thermal_emum_mode == PROC_THERMAL_PLATFORM_DEV) { 531 dev_err(&pdev->dev, "error: enumerated as platform dev\n"); 532 return -ENODEV; 533 } 534 535 ret = pcim_enable_device(pdev); 536 if (ret < 0) { 537 dev_err(&pdev->dev, "error: could not enable device\n"); 538 return ret; 539 } 540 541 ret = proc_thermal_add(&pdev->dev, &proc_priv); 542 if (ret) 543 return ret; 544 545 ret = proc_thermal_rapl_add(pdev, proc_priv, 546 (struct rapl_mmio_regs *)id->driver_data); 547 if (ret) { 548 dev_err(&pdev->dev, "failed to add RAPL MMIO interface\n"); 549 proc_thermal_remove(proc_priv); 550 return ret; 551 } 552 553 pci_set_drvdata(pdev, proc_priv); 554 proc_thermal_emum_mode = PROC_THERMAL_PCI; 555 556 if (pdev->device == PCI_DEVICE_ID_PROC_BSW_THERMAL) { 557 /* 558 * Enumerate additional DTS sensors available via IOSF. 559 * But we are not treating as a failure condition, if 560 * there are no aux DTSs enabled or fails. This driver 561 * already exposes sensors, which can be accessed via 562 * ACPI/MSR. So we don't want to fail for auxiliary DTSs. 563 */ 564 proc_priv->soc_dts = intel_soc_dts_iosf_init( 565 INTEL_SOC_DTS_INTERRUPT_MSI, 2, 0); 566 567 if (!IS_ERR(proc_priv->soc_dts) && pdev->irq) { 568 ret = pci_enable_msi(pdev); 569 if (!ret) { 570 ret = request_threaded_irq(pdev->irq, NULL, 571 proc_thermal_pci_msi_irq, 572 IRQF_ONESHOT, "proc_thermal", 573 pdev); 574 if (ret) { 575 intel_soc_dts_iosf_exit( 576 proc_priv->soc_dts); 577 pci_disable_msi(pdev); 578 proc_priv->soc_dts = NULL; 579 } 580 } 581 } else 582 dev_err(&pdev->dev, "No auxiliary DTSs enabled\n"); 583 } 584 585 dev_info(&pdev->dev, "Creating sysfs group for PROC_THERMAL_PCI\n"); 586 587 return sysfs_create_group(&pdev->dev.kobj, 588 &power_limit_attribute_group); 589 } 590 591 static void proc_thermal_pci_remove(struct pci_dev *pdev) 592 { 593 struct proc_thermal_device *proc_priv = pci_get_drvdata(pdev); 594 595 if (proc_priv->soc_dts) { 596 intel_soc_dts_iosf_exit(proc_priv->soc_dts); 597 if (pdev->irq) { 598 free_irq(pdev->irq, pdev); 599 pci_disable_msi(pdev); 600 } 601 } 602 proc_thermal_rapl_remove(); 603 proc_thermal_remove(proc_priv); 604 } 605 606 #ifdef CONFIG_PM_SLEEP 607 static int proc_thermal_resume(struct device *dev) 608 { 609 struct proc_thermal_device *proc_dev; 610 611 proc_dev = dev_get_drvdata(dev); 612 proc_thermal_read_ppcc(proc_dev); 613 614 return 0; 615 } 616 #else 617 #define proc_thermal_resume NULL 618 #endif 619 620 static SIMPLE_DEV_PM_OPS(proc_thermal_pm, NULL, proc_thermal_resume); 621 622 static const struct pci_device_id proc_thermal_pci_ids[] = { 623 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_BDW_THERMAL)}, 624 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_HSB_THERMAL)}, 625 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_SKL_THERMAL), 626 .driver_data = (kernel_ulong_t)&rapl_mmio_hsw, }, 627 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_BSW_THERMAL)}, 628 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_BXT0_THERMAL)}, 629 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_BXT1_THERMAL)}, 630 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_BXTX_THERMAL)}, 631 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_BXTP_THERMAL)}, 632 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_CNL_THERMAL)}, 633 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_CFL_THERMAL)}, 634 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_GLK_THERMAL)}, 635 { 0, }, 636 }; 637 638 MODULE_DEVICE_TABLE(pci, proc_thermal_pci_ids); 639 640 static struct pci_driver proc_thermal_pci_driver = { 641 .name = DRV_NAME, 642 .probe = proc_thermal_pci_probe, 643 .remove = proc_thermal_pci_remove, 644 .id_table = proc_thermal_pci_ids, 645 .driver.pm = &proc_thermal_pm, 646 }; 647 648 static const struct acpi_device_id int3401_device_ids[] = { 649 {"INT3401", 0}, 650 {"", 0}, 651 }; 652 MODULE_DEVICE_TABLE(acpi, int3401_device_ids); 653 654 static struct platform_driver int3401_driver = { 655 .probe = int3401_add, 656 .remove = int3401_remove, 657 .driver = { 658 .name = "int3401 thermal", 659 .acpi_match_table = int3401_device_ids, 660 .pm = &proc_thermal_pm, 661 }, 662 }; 663 664 static int __init proc_thermal_init(void) 665 { 666 int ret; 667 668 ret = platform_driver_register(&int3401_driver); 669 if (ret) 670 return ret; 671 672 ret = pci_register_driver(&proc_thermal_pci_driver); 673 674 return ret; 675 } 676 677 static void __exit proc_thermal_exit(void) 678 { 679 platform_driver_unregister(&int3401_driver); 680 pci_unregister_driver(&proc_thermal_pci_driver); 681 } 682 683 module_init(proc_thermal_init); 684 module_exit(proc_thermal_exit); 685 686 MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>"); 687 MODULE_DESCRIPTION("Processor Thermal Reporting Device Driver"); 688 MODULE_LICENSE("GPL v2"); 689