1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Board specific initialization for J784S4 EVM
4  *
5  * Copyright (C) 2023-2024 Texas Instruments Incorporated - https://www.ti.com/
6  *	Hari Nagalla <hnagalla@ti.com>
7  *
8  */
9 
10 #include <dm.h>
11 #include <efi_loader.h>
12 #include <init.h>
13 #include <spl.h>
14 #include <asm/arch/k3-ddr.h>
15 #include "../common/fdt_ops.h"
16 
17 DECLARE_GLOBAL_DATA_PTR;
18 
19 struct efi_fw_image fw_images[] = {
20 	{
21 		.image_type_id = AM69_SK_TIBOOT3_IMAGE_GUID,
22 		.fw_name = u"AM69_SK_TIBOOT3",
23 		.image_index = 1,
24 	},
25 	{
26 		.image_type_id = AM69_SK_SPL_IMAGE_GUID,
27 		.fw_name = u"AM69_SK_SPL",
28 		.image_index = 2,
29 	},
30 	{
31 		.image_type_id = AM69_SK_UBOOT_IMAGE_GUID,
32 		.fw_name = u"AM69_SK_UBOOT",
33 		.image_index = 3,
34 	}
35 };
36 
37 struct efi_capsule_update_info update_info = {
38 	.dfu_string = "sf 0:0=tiboot3.bin raw 0 80000;"
39 	"tispl.bin raw 80000 200000;u-boot.img raw 280000 400000",
40 	.num_images = ARRAY_SIZE(fw_images),
41 	.images = fw_images,
42 };
43 
44 #if defined(CONFIG_XPL_BUILD)
spl_perform_fixups(struct spl_image_info * spl_image)45 void spl_perform_fixups(struct spl_image_info *spl_image)
46 {
47 	if (IS_ENABLED(CONFIG_K3_DDRSS)) {
48 		if (IS_ENABLED(CONFIG_K3_INLINE_ECC))
49 			fixup_ddr_driver_for_ecc(spl_image);
50 	} else {
51 		fixup_memory_node(spl_image);
52 	}
53 }
54 #endif
55 
56 #ifdef CONFIG_BOARD_LATE_INIT
board_late_init(void)57 int board_late_init(void)
58 {
59 	ti_set_fdt_env(NULL, NULL);
60 	return 0;
61 }
62 #endif
63 
spl_board_init(void)64 void spl_board_init(void)
65 {
66 	struct udevice *dev;
67 	int ret;
68 
69 	if (IS_ENABLED(CONFIG_ESM_K3)) {
70 		const char * const esms[] = {"esm@700000", "esm@40800000", "esm@42080000"};
71 
72 		for (int i = 0; i < ARRAY_SIZE(esms); ++i) {
73 			ret = uclass_get_device_by_name(UCLASS_MISC, esms[i],
74 							&dev);
75 			if (ret) {
76 				printf("MISC init for %s failed: %d\n", esms[i], ret);
77 				break;
78 			}
79 		}
80 	}
81 
82 	if (IS_ENABLED(CONFIG_ESM_PMIC) && ret == 0) {
83 		ret = uclass_get_device_by_driver(UCLASS_MISC,
84 						  DM_DRIVER_GET(pmic_esm),
85 						  &dev);
86 		if (ret)
87 			printf("ESM PMIC init failed: %d\n", ret);
88 	}
89 }
90