blob: b5fe9e392507cd4186e369b6fd6847e04dc15a3d [file] [log] [blame]
wdenk8ed96042005-01-09 23:16:25 +00001/*
2 * (C) Copyright 2004
3 * Texas Instruments, <www.ti.com>
4 * Richard Woodruff <r-woodruff2@ti.com>
5 *
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.
10 *
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.
15 *
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,
19 * MA 02111-1307 USA
20 */
21
22#include <common.h>
23#include <asm/arch/omap2420.h>
24#include <asm/io.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>
29#include <i2c.h>
30
31/**************************************************************************
32 * get_cpu_type() - low level get cpu type
33 * - no C globals yet.
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 ***************************************************************************/
39u32 get_cpu_type(void)
40{
41 u32 v;
42
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 */
47 return(CPU_2420);
48 else
49 return(CPU_2422);
50 } else
51 return(CPU_2420); /* don't know, say 2420 */
52}
53
54/******************************************
55 * get_cpu_rev(void) - extract version info
56 ******************************************/
57u32 get_cpu_rev(void)
58{
59 u32 v;
60 v = __raw_readl(TAP_IDCODE_REG);
61 v = v >> 28;
62 return(v+1); /* currently 2422 and 2420 match up */
63}
64
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 *************************************************************/
71u32 get_mem_type(void)
72{
73 if (get_cpu_type() == CPU_2422)
74 return(DDR_STACKED);
75
76 if (get_board_type() == BOARD_H4_MENELAUS)
77 return(DDR_COMBO);
78 else
79 return(DDR_DISCRETE);
80}
81
82/***********************************************************************
83 * get_board_type() - get board type based on current production stats.
84 * --- NOTE: 2 I2C EEPROMs will someday be populated with proper info.
85 * when they are available we can get info from there. This should
86 * be correct of all known boards up until today.
87 ************************************************************************/
88u32 get_board_type(void)
89{
90 if (i2c_probe(I2C_MENELAUS) == 0)
91 return(BOARD_H4_MENELAUS);
92 else
93 return(BOARD_H4_SDP);
94}
95
96/******************************************************************
97 * get_sysboot_value() - get init word settings (dip switch on h4)
98 ******************************************************************/
99u32 get_sysboot_value(void)
100{
101 return(0x00000FFF & __raw_readl(CONTROL_STATUS));
102}
103
104/***************************************************************************
105 * get_gpmc0_base() - Return current address hardware will be
106 * fetching from. The below effectively gives what is correct, its a bit
107 * mis-leading compared to the TRM. For the most general case the mask
108 * needs to be also taken into account this does work in practice.
109 * - for u-boot we currently map:
110 * -- 0 to nothing,
111 * -- 4 to flash
112 * -- 8 to enent
113 * -- c to wifi
114 ****************************************************************************/
115u32 get_gpmc0_base(void)
116{
117 u32 b;
118
119 b = __raw_readl(GPMC_CONFIG7_0);
120 b &= 0x1F; /* keep base [5:0] */
121 b = b << 24; /* ret 0x0b000000 */
122 return(b);
123}
124
125/*****************************************************************
126 * is_gpmc_muxed() - tells if address/data lines are multiplexed
127 *****************************************************************/
128u32 is_gpmc_muxed(void)
129{
130 u32 mux;
131 mux = get_sysboot_value();
132 if (mux & BIT1) /* if mux'ed */
133 return(GPMC_MUXED);
134 else
135 return(GPMC_NONMUXED);
136}
137
138/************************************************************************
139 * get_gpmc0_type() - read sysboot lines to see type of memory attached
140 ************************************************************************/
141u32 get_gpmc0_type(void)
142{
143 u32 type;
144 type = get_sysboot_value();
145 if ((type & (BIT3|BIT2)) == (BIT3|BIT2))
146 return(TYPE_NAND);
147 else
148 return(TYPE_NOR);
149}
150
151/*******************************************************************
152 * get_gpmc0_width() - See if bus is in x8 or x16 (mainly for nand)
153 *******************************************************************/
154u32 get_gpmc0_width(void)
155{
156 u32 width;
157 width = get_sysboot_value();
158 if ((width & 0xF) == (BIT3|BIT2))
159 return(WIDTH_8BIT);
160 else
161 return(WIDTH_16BIT);
162}
163
164/*********************************************************************
165 * wait_on_value() - common routine to allow waiting for changes in
166 * volatile regs.
167 *********************************************************************/
168u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
169{
170 u32 i = 0, val;
171 do {
172 ++i;
173 val = __raw_readl(read_addr) & read_bit_mask;
174 if (val == match_value)
175 return(1);
176 if (i==bound)
177 return(0);
178 } while (1);
179}
180
181/*********************************************************************
182 * display_board_info() - print banner with board info.
183 *********************************************************************/
184void display_board_info(u32 btype)
185{
186 char cpu_2420[] = "2420";
187 char cpu_2422[] = "2422";
188 char db_men[] = "Menelaus";
189 char db_ip[]= "IP";
190 char *cpu_s, *db_s;
191 u32 cpu = get_cpu_type();
192
193 if(cpu == CPU_2420)
194 cpu_s = cpu_2420;
195 else
196 cpu_s = cpu_2422;
197 if(btype == BOARD_H4_MENELAUS)
198 db_s = db_men;
199 else
200 db_s = db_ip;
201 printf("TI H4 SDP Base Board with OMAP%s %s Daughter Board\n",cpu_s, db_s);
202}