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