]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - cpu/arm_cortexa8/omap3/sys_info.c
OMAP3: Add OMAP3 auto detection
[karo-tx-uboot.git] / cpu / arm_cortexa8 / omap3 / sys_info.c
1 /*
2  * (C) Copyright 2008
3  * Texas Instruments, <www.ti.com>
4  *
5  * Author :
6  *      Manikandan Pillai <mani.pillai@ti.com>
7  *
8  * Derived from Beagle Board and 3430 SDP code by
9  *      Richard Woodruff <r-woodruff2@ti.com>
10  *      Syed Mohammed Khasim <khasim@ti.com>
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License as
14  * published by the Free Software Foundation; either version 2 of
15  * the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25  * MA 02111-1307 USA
26  */
27
28 #include <common.h>
29 #include <asm/io.h>
30 #include <asm/arch/mem.h>       /* get mem tables */
31 #include <asm/arch/sys_proto.h>
32 #include <i2c.h>
33
34 extern omap3_sysinfo sysinfo;
35 static gpmc_csx_t *gpmc_cs_base = (gpmc_csx_t *)GPMC_CONFIG_CS0_BASE;
36 static sdrc_t *sdrc_base = (sdrc_t *)OMAP34XX_SDRC_BASE;
37 static ctrl_t *ctrl_base = (ctrl_t *)OMAP34XX_CTRL_BASE;
38
39 /******************************************
40  * get_cpu_type(void) - extract cpu info
41  ******************************************/
42 u32 get_cpu_type(void)
43 {
44         return readl(&ctrl_base->ctrl_omap_stat);
45 }
46
47 /******************************************
48  * get_cpu_rev(void) - extract version info
49  ******************************************/
50 u32 get_cpu_rev(void)
51 {
52         u32 cpuid = 0;
53
54         /*
55          * On ES1.0 the IDCODE register is not exposed on L4
56          * so using CPU ID to differentiate
57          * between ES2.0 and ES1.0.
58          */
59         __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r"(cpuid));
60         if ((cpuid & 0xf) == 0x0)
61                 return CPU_3430_ES1;
62         else
63                 return CPU_3430_ES2;
64
65 }
66
67 /****************************************************
68  * is_mem_sdr() - return 1 if mem type in use is SDR
69  ****************************************************/
70 u32 is_mem_sdr(void)
71 {
72         if (readl(&sdrc_base->cs[CS0].mr) == SDP_SDRC_MR_0_SDR)
73                 return 1;
74         return 0;
75 }
76
77 /***********************************************************************
78  * get_cs0_size() - get size of chip select 0/1
79  ************************************************************************/
80 u32 get_sdr_cs_size(u32 cs)
81 {
82         u32 size;
83
84         /* get ram size field */
85         size = readl(&sdrc_base->cs[cs].mcfg) >> 8;
86         size &= 0x3FF;          /* remove unwanted bits */
87         size *= SZ_2M;          /* find size in MB */
88         return size;
89 }
90
91 /***********************************************************************
92  * get_sdr_cs_offset() - get offset of cs from cs0 start
93  ************************************************************************/
94 u32 get_sdr_cs_offset(u32 cs)
95 {
96         u32 offset;
97
98         if (!cs)
99                 return 0;
100
101         offset = readl(&sdrc_base->cs_cfg);
102         offset = (offset & 15) << 27 | (offset & 0x30) >> 17;
103
104         return offset;
105 }
106
107 /***********************************************************************
108  * get_board_type() - get board type based on current production stats.
109  *  - NOTE-1-: 2 I2C EEPROMs will someday be populated with proper info.
110  *    when they are available we can get info from there.  This should
111  *    be correct of all known boards up until today.
112  *  - NOTE-2- EEPROMs are populated but they are updated very slowly.  To
113  *    avoid waiting on them we will use ES version of the chip to get info.
114  *    A later version of the FPGA migth solve their speed issue.
115  ************************************************************************/
116 u32 get_board_type(void)
117 {
118         if (get_cpu_rev() == CPU_3430_ES2)
119                 return sysinfo.board_type_v2;
120         else
121                 return sysinfo.board_type_v1;
122 }
123
124 /***************************************************************************
125  *  get_gpmc0_base() - Return current address hardware will be
126  *     fetching from. The below effectively gives what is correct, its a bit
127  *   mis-leading compared to the TRM.  For the most general case the mask
128  *   needs to be also taken into account this does work in practice.
129  *   - for u-boot we currently map:
130  *       -- 0 to nothing,
131  *       -- 4 to flash
132  *       -- 8 to enent
133  *       -- c to wifi
134  ****************************************************************************/
135 u32 get_gpmc0_base(void)
136 {
137         u32 b;
138
139         b = readl(&gpmc_cs_base->config7);
140         b &= 0x1F;              /* keep base [5:0] */
141         b = b << 24;            /* ret 0x0b000000 */
142         return b;
143 }
144
145 /*******************************************************************
146  * get_gpmc0_width() - See if bus is in x8 or x16 (mainly for nand)
147  *******************************************************************/
148 u32 get_gpmc0_width(void)
149 {
150         return WIDTH_16BIT;
151 }
152
153 /*************************************************************************
154  * get_board_rev() - setup to pass kernel board revision information
155  * returns:(bit[0-3] sub version, higher bit[7-4] is higher version)
156  *************************************************************************/
157 u32 get_board_rev(void)
158 {
159         return 0x20;
160 }
161
162 /*********************************************************************
163  *  display_board_info() - print banner with board info.
164  *********************************************************************/
165 void display_board_info(u32 btype)
166 {
167         char *cpu_s, *mem_s, *sec_s;
168
169         switch (get_cpu_type()) {
170         case OMAP3503:
171                 cpu_s = "3503";
172                 break;
173         case OMAP3515:
174                 cpu_s = "3515";
175                 break;
176         case OMAP3525:
177                 cpu_s = "3525";
178                 break;
179         case OMAP3530:
180                 cpu_s = "3530";
181                 break;
182         default:
183                 cpu_s = "35XX";
184                 break;
185         }
186
187         if (is_mem_sdr())
188                 mem_s = "mSDR";
189         else
190                 mem_s = "LPDDR";
191
192         switch (get_device_type()) {
193         case TST_DEVICE:
194                 sec_s = "TST";
195                 break;
196         case EMU_DEVICE:
197                 sec_s = "EMU";
198                 break;
199         case HS_DEVICE:
200                 sec_s = "HS";
201                 break;
202         case GP_DEVICE:
203                 sec_s = "GP";
204                 break;
205         default:
206                 sec_s = "?";
207         }
208
209
210         printf("OMAP%s-%s rev %d, CPU-OPP2 L3-165MHz\n", cpu_s,
211                sec_s, get_cpu_rev());
212         printf("%s + %s/%s\n", sysinfo.board_string,
213                mem_s, sysinfo.nand_string);
214
215 }
216
217 /********************************************************
218  *  get_base(); get upper addr of current execution
219  *******************************************************/
220 u32 get_base(void)
221 {
222         u32 val;
223
224         __asm__ __volatile__("mov %0, pc \n":"=r"(val)::"memory");
225         val &= 0xF0000000;
226         val >>= 28;
227         return val;
228 }
229
230 /********************************************************
231  *  is_running_in_flash() - tell if currently running in
232  *  FLASH.
233  *******************************************************/
234 u32 is_running_in_flash(void)
235 {
236         if (get_base() < 4)
237                 return 1;       /* in FLASH */
238
239         return 0;               /* running in SRAM or SDRAM */
240 }
241
242 /********************************************************
243  *  is_running_in_sram() - tell if currently running in
244  *  SRAM.
245  *******************************************************/
246 u32 is_running_in_sram(void)
247 {
248         if (get_base() == 4)
249                 return 1;       /* in SRAM */
250
251         return 0;               /* running in FLASH or SDRAM */
252 }
253
254 /********************************************************
255  *  is_running_in_sdram() - tell if currently running in
256  *  SDRAM.
257  *******************************************************/
258 u32 is_running_in_sdram(void)
259 {
260         if (get_base() > 4)
261                 return 1;       /* in SDRAM */
262
263         return 0;               /* running in SRAM or FLASH */
264 }
265
266 /***************************************************************
267  *  get_boot_type() - Is this an XIP type device or a stream one
268  *  bits 4-0 specify type. Bit 5 says mem/perif
269  ***************************************************************/
270 u32 get_boot_type(void)
271 {
272         return (readl(&ctrl_base->status) & SYSBOOT_MASK);
273 }
274
275 /*************************************************************
276  *  get_device_type(): tell if GP/HS/EMU/TST
277  *************************************************************/
278 u32 get_device_type(void)
279 {
280         return ((readl(&ctrl_base->status) & (DEVICE_MASK)) >> 8);
281 }