blob: 9bdd0223cdb63e3d9c893b1580a0951eedba0009 [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>
Nikhil M Jain155a0822023-01-31 15:35:19 +053019#include <asm/io.h>
Suman Anna3b431102022-05-25 13:38:47 +053020#include <asm/arch/hardware.h>
Nikhil M Jain155a0822023-01-31 15:35:19 +053021#include <dm/uclass.h>
Suman Anna3b431102022-05-25 13:38:47 +053022
Nishanth Menon6850daf2024-02-12 13:47:19 -060023#include "../common/fdt_ops.h"
24
Suman Anna3b431102022-05-25 13:38:47 +053025DECLARE_GLOBAL_DATA_PTR;
26
Nikhil M Jain1ff64a22023-04-20 17:41:11 +053027#if CONFIG_IS_ENABLED(SPLASH_SCREEN)
Nikhil M Jain155a0822023-01-31 15:35:19 +053028static struct splash_location default_splash_locations[] = {
29 {
Nikhil M Jain1ff64a22023-04-20 17:41:11 +053030 .name = "sf",
31 .storage = SPLASH_STORAGE_SF,
32 .flags = SPLASH_STORAGE_RAW,
33 .offset = 0x700000,
34 },
35 {
Nikhil M Jain155a0822023-01-31 15:35:19 +053036 .name = "mmc",
37 .storage = SPLASH_STORAGE_MMC,
38 .flags = SPLASH_STORAGE_FS,
39 .devpart = "1:1",
40 },
41};
42
43int splash_screen_prepare(void)
44{
45 return splash_source_load(default_splash_locations,
46 ARRAY_SIZE(default_splash_locations));
47}
48#endif
49
Jonathan Humphreyse7aade52024-06-14 11:35:40 -050050struct efi_fw_image fw_images[] = {
51 {
52 .image_type_id = AM62X_SK_TIBOOT3_IMAGE_GUID,
53 .fw_name = u"AM62X_SK_TIBOOT3",
54 .image_index = 1,
55 },
56 {
57 .image_type_id = AM62X_SK_SPL_IMAGE_GUID,
58 .fw_name = u"AM62X_SK_SPL",
59 .image_index = 2,
60 },
61 {
62 .image_type_id = AM62X_SK_UBOOT_IMAGE_GUID,
63 .fw_name = u"AM62X_SK_UBOOT",
64 .image_index = 3,
65 }
66};
67
68struct efi_capsule_update_info update_info = {
69 .dfu_string = "sf 0:0=tiboot3.bin raw 0 80000;"
70 "tispl.bin raw 80000 200000;u-boot.img raw 280000 400000",
71 .num_images = ARRAY_SIZE(fw_images),
72 .images = fw_images,
73};
74
75#if IS_ENABLED(CONFIG_SET_DFU_ALT_INFO)
76void set_dfu_alt_info(char *interface, char *devstr)
77{
78 if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT))
79 env_set("dfu_alt_info", update_info.dfu_string);
80}
81#endif
82
Suman Anna3b431102022-05-25 13:38:47 +053083int board_init(void)
84{
85 return 0;
86}
87
88int dram_init(void)
89{
Georgi Vlaev8a9ceb42022-06-14 17:45:32 +030090 return fdtdec_setup_mem_size_base();
Suman Anna3b431102022-05-25 13:38:47 +053091}
Nishanth Menon6850daf2024-02-12 13:47:19 -060092
93#ifdef CONFIG_BOARD_LATE_INIT
94int board_late_init(void)
95{
96 ti_set_fdt_env(NULL, NULL);
97 return 0;
98}
99#endif
Suman Anna3b431102022-05-25 13:38:47 +0530100
101int dram_init_banksize(void)
102{
Georgi Vlaev8a9ceb42022-06-14 17:45:32 +0300103 return fdtdec_setup_memory_banksize();
Suman Anna3b431102022-05-25 13:38:47 +0530104}
Georgi Vlaev18c0fbf2022-06-14 17:45:33 +0300105
106#if defined(CONFIG_SPL_BUILD)
Nikhil M Jain57a531b2023-04-10 14:19:12 +0530107
Nikhil M Jain57a531b2023-04-10 14:19:12 +0530108void spl_board_init(void)
109{
Nikhil M Jain57a531b2023-04-10 14:19:12 +0530110 enable_caches();
Nikhil M Jaindafda902023-07-18 14:27:29 +0530111 if (IS_ENABLED(CONFIG_SPL_SPLASH_SCREEN) && IS_ENABLED(CONFIG_SPL_BMP))
112 splash_display();
113
Nikhil M Jain57a531b2023-04-10 14:19:12 +0530114}
115
Georgi Vlaev18c0fbf2022-06-14 17:45:33 +0300116#if defined(CONFIG_K3_AM64_DDRSS)
117static void fixup_ddr_driver_for_ecc(struct spl_image_info *spl_image)
118{
119 struct udevice *dev;
120 int ret;
121
122 dram_init_banksize();
123
124 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
125 if (ret)
126 panic("Cannot get RAM device for ddr size fixup: %d\n", ret);
127
128 ret = k3_ddrss_ddr_fdt_fixup(dev, spl_image->fdt_addr, gd->bd);
129 if (ret)
130 printf("Error fixing up ddr node for ECC use! %d\n", ret);
131}
132#else
133static void fixup_memory_node(struct spl_image_info *spl_image)
134{
135 u64 start[CONFIG_NR_DRAM_BANKS];
136 u64 size[CONFIG_NR_DRAM_BANKS];
137 int bank;
138 int ret;
139
140 dram_init();
141 dram_init_banksize();
142
143 for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
144 start[bank] = gd->bd->bi_dram[bank].start;
145 size[bank] = gd->bd->bi_dram[bank].size;
146 }
147
148 /* dram_init functions use SPL fdt, and we must fixup u-boot fdt */
149 ret = fdt_fixup_memory_banks(spl_image->fdt_addr, start, size,
150 CONFIG_NR_DRAM_BANKS);
151 if (ret)
152 printf("Error fixing up memory node! %d\n", ret);
153}
154#endif
155
156void spl_perform_fixups(struct spl_image_info *spl_image)
157{
158#if defined(CONFIG_K3_AM64_DDRSS)
159 fixup_ddr_driver_for_ecc(spl_image);
160#else
161 fixup_memory_node(spl_image);
162#endif
163}
164#endif