blob: 8ac045c38a577c483049a51e2706cc19e7c9c437 [file] [log] [blame]
Aparna Mallavarapu2269a2f2013-01-07 19:44:48 +05301/* Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
Amol Jadica4f4c92011-01-13 20:19:34 -08002 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5 * * Redistributions of source code must retain the above copyright
6 * notice, this list of conditions and the following disclaimer.
7 * * Redistributions in binary form must reproduce the above copyright
8 * notice, this list of conditions and the following disclaimer in the
9 * documentation and/or other materials provided with the distribution.
Channagoud Kadabia6f305d2012-10-04 14:43:17 +053010 * * Neither the name of Linux Foundation nor
Amol Jadica4f4c92011-01-13 20:19:34 -080011 * the names of its contributors may be used to endorse or promote
12 * products derived from this software without specific prior written
13 * permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 */
28
Ajay Dudanibe7733b2011-07-06 15:39:26 -070029#include <reg.h>
30#include <debug.h>
31#include <smem.h>
32#include <stdint.h>
Naveen Kallaa0221872012-04-09 18:24:57 -070033#include "board.h"
34#include "baseband.h"
Shashank Mittal2ce16452011-04-26 17:50:00 -070035
Ajay Dudanibe7733b2011-07-06 15:39:26 -070036#define SIZE_1M (1024 * 1024)
Naveen Kallaa0221872012-04-09 18:24:57 -070037#define SIZE_2M (2 * SIZE_1M)
38#define SIZE_256M (256 * SIZE_1M)
39#define SIZE_512M (512 * SIZE_1M)
Channagoud Kadabi7d84dd62012-08-24 21:20:56 +053040#define SIZE_768M (768 * SIZE_1M)
Naveen Kallaa0221872012-04-09 18:24:57 -070041
42#define ATAG_MEM 0x54410002
43
44#define PHYS_MEM_START_ADDR 0x80000000
45
46typedef struct {
47 uint32_t size;
48 uint32_t start_addr;
49}atag_mem_info;
50
51atag_mem_info apq8064_standalone_first_256M[] = {
52 { .size = (140 * SIZE_1M),
53 .start_addr = PHYS_MEM_START_ADDR + SIZE_2M
54 },
Channagoud Kadabia6f305d2012-10-04 14:43:17 +053055 { .size = (58 * SIZE_1M),
56 .start_addr = PHYS_MEM_START_ADDR + (0xA0 * SIZE_1M)
57 },
58 { .size = (4 * SIZE_1M),
59 .start_addr = PHYS_MEM_START_ADDR + (0xEC * SIZE_1M)
Naveen Kallaa0221872012-04-09 18:24:57 -070060 },
61 { .size = (7 * SIZE_1M),
62 .start_addr = PHYS_MEM_START_ADDR + (0xF7 * SIZE_1M)
63 }
64};
65
66atag_mem_info apq8064_fusion_first_256M[] = {
67 { .size = (140 * SIZE_1M),
68 .start_addr = PHYS_MEM_START_ADDR + SIZE_2M
69 },
70 { .size = (74 * SIZE_1M),
71 .start_addr = PHYS_MEM_START_ADDR + (0x90 * SIZE_1M)
72 },
73 { .size = (7 * SIZE_1M),
74 .start_addr = PHYS_MEM_START_ADDR + (0xF7 * SIZE_1M)
75 },
Channagoud Kadabi9738c552012-08-13 15:49:55 +053076 { .size = (4 * SIZE_1M),
77 .start_addr = PHYS_MEM_START_ADDR + (0xEC * SIZE_1M)
78 },
Naveen Kallaa0221872012-04-09 18:24:57 -070079 { .size = SIZE_1M,
80 .start_addr = PHYS_MEM_START_ADDR + (0xFF * SIZE_1M)
81 }
82};
83
84atag_mem_info mpq8064_first_256M[] = {
85 { .size = (140 * SIZE_1M),
86 .start_addr = PHYS_MEM_START_ADDR + SIZE_2M
87 },
88 { .size = (74 * SIZE_1M),
89 .start_addr = PHYS_MEM_START_ADDR + (0x90 * SIZE_1M)
90 },
Amol Jadi8f15a722012-08-20 14:28:42 -070091 { .size = (20 * SIZE_1M),
92 .start_addr = PHYS_MEM_START_ADDR + (0xEC * SIZE_1M)
Naveen Kallaa0221872012-04-09 18:24:57 -070093 }
94};
95
96atag_mem_info msm8960_default_first_256M[] = {
97 { .size = (140 * SIZE_1M),
98 .start_addr = PHYS_MEM_START_ADDR + SIZE_2M
99 }
100};
101
Channagoud Kadabic8c8e022012-10-09 11:39:39 +0530102atag_mem_info msm8930_default_first_256M[] = {
103 { .size = (140 * SIZE_1M),
104 .start_addr = PHYS_MEM_START_ADDR + SIZE_2M
105 },
106 { .size = (4 * SIZE_1M),
107 .start_addr = PHYS_MEM_START_ADDR + (0xEC * SIZE_1M)
108 },
109 { .size = (3 * SIZE_1M),
110 .start_addr = PHYS_MEM_START_ADDR + (0xF8 * SIZE_1M)
111 },
112 { .size = (1 * SIZE_1M),
113 .start_addr = PHYS_MEM_START_ADDR + (0xFE * SIZE_1M)
114 }
115};
Naveen Kallaa0221872012-04-09 18:24:57 -0700116
117unsigned *target_mem_atag_create(unsigned *ptr, uint32_t size, uint32_t addr)
118{
119 *ptr++ = 4;
120 *ptr++ = ATAG_MEM;
121 *ptr++ = size;
122 *ptr++ = addr;
123
124 return ptr;
125}
126
127unsigned *target_atag(unsigned *ptr, atag_mem_info usable_mem_map[], unsigned num_regions)
128{
129 unsigned i;
130
131 dprintf(SPEW, "Number of regions for HLOS in 1st 256MB = %u\n", num_regions);
132 for (i=0; i < num_regions; i++)
133 {
134 ptr = target_mem_atag_create(ptr,
135 usable_mem_map[i].size,
136 usable_mem_map[i].start_addr);
137 }
138 return ptr;
139}
140
141unsigned *target_first_256M_atag(unsigned *ptr)
142{
143 unsigned int platform_id = board_platform_id();
144 unsigned int baseband = board_baseband();
145
146 switch (platform_id) {
147 case APQ8064:
Aparna Mallavarapu2269a2f2013-01-07 19:44:48 +0530148 case APQ8064AA:
Amol Jadi117ef3a2012-09-20 13:32:55 -0700149 case APQ8064AB:
Naveen Kallaa0221872012-04-09 18:24:57 -0700150 if(baseband == BASEBAND_MDM)
151 {
152 /* Use 8064 Fusion 3 memory map */
153 ptr = target_atag(ptr,
154 apq8064_fusion_first_256M,
155 ARRAY_SIZE(apq8064_fusion_first_256M));
156 } else {
157 /* Use 8064 standalone memory map */
158 ptr = target_atag(ptr,
159 apq8064_standalone_first_256M,
160 ARRAY_SIZE(apq8064_standalone_first_256M));
161 }
162 break;
163
164 case MPQ8064:
165 ptr = target_atag(ptr, mpq8064_first_256M, ARRAY_SIZE(mpq8064_first_256M));
166 break;
David Ng0f56e932013-02-12 18:11:56 -0800167 case MSM8130:
Channagoud Kadabic8c8e022012-10-09 11:39:39 +0530168 case MSM8230:
169 case MSM8930:
170 case MSM8630:
David Ng0f56e932013-02-12 18:11:56 -0800171 case MSM8130AA:
Channagoud Kadabic8c8e022012-10-09 11:39:39 +0530172 case MSM8230AA:
173 case MSM8630AA:
174 case MSM8930AA:
175 case MSM8930AB:
176 case MSM8630AB:
177 case MSM8230AB:
David Ng0f56e932013-02-12 18:11:56 -0800178 case MSM8130AB:
Channagoud Kadabic8c8e022012-10-09 11:39:39 +0530179 case APQ8030AB:
180 case APQ8030:
Channagoud Kadabi512295f2012-10-23 10:00:42 +0530181 case APQ8030AA:
Channagoud Kadabic8c8e022012-10-09 11:39:39 +0530182 ptr = target_atag(ptr, msm8930_default_first_256M,
183 ARRAY_SIZE(msm8930_default_first_256M));
184 break;
Naveen Kallaa0221872012-04-09 18:24:57 -0700185 case MSM8960: /* fall through */
Neeti Desai6e015252012-08-13 13:22:37 -0700186 case MSM8960AB:
187 case APQ8060AB:
188 case MSM8260AB:
189 case MSM8660AB:
Naveen Kallaa0221872012-04-09 18:24:57 -0700190 default:
191 ptr = target_atag(ptr,
192 msm8960_default_first_256M,
193 ARRAY_SIZE(msm8960_default_first_256M));
194 break;
195 }
196 return ptr;
197}
Amol Jadica4f4c92011-01-13 20:19:34 -0800198
Ajay Dudanib01e5062011-12-03 23:23:42 -0800199unsigned *target_atag_mem(unsigned *ptr)
Amol Jadica4f4c92011-01-13 20:19:34 -0800200{
Ajay Dudanibe7733b2011-07-06 15:39:26 -0700201 struct smem_ram_ptable ram_ptable;
202 uint8_t i = 0;
Shashank Mittal2ce16452011-04-26 17:50:00 -0700203
Naveen Kallaa0221872012-04-09 18:24:57 -0700204 if (smem_ram_ptable_init(&ram_ptable))
205 {
206 for (i = 0; i < ram_ptable.len; i++)
207 {
Ajay Dudaniebb0b5b2011-08-02 14:35:55 -0700208 if (ram_ptable.parts[i].category == SDRAM &&
Naveen Kallaa0221872012-04-09 18:24:57 -0700209 (ram_ptable.parts[i].type == SYS_MEMORY) &&
210 (ram_ptable.parts[i].start == PHYS_MEM_START_ADDR))
211 {
Ajay Dudaniebb0b5b2011-08-02 14:35:55 -0700212 ASSERT(ram_ptable.parts[i].size >= SIZE_256M);
Ajay Dudanibe7733b2011-07-06 15:39:26 -0700213
Naveen Kallaa0221872012-04-09 18:24:57 -0700214 ptr = target_first_256M_atag(ptr);
Ajay Dudanibe7733b2011-07-06 15:39:26 -0700215
Naveen Kallaa0221872012-04-09 18:24:57 -0700216 if (ram_ptable.parts[i].size > SIZE_256M)
217 {
218 ptr = target_mem_atag_create(ptr,
219 (ram_ptable.parts[i].size - SIZE_256M),
220 (ram_ptable.parts[i].start + SIZE_256M));
Ajay Dudani0ec110f2011-08-26 12:57:45 -0700221 }
Ajay Dudanibe7733b2011-07-06 15:39:26 -0700222 }
223
Ajay Dudaniebb0b5b2011-08-02 14:35:55 -0700224 /* Pass along all other usable memory regions to Linux */
225 if (ram_ptable.parts[i].category == SDRAM &&
Naveen Kallaa0221872012-04-09 18:24:57 -0700226 (ram_ptable.parts[i].type == SYS_MEMORY) &&
227 (ram_ptable.parts[i].start != PHYS_MEM_START_ADDR))
228 {
229 ptr = target_mem_atag_create(ptr,
230 ram_ptable.parts[i].size,
231 ram_ptable.parts[i].start);
Ajay Dudanibe7733b2011-07-06 15:39:26 -0700232 }
233 }
Ajay Dudanib01e5062011-12-03 23:23:42 -0800234 } else {
Ajay Dudanibe7733b2011-07-06 15:39:26 -0700235 dprintf(CRITICAL, "ERROR: Unable to read RAM partition\n");
236 ASSERT(0);
237 }
Amol Jadica4f4c92011-01-13 20:19:34 -0800238
239 return ptr;
240}
241
242void *target_get_scratch_address(void)
243{
Naveen Kallaa0221872012-04-09 18:24:57 -0700244 return ((void *) SCRATCH_ADDR);
Amol Jadica4f4c92011-01-13 20:19:34 -0800245}
Shashank Mittaldaef9e52011-05-09 15:23:14 -0700246
247unsigned target_get_max_flash_size(void)
248{
Channagoud Kadabi7d84dd62012-08-24 21:20:56 +0530249 return (SIZE_768M);
Shashank Mittaldaef9e52011-05-09 15:23:14 -0700250}