]>
Commit | Line | Data |
---|---|---|
2bc2f817 MZ |
1 | // SPDX-License-Identifier: GPL-2.0-or-later |
2 | /* | |
3 | * Copyright 2022 Toradex | |
4 | */ | |
5 | ||
d678a59d | 6 | #include <common.h> |
2bc2f817 MZ |
7 | #include <asm/arch/clock.h> |
8 | #include <asm/arch/imx8mp_pins.h> | |
9 | #include <asm/arch/sys_proto.h> | |
10 | #include <asm-generic/gpio.h> | |
11 | #include <asm/global_data.h> | |
12 | #include <asm/mach-imx/gpio.h> | |
13 | #include <asm/mach-imx/iomux-v3.h> | |
14 | #include <errno.h> | |
15 | #include <env.h> | |
16 | #include <init.h> | |
17 | #include <linux/delay.h> | |
18 | #include <micrel.h> | |
19 | #include <miiphy.h> | |
20 | #include <netdev.h> | |
21 | ||
22 | #include "../common/tdx-cfg-block.h" | |
23 | ||
24 | DECLARE_GLOBAL_DATA_PTR; | |
25 | ||
26 | #define UART_PAD_CTRL (PAD_CTL_DSE6 | PAD_CTL_FSEL1) | |
2bc2f817 MZ |
27 | |
28 | /* Verdin UART_3, Console/Debug UART */ | |
29 | static const iomux_v3_cfg_t uart_pads[] = { | |
30 | MX8MP_PAD_UART3_RXD__UART3_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL), | |
31 | MX8MP_PAD_UART3_TXD__UART3_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL), | |
32 | }; | |
33 | ||
2bc2f817 MZ |
34 | int board_early_init_f(void) |
35 | { | |
2bc2f817 MZ |
36 | imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads)); |
37 | ||
38 | init_uart_clk(2); | |
39 | ||
40 | return 0; | |
41 | } | |
42 | ||
43 | static void setup_fec(void) | |
44 | { | |
45 | struct iomuxc_gpr_base_regs *gpr = | |
46 | (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR; | |
47 | ||
48 | /* Enable RGMII TX clk output */ | |
49 | setbits_le32(&gpr->gpr[1], BIT(22)); | |
50 | } | |
51 | ||
2bc2f817 MZ |
52 | #if IS_ENABLED(CONFIG_NET) |
53 | int board_phy_config(struct phy_device *phydev) | |
54 | { | |
55 | if (phydev->drv->config) | |
56 | phydev->drv->config(phydev); | |
57 | return 0; | |
58 | } | |
59 | #endif | |
60 | ||
61 | int board_init(void) | |
62 | { | |
63 | int ret = 0; | |
64 | ||
65 | if (IS_ENABLED(CONFIG_FEC_MXC)) | |
66 | setup_fec(); | |
67 | ||
2bc2f817 MZ |
68 | return ret; |
69 | } | |
70 | ||
71 | static void select_dt_from_module_version(void) | |
72 | { | |
73 | char variant[32]; | |
74 | char *env_variant = env_get("variant"); | |
75 | int is_wifi = 0; | |
76 | ||
77 | if (IS_ENABLED(CONFIG_TDX_CFG_BLOCK)) { | |
78 | /* | |
79 | * If we have a valid config block and it says we are a module with | |
80 | * Wi-Fi/Bluetooth make sure we use the -wifi device tree. | |
81 | */ | |
82 | is_wifi = (tdx_hw_tag.prodid == VERDIN_IMX8MPQ_WIFI_BT_IT) || | |
83 | (tdx_hw_tag.prodid == VERDIN_IMX8MPQ_2GB_WIFI_BT_IT) || | |
611b94bf EG |
84 | (tdx_hw_tag.prodid == VERDIN_IMX8MPQ_8GB_WIFI_BT) || |
85 | (tdx_hw_tag.prodid == VERDIN_IMX8MPQ_8GB_WIFI_BT_IT); | |
2bc2f817 MZ |
86 | } |
87 | ||
88 | if (is_wifi) | |
89 | strlcpy(&variant[0], "wifi", sizeof(variant)); | |
90 | else | |
91 | strlcpy(&variant[0], "nonwifi", sizeof(variant)); | |
92 | ||
93 | if (strcmp(variant, env_variant)) { | |
94 | printf("Setting variant to %s\n", variant); | |
95 | env_set("variant", variant); | |
2bc2f817 MZ |
96 | } |
97 | } | |
98 | ||
99 | int board_late_init(void) | |
100 | { | |
101 | select_dt_from_module_version(); | |
102 | ||
103 | return 0; | |
104 | } | |
105 | ||
5a167971 FD |
106 | int board_phys_sdram_size(phys_size_t *size) |
107 | { | |
108 | if (!size) | |
109 | return -EINVAL; | |
110 | ||
111 | *size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE + PHYS_SDRAM_2_SIZE); | |
112 | ||
113 | return 0; | |
114 | } | |
115 | ||
2bc2f817 MZ |
116 | #if IS_ENABLED(CONFIG_OF_LIBFDT) && IS_ENABLED(CONFIG_OF_BOARD_SETUP) |
117 | int ft_board_setup(void *blob, struct bd_info *bd) | |
118 | { | |
6a64bcfa | 119 | return ft_common_board_setup(blob, bd); |
2bc2f817 MZ |
120 | } |
121 | #endif |