]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - board/gateworks/venice/venice.c
1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2021 Gateworks Corporation
6 #include <fdt_support.h>
12 #include <asm/arch/clock.h>
13 #include <asm/arch/sys_proto.h>
14 #include <asm/mach-imx/boot_mode.h>
18 int board_phys_sdram_size(phys_size_t
*size
)
23 *size
= get_ram_size((void *)PHYS_SDRAM
, (long)PHYS_SDRAM_SIZE
+ (long)PHYS_SDRAM_2_SIZE
);
28 int board_fit_config_name_match(const char *name
)
36 dtb
= eeprom_get_dtb_name(i
++, buf
, sizeof(buf
));
37 if (!strcmp(dtb
, name
)) {
39 printf("DTB : %s\n", name
);
47 static int __maybe_unused
setup_fec(void)
49 struct iomuxc_gpr_base_regs
*gpr
=
50 (struct iomuxc_gpr_base_regs
*)IOMUXC_GPR_BASE_ADDR
;
53 /* Use 125M anatop REF_CLK1 for ENET1, not from external */
54 clrsetbits_le32(&gpr
->gpr
[1], 0x2000, 0);
56 /* Enable RGMII TX clk output */
57 setbits_le32(&gpr
->gpr
[1], BIT(22));
63 #if (IS_ENABLED(CONFIG_NET))
64 int board_phy_config(struct phy_device
*phydev
)
68 switch (phydev
->phy_id
) {
69 case 0x2000a231: /* TI DP83867 GbE PHY */
71 /* LED configuration */
73 val
|= 0x5 << 4; /* LED1(Amber;Speed) : 1000BT link */
74 val
|= 0xb << 8; /* LED2(Green;Link/Act): blink for TX/RX act */
75 phy_write(phydev
, MDIO_DEVAD_NONE
, 24, val
);
79 if (phydev
->drv
->config
)
80 phydev
->drv
->config(phydev
);
84 #endif // IS_ENABLED(CONFIG_NET)
88 venice_eeprom_init(1);
90 if (IS_ENABLED(CONFIG_FEC_MXC
))
96 int board_late_init(void)
99 struct mmc
*mmc
= NULL
;
106 /* Set board serial/model */
107 if (!env_get("serial#"))
108 env_set_ulong("serial#", eeprom_get_serial());
109 env_set("model", eeprom_get_model());
111 /* Set fdt_file vars */
114 str
= eeprom_get_dtb_name(i
, fdt
, sizeof(fdt
));
116 sprintf(env
, "fdt_file%d", i
+ 1);
127 sprintf(env
, "eth%daddr", i
);
129 sprintf(env
, "ethaddr");
132 ret
= eeprom_getmac(i
, enetaddr
);
134 eth_env_set_enetaddr(env
, enetaddr
);
140 * set bootdev/bootblk/bootpart (used in firmware_update script)
141 * dynamically depending on boot device and SoC
144 switch (get_boot_device()) {
146 case MMC1_BOOT
: /* SDHC1 */
150 case MMC2_BOOT
: /* SDHC2 */
154 case MMC3_BOOT
: /* SDHC3 */
158 bootdev
= 2; /* assume SDHC3 (eMMC) if booting over SDP */
162 mmc
= find_mmc_device(bootdev
);
166 if (IS_ENABLED(CONFIG_IMX8MN
) || IS_ENABLED(CONFIG_IMX8MP
))
167 bootblk
= 32 * SZ_1K
/ 512;
169 bootblk
= 33 * SZ_1K
/ 512;
174 switch (EXT_CSD_EXTRACT_BOOT_PART(mmc
->part_config
)) {
186 /* IMX8MP/IMX8MN BOOTROM v2 uses offset=0 for boot parts */
187 if ((IS_ENABLED(CONFIG_IMX8MN
) || IS_ENABLED(CONFIG_IMX8MP
)) &&
188 (bootpart
== 1 || bootpart
== 2))
190 env_set_hex("bootpart", bootpart
);
191 env_set_hex("bootblk", bootblk
);
193 env_set("bootpart", "");
194 env_set_hex("bootblk", bootblk
);
196 env_set_hex("dev", bootdev
);
199 /* override soc=imx8m to provide a more specific soc name */
200 if (IS_ENABLED(CONFIG_IMX8MN
))
201 env_set("soc", "imx8mn");
202 else if (IS_ENABLED(CONFIG_IMX8MP
))
203 env_set("soc", "imx8mp");
204 else if (IS_ENABLED(CONFIG_IMX8MM
))
205 env_set("soc", "imx8mm");
210 int board_mmc_get_env_dev(int devno
)
215 uint
mmc_get_env_part(struct mmc
*mmc
)
218 switch (EXT_CSD_EXTRACT_BOOT_PART(mmc
->part_config
)) {
229 int ft_board_setup(void *fdt
, struct bd_info
*bd
)
231 const char *base_model
= eeprom_get_baseboard_model();
235 /* set board model dt prop */
236 fdt_setprop_string(fdt
, 0, "board", eeprom_get_model());
238 if (!strncmp(base_model
, "GW73", 4)) {
239 pcbrev
= get_pcb_rev(base_model
);
241 if (pcbrev
> 'B' && pcbrev
< 'E') {
242 printf("adjusting dt for %s\n", base_model
);
245 * revC/D/E has PCIe 4-port switch which changes
246 * ethernet1 PCIe GbE:
247 * from: pcie@0,0/pcie@1,0/pcie@2,4/pcie@6.0
248 * to: pcie@0,0/pcie@1,0/pcie@2,3/pcie@5.0
250 off
= fdt_path_offset(fdt
, "ethernet1");
254 fdt_set_name(fdt
, off
, "pcie@5,0");
255 off
= fdt_parent_offset(fdt
, off
);
256 fdt_set_name(fdt
, off
, "pcie@2,3");
257 memset(reg
, 0, sizeof(reg
));
258 reg
[0] = cpu_to_fdt32(PCI_DEVFN(3, 0));
259 fdt_setprop(fdt
, off
, "reg", reg
, sizeof(reg
));