blob: 17aafd719c9d444a23b63cc0f48e89a82320e72a [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
Marek Vasut0b16ba52022-04-12 17:26:01 +02006#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 Vasut78943112022-12-11 21:17:14 +010028#include "../common/common.h"
Marek Vasut0b16ba52022-04-12 17:26:01 +020029
Marek Vasut78943112022-12-11 21:17:14 +010030DECLARE_GLOBAL_DATA_PTR;
Marek Vasut0b16ba52022-04-12 17:26:01 +020031
Marek Vasut78943112022-12-11 21:17:14 +010032int data_modul_imx_edm_sbc_board_power_init(void)
Marek Vasut0b16ba52022-04-12 17:26:01 +020033{
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
60int 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
68void 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
83static 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 Vasut0b16ba52022-04-12 17:26:01 +020094void board_init_f(ulong dummy)
95{
Marek Vasut78943112022-12-11 21:17:14 +010096 dmo_board_init_f(IMX8MM_PAD_GPIO1_IO02_WDOG1_WDOG_B, dram_timing_info);
Marek Vasut0b16ba52022-04-12 17:26:01 +020097}