blob: 698ae1f9a65b985b7a84ffb3e3f05cd8c4e98c52 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
York Sunf749db32014-06-23 15:15:56 -07002/*
3 * Copyright 2014 Freescale Semiconductor
York Sunf749db32014-06-23 15:15:56 -07004 */
5#include <common.h>
6#include <malloc.h>
7#include <errno.h>
8#include <netdev.h>
9#include <fsl_ifc.h>
10#include <fsl_ddr.h>
11#include <asm/io.h>
12#include <fdt_support.h>
Masahiro Yamadab08c8c42018-03-05 01:20:11 +090013#include <linux/libfdt.h>
J. German Rivera7b3bd9a2015-01-06 13:19:02 -080014#include <fsl-mc/fsl_mc.h>
Prabhakar Kushwaha1b357212014-07-14 17:15:44 +053015#include <environment.h>
Mingkai Hu9f3183d2015-10-26 19:47:50 +080016#include <asm/arch/soc.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{
Scott Woodb991b982015-03-20 19:28:12 -070033 fsl_lsch3_early_init_f();
York Sunf749db32014-06-23 15:15:56 -070034 return 0;
35}
36
York Sund9c68b12014-08-13 10:21:05 -070037void detail_board_ddr_info(void)
38{
39 puts("\nDDR ");
40 print_size(gd->bd->bi_dram[0].size + gd->bd->bi_dram[1].size, "");
41 print_ddr_info(0);
Prabhakar Kushwaha44937212015-11-09 16:42:07 +053042#ifdef CONFIG_SYS_FSL_HAS_DP_DDR
York Sun3c1d2182016-04-04 11:41:26 -070043 if (soc_has_dp_ddr() && gd->bd->bi_dram[2].size) {
York Sund9c68b12014-08-13 10:21:05 -070044 puts("\nDP-DDR ");
45 print_size(gd->bd->bi_dram[2].size, "");
46 print_ddr_info(CONFIG_DP_DDR_CTRL);
47 }
Prabhakar Kushwaha44937212015-11-09 16:42:07 +053048#endif
York Sund9c68b12014-08-13 10:21:05 -070049}
50
Bhupesh Sharma422cb082015-03-19 09:20:43 -070051#if defined(CONFIG_ARCH_MISC_INIT)
52int arch_misc_init(void)
53{
Bhupesh Sharma422cb082015-03-19 09:20:43 -070054 return 0;
55}
56#endif
57
York Sunf749db32014-06-23 15:15:56 -070058int board_eth_init(bd_t *bis)
59{
60 int error = 0;
61
62#ifdef CONFIG_SMC91111
63 error = smc91111_initialize(0, CONFIG_SMC91111_BASE);
64#endif
65
Santan Kumar1f55a932017-05-05 15:42:29 +053066#if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
York Sunf749db32014-06-23 15:15:56 -070067 error = cpu_eth_init(bis);
68#endif
69 return error;
70}
71
Santan Kumar1f55a932017-05-05 15:42:29 +053072#if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
York Sunf749db32014-06-23 15:15:56 -070073void fdt_fixup_board_enet(void *fdt)
74{
75 int offset;
76
Stuart Yodere91f1de2016-03-02 16:37:13 -060077 offset = fdt_path_offset(fdt, "/soc/fsl-mc");
J. German Rivera7b3bd9a2015-01-06 13:19:02 -080078
79 /*
80 * TODO: Remove this when backward compatibility
Stuart Yodere91f1de2016-03-02 16:37:13 -060081 * with old DT node (/fsl-mc) is no longer needed.
J. German Rivera7b3bd9a2015-01-06 13:19:02 -080082 */
83 if (offset < 0)
Stuart Yodere91f1de2016-03-02 16:37:13 -060084 offset = fdt_path_offset(fdt, "/fsl-mc");
J. German Rivera7b3bd9a2015-01-06 13:19:02 -080085
86 if (offset < 0) {
87 printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n",
88 __func__, offset);
89 return;
90 }
91
Yogesh Gaur70a131e2017-12-07 11:10:14 +053092 if ((get_mc_boot_status() == 0) && (get_dpl_apply_status() == 0))
York Sunf749db32014-06-23 15:15:56 -070093 fdt_status_okay(fdt, offset);
94 else
95 fdt_status_fail(fdt, offset);
96}
Alexander Grafb7b84102016-11-17 01:02:57 +010097
98void board_quiesce_devices(void)
99{
100 fsl_mc_ldpaa_exit(gd->bd);
101}
York Sunf749db32014-06-23 15:15:56 -0700102#endif
103
104#ifdef CONFIG_OF_BOARD_SETUP
Simon Glasse895a4b2014-10-23 18:58:47 -0600105int ft_board_setup(void *blob, bd_t *bd)
York Sunf749db32014-06-23 15:15:56 -0700106{
Bhupesh Sharmaa2dc8182015-05-28 14:54:10 +0530107 u64 base[CONFIG_NR_DRAM_BANKS];
108 u64 size[CONFIG_NR_DRAM_BANKS];
York Sunf749db32014-06-23 15:15:56 -0700109
York Sun8bfa3012014-09-08 12:20:01 -0700110 ft_cpu_setup(blob, bd);
111
Bhupesh Sharmaa2dc8182015-05-28 14:54:10 +0530112 /* fixup DT for the two GPP DDR banks */
113 base[0] = gd->bd->bi_dram[0].start;
114 size[0] = gd->bd->bi_dram[0].size;
115 base[1] = gd->bd->bi_dram[1].start;
116 size[1] = gd->bd->bi_dram[1].size;
117
York Sun36cc0de2017-03-06 09:02:28 -0800118#ifdef CONFIG_RESV_RAM
119 /* reduce size if reserved memory is within this bank */
120 if (gd->arch.resv_ram >= base[0] &&
121 gd->arch.resv_ram < base[0] + size[0])
122 size[0] = gd->arch.resv_ram - base[0];
123 else if (gd->arch.resv_ram >= base[1] &&
124 gd->arch.resv_ram < base[1] + size[1])
125 size[1] = gd->arch.resv_ram - base[1];
126#endif
127
Bhupesh Sharmaa2dc8182015-05-28 14:54:10 +0530128 fdt_fixup_memory_banks(blob, base, size, 2);
York Sunf749db32014-06-23 15:15:56 -0700129
Nipun Guptaa78df402018-08-20 16:01:14 +0530130 fdt_fsl_mc_fixup_iommu_map_entry(blob);
131
Santan Kumar1f55a932017-05-05 15:42:29 +0530132#if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
York Sunf749db32014-06-23 15:15:56 -0700133 fdt_fixup_board_enet(blob);
134#endif
Simon Glasse895a4b2014-10-23 18:58:47 -0600135
136 return 0;
York Sunf749db32014-06-23 15:15:56 -0700137}
138#endif
Bogdan Purcareata33a89912017-05-24 16:40:21 +0000139
140#if defined(CONFIG_RESET_PHY_R)
141void reset_phy(void)
142{
143}
144#endif