blob: 01d9d09447e8d2e4431bf8f5e0e17be36f285b16 [file] [log] [blame]
Duy Truongf3ac7b32013-02-13 01:07:28 -08001/* Copyright (c) 2009, The Linux Foundation. All rights reserved.
Chandan Uddarajuc6860e12009-11-19 11:22:15 -08002 *
Ajay Dudanifa746af2009-12-02 13:51:09 -08003 * 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 Truongf3ac7b32013-02-13 01:07:28 -080010 * * Neither the name of The Linux Foundation nor
Ajay Dudanifa746af2009-12-02 13:51:09 -080011 * 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 Uddarajuc6860e12009-11-19 11:22:15 -080014 *
Ajay Dudanifa746af2009-12-02 13:51:09 -080015 * 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 Uddarajuc6860e12009-11-19 11:22:15 -080026 *
27 */
28
29#include <reg.h>
30
Ajay Dudani57bd43a2010-01-19 15:18:28 -080031#define EBI1_SIZE1 0x0E800000 //232MB for 256/512/1024MB RAM
Chandan Uddarajuc6860e12009-11-19 11:22:15 -080032#define EBI1_ADDR1 0x20000000
33
Ajay Dudani57bd43a2010-01-19 15:18:28 -080034#define EBI1_SIZE2_512M 0x10000000 //256MB for 512MB RAM
35#define EBI1_SIZE2_1G 0x30000000 //768MB for 1GB RAM
36#define EBI1_ADDR2 0x30000000
Chandan Uddarajuc6860e12009-11-19 11:22:15 -080037
38static unsigned check_1gb_mem()
39{
40 // check for 1GB
41 unsigned adr1 = 0x57000000;
42 unsigned adr2 = 0x5F000000;
43 unsigned value1 = 0x55555555;
44 unsigned value2 = 0xAAAAAAAA;
45
46 writel(value1, adr1);
47 writel(value2, adr2);
48
49 return ((value1 == readl(adr1)) && (value2 == readl(adr2)));
50}
51
52
53unsigned* target_atag_mem(unsigned* ptr)
54{
55 unsigned size;
56
57 /* ATAG_MEM */
58 /* 1st segment */
59 *ptr++ = 4;
60 *ptr++ = 0x54410002;
61 *ptr++ = EBI1_SIZE1;
62 *ptr++ = EBI1_ADDR1;
63
64 /* 2nd segment */
65#ifdef USE_512M_RAM
Chandan Uddaraju16a19f12010-03-18 12:37:16 -070066 size = EBI1_SIZE2_512M;
Chandan Uddarajuc6860e12009-11-19 11:22:15 -080067#else
68 size = 0;
69#endif
70 if (check_1gb_mem()) {
Ajay Dudani57bd43a2010-01-19 15:18:28 -080071 size = EBI1_SIZE2_1G;
Chandan Uddarajuc6860e12009-11-19 11:22:15 -080072 }
73
74 if (size > 0) {
75 *ptr++ = 4;
76 *ptr++ = 0x54410002;
77 *ptr++ = size;
Ajay Dudani57bd43a2010-01-19 15:18:28 -080078 *ptr++ = EBI1_ADDR2;
Chandan Uddarajuc6860e12009-11-19 11:22:15 -080079 }
80
81 return ptr;
82}