blob: 315d05ee67ee2cd83a8708796bd2c4297c97489d [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 *
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
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
Sridhar Parasurambe12c3d2015-01-16 13:42:26 -080047/* RPM MSG RAM memory - cacheable, write through */
48#define MSG_RAM_MEMORY (MMU_MEMORY_TYPE_NORMAL_WRITE_THROUGH | \
49 MMU_MEMORY_AP_READ_WRITE)
Channagoud Kadabied60a8b2014-06-27 15:35:09 -070050/* Peripherals - non-shared device */
51#define IOMAP_MEMORY (MMU_MEMORY_TYPE_DEVICE_SHARED | \
52 MMU_MEMORY_AP_READ_WRITE | MMU_MEMORY_XN)
53
54/* SCRATCH memory - cacheable, write through */
55#define SCRATCH_MEMORY (MMU_MEMORY_TYPE_NORMAL_WRITE_THROUGH | \
56 MMU_MEMORY_AP_READ_WRITE | MMU_MEMORY_XN)
57
58static mmu_section_t mmu_section_table[] = {
59/* Physical addr, Virtual addr, Size (in MB), Flags */
60 { MEMBASE, MEMBASE, (MEMSIZE / MB), LK_MEMORY},
61 { MSM_IOMAP_BASE, MSM_IOMAP_BASE, MSM_IOMAP_SIZE, IOMAP_MEMORY},
62 { KERNEL_ADDR, KERNEL_ADDR, KERNEL_SIZE, SCRATCH_MEMORY},
63 { SCRATCH_ADDR, SCRATCH_ADDR, SCRATCH_SIZE, SCRATCH_MEMORY},
64 { MSM_SHARED_BASE, MSM_SHARED_BASE, MSM_SHARED_SIZE, SCRATCH_MEMORY},
Sridhar Parasurambe12c3d2015-01-16 13:42:26 -080065 { RPM_SS_MSG_RAM_START_ADDRESS_BASE, RPM_SS_MSG_RAM_START_ADDRESS_BASE, RPM_SS_MSG_RAM_START_ADDRESS_BASE_SIZE, MSG_RAM_MEMORY},
Channagoud Kadabied60a8b2014-06-27 15:35:09 -070066};
67
68void platform_early_init(void)
69{
70 board_init();
71 platform_clock_init();
72 qgic_init();
73 qtimer_init();
74 scm_init();
75}
76
77void platform_init(void)
78{
79 dprintf(INFO, "platform_init()\n");
80}
81
82void platform_uninit(void)
83{
84#if DISPLAY_SPLASH_SCREEN
85 display_shutdown();
86#endif
87
88 qtimer_uninit();
89}
90
91int platform_use_identity_mmu_mappings(void)
92{
93 /* Use only the mappings specified in this file. */
94 return 0;
95}
96
97/* Setup memory for this platform */
98void platform_init_mmu_mappings(void)
99{
100 uint32_t i;
101 uint32_t sections;
102 uint32_t table_size = ARRAY_SIZE(mmu_section_table);
103
104 /* Configure the MMU page entries for memory read from the
105 mmu_section_table */
106 for (i = 0; i < table_size; i++)
107 {
108 sections = mmu_section_table[i].num_of_sections;
109
110 while (sections--)
111 {
112 arm_mmu_map_section(mmu_section_table[i].paddress +
113 sections * MB,
114 mmu_section_table[i].vaddress +
115 sections * MB,
116 mmu_section_table[i].flags);
117 }
118 }
119}
120
121addr_t platform_get_virt_to_phys_mapping(addr_t virt_addr)
122{
123 /* Using 1-1 mapping on this platform. */
124 return virt_addr;
125}
126
127addr_t platform_get_phys_to_virt_mapping(addr_t phys_addr)
128{
129 /* Using 1-1 mapping on this platform. */
130 return phys_addr;
131}
132
133uint32_t platform_get_sclk_count(void)
134{
135 return readl(MPM2_MPM_SLEEP_TIMETICK_COUNT_VAL);
136}