3 * Texas Instruments, <www.ti.com>
4 * Richard Woodruff <r-woodruff2@ti.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 #include <asm/arch/omap2420.h>
25 #include <asm/arch/bits.h>
26 #include <asm/arch/mem.h> /* get mem tables */
27 #include <asm/arch/sys_proto.h>
28 #include <asm/arch/sys_info.h>
31 /**************************************************************************
32 * get_prod_id() - get id info from chips
33 ***************************************************************************/
34 static u32 get_prod_id(void)
37 p = __raw_readl(PRODUCTION_ID); /* get production ID */
38 return((p & CPU_242X_PID_MASK) >> 16);
41 /**************************************************************************
42 * get_cpu_type() - low level get cpu type
44 * - just looking to say if this is a 2422 or 2420 or ...
45 * - to start with we will look at switch settings..
46 * - 2422 id's same as 2420 for ES1 will rely on H4 board characteristics
47 * (mux for 2420, non-mux for 2422).
48 ***************************************************************************/
49 u32 get_cpu_type(void)
53 switch(get_prod_id()){
55 case 2: return(CPU_2420); break; /* 2420 pop */
56 case 4: return(CPU_2422); break;
57 case 8: return(CPU_2423); break;
58 default: break; /* early 2420/2422's unmarked */
61 v = __raw_readl(TAP_IDCODE_REG);
62 v &= CPU_24XX_ID_MASK;
63 if (v == CPU_2420_CHIPID) { /* currently 2420 and 2422 have same id */
64 if (is_gpmc_muxed() == GPMC_MUXED) /* if mux'ed */
69 return(CPU_2420); /* don't know, say 2420 */
72 /******************************************
73 * get_cpu_rev(void) - extract version info
74 ******************************************/
78 v = __raw_readl(TAP_IDCODE_REG);
80 return(v+1); /* currently 2422 and 2420 match up */
82 /****************************************************
83 * is_mem_sdr() - return 1 if mem type in use is SDR
84 ****************************************************/
87 volatile u32 *burst = (volatile u32 *)(SDRC_MR_0+SDRC_CS0_OSET);
88 if(*burst == H4_2420_SDRC_MR_0_SDR)
93 /***********************************************************
94 * get_mem_type() - identify type of mDDR part used.
95 * 2422 uses stacked DDR, 2 parts CS0/CS1.
96 * 2420 may have 1 or 2, no good way to know...only init 1...
97 * when eeprom data is up we can select 1 more.
98 *************************************************************/
99 u32 get_mem_type(void)
101 u32 cpu, sdr = is_mem_sdr();
103 cpu = get_cpu_type();
104 if (cpu == CPU_2422 || cpu == CPU_2423)
107 if(get_prod_id() == 0x2)
110 if (get_board_type() == BOARD_H4_MENELAUS)
112 return(SDR_DISCRETE);
116 if(sdr) /* SDP + SDR kit */
117 return(SDR_DISCRETE);
119 return(DDR_DISCRETE); /* origional SDP */
122 /***********************************************************************
123 * get_cs0_size() - get size of chip select 0/1
124 ************************************************************************/
125 u32 get_sdr_cs_size(u32 offset)
128 size = __raw_readl(SDRC_MCFG_0+offset) >> 8; /* get ram size field */
129 size &= 0x2FF; /* remove unwanted bits */
130 size *= SZ_2M; /* find size in MB */
134 /***********************************************************************
135 * get_board_type() - get board type based on current production stats.
136 * --- NOTE: 2 I2C EEPROMs will someday be populated with proper info.
137 * when they are available we can get info from there. This should
138 * be correct of all known boards up until today.
139 ************************************************************************/
140 u32 get_board_type(void)
142 if (i2c_probe(I2C_MENELAUS) == 0)
143 return(BOARD_H4_MENELAUS);
145 return(BOARD_H4_SDP);
148 /******************************************************************
149 * get_sysboot_value() - get init word settings (dip switch on h4)
150 ******************************************************************/
151 inline u32 get_sysboot_value(void)
153 return(0x00000FFF & __raw_readl(CONTROL_STATUS));
156 /***************************************************************************
157 * get_gpmc0_base() - Return current address hardware will be
158 * fetching from. The below effectively gives what is correct, its a bit
159 * mis-leading compared to the TRM. For the most general case the mask
160 * needs to be also taken into account this does work in practice.
161 * - for u-boot we currently map:
166 ****************************************************************************/
167 u32 get_gpmc0_base(void)
171 b = __raw_readl(GPMC_CONFIG7_0);
172 b &= 0x1F; /* keep base [5:0] */
173 b = b << 24; /* ret 0x0b000000 */
177 /*****************************************************************
178 * is_gpmc_muxed() - tells if address/data lines are multiplexed
179 *****************************************************************/
180 u32 is_gpmc_muxed(void)
183 mux = get_sysboot_value();
184 if ((mux & (BIT0 | BIT1 | BIT2 | BIT3)) == (BIT0 | BIT2 | BIT3))
185 return(GPMC_MUXED); /* NAND Boot mode */
186 if (mux & BIT1) /* if mux'ed */
189 return(GPMC_NONMUXED);
192 /************************************************************************
193 * get_gpmc0_type() - read sysboot lines to see type of memory attached
194 ************************************************************************/
195 u32 get_gpmc0_type(void)
198 type = get_sysboot_value();
199 if ((type & (BIT3|BIT2)) == (BIT3|BIT2))
205 /*******************************************************************
206 * get_gpmc0_width() - See if bus is in x8 or x16 (mainly for nand)
207 *******************************************************************/
208 u32 get_gpmc0_width(void)
211 width = get_sysboot_value();
212 if ((width & 0xF) == (BIT3|BIT2))
218 /*********************************************************************
219 * wait_on_value() - common routine to allow waiting for changes in
221 *********************************************************************/
222 u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
227 val = __raw_readl(read_addr) & read_bit_mask;
228 if (val == match_value)
235 /*********************************************************************
236 * display_board_info() - print banner with board info.
237 *********************************************************************/
238 void display_board_info(u32 btype)
240 char cpu_2420[] = "2420"; /* cpu type */
241 char cpu_2422[] = "2422";
242 char cpu_2423[] = "2423";
243 char db_men[] = "Menelaus"; /* board type */
245 char mem_sdr[] = "mSDR"; /* memory type */
246 char mem_ddr[] = "mDDR";
247 char t_tst[] = "TST"; /* security level */
248 char t_emu[] = "EMU";
253 char *cpu_s, *db_s, *mem_s, *sec_s;
257 cpu = get_cpu_type();
258 sec = get_device_type();
267 else if (cpu == CPU_2422)
272 if(btype == BOARD_H4_MENELAUS)
278 case TST_DEVICE: sec_s = t_tst; break;
279 case EMU_DEVICE: sec_s = t_emu; break;
280 case HS_DEVICE: sec_s = t_hs; break;
281 case GP_DEVICE: sec_s = t_gp; break;
282 default: sec_s = unk;
285 printf("OMAP%s-%s revision %d\n", cpu_s, sec_s, rev-1);
286 printf("TI H4 SDP Base Board + %s Daughter Board + %s \n", db_s, mem_s);
289 /*************************************************************************
290 * get_board_rev() - setup to pass kernel board revision information
291 * 0 = 242x IP platform (first 2xx boards)
292 * 1 = 242x Menelaus platfrom.
293 *************************************************************************/
294 u32 get_board_rev(void)
297 u32 btype = get_board_type();
299 if (btype == BOARD_H4_MENELAUS){
305 /********************************************************
306 * get_base(); get upper addr of current execution
307 *******************************************************/
311 __asm__ __volatile__("mov %0, pc \n" : "=r" (val) : : "memory");
317 /********************************************************
318 * get_base2(); get 2upper addr of current execution
319 *******************************************************/
323 __asm__ __volatile__("mov %0, pc \n" : "=r" (val) : : "memory");
329 /********************************************************
330 * running_in_flash() - tell if currently running in
332 *******************************************************/
333 u32 running_in_flash(void)
336 return(1); /* in flash */
337 return(0); /* running in SRAM or SDRAM */
340 /********************************************************
341 * running_in_sram() - tell if currently running in
343 *******************************************************/
344 u32 running_in_sram(void)
347 return(1); /* in SRAM */
348 return(0); /* running in FLASH or SDRAM */
350 /********************************************************
351 * running_in_sdram() - tell if currently running in
353 *******************************************************/
354 u32 running_in_sdram(void)
357 return(1); /* in sdram */
358 return(0); /* running in SRAM or FLASH */
361 /*************************************************************
362 * running_from_internal_boot() - am I a signed NOR image.
363 *************************************************************/
364 u32 running_from_internal_boot(void)
368 v = get_sysboot_value() & BIT3;
370 /* if running at mask rom flash address and
371 * sysboot3 says this was an internal boot
373 if ((base == 0x08) && v)
379 /*************************************************************
380 * get_device_type(): tell if GP/HS/EMU/TST
381 *************************************************************/
382 u32 get_device_type(void)
385 mode = __raw_readl(CONTROL_STATUS) & (BIT10|BIT9|BIT8);