Duy Truong | f3ac7b3 | 2013-02-13 01:07:28 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2009-2010, The Linux Foundation. All rights reserved. |
Shashank Mittal | 23b8f42 | 2010-04-16 19:27:21 -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 |
Shashank Mittal | 23b8f42 | 2010-04-16 19:27:21 -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 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 33 | #define SIZE_44M 0x02C00000 // 44M |
Subbaraman Narayanamurthy | 34d7117 | 2010-09-13 13:54:36 -0700 | [diff] [blame] | 34 | #define EBI1_ADDR_1026M 0x40200000 |
Ajay Dudani | b3af417 | 2010-05-26 18:47:17 -0700 | [diff] [blame] | 35 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 36 | #define SIZE_128M 0x08000000 // 128M |
Subbaraman Narayanamurthy | 34d7117 | 2010-09-13 13:54:36 -0700 | [diff] [blame] | 37 | #define EBI1_ADDR_1152M 0x48000000 |
Shashank Mittal | 23b8f42 | 2010-04-16 19:27:21 -0700 | [diff] [blame] | 38 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 39 | #define SIZE_256M 0x10000000 // 256M |
Subbaraman Narayanamurthy | 34d7117 | 2010-09-13 13:54:36 -0700 | [diff] [blame] | 40 | #define EBI1_ADDR_1280M 0x50000000 |
| 41 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 42 | #define SIZE_768M 0x30000000 // 256M + 512M |
| 43 | #define SIZE_1792M 0x70000000 // 256M + 512M + 1G |
Subbaraman Narayanamurthy | e2e081c | 2010-07-02 18:22:41 -0700 | [diff] [blame] | 44 | |
| 45 | #define EBI1_CS1_ADDR_BASE 0x00A40024 |
| 46 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 47 | unsigned *target_atag_mem(unsigned *ptr) |
Shashank Mittal | 23b8f42 | 2010-04-16 19:27:21 -0700 | [diff] [blame] | 48 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 49 | unsigned value = 0; |
Subbaraman Narayanamurthy | e2e081c | 2010-07-02 18:22:41 -0700 | [diff] [blame] | 50 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 51 | /* ATAG_MEM */ |
| 52 | *ptr++ = 4; |
| 53 | *ptr++ = 0x54410002; |
| 54 | *ptr++ = SIZE_44M; |
| 55 | *ptr++ = EBI1_ADDR_1026M; |
Ajay Dudani | b3af417 | 2010-05-26 18:47:17 -0700 | [diff] [blame] | 56 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 57 | *ptr++ = 4; |
| 58 | *ptr++ = 0x54410002; |
| 59 | *ptr++ = SIZE_128M; |
| 60 | *ptr++ = EBI1_ADDR_1152M; |
Subbaraman Narayanamurthy | e2e081c | 2010-07-02 18:22:41 -0700 | [diff] [blame] | 61 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 62 | value = readl(EBI1_CS1_ADDR_BASE); |
| 63 | value = (value >> 8) & 0xFF; |
Subbaraman Narayanamurthy | 34d7117 | 2010-09-13 13:54:36 -0700 | [diff] [blame] | 64 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 65 | if (value == 0x50) { |
| 66 | /* For 512MB RAM */ |
| 67 | *ptr++ = 4; |
| 68 | *ptr++ = 0x54410002; |
| 69 | *ptr++ = SIZE_256M; |
| 70 | *ptr++ = EBI1_ADDR_1280M; |
| 71 | } else if (value == 0x60) { |
| 72 | /* For 1GB RAM */ |
| 73 | *ptr++ = 4; |
| 74 | *ptr++ = 0x54410002; |
| 75 | *ptr++ = SIZE_768M; |
| 76 | *ptr++ = EBI1_ADDR_1280M; |
| 77 | } else if (value == 0x80) { |
| 78 | /* For 2GB RAM */ |
| 79 | *ptr++ = 4; |
| 80 | *ptr++ = 0x54410002; |
| 81 | //*ptr++ = SIZE_1792M; |
| 82 | *ptr++ = SIZE_768M; |
| 83 | *ptr++ = EBI1_ADDR_1280M; |
| 84 | } |
Subbaraman Narayanamurthy | e2e081c | 2010-07-02 18:22:41 -0700 | [diff] [blame] | 85 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 86 | return ptr; |
Shashank Mittal | 23b8f42 | 2010-04-16 19:27:21 -0700 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | void *target_get_scratch_address(void) |
| 90 | { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 91 | return ((void *)SCRATCH_ADDR); |
Shashank Mittal | 23b8f42 | 2010-04-16 19:27:21 -0700 | [diff] [blame] | 92 | } |
Vivek Mehta | 5f1c9d4 | 2011-04-01 20:11:59 -0700 | [diff] [blame] | 93 | |
| 94 | unsigned target_get_max_flash_size(void) |
| 95 | { |
Channagoud Kadabi | c83581f | 2011-12-13 12:32:35 +0530 | [diff] [blame] | 96 | return (384 * 1024 * 1024); |
Vivek Mehta | 5f1c9d4 | 2011-04-01 20:11:59 -0700 | [diff] [blame] | 97 | } |