blob: 989c5b139aca9b8e41ddab0611932d75cd0944a1 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Dipen Dudhat2f143ed2011-07-28 14:47:28 -05002/*
3 * Copyright 2011 Freescale Semiconductor, Inc.
Dipen Dudhat2f143ed2011-07-28 14:47:28 -05004 */
5#include <common.h>
Simon Glass284f71b2019-12-28 10:44:45 -07006#include <init.h>
Dipen Dudhat2f143ed2011-07-28 14:47:28 -05007#include <mpc85xx.h>
8#include <asm/io.h>
9#include <ns16550.h>
10#include <nand.h>
11#include <asm/mmu.h>
12#include <asm/immap_85xx.h>
York Sunf0626592013-09-30 09:22:09 -070013#include <fsl_ddr_sdram.h>
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050014#include <asm/fsl_law.h>
Matthew McClintock4a71d582012-08-13 13:21:19 +000015#include <asm/global_data.h>
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050016
Matthew McClintock4a71d582012-08-13 13:21:19 +000017DECLARE_GLOBAL_DATA_PTR;
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050018
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050019void board_init_f(ulong bootflag)
20{
Prabhakar Kushwaha66d6aa82013-04-16 13:28:12 +053021 u32 plat_ratio;
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050022 ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
23
Ying Zhang1233cbc2014-01-24 15:50:09 +080024#if defined(CONFIG_SYS_NAND_BR_PRELIM) && defined(CONFIG_SYS_NAND_OR_PRELIM)
25 set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM);
26 set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM);
27#endif
28
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050029 /* initialize selected port with appropriate baud rate */
30 plat_ratio = in_be32(&gur->porpllsr) & MPC85xx_PORPLLSR_PLAT_RATIO;
31 plat_ratio >>= 1;
Matthew McClintock4a71d582012-08-13 13:21:19 +000032 gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio;
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050033
Simon Glass2b923982020-12-22 19:30:19 -070034 ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1,
Simon Glass119e7ef2020-12-22 19:30:18 -070035 gd->bus_clk / 16 / CONFIG_BAUDRATE);
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050036
37 puts("\nNAND boot... ");
38
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050039 /* copy code to RAM and jump to it - this should not return */
40 /* NOTE - code has to be copied out of NAND buffer before
41 * other blocks can be read.
42 */
Prabhakar Kushwaha66d6aa82013-04-16 13:28:12 +053043
44 relocate_code(CONFIG_SPL_RELOC_STACK, 0, CONFIG_SPL_RELOC_TEXT_BASE);
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050045}
46
47void board_init_r(gd_t *gd, ulong dest_addr)
48{
Ying Zhang1233cbc2014-01-24 15:50:09 +080049 puts("\nSecond program loader running in sram...");
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050050 nand_boot();
51}
52
53void putc(char c)
54{
55 if (c == '\n')
Simon Glass2b923982020-12-22 19:30:19 -070056 ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, '\r');
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050057
Simon Glass2b923982020-12-22 19:30:19 -070058 ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, c);
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050059}
60
61void puts(const char *str)
62{
63 while (*str)
64 putc(*str++);
65}