Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 351078
b: refs/heads/master
c: 5af4a21
h: refs/heads/master
v: v3
  • Loading branch information
Daniel Lezcano authored and Len Brown committed Feb 8, 2013
1 parent 2dfad9e commit 3e56503
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 28 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ac3ebafa81af76d65e4fb45c6388f08e90ddcc6d
refs/heads/master: 5af4a21c6efd270a334202fb1fc4a347ea4624e3
23 changes: 10 additions & 13 deletions trunk/arch/arm/mach-davinci/cpuidle.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#define DAVINCI_CPUIDLE_MAX_STATES 2

struct davinci_ops {
void (*enter) (u32 flags);
void (*exit) (u32 flags);
void (*enter) (void);
void (*exit) (void);
u32 flags;
};

Expand All @@ -40,20 +40,17 @@ static int davinci_enter_idle(struct cpuidle_device *dev,
struct davinci_ops *ops = cpuidle_get_statedata(state_usage);

if (ops && ops->enter)
ops->enter(ops->flags);
ops->enter();

index = cpuidle_wrap_enter(dev, drv, index,
arm_cpuidle_simple_enter);

if (ops && ops->exit)
ops->exit(ops->flags);
ops->exit();

return index;
}

/* fields in davinci_ops.flags */
#define DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN BIT(0)

static struct cpuidle_driver davinci_idle_driver = {
.name = "cpuidle-davinci",
.owner = THIS_MODULE,
Expand All @@ -72,6 +69,7 @@ static struct cpuidle_driver davinci_idle_driver = {

static DEFINE_PER_CPU(struct cpuidle_device, davinci_cpuidle_device);
static void __iomem *ddr2_reg_base;
static bool ddr2_pdown;

static void davinci_save_ddr_power(int enter, bool pdown)
{
Expand All @@ -92,14 +90,14 @@ static void davinci_save_ddr_power(int enter, bool pdown)
__raw_writel(val, ddr2_reg_base + DDR2_SDRCR_OFFSET);
}

static void davinci_c2state_enter(u32 flags)
static void davinci_c2state_enter(void)
{
davinci_save_ddr_power(1, !!(flags & DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN));
davinci_save_ddr_power(1, ddr2_pdown);
}

static void davinci_c2state_exit(u32 flags)
static void davinci_c2state_exit(void)
{
davinci_save_ddr_power(0, !!(flags & DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN));
davinci_save_ddr_power(0, ddr2_pdown);
}

static struct davinci_ops davinci_states[DAVINCI_CPUIDLE_MAX_STATES] = {
Expand All @@ -124,8 +122,7 @@ static int __init davinci_cpuidle_probe(struct platform_device *pdev)

ddr2_reg_base = pdata->ddr2_ctlr_base;

if (pdata->ddr2_pdown)
davinci_states[1].flags |= DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN;
ddr2_pdown = pdata->ddr2_pdown;
cpuidle_set_statedata(&device->states_usage[1], &davinci_states[1]);

device->state_count = DAVINCI_CPUIDLE_MAX_STATES;
Expand Down
47 changes: 33 additions & 14 deletions trunk/drivers/acpi/processor_idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/cpufreq.h>
#include <linux/slab.h>
#include <linux/acpi.h>
#include <linux/dmi.h>
#include <linux/sched.h> /* need_resched() */
#include <linux/moduleparam.h>
#include <linux/sched.h> /* need_resched() */
#include <linux/pm_qos.h>
#include <linux/clockchips.h>
#include <linux/cpuidle.h>
#include <linux/irqflags.h>

/*
* Include the apic definitions for x86 to have the APIC timer related defines
Expand All @@ -45,14 +52,22 @@
#include <asm/apic.h>
#endif

#include <asm/io.h>
#include <asm/uaccess.h>

#include <acpi/acpi_bus.h>
#include <acpi/processor.h>
#include <asm/processor.h>

#define PREFIX "ACPI: "

#define ACPI_PROCESSOR_CLASS "processor"
#define _COMPONENT ACPI_PROCESSOR_COMPONENT
ACPI_MODULE_NAME("processor_idle");
#define PM_TIMER_TICK_NS (1000000000ULL/PM_TIMER_FREQUENCY)
#define C2_OVERHEAD 1 /* 1us */
#define C3_OVERHEAD 1 /* 1us */
#define PM_TIMER_TICKS_TO_US(p) (((p) * 1000)/(PM_TIMER_FREQUENCY/1000))

static unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER;
module_param(max_cstate, uint, 0000);
Expand All @@ -66,8 +81,6 @@ module_param(latency_factor, uint, 0644);

static DEFINE_PER_CPU(struct cpuidle_device *, acpi_cpuidle_device);

static struct acpi_processor_cx *acpi_cstate[CPUIDLE_STATE_MAX];

static int disabled_by_idle_boot_param(void)
{
return boot_option_idle_override == IDLE_POLL ||
Expand Down Expand Up @@ -723,7 +736,8 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev,
struct cpuidle_driver *drv, int index)
{
struct acpi_processor *pr;
struct acpi_processor_cx *cx = acpi_cstate[index];
struct cpuidle_state_usage *state_usage = &dev->states_usage[index];
struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage);

pr = __this_cpu_read(processors);

Expand All @@ -746,7 +760,8 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev,
*/
static int acpi_idle_play_dead(struct cpuidle_device *dev, int index)
{
struct acpi_processor_cx *cx = acpi_cstate[index];
struct cpuidle_state_usage *state_usage = &dev->states_usage[index];
struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage);

ACPI_FLUSH_CPU_CACHE();

Expand Down Expand Up @@ -776,7 +791,8 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
struct cpuidle_driver *drv, int index)
{
struct acpi_processor *pr;
struct acpi_processor_cx *cx = acpi_cstate[index];
struct cpuidle_state_usage *state_usage = &dev->states_usage[index];
struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage);

pr = __this_cpu_read(processors);

Expand Down Expand Up @@ -834,7 +850,8 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
struct cpuidle_driver *drv, int index)
{
struct acpi_processor *pr;
struct acpi_processor_cx *cx = acpi_cstate[index];
struct cpuidle_state_usage *state_usage = &dev->states_usage[index];
struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage);

pr = __this_cpu_read(processors);

Expand Down Expand Up @@ -926,13 +943,13 @@ struct cpuidle_driver acpi_idle_driver = {
* device i.e. per-cpu data
*
* @pr: the ACPI processor
* @dev : the cpuidle device
*/
static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,
struct cpuidle_device *dev)
static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr)
{
int i, count = CPUIDLE_DRIVER_STATE_START;
struct acpi_processor_cx *cx;
struct cpuidle_state_usage *state_usage;
struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id);

