mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 12:42:02 +00: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
240 lines
5.7 KiB
C
240 lines
5.7 KiB
C
/*
|
|
* Copyright (C) 2001-2002 Deep Blue Solutions Ltd.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* CPU support functions
|
|
*/
|
|
#include <linux/module.h>
|
|
#include <linux/types.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/cpufreq.h>
|
|
#include <linux/sched.h>
|
|
#include <linux/smp.h>
|
|
#include <linux/init.h>
|
|
#include <linux/io.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/of.h>
|
|
#include <linux/of_address.h>
|
|
|
|
#include <asm/mach-types.h>
|
|
#include <asm/hardware/icst.h>
|
|
|
|
static void __iomem *cm_base;
|
|
/* The cpufreq driver only use the OSC register */
|
|
#define INTEGRATOR_HDR_OSC_OFFSET 0x08
|
|
#define INTEGRATOR_HDR_LOCK_OFFSET 0x14
|
|
|
|
static struct cpufreq_driver integrator_driver;
|
|
|
|
static const struct icst_params lclk_params = {
|
|
.ref = 24000000,
|
|
.vco_max = ICST525_VCO_MAX_5V,
|
|
.vco_min = ICST525_VCO_MIN,
|
|
.vd_min = 8,
|
|
.vd_max = 132,
|
|
.rd_min = 24,
|
|
.rd_max = 24,
|
|
.s2div = icst525_s2div,
|
|
.idx2s = icst525_idx2s,
|
|
};
|
|
|
|
static const struct icst_params cclk_params = {
|
|
.ref = 24000000,
|
|
.vco_max = ICST525_VCO_MAX_5V,
|
|
.vco_min = ICST525_VCO_MIN,
|
|
.vd_min = 12,
|
|
.vd_max = 160,
|
|
.rd_min = 24,
|
|
.rd_max = 24,
|
|
.s2div = icst525_s2div,
|
|
.idx2s = icst525_idx2s,
|
|
};
|
|
|
|
/*
|
|
* Validate the speed policy.
|
|
*/
|
|
static int integrator_verify_policy(struct cpufreq_policy *policy)
|
|
{
|
|
struct icst_vco vco;
|
|
|
|
cpufreq_verify_within_cpu_limits(policy);
|
|
|
|
vco = icst_hz_to_vco(&cclk_params, policy->max * 1000);
|
|
policy->max = icst_hz(&cclk_params, vco) / 1000;
|
|
|
|
vco = icst_hz_to_vco(&cclk_params, policy->min * 1000);
|
|
policy->min = icst_hz(&cclk_params, vco) / 1000;
|
|
|
|
cpufreq_verify_within_cpu_limits(policy);
|
|
return 0;
|
|
}
|
|
|
|
|
|
static int integrator_set_target(struct cpufreq_policy *policy,
|
|
unsigned int target_freq,
|
|
unsigned int relation)
|
|
{
|
|
cpumask_t cpus_allowed;
|
|
int cpu = policy->cpu;
|
|
struct icst_vco vco;
|
|
struct cpufreq_freqs freqs;
|
|
u_int cm_osc;
|
|
|
|
/*
|
|
* Save this threads cpus_allowed mask.
|
|
*/
|
|
cpus_allowed = current->cpus_allowed;
|
|
|
|
/*
|
|
* Bind to the specified CPU. When this call returns,
|
|
* we should be running on the right CPU.
|
|
*/
|
|
set_cpus_allowed(current, cpumask_of_cpu(cpu));
|
|
BUG_ON(cpu != smp_processor_id());
|
|
|
|
/* get current setting */
|
|
cm_osc = __raw_readl(cm_base + INTEGRATOR_HDR_OSC_OFFSET);
|
|
|
|
if (machine_is_integrator()) {
|
|
vco.s = (cm_osc >> 8) & 7;
|
|
} else if (machine_is_cintegrator()) {
|
|
vco.s = 1;
|
|
}
|
|
vco.v = cm_osc & 255;
|
|
vco.r = 22;
|
|
freqs.old = icst_hz(&cclk_params, vco) / 1000;
|
|
|
|
/* icst_hz_to_vco rounds down -- so we need the next
|
|
* larger freq in case of CPUFREQ_RELATION_L.
|
|
*/
|
|
if (relation == CPUFREQ_RELATION_L)
|
|
target_freq += 999;
|
|
if (target_freq > policy->max)
|
|
target_freq = policy->max;
|
|
vco = icst_hz_to_vco(&cclk_params, target_freq * 1000);
|
|
freqs.new = icst_hz(&cclk_params, vco) / 1000;
|
|
|
|
if (freqs.old == freqs.new) {
|
|
set_cpus_allowed(current, cpus_allowed);
|
|
return 0;
|
|
}
|
|
|
|
cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
|
|
|
|
cm_osc = __raw_readl(cm_base + INTEGRATOR_HDR_OSC_OFFSET);
|
|
|
|
if (machine_is_integrator()) {
|
|
cm_osc &= 0xfffff800;
|
|
cm_osc |= vco.s << 8;
|
|
} else if (machine_is_cintegrator()) {
|
|
cm_osc &= 0xffffff00;
|
|
}
|
|
cm_osc |= vco.v;
|
|
|
|
__raw_writel(0xa05f, cm_base + INTEGRATOR_HDR_LOCK_OFFSET);
|
|
__raw_writel(cm_osc, cm_base + INTEGRATOR_HDR_OSC_OFFSET);
|
|
__raw_writel(0, cm_base + INTEGRATOR_HDR_LOCK_OFFSET);
|
|
|
|
/*
|
|
* Restore the CPUs allowed mask.
|
|
*/
|
|
set_cpus_allowed(current, cpus_allowed);
|
|
|
|
cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static unsigned int integrator_get(unsigned int cpu)
|
|
{
|
|
cpumask_t cpus_allowed;
|
|
unsigned int current_freq;
|
|
u_int cm_osc;
|
|
struct icst_vco vco;
|
|
|
|
cpus_allowed = current->cpus_allowed;
|
|
|
|
set_cpus_allowed(current, cpumask_of_cpu(cpu));
|
|
BUG_ON(cpu != smp_processor_id());
|
|
|
|
/* detect memory etc. */
|
|
cm_osc = __raw_readl(cm_base + INTEGRATOR_HDR_OSC_OFFSET);
|
|
|
|
if (machine_is_integrator()) {
|
|
vco.s = (cm_osc >> 8) & 7;
|
|
} else {
|
|
vco.s = 1;
|
|
}
|
|
vco.v = cm_osc & 255;
|
|
vco.r = 22;
|
|
|
|
current_freq = icst_hz(&cclk_params, vco) / 1000; /* current freq */
|
|
|
|
set_cpus_allowed(current, cpus_allowed);
|
|
|
|
return current_freq;
|
|
}
|
|
|
|
static int integrator_cpufreq_init(struct cpufreq_policy *policy)
|
|
{
|
|
|
|
/* set default policy and cpuinfo */
|
|
policy->max = policy->cpuinfo.max_freq = 160000;
|
|
policy->min = policy->cpuinfo.min_freq = 12000;
|
|
policy->cpuinfo.transition_latency = 1000000; /* 1 ms, assumed */
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct cpufreq_driver integrator_driver = {
|
|
.verify = integrator_verify_policy,
|
|
.target = integrator_set_target,
|
|
.get = integrator_get,
|
|
.init = integrator_cpufreq_init,
|
|
.name = "integrator",
|
|
};
|
|
|
|
static int __init integrator_cpufreq_probe(struct platform_device *pdev)
|
|
{
|
|
struct resource *res;
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
if (!res)
|
|
return -ENODEV;
|
|
|
|
cm_base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
|
|
if (!cm_base)
|
|
return -ENODEV;
|
|
|
|
return cpufreq_register_driver(&integrator_driver);
|
|
}
|
|
|
|
static void __exit integrator_cpufreq_remove(struct platform_device *pdev)
|
|
{
|
|
cpufreq_unregister_driver(&integrator_driver);
|
|
}
|
|
|
|
static const struct of_device_id integrator_cpufreq_match[] = {
|
|
{ .compatible = "arm,core-module-integrator"},
|
|
{ },
|
|
};
|
|
|
|
static struct platform_driver integrator_cpufreq_driver = {
|
|
.driver = {
|
|
.name = "integrator-cpufreq",
|
|
.owner = THIS_MODULE,
|
|
.of_match_table = integrator_cpufreq_match,
|
|
},
|
|
.remove = __exit_p(integrator_cpufreq_remove),
|
|
};
|
|
|
|
module_platform_driver_probe(integrator_cpufreq_driver,
|
|
integrator_cpufreq_probe);
|
|
|
|
MODULE_AUTHOR ("Russell M. King");
|
|
MODULE_DESCRIPTION ("cpufreq driver for ARM Integrator CPUs");
|
|
MODULE_LICENSE ("GPL");
|