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> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 9 | #include <asm/global_data.h> |
Peng Fan | f7765d7 | 2017-02-22 16:21:56 +0800 | [diff] [blame] | 10 | #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 Fan | 23024fd7 | 2019-07-22 01:24:39 +0000 | [diff] [blame] | 14 | #include <asm/mach-imx/boot_mode.h> |
Peng Fan | f7765d7 | 2017-02-22 16:21:56 +0800 | [diff] [blame] | 15 | |
| 16 | DECLARE_GLOBAL_DATA_PTR; |
| 17 | |
| 18 | #define UART_PAD_CTRL (PAD_CTL_PUS_UP) |
| 19 | |
| 20 | int dram_init(void) |
| 21 | { |
Fabio Estevam | d4c56b8 | 2019-07-18 15:04:25 -0300 | [diff] [blame] | 22 | gd->ram_size = imx_ddr_size(); |
Peng Fan | f7765d7 | 2017-02-22 16:21:56 +0800 | [diff] [blame] | 23 | |
| 24 | return 0; |
| 25 | } |
| 26 | |
| 27 | static 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 | |
| 32 | static void setup_iomux_uart(void) |
| 33 | { |
| 34 | mx7ulp_iomux_setup_multiple_pads(lpuart4_pads, |
| 35 | ARRAY_SIZE(lpuart4_pads)); |
| 36 | } |
| 37 | |
| 38 | int board_early_init_f(void) |
| 39 | { |
| 40 | setup_iomux_uart(); |
| 41 | |
| 42 | return 0; |
| 43 | } |
| 44 | |
| 45 | int board_init(void) |
| 46 | { |
| 47 | /* address of boot parameters */ |
| 48 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 49 | |
| 50 | return 0; |
| 51 | } |
Peng Fan | 23024fd7 | 2019-07-22 01:24:39 +0000 | [diff] [blame] | 52 | |
| 53 | #if IS_ENABLED(CONFIG_OF_BOARD_SETUP) |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 54 | int ft_board_setup(void *blob, struct bd_info *bd) |
Peng Fan | 23024fd7 | 2019-07-22 01:24:39 +0000 | [diff] [blame] | 55 | { |
| 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"); |
| 76 | add: |
| 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 |