blob: 3a44db4da6f360c12c56f0f7059e0e13479dd926 [file] [log] [blame]
Deepa Dinamani645e9b12012-12-21 14:23:40 -08001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
12 * * Neither the name of The Linux Foundation nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <debug.h>
30#include <reg.h>
31#include <platform/iomap.h>
32#include <qgic.h>
33#include <qtimer.h>
Deepa Dinamanid1260ed2013-03-06 14:24:01 -080034#include <platform/clock.h>
35#include <mmu.h>
36#include <arch/arm/mmu.h>
37#include <smem.h>
38#include <board.h>
39
40#define MB (1024*1024)
41
42#define MSM_IOMAP_SIZE ((MSM_IOMAP_END - MSM_IOMAP_BASE)/MB)
43
44/* LK memory - cacheable, write through */
45#define LK_MEMORY (MMU_MEMORY_TYPE_NORMAL_WRITE_THROUGH | \
46 MMU_MEMORY_AP_READ_WRITE)
47
48/* Peripherals - non-shared device */
49#define IOMAP_MEMORY (MMU_MEMORY_TYPE_DEVICE_SHARED | \
50 MMU_MEMORY_AP_READ_WRITE | MMU_MEMORY_XN)
51
52static mmu_section_t mmu_section_table[] = {
53/* Physical addr, Virtual addr, Size (in MB), Flags */
54 { MEMBASE, MEMBASE, (MEMSIZE / MB), LK_MEMORY},
55 { MSM_IOMAP_BASE, MSM_IOMAP_BASE, MSM_IOMAP_SIZE, IOMAP_MEMORY},
56};
57
58static struct smem_ram_ptable ram_ptable;
Deepa Dinamani645e9b12012-12-21 14:23:40 -080059
60void platform_early_init(void)
61{
aiqunyb7f1cb12013-03-02 11:40:05 -080062 board_init();
Deepa Dinamanieb182372013-02-04 15:53:58 -080063 platform_clock_init();
Deepa Dinamani645e9b12012-12-21 14:23:40 -080064 qgic_init();
65 qtimer_init();
66}
67
68void platform_init(void)
69{
70 dprintf(INFO, "platform_init()\n");
71}
72
73void platform_uninit(void)
74{
75 qtimer_uninit();
76}
Deepa Dinamanid1260ed2013-03-06 14:24:01 -080077
78/* Setup memory for this platform */
79void platform_init_mmu_mappings(void)
80{
81 uint32_t i;
82 uint32_t sections;
83 uint32_t table_size = ARRAY_SIZE(mmu_section_table);
84
85 ASSERT(smem_ram_ptable_init(&ram_ptable));
86
87 /* Configure the MMU page entries for SDRAM and IMEM memory read
88 from the smem ram table*/
89 for(i = 0; i < ram_ptable.len; i++)
90 {
91 if(ram_ptable.parts[i].type == SYS_MEMORY)
92 {
93 if((ram_ptable.parts[i].category == SDRAM) ||
94 (ram_ptable.parts[i].category == IMEM))
95 {
96 /* Check to ensure that start address is 1MB aligned */
97 ASSERT((ram_ptable.parts[i].start & 0xFFFFF) == 0);
98
99 sections = (ram_ptable.parts[i].size) / MB;
100 while(sections--)
101 {
102 arm_mmu_map_section(ram_ptable.parts[i].start +
103 sections * MB,
104 ram_ptable.parts[i].start +
105 sections * MB,
106 (MMU_MEMORY_TYPE_NORMAL_WRITE_THROUGH | \
107 MMU_MEMORY_AP_READ_WRITE | MMU_MEMORY_XN));
108 }
109 }
110 }
111 }
112
113 /* Configure the MMU page entries for memory read from the
114 mmu_section_table */
115 for (i = 0; i < table_size; i++)
116 {
117 sections = mmu_section_table[i].num_of_sections;
118
119 while (sections--)
120 {
121 arm_mmu_map_section(mmu_section_table[i].paddress +
122 sections * MB,
123 mmu_section_table[i].vaddress +
124 sections * MB,
125 mmu_section_table[i].flags);
126 }
127 }
128}