Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Peng Fan | f7765d7 | 2017-02-22 16:21:56 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2016 Freescale Semiconductor, Inc. |
Peng Fan | f7765d7 | 2017-02-22 16:21:56 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Peng Fan | 23024fd7 | 2019-07-22 01:24:39 +0000 | [diff] [blame] | 7 | #include <fdt_support.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 8 | #include <init.h> |
Peng Fan | f7765d7 | 2017-02-22 16:21:56 +0800 | [diff] [blame] | 9 | #include <asm/io.h> |
| 10 | #include <asm/arch/sys_proto.h> |
| 11 | #include <asm/arch/mx7ulp-pins.h> |
| 12 | #include <asm/arch/iomux.h> |
Peng Fan | 23024fd7 | 2019-07-22 01:24:39 +0000 | [diff] [blame] | 13 | #include <asm/mach-imx/boot_mode.h> |
Peng Fan | f7765d7 | 2017-02-22 16:21:56 +0800 | [diff] [blame] | 14 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
| 16 | |
| 17 | #define UART_PAD_CTRL (PAD_CTL_PUS_UP) |
| 18 | |
| 19 | int dram_init(void) |
| 20 | { |
Fabio Estevam | d4c56b8 | 2019-07-18 15:04:25 -0300 | [diff] [blame] | 21 | gd->ram_size = imx_ddr_size(); |
Peng Fan | f7765d7 | 2017-02-22 16:21:56 +0800 | [diff] [blame] | 22 | |
| 23 | return 0; |
| 24 | } |
| 25 | |
| 26 | static iomux_cfg_t const lpuart4_pads[] = { |
| 27 | MX7ULP_PAD_PTC3__LPUART4_RX | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 28 | MX7ULP_PAD_PTC2__LPUART4_TX | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 29 | }; |
| 30 | |
| 31 | static void setup_iomux_uart(void) |
| 32 | { |
| 33 | mx7ulp_iomux_setup_multiple_pads(lpuart4_pads, |
| 34 | ARRAY_SIZE(lpuart4_pads)); |
| 35 | } |
| 36 | |
| 37 | int board_early_init_f(void) |
| 38 | { |
| 39 | setup_iomux_uart(); |
| 40 | |
| 41 | return 0; |
| 42 | } |
| 43 | |
| 44 | int board_init(void) |
| 45 | { |
| 46 | /* address of boot parameters */ |
| 47 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 48 | |
| 49 | return 0; |
| 50 | } |
Peng Fan | 23024fd7 | 2019-07-22 01:24:39 +0000 | [diff] [blame] | 51 | |
| 52 | #if IS_ENABLED(CONFIG_OF_BOARD_SETUP) |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 53 | int ft_board_setup(void *blob, struct bd_info *bd) |
Peng Fan | 23024fd7 | 2019-07-22 01:24:39 +0000 | [diff] [blame] | 54 | { |
| 55 | const char *path; |
| 56 | int rc, nodeoff; |
| 57 | |
| 58 | if (get_boot_device() == USB_BOOT) { |
| 59 | path = fdt_get_alias(blob, "mmc0"); |
| 60 | if (!path) { |
| 61 | puts("Not found mmc0\n"); |
| 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | nodeoff = fdt_path_offset(blob, path); |
| 66 | if (nodeoff < 0) |
| 67 | return 0; |
| 68 | |
| 69 | printf("Found usdhc0 node\n"); |
| 70 | if (fdt_get_property(blob, nodeoff, "vqmmc-supply", |
| 71 | NULL) != NULL) { |
| 72 | rc = fdt_delprop(blob, nodeoff, "vqmmc-supply"); |
| 73 | if (!rc) { |
| 74 | puts("Removed vqmmc-supply property\n"); |
| 75 | add: |
| 76 | rc = fdt_setprop(blob, nodeoff, |
| 77 | "no-1-8-v", NULL, 0); |
| 78 | if (rc == -FDT_ERR_NOSPACE) { |
| 79 | rc = fdt_increase_size(blob, 32); |
| 80 | if (!rc) |
| 81 | goto add; |
| 82 | } else if (rc) { |
| 83 | printf("Failed to add no-1-8-v property, %d\n", rc); |
| 84 | } else { |
| 85 | puts("Added no-1-8-v property\n"); |
| 86 | } |
| 87 | } else { |
| 88 | printf("Failed to remove vqmmc-supply property, %d\n", rc); |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | return 0; |
| 94 | } |
| 95 | #endif |