blob: b9eb4430f16fd45a5ad2fb47bd7841b40f9dd99b [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>
6#include <mpc85xx.h>
7#include <asm/io.h>
8#include <ns16550.h>
9#include <nand.h>
10#include <asm/mmu.h>
11#include <asm/immap_85xx.h>
York Sunf0626592013-09-30 09:22:09 -070012#include <fsl_ddr_sdram.h>
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050013#include <asm/fsl_law.h>
Matthew McClintock4a71d582012-08-13 13:21:19 +000014#include <asm/global_data.h>
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050015
Matthew McClintock4a71d582012-08-13 13:21:19 +000016DECLARE_GLOBAL_DATA_PTR;
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050017
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050018void board_init_f(ulong bootflag)
19{
Prabhakar Kushwaha66d6aa82013-04-16 13:28:12 +053020 u32 plat_ratio;
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050021 ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
22
Ying Zhang1233cbc2014-01-24 15:50:09 +080023#if defined(CONFIG_SYS_NAND_BR_PRELIM) && defined(CONFIG_SYS_NAND_OR_PRELIM)
24 set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM);
25 set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM);
26#endif
27
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050028 /* initialize selected port with appropriate baud rate */
29 plat_ratio = in_be32(&gur->porpllsr) & MPC85xx_PORPLLSR_PLAT_RATIO;
30 plat_ratio >>= 1;
Matthew McClintock4a71d582012-08-13 13:21:19 +000031 gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio;
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050032
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050033 NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
Matthew McClintock4a71d582012-08-13 13:21:19 +000034 gd->bus_clk / 16 / CONFIG_BAUDRATE);
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050035
36 puts("\nNAND boot... ");
37
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050038 /* copy code to RAM and jump to it - this should not return */
39 /* NOTE - code has to be copied out of NAND buffer before
40 * other blocks can be read.
41 */
Prabhakar Kushwaha66d6aa82013-04-16 13:28:12 +053042
43 relocate_code(CONFIG_SPL_RELOC_STACK, 0, CONFIG_SPL_RELOC_TEXT_BASE);
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050044}
45
46void board_init_r(gd_t *gd, ulong dest_addr)
47{
Ying Zhang1233cbc2014-01-24 15:50:09 +080048 puts("\nSecond program loader running in sram...");
Dipen Dudhat2f143ed2011-07-28 14:47:28 -050049 nand_boot();
50}
51
52void putc(char c)
53{
54 if (c == '\n')
55 NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r');
56
57 NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c);
58}
59
60void puts(const char *str)
61{
62 while (*str)
63 putc(*str++);
64}