2 * (C) Copyright 2005-2007
4 * Kyungmin Park <kyungmin.park@samsung.com>
6 * Derived from omap2420
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 #include <asm/arch/omap2420.h>
27 #include <asm/arch/bits.h>
28 #include <asm/arch/mem.h> /* get mem tables */
29 #include <asm/arch/sys_proto.h>
30 #include <asm/arch/sys_info.h>
33 /**************************************************************************
34 * get_prod_id() - get id info from chips
35 ***************************************************************************/
36 static u32 get_prod_id(void)
39 p = __raw_readl(PRODUCTION_ID); /* get production ID */
40 return ((p & CPU_242X_PID_MASK) >> 16);
43 /**************************************************************************
44 * get_cpu_type() - low level get cpu type
46 * - just looking to say if this is a 2422 or 2420 or ...
47 * - to start with we will look at switch settings..
48 * - 2422 id's same as 2420 for ES1 will rely on H4 board characteristics
49 * (mux for 2420, non-mux for 2422).
50 ***************************************************************************/
51 u32 get_cpu_type(void)
55 switch (get_prod_id()) {
67 break; /* early 2420/2422's unmarked */
70 v = __raw_readl(TAP_IDCODE_REG);
71 v &= CPU_24XX_ID_MASK;
72 /* currently 2420 and 2422 have same id */
73 if (v == CPU_2420_CHIPID) {
74 if (is_gpmc_muxed() == GPMC_MUXED) /* if mux'ed */
79 return (CPU_2420); /* don't know, say 2420 */
82 /******************************************
83 * get_cpu_rev(void) - extract version info
84 ******************************************/
88 v = __raw_readl(TAP_IDCODE_REG);
90 return (v + 1); /* currently 2422 and 2420 match up */
93 /****************************************************
94 * is_mem_sdr() - return 1 if mem type in use is SDR
95 ****************************************************/
98 volatile u32 *burst = (volatile u32 *)(SDRC_MR_0 + SDRC_CS0_OSET);
99 if (*burst == H4_2420_SDRC_MR_0_SDR)
104 /***********************************************************
105 * get_mem_type() - identify type of mDDR part used.
106 * 2422 uses stacked DDR, 2 parts CS0/CS1.
107 * 2420 may have 1 or 2, no good way to know...only init 1...
108 * when eeprom data is up we can select 1 more.
109 *************************************************************/
110 u32 get_mem_type(void)
112 u32 cpu, sdr = is_mem_sdr();
114 cpu = get_cpu_type();
115 if (cpu == CPU_2422 || cpu == CPU_2423)
116 return (DDR_STACKED);
118 if (get_prod_id() == 0x2)
121 if (get_board_type() == BOARD_H4_MENELAUS)
123 return (SDR_DISCRETE);
126 else if (sdr) /* SDP + SDR kit */
127 return (SDR_DISCRETE);
129 return (DDR_DISCRETE); /* origional SDP */
132 /***********************************************************************
133 * get_cs0_size() - get size of chip select 0/1
134 ************************************************************************/
135 u32 get_sdr_cs_size(u32 offset)
138 size = __raw_readl(SDRC_MCFG_0 + offset) >> 8; /* get ram size field */
139 size &= 0x2FF; /* remove unwanted bits */
140 size *= SZ_2M; /* find size in MB */
144 /***********************************************************************
145 * get_board_type() - get board type based on current production stats.
146 * --- NOTE: 2 I2C EEPROMs will someday be populated with proper info.
147 * when they are available we can get info from there. This should
148 * be correct of all known boards up until today.
149 ************************************************************************/
150 u32 get_board_type(void)
152 return (BOARD_H4_SDP);
155 /******************************************************************
156 * get_sysboot_value() - get init word settings (dip switch on h4)
157 ******************************************************************/
158 inline u32 get_sysboot_value(void)
160 return (0x00000FFF & __raw_readl(CONTROL_STATUS));
163 /***************************************************************************
164 * get_gpmc0_base() - Return current address hardware will be
165 * fetching from. The below effectively gives what is correct, its a bit
166 * mis-leading compared to the TRM. For the most general case the mask
167 * needs to be also taken into account this does work in practice.
168 * - for u-boot we currently map:
173 ****************************************************************************/
174 u32 get_gpmc0_base(void)
178 b = __raw_readl(GPMC_CONFIG7_0);
179 b &= 0x1F; /* keep base [5:0] */
180 b = b << 24; /* ret 0x0b000000 */
184 /*****************************************************************
185 * is_gpmc_muxed() - tells if address/data lines are multiplexed
186 *****************************************************************/
187 u32 is_gpmc_muxed(void)
190 mux = get_sysboot_value();
191 if ((mux & (BIT0 | BIT1 | BIT2 | BIT3)) == (BIT0 | BIT2 | BIT3))
192 return (GPMC_MUXED); /* NAND Boot mode */
193 if (mux & BIT1) /* if mux'ed */
196 return (GPMC_NONMUXED);
199 /************************************************************************
200 * get_gpmc0_type() - read sysboot lines to see type of memory attached
201 ************************************************************************/
202 u32 get_gpmc0_type(void)
205 type = get_sysboot_value();
206 if ((type & (BIT3 | BIT2)) == (BIT3 | BIT2))
212 /*******************************************************************
213 * get_gpmc0_width() - See if bus is in x8 or x16 (mainly for nand)
214 *******************************************************************/
215 u32 get_gpmc0_width(void)
218 width = get_sysboot_value();
219 if ((width & 0xF) == (BIT3 | BIT2))
222 return (WIDTH_16BIT);
225 /*********************************************************************
226 * wait_on_value() - common routine to allow waiting for changes in
228 *********************************************************************/
229 u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
234 val = __raw_readl(read_addr) & read_bit_mask;
235 if (val == match_value)
242 /*********************************************************************
243 * display_board_info() - print banner with board info.
244 *********************************************************************/
245 void display_board_info(u32 btype)
247 char cpu_2420[] = "2420"; /* cpu type */
248 char cpu_2422[] = "2422";
249 char cpu_2423[] = "2423";
250 char db_men[] = "Menelaus"; /* board type */
252 char mem_sdr[] = "mSDR"; /* memory type */
253 char mem_ddr[] = "mDDR";
254 char t_tst[] = "TST"; /* security level */
255 char t_emu[] = "EMU";
260 char *cpu_s, *db_s, *mem_s, *sec_s;
264 cpu = get_cpu_type();
265 sec = get_device_type();
274 else if (cpu == CPU_2422)
279 if (btype == BOARD_H4_MENELAUS)
301 printf("OMAP%s-%s revision %d\n", cpu_s, sec_s, rev - 1);
302 printf("Samsung Apollon SDP Base Board + %s \n", mem_s);
305 /*************************************************************************
306 * get_board_rev() - setup to pass kernel board revision information
307 * 0 = 242x IP platform (first 2xx boards)
308 * 1 = 242x Menelaus platfrom.
309 *************************************************************************/
310 u32 get_board_rev(void)
313 u32 btype = get_board_type();
315 if (btype == BOARD_H4_MENELAUS)
320 /********************************************************
321 * get_base(); get upper addr of current execution
322 *******************************************************/
326 __asm__ __volatile__("mov %0, pc \n":"=r"(val)::"memory");
332 /********************************************************
333 * get_base2(); get 2upper addr of current execution
334 *******************************************************/
338 __asm__ __volatile__("mov %0, pc \n":"=r"(val)::"memory");
344 /********************************************************
345 * running_in_flash() - tell if currently running in
347 *******************************************************/
348 u32 running_in_flash(void)
351 return (1); /* in flash */
352 return (0); /* running in SRAM or SDRAM */
355 /********************************************************
356 * running_in_sram() - tell if currently running in
358 *******************************************************/
359 u32 running_in_sram(void)
362 return (1); /* in SRAM */
363 return (0); /* running in FLASH or SDRAM */
366 /********************************************************
367 * running_in_sdram() - tell if currently running in
369 *******************************************************/
370 u32 running_in_sdram(void)
373 return (1); /* in sdram */
374 return (0); /* running in SRAM or FLASH */
377 /*************************************************************
378 * running_from_internal_boot() - am I a signed NOR image.
379 *************************************************************/
380 u32 running_from_internal_boot(void)
384 v = get_sysboot_value() & BIT3;
386 /* if running at mask rom flash address and
387 * sysboot3 says this was an internal boot
389 if ((base == 0x08) && v)
395 /*************************************************************
396 * get_device_type(): tell if GP/HS/EMU/TST
397 *************************************************************/
398 u32 get_device_type(void)
401 mode = __raw_readl(CONTROL_STATUS) & (BIT10 | BIT9 | BIT8);