Duy Truong | f3ac7b3 | 2013-02-13 01:07:28 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2009-2011, The Linux Foundation. All rights reserved. |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 2 | * |
| 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 Truong | f3ac7b3 | 2013-02-13 01:07:28 -0800 | [diff] [blame] | 10 | * * Neither the name of The Linux Foundation nor |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 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. |
| 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 Mallavarapu | 5a83b2a | 2011-05-26 18:01:31 +0530 | [diff] [blame] | 34 | #define ROUND_TO_MB(x) ((x >> 20) << 20) |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 35 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 36 | unsigned *target_atag_mem(unsigned *ptr) |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 37 | { |
| 38 | struct smem_ram_ptable ram_ptable; |
| 39 | unsigned i = 0; |
| 40 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 41 | if (smem_ram_ptable_init(&ram_ptable)) { |
| 42 | for (i = 0; i < ram_ptable.len; i++) { |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 43 | if ((ram_ptable.parts[i].attr == READWRITE) |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 44 | && (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 Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 49 | /* ATAG_MEM */ |
| 50 | *ptr++ = 4; |
| 51 | *ptr++ = 0x54410002; |
Channagoud Kadabi | 9090b3b | 2011-06-17 12:11:58 +0530 | [diff] [blame] | 52 | /* RAM parition are reported correctly by NON-HLOS |
| 53 | Use the size passed directly */ |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 54 | if (target_is_emmc_boot()) |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 55 | *ptr++ = |
| 56 | ROUND_TO_MB(ram_ptable.parts[i]. |
| 57 | size); |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 58 | else |
Channagoud Kadabi | 9090b3b | 2011-06-17 12:11:58 +0530 | [diff] [blame] | 59 | *ptr++ = ram_ptable.parts[i].size; |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 60 | |
| 61 | *ptr++ = ram_ptable.parts[i].start; |
| 62 | } |
| 63 | } |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 64 | } else { |
Shashank Mittal | 246f8d0 | 2011-01-21 17:12:27 -0800 | [diff] [blame] | 65 | dprintf(CRITICAL, "ERROR: Unable to read RAM partition\n"); |
| 66 | ASSERT(0); |
| 67 | } |
| 68 | return ptr; |
| 69 | } |
| 70 | |
Srilakshmi Punuru | 4cd89c4 | 2011-07-29 20:16:39 +0530 | [diff] [blame] | 71 | unsigned target_get_max_flash_size(void) |
| 72 | { |
Channagoud Kadabi | 7196188 | 2012-02-09 16:32:41 +0530 | [diff] [blame] | 73 | return (253 * 1024 * 1024); |
Srilakshmi Punuru | 4cd89c4 | 2011-07-29 20:16:39 +0530 | [diff] [blame] | 74 | } |