~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/u-boot/nand_spl/board/freescale/p1_p2_rdb/nand_boot.c

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2009 Freescale Semiconductor, Inc.
 
3
 *
 
4
 * SPDX-License-Identifier:     GPL-2.0+
 
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>
 
13
#include <fsl_ddr_sdram.h>
 
14
#include <asm/fsl_law.h>
 
15
 
 
16
#define SYSCLK_MASK     0x00200000
 
17
#define BOARDREV_MASK   0x10100000
 
18
#define BOARDREV_B      0x10100000
 
19
#define BOARDREV_C      0x00100000
 
20
 
 
21
#define SYSCLK_66       66666666
 
22
#define SYSCLK_50       50000000
 
23
#define SYSCLK_100      100000000
 
24
 
 
25
DECLARE_GLOBAL_DATA_PTR;
 
26
 
 
27
void board_init_f(ulong bootflag)
 
28
{
 
29
        uint plat_ratio, bus_clk, sys_clk = 0;
 
30
        volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
 
31
        volatile ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
 
32
        uint val, temp, sysclk_mask;
 
33
 
 
34
        val = pgpio->gpdat;
 
35
        sysclk_mask = val & SYSCLK_MASK;
 
36
        temp = val & BOARDREV_MASK;
 
37
        if (temp == BOARDREV_C) {
 
38
                if(sysclk_mask == 0)
 
39
                        sys_clk = SYSCLK_66;
 
40
                else
 
41
                        sys_clk = SYSCLK_100;
 
42
        } else if (temp == BOARDREV_B) {
 
43
                if(sysclk_mask == 0)
 
44
                        sys_clk = SYSCLK_66;
 
45
                else
 
46
                        sys_clk = SYSCLK_50;
 
47
        }
 
48
 
 
49
        plat_ratio = gur->porpllsr & 0x0000003e;
 
50
        plat_ratio >>= 1;
 
51
        bus_clk = plat_ratio * sys_clk;
 
52
        NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
 
53
                        bus_clk / 16 / CONFIG_BAUDRATE);
 
54
 
 
55
        puts("\nNAND boot... ");
 
56
 
 
57
        /* copy code to DDR and jump to it - this should not return */
 
58
        /* NOTE - code has to be copied out of NAND buffer before
 
59
         * other blocks can be read.
 
60
         */
 
61
        relocate_code(CONFIG_SYS_NAND_U_BOOT_RELOC_SP, 0,
 
62
                        CONFIG_SYS_NAND_U_BOOT_RELOC);
 
63
}
 
64
 
 
65
void board_init_r(gd_t *gd, ulong dest_addr)
 
66
{
 
67
        nand_boot();
 
68
}
 
69
 
 
70
void putc(char c)
 
71
{
 
72
        if (c == '\n')
 
73
                NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r');
 
74
 
 
75
        NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c);
 
76
}
 
77
 
 
78
void puts(const char *str)
 
79
{
 
80
        while (*str)
 
81
                putc(*str++);
 
82
}