Skip to content

Commit

Permalink
ARM: imx: cpuidle: use init/exit common routine
Browse files Browse the repository at this point in the history
The code intializes the cpuidle driver at different places.
The cpuidle driver for :
  * imx5 : is in the pm-imx5.c, the init function is in cpuidle.c
  * imx6 : is in cpuidle-imx6q.c, the init function is in cpuidle.c
           and cpuidle-imx6q.c

Instead of having the cpuidle code spread across different files,
let's create a driver for each SoC and use the common register function.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Daniel Lezcano authored and Rafael J. Wysocki committed Apr 23, 2013
1 parent 3aec034 commit 54a4644
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 116 deletions.
2 changes: 1 addition & 1 deletion arch/arm/mach-imx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o
obj-$(CONFIG_CPU_FREQ_IMX) += cpufreq.o

ifeq ($(CONFIG_CPU_IDLE),y)
obj-y += cpuidle.o
obj-$(CONFIG_SOC_IMX5) += cpuidle-imx5.o
obj-$(CONFIG_SOC_IMX6Q) += cpuidle-imx6q.o
endif

Expand Down
37 changes: 37 additions & 0 deletions arch/arm/mach-imx/cpuidle-imx5.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2012 Freescale Semiconductor, Inc.
*
* 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.
*/

#include <linux/cpuidle.h>
#include <linux/module.h>
#include <asm/system_misc.h>

static int imx5_cpuidle_enter(struct cpuidle_device *dev,
struct cpuidle_driver *drv, int index)
{
arm_pm_idle();
return index;
}

static struct cpuidle_driver imx5_cpuidle_driver = {
.name = "imx5_cpuidle",
.owner = THIS_MODULE,
.states[0] = {
.enter = imx5_cpuidle_enter,
.exit_latency = 2,
.target_residency = 1,
.flags = CPUIDLE_FLAG_TIME_VALID,
.name = "IMX5 SRPG",
.desc = "CPU state retained,powered off",
},
.state_count = 1,
};

int __init imx5_cpuidle_init(void)
{
return cpuidle_register(&imx5_cpuidle_driver, NULL);
}
2 changes: 1 addition & 1 deletion arch/arm/mach-imx/cpuidle-imx6q.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ int __init imx6q_cpuidle_init(void)
/* Set chicken bit to get a reliable WAIT mode support */
imx6q_set_chicken_bit();

return imx_cpuidle_init(&imx6q_cpuidle_driver);
return cpuidle_register(&imx6q_cpuidle_driver, NULL);
}
80 changes: 0 additions & 80 deletions arch/arm/mach-imx/cpuidle.c

This file was deleted.

10 changes: 4 additions & 6 deletions arch/arm/mach-imx/cpuidle.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@
* http://www.gnu.org/copyleft/gpl.html
*/

#include <linux/cpuidle.h>

#ifdef CONFIG_CPU_IDLE
extern int imx_cpuidle_init(struct cpuidle_driver *drv);
extern int imx5_cpuidle_init(void);
extern int imx6q_cpuidle_init(void);
#else
static inline int imx_cpuidle_init(struct cpuidle_driver *drv)
static inline int imx5_cpuidle_init(void)
{
return -ENODEV;
return 0;
}
static inline int imx6q_cpuidle_init(void)
{
return -ENODEV;
return 0;
}
#endif
29 changes: 1 addition & 28 deletions arch/arm/mach-imx/pm-imx5.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,32 +149,6 @@ static void imx5_pm_idle(void)
imx5_cpu_do_idle();
}

static int imx5_cpuidle_enter(struct cpuidle_device *dev,
struct cpuidle_driver *drv, int idx)
{
int ret;

ret = imx5_cpu_do_idle();
if (ret < 0)
return ret;

return idx;
}

static struct cpuidle_driver imx5_cpuidle_driver = {
.name = "imx5_cpuidle",
.owner = THIS_MODULE,
.states[0] = {
.enter = imx5_cpuidle_enter,
.exit_latency = 2,
.target_residency = 1,
.flags = CPUIDLE_FLAG_TIME_VALID,
.name = "IMX5 SRPG",
.desc = "CPU state retained,powered off",
},
.state_count = 1,
};

static int __init imx5_pm_common_init(void)
{
int ret;
Expand All @@ -192,8 +166,7 @@ static int __init imx5_pm_common_init(void)
/* Set the registers to the default cpu idle state. */
mx5_cpu_lp_set(IMX5_DEFAULT_CPU_IDLE_STATE);

imx_cpuidle_init(&imx5_cpuidle_driver);
return 0;
return imx5_cpuidle_init();
}

void __init imx51_pm_init(void)
Expand Down

0 comments on commit 54a4644

Please sign in to comment.