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_cpu_type() - low level get cpu type
34 * - just looking to say if this is a 2422 or 2420 or ...
35 * - to start with we will look at switch settings..
36 * - 2422 id's same as 2420 for ES1 will rely on H4 board characteristics
37 * (mux for 2420, non-mux for 2422).
38 ***************************************************************************/
39 u32 get_cpu_type(void)
43 v = __raw_readl(TAP_IDCODE_REG);
44 v &= CPU_24XX_ID_MASK;
45 if (v == CPU_2420_CHIPID) { /* currently 2420 and 2422 have same id */
46 if (is_gpmc_muxed() == GPMC_MUXED) /* if mux'ed */
51 return(CPU_2420); /* don't know, say 2420 */
54 /******************************************
55 * get_cpu_rev(void) - extract version info
56 ******************************************/
60 v = __raw_readl(TAP_IDCODE_REG);
62 return(v+1); /* currently 2422 and 2420 match up */
65 /***********************************************************
66 * get_mem_type() - identify type of mDDR part used.
67 * 2422 uses stacked DDR, 2 parts CS0/CS1.
68 * 2420 may have 1 or 2, no good way to know...only init 1...
69 * when eeprom data is up we can select 1 more.
70 *************************************************************/
71 u32 get_mem_type(void)
73 volatile u32 *burst = (volatile u32 *)(SDRC_MR_0+SDRC_CS0_OSET);
75 if (get_cpu_type() == CPU_2422)
78 if (get_board_type() == BOARD_H4_MENELAUS)
79 if(*burst == H4_2420_SDRC_MR_0_SDR)
84 if(*burst == H4_2420_SDRC_MR_0_SDR) /* SDP + SDR kit */
87 return(DDR_DISCRETE); /* origional SDP */
90 /***********************************************************************
91 * get_board_type() - get board type based on current production stats.
92 * --- NOTE: 2 I2C EEPROMs will someday be populated with proper info.
93 * when they are available we can get info from there. This should
94 * be correct of all known boards up until today.
95 ************************************************************************/
96 u32 get_board_type(void)
98 if (i2c_probe(I2C_MENELAUS) == 0)
99 return(BOARD_H4_MENELAUS);
101 return(BOARD_H4_SDP);
104 /******************************************************************
105 * get_sysboot_value() - get init word settings (dip switch on h4)
106 ******************************************************************/
107 u32 get_sysboot_value(void)
109 return(0x00000FFF & __raw_readl(CONTROL_STATUS));
112 /***************************************************************************
113 * get_gpmc0_base() - Return current address hardware will be
114 * fetching from. The below effectively gives what is correct, its a bit
115 * mis-leading compared to the TRM. For the most general case the mask
116 * needs to be also taken into account this does work in practice.
117 * - for u-boot we currently map:
122 ****************************************************************************/
123 u32 get_gpmc0_base(void)
127 b = __raw_readl(GPMC_CONFIG7_0);
128 b &= 0x1F; /* keep base [5:0] */
129 b = b << 24; /* ret 0x0b000000 */
133 /*****************************************************************
134 * is_gpmc_muxed() - tells if address/data lines are multiplexed
135 *****************************************************************/
136 u32 is_gpmc_muxed(void)
139 mux = get_sysboot_value();
140 if ((mux & (BIT0 | BIT1 | BIT2 | BIT3)) == (BIT0 | BIT2 | BIT3))
141 return(GPMC_MUXED); /* NAND Boot mode */
142 if (mux & BIT1) /* if mux'ed */
145 return(GPMC_NONMUXED);
148 /************************************************************************
149 * get_gpmc0_type() - read sysboot lines to see type of memory attached
150 ************************************************************************/
151 u32 get_gpmc0_type(void)
154 type = get_sysboot_value();
155 if ((type & (BIT3|BIT2)) == (BIT3|BIT2))
161 /*******************************************************************
162 * get_gpmc0_width() - See if bus is in x8 or x16 (mainly for nand)
163 *******************************************************************/
164 u32 get_gpmc0_width(void)
167 width = get_sysboot_value();
168 if ((width & 0xF) == (BIT3|BIT2))
174 /*********************************************************************
175 * wait_on_value() - common routine to allow waiting for changes in
177 *********************************************************************/
178 u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
183 val = __raw_readl(read_addr) & read_bit_mask;
184 if (val == match_value)
191 /*********************************************************************
192 * display_board_info() - print banner with board info.
193 *********************************************************************/
194 void display_board_info(u32 btype)
196 char cpu_2420[] = "2420";
197 char cpu_2422[] = "2422";
198 char db_men[] = "Menelaus";
201 u32 cpu = get_cpu_type();
207 if(btype == BOARD_H4_MENELAUS)
211 printf("TI H4 SDP Base Board with OMAP%s %s Daughter Board\n",cpu_s, db_s);
214 /*************************************************************************
215 * get_board_rev() - setup to pass kernel board revision information
216 * 0 = 242x IP platform (first 2xx boards)
217 * 1 = 242x Menelaus platfrom.
218 *************************************************************************/
219 u32 get_board_rev(void)
222 u32 btype = get_board_type();
224 if (btype == BOARD_H4_MENELAUS){
230 /********************************************************
231 * get_base(); get upper addr of current execution
232 *******************************************************/
233 static u32 get_base(void)
236 __asm__ __volatile__("mov %0, pc \n" : "=r" (val) : : "memory");
242 /********************************************************
243 * get_base2(); get 2upper addr of current execution
244 *******************************************************/
245 static u32 get_base2(void)
248 __asm__ __volatile__("mov %0, pc \n" : "=r" (val) : : "memory");
254 /********************************************************
255 * running_in_flash() - tell if currently running in
257 *******************************************************/
258 u32 running_in_flash(void)
261 return(1); /* in flash */
262 return(0); /* running in SRAM or SDRAM */
265 /********************************************************
266 * running_in_sram() - tell if currently running in
268 *******************************************************/
269 u32 running_in_sram(void)
272 return(1); /* in SRAM */
273 return(0); /* running in FLASH or SDRAM */
275 /********************************************************
276 * running_in_sdram() - tell if currently running in
278 *******************************************************/
279 u32 running_in_sdram(void)
282 return(1); /* in sdram */
283 return(0); /* running in SRAM or FLASH */
286 /*************************************************************
287 * running_from_internal_boot() - am I a signed NOR image.
288 *************************************************************/
289 u32 running_from_internal_boot(void)
293 v = get_sysboot_value() & BIT3;
295 /* if running at mask rom flash address and
296 * sysboot3 says this was an internal boot
298 if ((base == 0x08) && v)