blob: ec801832cc2f11755e5d135991278102fa205b3b [file] [log] [blame]
Ajay Dudanifa746af2009-12-02 13:51:09 -08001/* Copyright (c) 2009, Code Aurora Forum. 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.
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.
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
31#define EBI1_SIZE1 0x0E800000 //232MB for 256/512/1024MB RAM
32#define EBI1_ADDR1 0x20000000
33
34#define EBI1_SIZE2_512M 0x10000000 //256MB for 512MB RAM
35#define EBI1_SIZE2_1G 0x30000000 //768MB for 1GB RAM
36#define EBI1_ADDR2 0x30000000
37
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
66 size = EBT1_SIZE2_512M;
67#else
68 size = 0;
69#endif
70 if (check_1gb_mem()) {
71 size = EBI1_SIZE2_1G;
72 }
73
74 if (size > 0) {
75 *ptr++ = 4;
76 *ptr++ = 0x54410002;
77 *ptr++ = size;
78 *ptr++ = EBI1_ADDR2;
79 }
80
81 return ptr;
82}