xref: /rk3399_rockchip-uboot/scripts/dtc/libfdt/fdt.h (revision d18719a48ffdf6be4a0724f88d8968904df3a0d9)
1*d18719a4STom Rini #ifndef _FDT_H
2*d18719a4STom Rini #define _FDT_H
3*d18719a4STom Rini /*
4*d18719a4STom Rini  * libfdt - Flat Device Tree manipulation
5*d18719a4STom Rini  * Copyright (C) 2006 David Gibson, IBM Corporation.
6*d18719a4STom Rini  * Copyright 2012 Kim Phillips, Freescale Semiconductor.
7*d18719a4STom Rini  *
8*d18719a4STom Rini  * libfdt is dual licensed: you can use it either under the terms of
9*d18719a4STom Rini  * the GPL, or the BSD license, at your option.
10*d18719a4STom Rini  *
11*d18719a4STom Rini  *  a) This library is free software; you can redistribute it and/or
12*d18719a4STom Rini  *     modify it under the terms of the GNU General Public License as
13*d18719a4STom Rini  *     published by the Free Software Foundation; either version 2 of the
14*d18719a4STom Rini  *     License, or (at your option) any later version.
15*d18719a4STom Rini  *
16*d18719a4STom Rini  *     This library is distributed in the hope that it will be useful,
17*d18719a4STom Rini  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
18*d18719a4STom Rini  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19*d18719a4STom Rini  *     GNU General Public License for more details.
20*d18719a4STom Rini  *
21*d18719a4STom Rini  *     You should have received a copy of the GNU General Public
22*d18719a4STom Rini  *     License along with this library; if not, write to the Free
23*d18719a4STom Rini  *     Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
24*d18719a4STom Rini  *     MA 02110-1301 USA
25*d18719a4STom Rini  *
26*d18719a4STom Rini  * Alternatively,
27*d18719a4STom Rini  *
28*d18719a4STom Rini  *  b) Redistribution and use in source and binary forms, with or
29*d18719a4STom Rini  *     without modification, are permitted provided that the following
30*d18719a4STom Rini  *     conditions are met:
31*d18719a4STom Rini  *
32*d18719a4STom Rini  *     1. Redistributions of source code must retain the above
33*d18719a4STom Rini  *        copyright notice, this list of conditions and the following
34*d18719a4STom Rini  *        disclaimer.
35*d18719a4STom Rini  *     2. Redistributions in binary form must reproduce the above
36*d18719a4STom Rini  *        copyright notice, this list of conditions and the following
37*d18719a4STom Rini  *        disclaimer in the documentation and/or other materials
38*d18719a4STom Rini  *        provided with the distribution.
39*d18719a4STom Rini  *
40*d18719a4STom Rini  *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
41*d18719a4STom Rini  *     CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
42*d18719a4STom Rini  *     INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
43*d18719a4STom Rini  *     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
44*d18719a4STom Rini  *     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
45*d18719a4STom Rini  *     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46*d18719a4STom Rini  *     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47*d18719a4STom Rini  *     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48*d18719a4STom Rini  *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49*d18719a4STom Rini  *     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
50*d18719a4STom Rini  *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
51*d18719a4STom Rini  *     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
52*d18719a4STom Rini  *     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53*d18719a4STom Rini  */
54*d18719a4STom Rini 
55*d18719a4STom Rini #ifndef __ASSEMBLY__
56*d18719a4STom Rini 
57*d18719a4STom Rini struct fdt_header {
58*d18719a4STom Rini 	fdt32_t magic;			 /* magic word FDT_MAGIC */
59*d18719a4STom Rini 	fdt32_t totalsize;		 /* total size of DT block */
60*d18719a4STom Rini 	fdt32_t off_dt_struct;		 /* offset to structure */
61*d18719a4STom Rini 	fdt32_t off_dt_strings;		 /* offset to strings */
62*d18719a4STom Rini 	fdt32_t off_mem_rsvmap;		 /* offset to memory reserve map */
63*d18719a4STom Rini 	fdt32_t version;		 /* format version */
64*d18719a4STom Rini 	fdt32_t last_comp_version;	 /* last compatible version */
65*d18719a4STom Rini 
66*d18719a4STom Rini 	/* version 2 fields below */
67*d18719a4STom Rini 	fdt32_t boot_cpuid_phys;	 /* Which physical CPU id we're
68*d18719a4STom Rini 					    booting on */
69*d18719a4STom Rini 	/* version 3 fields below */
70*d18719a4STom Rini 	fdt32_t size_dt_strings;	 /* size of the strings block */
71*d18719a4STom Rini 
72*d18719a4STom Rini 	/* version 17 fields below */
73*d18719a4STom Rini 	fdt32_t size_dt_struct;		 /* size of the structure block */
74*d18719a4STom Rini };
75*d18719a4STom Rini 
76*d18719a4STom Rini struct fdt_reserve_entry {
77*d18719a4STom Rini 	fdt64_t address;
78*d18719a4STom Rini 	fdt64_t size;
79*d18719a4STom Rini };
80*d18719a4STom Rini 
81*d18719a4STom Rini struct fdt_node_header {
82*d18719a4STom Rini 	fdt32_t tag;
83*d18719a4STom Rini 	char name[0];
84*d18719a4STom Rini };
85*d18719a4STom Rini 
86*d18719a4STom Rini struct fdt_property {
87*d18719a4STom Rini 	fdt32_t tag;
88*d18719a4STom Rini 	fdt32_t len;
89*d18719a4STom Rini 	fdt32_t nameoff;
90*d18719a4STom Rini 	char data[0];
91*d18719a4STom Rini };
92*d18719a4STom Rini 
93*d18719a4STom Rini #endif /* !__ASSEMBLY */
94*d18719a4STom Rini 
95*d18719a4STom Rini #define FDT_MAGIC	0xd00dfeed	/* 4: version, 4: total size */
96*d18719a4STom Rini #define FDT_TAGSIZE	sizeof(fdt32_t)
97*d18719a4STom Rini 
98*d18719a4STom Rini #define FDT_BEGIN_NODE	0x1		/* Start node: full name */
99*d18719a4STom Rini #define FDT_END_NODE	0x2		/* End node */
100*d18719a4STom Rini #define FDT_PROP	0x3		/* Property: name off,
101*d18719a4STom Rini 					   size, content */
102*d18719a4STom Rini #define FDT_NOP		0x4		/* nop */
103*d18719a4STom Rini #define FDT_END		0x9
104*d18719a4STom Rini 
105*d18719a4STom Rini #define FDT_V1_SIZE	(7*sizeof(fdt32_t))
106*d18719a4STom Rini #define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(fdt32_t))
107*d18719a4STom Rini #define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(fdt32_t))
108*d18719a4STom Rini #define FDT_V16_SIZE	FDT_V3_SIZE
109*d18719a4STom Rini #define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(fdt32_t))
110*d18719a4STom Rini 
111*d18719a4STom Rini #endif /* _FDT_H */
112