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> |
Bhupesh Sharma | 422cb08 | 2015-03-19 09:20:43 -0700 | [diff] [blame] | 15 | #include <fsl_debug_server.h> |
J. German Rivera | 7b3bd9a | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 16 | #include <fsl-mc/fsl_mc.h> |
Prabhakar Kushwaha | 1b35721 | 2014-07-14 17:15:44 +0530 | [diff] [blame] | 17 | #include <environment.h> |
Mingkai Hu | 9f3183d | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 18 | #include <asm/arch/soc.h> |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 19 | |
| 20 | DECLARE_GLOBAL_DATA_PTR; |
| 21 | |
| 22 | int board_init(void) |
| 23 | { |
| 24 | init_final_memctl_regs(); |
Prabhakar Kushwaha | 1b35721 | 2014-07-14 17:15:44 +0530 | [diff] [blame] | 25 | |
| 26 | #ifdef CONFIG_ENV_IS_NOWHERE |
| 27 | gd->env_addr = (ulong)&default_environment[0]; |
| 28 | #endif |
| 29 | |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | int board_early_init_f(void) |
| 34 | { |
Scott Wood | b991b98 | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 35 | fsl_lsch3_early_init_f(); |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 36 | return 0; |
| 37 | } |
| 38 | |
York Sun | d9c68b1 | 2014-08-13 10:21:05 -0700 | [diff] [blame] | 39 | void 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 Kushwaha | 4493721 | 2015-11-09 16:42:07 +0530 | [diff] [blame] | 44 | #ifdef CONFIG_SYS_FSL_HAS_DP_DDR |
York Sun | d9c68b1 | 2014-08-13 10:21:05 -0700 | [diff] [blame] | 45 | 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 Kushwaha | 4493721 | 2015-11-09 16:42:07 +0530 | [diff] [blame] | 50 | #endif |
York Sun | d9c68b1 | 2014-08-13 10:21:05 -0700 | [diff] [blame] | 51 | } |
| 52 | |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 53 | int dram_init(void) |
| 54 | { |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 55 | gd->ram_size = initdram(0); |
| 56 | |
| 57 | return 0; |
| 58 | } |
| 59 | |
Bhupesh Sharma | 422cb08 | 2015-03-19 09:20:43 -0700 | [diff] [blame] | 60 | #if defined(CONFIG_ARCH_MISC_INIT) |
| 61 | int 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 | |
| 71 | unsigned long get_dram_size_to_hide(void) |
| 72 | { |
| 73 | unsigned long dram_to_hide = 0; |
| 74 | |
| 75 | /* Carve the Debug Server private DRAM block from the end of DRAM */ |
| 76 | #ifdef CONFIG_FSL_DEBUG_SERVER |
| 77 | dram_to_hide += debug_server_get_dram_block_size(); |
| 78 | #endif |
| 79 | |
| 80 | /* Carve the MC private DRAM block from the end of DRAM */ |
| 81 | #ifdef CONFIG_FSL_MC_ENET |
| 82 | dram_to_hide += mc_get_dram_block_size(); |
| 83 | #endif |
| 84 | |
Prabhakar Kushwaha | 5c05508 | 2015-06-02 10:55:52 +0530 | [diff] [blame] | 85 | return roundup(dram_to_hide, CONFIG_SYS_MEM_TOP_HIDE_MIN); |
Bhupesh Sharma | 422cb08 | 2015-03-19 09:20:43 -0700 | [diff] [blame] | 86 | } |
| 87 | |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 88 | int board_eth_init(bd_t *bis) |
| 89 | { |
| 90 | int error = 0; |
| 91 | |
| 92 | #ifdef CONFIG_SMC91111 |
| 93 | error = smc91111_initialize(0, CONFIG_SMC91111_BASE); |
| 94 | #endif |
| 95 | |
| 96 | #ifdef CONFIG_FSL_MC_ENET |
| 97 | error = cpu_eth_init(bis); |
| 98 | #endif |
| 99 | return error; |
| 100 | } |
| 101 | |
| 102 | #ifdef CONFIG_FSL_MC_ENET |
| 103 | void fdt_fixup_board_enet(void *fdt) |
| 104 | { |
| 105 | int offset; |
| 106 | |
J. German Rivera | 7b3bd9a | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 107 | offset = fdt_path_offset(fdt, "/fsl-mc"); |
| 108 | |
| 109 | /* |
| 110 | * TODO: Remove this when backward compatibility |
| 111 | * with old DT node (fsl,dprc@0) is no longer needed. |
| 112 | */ |
| 113 | if (offset < 0) |
| 114 | offset = fdt_path_offset(fdt, "/fsl,dprc@0"); |
| 115 | |
| 116 | if (offset < 0) { |
| 117 | printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n", |
| 118 | __func__, offset); |
| 119 | return; |
| 120 | } |
| 121 | |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 122 | if (get_mc_boot_status() == 0) |
| 123 | fdt_status_okay(fdt, offset); |
| 124 | else |
| 125 | fdt_status_fail(fdt, offset); |
| 126 | } |
| 127 | #endif |
| 128 | |
| 129 | #ifdef CONFIG_OF_BOARD_SETUP |
Simon Glass | e895a4b | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 130 | int ft_board_setup(void *blob, bd_t *bd) |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 131 | { |
Bhupesh Sharma | a2dc818 | 2015-05-28 14:54:10 +0530 | [diff] [blame] | 132 | u64 base[CONFIG_NR_DRAM_BANKS]; |
| 133 | u64 size[CONFIG_NR_DRAM_BANKS]; |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 134 | |
York Sun | 8bfa301 | 2014-09-08 12:20:01 -0700 | [diff] [blame] | 135 | ft_cpu_setup(blob, bd); |
| 136 | |
Bhupesh Sharma | a2dc818 | 2015-05-28 14:54:10 +0530 | [diff] [blame] | 137 | /* fixup DT for the two GPP DDR banks */ |
| 138 | base[0] = gd->bd->bi_dram[0].start; |
| 139 | size[0] = gd->bd->bi_dram[0].size; |
| 140 | base[1] = gd->bd->bi_dram[1].start; |
| 141 | size[1] = gd->bd->bi_dram[1].size; |
| 142 | |
| 143 | fdt_fixup_memory_banks(blob, base, size, 2); |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 144 | |
| 145 | #ifdef CONFIG_FSL_MC_ENET |
| 146 | fdt_fixup_board_enet(blob); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 147 | fsl_mc_ldpaa_exit(bd); |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 148 | #endif |
Simon Glass | e895a4b | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 149 | |
| 150 | return 0; |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 151 | } |
| 152 | #endif |