Duy Truong | f3ac7b3 | 2013-02-13 01:07:28 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2009-2010, The Linux Foundation. All rights reserved. |
Chandan Uddaraju | c6860e1 | 2009-11-19 11:22:15 -0800 | [diff] [blame] | 2 | * |
Ajay Dudani | fa746af | 2009-12-02 13:51:09 -0800 | [diff] [blame] | 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 |
Ajay Dudani | fa746af | 2009-12-02 13:51:09 -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. |
Chandan Uddaraju | c6860e1 | 2009-11-19 11:22:15 -0800 | [diff] [blame] | 14 | * |
Ajay Dudani | fa746af | 2009-12-02 13:51:09 -0800 | [diff] [blame] | 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. |
Chandan Uddaraju | c6860e1 | 2009-11-19 11:22:15 -0800 | [diff] [blame] | 26 | * |
| 27 | */ |
| 28 | |
Ajay Dudani | f12dd71 | 2010-07-30 18:35:25 -0700 | [diff] [blame] | 29 | #include <reg.h> |
| 30 | #include <debug.h> |
| 31 | #include <smem.h> |
| 32 | |
| 33 | #define SIZE_1M 0x00100000 |
| 34 | |
Channagoud Kadabi | 1eb82c6 | 2011-06-08 21:57:26 +0530 | [diff] [blame] | 35 | unsigned round_to_mb(unsigned size) |
| 36 | { |
| 37 | unsigned size_in_mb = 0; |
| 38 | size_in_mb = size >> 20; |
| 39 | size_in_mb = size_in_mb << 20; |
| 40 | return size_in_mb; |
| 41 | } |
| 42 | |
Chandan Uddaraju | c6860e1 | 2009-11-19 11:22:15 -0800 | [diff] [blame] | 43 | unsigned* target_atag_mem(unsigned* ptr) |
| 44 | { |
Ajay Dudani | f12dd71 | 2010-07-30 18:35:25 -0700 | [diff] [blame] | 45 | struct smem_ram_ptable ram_ptable; |
| 46 | unsigned i = 0; |
Channagoud Kadabi | 1eb82c6 | 2011-06-08 21:57:26 +0530 | [diff] [blame] | 47 | unsigned size_in_mb = 0; |
Ajay Dudani | f12dd71 | 2010-07-30 18:35:25 -0700 | [diff] [blame] | 48 | |
| 49 | if (smem_ram_ptable_init(&ram_ptable)) |
| 50 | { |
| 51 | for (i = 0; i < ram_ptable.len; i++) |
| 52 | { |
Channagoud Kadabi | 1eb82c6 | 2011-06-08 21:57:26 +0530 | [diff] [blame] | 53 | /* Round down to align to Mega byte size */ |
| 54 | size_in_mb = round_to_mb(ram_ptable.parts[i].size); |
| 55 | |
Ajay Dudani | f12dd71 | 2010-07-30 18:35:25 -0700 | [diff] [blame] | 56 | if ((ram_ptable.parts[i].attr == READWRITE) |
| 57 | && (ram_ptable.parts[i].domain == APPS_DOMAIN) |
| 58 | && (ram_ptable.parts[i].start != 0x0) |
Channagoud Kadabi | 1eb82c6 | 2011-06-08 21:57:26 +0530 | [diff] [blame] | 59 | && (!(size_in_mb <= SIZE_1M))) |
Ajay Dudani | f12dd71 | 2010-07-30 18:35:25 -0700 | [diff] [blame] | 60 | { |
| 61 | /* ATAG_MEM */ |
| 62 | *ptr++ = 4; |
| 63 | *ptr++ = 0x54410002; |
Channagoud Kadabi | 1eb82c6 | 2011-06-08 21:57:26 +0530 | [diff] [blame] | 64 | /* RAM parition for Emmc boot are reported correctly by modem |
| 65 | * Use the size passed from modem directly after rounding down |
| 66 | * to MB as kernel expects a megabyte aligned size. |
| 67 | */ |
| 68 | if (target_is_emmc_boot()) { |
| 69 | *ptr++ = size_in_mb; |
| 70 | } |
Ajay Dudani | 2676ea9 | 2010-08-10 07:15:45 -0700 | [diff] [blame] | 71 | else |
Channagoud Kadabi | d2adce2 | 2011-07-25 14:42:32 +0530 | [diff] [blame] | 72 | *ptr++ = ram_ptable.parts[i].size; |
Ajay Dudani | 2676ea9 | 2010-08-10 07:15:45 -0700 | [diff] [blame] | 73 | |
Ajay Dudani | f12dd71 | 2010-07-30 18:35:25 -0700 | [diff] [blame] | 74 | *ptr++ = ram_ptable.parts[i].start; |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | else |
| 79 | { |
| 80 | dprintf(CRITICAL, "ERROR: Unable to read RAM partition\n"); |
| 81 | ASSERT(0); |
| 82 | } |
| 83 | return ptr; |
Chandan Uddaraju | c6860e1 | 2009-11-19 11:22:15 -0800 | [diff] [blame] | 84 | } |
Ajay Dudani | f12dd71 | 2010-07-30 18:35:25 -0700 | [diff] [blame] | 85 | |
Srilakshmi Punuru | 4cd89c4 | 2011-07-29 20:16:39 +0530 | [diff] [blame] | 86 | unsigned target_get_max_flash_size(void) |
| 87 | { |
Channagoud Kadabi | 7252f11 | 2011-11-18 14:11:23 +0530 | [diff] [blame] | 88 | return (180 * 1024 * 1024); |
Srilakshmi Punuru | 4cd89c4 | 2011-07-29 20:16:39 +0530 | [diff] [blame] | 89 | } |