York Sun | 7b08d21 | 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 | 25b8efe | 2015-03-19 09:20:43 -0700 | [diff] [blame] | 15 | #include <fsl_debug_server.h> |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 16 | #include <fsl-mc/fsl_mc.h> |
Prabhakar Kushwaha | cf32918 | 2014-07-14 17:15:44 +0530 | [diff] [blame] | 17 | #include <environment.h> |
Scott Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 18 | #include <asm/arch-fsl-lsch3/soc.h> |
York Sun | 7b08d21 | 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 | cf32918 | 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 | 7b08d21 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | int board_early_init_f(void) |
| 34 | { |
Scott Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 35 | fsl_lsch3_early_init_f(); |
York Sun | 7b08d21 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 36 | return 0; |
| 37 | } |
| 38 | |
York Sun | c7a0e30 | 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); |
| 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 Sun | 7b08d21 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 51 | int dram_init(void) |
| 52 | { |
York Sun | 7b08d21 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 53 | gd->ram_size = initdram(0); |
| 54 | |
| 55 | return 0; |
| 56 | } |
| 57 | |
Bhupesh Sharma | 25b8efe | 2015-03-19 09:20:43 -0700 | [diff] [blame] | 58 | #if defined(CONFIG_ARCH_MISC_INIT) |
| 59 | int arch_misc_init(void) |
| 60 | { |
| 61 | #ifdef CONFIG_FSL_DEBUG_SERVER |
| 62 | debug_server_init(); |
| 63 | #endif |
| 64 | |
| 65 | return 0; |
| 66 | } |
| 67 | #endif |
| 68 | |
| 69 | unsigned long get_dram_size_to_hide(void) |
| 70 | { |
| 71 | unsigned long dram_to_hide = 0; |
| 72 | |
| 73 | /* Carve the Debug Server private DRAM block from the end of DRAM */ |
| 74 | #ifdef CONFIG_FSL_DEBUG_SERVER |
| 75 | dram_to_hide += debug_server_get_dram_block_size(); |
| 76 | #endif |
| 77 | |
| 78 | /* Carve the MC private DRAM block from the end of DRAM */ |
| 79 | #ifdef CONFIG_FSL_MC_ENET |
| 80 | dram_to_hide += mc_get_dram_block_size(); |
| 81 | #endif |
| 82 | |
| 83 | return dram_to_hide; |
| 84 | } |
| 85 | |
York Sun | 7b08d21 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 86 | int board_eth_init(bd_t *bis) |
| 87 | { |
| 88 | int error = 0; |
| 89 | |
| 90 | #ifdef CONFIG_SMC91111 |
| 91 | error = smc91111_initialize(0, CONFIG_SMC91111_BASE); |
| 92 | #endif |
| 93 | |
| 94 | #ifdef CONFIG_FSL_MC_ENET |
| 95 | error = cpu_eth_init(bis); |
| 96 | #endif |
| 97 | return error; |
| 98 | } |
| 99 | |
| 100 | #ifdef CONFIG_FSL_MC_ENET |
| 101 | void fdt_fixup_board_enet(void *fdt) |
| 102 | { |
| 103 | int offset; |
| 104 | |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 105 | offset = fdt_path_offset(fdt, "/fsl-mc"); |
| 106 | |
| 107 | /* |
| 108 | * TODO: Remove this when backward compatibility |
| 109 | * with old DT node (fsl,dprc@0) is no longer needed. |
| 110 | */ |
| 111 | if (offset < 0) |
| 112 | offset = fdt_path_offset(fdt, "/fsl,dprc@0"); |
| 113 | |
| 114 | if (offset < 0) { |
| 115 | printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n", |
| 116 | __func__, offset); |
| 117 | return; |
| 118 | } |
| 119 | |
York Sun | 7b08d21 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 120 | if (get_mc_boot_status() == 0) |
| 121 | fdt_status_okay(fdt, offset); |
| 122 | else |
| 123 | fdt_status_fail(fdt, offset); |
| 124 | } |
| 125 | #endif |
| 126 | |
| 127 | #ifdef CONFIG_OF_BOARD_SETUP |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 128 | int ft_board_setup(void *blob, bd_t *bd) |
York Sun | 7b08d21 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 129 | { |
| 130 | phys_addr_t base; |
| 131 | phys_size_t size; |
| 132 | |
York Sun | 290a83a | 2014-09-08 12:20:01 -0700 | [diff] [blame] | 133 | ft_cpu_setup(blob, bd); |
| 134 | |
York Sun | 7b08d21 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 135 | /* limit the memory size to bank 1 until Linux can handle 40-bit PA */ |
| 136 | base = getenv_bootm_low(); |
| 137 | size = getenv_bootm_size(); |
| 138 | fdt_fixup_memory(blob, (u64)base, (u64)size); |
| 139 | |
| 140 | #ifdef CONFIG_FSL_MC_ENET |
| 141 | fdt_fixup_board_enet(blob); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 142 | fsl_mc_ldpaa_exit(bd); |
York Sun | 7b08d21 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 143 | #endif |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 144 | |
| 145 | return 0; |
York Sun | 7b08d21 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 146 | } |
| 147 | #endif |