Commit d2b07fe2 authored by Ben Dooks's avatar Ben Dooks

[ARM] S3C: Update UART save over PM suspend/resume

Change the way the UART state is saved over suspend to allow the s3c64xx
code to modify the settings on resume to avoid any illegal state changes
to the UART clocks. This will also allow us to save the UDIVSLOT register
on newer SoCs.

Move to using a structure for the UART use the extant Kconfig configuration
specifying the number of UARTs.
Signed-off-by: default avatarBen Dooks <ben-linux@fluff.org>
parent ef30e144
...@@ -71,6 +71,25 @@ struct sleep_save { ...@@ -71,6 +71,25 @@ struct sleep_save {
#define SAVE_ITEM(x) \ #define SAVE_ITEM(x) \
{ .reg = (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. */ /* 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_save(struct sleep_save *ptr, int count);
......
...@@ -72,33 +72,50 @@ static inline void s3c_pm_debug_init(void) ...@@ -72,33 +72,50 @@ static inline void s3c_pm_debug_init(void)
#ifdef CONFIG_S3C2410_PM_DEBUG #ifdef CONFIG_S3C2410_PM_DEBUG
#define SAVE_UART(va) \ struct pm_uart_save uart_save[CONFIG_SERIAL_SAMSUNG_UARTS];
SAVE_ITEM((va) + S3C2410_ULCON), \
SAVE_ITEM((va) + S3C2410_UCON), \ static void s3c_pm_save_uart(unsigned int uart, struct pm_uart_save *save)
SAVE_ITEM((va) + S3C2410_UFCON), \ {
SAVE_ITEM((va) + S3C2410_UMCON), \ void __iomem *regs = S3C_VA_UARTx(uart);
SAVE_ITEM((va) + S3C2410_UBRDIV)
save->ulcon = __raw_readl(regs + S3C2410_ULCON);
static struct sleep_save uart_save[] = { save->ucon = __raw_readl(regs + S3C2410_UCON);
SAVE_UART(S3C_VA_UART0), save->ufcon = __raw_readl(regs + S3C2410_UFCON);
SAVE_UART(S3C_VA_UART1), save->umcon = __raw_readl(regs + S3C2410_UMCON);
#ifndef CONFIG_CPU_S3C2400 save->ubrdiv = __raw_readl(regs + S3C2410_UBRDIV);
SAVE_UART(S3C_VA_UART2), }
#endif
};
static void s3c_pm_save_uart(void) static void s3c_pm_save_uarts(void)
{ {
s3c_pm_do_save(uart_save, ARRAY_SIZE(uart_save)); struct pm_uart_save *save = uart_save;
unsigned int uart;
for (uart = 0; uart < CONFIG_SERIAL_SAMSUNG_UARTS; uart++, save++)
s3c_pm_save_uart(uart, save);
}
static void s3c_pm_restore_uart(unsigned int uart, struct pm_uart_save *save)
{
void __iomem *regs = S3C_VA_UARTx(uart);
__raw_writel(save->ulcon, regs + S3C2410_ULCON);
__raw_writel(save->ucon, regs + S3C2410_UCON);
__raw_writel(save->ufcon, regs + S3C2410_UFCON);
__raw_writel(save->umcon, regs + S3C2410_UMCON);
__raw_writel(save->ubrdiv, regs + S3C2410_UBRDIV);
} }
static void s3c_pm_restore_uart(void) static void s3c_pm_restore_uarts(void)
{ {
s3c_pm_do_restore(uart_save, ARRAY_SIZE(uart_save)); struct pm_uart_save *save = uart_save;
unsigned int uart;
for (uart = 0; uart < CONFIG_SERIAL_SAMSUNG_UARTS; uart++, save++)
s3c_pm_restore_uart(uart, save);
} }
#else #else
static void s3c_pm_save_uart(void) { } static void s3c_pm_save_uarts(void) { }
static void s3c_pm_restore_uart(void) { } static void s3c_pm_restore_uarts(void) { }
#endif #endif
/* The IRQ ext-int code goes here, it is too small to currently bother /* The IRQ ext-int code goes here, it is too small to currently bother
...@@ -250,7 +267,7 @@ static int s3c_pm_enter(suspend_state_t state) ...@@ -250,7 +267,7 @@ static int s3c_pm_enter(suspend_state_t state)
/* save all necessary core registers not covered by the drivers */ /* save all necessary core registers not covered by the drivers */
s3c_pm_save_gpios(); s3c_pm_save_gpios();
s3c_pm_save_uart(); s3c_pm_save_uarts();
s3c_pm_save_core(); s3c_pm_save_core();
/* set the irq configuration for wake */ /* set the irq configuration for wake */
...@@ -293,7 +310,7 @@ static int s3c_pm_enter(suspend_state_t state) ...@@ -293,7 +310,7 @@ static int s3c_pm_enter(suspend_state_t state)
/* restore the system state */ /* restore the system state */
s3c_pm_restore_core(); s3c_pm_restore_core();
s3c_pm_restore_uart(); s3c_pm_restore_uarts();
s3c_pm_restore_gpios(); s3c_pm_restore_gpios();
s3c_pm_debug_init(); s3c_pm_debug_init();
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#define S3C24XX_SZ_UART SZ_1M #define S3C24XX_SZ_UART SZ_1M
#define S3C_UART_OFFSET (0x4000) #define S3C_UART_OFFSET (0x4000)
#define S3C_VA_UARTx(uart) (S3C_VA_UART + ((uart * S3C_UART_OFFSET)))
/* Timers */ /* Timers */
#define S3C24XX_VA_TIMER S3C_VA_TIMER #define S3C24XX_VA_TIMER S3C_VA_TIMER
#define S3C2410_PA_TIMER (0x51000000) #define S3C2410_PA_TIMER (0x51000000)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment