blob: 3d726c4ae22618daa2084d4169fd84ced084844c [file] [log] [blame]
Duy Truongf3ac7b32013-02-13 01:07:28 -08001/* Copyright (c) 2009-2011, The Linux Foundation. All rights reserved.
Shashank Mittal246f8d02011-01-21 17:12:27 -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.
Duy Truongf3ac7b32013-02-13 01:07:28 -080010 * * Neither the name of The Linux Foundation nor
Shashank Mittal246f8d02011-01-21 17:12:27 -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
29#include <reg.h>
30#include <debug.h>
31#include <smem.h>
32
33#define SIZE_1M 0x00100000
Aparna Mallavarapu5a83b2a2011-05-26 18:01:31 +053034#define ROUND_TO_MB(x) ((x >> 20) << 20)
Shashank Mittal246f8d02011-01-21 17:12:27 -080035
Ajay Dudanib01e5062011-12-03 23:23:42 -080036unsigned *target_atag_mem(unsigned *ptr)
Shashank Mittal246f8d02011-01-21 17:12:27 -080037{
38 struct smem_ram_ptable ram_ptable;
39 unsigned i = 0;
40
Ajay Dudanib01e5062011-12-03 23:23:42 -080041 if (smem_ram_ptable_init(&ram_ptable)) {
42 for (i = 0; i < ram_ptable.len; i++) {
Shashank Mittal246f8d02011-01-21 17:12:27 -080043 if ((ram_ptable.parts[i].attr == READWRITE)
Ajay Dudanib01e5062011-12-03 23:23:42 -080044 && (ram_ptable.parts[i].domain == APPS_DOMAIN)
45 && (ram_ptable.parts[i].start != 0x0)
46 &&
47 (!(ROUND_TO_MB(ram_ptable.parts[i].size) <=
48 SIZE_1M))) {
Shashank Mittal246f8d02011-01-21 17:12:27 -080049 /* ATAG_MEM */
50 *ptr++ = 4;
51 *ptr++ = 0x54410002;
Channagoud Kadabi9090b3b2011-06-17 12:11:58 +053052 /* RAM parition are reported correctly by NON-HLOS
53 Use the size passed directly */
Shashank Mittal246f8d02011-01-21 17:12:27 -080054 if (target_is_emmc_boot())
Ajay Dudanib01e5062011-12-03 23:23:42 -080055 *ptr++ =
56 ROUND_TO_MB(ram_ptable.parts[i].
57 size);
Shashank Mittal246f8d02011-01-21 17:12:27 -080058 else
Channagoud Kadabi9090b3b2011-06-17 12:11:58 +053059 *ptr++ = ram_ptable.parts[i].size;
Shashank Mittal246f8d02011-01-21 17:12:27 -080060
61 *ptr++ = ram_ptable.parts[i].start;
62 }
63 }
Ajay Dudanib01e5062011-12-03 23:23:42 -080064 } else {
Shashank Mittal246f8d02011-01-21 17:12:27 -080065 dprintf(CRITICAL, "ERROR: Unable to read RAM partition\n");
66 ASSERT(0);
67 }
68 return ptr;
69}
70
Srilakshmi Punuru4cd89c42011-07-29 20:16:39 +053071unsigned target_get_max_flash_size(void)
72{
Channagoud Kadabi71961882012-02-09 16:32:41 +053073 return (253 * 1024 * 1024);
Srilakshmi Punuru4cd89c42011-07-29 20:16:39 +053074}