rk30: pm: support sram_log
author黄涛 <huangtao@rock-chips.com>
Fri, 21 Dec 2012 11:34:30 +0000 (19:34 +0800)
committer黄涛 <huangtao@rock-chips.com>
Fri, 21 Dec 2012 11:34:52 +0000 (19:34 +0800)
arch/arm/mach-rk2928/io.c
arch/arm/mach-rk30/include/mach/memory.h
arch/arm/mach-rk30/io.c
arch/arm/mach-rk30/pm.c
arch/arm/plat-rk/include/plat/sram.h
arch/arm/plat-rk/sram.c

index 3ce4bb9b71ce7eed6e1255bcf09bea8342b2e7fe..8b8eaf77fbbbe0a199a28d050243f5cd85903a09 100755 (executable)
@@ -50,12 +50,6 @@ static struct map_desc rk2928_io_desc[] __initdata = {
        RK2928_DEVICE(DDR_PHY),
        RK2928_DEVICE(RKI2C0),
        RK2928_DEVICE(RKI2C1),
-       {
-               .virtual = (unsigned long) RK2928_IMEM_NONCACHED,
-               .pfn = __phys_to_pfn(RK2928_IMEM_PHYS),
-               .length = RK2928_IMEM_SIZE,
-               .type = MT_MEMORY_NONCACHED,
-       },
 };
 
 void __init rk2928_map_common_io(void)
index 1a967f82de3a5e6747cf304a378cce25fa2a6613..5b9acf6aff6d7cb3dd2f752a6d41cecd3dcf328a 100644 (file)
@@ -10,6 +10,6 @@
 #define SRAM_CODE_OFFSET       (RK30_IMEM_BASE + 0x0010)
 #define SRAM_CODE_END          (RK30_IMEM_BASE + 0x2FFF)
 #define SRAM_DATA_OFFSET       (RK30_IMEM_BASE + 0x3000)
-#define SRAM_DATA_END          (RK30_IMEM_BASE + 0x3FFF)
+#define SRAM_DATA_END          (RK30_IMEM_BASE + 0x3FFF - 64)
 
 #endif
index e741bc132e5034aa41e621263ea8d9931920c035..e47402d80d67d77e9fb640391d273caca9813e82 100755 (executable)
@@ -59,15 +59,6 @@ static struct map_desc rk30_io_desc[] __initdata = {
        RK30_DEVICE(DDR_PCTL),
        RK30_DEVICE(DDR_PUBL),
        RK30_DEVICE(I2C1),
-
-#ifdef CONFIG_RK_SRAM_DMA
-       {
-               .virtual = (unsigned long) RK30_IMEM_NONCACHED,
-               .pfn = __phys_to_pfn(RK30_IMEM_PHYS),
-               .length = RK30_IMEM_SIZE,
-               .type = MT_MEMORY_NONCACHED,
-       },
-#endif
 };
 
 void __init rk30_map_common_io(void)
index c5268a7562239745a8724dcfdaaf909487d81d1a..a73e57a2f864f27d35095fc359ea93359148f29b 100755 (executable)
@@ -72,6 +72,7 @@ void __sramfunc sram_printch(char byte)
        cru_writel(0xffff0000 | clk_gate8, CRU_CLKGATES_CON(8));
 #endif
 
+       sram_log_char(byte);
        if (pm_log)
                pm_emit_log_char(byte);
 
@@ -563,6 +564,7 @@ static int rk30_pm_enter(suspend_state_t state)
 
        printk(KERN_DEBUG "pm: ");
        pm_log = true;
+       sram_log_reset();
        sram_printch('0');
 
        pmu_pwrdn_st = pmu_readl(PMU_PWRDN_ST);
index 034508a3661f1611e40d3c0d3441a40a77af5758..51c520cb207642451eaf38b80d22cdcae888e776 100755 (executable)
@@ -44,6 +44,8 @@ static inline unsigned long ddr_save_sp(unsigned long new_sp)
 extern void __sramfunc sram_printch(char byte);
 extern void __sramfunc sram_printascii(const char *s);
 extern void __sramfunc sram_printhex(unsigned int hex);
+extern void __sramfunc sram_log_char(char c);
+extern void __sramfunc sram_log_reset(void);
 
 #endif /* CONFIG_PLAT_RK */
 #endif
