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