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