Skip to content

Commit

Permalink
ARM / Samsung: 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 Samsung platforms with struct syscore_ops objects
that are simpler.

This generally 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>
Acked-by: Kukjin Kim <kgene.kim@samsung.com>
  • Loading branch information
Rafael J. Wysocki committed Apr 24, 2011
1 parent 2eaa03b commit bb072c3
Show file tree
Hide file tree
Showing 24 changed files with 203 additions and 228 deletions.
45 changes: 27 additions & 18 deletions arch/arm/mach-exynos4/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <linux/init.h>
#include <linux/suspend.h>
#include <linux/syscore_ops.h>
#include <linux/io.h>

#include <asm/cacheflush.h>
Expand Down Expand Up @@ -372,7 +373,27 @@ void exynos4_scu_enable(void __iomem *scu_base)
flush_cache_all();
}

static int exynos4_pm_resume(struct sys_device *dev)
static struct sysdev_driver exynos4_pm_driver = {
.add = exynos4_pm_add,
};

static __init int exynos4_pm_drvinit(void)
{
unsigned int tmp;

s3c_pm_init();

/* All wakeup disable */

tmp = __raw_readl(S5P_WAKEUP_MASK);
tmp |= ((0xFF << 8) | (0x1F << 1));
__raw_writel(tmp, S5P_WAKEUP_MASK);

return sysdev_driver_register(&exynos4_sysclass, &exynos4_pm_driver);
}
arch_initcall(exynos4_pm_drvinit);

static void exynos4_pm_resume(void)
{
/* For release retention */

Expand All @@ -394,27 +415,15 @@ static int exynos4_pm_resume(struct sys_device *dev)
/* enable L2X0*/
writel_relaxed(1, S5P_VA_L2CC + L2X0_CTRL);
#endif

return 0;
}

