blob: a2e1db7fa1d790cddbbfc25d4f4e2e9b34248faf [file] [log] [blame]
Ajay Dudanif12dd712010-07-30 18:35:25 -07001/* Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
Chandan Uddarajuc6860e12009-11-19 11:22:15 -08002 *
Ajay Dudanifa746af2009-12-02 13:51:09 -08003 * 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.
10 * * Neither the name of Code Aurora nor
11 * the names of its contributors may be used to endorse or promote
12 * products derived from this software without specific prior written
13 * permission.
Chandan Uddarajuc6860e12009-11-19 11:22:15 -080014 *
Ajay Dudanifa746af2009-12-02 13:51:09 -080015 * 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.
Chandan Uddarajuc6860e12009-11-19 11:22:15 -080026 *
27 */
28
Ajay Dudanif12dd712010-07-30 18:35:25 -070029#include <reg.h>
30#include <debug.h>
31#include <smem.h>
32
33#define SIZE_1M 0x00100000
34
Chandan Uddarajuc6860e12009-11-19 11:22:15 -080035unsigned* target_atag_mem(unsigned* ptr)
36{
Ajay Dudanif12dd712010-07-30 18:35:25 -070037 struct smem_ram_ptable ram_ptable;
38 unsigned i = 0;
39
40 if (smem_ram_ptable_init(&ram_ptable))
41 {
42 for (i = 0; i < ram_ptable.len; i++)
43 {
44 if ((ram_ptable.parts[i].attr == READWRITE)
45 && (ram_ptable.parts[i].domain == APPS_DOMAIN)
46 && (ram_ptable.parts[i].start != 0x0)
47 && (!(ram_ptable.parts[i].size < SIZE_1M)))
48 {
49 /* ATAG_MEM */
50 *ptr++ = 4;
51 *ptr++ = 0x54410002;
52 /* FIXME: RAM partition table currently reports 2M extra
53 Fix this by subracting 2M, until modem ram partition table
Ajay Dudani2676ea92010-08-10 07:15:45 -070054 starts reporting the right values. Also need fixes for
55 RAM partition table to have emmc entries correct */
56 if (target_is_emmc_boot())
57 *ptr++ = ram_ptable.parts[i].size - (2*SIZE_1M) - (6*SIZE_1M);
58 else
59 *ptr++ = ram_ptable.parts[i].size - (2*SIZE_1M);
60
Ajay Dudanif12dd712010-07-30 18:35:25 -070061 *ptr++ = ram_ptable.parts[i].start;
62 }
63 }
64 }
65 else
66 {
67 dprintf(CRITICAL, "ERROR: Unable to read RAM partition\n");
68 ASSERT(0);
69 }
70 return ptr;
Chandan Uddarajuc6860e12009-11-19 11:22:15 -080071}
Ajay Dudanif12dd712010-07-30 18:35:25 -070072