1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Library to support common device tree manipulation for TI EVMs
4  *
5  * Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com
6  */
7 
8 #ifndef __FDT_OPS_H
9 #define __FDT_OPS_H
10 
11 #define TI_BOARD_NAME_MAX 20
12 #define TI_FDT_FILE_MAX 200
13 
14 /**
15  *  struct ti_fdt_map - mapping of device tree blob name to board name
16  *  @board_name: board_name up to TI_BOARD_NAME_MAX long
17  *  @fdt_file_name: device tree blob name as described by kernel
18  */
19 struct ti_fdt_map {
20 	const char *board_name;
21 	char *fdt_file_name;
22 };
23 
24 /**
25  * ti_set_fdt_env  - Find the correct device tree file name based on the
26  * board name and set 'fdtfile' env variable with correct folder
27  * structure appropriate to the architecture and Linux kernel's
28  * 'make install_dtbs' conventions. This function is invoked typically
29  * as part of board_late_init.
30  *
31  * fdt name is picked by:
32  * a) If a board name match is found, use the match
33  * b) If not, CONFIG_DEFAULT_FDT_FILE (Boot OS device tree) if that is defined
34  *    and not null
35  * c) If not, Use CONFIG_DEFAULT_DEVICE_TREE (DT control for bootloader)
36  *
37  * @board_name: match to search with (max of TI_BOARD_NAME_MAX chars)
38  * @fdt_map: NULL terminated array of device tree file name matches.
39  */
40 void ti_set_fdt_env(const char *board_name, struct ti_fdt_map *fdt_map);
41 
42 #endif /* __FDT_OPS_H */
43