blob: d19f692e07aa1c186b006a1b05f787f8f0d138ff [file] [log] [blame]
York Sunf749db32014-06-23 15:15:56 -07001/*
2 * Copyright 2014 Freescale Semiconductor
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6#include <common.h>
7#include <malloc.h>
8#include <errno.h>
9#include <netdev.h>
10#include <fsl_ifc.h>
11#include <fsl_ddr.h>
12#include <asm/io.h>
13#include <fdt_support.h>
14#include <libfdt.h>
15#include <fsl_mc.h>
Prabhakar Kushwaha1b357212014-07-14 17:15:44 +053016#include <environment.h>
York Sunf749db32014-06-23 15:15:56 -070017
18DECLARE_GLOBAL_DATA_PTR;
19
20int board_init(void)
21{
22 init_final_memctl_regs();
Prabhakar Kushwaha1b357212014-07-14 17:15:44 +053023
24#ifdef CONFIG_ENV_IS_NOWHERE
25 gd->env_addr = (ulong)&default_environment[0];
26#endif
27
York Sunf749db32014-06-23 15:15:56 -070028 return 0;
29}
30
31int board_early_init_f(void)
32{
33 init_early_memctl_regs(); /* tighten IFC timing */
34
35 return 0;
36}
37
38int dram_init(void)
39{
40 printf("DRAM: ");
41 gd->ram_size = initdram(0);
42
43 return 0;
44}
45
46int timer_init(void)
47{
48 u32 __iomem *cntcr = (u32 *)CONFIG_SYS_FSL_TIMER_ADDR;
49 u32 __iomem *cltbenr = (u32 *)CONFIG_SYS_FSL_PMU_CLTBENR;
50
51 out_le32(cltbenr, 0x1); /* enable cluster0 timebase */
52 out_le32(cntcr, 0x1); /* enable clock for timer */
53
54 return 0;
55}
56
57/*
58 * Board specific reset that is system reset.
59 */
60void reset_cpu(ulong addr)
61{
62}
63
64int board_eth_init(bd_t *bis)
65{
66 int error = 0;
67
68#ifdef CONFIG_SMC91111
69 error = smc91111_initialize(0, CONFIG_SMC91111_BASE);
70#endif
71
72#ifdef CONFIG_FSL_MC_ENET
73 error = cpu_eth_init(bis);
74#endif
75 return error;
76}
77
78#ifdef CONFIG_FSL_MC_ENET
79void fdt_fixup_board_enet(void *fdt)
80{
81 int offset;
82
83 offset = fdt_path_offset(fdt, "/fsl,dprc@0");
84 if (get_mc_boot_status() == 0)
85 fdt_status_okay(fdt, offset);
86 else
87 fdt_status_fail(fdt, offset);
88}
89#endif
90
91#ifdef CONFIG_OF_BOARD_SETUP
92void ft_board_setup(void *blob, bd_t *bd)
93{
94 phys_addr_t base;
95 phys_size_t size;
96
97 /* limit the memory size to bank 1 until Linux can handle 40-bit PA */
98 base = getenv_bootm_low();
99 size = getenv_bootm_size();
100 fdt_fixup_memory(blob, (u64)base, (u64)size);
101
102#ifdef CONFIG_FSL_MC_ENET
103 fdt_fixup_board_enet(blob);
104#endif
105}
106#endif