blob: 01e32136532d1cebbf4a54aa167a7f58fbed5269 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Peng Fanf7765d72017-02-22 16:21:56 +08002/*
3 * Copyright (C) 2016 Freescale Semiconductor, Inc.
Peng Fanf7765d72017-02-22 16:21:56 +08004 */
5
6#include <common.h>
Peng Fan23024fd72019-07-22 01:24:39 +00007#include <fdt_support.h>
Simon Glass97589732020-05-10 11:40:02 -06008#include <init.h>
Simon Glass3ba929a2020-10-30 21:38:53 -06009#include <asm/global_data.h>
Peng Fanf7765d72017-02-22 16:21:56 +080010#include <asm/io.h>
11#include <asm/arch/sys_proto.h>
12#include <asm/arch/mx7ulp-pins.h>
13#include <asm/arch/iomux.h>
Peng Fan23024fd72019-07-22 01:24:39 +000014#include <asm/mach-imx/boot_mode.h>
Peng Fanf7765d72017-02-22 16:21:56 +080015
16DECLARE_GLOBAL_DATA_PTR;
17
18#define UART_PAD_CTRL (PAD_CTL_PUS_UP)
19
20int dram_init(void)
21{
Fabio Estevamd4c56b82019-07-18 15:04:25 -030022 gd->ram_size = imx_ddr_size();
Peng Fanf7765d72017-02-22 16:21:56 +080023
24 return 0;
25}
26
27static iomux_cfg_t const lpuart4_pads[] = {
28 MX7ULP_PAD_PTC3__LPUART4_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
29 MX7ULP_PAD_PTC2__LPUART4_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
30};
31
32static void setup_iomux_uart(void)
33{
34 mx7ulp_iomux_setup_multiple_pads(lpuart4_pads,
35 ARRAY_SIZE(lpuart4_pads));
36}
37
38int board_early_init_f(void)
39{
40 setup_iomux_uart();
41
42 return 0;
43}
44
45int board_init(void)
46{
47 /* address of boot parameters */
48 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
49
50 return 0;
51}
Peng Fan23024fd72019-07-22 01:24:39 +000052
53#if IS_ENABLED(CONFIG_OF_BOARD_SETUP)
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +090054int ft_board_setup(void *blob, struct bd_info *bd)
Peng Fan23024fd72019-07-22 01:24:39 +000055{
56 const char *path;
57 int rc, nodeoff;
58
59 if (get_boot_device() == USB_BOOT) {
60 path = fdt_get_alias(blob, "mmc0");
61 if (!path) {
62 puts("Not found mmc0\n");
63 return 0;
64 }
65
66 nodeoff = fdt_path_offset(blob, path);
67 if (nodeoff < 0)
68 return 0;
69
70 printf("Found usdhc0 node\n");
71 if (fdt_get_property(blob, nodeoff, "vqmmc-supply",
72 NULL) != NULL) {
73 rc = fdt_delprop(blob, nodeoff, "vqmmc-supply");
74 if (!rc) {
75 puts("Removed vqmmc-supply property\n");
76add:
77 rc = fdt_setprop(blob, nodeoff,
78 "no-1-8-v", NULL, 0);
79 if (rc == -FDT_ERR_NOSPACE) {
80 rc = fdt_increase_size(blob, 32);
81 if (!rc)
82 goto add;
83 } else if (rc) {
84 printf("Failed to add no-1-8-v property, %d\n", rc);
85 } else {
86 puts("Added no-1-8-v property\n");
87 }
88 } else {
89 printf("Failed to remove vqmmc-supply property, %d\n", rc);
90 }
91 }
92 }
93
94 return 0;
95}
96#endif