if (!pr->flags.power_setup_done)
return -EINVAL;
Expand All @@ -951,6 +968,7 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,

for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) {
cx = &pr->power.states[i];
state_usage = &dev->states_usage[count];

if (!cx->valid)
continue;
Expand All @@ -961,7 +979,8 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,
!(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED))
continue;
#endif
acpi_cstate[count] = cx;

cpuidle_set_statedata(state_usage, cx);

count++;
if (count == CPUIDLE_STATE_MAX)
Expand Down Expand Up @@ -1085,7 +1104,7 @@ int acpi_processor_hotplug(struct acpi_processor *pr)
cpuidle_disable_device(dev);
acpi_processor_get_power_info(pr);
if (pr->flags.power) {
acpi_processor_setup_cpuidle_cx(pr, dev);
acpi_processor_setup_cpuidle_cx(pr);
ret = cpuidle_enable_device(dev);
}
cpuidle_resume_and_unlock();
Expand Down Expand Up @@ -1143,8 +1162,8 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
continue;
acpi_processor_get_power_info(_pr);
if (_pr->flags.power) {
acpi_processor_setup_cpuidle_cx(_pr);
dev = per_cpu(acpi_cpuidle_device, cpu);
acpi_processor_setup_cpuidle_cx(_pr, dev);
cpuidle_enable_device(dev);
}
}
Expand Down Expand Up @@ -1213,7 +1232,7 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr)
return -ENOMEM;
per_cpu(acpi_cpuidle_device, pr->id) = dev;

acpi_processor_setup_cpuidle_cx(pr, dev);
acpi_processor_setup_cpuidle_cx(pr);

/* Register per-cpu cpuidle_device. Cpuidle driver
* must already be registered before registering device
Expand Down

0 comments on commit 3e56503

Please sign in to comment.