1
2
3
4
5
6#include <common.h>
7#include <cpu_func.h>
8#include <init.h>
9
10#include <asm/arch/clock.h>
11#include <asm/arch/imx8-pins.h>
12#include <asm/arch/iomux.h>
13#include <asm/arch/sci/sci.h>
14#include <asm/arch/sys_proto.h>
15#include <asm/gpio.h>
16#include <asm/io.h>
17#include <env.h>
18#include <errno.h>
19#include <linux/libfdt.h>
20
21#include "../common/tdx-cfg-block.h"
22
23DECLARE_GLOBAL_DATA_PTR;
24
25#define UART_PAD_CTRL ((SC_PAD_CONFIG_OUT_IN << PADRING_CONFIG_SHIFT) | \
26 (SC_PAD_ISO_OFF << PADRING_LPCONFIG_SHIFT) | \
27 (SC_PAD_28FDSOI_DSE_DV_HIGH << PADRING_DSE_SHIFT) | \
28 (SC_PAD_28FDSOI_PS_PU << PADRING_PULL_SHIFT))
29
30static iomux_cfg_t uart3_pads[] = {
31 SC_P_FLEXCAN2_RX | MUX_MODE_ALT(2) | MUX_PAD_CTRL(UART_PAD_CTRL),
32 SC_P_FLEXCAN2_TX | MUX_MODE_ALT(2) | MUX_PAD_CTRL(UART_PAD_CTRL),
33
34 SC_P_QSPI0B_DQS | MUX_MODE_ALT(4) | MUX_PAD_CTRL(UART_PAD_CTRL),
35};
36
37static void setup_iomux_uart(void)
38{
39 imx8_iomux_setup_multiple_pads(uart3_pads, ARRAY_SIZE(uart3_pads));
40}
41
42int board_early_init_f(void)
43{
44 sc_pm_clock_rate_t rate;
45 sc_err_t err = 0;
46
47
48
49
50
51 rate = 80000000;
52 err = sc_pm_set_clock_rate(-1, SC_R_UART_0, SC_PM_CLK_PER, &rate);
53 if (err != SC_ERR_NONE)
54 return 0;
55
56
57 rate = SC_80MHZ;
58 err = sc_pm_setup_uart(SC_R_UART_3, rate);
59 if (err != SC_ERR_NONE)
60 return 0;
61
62 setup_iomux_uart();
63
64 return 0;
65}
66
67#if IS_ENABLED(CONFIG_DM_GPIO)
68static void board_gpio_init(void)
69{
70
71}
72#else
73static inline void board_gpio_init(void) {}
74#endif
75
76#if IS_ENABLED(CONFIG_FEC_MXC)
77#include <miiphy.h>
78
79int board_phy_config(struct phy_device *phydev)
80{
81 if (phydev->drv->config)
82 phydev->drv->config(phydev);
83
84 return 0;
85}
86#endif
87
88int checkboard(void)
89{
90 puts("Model: Toradex Colibri iMX8X\n");
91
92 build_info();
93 print_bootinfo();
94
95 return 0;
96}
97
98int board_init(void)
99{
100 board_gpio_init();
101
102 return 0;
103}
104
105
106
107
108void reset_cpu(ulong addr)
109{
110
111}
112
113#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
114int ft_board_setup(void *blob, struct bd_info *bd)
115{
116 return ft_common_board_setup(blob, bd);
117}
118#endif
119
120int board_mmc_get_env_dev(int devno)
121{
122 return devno;
123}
124
125int board_late_init(void)
126{
127#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
128
129 env_set("board_name", "Colibri iMX8QXP");
130 env_set("board_rev", "v1.0");
131#endif
132
133 return 0;
134}
135