Marek Vasut | 0b16ba5 | 2022-04-12 17:26:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright 2022 Marek Vasut <marex@denx.de> |
| 4 | */ |
| 5 | |
Marek Vasut | 0b16ba5 | 2022-04-12 17:26:01 +0200 | [diff] [blame] | 6 | #include <hang.h> |
| 7 | #include <image.h> |
| 8 | #include <init.h> |
| 9 | #include <spl.h> |
| 10 | #include <asm/io.h> |
| 11 | #include <asm-generic/gpio.h> |
| 12 | #include <asm/arch/clock.h> |
| 13 | #include <asm/arch/imx8mm_pins.h> |
| 14 | #include <asm/arch/sys_proto.h> |
| 15 | #include <asm/arch/ddr.h> |
| 16 | #include <asm/mach-imx/boot_mode.h> |
| 17 | |
| 18 | #include <dm/uclass.h> |
| 19 | #include <dm/device.h> |
| 20 | #include <dm/uclass-internal.h> |
| 21 | #include <dm/device-internal.h> |
| 22 | |
| 23 | #include <power/pmic.h> |
| 24 | #include <power/bd71837.h> |
| 25 | |
| 26 | #include "lpddr4_timing.h" |
| 27 | |
Marek Vasut | 7894311 | 2022-12-11 21:17:14 +0100 | [diff] [blame] | 28 | #include "../common/common.h" |
Marek Vasut | 0b16ba5 | 2022-04-12 17:26:01 +0200 | [diff] [blame] | 29 | |
Marek Vasut | 7894311 | 2022-12-11 21:17:14 +0100 | [diff] [blame] | 30 | DECLARE_GLOBAL_DATA_PTR; |
Marek Vasut | 0b16ba5 | 2022-04-12 17:26:01 +0200 | [diff] [blame] | 31 | |
Marek Vasut | 7894311 | 2022-12-11 21:17:14 +0100 | [diff] [blame] | 32 | int data_modul_imx_edm_sbc_board_power_init(void) |
Marek Vasut | 0b16ba5 | 2022-04-12 17:26:01 +0200 | [diff] [blame] | 33 | { |
| 34 | struct udevice *dev; |
| 35 | int ret; |
| 36 | |
| 37 | ret = pmic_get("pmic@4b", &dev); |
| 38 | if (ret == -ENODEV) { |
| 39 | puts("Failed to get PMIC\n"); |
| 40 | return 0; |
| 41 | } |
| 42 | if (ret != 0) |
| 43 | return ret; |
| 44 | |
| 45 | /* Unlock the PMIC regs */ |
| 46 | pmic_reg_write(dev, BD718XX_REGLOCK, 0x1); |
| 47 | |
| 48 | /* Increase VDD_SOC to typical value 0.85V before first DRAM access */ |
| 49 | pmic_reg_write(dev, BD718XX_BUCK1_VOLT_RUN, 0x0f); |
| 50 | |
| 51 | /* Increase VDD_DRAM to 0.975V for 3GHz DDR */ |
| 52 | pmic_reg_write(dev, BD718XX_1ST_NODVS_BUCK_VOLT, 0x83); |
| 53 | |
| 54 | /* Lock the PMIC regs */ |
| 55 | pmic_reg_write(dev, BD718XX_REGLOCK, 0x11); |
| 56 | |
| 57 | return 0; |
| 58 | } |
| 59 | |
| 60 | int spl_board_boot_device(enum boot_device boot_dev_spl) |
| 61 | { |
| 62 | if (boot_dev_spl == MMC3_BOOT) |
| 63 | return BOOT_DEVICE_MMC2; /* eMMC */ |
| 64 | else |
| 65 | return BOOT_DEVICE_MMC1; /* SD */ |
| 66 | } |
| 67 | |
| 68 | void board_boot_order(u32 *spl_boot_list) |
| 69 | { |
| 70 | int boot_device = spl_boot_device(); |
| 71 | |
| 72 | spl_boot_list[0] = boot_device; /* 1:SD 2:eMMC */ |
| 73 | |
| 74 | if (boot_device == BOOT_DEVICE_MMC1) |
| 75 | spl_boot_list[1] = BOOT_DEVICE_MMC2; /* eMMC */ |
| 76 | else |
| 77 | spl_boot_list[1] = BOOT_DEVICE_MMC1; /* SD */ |
| 78 | |
| 79 | spl_boot_list[2] = BOOT_DEVICE_UART; /* YModem */ |
| 80 | spl_boot_list[3] = BOOT_DEVICE_NONE; |
| 81 | } |
| 82 | |
| 83 | static struct dram_timing_info *dram_timing_info[8] = { |
| 84 | &dmo_imx8mm_sbc_dram_timing_32_32, /* 32 Gbit x32 */ |
| 85 | NULL, /* 32 Gbit x16 */ |
| 86 | &dmo_imx8mm_sbc_dram_timing_16_32, /* 16 Gbit x32 */ |
| 87 | NULL, /* 16 Gbit x16 */ |
| 88 | NULL, /* 8 Gbit x32 */ |
| 89 | NULL, /* 8 Gbit x16 */ |
| 90 | NULL, /* INVALID */ |
| 91 | NULL, /* INVALID */ |
| 92 | }; |
| 93 | |
Marek Vasut | 0b16ba5 | 2022-04-12 17:26:01 +0200 | [diff] [blame] | 94 | void board_init_f(ulong dummy) |
| 95 | { |
Marek Vasut | 7894311 | 2022-12-11 21:17:14 +0100 | [diff] [blame] | 96 | dmo_board_init_f(IMX8MM_PAD_GPIO1_IO02_WDOG1_WDOG_B, dram_timing_info); |
Marek Vasut | 0b16ba5 | 2022-04-12 17:26:01 +0200 | [diff] [blame] | 97 | } |