mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-12 14:36:41 +07:00
f9300eaaac
- New power capping framework and the the Intel Running Average Power Limit (RAPL) driver using it from Srinivas Pandruvada and Jacob Pan. - Addition of the in-kernel switching feature to the arm_big_little cpufreq driver from Viresh Kumar and Nicolas Pitre. - cpufreq support for iMac G5 from Aaro Koskinen. - Baytrail processors support for intel_pstate from Dirk Brandewie. - cpufreq support for Midway/ECX-2000 from Mark Langsdorf. - ARM vexpress/TC2 cpufreq support from Sudeep KarkadaNagesha. - ACPI power management support for the I2C and SPI bus types from Mika Westerberg and Lv Zheng. - cpufreq core fixes and cleanups from Viresh Kumar, Srivatsa S Bhat, Stratos Karafotis, Xiaoguang Chen, Lan Tianyu. - cpufreq drivers updates (mostly fixes and cleanups) from Viresh Kumar, Aaro Koskinen, Jungseok Lee, Sudeep KarkadaNagesha, Lukasz Majewski, Manish Badarkhe, Hans-Christian Egtvedt, Evgeny Kapaev. - intel_pstate updates from Dirk Brandewie and Adrian Huang. - ACPICA update to version 20130927 includig fixes and cleanups and some reduction of divergences between the ACPICA code in the kernel and ACPICA upstream in order to improve the automatic ACPICA patch generation process. From Bob Moore, Lv Zheng, Tomasz Nowicki, Naresh Bhat, Bjorn Helgaas, David E Box. - ACPI IPMI driver fixes and cleanups from Lv Zheng. - ACPI hotplug fixes and cleanups from Bjorn Helgaas, Toshi Kani, Zhang Yanfei, Rafael J Wysocki. - Conversion of the ACPI AC driver to the platform bus type and multiple driver fixes and cleanups related to ACPI from Zhang Rui. - ACPI processor driver fixes and cleanups from Hanjun Guo, Jiang Liu, Bartlomiej Zolnierkiewicz, Mathieu Rhéaume, Rafael J Wysocki. - Fixes and cleanups and new blacklist entries related to the ACPI video support from Aaron Lu, Felipe Contreras, Lennart Poettering, Kirill Tkhai. - cpuidle core cleanups from Viresh Kumar and Lorenzo Pieralisi. - cpuidle drivers fixes and cleanups from Daniel Lezcano, Jingoo Han, Bartlomiej Zolnierkiewicz, Prarit Bhargava. - devfreq updates from Sachin Kamat, Dan Carpenter, Manish Badarkhe. - Operation Performance Points (OPP) core updates from Nishanth Menon. - Runtime power management core fix from Rafael J Wysocki and update from Ulf Hansson. - Hibernation fixes from Aaron Lu and Rafael J Wysocki. - Device suspend/resume lockup detection mechanism from Benoit Goby. - Removal of unused proc directories created for various ACPI drivers from Lan Tianyu. - ACPI LPSS driver fix and new device IDs for the ACPI platform scan handler from Heikki Krogerus and Jarkko Nikula. - New ACPI _OSI blacklist entry for Toshiba NB100 from Levente Kurusa. - Assorted fixes and cleanups related to ACPI from Andy Shevchenko, Al Stone, Bartlomiej Zolnierkiewicz, Colin Ian King, Dan Carpenter, Felipe Contreras, Jianguo Wu, Lan Tianyu, Yinghai Lu, Mathias Krause, Liu Chuansheng. - Assorted PM fixes and cleanups from Andy Shevchenko, Thierry Reding, Jean-Christophe Plagniol-Villard. / -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iQIcBAABCAAGBQJSfPKLAAoJEILEb/54YlRxH6YQAJwDKi25RCZziFSIenXuqzC/ c6JxoH/tSnDHJHhcTgqh7H7Raa+zmatMDf0m2oEv2Wjfx4Lt4BQK4iefhe/zY4lX yJ8uXDg+U8DYhDX2XwbwnFpd1M1k/A+s2gIHDTHHGnE0kDngXdd8RAFFktBmooTZ l5LBQvOrTlgX/ZfqI/MNmQ6lfY6kbCABGSHV1tUUsDA6Kkvk/LAUTOMSmptv1q22 hcs6k55vR34qADPkUX5GghjmcYJv+gNtvbDEJUjcmCwVoPWouF415m7R5lJ8w3/M 49Q8Tbu5HELWLwca64OorS8qh/P7sgUOf1BX5IDzHnJT+TGeDfvcYbMv2Z275/WZ /bqhuLuKBpsHQ2wvEeT+lYV3FlifKeTf1FBxER3ApjzI3GfpmVVQ+dpEu8e9hcTh ZTPGzziGtoIsHQ0unxb+zQOyt1PmIk+cU4IsKazs5U20zsVDMcKzPrb19Od49vMX gCHvRzNyOTqKWpE83Ss4NGOVPAG02AXiXi/BpuYBHKDy6fTH/liKiCw5xlCDEtmt lQrEbupKpc/dhCLo5ws6w7MZzjWJs2eSEQcNR4DlR++pxIpYOOeoPTXXrghgZt2X mmxZI2qsJ7GAvPzII8OBeF3CRO3fabZ6Nez+M+oEZjGe05ZtpB3ccw410HwieqBn dYpJFt/BHK189odhV9CM =JCxk -----END PGP SIGNATURE----- Merge tag 'pm+acpi-3.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm Pull ACPI and power management updates from Rafael J Wysocki: - New power capping framework and the the Intel Running Average Power Limit (RAPL) driver using it from Srinivas Pandruvada and Jacob Pan. - Addition of the in-kernel switching feature to the arm_big_little cpufreq driver from Viresh Kumar and Nicolas Pitre. - cpufreq support for iMac G5 from Aaro Koskinen. - Baytrail processors support for intel_pstate from Dirk Brandewie. - cpufreq support for Midway/ECX-2000 from Mark Langsdorf. - ARM vexpress/TC2 cpufreq support from Sudeep KarkadaNagesha. - ACPI power management support for the I2C and SPI bus types from Mika Westerberg and Lv Zheng. - cpufreq core fixes and cleanups from Viresh Kumar, Srivatsa S Bhat, Stratos Karafotis, Xiaoguang Chen, Lan Tianyu. - cpufreq drivers updates (mostly fixes and cleanups) from Viresh Kumar, Aaro Koskinen, Jungseok Lee, Sudeep KarkadaNagesha, Lukasz Majewski, Manish Badarkhe, Hans-Christian Egtvedt, Evgeny Kapaev. - intel_pstate updates from Dirk Brandewie and Adrian Huang. - ACPICA update to version 20130927 includig fixes and cleanups and some reduction of divergences between the ACPICA code in the kernel and ACPICA upstream in order to improve the automatic ACPICA patch generation process. From Bob Moore, Lv Zheng, Tomasz Nowicki, Naresh Bhat, Bjorn Helgaas, David E Box. - ACPI IPMI driver fixes and cleanups from Lv Zheng. - ACPI hotplug fixes and cleanups from Bjorn Helgaas, Toshi Kani, Zhang Yanfei, Rafael J Wysocki. - Conversion of the ACPI AC driver to the platform bus type and multiple driver fixes and cleanups related to ACPI from Zhang Rui. - ACPI processor driver fixes and cleanups from Hanjun Guo, Jiang Liu, Bartlomiej Zolnierkiewicz, Mathieu Rhéaume, Rafael J Wysocki. - Fixes and cleanups and new blacklist entries related to the ACPI video support from Aaron Lu, Felipe Contreras, Lennart Poettering, Kirill Tkhai. - cpuidle core cleanups from Viresh Kumar and Lorenzo Pieralisi. - cpuidle drivers fixes and cleanups from Daniel Lezcano, Jingoo Han, Bartlomiej Zolnierkiewicz, Prarit Bhargava. - devfreq updates from Sachin Kamat, Dan Carpenter, Manish Badarkhe. - Operation Performance Points (OPP) core updates from Nishanth Menon. - Runtime power management core fix from Rafael J Wysocki and update from Ulf Hansson. - Hibernation fixes from Aaron Lu and Rafael J Wysocki. - Device suspend/resume lockup detection mechanism from Benoit Goby. - Removal of unused proc directories created for various ACPI drivers from Lan Tianyu. - ACPI LPSS driver fix and new device IDs for the ACPI platform scan handler from Heikki Krogerus and Jarkko Nikula. - New ACPI _OSI blacklist entry for Toshiba NB100 from Levente Kurusa. - Assorted fixes and cleanups related to ACPI from Andy Shevchenko, Al Stone, Bartlomiej Zolnierkiewicz, Colin Ian King, Dan Carpenter, Felipe Contreras, Jianguo Wu, Lan Tianyu, Yinghai Lu, Mathias Krause, Liu Chuansheng. - Assorted PM fixes and cleanups from Andy Shevchenko, Thierry Reding, Jean-Christophe Plagniol-Villard. * tag 'pm+acpi-3.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (386 commits) cpufreq: conservative: fix requested_freq reduction issue ACPI / hotplug: Consolidate deferred execution of ACPI hotplug routines PM / runtime: Use pm_runtime_put_sync() in __device_release_driver() ACPI / event: remove unneeded NULL pointer check Revert "ACPI / video: Ignore BIOS initial backlight value for HP 250 G1" ACPI / video: Quirk initial backlight level 0 ACPI / video: Fix initial level validity test intel_pstate: skip the driver if ACPI has power mgmt option PM / hibernate: Avoid overflow in hibernate_preallocate_memory() ACPI / hotplug: Do not execute "insert in progress" _OST ACPI / hotplug: Carry out PCI root eject directly ACPI / hotplug: Merge device hot-removal routines ACPI / hotplug: Make acpi_bus_hot_remove_device() internal ACPI / hotplug: Simplify device ejection routines ACPI / hotplug: Fix handle_root_bridge_removal() ACPI / hotplug: Refuse to hot-remove all objects with disabled hotplug ACPI / scan: Start matching drivers after trying scan handlers ACPI: Remove acpi_pci_slot_init() headers from internal.h ACPI / blacklist: fix name of ThinkPad Edge E530 PowerCap: Fix build error with option -Werror=format-security ... Conflicts: arch/arm/mach-omap2/opp.c drivers/Kconfig drivers/spi/spi.c
293 lines
6.6 KiB
C
293 lines
6.6 KiB
C
/*
|
|
* Copyright (C) 2007 PA Semi, Inc
|
|
*
|
|
* Authors: Egor Martovetsky <egor@pasemi.com>
|
|
* Olof Johansson <olof@lixom.net>
|
|
*
|
|
* Maintained by: Olof Johansson <olof@lixom.net>
|
|
*
|
|
* Based on arch/powerpc/platforms/cell/cbe_cpufreq.c:
|
|
* (C) Copyright IBM Deutschland Entwicklung GmbH 2005
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
*
|
|
*/
|
|
|
|
#include <linux/cpufreq.h>
|
|
#include <linux/timer.h>
|
|
#include <linux/module.h>
|
|
#include <linux/of_address.h>
|
|
|
|
#include <asm/hw_irq.h>
|
|
#include <asm/io.h>
|
|
#include <asm/prom.h>
|
|
#include <asm/time.h>
|
|
#include <asm/smp.h>
|
|
|
|
#define SDCASR_REG 0x0100
|
|
#define SDCASR_REG_STRIDE 0x1000
|
|
#define SDCPWR_CFGA0_REG 0x0100
|
|
#define SDCPWR_PWST0_REG 0x0000
|
|
#define SDCPWR_GIZTIME_REG 0x0440
|
|
|
|
/* SDCPWR_GIZTIME_REG fields */
|
|
#define SDCPWR_GIZTIME_GR 0x80000000
|
|
#define SDCPWR_GIZTIME_LONGLOCK 0x000000ff
|
|
|
|
/* Offset of ASR registers from SDC base */
|
|
#define SDCASR_OFFSET 0x120000
|
|
|
|
static void __iomem *sdcpwr_mapbase;
|
|
static void __iomem *sdcasr_mapbase;
|
|
|
|
/* Current astate, is used when waking up from power savings on
|
|
* one core, in case the other core has switched states during
|
|
* the idle time.
|
|
*/
|
|
static int current_astate;
|
|
|
|
/* We support 5(A0-A4) power states excluding turbo(A5-A6) modes */
|
|
static struct cpufreq_frequency_table pas_freqs[] = {
|
|
{0, 0},
|
|
{1, 0},
|
|
{2, 0},
|
|
{3, 0},
|
|
{4, 0},
|
|
{0, CPUFREQ_TABLE_END},
|
|
};
|
|
|
|
/*
|
|
* hardware specific functions
|
|
*/
|
|
|
|
static int get_astate_freq(int astate)
|
|
{
|
|
u32 ret;
|
|
ret = in_le32(sdcpwr_mapbase + SDCPWR_CFGA0_REG + (astate * 0x10));
|
|
|
|
return ret & 0x3f;
|
|
}
|
|
|
|
static int get_cur_astate(int cpu)
|
|
{
|
|
u32 ret;
|
|
|
|
ret = in_le32(sdcpwr_mapbase + SDCPWR_PWST0_REG);
|
|
ret = (ret >> (cpu * 4)) & 0x7;
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int get_gizmo_latency(void)
|
|
{
|
|
u32 giztime, ret;
|
|
|
|
giztime = in_le32(sdcpwr_mapbase + SDCPWR_GIZTIME_REG);
|
|
|
|
/* just provide the upper bound */
|
|
if (giztime & SDCPWR_GIZTIME_GR)
|
|
ret = (giztime & SDCPWR_GIZTIME_LONGLOCK) * 128000;
|
|
else
|
|
ret = (giztime & SDCPWR_GIZTIME_LONGLOCK) * 1000;
|
|
|
|
return ret;
|
|
}
|
|
|
|
static void set_astate(int cpu, unsigned int astate)
|
|
{
|
|
unsigned long flags;
|
|
|
|
/* Return if called before init has run */
|
|
if (unlikely(!sdcasr_mapbase))
|
|
return;
|
|
|
|
local_irq_save(flags);
|
|
|
|
out_le32(sdcasr_mapbase + SDCASR_REG + SDCASR_REG_STRIDE*cpu, astate);
|
|
|
|
local_irq_restore(flags);
|
|
}
|
|
|
|
int check_astate(void)
|
|
{
|
|
return get_cur_astate(hard_smp_processor_id());
|
|
}
|
|
|
|
void restore_astate(int cpu)
|
|
{
|
|
set_astate(cpu, current_astate);
|
|
}
|
|
|
|
/*
|
|
* cpufreq functions
|
|
*/
|
|
|
|
static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)
|
|
{
|
|
const u32 *max_freqp;
|
|
u32 max_freq;
|
|
int i, cur_astate;
|
|
struct resource res;
|
|
struct device_node *cpu, *dn;
|
|
int err = -ENODEV;
|
|
|
|
cpu = of_get_cpu_node(policy->cpu, NULL);
|
|
|
|
if (!cpu)
|
|
goto out;
|
|
|
|
dn = of_find_compatible_node(NULL, NULL, "1682m-sdc");
|
|
if (!dn)
|
|
dn = of_find_compatible_node(NULL, NULL,
|
|
"pasemi,pwrficient-sdc");
|
|
if (!dn)
|
|
goto out;
|
|
err = of_address_to_resource(dn, 0, &res);
|
|
of_node_put(dn);
|
|
if (err)
|
|
goto out;
|
|
sdcasr_mapbase = ioremap(res.start + SDCASR_OFFSET, 0x2000);
|
|
if (!sdcasr_mapbase) {
|
|
err = -EINVAL;
|
|
goto out;
|
|
}
|
|
|
|
dn = of_find_compatible_node(NULL, NULL, "1682m-gizmo");
|
|
if (!dn)
|
|
dn = of_find_compatible_node(NULL, NULL,
|
|
"pasemi,pwrficient-gizmo");
|
|
if (!dn) {
|
|
err = -ENODEV;
|
|
goto out_unmap_sdcasr;
|
|
}
|
|
err = of_address_to_resource(dn, 0, &res);
|
|
of_node_put(dn);
|
|
if (err)
|
|
goto out_unmap_sdcasr;
|
|
sdcpwr_mapbase = ioremap(res.start, 0x1000);
|
|
if (!sdcpwr_mapbase) {
|
|
err = -EINVAL;
|
|
goto out_unmap_sdcasr;
|
|
}
|
|
|
|
pr_debug("init cpufreq on CPU %d\n", policy->cpu);
|
|
|
|
max_freqp = of_get_property(cpu, "clock-frequency", NULL);
|
|
if (!max_freqp) {
|
|
err = -EINVAL;
|
|
goto out_unmap_sdcpwr;
|
|
}
|
|
|
|
/* we need the freq in kHz */
|
|
max_freq = *max_freqp / 1000;
|
|
|
|
pr_debug("max clock-frequency is at %u kHz\n", max_freq);
|
|
pr_debug("initializing frequency table\n");
|
|
|
|
/* initialize frequency table */
|
|
for (i=0; pas_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) {
|
|
pas_freqs[i].frequency =
|
|
get_astate_freq(pas_freqs[i].driver_data) * 100000;
|
|
pr_debug("%d: %d\n", i, pas_freqs[i].frequency);
|
|
}
|
|
|
|
cur_astate = get_cur_astate(policy->cpu);
|
|
pr_debug("current astate is at %d\n",cur_astate);
|
|
|
|
policy->cur = pas_freqs[cur_astate].frequency;
|
|
ppc_proc_freq = policy->cur * 1000ul;
|
|
|
|
return cpufreq_generic_init(policy, pas_freqs, get_gizmo_latency());
|
|
|
|
out_unmap_sdcpwr:
|
|
iounmap(sdcpwr_mapbase);
|
|
|
|
out_unmap_sdcasr:
|
|
iounmap(sdcasr_mapbase);
|
|
out:
|
|
return err;
|
|
}
|
|
|
|
static int pas_cpufreq_cpu_exit(struct cpufreq_policy *policy)
|
|
{
|
|
/*
|
|
* We don't support CPU hotplug. Don't unmap after the system
|
|
* has already made it to a running state.
|
|
*/
|
|
if (system_state != SYSTEM_BOOTING)
|
|
return 0;
|
|
|
|
if (sdcasr_mapbase)
|
|
iounmap(sdcasr_mapbase);
|
|
if (sdcpwr_mapbase)
|
|
iounmap(sdcpwr_mapbase);
|
|
|
|
cpufreq_frequency_table_put_attr(policy->cpu);
|
|
return 0;
|
|
}
|
|
|
|
static int pas_cpufreq_target(struct cpufreq_policy *policy,
|
|
unsigned int pas_astate_new)
|
|
{
|
|
int i;
|
|
|
|
pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n",
|
|
policy->cpu,
|
|
pas_freqs[pas_astate_new].frequency,
|
|
pas_freqs[pas_astate_new].driver_data);
|
|
|
|
current_astate = pas_astate_new;
|
|
|
|
for_each_online_cpu(i)
|
|
set_astate(i, pas_astate_new);
|
|
|
|
ppc_proc_freq = pas_freqs[pas_astate_new].frequency * 1000ul;
|
|
return 0;
|
|
}
|
|
|
|
static struct cpufreq_driver pas_cpufreq_driver = {
|
|
.name = "pas-cpufreq",
|
|
.flags = CPUFREQ_CONST_LOOPS,
|
|
.init = pas_cpufreq_cpu_init,
|
|
.exit = pas_cpufreq_cpu_exit,
|
|
.verify = cpufreq_generic_frequency_table_verify,
|
|
.target_index = pas_cpufreq_target,
|
|
.attr = cpufreq_generic_attr,
|
|
};
|
|
|
|
/*
|
|
* module init and destoy
|
|
*/
|
|
|
|
static int __init pas_cpufreq_init(void)
|
|
{
|
|
if (!of_machine_is_compatible("PA6T-1682M") &&
|
|
!of_machine_is_compatible("pasemi,pwrficient"))
|
|
return -ENODEV;
|
|
|
|
return cpufreq_register_driver(&pas_cpufreq_driver);
|
|
}
|
|
|
|
static void __exit pas_cpufreq_exit(void)
|
|
{
|
|
cpufreq_unregister_driver(&pas_cpufreq_driver);
|
|
}
|
|
|
|
module_init(pas_cpufreq_init);
|
|
module_exit(pas_cpufreq_exit);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_AUTHOR("Egor Martovetsky <egor@pasemi.com>, Olof Johansson <olof@lixom.net>");
|