blob: 12b103955cb4d2a666ec12c45dcb4e8f84958b59 [file] [log] [blame]
Jeevan Shriram8d5e5ee2015-01-07 11:35:55 -08001/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
Channagoud Kadabi123c9722014-02-06 13:22:50 -08002 *
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>
34#include <platform/clock.h>
35#include <mmu.h>
36#include <arch/arm/mmu.h>
37#include <smem.h>
38#include <board.h>
39
Channagoud Kadabi123c9722014-02-06 13:22:50 -080040#define MSM_IOMAP_SIZE ((MSM_IOMAP_END - MSM_IOMAP_BASE)/MB)
41
Channagoud Kadabi92d50182014-06-18 12:13:15 -070042#define HLOS_MEMORY_START 0x0
43#define HLOS_MEMORY_SIZE 0x63
44
Channagoud Kadabi123c9722014-02-06 13:22:50 -080045/* LK memory - cacheable, write through */
Channagoud Kadabib1aafbb2015-02-13 20:08:51 -080046#define LK_MEMORY (MMU_MEMORY_TYPE_NORMAL_WRITE_BACK_ALLOCATE | \
Channagoud Kadabi123c9722014-02-06 13:22:50 -080047 MMU_MEMORY_AP_READ_WRITE)
48
49/* Peripherals - non-shared device */
50#define IOMAP_MEMORY (MMU_MEMORY_TYPE_DEVICE_SHARED | \
51 MMU_MEMORY_AP_READ_WRITE | MMU_MEMORY_XN)
52
53/* IMEM memory - cacheable, write through */
Channagoud Kadabi92d50182014-06-18 12:13:15 -070054#define COMMON_MEMORY (MMU_MEMORY_TYPE_NORMAL_WRITE_THROUGH | \
Channagoud Kadabi123c9722014-02-06 13:22:50 -080055 MMU_MEMORY_AP_READ_WRITE | MMU_MEMORY_XN)
56
57static mmu_section_t mmu_section_table[] = {
Channagoud Kadabi92d50182014-06-18 12:13:15 -070058/* Physical addr, Virtual addr, Size (in MB), Flags */
59 { MEMBASE, MEMBASE, (MEMSIZE / MB), LK_MEMORY},
60 { MSM_IOMAP_BASE, MSM_IOMAP_BASE, MSM_IOMAP_SIZE, IOMAP_MEMORY},
61 { SYSTEM_IMEM_BASE, SYSTEM_IMEM_BASE, 1, COMMON_MEMORY},
62 { MSM_SHARED_BASE, MSM_SHARED_BASE, 2, COMMON_MEMORY},
63 { HLOS_MEMORY_START, HLOS_MEMORY_START, HLOS_MEMORY_SIZE, COMMON_MEMORY},
64 { SCRATCH_ADDR, SCRATCH_ADDR, (SCRATCH_SIZE / MB), COMMON_MEMORY},
Channagoud Kadabi123c9722014-02-06 13:22:50 -080065};
66
67void platform_early_init(void)
68{
69 board_init();
70 platform_clock_init();
71 qgic_init();
72 qtimer_init();
Channagoud Kadabic7eb5692014-08-19 15:45:00 -070073 scm_init();
Channagoud Kadabi123c9722014-02-06 13:22:50 -080074}
75
76void platform_init(void)
77{
78 dprintf(INFO, "platform_init()\n");
Channagoud Kadabidc627c02014-06-26 14:45:34 -070079#if ENABLE_XPU_VIOLATION
80 scm_xpu_err_fatal_init();
81#endif
Channagoud Kadabi123c9722014-02-06 13:22:50 -080082}
83
84void platform_uninit(void)
85{
86#if DISPLAY_SPLASH_SCREEN
87 display_shutdown();
88#endif
89
90 qtimer_uninit();
91}
92
93int platform_use_identity_mmu_mappings(void)
94{
95 /* Use only the mappings specified in this file. */
96 return 0;
97}
98
99/* Setup memory for this platform */
100void platform_init_mmu_mappings(void)
101{
102 uint32_t i;
103 uint32_t sections;
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800104 uint32_t table_size = ARRAY_SIZE(mmu_section_table);
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800105
106 /* Configure the MMU page entries for memory read from the
107 mmu_section_table */
108 for (i = 0; i < table_size; i++)
109 {
110 sections = mmu_section_table[i].num_of_sections;
111
112 while (sections--)
113 {
114 arm_mmu_map_section(mmu_section_table[i].paddress +
115 sections * MB,
116 mmu_section_table[i].vaddress +
117 sections * MB,
118 mmu_section_table[i].flags);
119 }
120 }
121}
122
123addr_t platform_get_virt_to_phys_mapping(addr_t virt_addr)
124{
125 /* Using 1-1 mapping on this platform. */
126 return virt_addr;
127}
128
129addr_t platform_get_phys_to_virt_mapping(addr_t phys_addr)
130{
131 /* Using 1-1 mapping on this platform. */
132 return phys_addr;
133}
134
135uint32_t platform_get_sclk_count(void)
136{
137 return readl(MPM2_MPM_SLEEP_TIMETICK_COUNT_VAL);
138}
139
Sridhar Parasuram39419a32014-09-12 18:11:05 -0700140int platform_is_msm8994()
141{
142 uint32_t platform = board_platform_id();
143 if ((platform == APQ8094) || (platform == MSM8994))
144 return 1;
145 else
146 return 0;
147}
148
Jeevan Shriram8d5e5ee2015-01-07 11:35:55 -0800149int platform_is_msm8992()
150{
151 int ret;
152
153 uint32_t platform = board_platform_id();
154 switch (platform) {
155 case MSM8992:
156 case APQ8092:
157 ret = 1;
158 break;
159 default:
160 ret = 0;
161 }
162
163 return ret;
164}
165
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800166addr_t get_bs_info_addr()
167{
Sridhar Parasuram39419a32014-09-12 18:11:05 -0700168 if (platform_is_msm8994())
169 return ((addr_t)BS_INFO_ADDR);
170 else
171 return ((addr_t)BS_INFO_ADDR2);
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800172}