Oleh Kravchenko | 4a2c0da | 2021-05-15 00:18:31 +0300 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | // Copyright (C) 2021 Oleh Kravchenko <oleg@kaa.org.ua> |
| 3 | |
| 4 | #include <asm/arch-mx6/clock.h> |
| 5 | #include <asm/arch/sys_proto.h> |
| 6 | #include <asm/global_data.h> |
| 7 | #include <asm/mach-imx/boot_mode.h> |
Oleh Kravchenko | 4a2c0da | 2021-05-15 00:18:31 +0300 | [diff] [blame] | 8 | #include <env.h> |
| 9 | |
| 10 | DECLARE_GLOBAL_DATA_PTR; |
| 11 | |
| 12 | int dram_init(void) |
| 13 | { |
| 14 | gd->ram_size = imx_ddr_size(); |
| 15 | |
| 16 | return 0; |
| 17 | } |
| 18 | |
| 19 | int board_early_init_f(void) |
| 20 | { |
| 21 | return 0; |
| 22 | } |
| 23 | |
| 24 | static int setup_fec_clock(void) |
| 25 | { |
| 26 | if (IS_ENABLED(CONFIG_FEC_MXC) && !IS_ENABLED(CONFIG_CLK_IMX6Q)) { |
| 27 | struct iomuxc *const iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR; |
| 28 | int ret; |
| 29 | |
| 30 | /* |
| 31 | * Use 50M anatop loopback REF_CLK1 for ENET1, |
| 32 | * clear gpr1[13], set gpr1[17]. |
| 33 | */ |
| 34 | clrsetbits_le32(&iomuxc_regs->gpr[1], IOMUX_GPR1_FEC1_MASK, |
| 35 | IOMUX_GPR1_FEC1_CLOCK_MUX1_SEL_MASK); |
| 36 | |
| 37 | ret = enable_fec_anatop_clock(0, ENET_50MHZ); |
| 38 | if (ret) |
| 39 | return ret; |
| 40 | |
Oleh Kravchenko | 9633828 | 2021-05-15 00:18:33 +0300 | [diff] [blame] | 41 | if (!IS_ENABLED(CONFIG_EV_IMX280_NANO_X_MB)) { |
| 42 | /* |
| 43 | * Use 50M anatop loopback REF_CLK2 for ENET2, |
| 44 | * clear gpr1[14], set gpr1[18]. |
| 45 | */ |
| 46 | clrsetbits_le32(&iomuxc_regs->gpr[1], IOMUX_GPR1_FEC2_MASK, |
| 47 | IOMUX_GPR1_FEC2_CLOCK_MUX1_SEL_MASK); |
Oleh Kravchenko | 4a2c0da | 2021-05-15 00:18:31 +0300 | [diff] [blame] | 48 | |
Oleh Kravchenko | 9633828 | 2021-05-15 00:18:33 +0300 | [diff] [blame] | 49 | ret = enable_fec_anatop_clock(1, ENET_50MHZ); |
| 50 | if (ret) |
| 51 | return ret; |
| 52 | } |
Oleh Kravchenko | 4a2c0da | 2021-05-15 00:18:31 +0300 | [diff] [blame] | 53 | |
| 54 | enable_enet_clk(1); |
| 55 | } |
| 56 | |
| 57 | return 0; |
| 58 | } |
| 59 | |
| 60 | int board_init(void) |
| 61 | { |
| 62 | /* Address of boot parameters */ |
| 63 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 64 | |
| 65 | return setup_fec_clock(); |
| 66 | } |
| 67 | |
| 68 | int board_late_init(void) |
| 69 | { |
| 70 | if (IS_ENABLED(CONFIG_CMD_BMODE)) |
| 71 | add_board_boot_modes(NULL); |
| 72 | |
| 73 | if (IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG)) { |
| 74 | const char *model; |
| 75 | |
| 76 | model = fdt_getprop(gd->fdt_blob, 0, "model", NULL); |
| 77 | if (model) |
| 78 | env_set("board_name", model); |
| 79 | } |
| 80 | |
| 81 | if (is_boot_from_usb()) { |
| 82 | env_set("bootcmd", "run bootcmd_mfg"); |
| 83 | env_set("bootdelay", "0"); |
| 84 | } |
| 85 | |
| 86 | return 0; |
| 87 | } |