]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
ff78aa2b | 2 | /* |
9629ccdd | 3 | * Copyright 2017-2018 NXP |
ff78aa2b PK |
4 | */ |
5 | ||
6 | #include <common.h> | |
807765b0 | 7 | #include <fdt_support.h> |
ff78aa2b | 8 | #include <i2c.h> |
90526e9f | 9 | #include <asm/cache.h> |
691d719d | 10 | #include <init.h> |
401d1c4f | 11 | #include <asm/global_data.h> |
ff78aa2b PK |
12 | #include <asm/io.h> |
13 | #include <asm/arch/clock.h> | |
14 | #include <asm/arch/fsl_serdes.h> | |
5b404be6 PK |
15 | #ifdef CONFIG_FSL_LS_PPA |
16 | #include <asm/arch/ppa.h> | |
17 | #endif | |
4961eafc | 18 | #include <asm/arch/mmu.h> |
ff78aa2b | 19 | #include <asm/arch/soc.h> |
9629ccdd | 20 | #include <fsl_esdhc.h> |
ff78aa2b | 21 | #include <hwconfig.h> |
f3998fdc | 22 | #include <env_internal.h> |
ff78aa2b PK |
23 | #include <fsl_mmdc.h> |
24 | #include <netdev.h> | |
2d91b533 | 25 | #include <fsl_sec.h> |
ff78aa2b PK |
26 | |
27 | DECLARE_GLOBAL_DATA_PTR; | |
28 | ||
9629ccdd BU |
29 | static inline int get_board_version(void) |
30 | { | |
1deae0c4 PK |
31 | uint32_t val; |
32 | #ifdef CONFIG_TARGET_LS1012AFRDM | |
33 | val = 0; | |
34 | #else | |
35 | struct ccsr_gpio *pgpio = (void *)(GPIO2_BASE_ADDR); | |
9629ccdd | 36 | |
1deae0c4 | 37 | val = in_be32(&pgpio->gpdat) & BOARD_REV_MASK;/*Get GPIO2 11,12,14*/ |
9629ccdd | 38 | |
1deae0c4 | 39 | #endif |
9629ccdd BU |
40 | return val; |
41 | } | |
42 | ||
ff78aa2b PK |
43 | int checkboard(void) |
44 | { | |
9629ccdd | 45 | #ifdef CONFIG_TARGET_LS1012AFRDM |
ff78aa2b | 46 | puts("Board: LS1012AFRDM "); |
9629ccdd BU |
47 | #else |
48 | int rev; | |
49 | ||
50 | rev = get_board_version(); | |
51 | ||
52 | puts("Board: FRWY-LS1012A "); | |
53 | ||
54 | puts("Version"); | |
55 | ||
56 | switch (rev) { | |
1deae0c4 PK |
57 | case BOARD_REV_A_B: |
58 | puts(": RevA/B "); | |
9629ccdd | 59 | break; |
1deae0c4 PK |
60 | case BOARD_REV_C: |
61 | puts(": RevC "); | |
9629ccdd BU |
62 | break; |
63 | default: | |
64 | puts(": unknown"); | |
65 | break; | |
66 | } | |
67 | #endif | |
68 | ||
69 | return 0; | |
70 | } | |
ff78aa2b | 71 | |
9629ccdd BU |
72 | #ifdef CONFIG_TARGET_LS1012AFRWY |
73 | int esdhc_status_fixup(void *blob, const char *compat) | |
74 | { | |
75 | char esdhc0_path[] = "/soc/esdhc@1560000"; | |
76 | char esdhc1_path[] = "/soc/esdhc@1580000"; | |
77 | ||
78 | do_fixup_by_path(blob, esdhc0_path, "status", "okay", | |
79 | sizeof("okay"), 1); | |
80 | ||
81 | do_fixup_by_path(blob, esdhc1_path, "status", "disabled", | |
82 | sizeof("disabled"), 1); | |
ff78aa2b PK |
83 | return 0; |
84 | } | |
9629ccdd | 85 | #endif |
ff78aa2b | 86 | |
7f91b658 RB |
87 | #ifdef CONFIG_TFABOOT |
88 | int dram_init(void) | |
89 | { | |
90 | #ifdef CONFIG_TARGET_LS1012AFRWY | |
91 | int board_rev; | |
92 | #endif | |
93 | ||
94 | gd->ram_size = tfa_get_dram_size(); | |
95 | ||
96 | if (!gd->ram_size) { | |
97 | #ifdef CONFIG_TARGET_LS1012AFRWY | |
98 | board_rev = get_board_version(); | |
99 | ||
100 | if (board_rev & BOARD_REV_C) | |
101 | gd->ram_size = SYS_SDRAM_SIZE_1024; | |
102 | else | |
103 | gd->ram_size = SYS_SDRAM_SIZE_512; | |
104 | #else | |
105 | gd->ram_size = CONFIG_SYS_SDRAM_SIZE; | |
106 | #endif | |
107 | } | |
108 | return 0; | |
109 | } | |
110 | #else | |
ff78aa2b PK |
111 | int dram_init(void) |
112 | { | |
9629ccdd BU |
113 | #ifdef CONFIG_TARGET_LS1012AFRWY |
114 | int board_rev; | |
115 | #endif | |
116 | struct fsl_mmdc_info mparam = { | |
1fdcc8df YS |
117 | 0x04180000, /* mdctl */ |
118 | 0x00030035, /* mdpdc */ | |
119 | 0x12554000, /* mdotc */ | |
120 | 0xbabf7954, /* mdcfg0 */ | |
121 | 0xdb328f64, /* mdcfg1 */ | |
122 | 0x01ff00db, /* mdcfg2 */ | |
123 | 0x00001680, /* mdmisc */ | |
124 | 0x0f3c8000, /* mdref */ | |
125 | 0x00002000, /* mdrwd */ | |
126 | 0x00bf1023, /* mdor */ | |
127 | 0x0000003f, /* mdasp */ | |
128 | 0x0000022a, /* mpodtctrl */ | |
129 | 0xa1390003, /* mpzqhwctrl */ | |
130 | }; | |
131 | ||
9629ccdd BU |
132 | #ifdef CONFIG_TARGET_LS1012AFRWY |
133 | board_rev = get_board_version(); | |
ff78aa2b | 134 | |
1deae0c4 | 135 | if (board_rev == BOARD_REV_C) { |
9629ccdd BU |
136 | mparam.mdctl = 0x05180000; |
137 | gd->ram_size = SYS_SDRAM_SIZE_1024; | |
138 | } else { | |
139 | gd->ram_size = SYS_SDRAM_SIZE_512; | |
140 | } | |
141 | #else | |
ff78aa2b | 142 | gd->ram_size = CONFIG_SYS_SDRAM_SIZE; |
9629ccdd BU |
143 | #endif |
144 | mmdc_init(&mparam); | |
145 | ||
4961eafc YS |
146 | #if !defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD) |
147 | /* This will break-before-make MMU for DDR */ | |
148 | update_early_mmu_table(); | |
149 | #endif | |
ff78aa2b PK |
150 | |
151 | return 0; | |
152 | } | |
7f91b658 | 153 | #endif |
ff78aa2b | 154 | |
ff78aa2b PK |
155 | int board_early_init_f(void) |
156 | { | |
157 | fsl_lsch2_early_init_f(); | |
158 | ||
159 | return 0; | |
160 | } | |
161 | ||
162 | int board_init(void) | |
163 | { | |
63b2316c AK |
164 | struct ccsr_cci400 *cci = (struct ccsr_cci400 *)(CONFIG_SYS_IMMR + |
165 | CONFIG_SYS_CCI400_OFFSET); | |
166 | ||
ff78aa2b PK |
167 | /* |
168 | * Set CCI-400 control override register to enable barrier | |
169 | * transaction | |
170 | */ | |
7f91b658 RB |
171 | if (current_el() == 3) |
172 | out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER); | |
ff78aa2b PK |
173 | |
174 | #ifdef CONFIG_ENV_IS_NOWHERE | |
175 | gd->env_addr = (ulong)&default_environment[0]; | |
176 | #endif | |
177 | ||
2d91b533 VP |
178 | #ifdef CONFIG_FSL_CAAM |
179 | sec_init(); | |
180 | #endif | |
181 | ||
5b404be6 PK |
182 | #ifdef CONFIG_FSL_LS_PPA |
183 | ppa_init(); | |
184 | #endif | |
ff78aa2b PK |
185 | return 0; |
186 | } | |
187 | ||
b75d8dc5 | 188 | int ft_board_setup(void *blob, struct bd_info *bd) |
ff78aa2b PK |
189 | { |
190 | arch_fixup_fdt(blob); | |
191 | ||
192 | ft_cpu_setup(blob, bd); | |
193 | ||
194 | return 0; | |
195 | } |