blob: 04830411872e1bbad3c8f4e7233321afee38c5da [file] [log] [blame]
Marcel Ziswiler475ceff2019-05-31 19:00:20 +03001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2019 Toradex
4 */
5
6#include <common.h>
Simon Glassa7b51302019-11-14 12:57:46 -07007#include <init.h>
Marcel Ziswiler475ceff2019-05-31 19:00:20 +03008
9#include <asm/arch/clock.h>
10#include <asm/arch/imx8-pins.h>
11#include <asm/arch/iomux.h>
12#include <asm/arch/sci/sci.h>
13#include <asm/arch/sys_proto.h>
14#include <asm/gpio.h>
15#include <asm/io.h>
Simon Glass5e6201b2019-08-01 09:46:51 -060016#include <env.h>
Marcel Ziswiler475ceff2019-05-31 19:00:20 +030017#include <errno.h>
18#include <linux/libfdt.h>
19
20#include "../common/tdx-cfg-block.h"
21
22DECLARE_GLOBAL_DATA_PTR;
23
24#define UART_PAD_CTRL ((SC_PAD_CONFIG_OUT_IN << PADRING_CONFIG_SHIFT) | \
25 (SC_PAD_ISO_OFF << PADRING_LPCONFIG_SHIFT) | \
26 (SC_PAD_28FDSOI_DSE_DV_HIGH << PADRING_DSE_SHIFT) | \
27 (SC_PAD_28FDSOI_PS_PU << PADRING_PULL_SHIFT))
28
29static iomux_cfg_t uart1_pads[] = {
30 SC_P_UART1_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
31 SC_P_UART1_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
32};
33
34static void setup_iomux_uart(void)
35{
36 imx8_iomux_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
37}
38
39int board_early_init_f(void)
40{
Anatolij Gustschinef156d22019-06-12 13:35:25 +020041 sc_pm_clock_rate_t rate = SC_80MHZ;
Marcel Ziswiler475ceff2019-05-31 19:00:20 +030042 sc_err_t err = 0;
43
Anatolij Gustschinef156d22019-06-12 13:35:25 +020044 /* Set UART1 clock root to 80 MHz and enable it */
45 err = sc_pm_setup_uart(SC_R_UART_1, rate);
Marcel Ziswiler475ceff2019-05-31 19:00:20 +030046 if (err != SC_ERR_NONE)
47 return 0;
48
49 setup_iomux_uart();
50
51 return 0;
52}
53
Simon Glassfa4689a2019-12-06 21:41:35 -070054#if CONFIG_IS_ENABLED(DM_GPIO)
Marcel Ziswiler475ceff2019-05-31 19:00:20 +030055static void board_gpio_init(void)
56{
57 /* TODO */
58}
59#else
60static inline void board_gpio_init(void) {}
61#endif
62
63#if IS_ENABLED(CONFIG_FEC_MXC)
64#include <miiphy.h>
65
66int board_phy_config(struct phy_device *phydev)
67{
68 if (phydev->drv->config)
69 phydev->drv->config(phydev);
70
71 return 0;
72}
73#endif
74
Marcel Ziswiler475ceff2019-05-31 19:00:20 +030075int checkboard(void)
76{
77 puts("Model: Toradex Apalis iMX8\n");
78
79 build_info();
80 print_bootinfo();
81
82 return 0;
83}
84
85int board_init(void)
86{
87 board_gpio_init();
88
89 return 0;
90}
91
92void detail_board_ddr_info(void)
93{
94 puts("\nDDR ");
95}
96
97/*
98 * Board specific reset that is system reset.
99 */
100void reset_cpu(ulong addr)
101{
102 /* TODO */
103}
104
105#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
106int ft_board_setup(void *blob, bd_t *bd)
107{
108 return ft_common_board_setup(blob, bd);
109}
110#endif
111
112int board_mmc_get_env_dev(int devno)
113{
114 return devno;
115}
116
117int board_late_init(void)
118{
119#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
120/* TODO move to common */
121 env_set("board_name", "Apalis iMX8QM");
122 env_set("board_rev", "v1.0");
123#endif
124
125 return 0;
126}