3 * Texas Instruments, <www.ti.com>
6 * Manikandan Pillai <mani.pillai@ti.com>
8 * Derived from Beagle Board and 3430 SDP code by
9 * Richard Woodruff <r-woodruff2@ti.com>
10 * Syed Mohammed Khasim <khasim@ti.com>
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.
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.
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,
30 #include <asm/arch/mem.h> /* get mem tables */
31 #include <asm/arch/sys_proto.h>
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;
39 /******************************************
40 * get_cpu_type(void) - extract cpu info
41 ******************************************/
42 u32 get_cpu_type(void)
44 return readl(&ctrl_base->ctrl_omap_stat);
47 /******************************************
48 * get_cpu_rev(void) - extract version info
49 ******************************************/
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.
59 __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r"(cpuid));
60 if ((cpuid & 0xf) == 0x0)
67 /****************************************************
68 * is_mem_sdr() - return 1 if mem type in use is SDR
69 ****************************************************/
72 if (readl(&sdrc_base->cs[CS0].mr) == SDP_SDRC_MR_0_SDR)
77 /***********************************************************************
78 * get_cs0_size() - get size of chip select 0/1
79 ************************************************************************/
80 u32 get_sdr_cs_size(u32 cs)
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 */
91 /***********************************************************************
92 * get_sdr_cs_offset() - get offset of cs from cs0 start
93 ************************************************************************/
94 u32 get_sdr_cs_offset(u32 cs)
101 offset = readl(&sdrc_base->cs_cfg);
102 offset = (offset & 15) << 27 | (offset & 0x30) >> 17;
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)
118 if (get_cpu_rev() == CPU_3430_ES2)
119 return sysinfo.board_type_v2;
121 return sysinfo.board_type_v1;
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:
134 ****************************************************************************/
135 u32 get_gpmc0_base(void)
139 b = readl(&gpmc_cs_base->config7);
140 b &= 0x1F; /* keep base [5:0] */
141 b = b << 24; /* ret 0x0b000000 */
145 /*******************************************************************
146 * get_gpmc0_width() - See if bus is in x8 or x16 (mainly for nand)
147 *******************************************************************/
148 u32 get_gpmc0_width(void)
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)
162 /*********************************************************************
163 * display_board_info() - print banner with board info.
164 *********************************************************************/
165 void display_board_info(u32 btype)
167 char *cpu_s, *mem_s, *sec_s;
169 switch (get_cpu_type()) {
192 switch (get_device_type()) {
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);
217 /********************************************************
218 * get_base(); get upper addr of current execution
219 *******************************************************/
224 __asm__ __volatile__("mov %0, pc \n":"=r"(val)::"memory");
230 /********************************************************
231 * is_running_in_flash() - tell if currently running in
233 *******************************************************/
234 u32 is_running_in_flash(void)
237 return 1; /* in FLASH */
239 return 0; /* running in SRAM or SDRAM */
242 /********************************************************
243 * is_running_in_sram() - tell if currently running in
245 *******************************************************/
246 u32 is_running_in_sram(void)
249 return 1; /* in SRAM */
251 return 0; /* running in FLASH or SDRAM */
254 /********************************************************
255 * is_running_in_sdram() - tell if currently running in
257 *******************************************************/
258 u32 is_running_in_sdram(void)
261 return 1; /* in SDRAM */
263 return 0; /* running in SRAM or FLASH */
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)
272 return (readl(&ctrl_base->status) & SYSBOOT_MASK);
275 /*************************************************************
276 * get_device_type(): tell if GP/HS/EMU/TST
277 *************************************************************/
278 u32 get_device_type(void)
280 return ((readl(&ctrl_base->status) & (DEVICE_MASK)) >> 8);