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