Dipen Dudhat | 2f143ed | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 Freescale Semiconductor, Inc. |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Dipen Dudhat | 2f143ed | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 5 | */ |
| 6 | #include <common.h> |
| 7 | #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 Sun | f062659 | 2013-09-30 09:22:09 -0700 | [diff] [blame] | 13 | #include <fsl_ddr_sdram.h> |
Dipen Dudhat | 2f143ed | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 14 | #include <asm/fsl_law.h> |
Matthew McClintock | 4a71d58 | 2012-08-13 13:21:19 +0000 | [diff] [blame] | 15 | #include <asm/global_data.h> |
Dipen Dudhat | 2f143ed | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 16 | |
Matthew McClintock | 4a71d58 | 2012-08-13 13:21:19 +0000 | [diff] [blame] | 17 | DECLARE_GLOBAL_DATA_PTR; |
Dipen Dudhat | 2f143ed | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 18 | |
Dipen Dudhat | 2f143ed | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 19 | void board_init_f(ulong bootflag) |
| 20 | { |
Prabhakar Kushwaha | 66d6aa8 | 2013-04-16 13:28:12 +0530 | [diff] [blame] | 21 | u32 plat_ratio; |
Dipen Dudhat | 2f143ed | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 22 | ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR; |
| 23 | |
Ying Zhang | 1233cbc | 2014-01-24 15:50:09 +0800 | [diff] [blame] | 24 | #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 Dudhat | 2f143ed | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 29 | /* initialize selected port with appropriate baud rate */ |
| 30 | plat_ratio = in_be32(&gur->porpllsr) & MPC85xx_PORPLLSR_PLAT_RATIO; |
| 31 | plat_ratio >>= 1; |
Matthew McClintock | 4a71d58 | 2012-08-13 13:21:19 +0000 | [diff] [blame] | 32 | gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio; |
Dipen Dudhat | 2f143ed | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 33 | |
Dipen Dudhat | 2f143ed | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 34 | NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, |
Matthew McClintock | 4a71d58 | 2012-08-13 13:21:19 +0000 | [diff] [blame] | 35 | gd->bus_clk / 16 / CONFIG_BAUDRATE); |
Dipen Dudhat | 2f143ed | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 36 | |
| 37 | puts("\nNAND boot... "); |
| 38 | |
Dipen Dudhat | 2f143ed | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 39 | /* 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 Kushwaha | 66d6aa8 | 2013-04-16 13:28:12 +0530 | [diff] [blame] | 43 | |
| 44 | relocate_code(CONFIG_SPL_RELOC_STACK, 0, CONFIG_SPL_RELOC_TEXT_BASE); |
Dipen Dudhat | 2f143ed | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | void board_init_r(gd_t *gd, ulong dest_addr) |
| 48 | { |
Ying Zhang | 1233cbc | 2014-01-24 15:50:09 +0800 | [diff] [blame] | 49 | puts("\nSecond program loader running in sram..."); |
Dipen Dudhat | 2f143ed | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 50 | nand_boot(); |
| 51 | } |
| 52 | |
| 53 | void putc(char c) |
| 54 | { |
| 55 | if (c == '\n') |
| 56 | NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r'); |
| 57 | |
| 58 | NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c); |
| 59 | } |
| 60 | |
| 61 | void puts(const char *str) |
| 62 | { |
| 63 | while (*str) |
| 64 | putc(*str++); |
| 65 | } |