From: 黄涛 <huangtao@rock-chips.com>
Date: Fri, 10 Feb 2012 08:27:40 +0000 (+0800)
Subject: rk: move sram.c from mach-rk29 to plat-rk
X-Git-Tag: firefly_0821_release~9595^2~150
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=fc30b5923e3eae1d7aa793107b311452cf26a3e7;p=firefly-linux-kernel-4.4.55.git

rk: move sram.c from mach-rk29 to plat-rk
---

diff --git a/arch/arm/mach-rk29/Makefile b/arch/arm/mach-rk29/Makefile
index 7385fe3cd186..79f18f3c6968 100644
--- a/arch/arm/mach-rk29/Makefile
+++ b/arch/arm/mach-rk29/Makefile
@@ -1,4 +1,4 @@
-obj-y += timer.o io.o devices.o iomux.o clock.o rk29-pl330.o dma.o ddr.o sram.o memcpy_dma.o reset.o
+obj-y += timer.o io.o devices.o iomux.o clock.o rk29-pl330.o dma.o ddr.o memcpy_dma.o reset.o
 obj-y += tests.o memtester.o
 obj-y += early_printk.o
 ifndef CONFIG_DEBUG_LL
diff --git a/arch/arm/mach-rk29/include/mach/sram.h b/arch/arm/mach-rk29/include/mach/sram.h
index 27d403c62e43..8fcb97883798 100644
--- a/arch/arm/mach-rk29/include/mach/sram.h
+++ b/arch/arm/mach-rk29/include/mach/sram.h
@@ -1,40 +1 @@
-/*
- * Copyright (C) 2008-2009 ST-Ericsson AB
- * License terms: GNU General Public License (GPL) version 2
- * TCM memory handling for ARM systems
- *
- * Author: Linus Walleij <linus.walleij@stericsson.com>
- * Author: Rickard Andersson <rickard.andersson@stericsson.com>
- */
-
-#ifndef __ARCH_ARM_MACH_RK29_SRAM_H
-#define __ARCH_ARM_MACH_RK29_SRAM_H
-#ifdef CONFIG_ARCH_RK29
-
-/* Tag variables with this */
-#define __sramdata __section(.sram.data)
-/* Tag constants with this */
-#define __sramconst __section(.sram.rodata)
-/* Tag functions inside SRAM called from outside SRAM with this */
-#define __sramfunc __attribute__((long_call)) __section(.sram.text) noinline
-/* Tag function inside SRAM called from inside SRAM  with this */
-#define __sramlocalfunc __section(.sram.text)
-
-void __init rk29_sram_init(void);
-
-static inline unsigned long ddr_save_sp(unsigned long new_sp)
-{
-	unsigned long old_sp;
-
-	asm volatile ("mov %0, sp" : "=r" (old_sp));
-	asm volatile ("mov sp, %0" :: "r" (new_sp));
-	return old_sp;
-}
-
-// save_sp ±ØÐ붨ÒåΪȫ¾Ö±äÁ¿
-#define DDR_SAVE_SP(save_sp)		do { save_sp = ddr_save_sp((SRAM_DATA_END&(~7))); } while (0)
-#define DDR_RESTORE_SP(save_sp)		do { ddr_save_sp(save_sp); } while (0)
-
-#endif
-#endif
-
+#include <plat/sram.h>
diff --git a/arch/arm/mach-rk29/sram.c b/arch/arm/mach-rk29/sram.c
deleted file mode 100644
index c2785926e07b..000000000000
--- a/arch/arm/mach-rk29/sram.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * License terms: GNU General Public License (GPL) version 2
- */
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/stddef.h>
-#include <linux/ioport.h>
-#include <linux/genalloc.h>
-#include <linux/string.h> /* memcpy */
-#include <asm/page.h> /* PAGE_SHIFT */
-#include <asm/cputype.h>
-#include <asm/mach/map.h>
-#include <asm/tlbflush.h>
-#include <asm/cacheflush.h>
-#include <mach/memory.h>
-#include <mach/rk29_iomap.h>
-
-
-/* SRAM section definitions from the linker */
-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 = {
-	{
-		.virtual	= SRAM_CODE_OFFSET,
-		.pfn		= __phys_to_pfn(0x0),
-		.length		=  1024*1024,
-		.type		=  MT_MEMORY
-	}
-};
-
-int __init rk29_sram_init(void)
-{
-	char *start;
-	char *end;
-	char *ram;
-
-	iotable_init(sram_code_iomap, 1);
-
-	/*
-	 * Normally devicemaps_init() would flush caches and tlb after
-	 * mdesc->map_io(), but since we're called from map_io(), we
-	 * must do it here.
-	 */
-	local_flush_tlb_all();
-	flush_cache_all();
-
-        memset((char *)SRAM_CODE_OFFSET,0x0,(SRAM_CODE_END - SRAM_CODE_OFFSET + 1));
-	memset((char *)SRAM_DATA_OFFSET,0x0,(SRAM_DATA_END - SRAM_DATA_OFFSET + 1));
-
-	/* Copy code from RAM to SRAM CODE */
-	start = &__ssram_code_text;
-	end   = &__esram_code_text;
-	ram   = &__sram_code_start;
-	memcpy(start, ram, (end-start));
-	flush_icache_range((unsigned long) start, (unsigned long) end);
-
-	printk("CPU SRAM: copied sram code from %p to %p - %p\n", ram, start, end);
-
-	/* Copy data from RAM to SRAM DATA */
-	start = &__ssram_data;
-	end   = &__esram_data;
-	ram   = &__sram_data_start;
-	memcpy(start, ram, (end-start));
-
-	printk("CPU SRAM: copied sram data from %p to %p - %p\n", ram,start, end);
-
-	return 0;
-}
diff --git a/arch/arm/plat-rk/Makefile b/arch/arm/plat-rk/Makefile
index f78a8e5a60cb..675b57652170 100644
--- a/arch/arm/plat-rk/Makefile
+++ b/arch/arm/plat-rk/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_USB_GADGET) += usb_detect.o
 obj-$(CONFIG_RK29_VPU) += vpu_service.o
 obj-$(CONFIG_ARCH_RK30) += dma-pl330.o
 obj-y += mem_reserve.o
