blob: 59dc1f09654040da0b1934be59d9e341cc970e68 [file] [log] [blame]
Duy Truongf3ac7b32013-02-13 01:07:28 -08001/* Copyright (c) 2009-2011, The Linux Foundation. All rights reserved.
Kinson Chik18e36332011-08-15 10:07:28 -07002 *
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 Truongf3ac7b32013-02-13 01:07:28 -080010 * * Neither the name of The Linux Foundation nor
Kinson Chik18e36332011-08-15 10:07:28 -070011 * 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 Dinamanif551d052012-02-02 17:55:22 -080033#include <lib/ptable.h>
Kinson Chik18e36332011-08-15 10:07:28 -070034
35#define SIZE_1M (1024 * 1024)
36#define SIZE_8M (8 * SIZE_1M)
Kinson Chik2768bb42011-09-07 16:58:45 -070037#define SIZE_15M (15 * SIZE_1M)
Deepa Dinamanif551d052012-02-02 17:55:22 -080038#define SIZE_17M (17 * SIZE_1M)
Kinson Chik2768bb42011-09-07 16:58:45 -070039#define SIZE_23M (23 * SIZE_1M)
40#define SIZE_88M (11 * SIZE_8M)
Kinson Chik18e36332011-08-15 10:07:28 -070041
Ajay Dudanib01e5062011-12-03 23:23:42 -080042unsigned *target_atag_mem(unsigned *ptr)
Kinson Chik18e36332011-08-15 10:07:28 -070043{
44 struct smem_ram_ptable ram_ptable;
45 uint8_t i = 0;
Deepa Dinamanif551d052012-02-02 17:55:22 -080046 struct ptable *nand_ptable;
47 struct ptentry *dsp3_ptn;
48 unsigned int size;
Kinson Chik18e36332011-08-15 10:07:28 -070049
Ajay Dudanib01e5062011-12-03 23:23:42 -080050 if (smem_ram_ptable_init(&ram_ptable)) {
51 for (i = 0; i < ram_ptable.len; i++) {
Kinson Chik18e36332011-08-15 10:07:28 -070052 if (ram_ptable.parts[i].category == SDRAM &&
Ajay Dudanib01e5062011-12-03 23:23:42 -080053 ram_ptable.parts[i].type == SYS_MEMORY &&
54 ram_ptable.parts[i].start == 0x40000000) {
Kinson Chik2768bb42011-09-07 16:58:45 -070055 ASSERT(ram_ptable.parts[i].size >= SIZE_15M);
Kinson Chik18e36332011-08-15 10:07:28 -070056
57 *ptr++ = 4;
58 *ptr++ = 0x54410002;
Kinson Chik2768bb42011-09-07 16:58:45 -070059 *ptr++ = SIZE_15M;
Kinson Chik18e36332011-08-15 10:07:28 -070060 *ptr++ = ram_ptable.parts[i].start + SIZE_8M;
Kinson Chik3d9ca482011-08-29 16:08:58 -070061
62 *ptr++ = 4;
63 *ptr++ = 0x54410002;
Kinson Chik2768bb42011-09-07 16:58:45 -070064 *ptr++ = SIZE_23M;
65 *ptr++ = ram_ptable.parts[i].start + SIZE_88M;
Deepa Dinamanif551d052012-02-02 17:55:22 -080066
67 nand_ptable = flash_get_ptable();
68 dsp3_ptn = ptable_find(nand_ptable, "dsp3");
69
70 /* Check for DSP3 partition and its size */
71 if(dsp3_ptn != NULL){
72 size = dsp3_ptn->start;
73 size += dsp3_ptn->length;
74 if(size != dsp3_ptn->start)
75 continue;
76 }
77
78 /*Add additional atag to pass DSP3 memory to kernel*/
79 *ptr++ = 4;
80 *ptr++ = 0x54410002;
81 *ptr++ = SIZE_17M;
82 *ptr++ = ram_ptable.parts[i].start + SIZE_88M + SIZE_23M;
83
Kinson Chik18e36332011-08-15 10:07:28 -070084 }
85 }
Ajay Dudanib01e5062011-12-03 23:23:42 -080086 } else {
Kinson Chik18e36332011-08-15 10:07:28 -070087 dprintf(CRITICAL, "ERROR: Unable to read RAM partition\n");
88 ASSERT(0);
89 }
90
91 return ptr;
92}
93
Kinson Chik28283082011-10-03 17:48:23 -070094void *target_get_scratch_address(void)
95{
Ajay Dudanib01e5062011-12-03 23:23:42 -080096 return ((void *)SCRATCH_ADDR);
Kinson Chik28283082011-10-03 17:48:23 -070097}
98
Kinson Chik18e36332011-08-15 10:07:28 -070099unsigned target_get_max_flash_size(void)
100{
Kinson Chik28283082011-10-03 17:48:23 -0700101 return (SIZE_23M);
Kinson Chik18e36332011-08-15 10:07:28 -0700102}