]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/freescale/p1_p2_rdb/spl_minimal.c
Merge branch 'u-boot-microblaze/zynq' into 'u-boot-arm/master'
[karo-tx-uboot.git] / board / freescale / p1_p2_rdb / spl_minimal.c
1 /*
2  * Copyright 2011 Freescale Semiconductor, Inc.
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6
7 #include <common.h>
8 #include <ns16550.h>
9 #include <asm/io.h>
10 #include <nand.h>
11 #include <linux/compiler.h>
12 #include <asm/fsl_law.h>
13 #include <fsl_ddr_sdram.h>
14 #include <asm/global_data.h>
15
16 DECLARE_GLOBAL_DATA_PTR;
17 #define SYSCLK_MASK     0x00200000
18 #define BOARDREV_MASK   0x10100000
19
20 #define SYSCLK_66       66666666
21 #define SYSCLK_100      100000000
22
23 unsigned long get_board_sys_clk(ulong dummy)
24 {
25         ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
26         u32 val_gpdat, sysclk_gpio;
27
28         val_gpdat = in_be32(&pgpio->gpdat);
29         sysclk_gpio = val_gpdat & SYSCLK_MASK;
30
31         if (sysclk_gpio == 0)
32                 return SYSCLK_66;
33         else
34                 return SYSCLK_100;
35
36         return 0;
37 }
38
39 void board_init_f(ulong bootflag)
40 {
41         u32 plat_ratio;
42         ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
43
44 #if defined(CONFIG_SYS_NAND_BR_PRELIM) && defined(CONFIG_SYS_NAND_OR_PRELIM)
45         set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM);
46         set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM);
47 #endif
48
49         /* initialize selected port with appropriate baud rate */
50         plat_ratio = in_be32(&gur->porpllsr) & MPC85xx_PORPLLSR_PLAT_RATIO;
51         plat_ratio >>= 1;
52         gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio;
53
54         NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
55                      gd->bus_clk / 16 / CONFIG_BAUDRATE);
56
57         puts("\nNAND boot... ");
58
59         /* copy code to RAM and jump to it - this should not return */
60         /* NOTE - code has to be copied out of NAND buffer before
61          * other blocks can be read.
62          */
63         relocate_code(CONFIG_SPL_RELOC_STACK, 0, CONFIG_SPL_RELOC_TEXT_BASE);
64 }
65
66 void board_init_r(gd_t *gd, ulong dest_addr)
67 {
68         puts("\nSecond program loader running in sram...");
69         nand_boot();
70 }
71
72 void putc(char c)
73 {
74         if (c == '\n')
75                 NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r');
76
77         NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c);
78 }
79
80 void puts(const char *str)
81 {
82         while (*str)
83                 putc(*str++);
84 }