Liu Yu | 2639e51 | 2010-01-18 19:03:28 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2009 Freescale Semiconductor, Inc. |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Liu Yu | 2639e51 | 2010-01-18 19:03:28 +0800 | [diff] [blame] | 5 | */ |
| 6 | #include <common.h> |
| 7 | #include <mpc85xx.h> |
Peter Tyser | 133c0fe | 2010-04-12 22:28:07 -0500 | [diff] [blame] | 8 | #include <asm/io.h> |
Liu Yu | 2639e51 | 2010-01-18 19:03:28 +0800 | [diff] [blame] | 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> |
Liu Yu | 2639e51 | 2010-01-18 19:03:28 +0800 | [diff] [blame] | 14 | #include <asm/fsl_law.h> |
| 15 | |
| 16 | #define SYSCLK_66 66666666 |
| 17 | |
| 18 | DECLARE_GLOBAL_DATA_PTR; |
| 19 | |
| 20 | void board_init_f(ulong bootflag) |
| 21 | { |
| 22 | uint plat_ratio, bus_clk, sys_clk; |
| 23 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
| 24 | |
| 25 | sys_clk = SYSCLK_66; |
| 26 | |
| 27 | plat_ratio = gur->porpllsr & 0x0000003e; |
| 28 | plat_ratio >>= 1; |
| 29 | bus_clk = plat_ratio * sys_clk; |
| 30 | NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, |
| 31 | bus_clk / 16 / CONFIG_BAUDRATE); |
| 32 | |
| 33 | puts("\nNAND boot... "); |
| 34 | |
| 35 | /* copy code to DDR and jump to it - this should not return */ |
| 36 | /* NOTE - code has to be copied out of NAND buffer before |
| 37 | * other blocks can be read. |
| 38 | */ |
| 39 | relocate_code(CONFIG_SYS_NAND_U_BOOT_RELOC_SP, 0, |
| 40 | CONFIG_SYS_NAND_U_BOOT_RELOC); |
| 41 | } |
| 42 | |
| 43 | void board_init_r(gd_t *gd, ulong dest_addr) |
| 44 | { |
| 45 | nand_boot(); |
| 46 | } |
| 47 | |
| 48 | void putc(char c) |
| 49 | { |
| 50 | if (c == '\n') |
| 51 | NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r'); |
| 52 | |
| 53 | NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c); |
| 54 | } |
| 55 | |
| 56 | void puts(const char *str) |
| 57 | { |
| 58 | while (*str) |
| 59 | putc(*str++); |
| 60 | } |