blob: 9075df01cac626f555a1920347283bc8af98a62a [file] [log] [blame]
Suman Anna3b431102022-05-25 13:38:47 +05301// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Board specific initialization for AM62x platforms
4 *
5 * Copyright (C) 2020-2022 Texas Instruments Incorporated - https://www.ti.com/
6 * Suman Anna <s-anna@ti.com>
7 *
8 */
9
Jonathan Humphreyse7aade52024-06-14 11:35:40 -050010#include <efi_loader.h>
Nikhil M Jain155a0822023-01-31 15:35:19 +053011#include <env.h>
Suman Anna3b431102022-05-25 13:38:47 +053012#include <spl.h>
Nikhil M Jain57a531b2023-04-10 14:19:12 +053013#include <init.h>
Nikhil M Jain155a0822023-01-31 15:35:19 +053014#include <video.h>
15#include <splash.h>
Nikhil M Jain3ad584b2023-06-21 16:29:52 +053016#include <cpu_func.h>
Georgi Vlaev18c0fbf2022-06-14 17:45:33 +030017#include <k3-ddrss.h>
Suman Anna3b431102022-05-25 13:38:47 +053018#include <fdt_support.h>
Devarsh Thakkar84085d22024-09-25 20:43:54 +053019#include <fdt_simplefb.h>
Nikhil M Jain155a0822023-01-31 15:35:19 +053020#include <asm/io.h>
Suman Anna3b431102022-05-25 13:38:47 +053021#include <asm/arch/hardware.h>
Nikhil M Jain155a0822023-01-31 15:35:19 +053022#include <dm/uclass.h>
Suman Anna3b431102022-05-25 13:38:47 +053023
Nishanth Menon6850daf2024-02-12 13:47:19 -060024#include "../common/fdt_ops.h"
25
Suman Anna3b431102022-05-25 13:38:47 +053026DECLARE_GLOBAL_DATA_PTR;
27
Nikhil M Jain1ff64a22023-04-20 17:41:11 +053028#if CONFIG_IS_ENABLED(SPLASH_SCREEN)
Nikhil M Jain155a0822023-01-31 15:35:19 +053029static struct splash_location default_splash_locations[] = {
30 {
Nikhil M Jain1ff64a22023-04-20 17:41:11 +053031 .name = "sf",
32 .storage = SPLASH_STORAGE_SF,
33 .flags = SPLASH_STORAGE_RAW,
34 .offset = 0x700000,
35 },
36 {
Nikhil M Jain155a0822023-01-31 15:35:19 +053037 .name = "mmc",
38 .storage = SPLASH_STORAGE_MMC,
39 .flags = SPLASH_STORAGE_FS,
40 .devpart = "1:1",
41 },
42};
43
44int splash_screen_prepare(void)
45{
46 return splash_source_load(default_splash_locations,
47 ARRAY_SIZE(default_splash_locations));
48}
49#endif
50
Jonathan Humphreyse7aade52024-06-14 11:35:40 -050051struct efi_fw_image fw_images[] = {
52 {
53 .image_type_id = AM62X_SK_TIBOOT3_IMAGE_GUID,
54 .fw_name = u"AM62X_SK_TIBOOT3",
55 .image_index = 1,
56 },
57 {
58 .image_type_id = AM62X_SK_SPL_IMAGE_GUID,
59 .fw_name = u"AM62X_SK_SPL",
60 .image_index = 2,
61 },
62 {
63 .image_type_id = AM62X_SK_UBOOT_IMAGE_GUID,
64 .fw_name = u"AM62X_SK_UBOOT",
65 .image_index = 3,
66 }
67};
68
69struct efi_capsule_update_info update_info = {
70 .dfu_string = "sf 0:0=tiboot3.bin raw 0 80000;"
71 "tispl.bin raw 80000 200000;u-boot.img raw 280000 400000",
72 .num_images = ARRAY_SIZE(fw_images),
73 .images = fw_images,
74};
75
76#if IS_ENABLED(CONFIG_SET_DFU_ALT_INFO)
77void set_dfu_alt_info(char *interface, char *devstr)
78{
79 if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT))
80 env_set("dfu_alt_info", update_info.dfu_string);
81}
82#endif
83
Suman Anna3b431102022-05-25 13:38:47 +053084int board_init(void)
85{
86 return 0;
87}
88
89int dram_init(void)
90{
Georgi Vlaev8a9ceb42022-06-14 17:45:32 +030091 return fdtdec_setup_mem_size_base();
Suman Anna3b431102022-05-25 13:38:47 +053092}
Nishanth Menon6850daf2024-02-12 13:47:19 -060093
94#ifdef CONFIG_BOARD_LATE_INIT
95int board_late_init(void)
96{
97 ti_set_fdt_env(NULL, NULL);
98 return 0;
99}
100#endif
Suman Anna3b431102022-05-25 13:38:47 +0530101
102int dram_init_banksize(void)
103{
Georgi Vlaev8a9ceb42022-06-14 17:45:32 +0300104 return fdtdec_setup_memory_banksize();
Suman Anna3b431102022-05-25 13:38:47 +0530105}
Georgi Vlaev18c0fbf2022-06-14 17:45:33 +0300106
Simon Glass49c24a82024-09-29 19:49:47 -0600107#if defined(CONFIG_XPL_BUILD)
Nikhil M Jain57a531b2023-04-10 14:19:12 +0530108
Nikhil M Jain57a531b2023-04-10 14:19:12 +0530109void spl_board_init(void)
110{
Nikhil M Jain57a531b2023-04-10 14:19:12 +0530111 enable_caches();
Nikhil M Jaindafda902023-07-18 14:27:29 +0530112 if (IS_ENABLED(CONFIG_SPL_SPLASH_SCREEN) && IS_ENABLED(CONFIG_SPL_BMP))
113 splash_display();
114
Nikhil M Jain57a531b2023-04-10 14:19:12 +0530115}
116
Georgi Vlaev18c0fbf2022-06-14 17:45:33 +0300117#if defined(CONFIG_K3_AM64_DDRSS)
118static void fixup_ddr_driver_for_ecc(struct spl_image_info *spl_image)
119{
120 struct udevice *dev;
121 int ret;
122
123 dram_init_banksize();
124
125 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
126 if (ret)
127 panic("Cannot get RAM device for ddr size fixup: %d\n", ret);
128
129 ret = k3_ddrss_ddr_fdt_fixup(dev, spl_image->fdt_addr, gd->bd);
130 if (ret)
131 printf("Error fixing up ddr node for ECC use! %d\n", ret);
132}
133#else
134static void fixup_memory_node(struct spl_image_info *spl_image)
135{
136 u64 start[CONFIG_NR_DRAM_BANKS];
137 u64 size[CONFIG_NR_DRAM_BANKS];
138 int bank;
139 int ret;
140
141 dram_init();
142 dram_init_banksize();
143
144 for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
145 start[bank] = gd->bd->bi_dram[bank].start;
146 size[bank] = gd->bd->bi_dram[bank].size;
147 }
148
149 /* dram_init functions use SPL fdt, and we must fixup u-boot fdt */
150 ret = fdt_fixup_memory_banks(spl_image->fdt_addr, start, size,
151 CONFIG_NR_DRAM_BANKS);
152 if (ret)
153 printf("Error fixing up memory node! %d\n", ret);
154}
155#endif
156
157void spl_perform_fixups(struct spl_image_info *spl_image)
158{
159#if defined(CONFIG_K3_AM64_DDRSS)
160 fixup_ddr_driver_for_ecc(spl_image);
161#else
162 fixup_memory_node(spl_image);
163#endif
164}
165#endif
Devarsh Thakkar84085d22024-09-25 20:43:54 +0530166
167#if defined(CONFIG_OF_BOARD_SETUP)
168int ft_board_setup(void *blob, struct bd_info *bd)
169{
170 int ret = -1;
171
172 if (IS_ENABLED(CONFIG_FDT_SIMPLEFB))
173 ret = fdt_simplefb_enable_and_mem_rsv(blob);
174
175 /* If simplefb is not enabled and video is active, then at least reserve
176 * the framebuffer region to preserve the splash screen while OS is booting
177 */
178 if (IS_ENABLED(CONFIG_VIDEO) && IS_ENABLED(CONFIG_OF_LIBFDT)) {
179 if (ret && video_is_active())
180 return fdt_add_fb_mem_rsv(blob);
181 }
182
183 return 0;
184}
185#endif