York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 1 | /* |
| 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> |
J. German Rivera | 7b3bd9a | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 15 | #include <fsl-mc/fsl_mc.h> |
Prabhakar Kushwaha | 1b35721 | 2014-07-14 17:15:44 +0530 | [diff] [blame] | 16 | #include <environment.h> |
Mingkai Hu | 9f3183d | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 17 | #include <asm/arch/soc.h> |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 18 | |
| 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
| 21 | int board_init(void) |
| 22 | { |
| 23 | init_final_memctl_regs(); |
Prabhakar Kushwaha | 1b35721 | 2014-07-14 17:15:44 +0530 | [diff] [blame] | 24 | |
| 25 | #ifdef CONFIG_ENV_IS_NOWHERE |
| 26 | gd->env_addr = (ulong)&default_environment[0]; |
| 27 | #endif |
| 28 | |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 29 | return 0; |
| 30 | } |
| 31 | |
| 32 | int board_early_init_f(void) |
| 33 | { |
Scott Wood | b991b98 | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 34 | fsl_lsch3_early_init_f(); |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 35 | return 0; |
| 36 | } |
| 37 | |
York Sun | d9c68b1 | 2014-08-13 10:21:05 -0700 | [diff] [blame] | 38 | void detail_board_ddr_info(void) |
| 39 | { |
| 40 | puts("\nDDR "); |
| 41 | print_size(gd->bd->bi_dram[0].size + gd->bd->bi_dram[1].size, ""); |
| 42 | print_ddr_info(0); |
Prabhakar Kushwaha | 4493721 | 2015-11-09 16:42:07 +0530 | [diff] [blame] | 43 | #ifdef CONFIG_SYS_FSL_HAS_DP_DDR |
York Sun | 3c1d218 | 2016-04-04 11:41:26 -0700 | [diff] [blame] | 44 | if (soc_has_dp_ddr() && gd->bd->bi_dram[2].size) { |
York Sun | d9c68b1 | 2014-08-13 10:21:05 -0700 | [diff] [blame] | 45 | puts("\nDP-DDR "); |
| 46 | print_size(gd->bd->bi_dram[2].size, ""); |
| 47 | print_ddr_info(CONFIG_DP_DDR_CTRL); |
| 48 | } |
Prabhakar Kushwaha | 4493721 | 2015-11-09 16:42:07 +0530 | [diff] [blame] | 49 | #endif |
York Sun | d9c68b1 | 2014-08-13 10:21:05 -0700 | [diff] [blame] | 50 | } |
| 51 | |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 52 | int dram_init(void) |
| 53 | { |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 54 | gd->ram_size = initdram(0); |
| 55 | |
| 56 | return 0; |
| 57 | } |
| 58 | |
Bhupesh Sharma | 422cb08 | 2015-03-19 09:20:43 -0700 | [diff] [blame] | 59 | #if defined(CONFIG_ARCH_MISC_INIT) |
| 60 | int arch_misc_init(void) |
| 61 | { |
Bhupesh Sharma | 422cb08 | 2015-03-19 09:20:43 -0700 | [diff] [blame] | 62 | return 0; |
| 63 | } |
| 64 | #endif |
| 65 | |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 66 | int board_eth_init(bd_t *bis) |
| 67 | { |
| 68 | int error = 0; |
| 69 | |
| 70 | #ifdef CONFIG_SMC91111 |
| 71 | error = smc91111_initialize(0, CONFIG_SMC91111_BASE); |
| 72 | #endif |
| 73 | |
| 74 | #ifdef CONFIG_FSL_MC_ENET |
| 75 | error = cpu_eth_init(bis); |
| 76 | #endif |
| 77 | return error; |
| 78 | } |
| 79 | |
| 80 | #ifdef CONFIG_FSL_MC_ENET |
| 81 | void fdt_fixup_board_enet(void *fdt) |
| 82 | { |
| 83 | int offset; |
| 84 | |
Stuart Yoder | e91f1de | 2016-03-02 16:37:13 -0600 | [diff] [blame] | 85 | offset = fdt_path_offset(fdt, "/soc/fsl-mc"); |
J. German Rivera | 7b3bd9a | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 86 | |
| 87 | /* |
| 88 | * TODO: Remove this when backward compatibility |
Stuart Yoder | e91f1de | 2016-03-02 16:37:13 -0600 | [diff] [blame] | 89 | * with old DT node (/fsl-mc) is no longer needed. |
J. German Rivera | 7b3bd9a | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 90 | */ |
| 91 | if (offset < 0) |
Stuart Yoder | e91f1de | 2016-03-02 16:37:13 -0600 | [diff] [blame] | 92 | offset = fdt_path_offset(fdt, "/fsl-mc"); |
J. German Rivera | 7b3bd9a | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 93 | |
| 94 | if (offset < 0) { |
| 95 | printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n", |
| 96 | __func__, offset); |
| 97 | return; |
| 98 | } |
| 99 | |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 100 | if (get_mc_boot_status() == 0) |
| 101 | fdt_status_okay(fdt, offset); |
| 102 | else |
| 103 | fdt_status_fail(fdt, offset); |
| 104 | } |
| 105 | #endif |
| 106 | |
| 107 | #ifdef CONFIG_OF_BOARD_SETUP |
Simon Glass | e895a4b | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 108 | int ft_board_setup(void *blob, bd_t *bd) |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 109 | { |
Bhupesh Sharma | a2dc818 | 2015-05-28 14:54:10 +0530 | [diff] [blame] | 110 | u64 base[CONFIG_NR_DRAM_BANKS]; |
| 111 | u64 size[CONFIG_NR_DRAM_BANKS]; |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 112 | |
York Sun | 8bfa301 | 2014-09-08 12:20:01 -0700 | [diff] [blame] | 113 | ft_cpu_setup(blob, bd); |
| 114 | |
Bhupesh Sharma | a2dc818 | 2015-05-28 14:54:10 +0530 | [diff] [blame] | 115 | /* fixup DT for the two GPP DDR banks */ |
| 116 | base[0] = gd->bd->bi_dram[0].start; |
| 117 | size[0] = gd->bd->bi_dram[0].size; |
| 118 | base[1] = gd->bd->bi_dram[1].start; |
| 119 | size[1] = gd->bd->bi_dram[1].size; |
| 120 | |
| 121 | fdt_fixup_memory_banks(blob, base, size, 2); |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 122 | |
| 123 | #ifdef CONFIG_FSL_MC_ENET |
| 124 | fdt_fixup_board_enet(blob); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 125 | fsl_mc_ldpaa_exit(bd); |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 126 | #endif |
Simon Glass | e895a4b | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 127 | |
| 128 | return 0; |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 129 | } |
| 130 | #endif |