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);
42 /**************************************************************************
43 * get_cpu_type() - low level get cpu type
45 * - just looking to say if this is a 2422 or 2420 or ...
46 * - to start with we will look at switch settings..
47 * - 2422 id's same as 2420 for ES1 will rely on H4 board characteristics
48 * (mux for 2420, non-mux for 2422).
49 ***************************************************************************/
50 u32 get_cpu_type(void)
54 switch (get_prod_id()) {
66 break; /* early 2420/2422's unmarked */
69 v = __raw_readl(TAP_IDCODE_REG);
70 v &= CPU_24XX_ID_MASK;
71 if (v == CPU_2420_CHIPID) { /* currently 2420 and 2422 have same id */
72 if (is_gpmc_muxed() == GPMC_MUXED) /* if mux'ed */
77 return (CPU_2420); /* don't know, say 2420 */
80 /******************************************
81 * get_cpu_rev(void) - extract version info
82 ******************************************/
86 v = __raw_readl(TAP_IDCODE_REG);
88 return (v + 1); /* currently 2422 and 2420 match up */
91 /****************************************************
92 * is_mem_sdr() - return 1 if mem type in use is SDR
93 ****************************************************/
96 volatile u32 *burst = (volatile u32 *)(SDRC_MR_0 + SDRC_CS0_OSET);
97 if (*burst == H4_2420_SDRC_MR_0_SDR)
102 /***********************************************************
103 * get_mem_type() - identify type of mDDR part used.
104 * 2422 uses stacked DDR, 2 parts CS0/CS1.
105 * 2420 may have 1 or 2, no good way to know...only init 1...
106 * when eeprom data is up we can select 1 more.
107 *************************************************************/
108 u32 get_mem_type(void)
110 u32 cpu, sdr = is_mem_sdr();
112 cpu = get_cpu_type();
113 if (cpu == CPU_2422 || cpu == CPU_2423)
114 return (DDR_STACKED);
116 if (get_prod_id() == 0x2)
119 if (get_board_type() == BOARD_H4_MENELAUS)
121 return (SDR_DISCRETE);
124 else if (sdr) /* SDP + SDR kit */
125 return (SDR_DISCRETE);
127 return (DDR_DISCRETE); /* origional SDP */
130 /**********************************************************************
132 * get_cs0_size() - get size of chip select 0/1
133 ************************************************************************/
134 u32 get_sdr_cs_size(u32 offset)
137 size = __raw_readl(SDRC_MCFG_0 + offset) >> 8; /* get ram size field */
138 size &= 0x2FF; /* remove unwanted bits */
139 size *= SZ_2M; /* find size in MB */
143 /**********************************************************************
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)
153 if (i2c_probe(I2C_MENELAUS) == 0)
154 return (BOARD_H4_MENELAUS);
157 return (BOARD_H4_SDP);
160 /******************************************************************
161 * get_sysboot_value() - get init word settings (dip switch on h4)
162 ******************************************************************/
163 inline u32 get_sysboot_value(void)
165 return (0x00000FFF & __raw_readl(CONTROL_STATUS));
168 /***************************************************************************
169 * get_gpmc0_base() - Return current address hardware will be
170 * fetching from. The below effectively gives what is correct, its a bit
171 * mis-leading compared to the TRM. For the most general case the mask
172 * needs to be also taken into account this does work in practice.
173 * - for u-boot we currently map:
178 ***************************************************************************/
179 u32 get_gpmc0_base(void)
183 b = __raw_readl(GPMC_CONFIG7_0);
184 b &= 0x1F; /* keep base [5:0] */
185 b = b << 24; /* ret 0x0b000000 */
189 /*****************************************************************
190 * is_gpmc_muxed() - tells if address/data lines are multiplexed
191 *****************************************************************/
192 u32 is_gpmc_muxed(void)
195 mux = get_sysboot_value();
196 if ((mux & (BIT0 | BIT1 | BIT2 | BIT3)) == (BIT0 | BIT2 | BIT3))
197 return (GPMC_MUXED); /* NAND Boot mode */
198 if (mux & BIT1) /* if mux'ed */
201 return (GPMC_NONMUXED);
204 /************************************************************************
205 * get_gpmc0_type() - read sysboot lines to see type of memory attached
206 ************************************************************************/
207 u32 get_gpmc0_type(void)
210 type = get_sysboot_value();
211 if ((type & (BIT3 | BIT2)) == (BIT3 | BIT2))
217 /*******************************************************************
218 * get_gpmc0_width() - See if bus is in x8 or x16 (mainly for nand)
219 *******************************************************************/
220 u32 get_gpmc0_width(void)
223 width = get_sysboot_value();
224 if ((width & 0xF) == (BIT3 | BIT2))
227 return (WIDTH_16BIT);
230 /*********************************************************************
231 * wait_on_value() - common routine to allow waiting for changes in
233 *********************************************************************/
234 u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr,
239 val = __raw_readl(read_addr) & read_bit_mask;
240 if (val == match_value)
247 /*********************************************************************
248 * display_board_info() - print banner with board info.
249 *********************************************************************/
250 void display_board_info(u32 btype)
252 char cpu_2420[] = "2420"; /* cpu type */
253 char cpu_2422[] = "2422";
254 char cpu_2423[] = "2423";
255 char db_men[] = "Menelaus"; /* board type */
257 char mem_sdr[] = "mSDR"; /* memory type */
258 char mem_ddr[] = "mDDR";
259 char t_tst[] = "TST"; /* security level */
260 char t_emu[] = "EMU";
265 char *cpu_s, *db_s, *mem_s, *sec_s;
269 cpu = get_cpu_type();
270 sec = get_device_type();
279 else if (cpu == CPU_2422)
284 if (btype == BOARD_H4_MENELAUS)
306 printf("OMAP%s-%s revision %d\n", cpu_s, sec_s, rev - 1);
307 printf("Samsung Apollon SDP Base Board + %s \n", mem_s); }
309 /*************************************************************************
310 * get_board_rev() - setup to pass kernel board revision information
311 * 0 = 242x IP platform (first 2xx boards)
312 * 1 = 242x Menelaus platfrom.
313 *************************************************************************/
314 u32 get_board_rev(void)
317 u32 btype = get_board_type();
319 if (btype == BOARD_H4_MENELAUS) {
325 /********************************************************
326 * get_base(); get upper addr of current execution
327 *******************************************************/
331 __asm__ __volatile__("mov %0, pc \n":"=r"(val)::"memory");
337 /********************************************************
338 * get_base2(); get 2upper addr of current execution
339 *******************************************************/
343 __asm__ __volatile__("mov %0, pc \n":"=r"(val)::"memory");
349 /********************************************************
350 * running_in_flash() - tell if currently running in
352 *******************************************************/
353 u32 running_in_flash(void)
356 return (1); /* in flash */
357 return (0); /* running in SRAM or SDRAM */
360 /********************************************************
361 * running_in_sram() - tell if currently running in
363 *******************************************************/
364 u32 running_in_sram(void)
367 return (1); /* in SRAM */
368 return (0); /* running in FLASH or SDRAM */
371 /********************************************************
372 * running_in_sdram() - tell if currently running in
374 *******************************************************/
375 u32 running_in_sdram(void)
378 return (1); /* in sdram */
379 return (0); /* running in SRAM or FLASH */
382 /*************************************************************
383 * running_from_internal_boot() - am I a signed NOR image.
384 *************************************************************/
385 u32 running_from_internal_boot(void)
389 v = get_sysboot_value() & BIT3;
391 /* if running at mask rom flash address and
392 * sysboot3 says this was an internal boot
394 if ((base == 0x08) && v)
400 /*************************************************************
401 * get_device_type(): tell if GP/HS/EMU/TST
402 *************************************************************/
403 u32 get_device_type(void)
406 mode = __raw_readl(CONTROL_STATUS) & (BIT10 | BIT9 | BIT8);