Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [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 | |
| 29 | #include <reg.h> |
| 30 | #include <debug.h> |
| 31 | #include <smem.h> |
| 32 | #include <stdint.h> |
| 33 | |
| 34 | #define SIZE_1M (1024 * 1024) |
| 35 | #define SIZE_8M (8 * SIZE_1M) |
Kinson Chik | 2768bb4 | 2011-09-07 16:58:45 -0700 | [diff] [blame] | 36 | #define SIZE_15M (15 * SIZE_1M) |
| 37 | #define SIZE_23M (23 * SIZE_1M) |
| 38 | #define SIZE_88M (11 * SIZE_8M) |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [diff] [blame] | 39 | |
| 40 | unsigned* target_atag_mem(unsigned* ptr) |
| 41 | { |
| 42 | struct smem_ram_ptable ram_ptable; |
| 43 | uint8_t i = 0; |
| 44 | |
| 45 | if (smem_ram_ptable_init(&ram_ptable)) |
| 46 | { |
| 47 | for (i = 0; i < ram_ptable.len; i++) |
| 48 | { |
| 49 | if (ram_ptable.parts[i].category == SDRAM && |
| 50 | ram_ptable.parts[i].type == SYS_MEMORY && |
| 51 | ram_ptable.parts[i].start == 0x40000000) |
| 52 | { |
Kinson Chik | 2768bb4 | 2011-09-07 16:58:45 -0700 | [diff] [blame] | 53 | ASSERT(ram_ptable.parts[i].size >= SIZE_15M); |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [diff] [blame] | 54 | |
| 55 | *ptr++ = 4; |
| 56 | *ptr++ = 0x54410002; |
Kinson Chik | 2768bb4 | 2011-09-07 16:58:45 -0700 | [diff] [blame] | 57 | *ptr++ = SIZE_15M; |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [diff] [blame] | 58 | *ptr++ = ram_ptable.parts[i].start + SIZE_8M; |
Kinson Chik | 3d9ca48 | 2011-08-29 16:08:58 -0700 | [diff] [blame] | 59 | |
| 60 | *ptr++ = 4; |
| 61 | *ptr++ = 0x54410002; |
Kinson Chik | 2768bb4 | 2011-09-07 16:58:45 -0700 | [diff] [blame] | 62 | *ptr++ = SIZE_23M; |
| 63 | *ptr++ = ram_ptable.parts[i].start + SIZE_88M; |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [diff] [blame] | 64 | } |
| 65 | } |
| 66 | } |
| 67 | else |
| 68 | { |
| 69 | dprintf(CRITICAL, "ERROR: Unable to read RAM partition\n"); |
| 70 | ASSERT(0); |
| 71 | } |
| 72 | |
| 73 | return ptr; |
| 74 | } |
| 75 | |
Kinson Chik | 2828308 | 2011-10-03 17:48:23 -0700 | [diff] [blame^] | 76 | void *target_get_scratch_address(void) |
| 77 | { |
| 78 | return((void *)SCRATCH_ADDR); |
| 79 | } |
| 80 | |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [diff] [blame] | 81 | unsigned target_get_max_flash_size(void) |
| 82 | { |
Kinson Chik | 2828308 | 2011-10-03 17:48:23 -0700 | [diff] [blame^] | 83 | return (SIZE_23M); |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [diff] [blame] | 84 | } |