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