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