blob: 90abec9cce5fae700c7ff86c3b8ed2a0fc3bb5a6 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Oleksandr G Zhadan19ac6882015-04-29 16:57:39 -04002/*
3 * Copyright 2013-2015 Arcturus Networks, Inc.
4 * http://www.arcturusnetworks.com/products/ucp1020/
5 * based on board/freescale/p1_p2_rdb_pc/spl_minimal.c
6 * original copyright follows:
7 * Copyright 2011 Freescale Semiconductor, Inc.
Oleksandr G Zhadan19ac6882015-04-29 16:57:39 -04008 */
9
10#include <common.h>
Simon Glass284f71b2019-12-28 10:44:45 -070011#include <init.h>
Oleksandr G Zhadan19ac6882015-04-29 16:57:39 -040012#include <ns16550.h>
13#include <asm/io.h>
14#include <nand.h>
15#include <linux/compiler.h>
16#include <asm/fsl_law.h>
17#include <fsl_ddr_sdram.h>
18#include <asm/global_data.h>
19
20DECLARE_GLOBAL_DATA_PTR;
21
22void board_init_f(ulong bootflag)
23{
24 u32 plat_ratio;
25 ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
26
27#if defined(CONFIG_SYS_NAND_BR_PRELIM) && defined(CONFIG_SYS_NAND_OR_PRELIM)
28 set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM);
29 set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM);
30#endif
31
32 /* initialize selected port with appropriate baud rate */
33 plat_ratio = in_be32(&gur->porpllsr) & MPC85xx_PORPLLSR_PLAT_RATIO;
34 plat_ratio >>= 1;
35 gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio;
36
Simon Glass2b923982020-12-22 19:30:19 -070037 ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1,
Oleksandr G Zhadan19ac6882015-04-29 16:57:39 -040038 gd->bus_clk / 16 / CONFIG_BAUDRATE);
39
40 puts("\nNAND boot... ");
41
42 /* copy code to RAM and jump to it - this should not return */
43 /* NOTE - code has to be copied out of NAND buffer before
44 * other blocks can be read.
45 */
46 relocate_code(CONFIG_SPL_RELOC_STACK, 0, CONFIG_SPL_RELOC_TEXT_BASE);
47}
48
49void board_init_r(gd_t *gd, ulong dest_addr)
50{
51 puts("\nSecond program loader running in sram...");
52 nand_boot();
53}
54
55void putc(char c)
56{
57 if (c == '\n')
Simon Glass2b923982020-12-22 19:30:19 -070058 ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, '\r');
Oleksandr G Zhadan19ac6882015-04-29 16:57:39 -040059
Simon Glass2b923982020-12-22 19:30:19 -070060 ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, c);
Oleksandr G Zhadan19ac6882015-04-29 16:57:39 -040061}
62
63void puts(const char *str)
64{
65 while (*str)
66 putc(*str++);
67}