2 * Copyright 2013 Freescale Semiconductor, Inc.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #include "../common/ngpixis.h"
29 #include <fsl_esdhc.h>
31 DECLARE_GLOBAL_DATA_PTR
;
33 static const u32 sysclk_tbl
[] = {
34 66666000, 7499900, 83332500, 8999900,
35 99999000, 11111000, 12499800, 13333200
38 ulong
get_effective_memsize(void)
40 return CONFIG_SYS_L2_SIZE
;
43 void board_init_f(ulong bootflag
)
46 u32 plat_ratio
, sys_clk
, bus_clk
;
47 ccsr_gur_t
*gur
= (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR
;
51 /* Set pmuxcr to allow both i2c1 and i2c2 */
52 setbits_be32(&gur
->pmuxcr
, in_be32(&gur
->pmuxcr
) | 0x1000);
53 setbits_be32(&gur
->pmuxcr
,
54 in_be32(&gur
->pmuxcr
) | MPC85xx_PMUXCR_SD_DATA
);
56 /* Read back the register to synchronize the write. */
57 in_be32(&gur
->pmuxcr
);
59 /* initialize selected port with appropriate baud rate */
60 px_spd
= in_8((unsigned char *)(PIXIS_BASE
+ PIXIS_SPD
));
61 sys_clk
= sysclk_tbl
[px_spd
& PIXIS_SPD_SYSCLK_MASK
];
62 plat_ratio
= in_be32(&gur
->porpllsr
) & MPC85xx_PORPLLSR_PLAT_RATIO
;
63 bus_clk
= sys_clk
* plat_ratio
/ 2;
65 NS16550_init((NS16550_t
)CONFIG_SYS_NS16550_COM1
,
66 bus_clk
/ 16 / CONFIG_BAUDRATE
);
67 #ifdef CONFIG_SPL_MMC_BOOT
68 puts("\nSD boot...\n");
71 /* copy code to RAM and jump to it - this should not return */
72 /* NOTE - code has to be copied out of NAND buffer before
73 * other blocks can be read.
75 relocate_code(CONFIG_SPL_RELOC_STACK
, 0, CONFIG_SPL_RELOC_TEXT_BASE
);
78 void board_init_r(gd_t
*gd
, ulong dest_addr
)
80 /* Pointer is writable since we allocated a register for it */
81 gd
= (gd_t
*)CONFIG_SPL_GD_ADDR
;
84 memset(gd
, 0, sizeof(gd_t
));
85 bd
= (bd_t
*)(CONFIG_SPL_GD_ADDR
+ sizeof(gd_t
));
86 memset(bd
, 0, sizeof(bd_t
));
88 bd
->bi_memstart
= CONFIG_SYS_INIT_L2_ADDR
;
89 bd
->bi_memsize
= CONFIG_SYS_L2_SIZE
;
93 mem_malloc_init(CONFIG_SPL_RELOC_MALLOC_ADDR
,
94 CONFIG_SPL_RELOC_MALLOC_SIZE
);
96 #ifdef CONFIG_SPL_MMC_BOOT
99 /* relocate environment function pointers etc. */
102 i2c_init(CONFIG_SYS_FSL_I2C_SPEED
, CONFIG_SYS_I2C_SLAVE
);
104 gd
->ram_size
= initdram(0);
105 puts("Second program loader running in sram...\n");
107 #ifdef CONFIG_SPL_MMC_BOOT