Skip to content

Commit

Permalink
Merge branch 'next-s3c-pm' of git://aeryn.fluff.org.uk/bjdooks/linux …
Browse files Browse the repository at this point in the history
…into devel
  • Loading branch information
Russell King authored and Russell King committed Mar 26, 2009
2 parents 2f3ec50 + fff94cd commit f5f0e17
Show file tree
Hide file tree
Showing 28 changed files with 1,038 additions and 764 deletions.
8 changes: 4 additions & 4 deletions Documentation/arm/Samsung-S3C24XX/Suspend.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ Resuming
Machine Support
---------------

The machine specific functions must call the s3c2410_pm_init() function
The machine specific functions must call the s3c_pm_init() function
to say that its bootloader is capable of resuming. This can be as
simple as adding the following to the machine's definition:

INITMACHINE(s3c2410_pm_init)
INITMACHINE(s3c_pm_init)

A board can do its own setup before calling s3c2410_pm_init, if it
A board can do its own setup before calling s3c_pm_init, if it
needs to setup anything else for power management support.

There is currently no support for over-riding the default method of
Expand Down Expand Up @@ -74,7 +74,7 @@ statuc void __init machine_init(void)

enable_irq_wake(IRQ_EINT0);

s3c2410_pm_init();
s3c_pm_init();
}


Expand Down
23 changes: 23 additions & 0 deletions arch/arm/mach-s3c2410/include/mach/gpio-nrs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* arch/arm/mach-s3c2410/include/mach/gpio-nrs.h
*
* Copyright (c) 2008 Simtec Electronics
* http://armlinux.simtec.co.uk/
* Ben Dooks <ben@simtec.co.uk>
*
* S3C2410 - GPIO bank numbering
*
* 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.
*/

#define S3C2410_GPIONO(bank,offset) ((bank) + (offset))

#define S3C2410_GPIO_BANKA (32*0)
#define S3C2410_GPIO_BANKB (32*1)
#define S3C2410_GPIO_BANKC (32*2)
#define S3C2410_GPIO_BANKD (32*3)
#define S3C2410_GPIO_BANKE (32*4)
#define S3C2410_GPIO_BANKF (32*5)
#define S3C2410_GPIO_BANKG (32*6)
#define S3C2410_GPIO_BANKH (32*7)
3 changes: 3 additions & 0 deletions arch/arm/mach-s3c2410/include/mach/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@
#define ARCH_NR_GPIOS (256 + CONFIG_S3C24XX_GPIO_EXTRA)

#include <asm-generic/gpio.h>
#include <mach/gpio-nrs.h>

#define S3C_GPIO_END (S3C2410_GPIO_BANKH + 32)
2 changes: 1 addition & 1 deletion arch/arm/mach-s3c2410/include/mach/irqs.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
#define IRQ_EINT22 S3C2410_IRQ(50)
#define IRQ_EINT23 S3C2410_IRQ(51)


#define IRQ_EINT_BIT(x) ((x) - IRQ_EINT4 + 4)
#define IRQ_EINT(x) (((x) >= 4) ? (IRQ_EINT4 + (x) - 4) : (IRQ_EINT0 + (x)))

#define IRQ_LCD_FIFO S3C2410_IRQ(52)
Expand Down
11 changes: 1 addition & 10 deletions arch/arm/mach-s3c2410/include/mach/regs-gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,7 @@
#ifndef __ASM_ARCH_REGS_GPIO_H
#define __ASM_ARCH_REGS_GPIO_H

#define S3C2410_GPIONO(bank,offset) ((bank) + (offset))

#define S3C2410_GPIO_BANKA (32*0)
#define S3C2410_GPIO_BANKB (32*1)
#define S3C2410_GPIO_BANKC (32*2)
#define S3C2410_GPIO_BANKD (32*3)
#define S3C2410_GPIO_BANKE (32*4)
#define S3C2410_GPIO_BANKF (32*5)
#define S3C2410_GPIO_BANKG (32*6)
#define S3C2410_GPIO_BANKH (32*7)
#include <mach/gpio-nrs.h>

#ifdef CONFIG_CPU_S3C2400
#define S3C24XX_GPIO_BASE(x) S3C2400_GPIO_BASE(x)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-s3c2410/mach-h1940.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static void __init h1940_map_io(void)
#ifdef CONFIG_PM_H1940
memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 1024);
#endif
s3c2410_pm_init();
s3c_pm_init();
}

static void __init h1940_init_irq(void)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-s3c2410/mach-qt2410.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ static void __init qt2410_machine_init(void)
s3c2410_gpio_cfgpin(S3C2410_GPB5, S3C2410_GPIO_OUTPUT);

