blob: 430116bb1ed6bcd8758631367386efc7f11810f9 [file] [log] [blame]
Amol Jadid3d7cdc2013-01-16 17:02:01 -08001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Deepa Dinamani7d6c8972011-12-14 15:16:56 -08002 *
3 * Redistribution and use in source and binary forms, with or without
Deepa Dinamani17338312012-10-18 11:29:54 -07004 * 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.
Deepa Dinamani7d6c8972011-12-14 15:16:56 -080015 *
Deepa Dinamani17338312012-10-18 11:29:54 -070016 * 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.
Deepa Dinamani7d6c8972011-12-14 15:16:56 -080027 */
28
29#include <debug.h>
30#include <reg.h>
31#include <platform/iomap.h>
32#include <qgic.h>
Deepa Dinamani81eddd52012-05-31 11:18:50 -070033#include <qtimer.h>
Amol Jadi29f95032012-06-22 12:52:54 -070034#include <platform/clock.h>
Neeti Desai13e688d2012-08-22 16:30:55 -070035#include <mmu.h>
36#include <arch/arm/mmu.h>
37#include <smem.h>
Deepa Dinamani7d6c8972011-12-14 15:16:56 -080038
Neeti Desai13e688d2012-08-22 16:30:55 -070039#define MB (1024*1024)
40
41#define MSM_IOMAP_SIZE ((MSM_IOMAP_END - MSM_IOMAP_BASE)/MB)
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
Deepa Dinamani17338312012-10-18 11:29:54 -070051static mmu_section_t mmu_section_table[] = {
Neeti Desai13e688d2012-08-22 16:30:55 -070052/* Physical addr, Virtual addr, Size (in MB), Flags */
53 {MEMBASE, MEMBASE, (MEMSIZE / MB), LK_MEMORY},
54 {MSM_IOMAP_BASE, MSM_IOMAP_BASE, MSM_IOMAP_SIZE, IOMAP_MEMORY},
55};
Deepa Dinamani7d6c8972011-12-14 15:16:56 -080056
Deepa Dinamani17338312012-10-18 11:29:54 -070057static struct smem_ram_ptable ram_ptable;
58
Deepa Dinamani7d6c8972011-12-14 15:16:56 -080059void platform_early_init(void)
60{
Neeti Desai465491e2012-07-31 12:53:35 -070061 board_init();
Amol Jadi29f95032012-06-22 12:52:54 -070062 platform_clock_init();
Deepa Dinamani7d6c8972011-12-14 15:16:56 -080063 qgic_init();
Deepa Dinamani81eddd52012-05-31 11:18:50 -070064 qtimer_init();
Deepa Dinamani7d6c8972011-12-14 15:16:56 -080065}
66
67void platform_init(void)
68{
69 dprintf(INFO, "platform_init()\n");
70}
71
Joel King46d2a452013-02-13 18:35:21 -080072static void platform_print_sclk(void)
73{
74 uint32_t count;
75
76 count = readl(MPM2_MPM_SLEEP_TIMETICK_COUNT_VAL);
77
78 dprintf(INFO, "mpm sclk=(%lu)\n", count);
79}
80
Deepa Dinamani7d6c8972011-12-14 15:16:56 -080081void platform_uninit(void)
82{
Joel King46d2a452013-02-13 18:35:21 -080083 platform_print_sclk();
84
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -080085#if DISPLAY_SPLASH_SCREEN
86 display_shutdown();
87#endif
88
Deepa Dinamani81eddd52012-05-31 11:18:50 -070089 qtimer_uninit();
Deepa Dinamani7d6c8972011-12-14 15:16:56 -080090}
Neeti Desai13e688d2012-08-22 16:30:55 -070091
92/* Setup memory for this platform */
93void platform_init_mmu_mappings(void)
94{
Neeti Desai13e688d2012-08-22 16:30:55 -070095 uint32_t i;
96 uint32_t sections;
97 uint32_t table_size = ARRAY_SIZE(mmu_section_table);
98
99 ASSERT(smem_ram_ptable_init(&ram_ptable));
100
101 /* Configure the MMU page entries for SDRAM and IMEM memory read
102 from the smem ram table*/
103 for(i = 0; i < ram_ptable.len; i++)
Amol Jadid3d7cdc2013-01-16 17:02:01 -0800104 {
105 if(ram_ptable.parts[i].type == SYS_MEMORY)
Neeti Desai13e688d2012-08-22 16:30:55 -0700106 {
Amol Jadid3d7cdc2013-01-16 17:02:01 -0800107 if((ram_ptable.parts[i].category == SDRAM) ||
108 (ram_ptable.parts[i].category == IMEM))
109 {
110 /* Check to ensure that start address is 1MB aligned */
111 ASSERT((ram_ptable.parts[i].start & 0xFFFFF) == 0);
Neeti Desai13e688d2012-08-22 16:30:55 -0700112
Amol Jadid3d7cdc2013-01-16 17:02:01 -0800113 sections = (ram_ptable.parts[i].size) / MB;
114 while(sections--) {
115 arm_mmu_map_section(ram_ptable.parts[i].start +
116 sections * MB,
117 ram_ptable.parts[i].start +
118 sections * MB,
119 (MMU_MEMORY_TYPE_NORMAL_WRITE_THROUGH | \
120 MMU_MEMORY_AP_READ_WRITE | MMU_MEMORY_XN));
121 }
Neeti Desai13e688d2012-08-22 16:30:55 -0700122 }
123 }
124 }
125 /* Configure the MMU page entries for memory read from the
126 mmu_section_table */
127 for (i = 0; i < table_size; i++) {
128 sections = mmu_section_table[i].num_of_sections;
129
130 while (sections--) {
131 arm_mmu_map_section(mmu_section_table[i].paddress +
132 sections * MB,
133 mmu_section_table[i].vaddress +
134 sections * MB,
135 mmu_section_table[i].flags);
136 }
137 }
138}