The existing driver does not support System Memory so
adding support of system meory so that this can be used
on platforms which has ACPI_ADR_SPACE_SYSTEM_MEMORY type
system registers.

Function that creates sysfs entries in processor_driver in Linux,
is enabled to be compiled for arm64 platform

Signed-off-by: Tanveer <tanveer.a...@puresoftware.com>
Signed-off-by: kuldip dwivedi <kuldip.dwiv...@puresoftware.com>
---

Notes:
    1.  Added package in CPU.asl in edk2-platform to support
        _PCT: Performance Control and provide cluster status/control
        register like below..
    
        Name(_PTC, Package () {
          ResourceTemplate() {Register(SystemMemory, 32, 0, CPU_CLK_CSSR_REG,
                              CPU_DWORD_ACCESS)},
          ResourceTemplate() {Register(SystemMemory, 32, 0, CPU_CLK_CSSR_REG,
                              CPU_DWORD_ACCESS)}
        })
      for reference please see line:100 to line:105
    
https://source.codeaurora.org/external/qoriq/qoriq-components/edk2-platforms/tree/Platform/NXP/LS1046aRdbPkg/AcpiTables/Dsdt/CPU.asl?h=LX2160_UEFI_ACPI_EAR3
    2. This feature is tested on LS1046A platform

 drivers/acpi/Kconfig                |  2 +-
 drivers/acpi/processor_throttling.c | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 7540a5179a47..78b3e45f05e0 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -274,7 +274,7 @@ config ACPI_PROCESSOR
        tristate "Processor"
        depends on X86 || IA64 || ARM64
        select ACPI_PROCESSOR_IDLE
-       select ACPI_CPU_FREQ_PSS if X86 || IA64
+       select ACPI_CPU_FREQ_PSS if X86 || IA64 || ARM64
        default y
        help
          This driver adds support for the ACPI Processor package. It is 
required
diff --git a/drivers/acpi/processor_throttling.c 
b/drivers/acpi/processor_throttling.c
index a0bd56ece3ff..8ace1fb76712 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -767,6 +767,7 @@ static int acpi_read_throttling_status(struct 
acpi_processor *pr,
 {
        u32 bit_width, bit_offset;
        u32 ptc_value;
+       u64 ptc_value_64;
        u64 ptc_mask;
        struct acpi_processor_throttling *throttling;
        int ret = -1;
@@ -784,6 +785,17 @@ static int acpi_read_throttling_status(struct 
acpi_processor *pr,
                *value = (u64) ((ptc_value >> bit_offset) & ptc_mask);
                ret = 0;
                break;
+       case ACPI_ADR_SPACE_SYSTEM_MEMORY:
+               bit_width = throttling->status_register.bit_width;
+               bit_offset = throttling->status_register.bit_offset;
+
+               acpi_os_read_memory((acpi_physical_address)
+                               throttling->status_register.address,
+                               &ptc_value_64, (u32) (bit_width + bit_offset));
+               ptc_mask = (1UL << bit_width) - 1;
+               *value = (u64) ((ptc_value_64 >> bit_offset) & ptc_mask);
+               ret = 0;
+               break;
        case ACPI_ADR_SPACE_FIXED_HARDWARE:
                ret = acpi_throttling_rdmsr(value);
                break;
@@ -817,6 +829,18 @@ static int acpi_write_throttling_state(struct 
acpi_processor *pr,
                                        (u32) (bit_width + bit_offset));
                ret = 0;
                break;
+       case ACPI_ADR_SPACE_SYSTEM_MEMORY:
+               bit_width = throttling->control_register.bit_width;
+               bit_offset = throttling->control_register.bit_offset;
+               ptc_mask = (1UL << bit_width) - 1;
+               ptc_value = value & ptc_mask;
+
+               acpi_os_write_memory((acpi_physical_address)
+                               throttling->control_register.address,
+                                       (u64) (ptc_value << bit_offset),
+                                       (u32) (bit_width + bit_offset));
+               ret = 0;
+               break;
        case ACPI_ADR_SPACE_FIXED_HARDWARE:
                ret = acpi_throttling_wrmsr(value);
                break;
-- 
2.17.1

Reply via email to