blob: 9263b0f51fa70ba641156fe3a42f266d5c6f9b10 [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 Glassafb02152019-12-28 10:45:01 -07007#include <cpu_func.h>
Simon Glassa7b51302019-11-14 12:57:46 -07008#include <init.h>
Marcel Ziswiler475ceff2019-05-31 19:00:20 +03009
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>
Simon Glass5e6201b2019-08-01 09:46:51 -060017#include <env.h>
Marcel Ziswiler475ceff2019-05-31 19:00:20 +030018#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 uart1_pads[] = {
31 SC_P_UART1_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
32 SC_P_UART1_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
33};
34
35static void setup_iomux_uart(void)
36{
37 imx8_iomux_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
38}
39
40int board_early_init_f(void)
41{
Anatolij Gustschinef156d22019-06-12 13:35:25 +020042 sc_pm_clock_rate_t rate = SC_80MHZ;
Marcel Ziswiler475ceff2019-05-31 19:00:20 +030043 sc_err_t err = 0;
44
Anatolij Gustschinef156d22019-06-12 13:35:25 +020045 /* Set UART1 clock root to 80 MHz and enable it */
46 err = sc_pm_setup_uart(SC_R_UART_1, rate);
Marcel Ziswiler475ceff2019-05-31 19:00:20 +030047 if (err != SC_ERR_NONE)
48 return 0;
49
50 setup_iomux_uart();
51
52 return 0;
53}
54
Simon Glassfa4689a2019-12-06 21:41:35 -070055#if CONFIG_IS_ENABLED(DM_GPIO)
Marcel Ziswiler475ceff2019-05-31 19:00:20 +030056static void board_gpio_init(void)
57{
58 /* TODO */
59}
60#else
61static inline void board_gpio_init(void) {}
62#endif
63
64#if IS_ENABLED(CONFIG_FEC_MXC)
65#include <miiphy.h>
66
67int board_phy_config(struct phy_device *phydev)
68{
69 if (phydev->drv->config)
70 phydev->drv->config(phydev);
71
72 return 0;
73}
74#endif
75
Marcel Ziswiler475ceff2019-05-31 19:00:20 +030076int checkboard(void)
77{
78 puts("Model: Toradex Apalis iMX8\n");
79
80 build_info();
81 print_bootinfo();
82
83 return 0;
84}
85
86int board_init(void)
87{
88 board_gpio_init();
89
90 return 0;
91}
92
Marcel Ziswiler475ceff2019-05-31 19:00:20 +030093/*
94 * Board specific reset that is system reset.
95 */
96void reset_cpu(ulong addr)
97{
98 /* TODO */
99}
100
101#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900102int ft_board_setup(void *blob, struct bd_info *bd)
Marcel Ziswiler475ceff2019-05-31 19:00:20 +0300103{
104 return ft_common_board_setup(blob, bd);
105}
106#endif
107
108int board_mmc_get_env_dev(int devno)
109{
110 return devno;
111}
112
113int board_late_init(void)
114{
115#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
116/* TODO move to common */
117 env_set("board_name", "Apalis iMX8QM");
118 env_set("board_rev", "v1.0");
119#endif
120
121 return 0;
122}