xref: /linux/arch/arm/mach-omap1/sram-init.c (revision f205cfaf6c1287aca040c51c1789b46ed63a4d78)
1*f205cfafSTony Lindgren /*
2*f205cfafSTony Lindgren  * OMAP SRAM detection and management
3*f205cfafSTony Lindgren  *
4*f205cfafSTony Lindgren  * Copyright (C) 2005 Nokia Corporation
5*f205cfafSTony Lindgren  * Written by Tony Lindgren <tony@atomide.com>
6*f205cfafSTony Lindgren  *
7*f205cfafSTony Lindgren  * This program is free software; you can redistribute it and/or modify
8*f205cfafSTony Lindgren  * it under the terms of the GNU General Public License version 2 as
9*f205cfafSTony Lindgren  * published by the Free Software Foundation.
10*f205cfafSTony Lindgren  */
11*f205cfafSTony Lindgren 
12*f205cfafSTony Lindgren #include <linux/module.h>
13*f205cfafSTony Lindgren #include <linux/kernel.h>
14*f205cfafSTony Lindgren #include <linux/init.h>
15*f205cfafSTony Lindgren #include <linux/io.h>
16*f205cfafSTony Lindgren 
17*f205cfafSTony Lindgren #include <asm/fncpy.h>
18*f205cfafSTony Lindgren #include <asm/tlb.h>
19*f205cfafSTony Lindgren #include <asm/cacheflush.h>
20*f205cfafSTony Lindgren 
21*f205cfafSTony Lindgren #include <asm/mach/map.h>
22*f205cfafSTony Lindgren 
23*f205cfafSTony Lindgren #include "soc.h"
24*f205cfafSTony Lindgren #include "sram.h"
25*f205cfafSTony Lindgren 
26*f205cfafSTony Lindgren #define OMAP1_SRAM_PA		0x20000000
27*f205cfafSTony Lindgren #define SRAM_BOOTLOADER_SZ	0x80
28*f205cfafSTony Lindgren 
29*f205cfafSTony Lindgren /*
30*f205cfafSTony Lindgren  * The amount of SRAM depends on the core type.
31*f205cfafSTony Lindgren  * Note that we cannot try to test for SRAM here because writes
32*f205cfafSTony Lindgren  * to secure SRAM will hang the system. Also the SRAM is not
33*f205cfafSTony Lindgren  * yet mapped at this point.
34*f205cfafSTony Lindgren  */
35*f205cfafSTony Lindgren static void __init omap_detect_and_map_sram(void)
36*f205cfafSTony Lindgren {
37*f205cfafSTony Lindgren 	unsigned long omap_sram_skip = SRAM_BOOTLOADER_SZ;
38*f205cfafSTony Lindgren 	unsigned long omap_sram_start = OMAP1_SRAM_PA;
39*f205cfafSTony Lindgren 	unsigned long omap_sram_size;
40*f205cfafSTony Lindgren 
41*f205cfafSTony Lindgren 	if (cpu_is_omap7xx())
42*f205cfafSTony Lindgren 		omap_sram_size = 0x32000;	/* 200K */
43*f205cfafSTony Lindgren 	else if (cpu_is_omap15xx())
44*f205cfafSTony Lindgren 		omap_sram_size = 0x30000;	/* 192K */
45*f205cfafSTony Lindgren 	else if (cpu_is_omap1610() || cpu_is_omap1611() ||
46*f205cfafSTony Lindgren 			cpu_is_omap1621() || cpu_is_omap1710())
47*f205cfafSTony Lindgren 		omap_sram_size = 0x4000;	/* 16K */
48*f205cfafSTony Lindgren 	else {
49*f205cfafSTony Lindgren 		pr_err("Could not detect SRAM size\n");
50*f205cfafSTony Lindgren 		omap_sram_size = 0x4000;
51*f205cfafSTony Lindgren 	}
52*f205cfafSTony Lindgren 
53*f205cfafSTony Lindgren 	omap_map_sram(omap_sram_start, omap_sram_size,
54*f205cfafSTony Lindgren 		omap_sram_skip, 1);
55*f205cfafSTony Lindgren }
56*f205cfafSTony Lindgren 
57*f205cfafSTony Lindgren static void (*_omap_sram_reprogram_clock)(u32 dpllctl, u32 ckctl);
58*f205cfafSTony Lindgren 
59*f205cfafSTony Lindgren void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl)
60*f205cfafSTony Lindgren {
61*f205cfafSTony Lindgren 	BUG_ON(!_omap_sram_reprogram_clock);
62*f205cfafSTony Lindgren 	/* On 730, bit 13 must always be 1 */
63*f205cfafSTony Lindgren 	if (cpu_is_omap7xx())
64*f205cfafSTony Lindgren 		ckctl |= 0x2000;
65*f205cfafSTony Lindgren 	_omap_sram_reprogram_clock(dpllctl, ckctl);
66*f205cfafSTony Lindgren }
67*f205cfafSTony Lindgren 
68*f205cfafSTony Lindgren int __init omap_sram_init(void)
69*f205cfafSTony Lindgren {
70*f205cfafSTony Lindgren 	omap_detect_and_map_sram();
71*f205cfafSTony Lindgren 	_omap_sram_reprogram_clock =
72*f205cfafSTony Lindgren 			omap_sram_push(omap1_sram_reprogram_clock,
73*f205cfafSTony Lindgren 					omap1_sram_reprogram_clock_sz);
74*f205cfafSTony Lindgren 
75*f205cfafSTony Lindgren 	return 0;
76*f205cfafSTony Lindgren }
77