index 863cfad94d67d9cb78a02a6e9b8a61b9cabde36c..c2adeb67130093135591a4fbaca16c6d9833ad43 100755 (executable)
 extern char __sram_code_start, __ssram_code_text, __esram_code_text;
 extern char __sram_data_start, __ssram_data, __esram_data;
 
-static struct map_desc sram_code_iomap[] __initdata = {
+#if defined(CONFIG_ARCH_RK30)
+#define SRAM_NONCACHED RK30_IMEM_NONCACHED
+#define SRAM_CACHED    RK30_IMEM_BASE
+#define SRAM_PHYS      RK30_IMEM_PHYS
+#define SRAM_SIZE      RK30_IMEM_SIZE
+#elif defined(CONFIG_ARCH_RK2928)
+#define SRAM_NONCACHED RK2928_IMEM_NONCACHED
+#define SRAM_CACHED    RK2928_IMEM_BASE
+#define SRAM_PHYS      RK2928_IMEM_PHYS
+#define SRAM_SIZE      RK2928_IMEM_SIZE
+#endif
+
+static struct map_desc sram_io_desc[] __initdata = {
        {
-               .virtual        = (unsigned long)SRAM_CODE_OFFSET & PAGE_MASK,
+               .virtual        = (unsigned long) SRAM_CACHED,
                .pfn            = __phys_to_pfn(0x0),
-               .length         =  1024*1024,
-               .type           =  MT_MEMORY
-       }
+               .length         = SZ_1M,
+               .type           = MT_MEMORY,
+       },
+       {
+               .virtual        = (unsigned long) SRAM_NONCACHED,
+               .pfn            = __phys_to_pfn(SRAM_PHYS),
+               .length         = SRAM_SIZE,
+               .type           = MT_MEMORY_NONCACHED,
+       },
 };
 
+#define SRAM_LOG_BUF_LEN 64
+static char __sramdata *sram_log_buf;
+static unsigned char __sramdata sram_log_end;
+#define SRAM_LOG_BUF_MASK (SRAM_LOG_BUF_LEN-1)
+#define SRAM_LOG_BUF(idx) (sram_log_buf[(idx) & SRAM_LOG_BUF_MASK])
+
+void __sramfunc sram_log_char(char c)
+{
+       if (!sram_log_buf)
+               return;
+       SRAM_LOG_BUF(sram_log_end) = c;
+       sram_log_end++;
+}
+
+void __sramfunc sram_log_reset(void)
+{
+       int i;
+       if (!sram_log_buf)
+               return;
+       for (i = 0; i < SRAM_LOG_BUF_LEN; i++)
+               sram_log_buf[i] = 0;
+       sram_log_end = 0;
+}
+
+#include <linux/ctype.h>
+void __init sram_log_dump(void)
+{
+       int i;
+
+       if ((u32)SRAM_DATA_END & SRAM_LOG_BUF_LEN)
+               sram_log_buf = NULL;
+       else
+               sram_log_buf = SRAM_NONCACHED + (SRAM_DATA_END - SRAM_CACHED) + 1;
+       if (!sram_log_buf)
+               return;
+
+       printk("sram_log: ");
+       for (i = 0; i < SRAM_LOG_BUF_LEN; i++) {
+               char c = sram_log_buf[i];
+               if (isascii(c) && isprint(c))
+                       printk(KERN_CONT "%c", c);
+               else
+                       printk(KERN_CONT " ");
+       }
+       printk(KERN_CONT "\n");
+}
+
 int __init rk29_sram_init(void)
 {
        char *start;
        char *end;
        char *ram;
 
-       iotable_init(sram_code_iomap, 1);
+       iotable_init(sram_io_desc, ARRAY_SIZE(sram_io_desc));
 
        /*
         * Normally devicemaps_init() would flush caches and tlb after
@@ -64,13 +129,16 @@ int __init rk29_sram_init(void)
        ram   = &__sram_data_start;
        memcpy(start, ram, (end-start));
 
-       printk("CPU SRAM: copied sram data from %p to %p - %p\n", ram,start, end);
+       printk("CPU SRAM: copied sram data from %p to %p - %p\n", ram, start, end);
+
+       sram_log_dump();
 
        return 0;
 }
 
 __weak void __sramfunc sram_printch(char byte)
 {
+       sram_log_char(byte);
 #ifdef DEBUG_UART_BASE
        writel_relaxed(byte, DEBUG_UART_BASE);
        dsb();