blob: d0ab86d6a2f866e9fd236f05fe9661e45372477d [file] [log] [blame]
Sridhar Parasurambe12c3d2015-01-16 13:42:26 -08001/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
Channagoud Kadabied60a8b2014-06-27 15:35:09 -07002 *
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 *
Channagoud Kadabi0ffa7862015-03-19 11:58:28 -070016 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Channagoud Kadabied60a8b2014-06-27 15:35:09 -070027 */
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
40#define MSM_IOMAP_SIZE ((MSM_IOMAP_END - MSM_IOMAP_BASE)/MB)
41#define MSM_SHARED_SIZE 2
42
43/* LK memory - cacheable, write through */
44#define LK_MEMORY (MMU_MEMORY_TYPE_NORMAL_WRITE_THROUGH | \
45 MMU_MEMORY_AP_READ_WRITE)
46
47/* Peripherals - non-shared device */
48#define IOMAP_MEMORY (MMU_MEMORY_TYPE_DEVICE_SHARED | \
49 MMU_MEMORY_AP_READ_WRITE | MMU_MEMORY_XN)
50
51/* SCRATCH memory - cacheable, write through */
52#define SCRATCH_MEMORY (MMU_MEMORY_TYPE_NORMAL_WRITE_THROUGH | \
53 MMU_MEMORY_AP_READ_WRITE | MMU_MEMORY_XN)
54
55static mmu_section_t mmu_section_table[] = {
56/* Physical addr, Virtual addr, Size (in MB), Flags */
57 { MEMBASE, MEMBASE, (MEMSIZE / MB), LK_MEMORY},
58 { MSM_IOMAP_BASE, MSM_IOMAP_BASE, MSM_IOMAP_SIZE, IOMAP_MEMORY},
59 { KERNEL_ADDR, KERNEL_ADDR, KERNEL_SIZE, SCRATCH_MEMORY},
60 { SCRATCH_ADDR, SCRATCH_ADDR, SCRATCH_SIZE, SCRATCH_MEMORY},
61 { MSM_SHARED_BASE, MSM_SHARED_BASE, MSM_SHARED_SIZE, SCRATCH_MEMORY},
Channagoud Kadabi2bab29b2015-02-11 13:26:03 -080062 { RPMB_SND_RCV_BUF, RPMB_SND_RCV_BUF, RPMB_SND_RCV_BUF_SZ, IOMAP_MEMORY},
Channagoud Kadabied60a8b2014-06-27 15:35:09 -070063};
64
65void platform_early_init(void)
66{
67 board_init();
68 platform_clock_init();
69 qgic_init();
70 qtimer_init();
71 scm_init();
72}
73
74void platform_init(void)
75{
76 dprintf(INFO, "platform_init()\n");
77}
78
79void platform_uninit(void)
80{
81#if DISPLAY_SPLASH_SCREEN
82 display_shutdown();
83#endif
84
85 qtimer_uninit();
86}
87
88int platform_use_identity_mmu_mappings(void)
89{
90 /* Use only the mappings specified in this file. */
91 return 0;
92}
93
94/* Setup memory for this platform */
95void platform_init_mmu_mappings(void)
96{
97 uint32_t i;
98 uint32_t sections;
99 uint32_t table_size = ARRAY_SIZE(mmu_section_table);
100
101 /* Configure the MMU page entries for memory read from the
102 mmu_section_table */
103 for (i = 0; i < table_size; i++)
104 {
105 sections = mmu_section_table[i].num_of_sections;
106
107 while (sections--)
108 {
109 arm_mmu_map_section(mmu_section_table[i].paddress +
110 sections * MB,
111 mmu_section_table[i].vaddress +
112 sections * MB,
113 mmu_section_table[i].flags);
114 }
115 }
116}
117
118addr_t platform_get_virt_to_phys_mapping(addr_t virt_addr)
119{
120 /* Using 1-1 mapping on this platform. */
121 return virt_addr;
122}
123
124addr_t platform_get_phys_to_virt_mapping(addr_t phys_addr)
125{
126 /* Using 1-1 mapping on this platform. */
127 return phys_addr;
128}
129
130uint32_t platform_get_sclk_count(void)
131{
132 return readl(MPM2_MPM_SLEEP_TIMETICK_COUNT_VAL);
133}
Channagoud Kadabi99d23702015-02-02 20:52:17 -0800134
135addr_t get_bs_info_addr()
136{
137 return BS_INFO_ADDR;
138}
Channagoud Kadabi652a6f62014-11-17 17:23:23 -0800139
140uint32_t platform_get_qmp_rev()
141{
142 return readl(USB3_PHY_REVISION_ID3) << 24 | readl(USB3_PHY_REVISION_ID2) << 16 |
143 readl(USB3_PHY_REVISION_ID1) << 8 | readl(USB3_PHY_REVISION_ID0);
144}
Channagoud Kadabi1fc3c682015-03-29 19:49:11 -0700145
146uint32_t platform_get_max_periph()
147{
148 return 256;
149}
Channagoud Kadabi53a21262015-04-09 16:18:23 -0700150
151int platform_is_msm8996()
152{
153 if (board_platform_id() == MSM8996)
154 return 1;
155 else
156 return 0;
157}