platform_add_devices(qt2410_devices, ARRAY_SIZE(qt2410_devices));
s3c2410_pm_init();
s3c_pm_init();
}

MACHINE_START(QT2410, "QT2410")
Expand Down
13 changes: 3 additions & 10 deletions arch/arm/mach-s3c2410/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,14 @@
#include <plat/cpu.h>
#include <plat/pm.h>

#ifdef CONFIG_S3C2410_PM_DEBUG
extern void pm_dbg(const char *fmt, ...);
#define DBG(fmt...) pm_dbg(fmt)
#else
#define DBG(fmt...) printk(KERN_DEBUG fmt)
#endif

static void s3c2410_pm_prepare(void)
{
/* ensure at least GSTATUS3 has the resume address */

__raw_writel(virt_to_phys(s3c2410_cpu_resume), S3C2410_GSTATUS3);
__raw_writel(virt_to_phys(s3c_cpu_resume), S3C2410_GSTATUS3);

DBG("GSTATUS3 0x%08x\n", __raw_readl(S3C2410_GSTATUS3));
DBG("GSTATUS4 0x%08x\n", __raw_readl(S3C2410_GSTATUS4));
S3C_PMDBG("GSTATUS3 0x%08x\n", __raw_readl(S3C2410_GSTATUS3));
S3C_PMDBG("GSTATUS4 0x%08x\n", __raw_readl(S3C2410_GSTATUS4));

if (machine_is_h1940()) {
void *base = phys_to_virt(H1940_SUSPEND_CHECK);
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/mach-s3c2412/mach-jive.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ static int jive_pm_suspend(struct sys_device *sd, pm_message_t state)
* correct address to resume from. */

__raw_writel(0x2BED, S3C2412_INFORM0);
__raw_writel(virt_to_phys(s3c2410_cpu_resume), S3C2412_INFORM1);
__raw_writel(virt_to_phys(s3c_cpu_resume), S3C2412_INFORM1);

return 0;
}
Expand Down Expand Up @@ -630,7 +630,7 @@ static void __init jive_machine_init(void)

/* initialise the power management now we've setup everything. */

s3c2410_pm_init();
s3c_pm_init();

s3c_device_nand.dev.platform_data = &jive_nand_info;

Expand Down
4 changes: 2 additions & 2 deletions arch/arm/mach-s3c2412/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static struct sleep_save s3c2412_sleep[] = {

static int s3c2412_pm_suspend(struct sys_device *dev, pm_message_t state)
{
s3c2410_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
s3c_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
return 0;
}

Expand All @@ -98,7 +98,7 @@ static int s3c2412_pm_resume(struct sys_device *dev)
tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE;
__raw_writel(tmp, S3C2412_PWRCFG);

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

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-s3c2440/mach-rx3715.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static void __init rx3715_init_machine(void)
#ifdef CONFIG_PM_H1940
memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 1024);
#endif
s3c2410_pm_init();
s3c_pm_init();

s3c24xx_fb_set_platdata(&rx3715_fb_info);
platform_add_devices(rx3715_devices, ARRAY_SIZE(rx3715_devices));
Expand Down
2 changes: 2 additions & 0 deletions arch/arm/mach-s3c24a0/include/mach/irqs.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
#define IRQ_EINT17 S3C2410_IRQ(49)
#define IRQ_EINT18 S3C2410_IRQ(50)

#define IRQ_EINT_BIT(x) ((x) - IRQ_EINT00)

/* SUB IRQS */
#define IRQ_S3CUART_RX0 S3C2410_IRQ(51) /* 67 */
#define IRQ_S3CUART_TX0 S3C2410_IRQ(52)
Expand Down
5 changes: 5 additions & 0 deletions arch/arm/plat-s3c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ obj-y += pwm-clock.o
obj-y += gpio.o
obj-y += gpio-config.o

# PM support

obj-$(CONFIG_PM) += pm.o
obj-$(CONFIG_S3C2410_PM_CHECK) += pm-check.o

# devices

obj-$(CONFIG_S3C_DEV_HSMMC) += dev-hsmmc.o
Expand Down
174 changes: 174 additions & 0 deletions arch/arm/plat-s3c/include/plat/pm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
/* linux/include/asm-arm/plat-s3c24xx/pm.h
*
* Copyright (c) 2004 Simtec Electronics
* http://armlinux.simtec.co.uk/
* Written by Ben Dooks, <ben@simtec.co.uk>
*
* 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.
*/

/* s3c_pm_init
*
* called from board at initialisation time to setup the power
* management
*/

#ifdef CONFIG_PM

extern __init int s3c_pm_init(void);

#else

static inline int s3c_pm_init(void)
{
return 0;
}
#endif

/* configuration for the IRQ mask over sleep */
extern unsigned long s3c_irqwake_intmask;
extern unsigned long s3c_irqwake_eintmask;

/* IRQ masks for IRQs allowed to go to sleep (see irq.c) */
extern unsigned long s3c_irqwake_intallow;
extern unsigned long s3c_irqwake_eintallow;

/* per-cpu sleep functions */

extern void (*pm_cpu_prep)(void);
extern void (*pm_cpu_sleep)(void);

/* Flags for PM Control */

extern unsigned long s3c_pm_flags;

/* from sleep.S */

extern int s3c_cpu_save(unsigned long *saveblk);
extern void s3c_cpu_resume(void);

extern void s3c2410_cpu_suspend(void);

extern unsigned long s3c_sleep_save_phys;

/* sleep save info */

/**
* struct sleep_save - save information for shared peripherals.
* @reg: Pointer to the register to save.
* @val: Holder for the value saved from reg.
*
* This describes a list of registers which is used by the pm core and
* other subsystem to save and restore register values over suspend.
*/
struct sleep_save {
void __iomem *reg;
unsigned long val;
};

#define SAVE_ITEM(x) \
{ .reg = (x) }

/**
* struct pm_uart_save - save block for core UART
* @ulcon: Save value for S3C2410_ULCON
* @ucon: Save value for S3C2410_UCON
* @ufcon: Save value for S3C2410_UFCON
* @umcon: Save value for S3C2410_UMCON
* @ubrdiv: Save value for S3C2410_UBRDIV
*
* Save block for UART registers to be held over sleep and restored if they
* are needed (say by debug).
*/
struct pm_uart_save {
u32 ulcon;
u32 ucon;
u32 ufcon;
u32 umcon;
u32 ubrdiv;
};

/* helper functions to save/restore lists of registers. */

extern void s3c_pm_do_save(struct sleep_save *ptr, int count);
extern void s3c_pm_do_restore(struct sleep_save *ptr, int count);
extern void s3c_pm_do_restore_core(struct sleep_save *ptr, int count);

#ifdef CONFIG_PM
extern int s3c_irqext_wake(unsigned int irqno, unsigned int state);
extern int s3c24xx_irq_suspend(struct sys_device *dev, pm_message_t state);
extern int s3c24xx_irq_resume(struct sys_device *dev);
#else
#define s3c_irqext_wake NULL
#define s3c24xx_irq_suspend NULL
#define s3c24xx_irq_resume NULL
#endif

/* PM debug functions */

#ifdef CONFIG_S3C2410_PM_DEBUG
/**
* s3c_pm_dbg() - low level debug function for use in suspend/resume.
* @msg: The message to print.
*
* This function is used mainly to debug the resume process before the system
* can rely on printk/console output. It uses the low-level debugging output
* routine printascii() to do its work.
*/
extern void s3c_pm_dbg(const char *msg, ...);

#define S3C_PMDBG(fmt...) s3c_pm_dbg(fmt)
#else
#define S3C_PMDBG(fmt...) printk(KERN_DEBUG fmt)
#endif

/* suspend memory checking */

#ifdef CONFIG_S3C2410_PM_CHECK
extern void s3c_pm_check_prepare(void);
extern void s3c_pm_check_restore(void);
extern void s3c_pm_check_cleanup(void);
extern void s3c_pm_check_store(void);
#else
#define s3c_pm_check_prepare() do { } while(0)
#define s3c_pm_check_restore() do { } while(0)
#define s3c_pm_check_cleanup() do { } while(0)
#define s3c_pm_check_store() do { } while(0)
#endif

/**
* s3c_pm_configure_extint() - ensure pins are correctly set for IRQ
*
* Setup all the necessary GPIO pins for waking the system on external
* interrupt.
*/
extern void s3c_pm_configure_extint(void);

/**
* s3c_pm_restore_gpios() - restore the state of the gpios after sleep.
*
* Restore the state of the GPIO pins after sleep, which may involve ensuring
* that we do not glitch the state of the pins from that the bootloader's
* resume code has done.
*/
extern void s3c_pm_restore_gpios(void);

/**
* s3c_pm_save_gpios() - save the state of the GPIOs for restoring after sleep.
*
* Save the GPIO states for resotration on resume. See s3c_pm_restore_gpios().
*/
extern void s3c_pm_save_gpios(void);

/**
* s3c_pm_cb_flushcache - callback for assembly code
*
* Callback to issue flush_cache_all() as this call is
* not a directly callable object.
*/
extern void s3c_pm_cb_flushcache(void);

extern void s3c_pm_save_core(void);
extern void s3c_pm_restore_core(void);
Loading

0 comments on commit f5f0e17

Please sign in to comment.