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_rev(void) - extract version info
41 ******************************************/
47 * On ES1.0 the IDCODE register is not exposed on L4
48 * so using CPU ID to differentiate
49 * between ES2.0 and ES1.0.
51 __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r"(cpuid));
52 if ((cpuid & 0xf) == 0x0)
59 /****************************************************
60 * is_mem_sdr() - return 1 if mem type in use is SDR
61 ****************************************************/
64 if (readl(&sdrc_base->cs[CS0].mr) == SDP_SDRC_MR_0_SDR)
69 /***********************************************************************
70 * get_cs0_size() - get size of chip select 0/1
71 ************************************************************************/
72 u32 get_sdr_cs_size(u32 cs)
76 /* get ram size field */
77 size = readl(&sdrc_base->cs[cs].mcfg) >> 8;
78 size &= 0x3FF; /* remove unwanted bits */
79 size *= SZ_2M; /* find size in MB */
83 /***********************************************************************
84 * get_sdr_cs_offset() - get offset of cs from cs0 start
85 ************************************************************************/
86 u32 get_sdr_cs_offset(u32 cs)
93 offset = readl(&sdrc_base->cs_cfg);
94 offset = (offset & 15) << 27 | (offset & 0x30) >> 17;
99 /***********************************************************************
100 * get_board_type() - get board type based on current production stats.
101 * - NOTE-1-: 2 I2C EEPROMs will someday be populated with proper info.
102 * when they are available we can get info from there. This should
103 * be correct of all known boards up until today.
104 * - NOTE-2- EEPROMs are populated but they are updated very slowly. To
105 * avoid waiting on them we will use ES version of the chip to get info.
106 * A later version of the FPGA migth solve their speed issue.
107 ************************************************************************/
108 u32 get_board_type(void)
110 if (get_cpu_rev() == CPU_3430_ES2)
111 return sysinfo.board_type_v2;
113 return sysinfo.board_type_v1;
116 /***************************************************************************
117 * get_gpmc0_base() - Return current address hardware will be
118 * fetching from. The below effectively gives what is correct, its a bit
119 * mis-leading compared to the TRM. For the most general case the mask
120 * needs to be also taken into account this does work in practice.
121 * - for u-boot we currently map:
126 ****************************************************************************/
127 u32 get_gpmc0_base(void)
131 b = readl(&gpmc_cs_base->config7);
132 b &= 0x1F; /* keep base [5:0] */
133 b = b << 24; /* ret 0x0b000000 */
137 /*******************************************************************
138 * get_gpmc0_width() - See if bus is in x8 or x16 (mainly for nand)
139 *******************************************************************/
140 u32 get_gpmc0_width(void)
145 /*************************************************************************
146 * get_board_rev() - setup to pass kernel board revision information
147 * returns:(bit[0-3] sub version, higher bit[7-4] is higher version)
148 *************************************************************************/
149 u32 get_board_rev(void)
154 /*********************************************************************
155 * display_board_info() - print banner with board info.
156 *********************************************************************/
157 void display_board_info(u32 btype)
166 switch (get_device_type()) {
183 printf("OMAP%s-%s rev %d, CPU-OPP2 L3-165MHz\n", sysinfo.cpu_string,
184 sec_s, get_cpu_rev());
185 printf("%s + %s/%s\n", sysinfo.board_string,
186 mem_s, sysinfo.nand_string);
190 /********************************************************
191 * get_base(); get upper addr of current execution
192 *******************************************************/
197 __asm__ __volatile__("mov %0, pc \n":"=r"(val)::"memory");
203 /********************************************************
204 * is_running_in_flash() - tell if currently running in
206 *******************************************************/
207 u32 is_running_in_flash(void)
210 return 1; /* in FLASH */
212 return 0; /* running in SRAM or SDRAM */
215 /********************************************************
216 * is_running_in_sram() - tell if currently running in
218 *******************************************************/
219 u32 is_running_in_sram(void)
222 return 1; /* in SRAM */
224 return 0; /* running in FLASH or SDRAM */
227 /********************************************************
228 * is_running_in_sdram() - tell if currently running in
230 *******************************************************/
231 u32 is_running_in_sdram(void)
234 return 1; /* in SDRAM */
236 return 0; /* running in SRAM or FLASH */
239 /***************************************************************
240 * get_boot_type() - Is this an XIP type device or a stream one
241 * bits 4-0 specify type. Bit 5 says mem/perif
242 ***************************************************************/
243 u32 get_boot_type(void)
245 return (readl(&ctrl_base->status) & SYSBOOT_MASK);
248 /*************************************************************
249 * get_device_type(): tell if GP/HS/EMU/TST
250 *************************************************************/
251 u32 get_device_type(void)
253 return ((readl(&ctrl_base->status) & (DEVICE_MASK)) >> 8);