blob: d615d273d2ec28d5e0ca5bea1dd6c77a6ebbf201 [file] [log] [blame]
Duy Truongf3ac7b32013-02-13 01:07:28 -08001/* Copyright (c) 2009, The Linux Foundation. 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.
Duy Truongf3ac7b32013-02-13 01:07:28 -080010 * * Neither the name of The Linux Foundation nor
Ajay Dudanifa746af2009-12-02 13:51:09 -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.
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
29#include <reg.h>
Ajay Dudani3337ebb2009-12-05 18:13:05 -080030#include <debug.h>
31#include <smem.h>
Chandan Uddarajuc6860e12009-11-19 11:22:15 -080032
Chandan Uddarajua71835f2010-03-31 13:06:47 -070033#define EBI1_ADDR_128M 0x08000000
Ajay Dudania1eafc42010-04-21 19:48:11 -070034#define SIZE_1M 0x00100000
Chandan Uddarajuc6860e12009-11-19 11:22:15 -080035
Ajay Dudania1eafc42010-04-21 19:48:11 -070036static int scratch_addr = -1;
David Ng3679bc52010-02-09 15:43:43 -080037
Ajay Dudanib01e5062011-12-03 23:23:42 -080038unsigned *target_atag_mem(unsigned *ptr)
David Ng3679bc52010-02-09 15:43:43 -080039{
Ajay Dudanib01e5062011-12-03 23:23:42 -080040 struct smem_ram_ptable ram_ptable;
41 unsigned i = 0;
Ajay Dudani3337ebb2009-12-05 18:13:05 -080042
Ajay Dudanib01e5062011-12-03 23:23:42 -080043 if (smem_ram_ptable_init(&ram_ptable)) {
44 for (i = 0; i < ram_ptable.len; i++) {
45 if ((ram_ptable.parts[i].attr == READWRITE)
46 && (ram_ptable.parts[i].domain == APPS_DOMAIN)
47 && (ram_ptable.parts[i].type == APPS_MEMORY)
48 && (ram_ptable.parts[i].category != IMEM)) {
49 /* ATAG_MEM */
50 *ptr++ = 4;
51 *ptr++ = 0x54410002;
52 *ptr++ = ram_ptable.parts[i].size;
53 *ptr++ = ram_ptable.parts[i].start;
54 }
Ajay Dudani9539c2d2010-09-22 14:35:20 -070055
Ajay Dudanib01e5062011-12-03 23:23:42 -080056 /* Check for modem bootloader memory that can be reclaimed */
57 if ((ram_ptable.parts[i].attr == READWRITE)
58 && (ram_ptable.parts[i].domain == APPS_DOMAIN)
59 && (ram_ptable.parts[i].type ==
60 BOOT_REGION_MEMORY1)) {
61 /* ATAG_MEM_OSBL */
62 *ptr++ = 4;
63 *ptr++ = 0x5441000C;
64 *ptr++ = ram_ptable.parts[i].size;
65 *ptr++ = ram_ptable.parts[i].start;
66 }
67 }
68 } else {
69 dprintf(CRITICAL, "ERROR: Unable to read RAM partition\n");
70 ASSERT(0);
71 }
Chandan Uddarajua71835f2010-03-31 13:06:47 -070072
Ajay Dudanib01e5062011-12-03 23:23:42 -080073 return ptr;
Chandan Uddarajuc6860e12009-11-19 11:22:15 -080074}
Ajay Dudani3337ebb2009-12-05 18:13:05 -080075
David Ng3679bc52010-02-09 15:43:43 -080076void *target_get_scratch_address(void)
77{
Ajay Dudanib01e5062011-12-03 23:23:42 -080078 struct smem_ram_ptable ram_ptable;
79 unsigned i = 0;
Ajay Dudania1eafc42010-04-21 19:48:11 -070080
Ajay Dudanib01e5062011-12-03 23:23:42 -080081 if (smem_ram_ptable_init(&ram_ptable)) {
82 for (i = 0; i < ram_ptable.len; i++) {
83 if ((ram_ptable.parts[i].attr == READWRITE)
84 && (ram_ptable.parts[i].domain == APPS_DOMAIN)
85 && (ram_ptable.parts[i].start != 0x0)) {
86 if (ram_ptable.parts[i].size >=
87 FASTBOOT_BUF_SIZE) {
88 scratch_addr =
89 ram_ptable.parts[i].start;
90 break;
91 }
92 }
93 }
94 } else {
95 dprintf(CRITICAL, "ERROR: Unable to read RAM partition\n");
96 ASSERT(0);
97 }
Ajay Dudania1eafc42010-04-21 19:48:11 -070098
Ajay Dudanib01e5062011-12-03 23:23:42 -080099 return (void *)((scratch_addr == -1) ? EBI1_ADDR_128M : scratch_addr);
David Ng3679bc52010-02-09 15:43:43 -0800100}
Srilakshmi Punuru4cd89c42011-07-29 20:16:39 +0530101
102unsigned target_get_max_flash_size(void)
103{
Channagoud Kadabiaa743672011-12-19 16:25:52 +0530104 return (256 * 1024 * 1024);
Srilakshmi Punuru4cd89c42011-07-29 20:16:39 +0530105}