]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
e363426e PK |
2 | /* |
3 | * board.c | |
4 | * | |
5 | * Board functions for TI AM335X based boards | |
6 | * | |
7 | * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/ | |
e363426e PK |
8 | */ |
9 | ||
10 | #include <common.h> | |
4548bc8d | 11 | #include <dm.h> |
4bfd1f5d | 12 | #include <env.h> |
e363426e | 13 | #include <errno.h> |
5255932f | 14 | #include <init.h> |
e363426e | 15 | #include <spl.h> |
3d16389c | 16 | #include <serial.h> |
e363426e PK |
17 | #include <asm/arch/cpu.h> |
18 | #include <asm/arch/hardware.h> | |
19 | #include <asm/arch/omap.h> | |
20 | #include <asm/arch/ddr_defs.h> | |
21 | #include <asm/arch/clock.h> | |
97f3a178 | 22 | #include <asm/arch/clk_synthesizer.h> |
e363426e PK |
23 | #include <asm/arch/gpio.h> |
24 | #include <asm/arch/mmc_host_def.h> | |
25 | #include <asm/arch/sys_proto.h> | |
cd8845d7 | 26 | #include <asm/arch/mem.h> |
e363426e PK |
27 | #include <asm/io.h> |
28 | #include <asm/emif.h> | |
29 | #include <asm/gpio.h> | |
00bbe96e | 30 | #include <asm/omap_common.h> |
b0a4eea1 | 31 | #include <asm/omap_sec_common.h> |
4548bc8d | 32 | #include <asm/omap_mmc.h> |
e363426e PK |
33 | #include <i2c.h> |
34 | #include <miiphy.h> | |
35 | #include <cpsw.h> | |
9721027a TR |
36 | #include <power/tps65217.h> |
37 | #include <power/tps65910.h> | |
f3998fdc | 38 | #include <env_internal.h> |
6843918e | 39 | #include <watchdog.h> |
770e68c0 | 40 | #include "../common/board_detect.h" |
e363426e PK |
41 | #include "board.h" |
42 | ||
43 | DECLARE_GLOBAL_DATA_PTR; | |
44 | ||
e363426e | 45 | /* GPIO that controls power to DDR on EVM-SK */ |
97f3a178 LV |
46 | #define GPIO_TO_PIN(bank, gpio) (32 * (bank) + (gpio)) |
47 | #define GPIO_DDR_VTT_EN GPIO_TO_PIN(0, 7) | |
48 | #define ICE_GPIO_DDR_VTT_EN GPIO_TO_PIN(0, 18) | |
49 | #define GPIO_PR1_MII_CTRL GPIO_TO_PIN(3, 4) | |
50 | #define GPIO_MUX_MII_CTRL GPIO_TO_PIN(3, 10) | |
51 | #define GPIO_FET_SWITCH_CTRL GPIO_TO_PIN(0, 7) | |
52 | #define GPIO_PHY_RESET GPIO_TO_PIN(2, 5) | |
e607ec99 RQ |
53 | #define GPIO_ETH0_MODE GPIO_TO_PIN(0, 11) |
54 | #define GPIO_ETH1_MODE GPIO_TO_PIN(1, 26) | |
e363426e PK |
55 | |
56 | static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; | |
57 | ||
e607ec99 RQ |
58 | #define GPIO0_RISINGDETECT (AM33XX_GPIO0_BASE + OMAP_GPIO_RISINGDETECT) |
59 | #define GPIO1_RISINGDETECT (AM33XX_GPIO1_BASE + OMAP_GPIO_RISINGDETECT) | |
60 | ||
61 | #define GPIO0_IRQSTATUS1 (AM33XX_GPIO0_BASE + OMAP_GPIO_IRQSTATUS1) | |
62 | #define GPIO1_IRQSTATUS1 (AM33XX_GPIO1_BASE + OMAP_GPIO_IRQSTATUS1) | |
63 | ||
64 | #define GPIO0_IRQSTATUSRAW (AM33XX_GPIO0_BASE + 0x024) | |
65 | #define GPIO1_IRQSTATUSRAW (AM33XX_GPIO1_BASE + 0x024) | |
66 | ||
e363426e PK |
67 | /* |
68 | * Read header information from EEPROM into global structure. | |
69 | */ | |
140d76a9 LV |
70 | #ifdef CONFIG_TI_I2C_BOARD_DETECT |
71 | void do_board_detect(void) | |
e363426e | 72 | { |
140d76a9 | 73 | enable_i2c0_pin_mux(); |
1514244c | 74 | #ifndef CONFIG_DM_I2C |
140d76a9 | 75 | i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE); |
1514244c | 76 | #endif |
64a144dc SG |
77 | if (ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS, |
78 | CONFIG_EEPROM_CHIP_ADDRESS)) | |
140d76a9 | 79 | printf("ti_i2c_eeprom_init failed\n"); |
e363426e | 80 | } |
140d76a9 | 81 | #endif |
e363426e | 82 | |
3d16389c LV |
83 | #ifndef CONFIG_DM_SERIAL |
84 | struct serial_device *default_serial_console(void) | |
85 | { | |
86 | if (board_is_icev2()) | |
87 | return &eserial4_device; | |
88 | else | |
89 | return &eserial1_device; | |
90 | } | |
91 | #endif | |
92 | ||
d0e6d34d | 93 | #ifndef CONFIG_SKIP_LOWLEVEL_INIT |
c00f69db | 94 | static const struct ddr_data ddr2_data = { |
c4f80f50 TR |
95 | .datardsratio0 = MT47H128M16RT25E_RD_DQS, |
96 | .datafwsratio0 = MT47H128M16RT25E_PHY_FIFO_WE, | |
97 | .datawrsratio0 = MT47H128M16RT25E_PHY_WR_DATA, | |
c00f69db | 98 | }; |
e363426e | 99 | |
c00f69db | 100 | static const struct cmd_control ddr2_cmd_ctrl_data = { |
c7d35bef | 101 | .cmd0csratio = MT47H128M16RT25E_RATIO, |
c00f69db | 102 | |
c7d35bef | 103 | .cmd1csratio = MT47H128M16RT25E_RATIO, |
c00f69db | 104 | |
c7d35bef | 105 | .cmd2csratio = MT47H128M16RT25E_RATIO, |
c00f69db PK |
106 | }; |
107 | ||
108 | static const struct emif_regs ddr2_emif_reg_data = { | |
c7d35bef PK |
109 | .sdram_config = MT47H128M16RT25E_EMIF_SDCFG, |
110 | .ref_ctrl = MT47H128M16RT25E_EMIF_SDREF, | |
111 | .sdram_tim1 = MT47H128M16RT25E_EMIF_TIM1, | |
112 | .sdram_tim2 = MT47H128M16RT25E_EMIF_TIM2, | |
113 | .sdram_tim3 = MT47H128M16RT25E_EMIF_TIM3, | |
114 | .emif_ddr_phy_ctlr_1 = MT47H128M16RT25E_EMIF_READ_LATENCY, | |
c00f69db PK |
115 | }; |
116 | ||
8c17cbdf JS |
117 | static const struct emif_regs ddr2_evm_emif_reg_data = { |
118 | .sdram_config = MT47H128M16RT25E_EMIF_SDCFG, | |
119 | .ref_ctrl = MT47H128M16RT25E_EMIF_SDREF, | |
120 | .sdram_tim1 = MT47H128M16RT25E_EMIF_TIM1, | |
121 | .sdram_tim2 = MT47H128M16RT25E_EMIF_TIM2, | |
122 | .sdram_tim3 = MT47H128M16RT25E_EMIF_TIM3, | |
123 | .ocp_config = EMIF_OCP_CONFIG_AM335X_EVM, | |
124 | .emif_ddr_phy_ctlr_1 = MT47H128M16RT25E_EMIF_READ_LATENCY, | |
125 | }; | |
126 | ||
c00f69db | 127 | static const struct ddr_data ddr3_data = { |
c7d35bef PK |
128 | .datardsratio0 = MT41J128MJT125_RD_DQS, |
129 | .datawdsratio0 = MT41J128MJT125_WR_DQS, | |
130 | .datafwsratio0 = MT41J128MJT125_PHY_FIFO_WE, | |
131 | .datawrsratio0 = MT41J128MJT125_PHY_WR_DATA, | |
c00f69db PK |
132 | }; |
133 | ||
c7ba18ad TR |
134 | static const struct ddr_data ddr3_beagleblack_data = { |
135 | .datardsratio0 = MT41K256M16HA125E_RD_DQS, | |
136 | .datawdsratio0 = MT41K256M16HA125E_WR_DQS, | |
137 | .datafwsratio0 = MT41K256M16HA125E_PHY_FIFO_WE, | |
138 | .datawrsratio0 = MT41K256M16HA125E_PHY_WR_DATA, | |
c7ba18ad TR |
139 | }; |
140 | ||
13526f71 JL |
141 | static const struct ddr_data ddr3_evm_data = { |
142 | .datardsratio0 = MT41J512M8RH125_RD_DQS, | |
143 | .datawdsratio0 = MT41J512M8RH125_WR_DQS, | |
144 | .datafwsratio0 = MT41J512M8RH125_PHY_FIFO_WE, | |
145 | .datawrsratio0 = MT41J512M8RH125_PHY_WR_DATA, | |
13526f71 JL |
146 | }; |
147 | ||
d8ff4fdb LV |
148 | static const struct ddr_data ddr3_icev2_data = { |
149 | .datardsratio0 = MT41J128MJT125_RD_DQS_400MHz, | |
150 | .datawdsratio0 = MT41J128MJT125_WR_DQS_400MHz, | |
151 | .datafwsratio0 = MT41J128MJT125_PHY_FIFO_WE_400MHz, | |
152 | .datawrsratio0 = MT41J128MJT125_PHY_WR_DATA_400MHz, | |
153 | }; | |
154 | ||
c00f69db | 155 | static const struct cmd_control ddr3_cmd_ctrl_data = { |
c7d35bef | 156 | .cmd0csratio = MT41J128MJT125_RATIO, |
c7d35bef | 157 | .cmd0iclkout = MT41J128MJT125_INVERT_CLKOUT, |
c00f69db | 158 | |
c7d35bef | 159 | .cmd1csratio = MT41J128MJT125_RATIO, |
c7d35bef | 160 | .cmd1iclkout = MT41J128MJT125_INVERT_CLKOUT, |
c00f69db | 161 | |
c7d35bef | 162 | .cmd2csratio = MT41J128MJT125_RATIO, |
c7d35bef | 163 | .cmd2iclkout = MT41J128MJT125_INVERT_CLKOUT, |
c00f69db PK |
164 | }; |
165 | ||
c7ba18ad TR |
166 | static const struct cmd_control ddr3_beagleblack_cmd_ctrl_data = { |
167 | .cmd0csratio = MT41K256M16HA125E_RATIO, | |
c7ba18ad TR |
168 | .cmd0iclkout = MT41K256M16HA125E_INVERT_CLKOUT, |
169 | ||
170 | .cmd1csratio = MT41K256M16HA125E_RATIO, | |
c7ba18ad TR |
171 | .cmd1iclkout = MT41K256M16HA125E_INVERT_CLKOUT, |
172 | ||
173 | .cmd2csratio = MT41K256M16HA125E_RATIO, | |
c7ba18ad TR |
174 | .cmd2iclkout = MT41K256M16HA125E_INVERT_CLKOUT, |
175 | }; | |
176 | ||
13526f71 JL |
177 | static const struct cmd_control ddr3_evm_cmd_ctrl_data = { |
178 | .cmd0csratio = MT41J512M8RH125_RATIO, | |
13526f71 JL |
179 | .cmd0iclkout = MT41J512M8RH125_INVERT_CLKOUT, |
180 | ||
181 | .cmd1csratio = MT41J512M8RH125_RATIO, | |
13526f71 JL |
182 | .cmd1iclkout = MT41J512M8RH125_INVERT_CLKOUT, |
183 | ||
184 | .cmd2csratio = MT41J512M8RH125_RATIO, | |
13526f71 JL |
185 | .cmd2iclkout = MT41J512M8RH125_INVERT_CLKOUT, |
186 | }; | |
187 | ||
d8ff4fdb LV |
188 | static const struct cmd_control ddr3_icev2_cmd_ctrl_data = { |
189 | .cmd0csratio = MT41J128MJT125_RATIO_400MHz, | |
190 | .cmd0iclkout = MT41J128MJT125_INVERT_CLKOUT_400MHz, | |
191 | ||
192 | .cmd1csratio = MT41J128MJT125_RATIO_400MHz, | |
193 | .cmd1iclkout = MT41J128MJT125_INVERT_CLKOUT_400MHz, | |
194 | ||
195 | .cmd2csratio = MT41J128MJT125_RATIO_400MHz, | |
196 | .cmd2iclkout = MT41J128MJT125_INVERT_CLKOUT_400MHz, | |
197 | }; | |
198 | ||
c00f69db | 199 | static struct emif_regs ddr3_emif_reg_data = { |
c7d35bef PK |
200 | .sdram_config = MT41J128MJT125_EMIF_SDCFG, |
201 | .ref_ctrl = MT41J128MJT125_EMIF_SDREF, | |
202 | .sdram_tim1 = MT41J128MJT125_EMIF_TIM1, | |
203 | .sdram_tim2 = MT41J128MJT125_EMIF_TIM2, | |
204 | .sdram_tim3 = MT41J128MJT125_EMIF_TIM3, | |
205 | .zq_config = MT41J128MJT125_ZQ_CFG, | |
59dcf970 VH |
206 | .emif_ddr_phy_ctlr_1 = MT41J128MJT125_EMIF_READ_LATENCY | |
207 | PHY_EN_DYN_PWRDN, | |
c00f69db | 208 | }; |
13526f71 | 209 | |
c7ba18ad TR |
210 | static struct emif_regs ddr3_beagleblack_emif_reg_data = { |
211 | .sdram_config = MT41K256M16HA125E_EMIF_SDCFG, | |
212 | .ref_ctrl = MT41K256M16HA125E_EMIF_SDREF, | |
213 | .sdram_tim1 = MT41K256M16HA125E_EMIF_TIM1, | |
214 | .sdram_tim2 = MT41K256M16HA125E_EMIF_TIM2, | |
215 | .sdram_tim3 = MT41K256M16HA125E_EMIF_TIM3, | |
8c17cbdf | 216 | .ocp_config = EMIF_OCP_CONFIG_BEAGLEBONE_BLACK, |
c7ba18ad TR |
217 | .zq_config = MT41K256M16HA125E_ZQ_CFG, |
218 | .emif_ddr_phy_ctlr_1 = MT41K256M16HA125E_EMIF_READ_LATENCY, | |
219 | }; | |
220 | ||
13526f71 JL |
221 | static struct emif_regs ddr3_evm_emif_reg_data = { |
222 | .sdram_config = MT41J512M8RH125_EMIF_SDCFG, | |
223 | .ref_ctrl = MT41J512M8RH125_EMIF_SDREF, | |
224 | .sdram_tim1 = MT41J512M8RH125_EMIF_TIM1, | |
225 | .sdram_tim2 = MT41J512M8RH125_EMIF_TIM2, | |
226 | .sdram_tim3 = MT41J512M8RH125_EMIF_TIM3, | |
8c17cbdf | 227 | .ocp_config = EMIF_OCP_CONFIG_AM335X_EVM, |
13526f71 | 228 | .zq_config = MT41J512M8RH125_ZQ_CFG, |
59dcf970 VH |
229 | .emif_ddr_phy_ctlr_1 = MT41J512M8RH125_EMIF_READ_LATENCY | |
230 | PHY_EN_DYN_PWRDN, | |
13526f71 | 231 | }; |
12d7a474 | 232 | |
d8ff4fdb LV |
233 | static struct emif_regs ddr3_icev2_emif_reg_data = { |
234 | .sdram_config = MT41J128MJT125_EMIF_SDCFG_400MHz, | |
235 | .ref_ctrl = MT41J128MJT125_EMIF_SDREF_400MHz, | |
236 | .sdram_tim1 = MT41J128MJT125_EMIF_TIM1_400MHz, | |
237 | .sdram_tim2 = MT41J128MJT125_EMIF_TIM2_400MHz, | |
238 | .sdram_tim3 = MT41J128MJT125_EMIF_TIM3_400MHz, | |
239 | .zq_config = MT41J128MJT125_ZQ_CFG_400MHz, | |
240 | .emif_ddr_phy_ctlr_1 = MT41J128MJT125_EMIF_READ_LATENCY_400MHz | | |
241 | PHY_EN_DYN_PWRDN, | |
242 | }; | |
243 | ||
12d7a474 PK |
244 | #ifdef CONFIG_SPL_OS_BOOT |
245 | int spl_start_uboot(void) | |
246 | { | |
d4bb3b37 | 247 | #ifdef CONFIG_SPL_SERIAL_SUPPORT |
12d7a474 | 248 | /* break into full u-boot on 'c' */ |
ba9a6708 TR |
249 | if (serial_tstc() && serial_getc() == 'c') |
250 | return 1; | |
d4bb3b37 | 251 | #endif |
ba9a6708 TR |
252 | |
253 | #ifdef CONFIG_SPL_ENV_SUPPORT | |
254 | env_init(); | |
310fb14b | 255 | env_load(); |
bfebc8c9 | 256 | if (env_get_yesno("boot_os") != 1) |
ba9a6708 TR |
257 | return 1; |
258 | #endif | |
259 | ||
260 | return 0; | |
12d7a474 PK |
261 | } |
262 | #endif | |
263 | ||
06507988 | 264 | const struct dpll_params *get_dpll_ddr_params(void) |
9721027a | 265 | { |
fbd6295d LV |
266 | int ind = get_sys_clk_index(); |
267 | ||
06507988 | 268 | if (board_is_evm_sk()) |
fbd6295d | 269 | return &dpll_ddr3_303MHz[ind]; |
eff0c977 | 270 | else if (board_is_pb() || board_is_bone_lt() || board_is_icev2()) |
fbd6295d | 271 | return &dpll_ddr3_400MHz[ind]; |
06507988 | 272 | else if (board_is_evm_15_or_later()) |
fbd6295d | 273 | return &dpll_ddr3_303MHz[ind]; |
06507988 | 274 | else |
fbd6295d LV |
275 | return &dpll_ddr2_266MHz[ind]; |
276 | } | |
277 | ||
278 | static u8 bone_not_connected_to_ac_power(void) | |
279 | { | |
280 | if (board_is_bone()) { | |
281 | uchar pmic_status_reg; | |
282 | if (tps65217_reg_read(TPS65217_STATUS, | |
283 | &pmic_status_reg)) | |
284 | return 1; | |
285 | if (!(pmic_status_reg & TPS65217_PWR_SRC_AC_BITMASK)) { | |
286 | puts("No AC power, switching to default OPP\n"); | |
287 | return 1; | |
288 | } | |
289 | } | |
290 | return 0; | |
291 | } | |
292 | ||
293 | const struct dpll_params *get_dpll_mpu_params(void) | |
294 | { | |
295 | int ind = get_sys_clk_index(); | |
296 | int freq = am335x_get_efuse_mpu_max_freq(cdev); | |
297 | ||
298 | if (bone_not_connected_to_ac_power()) | |
299 | freq = MPUPLL_M_600; | |
300 | ||
eff0c977 | 301 | if (board_is_pb() || board_is_bone_lt()) |
fbd6295d LV |
302 | freq = MPUPLL_M_1000; |
303 | ||
304 | switch (freq) { | |
305 | case MPUPLL_M_1000: | |
306 | return &dpll_mpu_opp[ind][5]; | |
307 | case MPUPLL_M_800: | |
308 | return &dpll_mpu_opp[ind][4]; | |
309 | case MPUPLL_M_720: | |
310 | return &dpll_mpu_opp[ind][3]; | |
311 | case MPUPLL_M_600: | |
312 | return &dpll_mpu_opp[ind][2]; | |
313 | case MPUPLL_M_500: | |
314 | return &dpll_mpu_opp100; | |
315 | case MPUPLL_M_300: | |
316 | return &dpll_mpu_opp[ind][0]; | |
317 | } | |
318 | ||
319 | return &dpll_mpu_opp[ind][0]; | |
06507988 | 320 | } |
9721027a | 321 | |
06507988 LV |
322 | static void scale_vcores_bone(int freq) |
323 | { | |
324 | int usb_cur_lim, mpu_vdd; | |
325 | ||
326 | /* | |
327 | * Only perform PMIC configurations if board rev > A1 | |
328 | * on Beaglebone White | |
329 | */ | |
330 | if (board_is_bone() && !strncmp(board_ti_get_rev(), "00A1", 4)) | |
331 | return; | |
332 | ||
1514244c | 333 | #ifndef CONFIG_DM_I2C |
06507988 LV |
334 | if (i2c_probe(TPS65217_CHIP_PM)) |
335 | return; | |
1514244c JJH |
336 | #else |
337 | if (power_tps65217_init(0)) | |
338 | return; | |
339 | #endif | |
340 | ||
06507988 LV |
341 | |
342 | /* | |
343 | * On Beaglebone White we need to ensure we have AC power | |
344 | * before increasing the frequency. | |
345 | */ | |
fbd6295d LV |
346 | if (bone_not_connected_to_ac_power()) |
347 | freq = MPUPLL_M_600; | |
9721027a | 348 | |
06507988 LV |
349 | /* |
350 | * Override what we have detected since we know if we have | |
351 | * a Beaglebone Black it supports 1GHz. | |
352 | */ | |
eff0c977 | 353 | if (board_is_pb() || board_is_bone_lt()) |
06507988 | 354 | freq = MPUPLL_M_1000; |
9721027a | 355 | |
06507988 LV |
356 | switch (freq) { |
357 | case MPUPLL_M_1000: | |
358 | mpu_vdd = TPS65217_DCDC_VOLT_SEL_1325MV; | |
359 | usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1800MA; | |
360 | break; | |
361 | case MPUPLL_M_800: | |
362 | mpu_vdd = TPS65217_DCDC_VOLT_SEL_1275MV; | |
9f7923c7 | 363 | usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1300MA; |
06507988 LV |
364 | break; |
365 | case MPUPLL_M_720: | |
366 | mpu_vdd = TPS65217_DCDC_VOLT_SEL_1200MV; | |
9f7923c7 | 367 | usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1300MA; |
06507988 LV |
368 | break; |
369 | case MPUPLL_M_600: | |
370 | case MPUPLL_M_500: | |
371 | case MPUPLL_M_300: | |
9f7923c7 | 372 | default: |
06507988 LV |
373 | mpu_vdd = TPS65217_DCDC_VOLT_SEL_1100MV; |
374 | usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1300MA; | |
375 | break; | |
376 | } | |
9721027a | 377 | |
06507988 LV |
378 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_NONE, |
379 | TPS65217_POWER_PATH, | |
380 | usb_cur_lim, | |
381 | TPS65217_USB_INPUT_CUR_LIMIT_MASK)) | |
382 | puts("tps65217_reg_write failure\n"); | |
383 | ||
384 | /* Set DCDC3 (CORE) voltage to 1.10V */ | |
385 | if (tps65217_voltage_update(TPS65217_DEFDCDC3, | |
386 | TPS65217_DCDC_VOLT_SEL_1100MV)) { | |
387 | puts("tps65217_voltage_update failure\n"); | |
388 | return; | |
389 | } | |
9721027a | 390 | |
06507988 LV |
391 | /* Set DCDC2 (MPU) voltage */ |
392 | if (tps65217_voltage_update(TPS65217_DEFDCDC2, mpu_vdd)) { | |
393 | puts("tps65217_voltage_update failure\n"); | |
394 | return; | |
395 | } | |
9721027a | 396 | |
06507988 LV |
397 | /* |
398 | * Set LDO3, LDO4 output voltage to 3.3V for Beaglebone. | |
399 | * Set LDO3 to 1.8V and LDO4 to 3.3V for Beaglebone Black. | |
400 | */ | |
401 | if (board_is_bone()) { | |
9721027a | 402 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, |
06507988 | 403 | TPS65217_DEFLS1, |
9721027a TR |
404 | TPS65217_LDO_VOLTAGE_OUT_3_3, |
405 | TPS65217_LDO_MASK)) | |
406 | puts("tps65217_reg_write failure\n"); | |
407 | } else { | |
06507988 LV |
408 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, |
409 | TPS65217_DEFLS1, | |
410 | TPS65217_LDO_VOLTAGE_OUT_1_8, | |
411 | TPS65217_LDO_MASK)) | |
412 | puts("tps65217_reg_write failure\n"); | |
413 | } | |
9721027a | 414 | |
06507988 LV |
415 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, |
416 | TPS65217_DEFLS2, | |
417 | TPS65217_LDO_VOLTAGE_OUT_3_3, | |
418 | TPS65217_LDO_MASK)) | |
419 | puts("tps65217_reg_write failure\n"); | |
420 | } | |
9721027a | 421 | |
06507988 LV |
422 | void scale_vcores_generic(int freq) |
423 | { | |
424 | int sil_rev, mpu_vdd; | |
425 | ||
426 | /* | |
427 | * The GP EVM, IDK and EVM SK use a TPS65910 PMIC. For all | |
428 | * MPU frequencies we support we use a CORE voltage of | |
429 | * 1.10V. For MPU voltage we need to switch based on | |
430 | * the frequency we are running at. | |
431 | */ | |
1514244c | 432 | #ifndef CONFIG_DM_I2C |
06507988 LV |
433 | if (i2c_probe(TPS65910_CTRL_I2C_ADDR)) |
434 | return; | |
1514244c JJH |
435 | #else |
436 | if (power_tps65910_init(0)) | |
437 | return; | |
438 | #endif | |
06507988 LV |
439 | /* |
440 | * Depending on MPU clock and PG we will need a different | |
441 | * VDD to drive at that speed. | |
442 | */ | |
443 | sil_rev = readl(&cdev->deviceid) >> 28; | |
444 | mpu_vdd = am335x_get_tps65910_mpu_vdd(sil_rev, freq); | |
445 | ||
446 | /* Tell the TPS65910 to use i2c */ | |
447 | tps65910_set_i2c_control(); | |
448 | ||
449 | /* First update MPU voltage. */ | |
450 | if (tps65910_voltage_update(MPU, mpu_vdd)) | |
451 | return; | |
452 | ||
453 | /* Second, update the CORE voltage. */ | |
454 | if (tps65910_voltage_update(CORE, TPS65910_OP_REG_SEL_1_1_0)) | |
455 | return; | |
9721027a | 456 | |
06507988 | 457 | } |
52f7d844 | 458 | |
06507988 LV |
459 | void gpi2c_init(void) |
460 | { | |
461 | /* When needed to be invoked prior to BSS initialization */ | |
462 | static bool first_time = true; | |
463 | ||
464 | if (first_time) { | |
465 | enable_i2c0_pin_mux(); | |
1514244c | 466 | #ifndef CONFIG_DM_I2C |
06507988 LV |
467 | i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, |
468 | CONFIG_SYS_OMAP24_I2C_SLAVE); | |
1514244c | 469 | #endif |
06507988 | 470 | first_time = false; |
9721027a | 471 | } |
9721027a TR |
472 | } |
473 | ||
06507988 | 474 | void scale_vcores(void) |
94d77fb6 | 475 | { |
06507988 LV |
476 | int freq; |
477 | ||
478 | gpi2c_init(); | |
479 | freq = am335x_get_efuse_mpu_max_freq(cdev); | |
480 | ||
9f7923c7 | 481 | if (board_is_beaglebonex()) |
06507988 | 482 | scale_vcores_bone(freq); |
94d77fb6 | 483 | else |
06507988 | 484 | scale_vcores_generic(freq); |
94d77fb6 LV |
485 | } |
486 | ||
0660481a | 487 | void set_uart_mux_conf(void) |
e363426e | 488 | { |
1286b7f6 | 489 | #if CONFIG_CONS_INDEX == 1 |
e363426e | 490 | enable_uart0_pin_mux(); |
1286b7f6 | 491 | #elif CONFIG_CONS_INDEX == 2 |
6422b70b | 492 | enable_uart1_pin_mux(); |
1286b7f6 | 493 | #elif CONFIG_CONS_INDEX == 3 |
6422b70b | 494 | enable_uart2_pin_mux(); |
1286b7f6 | 495 | #elif CONFIG_CONS_INDEX == 4 |
6422b70b | 496 | enable_uart3_pin_mux(); |
1286b7f6 | 497 | #elif CONFIG_CONS_INDEX == 5 |
6422b70b | 498 | enable_uart4_pin_mux(); |
1286b7f6 | 499 | #elif CONFIG_CONS_INDEX == 6 |
6422b70b | 500 | enable_uart5_pin_mux(); |
1286b7f6 | 501 | #endif |
0660481a | 502 | } |
e363426e | 503 | |
0660481a HS |
504 | void set_mux_conf_regs(void) |
505 | { | |
770e68c0 | 506 | enable_board_pin_mux(); |
0660481a | 507 | } |
e363426e | 508 | |
965de8b9 LV |
509 | const struct ctrl_ioregs ioregs_evmsk = { |
510 | .cm0ioctl = MT41J128MJT125_IOCTRL_VALUE, | |
511 | .cm1ioctl = MT41J128MJT125_IOCTRL_VALUE, | |
512 | .cm2ioctl = MT41J128MJT125_IOCTRL_VALUE, | |
513 | .dt0ioctl = MT41J128MJT125_IOCTRL_VALUE, | |
514 | .dt1ioctl = MT41J128MJT125_IOCTRL_VALUE, | |
515 | }; | |
516 | ||
517 | const struct ctrl_ioregs ioregs_bonelt = { | |
518 | .cm0ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | |
519 | .cm1ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | |
520 | .cm2ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | |
521 | .dt0ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | |
522 | .dt1ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | |
523 | }; | |
524 | ||
525 | const struct ctrl_ioregs ioregs_evm15 = { | |
526 | .cm0ioctl = MT41J512M8RH125_IOCTRL_VALUE, | |
527 | .cm1ioctl = MT41J512M8RH125_IOCTRL_VALUE, | |
528 | .cm2ioctl = MT41J512M8RH125_IOCTRL_VALUE, | |
529 | .dt0ioctl = MT41J512M8RH125_IOCTRL_VALUE, | |
530 | .dt1ioctl = MT41J512M8RH125_IOCTRL_VALUE, | |
531 | }; | |
532 | ||
533 | const struct ctrl_ioregs ioregs = { | |
534 | .cm0ioctl = MT47H128M16RT25E_IOCTRL_VALUE, | |
535 | .cm1ioctl = MT47H128M16RT25E_IOCTRL_VALUE, | |
536 | .cm2ioctl = MT47H128M16RT25E_IOCTRL_VALUE, | |
537 | .dt0ioctl = MT47H128M16RT25E_IOCTRL_VALUE, | |
538 | .dt1ioctl = MT47H128M16RT25E_IOCTRL_VALUE, | |
539 | }; | |
540 | ||
0660481a HS |
541 | void sdram_init(void) |
542 | { | |
770e68c0 | 543 | if (board_is_evm_sk()) { |
e363426e PK |
544 | /* |
545 | * EVM SK 1.2A and later use gpio0_7 to enable DDR3. | |
546 | * This is safe enough to do on older revs. | |
547 | */ | |
548 | gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en"); | |
549 | gpio_direction_output(GPIO_DDR_VTT_EN, 1); | |
550 | } | |
551 | ||
d8ff4fdb LV |
552 | if (board_is_icev2()) { |
553 | gpio_request(ICE_GPIO_DDR_VTT_EN, "ddr_vtt_en"); | |
554 | gpio_direction_output(ICE_GPIO_DDR_VTT_EN, 1); | |
555 | } | |
556 | ||
770e68c0 | 557 | if (board_is_evm_sk()) |
965de8b9 | 558 | config_ddr(303, &ioregs_evmsk, &ddr3_data, |
3ba65f97 | 559 | &ddr3_cmd_ctrl_data, &ddr3_emif_reg_data, 0); |
eff0c977 | 560 | else if (board_is_pb() || board_is_bone_lt()) |
965de8b9 | 561 | config_ddr(400, &ioregs_bonelt, |
c7ba18ad TR |
562 | &ddr3_beagleblack_data, |
563 | &ddr3_beagleblack_cmd_ctrl_data, | |
564 | &ddr3_beagleblack_emif_reg_data, 0); | |
770e68c0 | 565 | else if (board_is_evm_15_or_later()) |
965de8b9 | 566 | config_ddr(303, &ioregs_evm15, &ddr3_evm_data, |
3ba65f97 | 567 | &ddr3_evm_cmd_ctrl_data, &ddr3_evm_emif_reg_data, 0); |
d8ff4fdb LV |
568 | else if (board_is_icev2()) |
569 | config_ddr(400, &ioregs_evmsk, &ddr3_icev2_data, | |
570 | &ddr3_icev2_cmd_ctrl_data, &ddr3_icev2_emif_reg_data, | |
571 | 0); | |
8c17cbdf JS |
572 | else if (board_is_gp_evm()) |
573 | config_ddr(266, &ioregs, &ddr2_data, | |
574 | &ddr2_cmd_ctrl_data, &ddr2_evm_emif_reg_data, 0); | |
c00f69db | 575 | else |
965de8b9 | 576 | config_ddr(266, &ioregs, &ddr2_data, |
3ba65f97 | 577 | &ddr2_cmd_ctrl_data, &ddr2_emif_reg_data, 0); |
e363426e | 578 | } |
0660481a | 579 | #endif |
e363426e | 580 | |
8cf2f360 AK |
581 | #if defined(CONFIG_CLOCK_SYNTHESIZER) && (!defined(CONFIG_SPL_BUILD) || \ |
582 | (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))) | |
e607ec99 | 583 | static void request_and_set_gpio(int gpio, char *name, int val) |
97f3a178 LV |
584 | { |
585 | int ret; | |
586 | ||
587 | ret = gpio_request(gpio, name); | |
588 | if (ret < 0) { | |
589 | printf("%s: Unable to request %s\n", __func__, name); | |
590 | return; | |
591 | } | |
592 | ||
593 | ret = gpio_direction_output(gpio, 0); | |
594 | if (ret < 0) { | |
595 | printf("%s: Unable to set %s as output\n", __func__, name); | |
596 | goto err_free_gpio; | |
597 | } | |
598 | ||
e607ec99 | 599 | gpio_set_value(gpio, val); |
97f3a178 LV |
600 | |
601 | return; | |
602 | ||
603 | err_free_gpio: | |
604 | gpio_free(gpio); | |
605 | } | |
606 | ||
e607ec99 RQ |
607 | #define REQUEST_AND_SET_GPIO(N) request_and_set_gpio(N, #N, 1); |
608 | #define REQUEST_AND_CLR_GPIO(N) request_and_set_gpio(N, #N, 0); | |
97f3a178 LV |
609 | |
610 | /** | |
611 | * RMII mode on ICEv2 board needs 50MHz clock. Given the clock | |
612 | * synthesizer With a capacitor of 18pF, and 25MHz input clock cycle | |
613 | * PLL1 gives an output of 100MHz. So, configuring the div2/3 as 2 to | |
614 | * give 50MHz output for Eth0 and 1. | |
615 | */ | |
616 | static struct clk_synth cdce913_data = { | |
617 | .id = 0x81, | |
618 | .capacitor = 0x90, | |
619 | .mux = 0x6d, | |
620 | .pdiv2 = 0x2, | |
621 | .pdiv3 = 0x2, | |
622 | }; | |
623 | #endif | |
624 | ||
20c37fb1 SN |
625 | #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_CONTROL) && \ |
626 | defined(CONFIG_DM_ETH) && defined(CONFIG_DRIVER_TI_CPSW) | |
627 | ||
628 | #define MAX_CPSW_SLAVES 2 | |
629 | ||
630 | /* At the moment, we do not want to stop booting for any failures here */ | |
631 | int ft_board_setup(void *fdt, bd_t *bd) | |
632 | { | |
633 | const char *slave_path, *enet_name; | |
634 | int enetnode, slavenode, phynode; | |
635 | struct udevice *ethdev; | |
636 | char alias[16]; | |
637 | u32 phy_id[2]; | |
638 | int phy_addr; | |
639 | int i, ret; | |
640 | ||
641 | /* phy address fixup needed only on beagle bone family */ | |
642 | if (!board_is_beaglebonex()) | |
643 | goto done; | |
644 | ||
645 | for (i = 0; i < MAX_CPSW_SLAVES; i++) { | |
646 | sprintf(alias, "ethernet%d", i); | |
647 | ||
648 | slave_path = fdt_get_alias(fdt, alias); | |
649 | if (!slave_path) | |
650 | continue; | |
651 | ||
652 | slavenode = fdt_path_offset(fdt, slave_path); | |
653 | if (slavenode < 0) | |
654 | continue; | |
655 | ||
656 | enetnode = fdt_parent_offset(fdt, slavenode); | |
657 | enet_name = fdt_get_name(fdt, enetnode, NULL); | |
658 | ||
659 | ethdev = eth_get_dev_by_name(enet_name); | |
660 | if (!ethdev) | |
661 | continue; | |
662 | ||
663 | phy_addr = cpsw_get_slave_phy_addr(ethdev, i); | |
664 | ||
665 | /* check for phy_id as well as phy-handle properties */ | |
666 | ret = fdtdec_get_int_array_count(fdt, slavenode, "phy_id", | |
667 | phy_id, 2); | |
668 | if (ret == 2) { | |
669 | if (phy_id[1] != phy_addr) { | |
670 | printf("fixing up phy_id for %s, old: %d, new: %d\n", | |
671 | alias, phy_id[1], phy_addr); | |
672 | ||
673 | phy_id[0] = cpu_to_fdt32(phy_id[0]); | |
674 | phy_id[1] = cpu_to_fdt32(phy_addr); | |
675 | do_fixup_by_path(fdt, slave_path, "phy_id", | |
676 | phy_id, sizeof(phy_id), 0); | |
677 | } | |
678 | } else { | |
679 | phynode = fdtdec_lookup_phandle(fdt, slavenode, | |
680 | "phy-handle"); | |
681 | if (phynode < 0) | |
682 | continue; | |
683 | ||
684 | ret = fdtdec_get_int(fdt, phynode, "reg", -ENOENT); | |
685 | if (ret < 0) | |
686 | continue; | |
687 | ||
688 | if (ret != phy_addr) { | |
689 | printf("fixing up phy-handle for %s, old: %d, new: %d\n", | |
690 | alias, ret, phy_addr); | |
691 | ||
692 | fdt_setprop_u32(fdt, phynode, "reg", | |
693 | cpu_to_fdt32(phy_addr)); | |
694 | } | |
695 | } | |
696 | } | |
697 | ||
698 | done: | |
699 | return 0; | |
700 | } | |
701 | #endif | |
702 | ||
e363426e PK |
703 | /* |
704 | * Basic board specific setup. Pinmux has been handled already. | |
705 | */ | |
706 | int board_init(void) | |
707 | { | |
6843918e TR |
708 | #if defined(CONFIG_HW_WATCHDOG) |
709 | hw_watchdog_init(); | |
710 | #endif | |
711 | ||
73feefdc | 712 | gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; |
2c17e6d1 | 713 | #if defined(CONFIG_NOR) || defined(CONFIG_NAND) |
98b5c269 | 714 | gpmc_init(); |
cd8845d7 | 715 | #endif |
97f3a178 | 716 | |
8cf2f360 AK |
717 | #if defined(CONFIG_CLOCK_SYNTHESIZER) && (!defined(CONFIG_SPL_BUILD) || \ |
718 | (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))) | |
97f3a178 | 719 | if (board_is_icev2()) { |
e607ec99 RQ |
720 | int rv; |
721 | u32 reg; | |
722 | ||
97f3a178 | 723 | REQUEST_AND_SET_GPIO(GPIO_PR1_MII_CTRL); |
e607ec99 RQ |
724 | /* Make J19 status available on GPIO1_26 */ |
725 | REQUEST_AND_CLR_GPIO(GPIO_MUX_MII_CTRL); | |
726 | ||
97f3a178 | 727 | REQUEST_AND_SET_GPIO(GPIO_FET_SWITCH_CTRL); |
e607ec99 RQ |
728 | /* |
729 | * Both ports can be set as RMII-CPSW or MII-PRU-ETH using | |
730 | * jumpers near the port. Read the jumper value and set | |
731 | * the pinmux, external mux and PHY clock accordingly. | |
732 | * As jumper line is overridden by PHY RX_DV pin immediately | |
733 | * after bootstrap (power-up/reset), we need to sample | |
734 | * it during PHY reset using GPIO rising edge detection. | |
735 | */ | |
97f3a178 | 736 | REQUEST_AND_SET_GPIO(GPIO_PHY_RESET); |
e607ec99 RQ |
737 | /* Enable rising edge IRQ on GPIO0_11 and GPIO 1_26 */ |
738 | reg = readl(GPIO0_RISINGDETECT) | BIT(11); | |
739 | writel(reg, GPIO0_RISINGDETECT); | |
740 | reg = readl(GPIO1_RISINGDETECT) | BIT(26); | |
741 | writel(reg, GPIO1_RISINGDETECT); | |
742 | /* Reset PHYs to capture the Jumper setting */ | |
743 | gpio_set_value(GPIO_PHY_RESET, 0); | |
744 | udelay(2); /* PHY datasheet states 1uS min. */ | |
745 | gpio_set_value(GPIO_PHY_RESET, 1); | |
746 | ||
747 | reg = readl(GPIO0_IRQSTATUSRAW) & BIT(11); | |
748 | if (reg) { | |
749 | writel(reg, GPIO0_IRQSTATUS1); /* clear irq */ | |
750 | /* RMII mode */ | |
751 | printf("ETH0, CPSW\n"); | |
752 | } else { | |
753 | /* MII mode */ | |
754 | printf("ETH0, PRU\n"); | |
755 | cdce913_data.pdiv3 = 4; /* 25MHz PHY clk */ | |
756 | } | |
757 | ||
758 | reg = readl(GPIO1_IRQSTATUSRAW) & BIT(26); | |
759 | if (reg) { | |
760 | writel(reg, GPIO1_IRQSTATUS1); /* clear irq */ | |
761 | /* RMII mode */ | |
762 | printf("ETH1, CPSW\n"); | |
763 | gpio_set_value(GPIO_MUX_MII_CTRL, 1); | |
764 | } else { | |
765 | /* MII mode */ | |
766 | printf("ETH1, PRU\n"); | |
767 | cdce913_data.pdiv2 = 4; /* 25MHz PHY clk */ | |
768 | } | |
769 | ||
770 | /* disable rising edge IRQs */ | |
771 | reg = readl(GPIO0_RISINGDETECT) & ~BIT(11); | |
772 | writel(reg, GPIO0_RISINGDETECT); | |
773 | reg = readl(GPIO1_RISINGDETECT) & ~BIT(26); | |
774 | writel(reg, GPIO1_RISINGDETECT); | |
97f3a178 LV |
775 | |
776 | rv = setup_clock_synthesizer(&cdce913_data); | |
777 | if (rv) { | |
778 | printf("Clock synthesizer setup failed %d\n", rv); | |
779 | return rv; | |
780 | } | |
e607ec99 RQ |
781 | |
782 | /* reset PHYs */ | |
783 | gpio_set_value(GPIO_PHY_RESET, 0); | |
784 | udelay(2); /* PHY datasheet states 1uS min. */ | |
785 | gpio_set_value(GPIO_PHY_RESET, 1); | |
97f3a178 LV |
786 | } |
787 | #endif | |
788 | ||
e363426e PK |
789 | return 0; |
790 | } | |
791 | ||
044fc14b TR |
792 | #ifdef CONFIG_BOARD_LATE_INIT |
793 | int board_late_init(void) | |
794 | { | |
752a45a1 | 795 | struct udevice *dev; |
f411b5cc RQ |
796 | #if !defined(CONFIG_SPL_BUILD) |
797 | uint8_t mac_addr[6]; | |
798 | uint32_t mac_hi, mac_lo; | |
799 | #endif | |
800 | ||
044fc14b | 801 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
770e68c0 | 802 | char *name = NULL; |
ace4275e | 803 | |
4015949f | 804 | if (board_is_bone_lt()) { |
805 | /* BeagleBoard.org BeagleBone Black Wireless: */ | |
806 | if (!strncmp(board_ti_get_rev(), "BWA", 3)) { | |
807 | name = "BBBW"; | |
2b79fba6 | 808 | } |
809 | /* SeeedStudio BeagleBone Green Wireless */ | |
810 | if (!strncmp(board_ti_get_rev(), "GW1", 3)) { | |
811 | name = "BBGW"; | |
52609d75 | 812 | } |
813 | /* BeagleBoard.org BeagleBone Blue */ | |
814 | if (!strncmp(board_ti_get_rev(), "BLA", 3)) { | |
815 | name = "BBBL"; | |
4015949f | 816 | } |
817 | } | |
818 | ||
770e68c0 NM |
819 | if (board_is_bbg1()) |
820 | name = "BBG1"; | |
ad6054f1 KK |
821 | if (board_is_bben()) |
822 | name = "BBEN"; | |
770e68c0 | 823 | set_board_info_env(name); |
5d4d436c LV |
824 | |
825 | /* | |
826 | * Default FIT boot on HS devices. Non FIT images are not allowed | |
827 | * on HS devices. | |
828 | */ | |
829 | if (get_device_type() == HS_DEVICE) | |
382bee57 | 830 | env_set("boot_fit", "1"); |
044fc14b TR |
831 | #endif |
832 | ||
f411b5cc RQ |
833 | #if !defined(CONFIG_SPL_BUILD) |
834 | /* try reading mac address from efuse */ | |
835 | mac_lo = readl(&cdev->macid0l); | |
836 | mac_hi = readl(&cdev->macid0h); | |
837 | mac_addr[0] = mac_hi & 0xFF; | |
838 | mac_addr[1] = (mac_hi & 0xFF00) >> 8; | |
839 | mac_addr[2] = (mac_hi & 0xFF0000) >> 16; | |
840 | mac_addr[3] = (mac_hi & 0xFF000000) >> 24; | |
841 | mac_addr[4] = mac_lo & 0xFF; | |
842 | mac_addr[5] = (mac_lo & 0xFF00) >> 8; | |
843 | ||
00caae6d | 844 | if (!env_get("ethaddr")) { |
f411b5cc RQ |
845 | printf("<ethaddr> not set. Validating first E-fuse MAC\n"); |
846 | ||
847 | if (is_valid_ethaddr(mac_addr)) | |
fd1e959e | 848 | eth_env_set_enetaddr("ethaddr", mac_addr); |
f411b5cc RQ |
849 | } |
850 | ||
851 | mac_lo = readl(&cdev->macid1l); | |
852 | mac_hi = readl(&cdev->macid1h); | |
853 | mac_addr[0] = mac_hi & 0xFF; | |
854 | mac_addr[1] = (mac_hi & 0xFF00) >> 8; | |
855 | mac_addr[2] = (mac_hi & 0xFF0000) >> 16; | |
856 | mac_addr[3] = (mac_hi & 0xFF000000) >> 24; | |
857 | mac_addr[4] = mac_lo & 0xFF; | |
858 | mac_addr[5] = (mac_lo & 0xFF00) >> 8; | |
859 | ||
00caae6d | 860 | if (!env_get("eth1addr")) { |
f411b5cc | 861 | if (is_valid_ethaddr(mac_addr)) |
fd1e959e | 862 | eth_env_set_enetaddr("eth1addr", mac_addr); |
f411b5cc RQ |
863 | } |
864 | #endif | |
865 | ||
fc228dc9 SP |
866 | if (!env_get("serial#")) { |
867 | char *board_serial = env_get("board_serial"); | |
868 | char *ethaddr = env_get("ethaddr"); | |
869 | ||
870 | if (!board_serial || !strncmp(board_serial, "unknown", 7)) | |
871 | env_set("serial#", ethaddr); | |
872 | else | |
873 | env_set("serial#", board_serial); | |
874 | } | |
875 | ||
752a45a1 TK |
876 | /* Just probe the potentially supported cdce913 device */ |
877 | uclass_get_device(UCLASS_CLK, 0, &dev); | |
878 | ||
044fc14b TR |
879 | return 0; |
880 | } | |
881 | #endif | |
882 | ||
0229c933 FA |
883 | /* CPSW platdata */ |
884 | #if !CONFIG_IS_ENABLED(OF_CONTROL) | |
885 | struct cpsw_slave_data slave_data[] = { | |
886 | { | |
887 | .slave_reg_ofs = CPSW_SLAVE0_OFFSET, | |
888 | .sliver_reg_ofs = CPSW_SLIVER0_OFFSET, | |
889 | .phy_addr = 0, | |
890 | }, | |
891 | { | |
892 | .slave_reg_ofs = CPSW_SLAVE1_OFFSET, | |
893 | .sliver_reg_ofs = CPSW_SLIVER1_OFFSET, | |
894 | .phy_addr = 1, | |
895 | }, | |
896 | }; | |
897 | ||
898 | struct cpsw_platform_data am335_eth_data = { | |
899 | .cpsw_base = CPSW_BASE, | |
900 | .version = CPSW_CTRL_VERSION_2, | |
901 | .bd_ram_ofs = CPSW_BD_OFFSET, | |
902 | .ale_reg_ofs = CPSW_ALE_OFFSET, | |
903 | .cpdma_reg_ofs = CPSW_CPDMA_OFFSET, | |
904 | .mdio_div = CPSW_MDIO_DIV, | |
905 | .host_port_reg_ofs = CPSW_HOST_PORT_OFFSET, | |
906 | .channels = 8, | |
907 | .slaves = 2, | |
908 | .slave_data = slave_data, | |
909 | .ale_entries = 1024, | |
910 | .bd_ram_ofs = 0x2000, | |
911 | .mac_control = 0x20, | |
912 | .active_slave = 0, | |
913 | .mdio_base = 0x4a101000, | |
914 | .gmii_sel = 0x44e10650, | |
915 | .phy_sel_compat = "ti,am3352-cpsw-phy-sel", | |
916 | .syscon_addr = 0x44e10630, | |
917 | .macid_sel_compat = "cpsw,am33xx", | |
918 | }; | |
919 | ||
920 | struct eth_pdata cpsw_pdata = { | |
921 | .iobase = 0x4a100000, | |
922 | .phy_interface = 0, | |
923 | .priv_pdata = &am335_eth_data, | |
924 | }; | |
925 | ||
926 | U_BOOT_DEVICE(am335x_eth) = { | |
927 | .name = "eth_cpsw", | |
928 | .platdata = &cpsw_pdata, | |
929 | }; | |
930 | #endif | |
931 | ||
505ea6e8 LV |
932 | #ifdef CONFIG_SPL_LOAD_FIT |
933 | int board_fit_config_name_match(const char *name) | |
934 | { | |
935 | if (board_is_gp_evm() && !strcmp(name, "am335x-evm")) | |
936 | return 0; | |
937 | else if (board_is_bone() && !strcmp(name, "am335x-bone")) | |
938 | return 0; | |
939 | else if (board_is_bone_lt() && !strcmp(name, "am335x-boneblack")) | |
940 | return 0; | |
eff0c977 JK |
941 | else if (board_is_pb() && !strcmp(name, "am335x-pocketbeagle")) |
942 | return 0; | |
3819ea70 LV |
943 | else if (board_is_evm_sk() && !strcmp(name, "am335x-evmsk")) |
944 | return 0; | |
da9d9599 LV |
945 | else if (board_is_bbg1() && !strcmp(name, "am335x-bonegreen")) |
946 | return 0; | |
73ec6960 LV |
947 | else if (board_is_icev2() && !strcmp(name, "am335x-icev2")) |
948 | return 0; | |
505ea6e8 LV |
949 | else |
950 | return -1; | |
951 | } | |
952 | #endif | |
b0a4eea1 AD |
953 | |
954 | #ifdef CONFIG_TI_SECURE_DEVICE | |
955 | void board_fit_image_post_process(void **p_image, size_t *p_size) | |
956 | { | |
957 | secure_boot_verify_image(p_image, p_size); | |
958 | } | |
959 | #endif | |
4548bc8d LV |
960 | |
961 | #if !CONFIG_IS_ENABLED(OF_CONTROL) | |
962 | static const struct omap_hsmmc_plat am335x_mmc0_platdata = { | |
963 | .base_addr = (struct hsmmc *)OMAP_HSMMC1_BASE, | |
964 | .cfg.host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS | MMC_MODE_4BIT, | |
965 | .cfg.f_min = 400000, | |
966 | .cfg.f_max = 52000000, | |
967 | .cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195, | |
968 | .cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT, | |
969 | }; | |
970 | ||
971 | U_BOOT_DEVICE(am335x_mmc0) = { | |
972 | .name = "omap_hsmmc", | |
973 | .platdata = &am335x_mmc0_platdata, | |
974 | }; | |
975 | ||
976 | static const struct omap_hsmmc_plat am335x_mmc1_platdata = { | |
977 | .base_addr = (struct hsmmc *)OMAP_HSMMC2_BASE, | |
978 | .cfg.host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS | MMC_MODE_8BIT, | |
979 | .cfg.f_min = 400000, | |
980 | .cfg.f_max = 52000000, | |
981 | .cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195, | |
982 | .cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT, | |
983 | }; | |
984 | ||
985 | U_BOOT_DEVICE(am335x_mmc1) = { | |
986 | .name = "omap_hsmmc", | |
987 | .platdata = &am335x_mmc1_platdata, | |
988 | }; | |
989 | #endif |