command: Remove the cmd_tbl_t typedef
[oweals/u-boot.git] / board / freescale / imx8mp_evk / imx8mp_evk.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright 2019 NXP
4  */
5
6 #include <common.h>
7 #include <env.h>
8 #include <errno.h>
9 #include <init.h>
10 #include <asm/mach-imx/iomux-v3.h>
11 #include <asm-generic/gpio.h>
12 #include <asm/arch/imx8mp_pins.h>
13 #include <asm/arch/sys_proto.h>
14 #include <asm/mach-imx/gpio.h>
15
16 DECLARE_GLOBAL_DATA_PTR;
17
18 #define UART_PAD_CTRL   (PAD_CTL_DSE6 | PAD_CTL_FSEL1)
19 #define WDOG_PAD_CTRL   (PAD_CTL_DSE6 | PAD_CTL_ODE | PAD_CTL_PUE | PAD_CTL_PE)
20
21 static iomux_v3_cfg_t const uart_pads[] = {
22         MX8MP_PAD_UART2_RXD__UART2_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
23         MX8MP_PAD_UART2_TXD__UART2_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
24 };
25
26 static iomux_v3_cfg_t const wdog_pads[] = {
27         MX8MP_PAD_GPIO1_IO02__WDOG1_WDOG_B  | MUX_PAD_CTRL(WDOG_PAD_CTRL),
28 };
29
30 int board_early_init_f(void)
31 {
32         struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR;
33
34         imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads));
35
36         set_wdog_reset(wdog);
37
38         imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
39
40         return 0;
41 }
42
43 int dram_init(void)
44 {
45         /* rom_pointer[1] contains the size of TEE occupies */
46         if (rom_pointer[1])
47                 gd->ram_size = PHYS_SDRAM_SIZE - rom_pointer[1];
48         else
49                 gd->ram_size = PHYS_SDRAM_SIZE;
50
51 #if CONFIG_NR_DRAM_BANKS > 1
52         gd->ram_size += PHYS_SDRAM_2_SIZE;
53 #endif
54
55         return 0;
56 }
57
58 int dram_init_banksize(void)
59 {
60         gd->bd->bi_dram[0].start = PHYS_SDRAM;
61         if (rom_pointer[1])
62
63                 gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE - rom_pointer[1];
64         else
65                 gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE;
66
67 #if CONFIG_NR_DRAM_BANKS > 1
68         gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
69         gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
70 #endif
71
72         return 0;
73 }
74
75 phys_size_t get_effective_memsize(void)
76 {
77         if (rom_pointer[1])
78                 return (PHYS_SDRAM_SIZE - rom_pointer[1]);
79         else
80                 return PHYS_SDRAM_SIZE;
81 }
82
83 int board_init(void)
84 {
85         return 0;
86 }
87
88 int board_late_init(void)
89 {
90 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
91         env_set("board_name", "EVK");
92         env_set("board_rev", "iMX8MP");
93 #endif
94
95         return 0;
96 }