vijay kumar | 47cb1d2 | 2015-04-06 15:33:00 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2009-2011,2015 The Linux Foundation. All rights reserved. |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [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 |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [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 | #include <stdint.h> |
Deepa Dinamani | f551d05 | 2012-02-02 17:55:22 -0800 | [diff] [blame] | 33 | #include <lib/ptable.h> |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [diff] [blame] | 34 | |
| 35 | #define SIZE_1M (1024 * 1024) |
| 36 | #define SIZE_8M (8 * SIZE_1M) |
Kinson Chik | 2768bb4 | 2011-09-07 16:58:45 -0700 | [diff] [blame] | 37 | #define SIZE_15M (15 * SIZE_1M) |
Deepa Dinamani | f551d05 | 2012-02-02 17:55:22 -0800 | [diff] [blame] | 38 | #define SIZE_17M (17 * SIZE_1M) |
Kinson Chik | 2768bb4 | 2011-09-07 16:58:45 -0700 | [diff] [blame] | 39 | #define SIZE_23M (23 * SIZE_1M) |
| 40 | #define SIZE_88M (11 * SIZE_8M) |
vijay kumar | 47cb1d2 | 2015-04-06 15:33:00 +0530 | [diff] [blame] | 41 | #define SIZE_38M (38 * SIZE_1M) |
vijay kumar | b768d06 | 2015-04-07 16:55:24 +0530 | [diff] [blame] | 42 | #define SIZE_128M (16 * SIZE_8M) |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [diff] [blame] | 43 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 44 | unsigned *target_atag_mem(unsigned *ptr) |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [diff] [blame] | 45 | { |
| 46 | struct smem_ram_ptable ram_ptable; |
| 47 | uint8_t i = 0; |
Deepa Dinamani | f551d05 | 2012-02-02 17:55:22 -0800 | [diff] [blame] | 48 | struct ptable *nand_ptable; |
| 49 | struct ptentry *dsp3_ptn; |
| 50 | unsigned int size; |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [diff] [blame] | 51 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 52 | if (smem_ram_ptable_init(&ram_ptable)) { |
| 53 | for (i = 0; i < ram_ptable.len; i++) { |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [diff] [blame] | 54 | if (ram_ptable.parts[i].category == SDRAM && |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 55 | ram_ptable.parts[i].type == SYS_MEMORY && |
| 56 | ram_ptable.parts[i].start == 0x40000000) { |
Kinson Chik | 2768bb4 | 2011-09-07 16:58:45 -0700 | [diff] [blame] | 57 | ASSERT(ram_ptable.parts[i].size >= SIZE_15M); |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [diff] [blame] | 58 | |
| 59 | *ptr++ = 4; |
| 60 | *ptr++ = 0x54410002; |
Kinson Chik | 2768bb4 | 2011-09-07 16:58:45 -0700 | [diff] [blame] | 61 | *ptr++ = SIZE_15M; |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [diff] [blame] | 62 | *ptr++ = ram_ptable.parts[i].start + SIZE_8M; |
Kinson Chik | 3d9ca48 | 2011-08-29 16:08:58 -0700 | [diff] [blame] | 63 | |
| 64 | *ptr++ = 4; |
| 65 | *ptr++ = 0x54410002; |
Sridhar Ancha | b85cdd8 | 2015-05-01 14:22:29 +0530 | [diff] [blame] | 66 | *ptr++ = (SIZE_23M-SIZE_1M); |
Kinson Chik | 2768bb4 | 2011-09-07 16:58:45 -0700 | [diff] [blame] | 67 | *ptr++ = ram_ptable.parts[i].start + SIZE_88M; |
Deepa Dinamani | f551d05 | 2012-02-02 17:55:22 -0800 | [diff] [blame] | 68 | |
vijay kumar | b768d06 | 2015-04-07 16:55:24 +0530 | [diff] [blame] | 69 | if(ram_ptable.parts[i].size == 0x10000000) { |
| 70 | *ptr++ = 4; |
| 71 | *ptr++ = 0x54410002; |
| 72 | *ptr++ = SIZE_128M; |
| 73 | *ptr++ = ram_ptable.parts[i].start + SIZE_128M; |
| 74 | } |
| 75 | |
Deepa Dinamani | f551d05 | 2012-02-02 17:55:22 -0800 | [diff] [blame] | 76 | nand_ptable = flash_get_ptable(); |
| 77 | dsp3_ptn = ptable_find(nand_ptable, "dsp3"); |
| 78 | |
| 79 | /* Check for DSP3 partition and its size */ |
| 80 | if(dsp3_ptn != NULL){ |
| 81 | size = dsp3_ptn->start; |
| 82 | size += dsp3_ptn->length; |
| 83 | if(size != dsp3_ptn->start) |
| 84 | continue; |
| 85 | } |
| 86 | |
| 87 | /*Add additional atag to pass DSP3 memory to kernel*/ |
| 88 | *ptr++ = 4; |
| 89 | *ptr++ = 0x54410002; |
| 90 | *ptr++ = SIZE_17M; |
| 91 | *ptr++ = ram_ptable.parts[i].start + SIZE_88M + SIZE_23M; |
| 92 | |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [diff] [blame] | 93 | } |
| 94 | } |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 95 | } else { |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [diff] [blame] | 96 | dprintf(CRITICAL, "ERROR: Unable to read RAM partition\n"); |
| 97 | ASSERT(0); |
| 98 | } |
| 99 | |
| 100 | return ptr; |
| 101 | } |
| 102 | |
Kinson Chik | 2828308 | 2011-10-03 17:48:23 -0700 | [diff] [blame] | 103 | void *target_get_scratch_address(void) |
| 104 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 105 | return ((void *)SCRATCH_ADDR); |
Kinson Chik | 2828308 | 2011-10-03 17:48:23 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [diff] [blame] | 108 | unsigned target_get_max_flash_size(void) |
| 109 | { |
vijay kumar | 47cb1d2 | 2015-04-06 15:33:00 +0530 | [diff] [blame] | 110 | return (SIZE_38M); |
Kinson Chik | 18e3633 | 2011-08-15 10:07:28 -0700 | [diff] [blame] | 111 | } |