Rev 9144 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9144 | Rev 9827 | ||
---|---|---|---|
Line 27... | Line 27... | ||
27 | #include |
27 | #include |
28 | #include |
28 | #include |
Line 29... | Line 29... | ||
29 | 29 | ||
30 | struct cpuinfo_x86 boot_cpu_data; |
30 | struct cpuinfo_x86 boot_cpu_data; |
- | 31 | extern void init_amd_nbs(void); |
|
- | 32 | extern void free_pci_devices(void); |
|
- | 33 | ||
Line 31... | Line 34... | ||
31 | extern void init_amd_nbs(void); |
34 | #define MODNAME KBUILD_MODNAME ": " |
Line 32... | Line 35... | ||
32 | 35 | ||
33 | #define KERNEL_SPACE 0x80000000 |
36 | #define KERNEL_SPACE 0x80000000 |
Line 307... | Line 310... | ||
307 | default: |
310 | default: |
308 | return 0; |
311 | return 0; |
309 | } |
312 | } |
310 | return 0444; |
313 | return 0444; |
311 | } |
314 | } |
312 | #if 0 |
315 | |
313 | bool has_erratum_319(struct pci_dev *pdev) |
316 | bool has_erratum_319(struct pci_dev *pdev) |
314 | { |
317 | { |
315 | u32 pkg_type, reg_dram_cfg; |
318 | u32 pkg_type, reg_dram_cfg; |
Line 316... | Line 319... | ||
316 | 319 | ||
Line 341... | Line 344... | ||
341 | * and AM3 formats, but that's the best we can do. |
344 | * and AM3 formats, but that's the best we can do. |
342 | */ |
345 | */ |
Line 343... | Line 346... | ||
343 | 346 | ||
344 | return boot_cpu_data.x86_model < 4; |
347 | return boot_cpu_data.x86_model < 4; |
345 | } |
- | |
Line 346... | Line 348... | ||
346 | #endif |
348 | } |
347 | 349 | ||
348 | const struct hwmon_channel_info *k10temp_info[] = { |
350 | const struct hwmon_channel_info *k10temp_info[] = { |
349 | HWMON_CHANNEL_INFO(temp, |
351 | HWMON_CHANNEL_INFO(temp, |
Line 394... | Line 396... | ||
394 | } |
396 | } |
395 | } |
397 | } |
Line 396... | Line 398... | ||
396 | 398 | ||
397 | int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id, struct device *hwmon_dev) |
399 | int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id, struct device *hwmon_dev) |
398 | { |
400 | { |
399 | // int unreliable = has_erratum_319(pdev); |
401 | int unreliable = has_erratum_319(pdev); |
400 | struct device *dev = &pdev->dev; |
402 | struct device *dev = &pdev->dev; |
401 | struct k10temp_data *data; |
403 | struct k10temp_data *data; |
402 | int i; |
404 | int i; |
403 | /* if (unreliable) { |
405 | if (unreliable) { |
404 | if (!force) { |
406 | /* if (!force) { |
405 | dev_err(dev,"unreliable CPU thermal sensor; monitoring disabled\n"); |
407 | dev_err(dev,"unreliable CPU thermal sensor; monitoring disabled\n"); |
406 | return -ENODEV; |
408 | return -ENODEV; |
407 | } |
- | |
408 | dev_warn(dev, |
- | |
409 | "unreliable CPU thermal sensor; check erratum 319\n"); |
- | |
410 | } |
409 | } |
411 | */ |
410 | */ |
- | 411 | printk(MODNAME "Unreliable CPU thermal sensor; Check erratum 319\n"); |
|
- | 412 | } |
|
412 | data = kzalloc(sizeof(struct k10temp_data), GFP_KERNEL); |
413 | |
413 | memset(data, 0x0, sizeof(struct k10temp_data)); |
414 | data = KernelZeroAlloc(sizeof(struct k10temp_data)); |
414 | if (!data) |
415 | if (!data) |
Line 415... | Line 416... | ||
415 | return -ENOMEM; |
416 | return -ENOMEM; |
416 | 417 | ||
Line 489... | Line 490... | ||
489 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_19H_DF_F3) }, |
490 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_19H_DF_F3) }, |
490 | { PCI_VDEVICE(HYGON, PCI_DEVICE_ID_AMD_17H_DF_F3) }, |
491 | { PCI_VDEVICE(HYGON, PCI_DEVICE_ID_AMD_17H_DF_F3) }, |
491 | {} |
492 | {} |
492 | }; |
493 | }; |
Line 493... | Line 494... | ||
493 | 494 | ||
494 | #define K10TEMP_NA (~0) |
495 | #define K10TEMP_NA (-1) |
Line 495... | Line -... | ||
495 | #define CHANEL_MAX 9 |
- | |
496 | 496 | #define CHANEL_INPUT_MAX 10 |
|
497 | #pragma pack(push, 1) |
497 | |
498 | struct{ |
498 | struct { |
499 | int Tctl; |
499 | int Tctl; |
500 | int Tdie; |
500 | int Tdie; |
Line 509... | Line 509... | ||
509 | 509 | ||
510 | int Tmax; |
510 | int Tmax; |
511 | int Tcrit; |
511 | int Tcrit; |
512 | int Tcrit_hyst; |
512 | int Tcrit_hyst; |
513 | }k10temp_out; |
- | |
Line 514... | Line 513... | ||
514 | #pragma pack(pop) |
513 | } k10temp_out; |
Line 515... | Line 514... | ||
515 | 514 | ||
516 | struct device k10temp_device; |
515 | struct device k10temp_device; |
517 | 516 | ||
518 | void read_temp_info(struct device *dev, u32 attr, int channel, int *val){ |
517 | int read_temp_info(struct device *dev, unsigned attr, int channel) { |
519 | long temp=0; |
- | |
520 | if(k10temp_is_visible(dev->driver_data, hwmon_temp, attr, channel)){ |
- | |
521 | k10temp_read_temp(dev, attr, channel, &temp); |
518 | long temp = K10TEMP_NA; |
522 | *val=temp; |
519 | if (k10temp_is_visible(dev->driver_data, hwmon_temp, attr, channel)) { |
523 | }else{ |
520 | if (k10temp_read_temp(dev, attr, channel, &temp)) { |
- | 521 | temp = K10TEMP_NA; |
|
- | 522 | } |
|
Line 524... | Line 523... | ||
524 | *val=K10TEMP_NA; |
523 | } |
- | 524 | return (int)temp; |
|
- | 525 | } |
|
525 | } |
526 | |
526 | } |
527 | void read_all_info(struct device* dev) |
527 | 528 | { |
|
528 | void read_all_info(struct device* dev){ |
- | |
529 | for(int c=0; c<=CHANEL_MAX; c++){ |
- | |
530 | read_temp_info(dev, hwmon_temp_input, c, (int*)&k10temp_out+c); |
- | |
531 | } |
529 | int* k10temp_out_array = (int*)&k10temp_out; |
Line 532... | Line 530... | ||
532 | read_temp_info(dev, hwmon_temp_max, 0, &k10temp_out.Tmax); |
530 | for (int c = 0; c < CHANEL_INPUT_MAX; c++) { |
- | 531 | k10temp_out_array[c] = read_temp_info(dev, hwmon_temp_input, c); |
|
533 | read_temp_info(dev, hwmon_temp_crit, 0, &k10temp_out.Tcrit); |
532 | } |
534 | read_temp_info(dev, hwmon_temp_crit_hyst, 0, &k10temp_out.Tcrit_hyst); |
533 | } |
535 | } |
534 | |
536 | 535 | int __stdcall service_proc(ioctl_t *my_ctl) |
|
Line 537... | Line 536... | ||
537 | int __stdcall service_proc(ioctl_t *my_ctl){ |
536 | { |
Line 538... | Line 537... | ||
538 | if(!my_ctl || !my_ctl->output || (int)my_ctl->output>=KERNEL_SPACE-sizeof(k10temp_out)){ |
537 | if(!my_ctl || !my_ctl->output || (int)my_ctl->output>=KERNEL_SPACE-sizeof(k10temp_out)){ |
539 | printk("k10temp: Bad address for writing data!\n"); |
538 | printk(MODNAME "Bad address for writing data!\n"); |
540 | return 0; |
539 | return 0; |
541 | } |
540 | } |
542 | 541 | ||
543 | read_all_info(&k10temp_device); |
542 | read_all_info(&k10temp_device); |
544 | 543 | ||
Line 545... | Line 544... | ||
545 | if(my_ctl->out_size == sizeof(k10temp_out)){ |
544 | if(my_ctl->out_size == sizeof(k10temp_out)){ |
- | 545 | memcpy(my_ctl->output, &k10temp_out, sizeof(k10temp_out)); |
|
546 | memcpy(my_ctl->output, &k10temp_out, sizeof(k10temp_out)); |
546 | return 0; |
547 | return 0; |
547 | } |
548 | } |
548 | printk(MODNAME "Invalid buffer length!\n"); |
- | 549 | return 1; |
|
549 | printk("k10temp: Invalid buffer length!\n"); |
550 | } |
550 | return 1; |
551 | |
551 | } |
- | |
Line 552... | Line 552... | ||
552 | 552 | uint32_t drvEntry(int action, char *cmdline) |
|
Line 553... | Line -... | ||
553 | uint32_t drvEntry(int action, char *cmdline){ |
- | |
554 | if(action != 1){ |
553 | { |
555 | return 0; |
554 | if (action != 1) { |
556 | } |
555 | return 0; |
557 | pci_dev_t device; |
556 | } |
Line 558... | Line 557... | ||
558 | const struct pci_device_id *k10temp_id; |
557 | |
Line 559... | Line 558... | ||
559 | int err; |
558 | static pci_dev_t device; |
560 | 559 | const struct pci_device_id *k10temp_id; |
|
561 | cpu_detect(&boot_cpu_data); |
560 | |
562 | 561 | cpu_detect(&boot_cpu_data); |
|
Line 563... | Line 562... | ||
563 | err = enum_pci_devices(); |
562 | |
564 | if(unlikely(err != 0)) { |
563 | if(unlikely(enum_pci_devices() != 0)) { |
- | 564 | printk(MODNAME "Device enumeration failed!\n"); |
|
- | 565 | goto error; |
|
- | 566 | } |
|
- | 567 | ||
- | 568 | k10temp_id = find_pci_device(&device, k10temp_id_table); |
|
565 | printk("k10temp: Device enumeration failed!\n"); |
569 | |
- | 570 | if (unlikely(k10temp_id == NULL)) { |
|
- | 571 | printk(MODNAME "Device not found!\n"); |
|
- | 572 | goto error; |
|
- | 573 | } |
|
566 | return 0; |
574 |