static struct sysdev_driver exynos4_pm_driver = {
.add = exynos4_pm_add,
static struct syscore_ops exynos4_pm_syscore_ops = {
.resume = exynos4_pm_resume,
};

static __init int exynos4_pm_drvinit(void)
static __init int exynos4_pm_syscore_init(void)
{
unsigned int tmp;

s3c_pm_init();

/* All wakeup disable */

tmp = __raw_readl(S5P_WAKEUP_MASK);
tmp |= ((0xFF << 8) | (0x1F << 1));
__raw_writel(tmp, S5P_WAKEUP_MASK);

return sysdev_driver_register(&exynos4_sysclass, &exynos4_pm_driver);
register_syscore_ops(&exynos4_pm_syscore_ops);
return 0;
}
arch_initcall(exynos4_pm_drvinit);
arch_initcall(exynos4_pm_syscore_init);
30 changes: 2 additions & 28 deletions arch/arm/mach-s3c2410/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,12 @@
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/ioport.h>
#include <linux/sysdev.h>
#include <linux/syscore_ops.h>

#include <plat/cpu.h>
#include <plat/pm.h>

static int s3c2410_irq_add(struct sys_device *sysdev)
{
return 0;
}

static struct sysdev_driver s3c2410_irq_driver = {
.add = s3c2410_irq_add,
struct syscore_ops s3c24xx_irq_syscore_ops = {
.suspend = s3c24xx_irq_suspend,
.resume = s3c24xx_irq_resume,
};

static int __init s3c2410_irq_init(void)
{
return sysdev_driver_register(&s3c2410_sysclass, &s3c2410_irq_driver);
}

arch_initcall(s3c2410_irq_init);

static struct sysdev_driver s3c2410a_irq_driver = {
.add = s3c2410_irq_add,
.suspend = s3c24xx_irq_suspend,
.resume = s3c24xx_irq_resume,
};

static int __init s3c2410a_irq_init(void)
{
return sysdev_driver_register(&s3c2410a_sysclass, &s3c2410a_irq_driver);
}

arch_initcall(s3c2410a_irq_init);
17 changes: 5 additions & 12 deletions arch/arm/mach-s3c2410/mach-bast.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <linux/timer.h>
#include <linux/init.h>
#include <linux/gpio.h>
#include <linux/sysdev.h>
#include <linux/syscore_ops.h>
#include <linux/serial_core.h>
#include <linux/platform_device.h>
#include <linux/dm9000.h>
Expand Down Expand Up @@ -214,34 +214,28 @@ static struct s3c2410_uartcfg bast_uartcfgs[] __initdata = {
/* NAND Flash on BAST board */

#ifdef CONFIG_PM
static int bast_pm_suspend(struct sys_device *sd, pm_message_t state)
static int bast_pm_suspend(void)
{
/* ensure that an nRESET is not generated on resume. */
gpio_direction_output(S3C2410_GPA(21), 1);
return 0;
}

static int bast_pm_resume(struct sys_device *sd)
static void bast_pm_resume(void)
{
s3c_gpio_cfgpin(S3C2410_GPA(21), S3C2410_GPA21_nRSTOUT);
return 0;
}

#else
#define bast_pm_suspend NULL
#define bast_pm_resume NULL
#endif

static struct sysdev_class bast_pm_sysclass = {
.name = "mach-bast",
static struct syscore_ops bast_pm_syscore_ops = {
.suspend = bast_pm_suspend,
.resume = bast_pm_resume,
};

static struct sys_device bast_pm_sysdev = {
.cls = &bast_pm_sysclass,
};

static int smartmedia_map[] = { 0 };
static int chip0_map[] = { 1 };
static int chip1_map[] = { 2 };
Expand Down Expand Up @@ -642,8 +636,7 @@ static void __init bast_map_io(void)

static void __init bast_init(void)
{
sysdev_class_register(&bast_pm_sysclass);
sysdev_register(&bast_pm_sysdev);
register_syscore_ops(&bast_pm_syscore_ops);

s3c_i2c0_set_platdata(&bast_i2c_info);
s3c_nand_set_platdata(&bast_nand_info);
Expand Down
13 changes: 6 additions & 7 deletions arch/arm/mach-s3c2410/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <linux/errno.h>
#include <linux/time.h>
#include <linux/sysdev.h>
#include <linux/syscore_ops.h>
#include <linux/gpio.h>
#include <linux/io.h>

Expand Down Expand Up @@ -92,7 +93,7 @@ static void s3c2410_pm_prepare(void)
}
}

static int s3c2410_pm_resume(struct sys_device *dev)
static void s3c2410_pm_resume(void)
{
unsigned long tmp;

Expand All @@ -104,10 +105,12 @@ static int s3c2410_pm_resume(struct sys_device *dev)

if ( machine_is_aml_m5900() )
s3c2410_gpio_setpin(S3C2410_GPF(2), 0);

return 0;
}

struct syscore_ops s3c2410_pm_syscore_ops = {
.resume = s3c2410_pm_resume,
};

static int s3c2410_pm_add(struct sys_device *dev)
{
pm_cpu_prep = s3c2410_pm_prepare;
Expand All @@ -119,7 +122,6 @@ static int s3c2410_pm_add(struct sys_device *dev)
#if defined(CONFIG_CPU_S3C2410)
static struct sysdev_driver s3c2410_pm_driver = {
.add = s3c2410_pm_add,
.resume = s3c2410_pm_resume,
};

/* register ourselves */
Expand All @@ -133,7 +135,6 @@ arch_initcall(s3c2410_pm_drvinit);

static struct sysdev_driver s3c2410a_pm_driver = {
.add = s3c2410_pm_add,
.resume = s3c2410_pm_resume,
};

static int __init s3c2410a_pm_drvinit(void)
Expand All @@ -147,7 +148,6 @@ arch_initcall(s3c2410a_pm_drvinit);
#if defined(CONFIG_CPU_S3C2440)
static struct sysdev_driver s3c2440_pm_driver = {
.add = s3c2410_pm_add,
.resume = s3c2410_pm_resume,
};

static int __init s3c2440_pm_drvinit(void)
Expand All @@ -161,7 +161,6 @@ arch_initcall(s3c2440_pm_drvinit);
#if defined(CONFIG_CPU_S3C2442)
static struct sysdev_driver s3c2442_pm_driver = {
.add = s3c2410_pm_add,
.resume = s3c2410_pm_resume,
};

static int __init s3c2442_pm_drvinit(void)
Expand Down
5 changes: 5 additions & 0 deletions arch/arm/mach-s3c2410/s3c2410.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <linux/gpio.h>
#include <linux/clk.h>
#include <linux/sysdev.h>
#include <linux/syscore_ops.h>
#include <linux/serial_core.h>
#include <linux/platform_device.h>
#include <linux/io.h>
Expand All @@ -40,6 +41,7 @@
#include <plat/devs.h>
#include <plat/clock.h>
#include <plat/pll.h>
#include <plat/pm.h>

#include <plat/gpio-core.h>
#include <plat/gpio-cfg.h>
Expand Down Expand Up @@ -168,6 +170,9 @@ int __init s3c2410_init(void)
{
printk("S3C2410: Initialising architecture\n");

register_syscore_ops(&s3c2410_pm_syscore_ops);
register_syscore_ops(&s3c24xx_irq_syscore_ops);

return sysdev_register(&s3c2410_sysdev);
}

Expand Down
2 changes: 0 additions & 2 deletions arch/arm/mach-s3c2412/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ static int s3c2412_irq_add(struct sys_device *sysdev)

static struct sysdev_driver s3c2412_irq_driver = {
.add = s3c2412_irq_add,
.suspend = s3c24xx_irq_suspend,
.resume = s3c24xx_irq_resume,
};

static int s3c2412_irq_init(void)
Expand Down
19 changes: 6 additions & 13 deletions arch/arm/mach-s3c2412/mach-jive.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <linux/timer.h>
#include <linux/init.h>
#include <linux/gpio.h>
#include <linux/sysdev.h>
#include <linux/syscore_ops.h>
#include <linux/serial_core.h>
#include <linux/platform_device.h>
#include <linux/i2c.h>
Expand Down Expand Up @@ -486,7 +486,7 @@ static struct s3c2410_udc_mach_info jive_udc_cfg __initdata = {
/* Jive power management device */

#ifdef CONFIG_PM
static int jive_pm_suspend(struct sys_device *sd, pm_message_t state)
static int jive_pm_suspend(void)
{
/* Write the magic value u-boot uses to check for resume into
* the INFORM0 register, and ensure INFORM1 is set to the
Expand All @@ -498,27 +498,21 @@ static int jive_pm_suspend(struct sys_device *sd, pm_message_t state)
return 0;
}

static int jive_pm_resume(struct sys_device *sd)
static void jive_pm_resume(void)
{
__raw_writel(0x0, S3C2412_INFORM0);
return 0;
}

#else
#define jive_pm_suspend NULL
#define jive_pm_resume NULL
#endif

static struct sysdev_class jive_pm_sysclass = {
.name = "jive-pm",
static struct syscore_ops jive_pm_syscore_ops = {
.suspend = jive_pm_suspend,
.resume = jive_pm_resume,
};

static struct sys_device jive_pm_sysdev = {
.cls = &jive_pm_sysclass,
};

static void __init jive_map_io(void)
{
s3c24xx_init_io(jive_iodesc, ARRAY_SIZE(jive_iodesc));
Expand All @@ -536,10 +530,9 @@ static void jive_power_off(void)

static void __init jive_machine_init(void)
{
/* register system devices for managing low level suspend */
/* register system core operations for managing low level suspend */

sysdev_class_register(&jive_pm_sysclass);
sysdev_register(&jive_pm_sysdev);
register_syscore_ops(&jive_pm_syscore_ops);

/* write our sleep configurations for the IO. Pull down all unused
* IO, ensure that we have turned off all peripherals we do not
Expand Down
27 changes: 15 additions & 12 deletions arch/arm/mach-s3c2412/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/timer.h>
#include <linux/init.h>
#include <linux/sysdev.h>
#include <linux/syscore_ops.h>
#include <linux/platform_device.h>
#include <linux/io.h>

Expand Down Expand Up @@ -86,13 +87,24 @@ static struct sleep_save s3c2412_sleep[] = {
SAVE_ITEM(S3C2413_GPJSLPCON),
};

static int s3c2412_pm_suspend(struct sys_device *dev, pm_message_t state)
static struct sysdev_driver s3c2412_pm_driver = {
.add = s3c2412_pm_add,
};

static __init int s3c2412_pm_init(void)
{
return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_pm_driver);
}

arch_initcall(s3c2412_pm_init);

static int s3c2412_pm_suspend(void)
{
s3c_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
return 0;
}

static int s3c2412_pm_resume(struct sys_device *dev)
static void s3c2412_pm_resume(void)
{
unsigned long tmp;

Expand All @@ -102,18 +114,9 @@ static int s3c2412_pm_resume(struct sys_device *dev)
__raw_writel(tmp, S3C2412_PWRCFG);

s3c_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
return 0;
}

static struct sysdev_driver s3c2412_pm_driver = {
.add = s3c2412_pm_add,
struct syscore_ops s3c2412_pm_syscore_ops = {
.suspend = s3c2412_pm_suspend,
.resume = s3c2412_pm_resume,
};

static __init int s3c2412_pm_init(void)
{
return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_pm_driver);
}

arch_initcall(s3c2412_pm_init);
4 changes: 4 additions & 0 deletions arch/arm/mach-s3c2412/s3c2412.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/sysdev.h>
#include <linux/syscore_ops.h>
#include <linux/serial_core.h>
#include <linux/platform_device.h>
#include <linux/io.h>
Expand Down Expand Up @@ -244,5 +245,8 @@ int __init s3c2412_init(void)
{
printk("S3C2412: Initialising architecture\n");

register_syscore_ops(&s3c2412_pm_syscore_ops);
register_syscore_ops(&s3c24xx_irq_syscore_ops);

return sysdev_register(&s3c2412_sysdev);
}
Loading

0 comments on commit bb072c3

Please sign in to comment.