Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPI: DPTF: Add PCH FIVR participant driver

This driver adds support for Dynamic Platform and Thermal Framework
(DPTF) PCH (Platform Controller Hub) FIVR (Fully Integrated Voltage
Regulator) participant support.

This participant is responsible for exposing platform telemetry and
control for:
freq_mhz_high_clock
freq_mhz_low_clock

These attributes are used to get and set PCH FIVR switching frequency
for thermal and radio frequency interference mitigation.

Refer to Documentation/ABI/testing/sysfs-platform-dptf for ABI details.

ACPI methods description used in this driver:
RFC0: This ACPI method to set PCH FIVR switching frequency when FIVR
clock is 19.2MHz or 24MHz. The ACPI method takes a DWORD value.
GFC0: This ACPI method to get PCH FIVR switching frequency when FIVR
clock is 19.2MHz or 24MHz.
RFC1: This ACPI method to set PCH FIVR switching frequency when FIVR
clock is 38.4MHz. The ACPI method takes a DWORD value.
GFC1: This ACPI method to get PCH FIVR switching frequency when FIVR
clock is 38.4MHz.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Srinivas Pandruvada and committed by
Rafael J. Wysocki
2ce6324e 856deb86

+158
+16
Documentation/ABI/testing/sysfs-platform-dptf
··· 92 92 Description: 93 93 (RO) The battery discharge current capability obtained from battery fuel gauge in 94 94 milli Amps. 95 + 96 + What: /sys/bus/platform/devices/INTC1045:00/pch_fivr_switch_frequency/freq_mhz_low_clock 97 + Date: November, 2020 98 + KernelVersion: v5.10 99 + Contact: linux-acpi@vger.kernel.org 100 + Description: 101 + (RW) The PCH FIVR (Fully Integrated Voltage Regulator) switching frequency in MHz, 102 + when FIVR clock is 19.2MHz or 24MHz. 103 + 104 + What: /sys/bus/platform/devices/INTC1045:00/pch_fivr_switch_frequency/freq_mhz_high_clock 105 + Date: November, 2020 106 + KernelVersion: v5.10 107 + Contact: linux-acpi@vger.kernel.org 108 + Description: 109 + (RW) The PCH FIVR (Fully Integrated Voltage Regulator) switching frequency in MHz, 110 + when FIVR clock is 38.4MHz.
+14
drivers/acpi/dptf/Kconfig
··· 14 14 15 15 To compile this driver as a module, choose M here: 16 16 the module will be called dptf_power. 17 + 18 + config DPTF_PCH_FIVR 19 + tristate "DPTF PCH FIVR Participant" 20 + depends on X86 21 + help 22 + This driver adds support for Dynamic Platform and Thermal Framework 23 + (DPTF) PCH FIVR Participant device support. This driver allows to 24 + switch PCH FIVR (Fully Integrated Voltage Regulator) frequency. 25 + This participant is responsible for exposing: 26 + freq_mhz_low_clock 27 + freq_mhz_high_clock 28 + 29 + To compile this driver as a module, choose M here: 30 + the module will be called dptf_pch_fivr.
+1
drivers/acpi/dptf/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 obj-$(CONFIG_ACPI) += int340x_thermal.o 3 3 obj-$(CONFIG_DPTF_POWER) += dptf_power.o 4 + obj-$(CONFIG_DPTF_PCH_FIVR) += dptf_pch_fivr.o
+126
drivers/acpi/dptf/dptf_pch_fivr.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * dptf_pch_fivr: DPTF PCH FIVR Participant driver 4 + * Copyright (c) 2020, Intel Corporation. 5 + */ 6 + 7 + #include <linux/acpi.h> 8 + #include <linux/kernel.h> 9 + #include <linux/module.h> 10 + #include <linux/platform_device.h> 11 + 12 + /* 13 + * Presentation of attributes which are defined for INT1045 14 + * They are: 15 + * freq_mhz_low_clock : Set PCH FIVR switching freq for 16 + * FIVR clock 19.2MHz and 24MHz 17 + * freq_mhz_high_clock : Set PCH FIVR switching freq for 18 + * FIVR clock 38.4MHz 19 + */ 20 + #define PCH_FIVR_SHOW(name, method) \ 21 + static ssize_t name##_show(struct device *dev,\ 22 + struct device_attribute *attr,\ 23 + char *buf)\ 24 + {\ 25 + struct acpi_device *acpi_dev = dev_get_drvdata(dev);\ 26 + unsigned long long val;\ 27 + acpi_status status;\ 28 + \ 29 + status = acpi_evaluate_integer(acpi_dev->handle, #method,\ 30 + NULL, &val);\ 31 + if (ACPI_SUCCESS(status))\ 32 + return sprintf(buf, "%d\n", (int)val);\ 33 + else\ 34 + return -EINVAL;\ 35 + } 36 + 37 + #define PCH_FIVR_STORE(name, method) \ 38 + static ssize_t name##_store(struct device *dev,\ 39 + struct device_attribute *attr,\ 40 + const char *buf, size_t count)\ 41 + {\ 42 + struct acpi_device *acpi_dev = dev_get_drvdata(dev);\ 43 + acpi_status status;\ 44 + u32 val;\ 45 + \ 46 + if (kstrtouint(buf, 0, &val) < 0)\ 47 + return -EINVAL;\ 48 + \ 49 + status = acpi_execute_simple_method(acpi_dev->handle, #method, val);\ 50 + if (ACPI_SUCCESS(status))\ 51 + return count;\ 52 + \ 53 + return -EINVAL;\ 54 + } 55 + 56 + PCH_FIVR_SHOW(freq_mhz_low_clock, GFC0) 57 + PCH_FIVR_SHOW(freq_mhz_high_clock, GFC1) 58 + PCH_FIVR_STORE(freq_mhz_low_clock, RFC0) 59 + PCH_FIVR_STORE(freq_mhz_high_clock, RFC1) 60 + 61 + static DEVICE_ATTR_RW(freq_mhz_low_clock); 62 + static DEVICE_ATTR_RW(freq_mhz_high_clock); 63 + 64 + static struct attribute *fivr_attrs[] = { 65 + &dev_attr_freq_mhz_low_clock.attr, 66 + &dev_attr_freq_mhz_high_clock.attr, 67 + NULL 68 + }; 69 + 70 + static const struct attribute_group pch_fivr_attribute_group = { 71 + .attrs = fivr_attrs, 72 + .name = "pch_fivr_switch_frequency" 73 + }; 74 + 75 + static int pch_fivr_add(struct platform_device *pdev) 76 + { 77 + struct acpi_device *acpi_dev; 78 + unsigned long long ptype; 79 + acpi_status status; 80 + int result; 81 + 82 + acpi_dev = ACPI_COMPANION(&(pdev->dev)); 83 + if (!acpi_dev) 84 + return -ENODEV; 85 + 86 + status = acpi_evaluate_integer(acpi_dev->handle, "PTYP", NULL, &ptype); 87 + if (ACPI_FAILURE(status) || ptype != 0x05) 88 + return -ENODEV; 89 + 90 + result = sysfs_create_group(&pdev->dev.kobj, 91 + &pch_fivr_attribute_group); 92 + if (result) 93 + return result; 94 + 95 + platform_set_drvdata(pdev, acpi_dev); 96 + 97 + return 0; 98 + } 99 + 100 + static int pch_fivr_remove(struct platform_device *pdev) 101 + { 102 + sysfs_remove_group(&pdev->dev.kobj, &pch_fivr_attribute_group); 103 + 104 + return 0; 105 + } 106 + 107 + static const struct acpi_device_id pch_fivr_device_ids[] = { 108 + {"INTC1045", 0}, 109 + {"", 0}, 110 + }; 111 + MODULE_DEVICE_TABLE(acpi, pch_fivr_device_ids); 112 + 113 + static struct platform_driver pch_fivr_driver = { 114 + .probe = pch_fivr_add, 115 + .remove = pch_fivr_remove, 116 + .driver = { 117 + .name = "DPTF PCH FIVR", 118 + .acpi_match_table = pch_fivr_device_ids, 119 + }, 120 + }; 121 + 122 + module_platform_driver(pch_fivr_driver); 123 + 124 + MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>"); 125 + MODULE_LICENSE("GPL v2"); 126 + MODULE_DESCRIPTION("ACPI DPTF PCH FIVR driver");
+1
drivers/acpi/dptf/int340x_thermal.c
··· 27 27 {"INTC1040"}, 28 28 {"INTC1043"}, 29 29 {"INTC1044"}, 30 + {"INTC1045"}, 30 31 {"INTC1047"}, 31 32 {""}, 32 33 };