1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2020-2021 Toradex
8 #include <asm/arch/clock.h>
9 #include <asm/arch/sys_proto.h>
10 #include <asm/global_data.h>
17 #include "../common/tdx-cfg-block.h"
19 DECLARE_GLOBAL_DATA_PTR;
28 #if IS_ENABLED(CONFIG_FEC_MXC)
29 static int setup_fec(void)
31 struct iomuxc_gpr_base_regs *gpr =
32 (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
34 /* Use 125M anatop REF_CLK1 for ENET1, not from external */
35 clrsetbits_le32(&gpr->gpr[1], 0x2000, 0);
43 if (IS_ENABLED(CONFIG_FEC_MXC))
49 int board_mmc_get_env_dev(int devno)
54 static enum pcb_rev_t get_pcb_revision(void)
57 struct udevice *i2c_dev = NULL;
61 ret = uclass_get_device_by_seq(UCLASS_I2C, I2C_PMIC, &bus);
63 ret = dm_i2c_probe(bus, 0x4b, 0, &i2c_dev);
65 ret = dm_i2c_read(i2c_dev, 0x0, &is_bd71837, 1);
67 /* BD71837_REV, High Nibble is major version, fix 1010 */
68 is_bd71837 = !ret && ((is_bd71837 & 0xf0) == 0xa0);
69 return is_bd71837 ? PCB_VERSION_1_0 : PCB_VERSION_1_1;
72 static void select_dt_from_module_version(void)
75 char *env_variant = env_get("variant");
78 if (IS_ENABLED(CONFIG_TDX_CFG_BLOCK)) {
80 * If we have a valid config block and it says we are a
81 * module with Wi-Fi/Bluetooth make sure we use the -wifi
84 is_wifi = (tdx_hw_tag.prodid == VERDIN_IMX8MMQ_WIFI_BT_IT) ||
85 (tdx_hw_tag.prodid == VERDIN_IMX8MMDL_WIFI_BT_IT);
88 switch (get_pcb_revision()) {
90 printf("Detected a V1.0 module\n");
92 strncpy(&variant[0], "wifi", sizeof(variant));
94 strncpy(&variant[0], "nonwifi", sizeof(variant));
98 strncpy(&variant[0], "wifi-v1.1", sizeof(variant));
100 strncpy(&variant[0], "nonwifi-v1.1", sizeof(variant));
104 if (strcmp(variant, env_variant)) {
105 printf("Setting variant to %s\n", variant);
106 env_set("variant", variant);
108 if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE))
113 int board_late_init(void)
115 select_dt_from_module_version();
120 int board_phys_sdram_size(phys_size_t *size)
125 *size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
130 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
131 int ft_board_setup(void *blob, struct bd_info *bd)