|
1
by Oliver Grawert
Import upstream version 1.4.3git20100305 |
1 |
/*
|
2 |
* (C) Copyright 2006
|
|
3 |
* Texas Instruments, <www.ti.com>
|
|
4 |
* Jian Zhang <jzhang@ti.com>
|
|
5 |
* Richard Woodruff <r-woodruff2@ti.com>
|
|
6 |
*
|
|
7 |
* See file CREDITS for list of people who contributed to this
|
|
8 |
* project.
|
|
9 |
*
|
|
10 |
* This program is free software; you can redistribute it and/or
|
|
11 |
* modify it under the terms of the GNU General Public License as
|
|
12 |
* published by the Free Software Foundation; either version 2 of
|
|
13 |
* the License, or (at your option) any later version.
|
|
14 |
*
|
|
15 |
* This program is distributed in the hope that it will be useful,
|
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 |
* GNU General Public License for more details.
|
|
19 |
*
|
|
20 |
* You should have received a copy of the GNU General Public License
|
|
21 |
* along with this program; if not, write to the Free Software
|
|
22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
23 |
* MA 02111-1307 USA
|
|
24 |
*/
|
|
25 |
||
26 |
#include <common.h>
|
|
27 |
#include <command.h>
|
|
28 |
#include <part.h>
|
|
29 |
#include <fat.h>
|
|
30 |
#include <asm/arch/cpu.h>
|
|
31 |
#include <asm/arch/bits.h>
|
|
32 |
#include <asm/arch/mux.h>
|
|
|
1.1.1
by Oliver Grawert
Import upstream version 1.4.3git20100531 |
33 |
#include <asm/arch/gpio.h>
|
|
1
by Oliver Grawert
Import upstream version 1.4.3git20100305 |
34 |
#include <asm/arch/sys_proto.h>
|
35 |
#include <asm/arch/sys_info.h>
|
|
36 |
#include <asm/arch/clocks.h>
|
|
37 |
#include <asm/arch/mem.h>
|
|
38 |
||
|
1.1.1
by Oliver Grawert
Import upstream version 1.4.3git20100531 |
39 |
/* params for XM */
|
40 |
#define CORE_DPLL_PARAM_M2 0x09
|
|
41 |
#define CORE_DPLL_PARAM_M 0x360
|
|
42 |
#define CORE_DPLL_PARAM_N 0xC
|
|
43 |
||
44 |
/* BeagleBoard revisions */
|
|
45 |
#define REVISION_AXBX 0x7
|
|
46 |
#define REVISION_CX 0x6
|
|
47 |
#define REVISION_C4 0x5
|
|
48 |
#define REVISION_XM 0x0
|
|
49 |
||
|
1
by Oliver Grawert
Import upstream version 1.4.3git20100305 |
50 |
/* Used to index into DPLL parameter tables */
|
51 |
struct dpll_param { |
|
52 |
unsigned int m; |
|
53 |
unsigned int n; |
|
54 |
unsigned int fsel; |
|
55 |
unsigned int m2; |
|
56 |
};
|
|
57 |
||
58 |
typedef struct dpll_param dpll_param; |
|
59 |
||
60 |
/* Following functions are exported from lowlevel_init.S */
|
|
61 |
extern dpll_param *get_mpu_dpll_param(); |
|
62 |
extern dpll_param *get_iva_dpll_param(); |
|
63 |
extern dpll_param *get_core_dpll_param(); |
|
64 |
extern dpll_param *get_per_dpll_param(); |
|
65 |
||
66 |
#define __raw_readl(a) (*(volatile unsigned int *)(a))
|
|
67 |
#define __raw_writel(v, a) (*(volatile unsigned int *)(a) = (v))
|
|
68 |
#define __raw_readw(a) (*(volatile unsigned short *)(a))
|
|
69 |
#define __raw_writew(v, a) (*(volatile unsigned short *)(a) = (v))
|
|
70 |
||
71 |
/*******************************************************
|
|
72 |
* Routine: delay
|
|
73 |
* Description: spinning delay to use before udelay works
|
|
74 |
******************************************************/
|
|
75 |
static inline void delay(unsigned long loops) |
|
76 |
{
|
|
77 |
__asm__ volatile ("1:\n" "subs %0, %1, #1\n" |
|
78 |
"bne 1b":"=r" (loops):"0"(loops)); |
|
79 |
}
|
|
80 |
||
81 |
void udelay (unsigned long usecs) { |
|
82 |
delay(usecs); |
|
83 |
}
|
|
84 |
||
85 |
/*****************************************
|
|
86 |
* Routine: board_init
|
|
87 |
* Description: Early hardware init.
|
|
88 |
*****************************************/
|
|
89 |
int board_init(void) |
|
90 |
{
|
|
91 |
return 0; |
|
92 |
}
|
|
93 |
||
94 |
/*************************************************************
|
|
95 |
* get_device_type(): tell if GP/HS/EMU/TST
|
|
96 |
*************************************************************/
|
|
97 |
u32 get_device_type(void) |
|
98 |
{
|
|
99 |
int mode; |
|
100 |
mode = __raw_readl(CONTROL_STATUS) & (DEVICE_MASK); |
|
101 |
return mode >>= 8; |
|
102 |
}
|
|
103 |
||
104 |
/************************************************
|
|
105 |
* get_sysboot_value(void) - return SYS_BOOT[4:0]
|
|
106 |
************************************************/
|
|
107 |
u32 get_sysboot_value(void) |
|
108 |
{
|
|
109 |
int mode; |
|
110 |
mode = __raw_readl(CONTROL_STATUS) & (SYSBOOT_MASK); |
|
111 |
return mode; |
|
112 |
}
|
|
113 |
||
114 |
/*************************************************************
|
|
115 |
* Routine: get_mem_type(void) - returns the kind of memory connected
|
|
116 |
* to GPMC that we are trying to boot form. Uses SYS BOOT settings.
|
|
117 |
*************************************************************/
|
|
118 |
u32 get_mem_type(void) |
|
119 |
{
|
|
|
1.1.1
by Oliver Grawert
Import upstream version 1.4.3git20100531 |
120 |
|
121 |
if (beagle_revision() == REVISION_XM) |
|
122 |
return GPMC_NONE; |
|
123 |
||
|
1
by Oliver Grawert
Import upstream version 1.4.3git20100305 |
124 |
u32 mem_type = get_sysboot_value(); |
125 |
switch (mem_type) { |
|
126 |
case 0: |
|
127 |
case 2: |
|
128 |
case 4: |
|
129 |
case 16: |
|
130 |
case 22: |
|
131 |
return GPMC_ONENAND; |
|
132 |
||
133 |
case 1: |
|
134 |
case 12: |
|
135 |
case 15: |
|
136 |
case 21: |
|
137 |
case 27: |
|
138 |
return GPMC_NAND; |
|
139 |
||
140 |
case 3: |
|
141 |
case 6: |
|
142 |
return MMC_ONENAND; |
|
143 |
||
144 |
case 8: |
|
145 |
case 11: |
|
146 |
case 14: |
|
147 |
case 20: |
|
148 |
case 26: |
|
149 |
return GPMC_MDOC; |
|
150 |
||
151 |
case 17: |
|
152 |
case 18: |
|
153 |
case 24: |
|
154 |
return MMC_NAND; |
|
155 |
||
156 |
case 7: |
|
157 |
case 10: |
|
158 |
case 13: |
|
159 |
case 19: |
|
160 |
case 25: |
|
161 |
default:
|
|
162 |
return GPMC_NOR; |
|
163 |
}
|
|
164 |
}
|
|
165 |
||
166 |
/******************************************
|
|
167 |
* get_cpu_rev(void) - extract version info
|
|
168 |
******************************************/
|
|
169 |
u32 get_cpu_rev(void) |
|
170 |
{
|
|
171 |
u32 cpuid = 0; |
|
172 |
/* On ES1.0 the IDCODE register is not exposed on L4
|
|
173 |
* so using CPU ID to differentiate
|
|
174 |
* between ES2.0 and ES1.0.
|
|
175 |
*/
|
|
176 |
__asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r" (cpuid)); |
|
177 |
if ((cpuid & 0xf) == 0x0) |
|
178 |
return CPU_3430_ES1; |
|
179 |
else
|
|
180 |
return CPU_3430_ES2; |
|
181 |
||
182 |
}
|
|
183 |
||
184 |
/******************************************
|
|
185 |
* cpu_is_3410(void) - returns true for 3410
|
|
186 |
******************************************/
|
|
187 |
u32 cpu_is_3410(void) |
|
188 |
{
|
|
189 |
int status; |
|
190 |
if (get_cpu_rev() < CPU_3430_ES2) { |
|
191 |
return 0; |
|
192 |
} else { |
|
193 |
/* read scalability status and return 1 for 3410*/
|
|
194 |
status = __raw_readl(CONTROL_SCALABLE_OMAP_STATUS); |
|
195 |
/* Check whether MPU frequency is set to 266 MHz which
|
|
196 |
* is nominal for 3410. If yes return true else false
|
|
197 |
*/
|
|
198 |
if (((status >> 8) & 0x3) == 0x2) |
|
199 |
return 1; |
|
200 |
else
|
|
201 |
return 0; |
|
202 |
}
|
|
203 |
}
|
|
204 |
||
|
1.1.1
by Oliver Grawert
Import upstream version 1.4.3git20100531 |
205 |
/******************************************
|
206 |
* beagle_identify
|
|
207 |
* Description: Detect if we are running on a Beagle revision Ax/Bx,
|
|
208 |
* C1/2/3, C4 or D. This can be done by reading
|
|
209 |
* the level of GPIO173, GPIO172 and GPIO171. This should
|
|
210 |
* result in
|
|
211 |
* GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
|
|
212 |
* GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
|
|
213 |
* GPIO173, GPIO172, GPIO171: 1 0 1 => C4
|
|
214 |
* GPIO173, GPIO172, GPIO171: 0 0 0 => XM
|
|
215 |
******************************************/
|
|
216 |
int beagle_revision(void) |
|
217 |
{
|
|
218 |
int rev; |
|
219 |
||
220 |
omap_request_gpio(171); |
|
221 |
omap_request_gpio(172); |
|
222 |
omap_request_gpio(173); |
|
223 |
omap_set_gpio_direction(171, 1); |
|
224 |
omap_set_gpio_direction(172, 1); |
|
225 |
omap_set_gpio_direction(173, 1); |
|
226 |
||
227 |
rev = omap_get_gpio_datain(173) << 2 | |
|
228 |
omap_get_gpio_datain(172) << 1 | |
|
229 |
omap_get_gpio_datain(171); |
|
230 |
omap_free_gpio(171); |
|
231 |
omap_free_gpio(172); |
|
232 |
omap_free_gpio(173); |
|
233 |
||
234 |
return rev; |
|
235 |
}
|
|
236 |
||
|
1
by Oliver Grawert
Import upstream version 1.4.3git20100305 |
237 |
/*****************************************************************
|
238 |
* sr32 - clear & set a value in a bit range for a 32 bit address
|
|
239 |
*****************************************************************/
|
|
240 |
void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value) |
|
241 |
{
|
|
242 |
u32 tmp, msk = 0; |
|
243 |
msk = 1 << num_bits; |
|
244 |
--msk; |
|
245 |
tmp = __raw_readl(addr) & ~(msk << start_bit); |
|
246 |
tmp |= value << start_bit; |
|
247 |
__raw_writel(tmp, addr); |
|
248 |
}
|
|
249 |
||
250 |
/*********************************************************************
|
|
251 |
* wait_on_value() - common routine to allow waiting for changes in
|
|
252 |
* volatile regs.
|
|
253 |
*********************************************************************/
|
|
254 |
u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound) |
|
255 |
{
|
|
256 |
u32 i = 0, val; |
|
257 |
do { |
|
258 |
++i; |
|
259 |
val = __raw_readl(read_addr) & read_bit_mask; |
|
260 |
if (val == match_value) |
|
261 |
return 1; |
|
262 |
if (i == bound) |
|
263 |
return 0; |
|
264 |
} while (1); |
|
265 |
}
|
|
266 |
||
267 |
#ifdef CFG_3430SDRAM_DDR
|
|
268 |
/*********************************************************************
|
|
269 |
* config_3430sdram_ddr() - Init DDR on 3430SDP dev board.
|
|
270 |
*********************************************************************/
|
|
271 |
void config_3430sdram_ddr(void) |
|
272 |
{
|
|
273 |
/* reset sdrc controller */
|
|
274 |
__raw_writel(SOFTRESET, SDRC_SYSCONFIG); |
|
275 |
wait_on_value(BIT0, BIT0, SDRC_STATUS, 12000000); |
|
276 |
__raw_writel(0, SDRC_SYSCONFIG); |
|
277 |
||
278 |
/* setup sdrc to ball mux */
|
|
279 |
__raw_writel(SDP_SDRC_SHARING, SDRC_SHARING); |
|
280 |
||
|
1.1.1
by Oliver Grawert
Import upstream version 1.4.3git20100531 |
281 |
if (beagle_revision() == REVISION_XM) { |
282 |
__raw_writel(0x2, SDRC_CS_CFG); /* 256MB/bank */ |
|
283 |
__raw_writel(SDP_SDRC_MDCFG_0_DDR_XM, SDRC_MCFG_0); |
|
284 |
__raw_writel(SDP_SDRC_MDCFG_0_DDR_XM, SDRC_MCFG_1); |
|
285 |
__raw_writel(MICRON_V_ACTIMA_200, SDRC_ACTIM_CTRLA_0); |
|
286 |
__raw_writel(MICRON_V_ACTIMB_200, SDRC_ACTIM_CTRLB_0); |
|
287 |
__raw_writel(MICRON_V_ACTIMA_200, SDRC_ACTIM_CTRLA_1); |
|
288 |
__raw_writel(MICRON_V_ACTIMB_200, SDRC_ACTIM_CTRLB_1); |
|
289 |
__raw_writel(SDP_3430_SDRC_RFR_CTRL_200MHz, SDRC_RFR_CTRL_0); |
|
290 |
__raw_writel(SDP_3430_SDRC_RFR_CTRL_200MHz, SDRC_RFR_CTRL_1); |
|
291 |
} else { |
|
292 |
__raw_writel(0x1, SDRC_CS_CFG); /* 128MB/bank */ |
|
293 |
__raw_writel(SDP_SDRC_MDCFG_0_DDR, SDRC_MCFG_0); |
|
294 |
__raw_writel(SDP_SDRC_MDCFG_0_DDR, SDRC_MCFG_1); |
|
295 |
__raw_writel(MICRON_V_ACTIMA_165, SDRC_ACTIM_CTRLA_0); |
|
296 |
__raw_writel(MICRON_V_ACTIMB_165, SDRC_ACTIM_CTRLB_0); |
|
297 |
__raw_writel(MICRON_V_ACTIMA_165, SDRC_ACTIM_CTRLA_1); |
|
298 |
__raw_writel(MICRON_V_ACTIMB_165, SDRC_ACTIM_CTRLB_1); |
|
299 |
__raw_writel(SDP_3430_SDRC_RFR_CTRL_165MHz, SDRC_RFR_CTRL_0); |
|
300 |
__raw_writel(SDP_3430_SDRC_RFR_CTRL_165MHz, SDRC_RFR_CTRL_1); |
|
301 |
}
|
|
302 |
||
|
1
by Oliver Grawert
Import upstream version 1.4.3git20100305 |
303 |
__raw_writel(SDP_SDRC_POWER_POP, SDRC_POWER); |
304 |
||
305 |
/* init sequence for mDDR/mSDR using manual commands (DDR is different) */
|
|
306 |
__raw_writel(CMD_NOP, SDRC_MANUAL_0); |
|
|
1.1.1
by Oliver Grawert
Import upstream version 1.4.3git20100531 |
307 |
__raw_writel(CMD_NOP, SDRC_MANUAL_1); |
308 |
||
|
1
by Oliver Grawert
Import upstream version 1.4.3git20100305 |
309 |
delay(5000); |
|
1.1.1
by Oliver Grawert
Import upstream version 1.4.3git20100531 |
310 |
|
|
1
by Oliver Grawert
Import upstream version 1.4.3git20100305 |
311 |
__raw_writel(CMD_PRECHARGE, SDRC_MANUAL_0); |
|
1.1.1
by Oliver Grawert
Import upstream version 1.4.3git20100531 |
312 |
__raw_writel(CMD_PRECHARGE, SDRC_MANUAL_1); |
313 |
||
314 |
__raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_0); |
|
315 |
__raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_1); |
|
316 |
||
317 |
__raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_0); |
|
318 |
__raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_1); |
|
|
1
by Oliver Grawert
Import upstream version 1.4.3git20100305 |
319 |
|
320 |
/* set mr0 */
|
|
321 |
__raw_writel(SDP_SDRC_MR_0_DDR, SDRC_MR_0); |
|
|
1.1.1
by Oliver Grawert
Import upstream version 1.4.3git20100531 |
322 |
__raw_writel(SDP_SDRC_MR_0_DDR, SDRC_MR_1); |
|
1
by Oliver Grawert
Import upstream version 1.4.3git20100305 |
323 |
|
324 |
/* set up dll */
|
|
325 |
__raw_writel(SDP_SDRC_DLLAB_CTRL, SDRC_DLLA_CTRL); |
|
326 |
delay(0x2000); /* give time to lock */ |
|
327 |
||
328 |
}
|
|
329 |
#endif /* CFG_3430SDRAM_DDR */ |
|
330 |
||
331 |
/*************************************************************
|
|
332 |
* get_sys_clk_speed - determine reference oscillator speed
|
|
333 |
* based on known 32kHz clock and gptimer.
|
|
334 |
*************************************************************/
|
|
335 |
u32 get_osc_clk_speed(void) |
|
336 |
{
|
|
|
1.1.1
by Oliver Grawert
Import upstream version 1.4.3git20100531 |
337 |
u32 start, cstart, cend, cdiff, cdiv, val; |
|
1
by Oliver Grawert
Import upstream version 1.4.3git20100305 |
338 |
|
339 |
val = __raw_readl(PRM_CLKSRC_CTRL); |
|
|
1.1.1
by Oliver Grawert
Import upstream version 1.4.3git20100531 |
340 |
|
341 |
if (val & SYSCLKDIV_2) |
|
342 |
cdiv = 2; |
|
343 |
else
|
|
344 |
cdiv = 1; |
|
|
1
by Oliver Grawert
Import upstream version 1.4.3git20100305 |
345 |
|
346 |
/* enable timer2 */
|
|
347 |
val = __raw_readl(CM_CLKSEL_WKUP) | BIT0; |
|
348 |
__raw_writel(val, CM_CLKSEL_WKUP); /* select sys_clk for GPT1 */ |
|
349 |
||
350 |
/* Enable I and F Clocks for GPT1 */
|
|
351 |
val = __raw_readl(CM_ICLKEN_WKUP) | BIT0 | BIT2; |
|
352 |
__raw_writel(val, CM_ICLKEN_WKUP); |
|
353 |
val = __raw_readl(CM_FCLKEN_WKUP) | BIT0; |
|
354 |
__raw_writel(val, CM_FCLKEN_WKUP); |
|
355 |
||
356 |
__raw_writel(0, OMAP34XX_GPT1 + TLDR); /* start counting at 0 */ |
|
357 |
__raw_writel(GPT_EN, OMAP34XX_GPT1 + TCLR); /* enable clock */ |
|
358 |
/* enable 32kHz source */
|
|
359 |
/* enabled out of reset */
|
|
360 |
/* determine sys_clk via gauging */
|
|
361 |
||
362 |
start = 20 + __raw_readl(S32K_CR); /* start time in 20 cycles */ |
|
363 |
while (__raw_readl(S32K_CR) < start) ; /* dead loop till start time */ |
|
364 |
cstart = __raw_readl(OMAP34XX_GPT1 + TCRR); /* get start sys_clk count */ |
|
365 |
while (__raw_readl(S32K_CR) < (start + 20)) ; /* wait for 40 cycles */ |
|
366 |
cend = __raw_readl(OMAP34XX_GPT1 + TCRR); /* get end sys_clk count */ |
|
367 |
cdiff = cend - cstart; /* get elapsed ticks */ |
|
|
1.1.1
by Oliver Grawert
Import upstream version 1.4.3git20100531 |
368 |
cdiff *= cdiv; |
|
1
by Oliver Grawert
Import upstream version 1.4.3git20100305 |
369 |
|
370 |
/* based on number of ticks assign speed */
|
|
371 |
if (cdiff > 19000) |
|
372 |
return S38_4M; |
|
373 |
else if (cdiff > 15200) |
|
374 |
return S26M; |
|
375 |
else if (cdiff > 13000) |
|
376 |
return S24M; |
|
377 |
else if (cdiff > 9000) |
|
378 |
return S19_2M; |
|
379 |
else if (cdiff > 7600) |
|
380 |
return S13M; |
|
381 |
else
|
|
382 |
return S12M; |
|
383 |
}
|
|
384 |
||
385 |
/******************************************************************************
|
|
386 |
* get_sys_clkin_sel() - returns the sys_clkin_sel field value based on
|
|
387 |
* -- input oscillator clock frequency.
|
|
388 |
*
|
|
389 |
*****************************************************************************/
|
|
390 |
void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel) |
|
391 |
{
|
|
392 |
if (osc_clk == S38_4M) |
|
393 |
*sys_clkin_sel = 4; |
|
394 |
else if (osc_clk == S26M) |
|
395 |
*sys_clkin_sel = 3; |
|
396 |
else if (osc_clk == S19_2M) |
|
397 |
*sys_clkin_sel = 2; |
|
398 |
else if (osc_clk == S13M) |
|
399 |
*sys_clkin_sel = 1; |
|
400 |
else if (osc_clk == S12M) |
|
401 |
*sys_clkin_sel = 0; |
|
402 |
}
|
|
403 |
||
404 |
/******************************************************************************
|
|
405 |
* prcm_init() - inits clocks for PRCM as defined in clocks.h
|
|
406 |
* -- called from SRAM, or Flash (using temp SRAM stack).
|
|
407 |
*****************************************************************************/
|
|
408 |
void prcm_init(void) |
|
409 |
{
|
|
410 |
u32 osc_clk = 0, sys_clkin_sel; |
|
411 |
dpll_param *dpll_param_p; |
|
412 |
u32 clk_index, sil_index; |
|
413 |
||
414 |
/* Gauge the input clock speed and find out the sys_clkin_sel
|
|
415 |
* value corresponding to the input clock.
|
|
416 |
*/
|
|
417 |
osc_clk = get_osc_clk_speed(); |
|
418 |
get_sys_clkin_sel(osc_clk, &sys_clkin_sel); |
|
419 |
||
420 |
sr32(PRM_CLKSEL, 0, 3, sys_clkin_sel); /* set input crystal speed */ |
|
421 |
||
422 |
/* If the input clock is greater than 19.2M always divide/2 */
|
|
423 |
if (sys_clkin_sel > 2) { |
|
424 |
sr32(PRM_CLKSRC_CTRL, 6, 2, 2); /* input clock divider */ |
|
425 |
clk_index = sys_clkin_sel / 2; |
|
426 |
} else { |
|
427 |
sr32(PRM_CLKSRC_CTRL, 6, 2, 1); /* input clock divider */ |
|
428 |
clk_index = sys_clkin_sel; |
|
429 |
}
|
|
430 |
||
431 |
sr32(PRM_CLKSRC_CTRL, 0, 2, 0);/* Bypass mode: T2 inputs a square clock */ |
|
432 |
||
433 |
/* The DPLL tables are defined according to sysclk value and
|
|
434 |
* silicon revision. The clk_index value will be used to get
|
|
435 |
* the values for that input sysclk from the DPLL param table
|
|
436 |
* and sil_index will get the values for that SysClk for the
|
|
437 |
* appropriate silicon rev.
|
|
438 |
*/
|
|
439 |
sil_index = get_cpu_rev() - 1; |
|
440 |
||
441 |
/* Unlock MPU DPLL (slows things down, and needed later) */
|
|
442 |
sr32(CM_CLKEN_PLL_MPU, 0, 3, PLL_LOW_POWER_BYPASS); |
|
443 |
wait_on_value(BIT0, 0, CM_IDLEST_PLL_MPU, LDELAY); |
|
444 |
||
445 |
/* Getting the base address of Core DPLL param table */
|
|
446 |
dpll_param_p = (dpll_param *) get_core_dpll_param(); |
|
447 |
/* Moving it to the right sysclk and ES rev base */
|
|
448 |
dpll_param_p = dpll_param_p + 3 * clk_index + sil_index; |
|
449 |
/* CORE DPLL */
|
|
450 |
/* sr32(CM_CLKSEL2_EMU) set override to work when asleep */
|
|
451 |
sr32(CM_CLKEN_PLL, 0, 3, PLL_FAST_RELOCK_BYPASS); |
|
452 |
wait_on_value(BIT0, 0, CM_IDLEST_CKGEN, LDELAY); |
|
453 |
||
454 |
/* For 3430 ES1.0 Errata 1.50, default value directly doesnt
|
|
455 |
work. write another value and then default value. */
|
|
456 |
sr32(CM_CLKSEL1_EMU, 16, 5, CORE_M3X2 + 1); /* m3x2 */ |
|
457 |
sr32(CM_CLKSEL1_EMU, 16, 5, CORE_M3X2); /* m3x2 */ |
|
458 |
sr32(CM_CLKSEL1_PLL, 27, 2, dpll_param_p->m2); /* Set M2 */ |
|
459 |
sr32(CM_CLKSEL1_PLL, 16, 11, dpll_param_p->m); /* Set M */ |
|
460 |
sr32(CM_CLKSEL1_PLL, 8, 7, dpll_param_p->n); /* Set N */ |
|
461 |
sr32(CM_CLKSEL1_PLL, 6, 1, 0); /* 96M Src */ |
|
462 |
sr32(CM_CLKSEL_CORE, 8, 4, CORE_SSI_DIV); /* ssi */ |
|
463 |
sr32(CM_CLKSEL_CORE, 4, 2, CORE_FUSB_DIV); /* fsusb */ |
|
464 |
sr32(CM_CLKSEL_CORE, 2, 2, CORE_L4_DIV); /* l4 */ |
|
465 |
sr32(CM_CLKSEL_CORE, 0, 2, CORE_L3_DIV); /* l3 */ |
|
466 |
sr32(CM_CLKSEL_GFX, 0, 3, GFX_DIV); /* gfx */ |
|
467 |
sr32(CM_CLKSEL_WKUP, 1, 2, WKUP_RSM); /* reset mgr */ |
|
468 |
sr32(CM_CLKEN_PLL, 4, 4, dpll_param_p->fsel); /* FREQSEL */ |
|
469 |
sr32(CM_CLKEN_PLL, 0, 3, PLL_LOCK); /* lock mode */ |
|
470 |
wait_on_value(BIT0, 1, CM_IDLEST_CKGEN, LDELAY); |
|
471 |
||
472 |
/* Getting the base address to PER DPLL param table */
|
|
473 |
dpll_param_p = (dpll_param *) get_per_dpll_param(); |
|
474 |
/* Moving it to the right sysclk base */
|
|
475 |
dpll_param_p = dpll_param_p + clk_index; |
|
476 |
/* PER DPLL */
|
|
477 |
sr32(CM_CLKEN_PLL, 16, 3, PLL_STOP); |
|
478 |
wait_on_value(BIT1, 0, CM_IDLEST_CKGEN, LDELAY); |
|
479 |
sr32(CM_CLKSEL1_EMU, 24, 5, PER_M6X2); /* set M6 */ |
|
480 |
sr32(CM_CLKSEL_CAM, 0, 5, PER_M5X2); /* set M5 */ |
|
481 |
sr32(CM_CLKSEL_DSS, 0, 5, PER_M4X2); /* set M4 */ |
|
482 |
sr32(CM_CLKSEL_DSS, 8, 5, PER_M3X2); /* set M3 */ |
|
|
1.1.1
by Oliver Grawert
Import upstream version 1.4.3git20100531 |
483 |
|
484 |
if (beagle_revision() == REVISION_XM) { |
|
485 |
sr32(CM_CLKSEL3_PLL, 0, 5, CORE_DPLL_PARAM_M2); /* set M2 */ |
|
486 |
sr32(CM_CLKSEL2_PLL, 8, 11, CORE_DPLL_PARAM_M); /* set m */ |
|
487 |
sr32(CM_CLKSEL2_PLL, 0, 7, CORE_DPLL_PARAM_N); /* set n */ |
|
488 |
} else { |
|
489 |
sr32(CM_CLKSEL3_PLL, 0, 5, dpll_param_p->m2); /* set M2 */ |
|
490 |
sr32(CM_CLKSEL2_PLL, 8, 11, dpll_param_p->m); /* set m */ |
|
491 |
sr32(CM_CLKSEL2_PLL, 0, 7, dpll_param_p->n); /* set n */ |
|
492 |
}
|
|
493 |
||
|
1
by Oliver Grawert
Import upstream version 1.4.3git20100305 |
494 |
sr32(CM_CLKEN_PLL, 20, 4, dpll_param_p->fsel); /* FREQSEL */ |
495 |
sr32(CM_CLKEN_PLL, 16, 3, PLL_LOCK); /* lock mode */ |
|
496 |
wait_on_value(BIT1, 2, CM_IDLEST_CKGEN, LDELAY); |
|
497 |
||
498 |
/* Getting the base address to MPU DPLL param table */
|
|
499 |
dpll_param_p = (dpll_param *) get_mpu_dpll_param(); |
|
500 |
||
501 |
/* Moving it to the right sysclk and ES rev base */
|
|
502 |
dpll_param_p = dpll_param_p + 3 * clk_index + sil_index; |
|
503 |
||
504 |
/* MPU DPLL (unlocked already) */
|
|
505 |
sr32(CM_CLKSEL2_PLL_MPU, 0, 5, dpll_param_p->m2); /* Set M2 */ |
|
506 |
sr32(CM_CLKSEL1_PLL_MPU, 8, 11, dpll_param_p->m); /* Set M */ |
|
507 |
sr32(CM_CLKSEL1_PLL_MPU, 0, 7, dpll_param_p->n); /* Set N */ |
|
508 |
sr32(CM_CLKEN_PLL_MPU, 4, 4, dpll_param_p->fsel); /* FREQSEL */ |
|
509 |
sr32(CM_CLKEN_PLL_MPU, 0, 3, PLL_LOCK); /* lock mode */ |
|
510 |
wait_on_value(BIT0, 1, CM_IDLEST_PLL_MPU, LDELAY); |
|
511 |
||
512 |
/* Getting the base address to IVA DPLL param table */
|
|
513 |
dpll_param_p = (dpll_param *) get_iva_dpll_param(); |
|
514 |
/* Moving it to the right sysclk and ES rev base */
|
|
515 |
dpll_param_p = dpll_param_p + 3 * clk_index + sil_index; |
|
516 |
/* IVA DPLL (set to 12*20=240MHz) */
|
|
517 |
sr32(CM_CLKEN_PLL_IVA2, 0, 3, PLL_STOP); |
|
518 |
wait_on_value(BIT0, 0, CM_IDLEST_PLL_IVA2, LDELAY); |
|
519 |
sr32(CM_CLKSEL2_PLL_IVA2, 0, 5, dpll_param_p->m2); /* set M2 */ |
|
520 |
sr32(CM_CLKSEL1_PLL_IVA2, 8, 11, dpll_param_p->m); /* set M */ |
|
521 |
sr32(CM_CLKSEL1_PLL_IVA2, 0, 7, dpll_param_p->n); /* set N */ |
|
522 |
sr32(CM_CLKEN_PLL_IVA2, 4, 4, dpll_param_p->fsel); /* FREQSEL */ |
|
523 |
sr32(CM_CLKEN_PLL_IVA2, 0, 3, PLL_LOCK); /* lock mode */ |
|
524 |
wait_on_value(BIT0, 1, CM_IDLEST_PLL_IVA2, LDELAY); |
|
525 |
||
526 |
/* Set up GPTimers to sys_clk source only */
|
|
527 |
sr32(CM_CLKSEL_PER, 0, 8, 0xff); |
|
528 |
sr32(CM_CLKSEL_WKUP, 0, 1, 1); |
|
529 |
||
530 |
delay(5000); |
|
531 |
}
|
|
532 |
||
533 |
/*****************************************
|
|
534 |
* Routine: secure_unlock
|
|
535 |
* Description: Setup security registers for access
|
|
536 |
* (GP Device only)
|
|
537 |
*****************************************/
|
|
538 |
void secure_unlock(void) |
|
539 |
{
|
|
540 |
/* Permission values for registers -Full fledged permissions to all */
|
|
541 |
#define UNLOCK_1 0xFFFFFFFF
|
|
542 |
#define UNLOCK_2 0x00000000
|
|
543 |
#define UNLOCK_3 0x0000FFFF
|
|
544 |
/* Protection Module Register Target APE (PM_RT) */
|
|
545 |
__raw_writel(UNLOCK_1, RT_REQ_INFO_PERMISSION_1); |
|
546 |
__raw_writel(UNLOCK_1, RT_READ_PERMISSION_0); |
|
547 |
__raw_writel(UNLOCK_1, RT_WRITE_PERMISSION_0); |
|
548 |
__raw_writel(UNLOCK_2, RT_ADDR_MATCH_1); |
|
549 |
||
550 |
__raw_writel(UNLOCK_3, GPMC_REQ_INFO_PERMISSION_0); |
|
551 |
__raw_writel(UNLOCK_3, GPMC_READ_PERMISSION_0); |
|
552 |
__raw_writel(UNLOCK_3, GPMC_WRITE_PERMISSION_0); |
|
553 |
||
554 |
__raw_writel(UNLOCK_3, OCM_REQ_INFO_PERMISSION_0); |
|
555 |
__raw_writel(UNLOCK_3, OCM_READ_PERMISSION_0); |
|
556 |
__raw_writel(UNLOCK_3, OCM_WRITE_PERMISSION_0); |
|
557 |
__raw_writel(UNLOCK_2, OCM_ADDR_MATCH_2); |
|
558 |
||
559 |
/* IVA Changes */
|
|
560 |
__raw_writel(UNLOCK_3, IVA2_REQ_INFO_PERMISSION_0); |
|
561 |
__raw_writel(UNLOCK_3, IVA2_READ_PERMISSION_0); |
|
562 |
__raw_writel(UNLOCK_3, IVA2_WRITE_PERMISSION_0); |
|
563 |
||
564 |
__raw_writel(UNLOCK_1, SMS_RG_ATT0); /* SDRC region 0 public */ |
|
565 |
}
|
|
566 |
||
567 |
/**********************************************************
|
|
568 |
* Routine: try_unlock_sram()
|
|
569 |
* Description: If chip is GP type, unlock the SRAM for
|
|
570 |
* general use.
|
|
571 |
***********************************************************/
|
|
572 |
void try_unlock_memory(void) |
|
573 |
{
|
|
574 |
int mode; |
|
575 |
||
576 |
/* if GP device unlock device SRAM for general use */
|
|
577 |
/* secure code breaks for Secure/Emulation device - HS/E/T */
|
|
578 |
mode = get_device_type(); |
|
579 |
if (mode == GP_DEVICE) |
|
580 |
secure_unlock(); |
|
581 |
return; |
|
582 |
}
|
|
583 |
||
584 |
/**********************************************************
|
|
585 |
* Routine: s_init
|
|
586 |
* Description: Does early system init of muxing and clocks.
|
|
587 |
* - Called at time when only stack is available.
|
|
588 |
**********************************************************/
|
|
589 |
||
590 |
void s_init(void) |
|
591 |
{
|
|
592 |
watchdog_init(); |
|
593 |
#ifdef CONFIG_3430_AS_3410
|
|
594 |
/* setup the scalability control register for
|
|
595 |
* 3430 to work in 3410 mode
|
|
596 |
*/
|
|
597 |
__raw_writel(0x5ABF, CONTROL_SCALABLE_OMAP_OCP); |
|
598 |
#endif
|
|
599 |
try_unlock_memory(); |
|
600 |
set_muxconf_regs(); |
|
601 |
delay(100); |
|
|
1.1.1
by Oliver Grawert
Import upstream version 1.4.3git20100531 |
602 |
per_clocks_enable(); |
|
1
by Oliver Grawert
Import upstream version 1.4.3git20100305 |
603 |
prcm_init(); |
604 |
config_3430sdram_ddr(); |
|
605 |
}
|
|
606 |
||
607 |
/*******************************************************
|
|
608 |
* Routine: misc_init_r
|
|
609 |
* Description: Init ethernet (done here so udelay works)
|
|
610 |
********************************************************/
|
|
611 |
int misc_init_r(void) |
|
612 |
{
|
|
|
1.1.1
by Oliver Grawert
Import upstream version 1.4.3git20100531 |
613 |
int rev; |
614 |
||
615 |
rev = beagle_revision(); |
|
616 |
switch (rev) { |
|
617 |
case REVISION_AXBX: |
|
618 |
printf("Beagle Rev Ax/Bx\n"); |
|
619 |
break; |
|
620 |
case REVISION_CX: |
|
621 |
printf("Beagle Rev C1/C2/C3\n"); |
|
622 |
break; |
|
623 |
case REVISION_C4: |
|
624 |
printf("Beagle Rev C4\n"); |
|
625 |
break; |
|
626 |
case REVISION_XM: |
|
627 |
printf("Beagle xM Rev A\n"); |
|
628 |
break; |
|
629 |
default:
|
|
630 |
printf("Beagle unknown 0x%02x\n", rev); |
|
631 |
}
|
|
632 |
||
|
1
by Oliver Grawert
Import upstream version 1.4.3git20100305 |
633 |
return 0; |
634 |
}
|
|
635 |
||
636 |
/******************************************************
|
|
637 |
* Routine: wait_for_command_complete
|
|
638 |
* Description: Wait for posting to finish on watchdog
|
|
639 |
******************************************************/
|
|
640 |
void wait_for_command_complete(unsigned int wd_base) |
|
641 |
{
|
|
642 |
int pending = 1; |
|
643 |
do { |
|
644 |
pending = __raw_readl(wd_base + WWPS); |
|
645 |
} while (pending); |
|
646 |
}
|
|
647 |
||
648 |
/****************************************
|
|
649 |
* Routine: watchdog_init
|
|
650 |
* Description: Shut down watch dogs
|
|
651 |
*****************************************/
|
|
652 |
void watchdog_init(void) |
|
653 |
{
|
|
654 |
/* There are 3 watch dogs WD1=Secure, WD2=MPU, WD3=IVA. WD1 is
|
|
655 |
* either taken care of by ROM (HS/EMU) or not accessible (GP).
|
|
656 |
* We need to take care of WD2-MPU or take a PRCM reset. WD3
|
|
657 |
* should not be running and does not generate a PRCM reset.
|
|
658 |
*/
|
|
659 |
sr32(CM_FCLKEN_WKUP, 5, 1, 1); |
|
660 |
sr32(CM_ICLKEN_WKUP, 5, 1, 1); |
|
661 |
wait_on_value(BIT5, 0x20, CM_IDLEST_WKUP, 5); /* some issue here */ |
|
662 |
||
663 |
__raw_writel(WD_UNLOCK1, WD2_BASE + WSPR); |
|
664 |
wait_for_command_complete(WD2_BASE); |
|
665 |
__raw_writel(WD_UNLOCK2, WD2_BASE + WSPR); |
|
666 |
}
|
|
667 |
||
668 |
/**********************************************
|
|
669 |
* Routine: dram_init
|
|
670 |
* Description: sets uboots idea of sdram size
|
|
671 |
**********************************************/
|
|
672 |
int dram_init(void) |
|
673 |
{
|
|
674 |
return 0; |
|
675 |
}
|
|
676 |
||
677 |
/*****************************************************************
|
|
678 |
* Routine: peripheral_enable
|
|
679 |
* Description: Enable the clks & power for perifs (GPT2, UART1,...)
|
|
680 |
******************************************************************/
|
|
681 |
void per_clocks_enable(void) |
|
682 |
{
|
|
683 |
/* Enable GP2 timer. */
|
|
684 |
sr32(CM_CLKSEL_PER, 0, 1, 0x1); /* GPT2 = sys clk */ |
|
685 |
sr32(CM_ICLKEN_PER, 3, 1, 0x1); /* ICKen GPT2 */ |
|
686 |
sr32(CM_FCLKEN_PER, 3, 1, 0x1); /* FCKen GPT2 */ |
|
687 |
||
688 |
#ifdef CFG_NS16550
|
|
689 |
/* UART1 clocks */
|
|
690 |
sr32(CM_FCLKEN1_CORE, 13, 1, 0x1); |
|
691 |
sr32(CM_ICLKEN1_CORE, 13, 1, 0x1); |
|
692 |
||
693 |
/* UART 3 Clocks */
|
|
694 |
sr32(CM_FCLKEN_PER, 11, 1, 0x1); |
|
695 |
sr32(CM_ICLKEN_PER, 11, 1, 0x1); |
|
696 |
||
697 |
#endif
|
|
698 |
||
699 |
#ifdef CONFIG_DRIVER_OMAP34XX_I2C
|
|
700 |
/* Turn on all 3 I2C clocks */
|
|
701 |
sr32(CM_FCLKEN1_CORE, 15, 3, 0x7); |
|
702 |
sr32(CM_ICLKEN1_CORE, 15, 3, 0x7); /* I2C1,2,3 = on */ |
|
703 |
#endif
|
|
704 |
||
705 |
/* Enable the ICLK for 32K Sync Timer as its used in udelay */
|
|
706 |
sr32(CM_ICLKEN_WKUP, 2, 1, 0x1); |
|
707 |
||
708 |
sr32(CM_FCLKEN_IVA2, 0, 32, FCK_IVA2_ON); |
|
709 |
sr32(CM_FCLKEN1_CORE, 0, 32, FCK_CORE1_ON); |
|
710 |
sr32(CM_ICLKEN1_CORE, 0, 32, ICK_CORE1_ON); |
|
711 |
sr32(CM_ICLKEN2_CORE, 0, 32, ICK_CORE2_ON); |
|
712 |
sr32(CM_FCLKEN_WKUP, 0, 32, FCK_WKUP_ON); |
|
713 |
sr32(CM_ICLKEN_WKUP, 0, 32, ICK_WKUP_ON); |
|
714 |
sr32(CM_FCLKEN_DSS, 0, 32, FCK_DSS_ON); |
|
715 |
sr32(CM_ICLKEN_DSS, 0, 32, ICK_DSS_ON); |
|
716 |
sr32(CM_FCLKEN_CAM, 0, 32, FCK_CAM_ON); |
|
717 |
sr32(CM_ICLKEN_CAM, 0, 32, ICK_CAM_ON); |
|
718 |
sr32(CM_FCLKEN_PER, 0, 32, FCK_PER_ON); |
|
719 |
sr32(CM_ICLKEN_PER, 0, 32, ICK_PER_ON); |
|
720 |
||
|
1.1.1
by Oliver Grawert
Import upstream version 1.4.3git20100531 |
721 |
/* Enable GPIO 5 & GPIO 6 clocks */
|
722 |
sr32(CM_FCLKEN_PER, 17, 2, 0x3); |
|
723 |
sr32(CM_ICLKEN_PER, 17, 2, 0x3); |
|
|
1
by Oliver Grawert
Import upstream version 1.4.3git20100305 |
724 |
|
725 |
delay(1000); |
|
726 |
}
|
|
727 |
||
728 |
/* Set MUX for UART, GPMC, SDRC, GPIO */
|
|
729 |
||
730 |
#define MUX_VAL(OFFSET,VALUE)\
|
|
731 |
__raw_writew((VALUE), OMAP34XX_CTRL_BASE + (OFFSET));
|
|
732 |
||
733 |
#define CP(x) (CONTROL_PADCONF_##x)
|
|
734 |
/*
|
|
735 |
* IEN - Input Enable
|
|
736 |
* IDIS - Input Disable
|
|
737 |
* PTD - Pull type Down
|
|
738 |
* PTU - Pull type Up
|
|
739 |
* DIS - Pull type selection is inactive
|
|
740 |
* EN - Pull type selection is active
|
|
741 |
* M0 - Mode 0
|
|
742 |
* The commented string gives the final mux configuration for that pin
|
|
743 |
*/
|
|
744 |
#define MUX_DEFAULT()\
|
|
745 |
MUX_VAL(CP(SDRC_D0), (IEN | PTD | DIS | M0)) /*SDRC_D0*/\ |
|
746 |
MUX_VAL(CP(SDRC_D1), (IEN | PTD | DIS | M0)) /*SDRC_D1*/\ |
|
747 |
MUX_VAL(CP(SDRC_D2), (IEN | PTD | DIS | M0)) /*SDRC_D2*/\ |
|
748 |
MUX_VAL(CP(SDRC_D3), (IEN | PTD | DIS | M0)) /*SDRC_D3*/\ |
|
749 |
MUX_VAL(CP(SDRC_D4), (IEN | PTD | DIS | M0)) /*SDRC_D4*/\ |
|
750 |
MUX_VAL(CP(SDRC_D5), (IEN | PTD | DIS | M0)) /*SDRC_D5*/\ |
|
751 |
MUX_VAL(CP(SDRC_D6), (IEN | PTD | DIS | M0)) /*SDRC_D6*/\ |
|
752 |
MUX_VAL(CP(SDRC_D7), (IEN | PTD | DIS | M0)) /*SDRC_D7*/\ |
|
753 |
MUX_VAL(CP(SDRC_D8), (IEN | PTD | DIS | M0)) /*SDRC_D8*/\ |
|
754 |
MUX_VAL(CP(SDRC_D9), (IEN | PTD | DIS | M0)) /*SDRC_D9*/\ |
|
755 |
MUX_VAL(CP(SDRC_D10), (IEN | PTD | DIS | M0)) /*SDRC_D10*/\ |
|
756 |
MUX_VAL(CP(SDRC_D11), (IEN | PTD | DIS | M0)) /*SDRC_D11*/\ |
|
757 |
MUX_VAL(CP(SDRC_D12), (IEN | PTD | DIS | M0)) /*SDRC_D12*/\ |
|
758 |
MUX_VAL(CP(SDRC_D13), (IEN | PTD | DIS | M0)) /*SDRC_D13*/\ |
|
759 |
MUX_VAL(CP(SDRC_D14), (IEN | PTD | DIS | M0)) /*SDRC_D14*/\ |
|
760 |
MUX_VAL(CP(SDRC_D15), (IEN | PTD | DIS | M0)) /*SDRC_D15*/\ |
|
761 |
MUX_VAL(CP(SDRC_D16), (IEN | PTD | DIS | M0)) /*SDRC_D16*/\ |
|
762 |
MUX_VAL(CP(SDRC_D17), (IEN | PTD | DIS | M0)) /*SDRC_D17*/\ |
|
763 |
MUX_VAL(CP(SDRC_D18), (IEN | PTD | DIS | M0)) /*SDRC_D18*/\ |
|
764 |
MUX_VAL(CP(SDRC_D19), (IEN | PTD | DIS | M0)) /*SDRC_D19*/\ |
|
765 |
MUX_VAL(CP(SDRC_D20), (IEN | PTD | DIS | M0)) /*SDRC_D20*/\ |
|
766 |
MUX_VAL(CP(SDRC_D21), (IEN | PTD | DIS | M0)) /*SDRC_D21*/\ |
|
767 |
MUX_VAL(CP(SDRC_D22), (IEN | PTD | DIS | M0)) /*SDRC_D22*/\ |
|
768 |
MUX_VAL(CP(SDRC_D23), (IEN | PTD | DIS | M0)) /*SDRC_D23*/\ |
|
769 |
MUX_VAL(CP(SDRC_D24), (IEN | PTD | DIS | M0)) /*SDRC_D24*/\ |
|
770 |
MUX_VAL(CP(SDRC_D25), (IEN | PTD | DIS | M0)) /*SDRC_D25*/\ |
|
771 |
MUX_VAL(CP(SDRC_D26), (IEN | PTD | DIS | M0)) /*SDRC_D26*/\ |
|
772 |
MUX_VAL(CP(SDRC_D27), (IEN | PTD | DIS | M0)) /*SDRC_D27*/\ |
|
773 |
MUX_VAL(CP(SDRC_D28), (IEN | PTD | DIS | M0)) /*SDRC_D28*/\ |
|
774 |
MUX_VAL(CP(SDRC_D29), (IEN | PTD | DIS | M0)) /*SDRC_D29*/\ |
|
775 |
MUX_VAL(CP(SDRC_D30), (IEN | PTD | DIS | M0)) /*SDRC_D30*/\ |
|
776 |
MUX_VAL(CP(SDRC_D31), (IEN | PTD | DIS | M0)) /*SDRC_D31*/\ |
|
777 |
MUX_VAL(CP(SDRC_CLK), (IEN | PTD | DIS | M0)) /*SDRC_CLK*/\ |
|
778 |
MUX_VAL(CP(SDRC_DQS0), (IEN | PTD | DIS | M0)) /*SDRC_DQS0*/\ |
|
779 |
MUX_VAL(CP(SDRC_DQS1), (IEN | PTD | DIS | M0)) /*SDRC_DQS1*/\ |
|
780 |
MUX_VAL(CP(SDRC_DQS2), (IEN | PTD | DIS | M0)) /*SDRC_DQS2*/\ |
|
781 |
MUX_VAL(CP(SDRC_DQS3), (IEN | PTD | DIS | M0)) /*SDRC_DQS3*/\ |
|
782 |
MUX_VAL(CP(GPMC_A1), (IDIS | PTD | DIS | M0)) /*GPMC_A1*/\ |
|
783 |
MUX_VAL(CP(GPMC_A2), (IDIS | PTD | DIS | M0)) /*GPMC_A2*/\ |
|
784 |
MUX_VAL(CP(GPMC_A3), (IDIS | PTD | DIS | M0)) /*GPMC_A3*/\ |
|
785 |
MUX_VAL(CP(GPMC_A4), (IDIS | PTD | DIS | M0)) /*GPMC_A4*/\ |
|
786 |
MUX_VAL(CP(GPMC_A5), (IDIS | PTD | DIS | M0)) /*GPMC_A5*/\ |
|
787 |
MUX_VAL(CP(GPMC_A6), (IDIS | PTD | DIS | M0)) /*GPMC_A6*/\ |
|
788 |
MUX_VAL(CP(GPMC_A7), (IDIS | PTD | DIS | M0)) /*GPMC_A7*/\ |
|
789 |
MUX_VAL(CP(GPMC_A8), (IDIS | PTD | DIS | M0)) /*GPMC_A8*/\ |
|
790 |
MUX_VAL(CP(GPMC_A9), (IDIS | PTD | DIS | M0)) /*GPMC_A9*/\ |
|
791 |
MUX_VAL(CP(GPMC_A10), (IDIS | PTD | DIS | M0)) /*GPMC_A10*/\ |
|
792 |
MUX_VAL(CP(GPMC_D0), (IEN | PTD | DIS | M0)) /*GPMC_D0*/\ |
|
793 |
MUX_VAL(CP(GPMC_D1), (IEN | PTD | DIS | M0)) /*GPMC_D1*/\ |
|
794 |
MUX_VAL(CP(GPMC_D2), (IEN | PTD | DIS | M0)) /*GPMC_D2*/\ |
|
795 |
MUX_VAL(CP(GPMC_D3), (IEN | PTD | DIS | M0)) /*GPMC_D3*/\ |
|
796 |
MUX_VAL(CP(GPMC_D4), (IEN | PTD | DIS | M0)) /*GPMC_D4*/\ |
|
797 |
MUX_VAL(CP(GPMC_D5), (IEN | PTD | DIS | M0)) /*GPMC_D5*/\ |
|
798 |
MUX_VAL(CP(GPMC_D6), (IEN | PTD | DIS | M0)) /*GPMC_D6*/\ |
|
799 |
MUX_VAL(CP(GPMC_D7), (IEN | PTD | DIS | M0)) /*GPMC_D7*/\ |
|
800 |
MUX_VAL(CP(GPMC_D8), (IEN | PTD | DIS | M0)) /*GPMC_D8*/\ |
|
801 |
MUX_VAL(CP(GPMC_D9), (IEN | PTD | DIS | M0)) /*GPMC_D9*/\ |
|
802 |
MUX_VAL(CP(GPMC_D10), (IEN | PTD | DIS | M0)) /*GPMC_D10*/\ |
|
803 |
MUX_VAL(CP(GPMC_D11), (IEN | PTD | DIS | M0)) /*GPMC_D11*/\ |
|
804 |
MUX_VAL(CP(GPMC_D12), (IEN | PTD | DIS | M0)) /*GPMC_D12*/\ |
|
805 |
MUX_VAL(CP(GPMC_D13), (IEN | PTD | DIS | M0)) /*GPMC_D13*/\ |
|
806 |
MUX_VAL(CP(GPMC_D14), (IEN | PTD | DIS | M0)) /*GPMC_D14*/\ |
|
807 |
MUX_VAL(CP(GPMC_D15), (IEN | PTD | DIS | M0)) /*GPMC_D15*/\ |
|
808 |
MUX_VAL(CP(GPMC_nCS0), (IDIS | PTU | EN | M0)) /*GPMC_nCS0*/\ |
|
809 |
MUX_VAL(CP(GPMC_nCS1), (IDIS | PTU | EN | M0)) /*GPMC_nCS1*/\ |
|
810 |
MUX_VAL(CP(GPMC_nCS2), (IDIS | PTU | EN | M0)) /*GPMC_nCS2*/\ |
|
811 |
MUX_VAL(CP(GPMC_nCS3), (IDIS | PTU | EN | M0)) /*GPMC_nCS3*/\ |
|
812 |
MUX_VAL(CP(GPMC_nCS4), (IDIS | PTU | EN | M0)) /*GPMC_nCS4*/\ |
|
813 |
MUX_VAL(CP(GPMC_nCS5), (IDIS | PTD | DIS | M0)) /*GPMC_nCS5*/\ |
|
814 |
MUX_VAL(CP(GPMC_nCS6), (IEN | PTD | DIS | M1)) /*GPMC_nCS6*/\ |
|
815 |
MUX_VAL(CP(GPMC_nCS7), (IEN | PTU | EN | M1)) /*GPMC_nCS7*/\ |
|
816 |
MUX_VAL(CP(GPMC_CLK), (IDIS | PTD | DIS | M0)) /*GPMC_CLK*/\ |
|
817 |
MUX_VAL(CP(GPMC_nADV_ALE), (IDIS | PTD | DIS | M0)) /*GPMC_nADV_ALE*/\ |
|
818 |
MUX_VAL(CP(GPMC_nOE), (IDIS | PTD | DIS | M0)) /*GPMC_nOE*/\ |
|
819 |
MUX_VAL(CP(GPMC_nWE), (IDIS | PTD | DIS | M0)) /*GPMC_nWE*/\ |
|
820 |
MUX_VAL(CP(GPMC_nBE0_CLE), (IDIS | PTD | DIS | M0)) /*GPMC_nBE0_CLE*/\ |
|
821 |
MUX_VAL(CP(GPMC_nBE1), (IEN | PTD | DIS | M0)) /*GPIO_61*/\ |
|
822 |
MUX_VAL(CP(GPMC_nWP), (IEN | PTD | DIS | M0)) /*GPMC_nWP*/\ |
|
823 |
MUX_VAL(CP(GPMC_WAIT0), (IEN | PTU | EN | M0)) /*GPMC_WAIT0*/\ |
|
824 |
MUX_VAL(CP(GPMC_WAIT1), (IEN | PTU | EN | M0)) /*GPMC_WAIT1*/\ |
|
825 |
MUX_VAL(CP(GPMC_WAIT2), (IEN | PTU | EN | M0)) /*GPIO_64*/\ |
|
826 |
MUX_VAL(CP(GPMC_WAIT3), (IEN | PTU | EN | M0)) /*GPIO_65*/\ |
|
827 |
MUX_VAL(CP(DSS_DATA18), (IEN | PTD | DIS | M4)) /*GPIO_88*/\ |
|
828 |
MUX_VAL(CP(DSS_DATA19), (IEN | PTD | DIS | M4)) /*GPIO_89*/\ |
|
829 |
MUX_VAL(CP(DSS_DATA20), (IEN | PTD | DIS | M4)) /*GPIO_90*/\ |
|
830 |
MUX_VAL(CP(DSS_DATA21), (IEN | PTD | DIS | M4)) /*GPIO_91*/\ |
|
831 |
MUX_VAL(CP(CAM_WEN), (IEN | PTD | DIS | M4)) /*GPIO_167*/\ |
|
832 |
MUX_VAL(CP(MMC1_CLK), (IDIS | PTU | EN | M0)) /*MMC1_CLK*/\ |
|
833 |
MUX_VAL(CP(MMC1_CMD), (IEN | PTU | EN | M0)) /*MMC1_CMD*/\ |
|
834 |
MUX_VAL(CP(MMC1_DAT0), (IEN | PTU | EN | M0)) /*MMC1_DAT0*/\ |
|
835 |
MUX_VAL(CP(MMC1_DAT1), (IEN | PTU | EN | M0)) /*MMC1_DAT1*/\ |
|
836 |
MUX_VAL(CP(MMC1_DAT2), (IEN | PTU | EN | M0)) /*MMC1_DAT2*/\ |
|
837 |
MUX_VAL(CP(MMC1_DAT3), (IEN | PTU | EN | M0)) /*MMC1_DAT3*/\ |
|
838 |
MUX_VAL(CP(MMC1_DAT4), (IEN | PTU | EN | M0)) /*MMC1_DAT4*/\ |
|
839 |
MUX_VAL(CP(MMC1_DAT5), (IEN | PTU | EN | M0)) /*MMC1_DAT5*/\ |
|
840 |
MUX_VAL(CP(MMC1_DAT6), (IEN | PTU | EN | M0)) /*MMC1_DAT6*/\ |
|
841 |
MUX_VAL(CP(MMC1_DAT7), (IEN | PTU | EN | M0)) /*MMC1_DAT7*/\ |
|
842 |
MUX_VAL(CP(UART1_TX), (IDIS | PTD | DIS | M0)) /*UART1_TX*/\ |
|
843 |
MUX_VAL(CP(UART1_RTS), (IDIS | PTD | DIS | M4)) /*GPIO_149*/\ |
|
844 |
MUX_VAL(CP(UART1_CTS), (IDIS | PTD | DIS | M4)) /*GPIO_150*/\ |
|
845 |
MUX_VAL(CP(UART1_RX), (IEN | PTD | DIS | M0)) /*UART1_RX*/\ |
|
846 |
MUX_VAL(CP(UART3_CTS_RCTX), (IEN | PTD | EN | M0)) /*UART3_CTS_RCTX */\ |
|
847 |
MUX_VAL(CP(UART3_RTS_SD), (IDIS | PTD | DIS | M0)) /*UART3_RTS_SD */\ |
|
848 |
MUX_VAL(CP(UART3_RX_IRRX), (IEN | PTD | DIS | M0)) /*UART3_RX_IRRX*/\ |
|
849 |
MUX_VAL(CP(UART3_TX_IRTX), (IDIS | PTD | DIS | M0)) /*UART3_TX_IRTX*/\ |
|
850 |
MUX_VAL(CP(I2C1_SCL), (IEN | PTU | EN | M0)) /*I2C1_SCL*/\ |
|
851 |
MUX_VAL(CP(I2C1_SDA), (IEN | PTU | EN | M0)) /*I2C1_SDA*/\ |
|
852 |
MUX_VAL(CP(I2C2_SCL), (IEN | PTU | EN | M0)) /*I2C2_SCL*/\ |
|
853 |
MUX_VAL(CP(I2C2_SDA), (IEN | PTU | EN | M0)) /*I2C2_SDA*/\ |
|
854 |
MUX_VAL(CP(I2C3_SCL), (IEN | PTU | EN | M0)) /*I2C3_SCL*/\ |
|
855 |
MUX_VAL(CP(I2C3_SDA), (IEN | PTU | EN | M0)) /*I2C3_SDA*/\ |
|
856 |
MUX_VAL(CP(I2C4_SCL), (IEN | PTU | EN | M0)) /*I2C4_SCL*/\ |
|
857 |
MUX_VAL(CP(I2C4_SDA), (IEN | PTU | EN | M0)) /*I2C4_SDA*/\ |
|
|
1.1.1
by Oliver Grawert
Import upstream version 1.4.3git20100531 |
858 |
MUX_VAL(CP(McSPI1_CLK), (IEN | PTU | EN | M4)) /*GPIO_171*/\ |
859 |
MUX_VAL(CP(McSPI1_SIMO), (IEN | PTU | EN | M4)) /*GPIO_172*/\ |
|
860 |
MUX_VAL(CP(McSPI1_SOMI), (IEN | PTU | EN | M4)) /*GPIO_173*/\ |
|
|
1
by Oliver Grawert
Import upstream version 1.4.3git20100305 |
861 |
MUX_VAL(CP(McBSP1_DX), (IEN | PTD | DIS | M4)) /*GPIO_158*/\ |
862 |
MUX_VAL(CP(SYS_32K), (IEN | PTD | DIS | M0)) /*SYS_32K*/\ |
|
863 |
MUX_VAL(CP(SYS_BOOT0), (IEN | PTD | DIS | M4)) /*GPIO_2 */\ |
|
864 |
MUX_VAL(CP(SYS_BOOT1), (IEN | PTD | DIS | M4)) /*GPIO_3 */\ |
|
865 |
MUX_VAL(CP(SYS_BOOT2), (IEN | PTD | DIS | M4)) /*GPIO_4 */\ |
|
866 |
MUX_VAL(CP(SYS_BOOT3), (IEN | PTD | DIS | M4)) /*GPIO_5 */\ |
|
867 |
MUX_VAL(CP(SYS_BOOT4), (IEN | PTD | DIS | M4)) /*GPIO_6 */\ |
|
868 |
MUX_VAL(CP(SYS_BOOT5), (IEN | PTD | DIS | M4)) /*GPIO_7 */\ |
|
869 |
MUX_VAL(CP(SYS_BOOT6), (IEN | PTD | DIS | M4)) /*GPIO_8 */\ |
|
870 |
MUX_VAL(CP(SYS_CLKOUT2), (IEN | PTU | EN | M4)) /*GPIO_186*/\ |
|
871 |
MUX_VAL(CP(JTAG_nTRST), (IEN | PTD | DIS | M0)) /*JTAG_nTRST*/\ |
|
872 |
MUX_VAL(CP(JTAG_TCK), (IEN | PTD | DIS | M0)) /*JTAG_TCK*/\ |
|
873 |
MUX_VAL(CP(JTAG_TMS), (IEN | PTD | DIS | M0)) /*JTAG_TMS*/\ |
|
874 |
MUX_VAL(CP(JTAG_TDI), (IEN | PTD | DIS | M0)) /*JTAG_TDI*/\ |
|
875 |
MUX_VAL(CP(JTAG_EMU0), (IEN | PTD | DIS | M0)) /*JTAG_EMU0*/\ |
|
876 |
MUX_VAL(CP(JTAG_EMU1), (IEN | PTD | DIS | M0)) /*JTAG_EMU1*/\ |
|
877 |
MUX_VAL(CP(ETK_CLK), (IEN | PTD | DIS | M4)) /*GPIO_12*/\ |
|
878 |
MUX_VAL(CP(ETK_CTL), (IEN | PTD | DIS | M4)) /*GPIO_13*/\ |
|
879 |
MUX_VAL(CP(ETK_D0), (IEN | PTD | DIS | M4)) /*GPIO_14*/\ |
|
880 |
MUX_VAL(CP(ETK_D1), (IEN | PTD | DIS | M4)) /*GPIO_15*/\ |
|
881 |
MUX_VAL(CP(ETK_D2), (IEN | PTD | DIS | M4)) /*GPIO_16*/\ |
|
882 |
MUX_VAL(CP(ETK_D11), (IEN | PTD | DIS | M4)) /*GPIO_25*/\ |
|
883 |
MUX_VAL(CP(ETK_D12), (IEN | PTD | DIS | M4)) /*GPIO_26*/\ |
|
884 |
MUX_VAL(CP(ETK_D13), (IEN | PTD | DIS | M4)) /*GPIO_27*/\ |
|
885 |
MUX_VAL(CP(ETK_D14), (IEN | PTD | DIS | M4)) /*GPIO_28*/\ |
|
886 |
MUX_VAL(CP(ETK_D15), (IEN | PTD | DIS | M4)) /*GPIO_29 */\ |
|
887 |
MUX_VAL(CP(sdrc_cke0), (IDIS | PTU | EN | M0)) /*sdrc_cke0 */\ |
|
888 |
MUX_VAL(CP(sdrc_cke1), (IDIS | PTD | DIS | M7)) /*sdrc_cke1 not used*/ |
|
889 |
||
890 |
/**********************************************************
|
|
891 |
* Routine: set_muxconf_regs
|
|
892 |
* Description: Setting up the configuration Mux registers
|
|
893 |
* specific to the hardware. Many pins need
|
|
894 |
* to be moved from protect to primary mode.
|
|
895 |
*********************************************************/
|
|
896 |
void set_muxconf_regs(void) |
|
897 |
{
|
|
898 |
MUX_DEFAULT(); |
|
899 |
}
|
|
900 |
||
901 |
/**********************************************************
|
|
902 |
* Routine: nand+_init
|
|
903 |
* Description: Set up nand for nand and jffs2 commands
|
|
904 |
*********************************************************/
|
|
905 |
||
906 |
int nand_init(void) |
|
907 |
{
|
|
908 |
/* global settings */
|
|
909 |
__raw_writel(0x10, GPMC_SYSCONFIG); /* smart idle */ |
|
910 |
__raw_writel(0x0, GPMC_IRQENABLE); /* isr's sources masked */ |
|
911 |
__raw_writel(0, GPMC_TIMEOUT_CONTROL);/* timeout disable */ |
|
912 |
||
913 |
/* Set the GPMC Vals, NAND is mapped at CS0, oneNAND at CS0.
|
|
914 |
* We configure only GPMC CS0 with required values. Configiring other devices
|
|
915 |
* at other CS is done in u-boot. So we don't have to bother doing it here.
|
|
916 |
*/
|
|
917 |
__raw_writel(0 , GPMC_CONFIG7 + GPMC_CONFIG_CS0); |
|
918 |
delay(1000); |
|
919 |
||
920 |
if ((get_mem_type() == GPMC_NAND) || (get_mem_type() == MMC_NAND)) { |
|
921 |
__raw_writel(M_NAND_GPMC_CONFIG1, GPMC_CONFIG1 + GPMC_CONFIG_CS0); |
|
922 |
__raw_writel(M_NAND_GPMC_CONFIG2, GPMC_CONFIG2 + GPMC_CONFIG_CS0); |
|
923 |
__raw_writel(M_NAND_GPMC_CONFIG3, GPMC_CONFIG3 + GPMC_CONFIG_CS0); |
|
924 |
__raw_writel(M_NAND_GPMC_CONFIG4, GPMC_CONFIG4 + GPMC_CONFIG_CS0); |
|
925 |
__raw_writel(M_NAND_GPMC_CONFIG5, GPMC_CONFIG5 + GPMC_CONFIG_CS0); |
|
926 |
__raw_writel(M_NAND_GPMC_CONFIG6, GPMC_CONFIG6 + GPMC_CONFIG_CS0); |
|
927 |
||
928 |
/* Enable the GPMC Mapping */
|
|
929 |
__raw_writel((((OMAP34XX_GPMC_CS0_SIZE & 0xF)<<8) | |
|
930 |
((NAND_BASE_ADR>>24) & 0x3F) | |
|
931 |
(1<<6)), (GPMC_CONFIG7 + GPMC_CONFIG_CS0)); |
|
932 |
delay(2000); |
|
933 |
||
934 |
if (nand_chip()) { |
|
935 |
#ifdef CFG_PRINTF
|
|
936 |
printf("Unsupported Chip!\n"); |
|
937 |
#endif
|
|
938 |
return 1; |
|
939 |
}
|
|
940 |
||
941 |
}
|
|
942 |
||
943 |
if ((get_mem_type() == GPMC_ONENAND) || (get_mem_type() == MMC_ONENAND)) { |
|
944 |
__raw_writel(ONENAND_GPMC_CONFIG1, GPMC_CONFIG1 + GPMC_CONFIG_CS0); |
|
945 |
__raw_writel(ONENAND_GPMC_CONFIG2, GPMC_CONFIG2 + GPMC_CONFIG_CS0); |
|
946 |
__raw_writel(ONENAND_GPMC_CONFIG3, GPMC_CONFIG3 + GPMC_CONFIG_CS0); |
|
947 |
__raw_writel(ONENAND_GPMC_CONFIG4, GPMC_CONFIG4 + GPMC_CONFIG_CS0); |
|
948 |
__raw_writel(ONENAND_GPMC_CONFIG5, GPMC_CONFIG5 + GPMC_CONFIG_CS0); |
|
949 |
__raw_writel(ONENAND_GPMC_CONFIG6, GPMC_CONFIG6 + GPMC_CONFIG_CS0); |
|
950 |
||
951 |
/* Enable the GPMC Mapping */
|
|
952 |
__raw_writel((((OMAP34XX_GPMC_CS0_SIZE & 0xF)<<8) | |
|
953 |
((ONENAND_BASE>>24) & 0x3F) | |
|
954 |
(1<<6)), (GPMC_CONFIG7 + GPMC_CONFIG_CS0)); |
|
955 |
delay(2000); |
|
956 |
||
957 |
if (onenand_chip()) { |
|
958 |
#ifdef CFG_PRINTF
|
|
959 |
printf("OneNAND Unsupported !\n"); |
|
960 |
#endif
|
|
961 |
return 1; |
|
962 |
}
|
|
963 |
}
|
|
964 |
return 0; |
|
965 |
}
|
|
966 |
||
967 |
#define DEBUG_LED1 149 /* gpio */ |
|
968 |
#define DEBUG_LED2 150 /* gpio */ |
|
969 |
||
970 |
void blinkLEDs() |
|
971 |
{
|
|
972 |
void *p; |
|
973 |
||
974 |
/* Alternately turn the LEDs on and off */
|
|
975 |
p = (unsigned long *)OMAP34XX_GPIO5_BASE; |
|
976 |
while (1) { |
|
977 |
/* turn LED1 on and LED2 off */
|
|
978 |
*(unsigned long *)(p + 0x94) = 1 << (DEBUG_LED1 % 32); |
|
979 |
*(unsigned long *)(p + 0x90) = 1 << (DEBUG_LED2 % 32); |
|
980 |
||
981 |
/* delay for a while */
|
|
982 |
delay(1000); |
|
983 |
||
984 |
/* turn LED1 off and LED2 on */
|
|
985 |
*(unsigned long *)(p + 0x90) = 1 << (DEBUG_LED1 % 32); |
|
986 |
*(unsigned long *)(p + 0x94) = 1 << (DEBUG_LED2 % 32); |
|
987 |
||
988 |
/* delay for a while */
|
|
989 |
delay(1000); |
|
990 |
}
|
|
991 |
}
|
|
992 |
||
993 |
/* optionally do something like blinking LED */
|
|
994 |
void board_hang(void) |
|
995 |
{
|
|
996 |
while (1) |
|
997 |
blinkLEDs(); |
|
998 |
}
|
|
999 |
||
1000 |
/******************************************************************************
|
|
1001 |
* Dummy function to handle errors for EABI incompatibility
|
|
1002 |
*****************************************************************************/
|
|
1003 |
void raise(void) |
|
1004 |
{
|
|
1005 |
}
|
|
1006 |
||
1007 |
/******************************************************************************
|
|
1008 |
* Dummy function to handle errors for EABI incompatibility
|
|
1009 |
*****************************************************************************/
|
|
1010 |
void abort(void) |
|
1011 |
{
|
|
1012 |
}
|