]>
Commit | Line | Data |
---|---|---|
14d5aeff IO |
1 | // SPDX-License-Identifier: GPL-2.0+ |
2 | /* | |
3 | * Copyright 2020 Toradex | |
4 | */ | |
5 | ||
09140113 | 6 | #include <command.h> |
4d72caa5 | 7 | #include <image.h> |
691d719d | 8 | #include <init.h> |
f7ae49fc | 9 | #include <log.h> |
14d5aeff IO |
10 | #include <asm/arch/clock.h> |
11 | #include <asm/arch/ddr.h> | |
12 | #include <asm/arch/imx8mm_pins.h> | |
13 | #include <asm/arch/sys_proto.h> | |
401d1c4f | 14 | #include <asm/global_data.h> |
14d5aeff IO |
15 | #include <asm/io.h> |
16 | #include <asm/mach-imx/boot_mode.h> | |
17 | #include <asm/mach-imx/iomux-v3.h> | |
506df9dc | 18 | #include <asm/sections.h> |
14d5aeff IO |
19 | #include <cpu_func.h> |
20 | #include <dm/device.h> | |
21 | #include <dm/device-internal.h> | |
22 | #include <dm/uclass.h> | |
23 | #include <dm/uclass-internal.h> | |
24 | #include <hang.h> | |
7d43807d | 25 | #include <i2c.h> |
7d43807d | 26 | #include <power/pca9450.h> |
14d5aeff IO |
27 | #include <power/pmic.h> |
28 | #include <spl.h> | |
29 | ||
30 | DECLARE_GLOBAL_DATA_PTR; | |
31 | ||
7d43807d MK |
32 | #define I2C_PMIC_BUS_ID 1 |
33 | ||
14d5aeff IO |
34 | int spl_board_boot_device(enum boot_device boot_dev_spl) |
35 | { | |
36 | switch (boot_dev_spl) { | |
cc34e9cb | 37 | case MMC1_BOOT: /* eMMC */ |
14d5aeff | 38 | return BOOT_DEVICE_MMC1; |
cc34e9cb | 39 | case SD2_BOOT: /* SD card */ |
14d5aeff IO |
40 | case MMC2_BOOT: |
41 | return BOOT_DEVICE_MMC2; | |
14d5aeff IO |
42 | case USB_BOOT: |
43 | return BOOT_DEVICE_BOARD; | |
44 | default: | |
45 | return BOOT_DEVICE_NONE; | |
46 | } | |
47 | } | |
48 | ||
49 | void spl_dram_init(void) | |
50 | { | |
51 | ddr_init(&dram_timing); | |
52 | } | |
53 | ||
54 | void spl_board_init(void) | |
55 | { | |
1f908b18 | 56 | arch_misc_init(); |
14d5aeff IO |
57 | } |
58 | ||
59 | #ifdef CONFIG_SPL_LOAD_FIT | |
60 | int board_fit_config_name_match(const char *name) | |
61 | { | |
62 | /* Just empty function now - can't decide what to choose */ | |
63 | debug("%s: %s\n", __func__, name); | |
64 | ||
65 | return 0; | |
66 | } | |
67 | #endif | |
68 | ||
34694f1a | 69 | __weak void board_early_init(void) |
14d5aeff | 70 | { |
34694f1a | 71 | init_uart_clk(0); |
14d5aeff IO |
72 | } |
73 | ||
74 | int power_init_board(void) | |
75 | { | |
76 | struct udevice *dev; | |
77 | int ret; | |
78 | ||
7d43807d | 79 | if (IS_ENABLED(CONFIG_SPL_DM_PMIC_PCA9450)) { |
a68bad0a | 80 | ret = pmic_get("pmic@25", &dev); |
7d43807d MK |
81 | if (ret == -ENODEV) { |
82 | puts("No pmic found\n"); | |
83 | return ret; | |
84 | } | |
14d5aeff | 85 | |
7d43807d MK |
86 | if (ret != 0) |
87 | return ret; | |
14d5aeff | 88 | |
7d43807d MK |
89 | /* BUCKxOUT_DVS0/1 control BUCK123 output, clear PRESET_EN */ |
90 | pmic_reg_write(dev, PCA9450_BUCK123_DVS, 0x29); | |
14d5aeff | 91 | |
7d43807d MK |
92 | /* increase VDD_DRAM to 0.975v for 1.5Ghz DDR */ |
93 | pmic_reg_write(dev, PCA9450_BUCK3OUT_DVS0, 0x1c); | |
14d5aeff | 94 | |
b8eecbac MK |
95 | pmic_reg_write(dev, PCA9450_CONFIG2, 0x1); |
96 | ||
7d43807d MK |
97 | return 0; |
98 | } | |
14d5aeff IO |
99 | |
100 | return 0; | |
101 | } | |
102 | ||
103 | void board_init_f(ulong dummy) | |
104 | { | |
105 | struct udevice *dev; | |
106 | int ret; | |
107 | ||
108 | arch_cpu_init(); | |
109 | ||
34694f1a | 110 | board_early_init(); |
14d5aeff IO |
111 | |
112 | timer_init(); | |
113 | ||
14d5aeff IO |
114 | /* Clear the BSS. */ |
115 | memset(__bss_start, 0, __bss_end - __bss_start); | |
116 | ||
117 | ret = spl_early_init(); | |
118 | if (ret) { | |
119 | debug("spl_early_init() failed: %d\n", ret); | |
120 | hang(); | |
121 | } | |
122 | ||
123 | ret = uclass_get_device_by_name(UCLASS_CLK, | |
124 | "clock-controller@30380000", | |
125 | &dev); | |
126 | if (ret < 0) { | |
127 | printf("Failed to find clock node. Check device tree\n"); | |
128 | hang(); | |
129 | } | |
130 | ||
c898b537 MZ |
131 | preloader_console_init(); |
132 | ||
14d5aeff IO |
133 | enable_tzc380(); |
134 | ||
135 | power_init_board(); | |
136 | ||
137 | /* DDR initialization */ | |
138 | spl_dram_init(); | |
139 | ||
140 | board_init_r(NULL, 0); | |
141 | } |