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> |
| 15 | #include <fsl_mc.h> |
| 16 | |
| 17 | DECLARE_GLOBAL_DATA_PTR; |
| 18 | |
| 19 | int board_init(void) |
| 20 | { |
| 21 | init_final_memctl_regs(); |
| 22 | return 0; |
| 23 | } |
| 24 | |
| 25 | int board_early_init_f(void) |
| 26 | { |
| 27 | init_early_memctl_regs(); /* tighten IFC timing */ |
| 28 | |
| 29 | return 0; |
| 30 | } |
| 31 | |
| 32 | int dram_init(void) |
| 33 | { |
| 34 | printf("DRAM: "); |
| 35 | gd->ram_size = initdram(0); |
| 36 | |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | int timer_init(void) |
| 41 | { |
| 42 | u32 __iomem *cntcr = (u32 *)CONFIG_SYS_FSL_TIMER_ADDR; |
| 43 | u32 __iomem *cltbenr = (u32 *)CONFIG_SYS_FSL_PMU_CLTBENR; |
| 44 | |
| 45 | out_le32(cltbenr, 0x1); /* enable cluster0 timebase */ |
| 46 | out_le32(cntcr, 0x1); /* enable clock for timer */ |
| 47 | |
| 48 | return 0; |
| 49 | } |
| 50 | |
| 51 | /* |
| 52 | * Board specific reset that is system reset. |
| 53 | */ |
| 54 | void reset_cpu(ulong addr) |
| 55 | { |
| 56 | } |
| 57 | |
| 58 | int 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 | |
| 66 | #ifdef CONFIG_FSL_MC_ENET |
| 67 | error = cpu_eth_init(bis); |
| 68 | #endif |
| 69 | return error; |
| 70 | } |
| 71 | |
| 72 | #ifdef CONFIG_FSL_MC_ENET |
| 73 | void fdt_fixup_board_enet(void *fdt) |
| 74 | { |
| 75 | int offset; |
| 76 | |
| 77 | offset = fdt_path_offset(fdt, "/fsl,dprc@0"); |
| 78 | if (get_mc_boot_status() == 0) |
| 79 | fdt_status_okay(fdt, offset); |
| 80 | else |
| 81 | fdt_status_fail(fdt, offset); |
| 82 | } |
| 83 | #endif |
| 84 | |
| 85 | #ifdef CONFIG_OF_BOARD_SETUP |
| 86 | void ft_board_setup(void *blob, bd_t *bd) |
| 87 | { |
| 88 | phys_addr_t base; |
| 89 | phys_size_t size; |
| 90 | |
| 91 | /* limit the memory size to bank 1 until Linux can handle 40-bit PA */ |
| 92 | base = getenv_bootm_low(); |
| 93 | size = getenv_bootm_size(); |
| 94 | fdt_fixup_memory(blob, (u64)base, (u64)size); |
| 95 | |
| 96 | #ifdef CONFIG_FSL_MC_ENET |
| 97 | fdt_fixup_board_enet(blob); |
| 98 | #endif |
| 99 | } |
| 100 | #endif |