blob: ace0d795433c12f98cf565e23310b5f62849d199 [file] [log] [blame]
York Sun7b08d212014-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 Sharma25b8efe2015-03-19 09:20:43 -070015#include <fsl_debug_server.h>
J. German Rivera43e4ae32015-01-06 13:19:02 -080016#include <fsl-mc/fsl_mc.h>
Prabhakar Kushwahacf329182014-07-14 17:15:44 +053017#include <environment.h>
Mingkai Hu0e58b512015-10-26 19:47:50 +080018#include <asm/arch/soc.h>
York Sun7b08d212014-06-23 15:15:56 -070019
20DECLARE_GLOBAL_DATA_PTR;
21
22int board_init(void)
23{
24 init_final_memctl_regs();
Prabhakar Kushwahacf329182014-07-14 17:15:44 +053025
26#ifdef CONFIG_ENV_IS_NOWHERE
27 gd->env_addr = (ulong)&default_environment[0];
28#endif
29
York Sun7b08d212014-06-23 15:15:56 -070030 return 0;
31}
32
33int board_early_init_f(void)
34{
Scott Woodf64c98c2015-03-20 19:28:12 -070035 fsl_lsch3_early_init_f();
York Sun7b08d212014-06-23 15:15:56 -070036 return 0;
37}
38
York Sunc7a0e302014-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);
Prabhakar Kushwaha122bcfd2015-11-09 16:42:07 +053044#ifdef CONFIG_SYS_FSL_HAS_DP_DDR
York Sunc7a0e302014-08-13 10:21:05 -070045 if (gd->bd->bi_dram[2].size) {
46 puts("\nDP-DDR ");
47 print_size(gd->bd->bi_dram[2].size, "");
48 print_ddr_info(CONFIG_DP_DDR_CTRL);
49 }
Prabhakar Kushwaha122bcfd2015-11-09 16:42:07 +053050#endif
York Sunc7a0e302014-08-13 10:21:05 -070051}
52
York Sun7b08d212014-06-23 15:15:56 -070053int dram_init(void)
54{
York Sun7b08d212014-06-23 15:15:56 -070055 gd->ram_size = initdram(0);
56
57 return 0;
58}
59
Bhupesh Sharma25b8efe2015-03-19 09:20:43 -070060#if defined(CONFIG_ARCH_MISC_INIT)
61int arch_misc_init(void)
62{
63#ifdef CONFIG_FSL_DEBUG_SERVER
64 debug_server_init();
65#endif
66
67 return 0;
68}
69#endif
70
York Sun7b08d212014-06-23 15:15:56 -070071int board_eth_init(bd_t *bis)
72{
73 int error = 0;
74
75#ifdef CONFIG_SMC91111
76 error = smc91111_initialize(0, CONFIG_SMC91111_BASE);
77#endif
78
79#ifdef CONFIG_FSL_MC_ENET
80 error = cpu_eth_init(bis);
81#endif
82 return error;
83}
84
85#ifdef CONFIG_FSL_MC_ENET
86void fdt_fixup_board_enet(void *fdt)
87{
88 int offset;
89
Stuart Yodera3466152016-03-02 16:37:13 -060090 offset = fdt_path_offset(fdt, "/soc/fsl-mc");
J. German Rivera43e4ae32015-01-06 13:19:02 -080091
92 /*
93 * TODO: Remove this when backward compatibility
Stuart Yodera3466152016-03-02 16:37:13 -060094 * with old DT node (/fsl-mc) is no longer needed.
J. German Rivera43e4ae32015-01-06 13:19:02 -080095 */
96 if (offset < 0)
Stuart Yodera3466152016-03-02 16:37:13 -060097 offset = fdt_path_offset(fdt, "/fsl-mc");
J. German Rivera43e4ae32015-01-06 13:19:02 -080098
99 if (offset < 0) {
100 printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n",
101 __func__, offset);
102 return;
103 }
104
York Sun7b08d212014-06-23 15:15:56 -0700105 if (get_mc_boot_status() == 0)
106 fdt_status_okay(fdt, offset);
107 else
108 fdt_status_fail(fdt, offset);
109}
110#endif
111
112#ifdef CONFIG_OF_BOARD_SETUP
Simon Glass2aec3cc2014-10-23 18:58:47 -0600113int ft_board_setup(void *blob, bd_t *bd)
York Sun7b08d212014-06-23 15:15:56 -0700114{
Bhupesh Sharma0b10a1a2015-05-28 14:54:10 +0530115 u64 base[CONFIG_NR_DRAM_BANKS];
116 u64 size[CONFIG_NR_DRAM_BANKS];
York Sun7b08d212014-06-23 15:15:56 -0700117
York Sun290a83a2014-09-08 12:20:01 -0700118 ft_cpu_setup(blob, bd);
119
Bhupesh Sharma0b10a1a2015-05-28 14:54:10 +0530120 /* fixup DT for the two GPP DDR banks */
121 base[0] = gd->bd->bi_dram[0].start;
122 size[0] = gd->bd->bi_dram[0].size;
123 base[1] = gd->bd->bi_dram[1].start;
124 size[1] = gd->bd->bi_dram[1].size;
125
126 fdt_fixup_memory_banks(blob, base, size, 2);
York Sun7b08d212014-06-23 15:15:56 -0700127
128#ifdef CONFIG_FSL_MC_ENET
129 fdt_fixup_board_enet(blob);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700130 fsl_mc_ldpaa_exit(bd);
York Sun7b08d212014-06-23 15:15:56 -0700131#endif
Simon Glass2aec3cc2014-10-23 18:58:47 -0600132
133 return 0;
York Sun7b08d212014-06-23 15:15:56 -0700134}
135#endif