Amol Jadi | ca4f4c9 | 2011-01-13 20:19:34 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved. |
| 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. |
| 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. |
| 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 | |
Ajay Dudani | be7733b | 2011-07-06 15:39:26 -0700 | [diff] [blame] | 29 | #include <reg.h> |
| 30 | #include <debug.h> |
| 31 | #include <smem.h> |
| 32 | #include <stdint.h> |
Shashank Mittal | 2ce1645 | 2011-04-26 17:50:00 -0700 | [diff] [blame] | 33 | |
Ajay Dudani | be7733b | 2011-07-06 15:39:26 -0700 | [diff] [blame] | 34 | #define SIZE_1M (1024 * 1024) |
| 35 | #define SIZE_2M (2 * SIZE_1M) |
| 36 | #define SIZE_141M (141 * SIZE_1M) |
| 37 | #define SIZE_256M (256 * SIZE_1M) |
| 38 | #define SIZE_512M (512 * SIZE_1M) |
Amol Jadi | ca4f4c9 | 2011-01-13 20:19:34 -0800 | [diff] [blame] | 39 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame^] | 40 | unsigned *target_atag_mem(unsigned *ptr) |
Amol Jadi | ca4f4c9 | 2011-01-13 20:19:34 -0800 | [diff] [blame] | 41 | { |
Ajay Dudani | be7733b | 2011-07-06 15:39:26 -0700 | [diff] [blame] | 42 | struct smem_ram_ptable ram_ptable; |
| 43 | uint8_t i = 0; |
Shashank Mittal | 2ce1645 | 2011-04-26 17:50:00 -0700 | [diff] [blame] | 44 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame^] | 45 | if (smem_ram_ptable_init(&ram_ptable)) { |
| 46 | for (i = 0; i < ram_ptable.len; i++) { |
Ajay Dudani | ebb0b5b | 2011-08-02 14:35:55 -0700 | [diff] [blame] | 47 | /* Use only 141M from memory bank starting at 0x80000000 */ |
| 48 | if (ram_ptable.parts[i].category == SDRAM && |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame^] | 49 | ram_ptable.parts[i].type == SYS_MEMORY && |
| 50 | ram_ptable.parts[i].start == 0x80000000) { |
Ajay Dudani | ebb0b5b | 2011-08-02 14:35:55 -0700 | [diff] [blame] | 51 | ASSERT(ram_ptable.parts[i].size >= SIZE_256M); |
Ajay Dudani | be7733b | 2011-07-06 15:39:26 -0700 | [diff] [blame] | 52 | |
| 53 | *ptr++ = 4; |
| 54 | *ptr++ = 0x54410002; |
| 55 | *ptr++ = SIZE_141M; |
| 56 | *ptr++ = ram_ptable.parts[i].start + SIZE_2M; |
| 57 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame^] | 58 | if (ram_ptable.parts[i].size > SIZE_256M) { |
Ajay Dudani | 0ec110f | 2011-08-26 12:57:45 -0700 | [diff] [blame] | 59 | *ptr++ = 4; |
| 60 | *ptr++ = 0x54410002; |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame^] | 61 | *ptr++ = |
| 62 | ram_ptable.parts[i].size - |
| 63 | SIZE_256M; |
| 64 | *ptr++ = |
| 65 | ram_ptable.parts[i].start + |
| 66 | SIZE_256M; |
Ajay Dudani | 0ec110f | 2011-08-26 12:57:45 -0700 | [diff] [blame] | 67 | } |
Ajay Dudani | be7733b | 2011-07-06 15:39:26 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Ajay Dudani | ebb0b5b | 2011-08-02 14:35:55 -0700 | [diff] [blame] | 70 | /* Pass along all other usable memory regions to Linux */ |
| 71 | if (ram_ptable.parts[i].category == SDRAM && |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame^] | 72 | ram_ptable.parts[i].type == SYS_MEMORY && |
| 73 | ram_ptable.parts[i].start != 0x80000000) { |
Ajay Dudani | be7733b | 2011-07-06 15:39:26 -0700 | [diff] [blame] | 74 | *ptr++ = 4; |
| 75 | *ptr++ = 0x54410002; |
| 76 | *ptr++ = ram_ptable.parts[i].size; |
| 77 | *ptr++ = ram_ptable.parts[i].start; |
| 78 | } |
| 79 | } |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame^] | 80 | } else { |
Ajay Dudani | be7733b | 2011-07-06 15:39:26 -0700 | [diff] [blame] | 81 | dprintf(CRITICAL, "ERROR: Unable to read RAM partition\n"); |
| 82 | ASSERT(0); |
| 83 | } |
Amol Jadi | ca4f4c9 | 2011-01-13 20:19:34 -0800 | [diff] [blame] | 84 | |
| 85 | return ptr; |
| 86 | } |
| 87 | |
| 88 | void *target_get_scratch_address(void) |
| 89 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame^] | 90 | return ((void *)SCRATCH_ADDR); |
Amol Jadi | ca4f4c9 | 2011-01-13 20:19:34 -0800 | [diff] [blame] | 91 | } |
Shashank Mittal | daef9e5 | 2011-05-09 15:23:14 -0700 | [diff] [blame] | 92 | |
| 93 | unsigned target_get_max_flash_size(void) |
| 94 | { |
Ajay Dudani | be7733b | 2011-07-06 15:39:26 -0700 | [diff] [blame] | 95 | return (SIZE_512M); |
Shashank Mittal | daef9e5 | 2011-05-09 15:23:14 -0700 | [diff] [blame] | 96 | } |