Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Dipen Dudhat | d793e5a | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2011 Freescale Semiconductor, Inc. |
Dipen Dudhat | d793e5a | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 4 | */ |
| 5 | #include <common.h> |
Tom Rini | 2f8a6db | 2021-12-14 13:36:40 -0500 | [diff] [blame] | 6 | #include <clock_legacy.h> |
Simon Glass | 9413387 | 2019-12-28 10:44:45 -0700 | [diff] [blame] | 7 | #include <init.h> |
Dipen Dudhat | d793e5a | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 8 | #include <mpc85xx.h> |
| 9 | #include <asm/io.h> |
| 10 | #include <ns16550.h> |
| 11 | #include <nand.h> |
| 12 | #include <asm/mmu.h> |
| 13 | #include <asm/immap_85xx.h> |
York Sun | 5614e71 | 2013-09-30 09:22:09 -0700 | [diff] [blame] | 14 | #include <fsl_ddr_sdram.h> |
Dipen Dudhat | d793e5a | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 15 | #include <asm/fsl_law.h> |
Matthew McClintock | 8c45404 | 2012-08-13 13:21:19 +0000 | [diff] [blame] | 16 | #include <asm/global_data.h> |
Dipen Dudhat | d793e5a | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 17 | |
Matthew McClintock | 8c45404 | 2012-08-13 13:21:19 +0000 | [diff] [blame] | 18 | DECLARE_GLOBAL_DATA_PTR; |
Dipen Dudhat | d793e5a | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 19 | |
Dipen Dudhat | d793e5a | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 20 | void board_init_f(ulong bootflag) |
| 21 | { |
Prabhakar Kushwaha | 0fa934d | 2013-04-16 13:28:12 +0530 | [diff] [blame] | 22 | u32 plat_ratio; |
Dipen Dudhat | d793e5a | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 23 | ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR; |
| 24 | |
Ying Zhang | c9e1f58 | 2014-01-24 15:50:09 +0800 | [diff] [blame] | 25 | #if defined(CONFIG_SYS_NAND_BR_PRELIM) && defined(CONFIG_SYS_NAND_OR_PRELIM) |
| 26 | set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM); |
| 27 | set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM); |
| 28 | #endif |
| 29 | |
Dipen Dudhat | d793e5a | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 30 | /* initialize selected port with appropriate baud rate */ |
| 31 | plat_ratio = in_be32(&gur->porpllsr) & MPC85xx_PORPLLSR_PLAT_RATIO; |
| 32 | plat_ratio >>= 1; |
Tom Rini | 2f8a6db | 2021-12-14 13:36:40 -0500 | [diff] [blame] | 33 | gd->bus_clk = get_board_sys_clk() * plat_ratio; |
Dipen Dudhat | d793e5a | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 34 | |
Simon Glass | 2d6bf75 | 2020-12-22 19:30:19 -0700 | [diff] [blame] | 35 | ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, |
Simon Glass | d30c720 | 2020-12-22 19:30:18 -0700 | [diff] [blame] | 36 | gd->bus_clk / 16 / CONFIG_BAUDRATE); |
Dipen Dudhat | d793e5a | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 37 | |
| 38 | puts("\nNAND boot... "); |
| 39 | |
Dipen Dudhat | d793e5a | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 40 | /* copy code to RAM and jump to it - this should not return */ |
| 41 | /* NOTE - code has to be copied out of NAND buffer before |
| 42 | * other blocks can be read. |
| 43 | */ |
Prabhakar Kushwaha | 0fa934d | 2013-04-16 13:28:12 +0530 | [diff] [blame] | 44 | |
| 45 | relocate_code(CONFIG_SPL_RELOC_STACK, 0, CONFIG_SPL_RELOC_TEXT_BASE); |
Dipen Dudhat | d793e5a | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | void board_init_r(gd_t *gd, ulong dest_addr) |
| 49 | { |
Ying Zhang | c9e1f58 | 2014-01-24 15:50:09 +0800 | [diff] [blame] | 50 | puts("\nSecond program loader running in sram..."); |
Dipen Dudhat | d793e5a | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 51 | nand_boot(); |
| 52 | } |
| 53 | |
| 54 | void putc(char c) |
| 55 | { |
| 56 | if (c == '\n') |
Simon Glass | 2d6bf75 | 2020-12-22 19:30:19 -0700 | [diff] [blame] | 57 | ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, '\r'); |
Dipen Dudhat | d793e5a | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 58 | |
Simon Glass | 2d6bf75 | 2020-12-22 19:30:19 -0700 | [diff] [blame] | 59 | ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, c); |
Dipen Dudhat | d793e5a | 2011-07-28 14:47:28 -0500 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | void puts(const char *str) |
| 63 | { |
| 64 | while (*str) |
| 65 | putc(*str++); |
| 66 | } |