blob: e78c63ada0eb8b6681fca43acb9b86a9c766531d [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>
Bhupesh Sharma422cb082015-03-19 09:20:43 -070015#include <fsl_debug_server.h>
J. German Rivera7b3bd9a2015-01-06 13:19:02 -080016#include <fsl-mc/fsl_mc.h>
Prabhakar Kushwaha1b357212014-07-14 17:15:44 +053017#include <environment.h>
York Sunf749db32014-06-23 15:15:56 -070018
19DECLARE_GLOBAL_DATA_PTR;
20
21int board_init(void)
22{
23 init_final_memctl_regs();
Prabhakar Kushwaha1b357212014-07-14 17:15:44 +053024
25#ifdef CONFIG_ENV_IS_NOWHERE
26 gd->env_addr = (ulong)&default_environment[0];
27#endif
28
York Sunf749db32014-06-23 15:15:56 -070029 return 0;
30}
31
32int board_early_init_f(void)
33{
34 init_early_memctl_regs(); /* tighten IFC timing */
35
36 return 0;
37}
38
York Sund9c68b12014-08-13 10:21:05 -070039void detail_board_ddr_info(void)
40{
41 puts("\nDDR ");
42 print_size(gd->bd->bi_dram[0].size + gd->bd->bi_dram[1].size, "");
43 print_ddr_info(0);
44 if (gd->bd->bi_dram[2].size) {
45 puts("\nDP-DDR ");
46 print_size(gd->bd->bi_dram[2].size, "");
47 print_ddr_info(CONFIG_DP_DDR_CTRL);
48 }
49}
50
York Sunf749db32014-06-23 15:15:56 -070051int dram_init(void)
52{
York Sunf749db32014-06-23 15:15:56 -070053 gd->ram_size = initdram(0);
54
55 return 0;
56}
57
58int timer_init(void)
59{
60 u32 __iomem *cntcr = (u32 *)CONFIG_SYS_FSL_TIMER_ADDR;
61 u32 __iomem *cltbenr = (u32 *)CONFIG_SYS_FSL_PMU_CLTBENR;
62
York Sun32da3392015-01-06 13:18:43 -080063 /* Enable timebase for all clusters.
64 * It is safe to do so even some clusters are not enabled.
65 */
66 out_le32(cltbenr, 0xf);
67
68 /* Enable clock for timer
69 * This is a global setting.
70 */
71 out_le32(cntcr, 0x1);
York Sunf749db32014-06-23 15:15:56 -070072
73 return 0;
74}
75
76/*
77 * Board specific reset that is system reset.
78 */
79void reset_cpu(ulong addr)
80{
81}
82
Bhupesh Sharma422cb082015-03-19 09:20:43 -070083#if defined(CONFIG_ARCH_MISC_INIT)
84int arch_misc_init(void)
85{
86#ifdef CONFIG_FSL_DEBUG_SERVER
87 debug_server_init();
88#endif
89
90 return 0;
91}
92#endif
93
94unsigned long get_dram_size_to_hide(void)
95{
96 unsigned long dram_to_hide = 0;
97
98/* Carve the Debug Server private DRAM block from the end of DRAM */
99#ifdef CONFIG_FSL_DEBUG_SERVER
100 dram_to_hide += debug_server_get_dram_block_size();
101#endif
102
103/* Carve the MC private DRAM block from the end of DRAM */
104#ifdef CONFIG_FSL_MC_ENET
105 dram_to_hide += mc_get_dram_block_size();
106#endif
107
108 return dram_to_hide;
109}
110
York Sunf749db32014-06-23 15:15:56 -0700111int board_eth_init(bd_t *bis)
112{
113 int error = 0;
114
115#ifdef CONFIG_SMC91111
116 error = smc91111_initialize(0, CONFIG_SMC91111_BASE);
117#endif
118
119#ifdef CONFIG_FSL_MC_ENET
120 error = cpu_eth_init(bis);
121#endif
122 return error;
123}
124
125#ifdef CONFIG_FSL_MC_ENET
126void fdt_fixup_board_enet(void *fdt)
127{
128 int offset;
129
J. German Rivera7b3bd9a2015-01-06 13:19:02 -0800130 offset = fdt_path_offset(fdt, "/fsl-mc");
131
132 /*
133 * TODO: Remove this when backward compatibility
134 * with old DT node (fsl,dprc@0) is no longer needed.
135 */
136 if (offset < 0)
137 offset = fdt_path_offset(fdt, "/fsl,dprc@0");
138
139 if (offset < 0) {
140 printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n",
141 __func__, offset);
142 return;
143 }
144
York Sunf749db32014-06-23 15:15:56 -0700145 if (get_mc_boot_status() == 0)
146 fdt_status_okay(fdt, offset);
147 else
148 fdt_status_fail(fdt, offset);
149}
150#endif
151
152#ifdef CONFIG_OF_BOARD_SETUP
Simon Glasse895a4b2014-10-23 18:58:47 -0600153int ft_board_setup(void *blob, bd_t *bd)
York Sunf749db32014-06-23 15:15:56 -0700154{
155 phys_addr_t base;
156 phys_size_t size;
157
York Sun8bfa3012014-09-08 12:20:01 -0700158 ft_cpu_setup(blob, bd);
159
York Sunf749db32014-06-23 15:15:56 -0700160 /* limit the memory size to bank 1 until Linux can handle 40-bit PA */
161 base = getenv_bootm_low();
162 size = getenv_bootm_size();
163 fdt_fixup_memory(blob, (u64)base, (u64)size);
164
165#ifdef CONFIG_FSL_MC_ENET
166 fdt_fixup_board_enet(blob);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700167 fsl_mc_ldpaa_exit(bd);
York Sunf749db32014-06-23 15:15:56 -0700168#endif
Simon Glasse895a4b2014-10-23 18:58:47 -0600169
170 return 0;
York Sunf749db32014-06-23 15:15:56 -0700171}
172#endif