From: 黄涛 Date: Fri, 21 Dec 2012 11:34:30 +0000 (+0800) Subject: rk30: pm: support sram_log X-Git-Tag: firefly_0821_release~8078 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=433a41b1958c8ac26ed7a588b1234ac24e22429c;p=firefly-linux-kernel-4.4.55.git rk30: pm: support sram_log --- diff --git a/arch/arm/mach-rk2928/io.c b/arch/arm/mach-rk2928/io.c index 3ce4bb9b71ce..8b8eaf77fbbb 100755 --- a/arch/arm/mach-rk2928/io.c +++ b/arch/arm/mach-rk2928/io.c @@ -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) diff --git a/arch/arm/mach-rk30/include/mach/memory.h b/arch/arm/mach-rk30/include/mach/memory.h index 1a967f82de3a..5b9acf6aff6d 100644 --- a/arch/arm/mach-rk30/include/mach/memory.h +++ b/arch/arm/mach-rk30/include/mach/memory.h @@ -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 diff --git a/arch/arm/mach-rk30/io.c b/arch/arm/mach-rk30/io.c index e741bc132e50..e47402d80d67 100755 --- a/arch/arm/mach-rk30/io.c +++ b/arch/arm/mach-rk30/io.c @@ -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) diff --git a/arch/arm/mach-rk30/pm.c b/arch/arm/mach-rk30/pm.c index c5268a756223..a73e57a2f864 100755 --- a/arch/arm/mach-rk30/pm.c +++ b/arch/arm/mach-rk30/pm.c @@ -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); diff --git a/arch/arm/plat-rk/include/plat/sram.h b/arch/arm/plat-rk/include/plat/sram.h index 034508a3661f..51c520cb2076 100755 --- a/arch/arm/plat-rk/include/plat/sram.h +++ b/arch/arm/plat-rk/include/plat/sram.h @@ -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 diff --git a/arch/arm/plat-rk/sram.c b/arch/arm/plat-rk/sram.c index 863cfad94d67..c2adeb671300 100755 --- a/arch/arm/plat-rk/sram.c +++ b/arch/arm/plat-rk/sram.c @@ -21,22 +21,87 @@ 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 +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();