CHROMIUM: serial: samsung: Drain UARTs with SAMSUNG_PM_DEBUG
authorMichael Spang <spang@chromium.org>
Fri, 9 Nov 2012 04:16:04 +0000 (23:16 -0500)
committerGerrit <chrome-bot@google.com>
Wed, 5 Dec 2012 20:35:41 +0000 (12:35 -0800)
We're losing the last characters output to the console in suspend. To
avoid this, wait for the transmitter to empty as late as possible.

BUG=chrome-os-partner:10932
TEST=powerd_suspend with no_console_suspend and SAMSUNG_PM_DEBUG

Change-Id: I7f6fbffd0f30458853f0ae67f496d3915ad0d0dc
Signed-off-by: Michael Spang <spang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/37735
Reviewed-by: Olof Johansson <olofj@chromium.org>
arch/arm/plat-samsung/pm.c

index 0bc15db..a4336a5 100644 (file)
@@ -126,9 +126,30 @@ static void s3c_pm_restore_uarts(void)
        for (uart = 0; uart < CONFIG_SERIAL_SAMSUNG_UARTS; uart++, save++)
                s3c_pm_restore_uart(uart, save);
 }
+
+static void s3c_pm_drain_uart(int uart)
+{
+       void __iomem *regs = S3C_VA_UARTx(uart);
+       unsigned long ufstat;
+
+       do {
+               ufstat = __raw_readl(regs + S3C2410_UTRSTAT);
+       } while (!(ufstat & S3C2410_UTRSTAT_TXE));
+}
+
+static void s3c_pm_drain_uarts(void)
+{
+       unsigned int uart;
+       for (uart = 0; uart < CONFIG_SERIAL_SAMSUNG_UARTS; uart++)
+               s3c_pm_drain_uart(uart);
+
+       mdelay(1);
+}
+
 #else
 static void s3c_pm_save_uarts(void) { }
 static void s3c_pm_restore_uarts(void) { }
+static void s3c_pm_drain_uarts(void) { }
 #endif
 
 /* The IRQ ext-int code goes here, it is too small to currently bother
@@ -293,6 +314,8 @@ static int s3c_pm_enter(suspend_state_t state)
 
        s3c_pm_check_store();
 
+       s3c_pm_drain_uarts();
+
        /* send the cpu to sleep... */
 
        s3c_pm_arch_stop_clocks();