blob: c1533edf452ac0987b892c9b748bfefb15cfa3ef [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
Sridhar Parasuram113229a2015-06-01 09:31:58 -070045/* LK memory - cacheable, write back */
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
Sridhar Parasuram113229a2015-06-01 09:31:58 -070057/* Scratch memory - cacheable, write back */
58#define SCRATCH_MEMORY (MMU_MEMORY_TYPE_NORMAL_WRITE_BACK_ALLOCATE | \
59 MMU_MEMORY_AP_READ_WRITE | MMU_MEMORY_XN)
60
61
Channagoud Kadabi123c9722014-02-06 13:22:50 -080062static mmu_section_t mmu_section_table[] = {
Channagoud Kadabi92d50182014-06-18 12:13:15 -070063/* Physical addr, Virtual addr, Size (in MB), Flags */
64 { MEMBASE, MEMBASE, (MEMSIZE / MB), LK_MEMORY},
65 { MSM_IOMAP_BASE, MSM_IOMAP_BASE, MSM_IOMAP_SIZE, IOMAP_MEMORY},
66 { SYSTEM_IMEM_BASE, SYSTEM_IMEM_BASE, 1, COMMON_MEMORY},
67 { MSM_SHARED_BASE, MSM_SHARED_BASE, 2, COMMON_MEMORY},
68 { HLOS_MEMORY_START, HLOS_MEMORY_START, HLOS_MEMORY_SIZE, COMMON_MEMORY},
Sridhar Parasuram113229a2015-06-01 09:31:58 -070069 { SCRATCH_ADDR, SCRATCH_ADDR, (SCRATCH_SIZE / MB), SCRATCH_MEMORY},
Sridhar Parasuram8d925a02015-05-21 21:28:32 -070070 { RPMB_SND_RCV_BUF, RPMB_SND_RCV_BUF, RPMB_SND_RCV_BUF_SZ, IOMAP_MEMORY},
Channagoud Kadabi123c9722014-02-06 13:22:50 -080071};
72
73void platform_early_init(void)
74{
75 board_init();
76 platform_clock_init();
77 qgic_init();
78 qtimer_init();
Channagoud Kadabic7eb5692014-08-19 15:45:00 -070079 scm_init();
Channagoud Kadabi123c9722014-02-06 13:22:50 -080080}
81
82void platform_init(void)
83{
84 dprintf(INFO, "platform_init()\n");
Channagoud Kadabidc627c02014-06-26 14:45:34 -070085#if ENABLE_XPU_VIOLATION
86 scm_xpu_err_fatal_init();
87#endif
Channagoud Kadabi123c9722014-02-06 13:22:50 -080088}
89
90void platform_uninit(void)
91{
92#if DISPLAY_SPLASH_SCREEN
93 display_shutdown();
94#endif
95
96 qtimer_uninit();
97}
98
99int platform_use_identity_mmu_mappings(void)
100{
101 /* Use only the mappings specified in this file. */
102 return 0;
103}
104
105/* Setup memory for this platform */
106void platform_init_mmu_mappings(void)
107{
108 uint32_t i;
109 uint32_t sections;
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800110 uint32_t table_size = ARRAY_SIZE(mmu_section_table);
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800111
112 /* Configure the MMU page entries for memory read from the
113 mmu_section_table */
114 for (i = 0; i < table_size; i++)
115 {
116 sections = mmu_section_table[i].num_of_sections;
117
118 while (sections--)
119 {
120 arm_mmu_map_section(mmu_section_table[i].paddress +
121 sections * MB,
122 mmu_section_table[i].vaddress +
123 sections * MB,
124 mmu_section_table[i].flags);
125 }
126 }
127}
128
129addr_t platform_get_virt_to_phys_mapping(addr_t virt_addr)
130{
131 /* Using 1-1 mapping on this platform. */
132 return virt_addr;
133}
134
135addr_t platform_get_phys_to_virt_mapping(addr_t phys_addr)
136{
137 /* Using 1-1 mapping on this platform. */
138 return phys_addr;
139}
140
141uint32_t platform_get_sclk_count(void)
142{
143 return readl(MPM2_MPM_SLEEP_TIMETICK_COUNT_VAL);
144}
145
Sridhar Parasuram39419a32014-09-12 18:11:05 -0700146int platform_is_msm8994()
147{
148 uint32_t platform = board_platform_id();
149 if ((platform == APQ8094) || (platform == MSM8994))
150 return 1;
151 else
152 return 0;
153}
154
Jeevan Shriram8d5e5ee2015-01-07 11:35:55 -0800155int platform_is_msm8992()
156{
157 int ret;
158
159 uint32_t platform = board_platform_id();
160 switch (platform) {
161 case MSM8992:
162 case APQ8092:
163 ret = 1;
164 break;
165 default:
166 ret = 0;
167 }
168
169 return ret;
170}
171
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800172addr_t get_bs_info_addr()
173{
Sridhar Parasuram39419a32014-09-12 18:11:05 -0700174 if (platform_is_msm8994())
175 return ((addr_t)BS_INFO_ADDR);
176 else
177 return ((addr_t)BS_INFO_ADDR2);
Channagoud Kadabi123c9722014-02-06 13:22:50 -0800178}