]> git.sur5r.net Git - u-boot/blob - board/freescale/ls2085a/ls2085a.c
armv8/ls2085a: Fix generic timer clock source
[u-boot] / board / freescale / ls2085a / ls2085a.c
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_debug_server.h>
16 #include <fsl-mc/fsl_mc.h>
17 #include <environment.h>
18
19 DECLARE_GLOBAL_DATA_PTR;
20
21 int board_init(void)
22 {
23         init_final_memctl_regs();
24
25 #ifdef CONFIG_ENV_IS_NOWHERE
26         gd->env_addr = (ulong)&default_environment[0];
27 #endif
28
29         return 0;
30 }
31
32 int board_early_init_f(void)
33 {
34         init_early_memctl_regs();       /* tighten IFC timing */
35
36         return 0;
37 }
38
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
51 int dram_init(void)
52 {
53         gd->ram_size = initdram(0);
54
55         return 0;
56 }
57
58 /*
59  * Board specific reset that is system reset.
60  */
61 void reset_cpu(ulong addr)
62 {
63 }
64
65 #if defined(CONFIG_ARCH_MISC_INIT)
66 int arch_misc_init(void)
67 {
68 #ifdef CONFIG_FSL_DEBUG_SERVER
69         debug_server_init();
70 #endif
71
72         return 0;
73 }
74 #endif
75
76 unsigned long get_dram_size_to_hide(void)
77 {
78         unsigned long dram_to_hide = 0;
79
80 /* Carve the Debug Server private DRAM block from the end of DRAM */
81 #ifdef CONFIG_FSL_DEBUG_SERVER
82         dram_to_hide += debug_server_get_dram_block_size();
83 #endif
84
85 /* Carve the MC private DRAM block from the end of DRAM */
86 #ifdef CONFIG_FSL_MC_ENET
87         dram_to_hide += mc_get_dram_block_size();
88 #endif
89
90         return dram_to_hide;
91 }
92
93 int board_eth_init(bd_t *bis)
94 {
95         int error = 0;
96
97 #ifdef CONFIG_SMC91111
98         error = smc91111_initialize(0, CONFIG_SMC91111_BASE);
99 #endif
100
101 #ifdef CONFIG_FSL_MC_ENET
102         error = cpu_eth_init(bis);
103 #endif
104         return error;
105 }
106
107 #ifdef CONFIG_FSL_MC_ENET
108 void fdt_fixup_board_enet(void *fdt)
109 {
110         int offset;
111
112         offset = fdt_path_offset(fdt, "/fsl-mc");
113
114         /*
115          * TODO: Remove this when backward compatibility
116          * with old DT node (fsl,dprc@0) is no longer needed.
117          */
118         if (offset < 0)
119                 offset = fdt_path_offset(fdt, "/fsl,dprc@0");
120
121         if (offset < 0) {
122                 printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n",
123                        __func__, offset);
124                 return;
125         }
126
127         if (get_mc_boot_status() == 0)
128                 fdt_status_okay(fdt, offset);
129         else
130                 fdt_status_fail(fdt, offset);
131 }
132 #endif
133
134 #ifdef CONFIG_OF_BOARD_SETUP
135 int ft_board_setup(void *blob, bd_t *bd)
136 {
137         phys_addr_t base;
138         phys_size_t size;
139
140         ft_cpu_setup(blob, bd);
141
142         /* limit the memory size to bank 1 until Linux can handle 40-bit PA */
143         base = getenv_bootm_low();
144         size = getenv_bootm_size();
145         fdt_fixup_memory(blob, (u64)base, (u64)size);
146
147 #ifdef CONFIG_FSL_MC_ENET
148         fdt_fixup_board_enet(blob);
149         fsl_mc_ldpaa_exit(bd);
150 #endif
151
152         return 0;
153 }
154 #endif