1204431Sraj#ifndef _FDT_H
2204431Sraj#define _FDT_H
3266130Sian/*
4266130Sian * libfdt - Flat Device Tree manipulation
5266130Sian * Copyright (C) 2006 David Gibson, IBM Corporation.
6266130Sian * Copyright 2012 Kim Phillips, Freescale Semiconductor.
7266130Sian *
8266130Sian * libfdt is dual licensed: you can use it either under the terms of
9266130Sian * the GPL, or the BSD license, at your option.
10266130Sian *
11266130Sian *  a) This library is free software; you can redistribute it and/or
12266130Sian *     modify it under the terms of the GNU General Public License as
13266130Sian *     published by the Free Software Foundation; either version 2 of the
14266130Sian *     License, or (at your option) any later version.
15266130Sian *
16266130Sian *     This library is distributed in the hope that it will be useful,
17266130Sian *     but WITHOUT ANY WARRANTY; without even the implied warranty of
18266130Sian *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19266130Sian *     GNU General Public License for more details.
20266130Sian *
21266130Sian *     You should have received a copy of the GNU General Public
22266130Sian *     License along with this library; if not, write to the Free
23266130Sian *     Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
24266130Sian *     MA 02110-1301 USA
25266130Sian *
26266130Sian * Alternatively,
27266130Sian *
28266130Sian *  b) Redistribution and use in source and binary forms, with or
29266130Sian *     without modification, are permitted provided that the following
30266130Sian *     conditions are met:
31266130Sian *
32266130Sian *     1. Redistributions of source code must retain the above
33266130Sian *        copyright notice, this list of conditions and the following
34266130Sian *        disclaimer.
35266130Sian *     2. Redistributions in binary form must reproduce the above
36266130Sian *        copyright notice, this list of conditions and the following
37266130Sian *        disclaimer in the documentation and/or other materials
38266130Sian *        provided with the distribution.
39266130Sian *
40266130Sian *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
41266130Sian *     CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
42266130Sian *     INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
43266130Sian *     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
44266130Sian *     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
45266130Sian *     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46266130Sian *     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47266130Sian *     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48266130Sian *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49266130Sian *     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
50266130Sian *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
51266130Sian *     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
52266130Sian *     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53266130Sian */
54204431Sraj
55204431Sraj#ifndef __ASSEMBLY__
56204431Sraj
57204431Srajstruct fdt_header {
58266130Sian	fdt32_t magic;			 /* magic word FDT_MAGIC */
59266130Sian	fdt32_t totalsize;		 /* total size of DT block */
60266130Sian	fdt32_t off_dt_struct;		 /* offset to structure */
61266130Sian	fdt32_t off_dt_strings;		 /* offset to strings */
62266130Sian	fdt32_t off_mem_rsvmap;		 /* offset to memory reserve map */
63266130Sian	fdt32_t version;		 /* format version */
64266130Sian	fdt32_t last_comp_version;	 /* last compatible version */
65204431Sraj
66204431Sraj	/* version 2 fields below */
67266130Sian	fdt32_t boot_cpuid_phys;	 /* Which physical CPU id we're
68204431Sraj					    booting on */
69204431Sraj	/* version 3 fields below */
70266130Sian	fdt32_t size_dt_strings;	 /* size of the strings block */
71204431Sraj
72204431Sraj	/* version 17 fields below */
73266130Sian	fdt32_t size_dt_struct;		 /* size of the structure block */
74204431Sraj};
75204431Sraj
76204431Srajstruct fdt_reserve_entry {
77266130Sian	fdt64_t address;
78266130Sian	fdt64_t size;
79204431Sraj};
80204431Sraj
81204431Srajstruct fdt_node_header {
82266130Sian	fdt32_t tag;
83204431Sraj	char name[0];
84204431Sraj};
85204431Sraj
86204431Srajstruct fdt_property {
87266130Sian	fdt32_t tag;
88266130Sian	fdt32_t len;
89266130Sian	fdt32_t nameoff;
90204431Sraj	char data[0];
91204431Sraj};
92204431Sraj
93204431Sraj#endif /* !__ASSEMBLY */
94204431Sraj
95204431Sraj#define FDT_MAGIC	0xd00dfeed	/* 4: version, 4: total size */
96266130Sian#define FDT_TAGSIZE	sizeof(fdt32_t)
97204431Sraj
98204431Sraj#define FDT_BEGIN_NODE	0x1		/* Start node: full name */
99204431Sraj#define FDT_END_NODE	0x2		/* End node */
100204431Sraj#define FDT_PROP	0x3		/* Property: name off,
101204431Sraj					   size, content */
102204431Sraj#define FDT_NOP		0x4		/* nop */
103204431Sraj#define FDT_END		0x9
104204431Sraj
105266130Sian#define FDT_V1_SIZE	(7*sizeof(fdt32_t))
106266130Sian#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(fdt32_t))
107266130Sian#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(fdt32_t))
108204431Sraj#define FDT_V16_SIZE	FDT_V3_SIZE
109266130Sian#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(fdt32_t))
110204431Sraj
111204431Sraj#endif /* _FDT_H */
112