Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Peng Fan | 8159063 | 2016-08-11 14:02:57 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2016 Freescale Semiconductor, Inc. |
Peng Fan | 8159063 | 2016-08-11 14:02:57 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 6 | #include <init.h> |
Peng Fan | 8159063 | 2016-08-11 14:02:57 +0800 | [diff] [blame] | 7 | #include <asm/arch/clock.h> |
| 8 | #include <asm/arch/iomux.h> |
| 9 | #include <asm/arch/imx-regs.h> |
| 10 | #include <asm/arch/crm_regs.h> |
| 11 | #include <asm/arch/mx6-pins.h> |
| 12 | #include <asm/arch/sys_proto.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 13 | #include <asm/global_data.h> |
Peng Fan | 8159063 | 2016-08-11 14:02:57 +0800 | [diff] [blame] | 14 | #include <asm/gpio.h> |
Stefano Babic | 33731bc | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 15 | #include <asm/mach-imx/iomux-v3.h> |
| 16 | #include <asm/mach-imx/boot_mode.h> |
Peng Fan | 8159063 | 2016-08-11 14:02:57 +0800 | [diff] [blame] | 17 | #include <asm/io.h> |
| 18 | #include <common.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 19 | #include <env.h> |
Yangbo Lu | 7334038 | 2019-06-21 11:42:28 +0800 | [diff] [blame] | 20 | #include <fsl_esdhc_imx.h> |
Peng Fan | 8159063 | 2016-08-11 14:02:57 +0800 | [diff] [blame] | 21 | #include <linux/sizes.h> |
| 22 | #include <mmc.h> |
Fabio Estevam | 4ada4f0 | 2020-02-03 14:23:58 -0300 | [diff] [blame] | 23 | #include <miiphy.h> |
Peng Fan | 8159063 | 2016-08-11 14:02:57 +0800 | [diff] [blame] | 24 | |
| 25 | DECLARE_GLOBAL_DATA_PTR; |
| 26 | |
Peng Fan | 8159063 | 2016-08-11 14:02:57 +0800 | [diff] [blame] | 27 | int dram_init(void) |
| 28 | { |
| 29 | gd->ram_size = imx_ddr_size(); |
| 30 | |
| 31 | return 0; |
| 32 | } |
| 33 | |
Peng Fan | 8159063 | 2016-08-11 14:02:57 +0800 | [diff] [blame] | 34 | int board_mmc_get_env_dev(int devno) |
| 35 | { |
| 36 | return devno; |
| 37 | } |
| 38 | |
| 39 | int mmc_map_to_kernel_blk(int devno) |
| 40 | { |
| 41 | return devno; |
| 42 | } |
| 43 | |
| 44 | int board_early_init_f(void) |
| 45 | { |
Peng Fan | 8159063 | 2016-08-11 14:02:57 +0800 | [diff] [blame] | 46 | return 0; |
| 47 | } |
| 48 | |
Fabio Estevam | 4ada4f0 | 2020-02-03 14:23:58 -0300 | [diff] [blame] | 49 | #ifdef CONFIG_FEC_MXC |
| 50 | static int setup_fec(int fec_id) |
| 51 | { |
| 52 | struct iomuxc *const iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR; |
| 53 | int ret; |
| 54 | |
| 55 | if (fec_id == 0) { |
| 56 | /* |
| 57 | * Use 50MHz anatop loopback REF_CLK1 for ENET1, |
| 58 | * clear gpr1[13], set gpr1[17]. |
| 59 | */ |
| 60 | clrsetbits_le32(&iomuxc_regs->gpr[1], IOMUX_GPR1_FEC1_MASK, |
| 61 | IOMUX_GPR1_FEC1_CLOCK_MUX1_SEL_MASK); |
| 62 | } else { |
| 63 | /* |
| 64 | * Use 50MHz anatop loopback REF_CLK2 for ENET2, |
| 65 | * clear gpr1[14], set gpr1[18]. |
| 66 | */ |
| 67 | clrsetbits_le32(&iomuxc_regs->gpr[1], IOMUX_GPR1_FEC2_MASK, |
| 68 | IOMUX_GPR1_FEC2_CLOCK_MUX1_SEL_MASK); |
| 69 | } |
| 70 | |
| 71 | ret = enable_fec_anatop_clock(fec_id, ENET_50MHZ); |
| 72 | if (ret) |
| 73 | return ret; |
| 74 | |
| 75 | enable_enet_clk(1); |
| 76 | |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | int board_phy_config(struct phy_device *phydev) |
| 81 | { |
| 82 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1f, 0x8190); |
| 83 | |
| 84 | if (phydev->drv->config) |
| 85 | phydev->drv->config(phydev); |
| 86 | |
| 87 | return 0; |
| 88 | } |
| 89 | #endif |
| 90 | |
Peng Fan | 8159063 | 2016-08-11 14:02:57 +0800 | [diff] [blame] | 91 | int board_init(void) |
| 92 | { |
| 93 | /* Address of boot parameters */ |
| 94 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 95 | |
Fabio Estevam | 4ada4f0 | 2020-02-03 14:23:58 -0300 | [diff] [blame] | 96 | #ifdef CONFIG_FEC_MXC |
Tom Rini | b70d5d4 | 2022-12-04 10:03:52 -0500 | [diff] [blame] | 97 | setup_fec(CFG_FEC_ENET_DEV); |
Fabio Estevam | 4ada4f0 | 2020-02-03 14:23:58 -0300 | [diff] [blame] | 98 | #endif |
| 99 | |
Peng Fan | 8159063 | 2016-08-11 14:02:57 +0800 | [diff] [blame] | 100 | return 0; |
| 101 | } |
| 102 | |
| 103 | #ifdef CONFIG_CMD_BMODE |
| 104 | static const struct boot_mode board_boot_modes[] = { |
| 105 | /* 4 bit bus width */ |
| 106 | {"sd1", MAKE_CFGVAL(0x42, 0x20, 0x00, 0x00)}, |
| 107 | {"sd2", MAKE_CFGVAL(0x40, 0x28, 0x00, 0x00)}, |
| 108 | {"qspi1", MAKE_CFGVAL(0x10, 0x00, 0x00, 0x00)}, |
| 109 | {NULL, 0}, |
| 110 | }; |
| 111 | #endif |
| 112 | |
| 113 | int board_late_init(void) |
| 114 | { |
| 115 | #ifdef CONFIG_CMD_BMODE |
| 116 | add_board_boot_modes(board_boot_modes); |
| 117 | #endif |
| 118 | |
| 119 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
Peng Fan | 5098eae | 2019-08-08 09:55:57 +0000 | [diff] [blame] | 120 | if (is_cpu_type(MXC_CPU_MX6ULZ)) |
| 121 | env_set("board_name", "ULZ-EVK"); |
| 122 | else |
| 123 | env_set("board_name", "EVK"); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 124 | env_set("board_rev", "14X14"); |
Peng Fan | 8159063 | 2016-08-11 14:02:57 +0800 | [diff] [blame] | 125 | #endif |
| 126 | |
| 127 | return 0; |
| 128 | } |
| 129 | |
| 130 | int checkboard(void) |
| 131 | { |
Peng Fan | 5098eae | 2019-08-08 09:55:57 +0000 | [diff] [blame] | 132 | if (is_cpu_type(MXC_CPU_MX6ULZ)) |
| 133 | puts("Board: MX6ULZ 14x14 EVK\n"); |
| 134 | else |
| 135 | puts("Board: MX6ULL 14x14 EVK\n"); |
Peng Fan | 8159063 | 2016-08-11 14:02:57 +0800 | [diff] [blame] | 136 | |
| 137 | return 0; |
| 138 | } |