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