194a45bb1SScott Wood /* 294a45bb1SScott Wood * Copyright 2011 Freescale Semiconductor, Inc. 394a45bb1SScott Wood * 41a459660SWolfgang Denk * SPDX-License-Identifier: GPL-2.0+ 594a45bb1SScott Wood */ 694a45bb1SScott Wood 794a45bb1SScott Wood #include <common.h> 894a45bb1SScott Wood #include <ns16550.h> 994a45bb1SScott Wood #include <asm/io.h> 1094a45bb1SScott Wood #include <nand.h> 1113d1143fSScott Wood #include <linux/compiler.h> 1294a45bb1SScott Wood #include <asm/fsl_law.h> 1394a45bb1SScott Wood #include <asm/fsl_ddr_sdram.h> 1494a45bb1SScott Wood #include <asm/global_data.h> 1594a45bb1SScott Wood 1694a45bb1SScott Wood DECLARE_GLOBAL_DATA_PTR; 1794a45bb1SScott Wood 1894a45bb1SScott Wood void board_init_f(ulong bootflag) 1994a45bb1SScott Wood { 2094a45bb1SScott Wood u32 plat_ratio; 2194a45bb1SScott Wood ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR; 22*62c6ef33SYing Zhang 23*62c6ef33SYing Zhang #if defined(CONFIG_SYS_NAND_BR_PRELIM) && defined(CONFIG_SYS_NAND_OR_PRELIM) 24*62c6ef33SYing Zhang set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM); 25*62c6ef33SYing Zhang set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM); 2694a45bb1SScott Wood #endif 2794a45bb1SScott Wood 2894a45bb1SScott Wood /* initialize selected port with appropriate baud rate */ 2994a45bb1SScott Wood plat_ratio = in_be32(&gur->porpllsr) & MPC85xx_PORPLLSR_PLAT_RATIO; 3094a45bb1SScott Wood plat_ratio >>= 1; 3194a45bb1SScott Wood gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio; 3294a45bb1SScott Wood 3394a45bb1SScott Wood NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, 3494a45bb1SScott Wood gd->bus_clk / 16 / CONFIG_BAUDRATE); 3594a45bb1SScott Wood 3694a45bb1SScott Wood puts("\nNAND boot... "); 3794a45bb1SScott Wood 3894a45bb1SScott Wood /* copy code to RAM and jump to it - this should not return */ 3994a45bb1SScott Wood /* NOTE - code has to be copied out of NAND buffer before 4094a45bb1SScott Wood * other blocks can be read. 4194a45bb1SScott Wood */ 4294a45bb1SScott Wood relocate_code(CONFIG_SPL_RELOC_STACK, 0, CONFIG_SPL_RELOC_TEXT_BASE); 4394a45bb1SScott Wood } 4494a45bb1SScott Wood 4594a45bb1SScott Wood void board_init_r(gd_t *gd, ulong dest_addr) 4694a45bb1SScott Wood { 47*62c6ef33SYing Zhang puts("\nSecond program loader running in sram..."); 4894a45bb1SScott Wood nand_boot(); 4994a45bb1SScott Wood } 5094a45bb1SScott Wood 5194a45bb1SScott Wood void putc(char c) 5294a45bb1SScott Wood { 5394a45bb1SScott Wood if (c == '\n') 5494a45bb1SScott Wood NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r'); 5594a45bb1SScott Wood 5694a45bb1SScott Wood NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c); 5794a45bb1SScott Wood } 5894a45bb1SScott Wood 5994a45bb1SScott Wood void puts(const char *str) 6094a45bb1SScott Wood { 6194a45bb1SScott Wood while (*str) 6294a45bb1SScott Wood putc(*str++); 6394a45bb1SScott Wood } 64