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> |
| 15 | #include <fsl_mc.h> |
Prabhakar Kushwaha | 1b35721 | 2014-07-14 17:15:44 +0530 | [diff] [blame] | 16 | #include <environment.h> |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 17 | |
| 18 | DECLARE_GLOBAL_DATA_PTR; |
| 19 | |
| 20 | int board_init(void) |
| 21 | { |
| 22 | init_final_memctl_regs(); |
Prabhakar Kushwaha | 1b35721 | 2014-07-14 17:15:44 +0530 | [diff] [blame] | 23 | |
| 24 | #ifdef CONFIG_ENV_IS_NOWHERE |
| 25 | gd->env_addr = (ulong)&default_environment[0]; |
| 26 | #endif |
| 27 | |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | int board_early_init_f(void) |
| 32 | { |
| 33 | init_early_memctl_regs(); /* tighten IFC timing */ |
| 34 | |
| 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); |
| 43 | if (gd->bd->bi_dram[2].size) { |
| 44 | puts("\nDP-DDR "); |
| 45 | print_size(gd->bd->bi_dram[2].size, ""); |
| 46 | print_ddr_info(CONFIG_DP_DDR_CTRL); |
| 47 | } |
| 48 | } |
| 49 | |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 50 | int dram_init(void) |
| 51 | { |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 52 | gd->ram_size = initdram(0); |
| 53 | |
| 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | int timer_init(void) |
| 58 | { |
| 59 | u32 __iomem *cntcr = (u32 *)CONFIG_SYS_FSL_TIMER_ADDR; |
| 60 | u32 __iomem *cltbenr = (u32 *)CONFIG_SYS_FSL_PMU_CLTBENR; |
| 61 | |
| 62 | out_le32(cltbenr, 0x1); /* enable cluster0 timebase */ |
| 63 | out_le32(cntcr, 0x1); /* enable clock for timer */ |
| 64 | |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | /* |
| 69 | * Board specific reset that is system reset. |
| 70 | */ |
| 71 | void reset_cpu(ulong addr) |
| 72 | { |
| 73 | } |
| 74 | |
| 75 | int board_eth_init(bd_t *bis) |
| 76 | { |
| 77 | int error = 0; |
| 78 | |
| 79 | #ifdef CONFIG_SMC91111 |
| 80 | error = smc91111_initialize(0, CONFIG_SMC91111_BASE); |
| 81 | #endif |
| 82 | |
| 83 | #ifdef CONFIG_FSL_MC_ENET |
| 84 | error = cpu_eth_init(bis); |
| 85 | #endif |
| 86 | return error; |
| 87 | } |
| 88 | |
| 89 | #ifdef CONFIG_FSL_MC_ENET |
| 90 | void fdt_fixup_board_enet(void *fdt) |
| 91 | { |
| 92 | int offset; |
| 93 | |
| 94 | offset = fdt_path_offset(fdt, "/fsl,dprc@0"); |
| 95 | if (get_mc_boot_status() == 0) |
| 96 | fdt_status_okay(fdt, offset); |
| 97 | else |
| 98 | fdt_status_fail(fdt, offset); |
| 99 | } |
| 100 | #endif |
| 101 | |
| 102 | #ifdef CONFIG_OF_BOARD_SETUP |
Simon Glass | e895a4b | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 103 | int ft_board_setup(void *blob, bd_t *bd) |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 104 | { |
| 105 | phys_addr_t base; |
| 106 | phys_size_t size; |
| 107 | |
York Sun | 8bfa301 | 2014-09-08 12:20:01 -0700 | [diff] [blame] | 108 | ft_cpu_setup(blob, bd); |
| 109 | |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 110 | /* limit the memory size to bank 1 until Linux can handle 40-bit PA */ |
| 111 | base = getenv_bootm_low(); |
| 112 | size = getenv_bootm_size(); |
| 113 | fdt_fixup_memory(blob, (u64)base, (u64)size); |
| 114 | |
| 115 | #ifdef CONFIG_FSL_MC_ENET |
| 116 | fdt_fixup_board_enet(blob); |
| 117 | #endif |
Simon Glass | e895a4b | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 118 | |
| 119 | return 0; |
York Sun | f749db3 | 2014-06-23 15:15:56 -0700 | [diff] [blame] | 120 | } |
| 121 | #endif |