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