+obj-y += sram.o
diff --git a/arch/arm/plat-rk/include/plat/sram.h b/arch/arm/plat-rk/include/plat/sram.h
new file mode 100644
index 000000000000..27d403c62e43
--- /dev/null
+++ b/arch/arm/plat-rk/include/plat/sram.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2008-2009 ST-Ericsson AB
+ * License terms: GNU General Public License (GPL) version 2
+ * TCM memory handling for ARM systems
+ *
+ * Author: Linus Walleij <linus.walleij@stericsson.com>
+ * Author: Rickard Andersson <rickard.andersson@stericsson.com>
+ */
+
+#ifndef __ARCH_ARM_MACH_RK29_SRAM_H
+#define __ARCH_ARM_MACH_RK29_SRAM_H
+#ifdef CONFIG_ARCH_RK29
+
+/* Tag variables with this */
+#define __sramdata __section(.sram.data)
+/* Tag constants with this */
+#define __sramconst __section(.sram.rodata)
+/* Tag functions inside SRAM called from outside SRAM with this */
+#define __sramfunc __attribute__((long_call)) __section(.sram.text) noinline
+/* Tag function inside SRAM called from inside SRAM  with this */
+#define __sramlocalfunc __section(.sram.text)
+
+void __init rk29_sram_init(void);
+
+static inline unsigned long ddr_save_sp(unsigned long new_sp)
+{
+	unsigned long old_sp;
+
+	asm volatile ("mov %0, sp" : "=r" (old_sp));
+	asm volatile ("mov sp, %0" :: "r" (new_sp));
+	return old_sp;
+}
+
+// save_sp ±ØÐ붨ÒåΪȫ¾Ö±äÁ¿
+#define DDR_SAVE_SP(save_sp)		do { save_sp = ddr_save_sp((SRAM_DATA_END&(~7))); } while (0)
+#define DDR_RESTORE_SP(save_sp)		do { ddr_save_sp(save_sp); } while (0)
+
+#endif
+#endif
+
diff --git a/arch/arm/plat-rk/sram.c b/arch/arm/plat-rk/sram.c
new file mode 100644
index 000000000000..c2785926e07b
--- /dev/null
+++ b/arch/arm/plat-rk/sram.c
@@ -0,0 +1,70 @@
+/*
+ * License terms: GNU General Public License (GPL) version 2
+ */
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/stddef.h>
+#include <linux/ioport.h>
+#include <linux/genalloc.h>
+#include <linux/string.h> /* memcpy */
+#include <asm/page.h> /* PAGE_SHIFT */
+#include <asm/cputype.h>
+#include <asm/mach/map.h>
+#include <asm/tlbflush.h>
+#include <asm/cacheflush.h>
+#include <mach/memory.h>
+#include <mach/rk29_iomap.h>
+
+
+/* SRAM section definitions from the linker */
+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 = {
+	{
+		.virtual	= SRAM_CODE_OFFSET,
+		.pfn		= __phys_to_pfn(0x0),
+		.length		=  1024*1024,
+		.type		=  MT_MEMORY
+	}
+};
+
+int __init rk29_sram_init(void)
+{
+	char *start;
+	char *end;
+	char *ram;
+
+	iotable_init(sram_code_iomap, 1);
+
+	/*
+	 * Normally devicemaps_init() would flush caches and tlb after
+	 * mdesc->map_io(), but since we're called from map_io(), we
+	 * must do it here.
+	 */
+	local_flush_tlb_all();
+	flush_cache_all();
+
+        memset((char *)SRAM_CODE_OFFSET,0x0,(SRAM_CODE_END - SRAM_CODE_OFFSET + 1));
+	memset((char *)SRAM_DATA_OFFSET,0x0,(SRAM_DATA_END - SRAM_DATA_OFFSET + 1));
+
+	/* Copy code from RAM to SRAM CODE */
+	start = &__ssram_code_text;
+	end   = &__esram_code_text;
+	ram   = &__sram_code_start;
+	memcpy(start, ram, (end-start));
+	flush_icache_range((unsigned long) start, (unsigned long) end);
+
+	printk("CPU SRAM: copied sram code from %p to %p - %p\n", ram, start, end);
+
+	/* Copy data from RAM to SRAM DATA */
+	start = &__ssram_data;
+	end   = &__esram_data;
+	ram   = &__sram_data_start;
+	memcpy(start, ram, (end-start));
+
+	printk("CPU SRAM: copied sram data from %p to %p - %p\n", ram,start, end);
+
+	return 0;
+}