1*3e6106c4SLoGin /* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */ 2*3e6106c4SLoGin #ifndef FDT_H 3*3e6106c4SLoGin #define FDT_H 4*3e6106c4SLoGin /* 5*3e6106c4SLoGin * libfdt - Flat Device Tree manipulation 6*3e6106c4SLoGin * Copyright (C) 2006 David Gibson, IBM Corporation. 7*3e6106c4SLoGin * Copyright 2012 Kim Phillips, Freescale Semiconductor. 8*3e6106c4SLoGin */ 9*3e6106c4SLoGin #include "libfdt_env.h" 10*3e6106c4SLoGin #ifndef __ASSEMBLY__ 11*3e6106c4SLoGin 12*3e6106c4SLoGin struct fdt_header { 13*3e6106c4SLoGin fdt32_t magic; /* magic word FDT_MAGIC */ 14*3e6106c4SLoGin fdt32_t totalsize; /* total size of DT block */ 15*3e6106c4SLoGin fdt32_t off_dt_struct; /* offset to structure */ 16*3e6106c4SLoGin fdt32_t off_dt_strings; /* offset to strings */ 17*3e6106c4SLoGin fdt32_t off_mem_rsvmap; /* offset to memory reserve map */ 18*3e6106c4SLoGin fdt32_t version; /* format version */ 19*3e6106c4SLoGin fdt32_t last_comp_version; /* last compatible version */ 20*3e6106c4SLoGin 21*3e6106c4SLoGin /* version 2 fields below */ 22*3e6106c4SLoGin fdt32_t boot_cpuid_phys; /* Which physical CPU id we're 23*3e6106c4SLoGin booting on */ 24*3e6106c4SLoGin /* version 3 fields below */ 25*3e6106c4SLoGin fdt32_t size_dt_strings; /* size of the strings block */ 26*3e6106c4SLoGin 27*3e6106c4SLoGin /* version 17 fields below */ 28*3e6106c4SLoGin fdt32_t size_dt_struct; /* size of the structure block */ 29*3e6106c4SLoGin }; 30*3e6106c4SLoGin 31*3e6106c4SLoGin struct fdt_reserve_entry { 32*3e6106c4SLoGin fdt64_t address; 33*3e6106c4SLoGin fdt64_t size; 34*3e6106c4SLoGin }; 35*3e6106c4SLoGin 36*3e6106c4SLoGin struct fdt_node_header { 37*3e6106c4SLoGin fdt32_t tag; 38*3e6106c4SLoGin char name[]; 39*3e6106c4SLoGin }; 40*3e6106c4SLoGin 41*3e6106c4SLoGin struct fdt_property { 42*3e6106c4SLoGin fdt32_t tag; 43*3e6106c4SLoGin fdt32_t len; 44*3e6106c4SLoGin fdt32_t nameoff; 45*3e6106c4SLoGin char data[]; 46*3e6106c4SLoGin }; 47*3e6106c4SLoGin 48*3e6106c4SLoGin #endif /* !__ASSEMBLY */ 49*3e6106c4SLoGin 50*3e6106c4SLoGin #define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */ 51*3e6106c4SLoGin #define FDT_TAGSIZE sizeof(fdt32_t) 52*3e6106c4SLoGin 53*3e6106c4SLoGin #define FDT_BEGIN_NODE 0x1 /* Start node: full name */ 54*3e6106c4SLoGin #define FDT_END_NODE 0x2 /* End node */ 55*3e6106c4SLoGin #define FDT_PROP 0x3 /* Property: name off, 56*3e6106c4SLoGin size, content */ 57*3e6106c4SLoGin #define FDT_NOP 0x4 /* nop */ 58*3e6106c4SLoGin #define FDT_END 0x9 59*3e6106c4SLoGin 60*3e6106c4SLoGin #define FDT_V1_SIZE (7*sizeof(fdt32_t)) 61*3e6106c4SLoGin #define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(fdt32_t)) 62*3e6106c4SLoGin #define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(fdt32_t)) 63*3e6106c4SLoGin #define FDT_V16_SIZE FDT_V3_SIZE 64*3e6106c4SLoGin #define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t)) 65*3e6106c4SLoGin 66*3e6106c4SLoGin #endif /* FDT_H */ 67