Skip to content

Commit

Permalink
ARM / PXA: Use struct syscore_ops for "core" power management
Browse files Browse the repository at this point in the history
Replace sysdev classes and struct sys_device objects used for "core"
power management by the PXA platform code with struct syscore_ops
objects that are simpler.

This reduces the code size and the kernel memory footprint.  It also
is necessary for removing sysdevs entirely from the kernel in the
future.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Rafael J. Wysocki committed Apr 24, 2011
1 parent 9053398 commit 2eaa03b
Show file tree
Hide file tree
Showing 31 changed files with 110 additions and 307 deletions.
1 change: 0 additions & 1 deletion arch/arm/mach-pxa/balloon3.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/sysdev.h>
#include <linux/interrupt.h>
#include <linux/sched.h>
#include <linux/bitops.h>
Expand Down
18 changes: 4 additions & 14 deletions arch/arm/mach-pxa/clock-pxa2xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/sysdev.h>
#include <linux/syscore_ops.h>

#include <mach/pxa2xx-regs.h>

Expand All @@ -33,32 +33,22 @@ const struct clkops clk_pxa2xx_cken_ops = {
#ifdef CONFIG_PM
static uint32_t saved_cken;

static int pxa2xx_clock_suspend(struct sys_device *d, pm_message_t state)
static int pxa2xx_clock_suspend(void)
{
saved_cken = CKEN;
return 0;
}

static int pxa2xx_clock_resume(struct sys_device *d)
static void pxa2xx_clock_resume(void)
{
CKEN = saved_cken;
return 0;
}
#else
#define pxa2xx_clock_suspend NULL
#define pxa2xx_clock_resume NULL
#endif

struct sysdev_class pxa2xx_clock_sysclass = {
.name = "pxa2xx-clock",
struct syscore_ops pxa2xx_clock_syscore_ops = {
.suspend = pxa2xx_clock_suspend,
.resume = pxa2xx_clock_resume,
};

static int __init pxa2xx_clock_init(void)
{
if (cpu_is_pxa2xx())
return sysdev_class_register(&pxa2xx_clock_sysclass);
return 0;
}
postcore_initcall(pxa2xx_clock_init);
17 changes: 4 additions & 13 deletions arch/arm/mach-pxa/clock-pxa3xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/syscore_ops.h>

#include <mach/smemc.h>
#include <mach/pxa3xx-regs.h>
Expand Down Expand Up @@ -182,36 +183,26 @@ const struct clkops clk_pxa3xx_pout_ops = {
static uint32_t cken[2];
static uint32_t accr;

static int pxa3xx_clock_suspend(struct sys_device *d, pm_message_t state)
static int pxa3xx_clock_suspend(void)
{
cken[0] = CKENA;
cken[1] = CKENB;
accr = ACCR;
return 0;
}

static int pxa3xx_clock_resume(struct sys_device *d)
static void pxa3xx_clock_resume(void)
{
ACCR = accr;
CKENA = cken[0];
CKENB = cken[1];
return 0;
}
#else
#define pxa3xx_clock_suspend NULL
#define pxa3xx_clock_resume NULL
#endif

struct sysdev_class pxa3xx_clock_sysclass = {
.name = "pxa3xx-clock",
struct syscore_ops pxa3xx_clock_syscore_ops = {
.suspend = pxa3xx_clock_suspend,
.resume = pxa3xx_clock_resume,
};

static int __init pxa3xx_clock_init(void)
{
if (cpu_is_pxa3xx() || cpu_is_pxa95x())
return sysdev_class_register(&pxa3xx_clock_sysclass);
return 0;
}
postcore_initcall(pxa3xx_clock_init);
7 changes: 4 additions & 3 deletions arch/arm/mach-pxa/clock.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <linux/clkdev.h>
#include <linux/sysdev.h>
#include <linux/syscore_ops.h>

struct clkops {
void (*enable)(struct clk *);
Expand Down Expand Up @@ -54,7 +54,7 @@ extern const struct clkops clk_pxa2xx_cken_ops;
void clk_pxa2xx_cken_enable(struct clk *clk);
void clk_pxa2xx_cken_disable(struct clk *clk);

extern struct sysdev_class pxa2xx_clock_sysclass;
extern struct syscore_ops pxa2xx_clock_syscore_ops;

#if defined(CONFIG_PXA3xx) || defined(CONFIG_PXA95x)
#define DEFINE_PXA3_CKEN(_name, _cken, _rate, _delay) \
Expand All @@ -74,5 +74,6 @@ extern const struct clkops clk_pxa3xx_smemc_ops;
extern void clk_pxa3xx_cken_enable(struct clk *);
extern void clk_pxa3xx_cken_disable(struct clk *);

extern struct sysdev_class pxa3xx_clock_sysclass;
extern struct syscore_ops pxa3xx_clock_syscore_ops;

#endif
1 change: 0 additions & 1 deletion arch/arm/mach-pxa/cm-x270.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*/

#include <linux/platform_device.h>
#include <linux/sysdev.h>
#include <linux/irq.h>
#include <linux/gpio.h>
#include <linux/delay.h>
Expand Down
23 changes: 7 additions & 16 deletions arch/arm/mach-pxa/cm-x2xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

#include <linux/platform_device.h>
#include <linux/sysdev.h>
#include <linux/syscore_ops.h>
#include <linux/irq.h>
#include <linux/gpio.h>

Expand Down Expand Up @@ -388,7 +388,7 @@ static inline void cmx2xx_init_display(void) {}
#ifdef CONFIG_PM
static unsigned long sleep_save_msc[10];

static int cmx2xx_suspend(struct sys_device *dev, pm_message_t state)
static int cmx2xx_suspend(void)
{
cmx2xx_pci_suspend();

Expand All @@ -412,35 +412,26 @@ static int cmx2xx_suspend(struct sys_device *dev, pm_message_t state)
return 0;
}

static int cmx2xx_resume(struct sys_device *dev)
static void cmx2xx_resume(void)
{
cmx2xx_pci_resume();

/* restore MSC registers */
__raw_writel(sleep_save_msc[0], MSC0);
__raw_writel(sleep_save_msc[1], MSC1);
__raw_writel(sleep_save_msc[2], MSC2);

return 0;
}

static struct sysdev_class cmx2xx_pm_sysclass = {
.name = "pm",
static struct syscore_ops cmx2xx_pm_syscore_ops = {
.resume = cmx2xx_resume,
.suspend = cmx2xx_suspend,
};

static struct sys_device cmx2xx_pm_device = {
.cls = &cmx2xx_pm_sysclass,
};

static int __init cmx2xx_pm_init(void)
{
int error;
error = sysdev_class_register(&cmx2xx_pm_sysclass);
if (error == 0)
error = sysdev_register(&cmx2xx_pm_device);
return error;
register_syscore_ops(&cmx2xx_pm_syscore_ops);

return 0;
}
#else
static int __init cmx2xx_pm_init(void) { return 0; }
Expand Down
1 change: 0 additions & 1 deletion arch/arm/mach-pxa/colibri-evalboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/sysdev.h>
#include <linux/interrupt.h>
#include <linux/gpio.h>
#include <asm/mach-types.h>
Expand Down
1 change: 0 additions & 1 deletion arch/arm/mach-pxa/colibri-pxa270-income.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <linux/platform_device.h>
#include <linux/pwm_backlight.h>
#include <linux/i2c/pxa-i2c.h>
#include <linux/sysdev.h>

#include <asm/irq.h>
#include <asm/mach-types.h>
Expand Down
1 change: 0 additions & 1 deletion arch/arm/mach-pxa/colibri-pxa270.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <linux/mtd/partitions.h>
#include <linux/mtd/physmap.h>
#include <linux/platform_device.h>
#include <linux/sysdev.h>
#include <linux/ucb1400.h>

#include <asm/mach/arch.h>
Expand Down
8 changes: 4 additions & 4 deletions arch/arm/mach-pxa/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ extern unsigned pxa3xx_get_clk_frequency_khz(int);
#define pxa3xx_get_clk_frequency_khz(x) (0)
#endif

extern struct sysdev_class pxa_irq_sysclass;
extern struct sysdev_class pxa_gpio_sysclass;
extern struct sysdev_class pxa2xx_mfp_sysclass;
extern struct sysdev_class pxa3xx_mfp_sysclass;
extern struct syscore_ops pxa_irq_syscore_ops;
extern struct syscore_ops pxa_gpio_syscore_ops;
extern struct syscore_ops pxa2xx_mfp_syscore_ops;
extern struct syscore_ops pxa3xx_mfp_syscore_ops;

void __init pxa_set_ffuart_info(void *info);
void __init pxa_set_btuart_info(void *info);
Expand Down
17 changes: 4 additions & 13 deletions arch/arm/mach-pxa/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/sysdev.h>
#include <linux/syscore_ops.h>
#include <linux/io.h>
#include <linux/irq.h>

Expand Down Expand Up @@ -183,7 +183,7 @@ void __init pxa_init_irq(int irq_nr, set_wake_t fn)
static unsigned long saved_icmr[MAX_INTERNAL_IRQS/32];
static unsigned long saved_ipr[MAX_INTERNAL_IRQS];

static int pxa_irq_suspend(struct sys_device *dev, pm_message_t state)
static int pxa_irq_suspend(void)
{
int i;

Expand All @@ -202,7 +202,7 @@ static int pxa_irq_suspend(struct sys_device *dev, pm_message_t state)
return 0;
}

static int pxa_irq_resume(struct sys_device *dev)
static void pxa_irq_resume(void)
{
int i;

Expand All @@ -218,22 +218,13 @@ static int pxa_irq_resume(struct sys_device *dev)
__raw_writel(saved_ipr[i], IRQ_BASE + IPR(i));

__raw_writel(1, IRQ_BASE + ICCR);
return 0;
}
#else
#define pxa_irq_suspend NULL
#define pxa_irq_resume NULL
#endif

struct sysdev_class pxa_irq_sysclass = {
.name = "irq",
struct syscore_ops pxa_irq_syscore_ops = {
.suspend = pxa_irq_suspend,
.resume = pxa_irq_resume,
};

static int __init pxa_irq_init(void)
{
return sysdev_class_register(&pxa_irq_sysclass);
}

core_initcall(pxa_irq_init);
20 changes: 6 additions & 14 deletions arch/arm/mach-pxa/lpd270.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/sysdev.h>
#include <linux/syscore_ops.h>
#include <linux/interrupt.h>
#include <linux/sched.h>
#include <linux/bitops.h>
Expand Down Expand Up @@ -159,30 +159,22 @@ static void __init lpd270_init_irq(void)


#ifdef CONFIG_PM
static int lpd270_irq_resume(struct sys_device *dev)
static void lpd270_irq_resume(void)
{
__raw_writew(lpd270_irq_enabled, LPD270_INT_MASK);
return 0;
}

static struct sysdev_class lpd270_irq_sysclass = {
.name = "cpld_irq",
static struct syscore_ops lpd270_irq_syscore_ops = {
.resume = lpd270_irq_resume,
};

static struct sys_device lpd270_irq_device = {
.cls = &lpd270_irq_sysclass,
};

static int __init lpd270_irq_device_init(void)
{
int ret = -ENODEV;
if (machine_is_logicpd_pxa270()) {
ret = sysdev_class_register(&lpd270_irq_sysclass);
if (ret == 0)
ret = sysdev_register(&lpd270_irq_device);
register_syscore_ops(&lpd270_irq_syscore_ops);
return 0;
}
return ret;
return -ENODEV;
}

device_initcall(lpd270_irq_device_init);
Expand Down
21 changes: 6 additions & 15 deletions arch/arm/mach-pxa/lubbock.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/sysdev.h>
#include <linux/syscore_ops.h>
#include <linux/major.h>
#include <linux/fb.h>
#include <linux/interrupt.h>
Expand Down Expand Up @@ -176,31 +176,22 @@ static void __init lubbock_init_irq(void)

#ifdef CONFIG_PM

static int lubbock_irq_resume(struct sys_device *dev)
static void lubbock_irq_resume(void)
{
LUB_IRQ_MASK_EN = lubbock_irq_enabled;
return 0;
}

static struct sysdev_class lubbock_irq_sysclass = {
.name = "cpld_irq",
static struct syscore_ops lubbock_irq_syscore_ops = {
.resume = lubbock_irq_resume,
};

static struct sys_device lubbock_irq_device = {
.cls = &lubbock_irq_sysclass,
};

static int __init lubbock_irq_device_init(void)
{
int ret = -ENODEV;

if (machine_is_lubbock()) {
ret = sysdev_class_register(&lubbock_irq_sysclass);
if (ret == 0)
ret = sysdev_register(&lubbock_irq_device);
register_syscore_ops(&lubbock_irq_syscore_ops);
return 0;
}
return ret;
return -ENODEV;
}

device_initcall(lubbock_irq_device_init);
Expand Down
Loading

0 comments on commit 2eaa03b

Please sign in to comment.