blob: 3134d78332d608b349b4dad3d9e0dbd76400e5cb [file] [log] [blame]
Gerald Van Baren7cd5da02007-03-31 11:59:59 -04001#ifndef _FDT_H
2#define _FDT_H
Justin Sobota1258f142013-02-15 11:06:10 -05003/*
4 * libfdt - Flat Device Tree manipulation
5 * Copyright (C) 2006 David Gibson, IBM Corporation.
6 * Copyright 2012 Kim Phillips, Freescale Semiconductor.
7 *
Simon Glassc40bfba2017-05-27 07:38:14 -06008 * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause
Justin Sobota1258f142013-02-15 11:06:10 -05009 */
Gerald Van Baren7cd5da02007-03-31 11:59:59 -040010
11#ifndef __ASSEMBLY__
12
13struct fdt_header {
Kim Phillips71bbb3d2013-01-16 13:59:43 +000014 fdt32_t magic; /* magic word FDT_MAGIC */
15 fdt32_t totalsize; /* total size of DT block */
16 fdt32_t off_dt_struct; /* offset to structure */
17 fdt32_t off_dt_strings; /* offset to strings */
18 fdt32_t off_mem_rsvmap; /* offset to memory reserve map */
19 fdt32_t version; /* format version */
20 fdt32_t last_comp_version; /* last compatible version */
Gerald Van Baren7cd5da02007-03-31 11:59:59 -040021
Wolfgang Denka5f601f2007-11-26 19:18:21 +010022 /* version 2 fields below */
Kim Phillips71bbb3d2013-01-16 13:59:43 +000023 fdt32_t boot_cpuid_phys; /* Which physical CPU id we're
Gerald Van Baren7cd5da02007-03-31 11:59:59 -040024 booting on */
25 /* version 3 fields below */
Kim Phillips71bbb3d2013-01-16 13:59:43 +000026 fdt32_t size_dt_strings; /* size of the strings block */
Gerald Van Baren7cd5da02007-03-31 11:59:59 -040027
28 /* version 17 fields below */
Kim Phillips71bbb3d2013-01-16 13:59:43 +000029 fdt32_t size_dt_struct; /* size of the structure block */
Gerald Van Baren7cd5da02007-03-31 11:59:59 -040030};
31
32struct fdt_reserve_entry {
Kim Phillips71bbb3d2013-01-16 13:59:43 +000033 fdt64_t address;
34 fdt64_t size;
Gerald Van Baren7cd5da02007-03-31 11:59:59 -040035};
36
37struct fdt_node_header {
Kim Phillips71bbb3d2013-01-16 13:59:43 +000038 fdt32_t tag;
Gerald Van Baren7cd5da02007-03-31 11:59:59 -040039 char name[0];
40};
41
42struct fdt_property {
Kim Phillips71bbb3d2013-01-16 13:59:43 +000043 fdt32_t tag;
44 fdt32_t len;
45 fdt32_t nameoff;
Gerald Van Baren7cd5da02007-03-31 11:59:59 -040046 char data[0];
47};
48
49#endif /* !__ASSEMBLY */
50
Wolfgang Denka5f601f2007-11-26 19:18:21 +010051#define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */
Kim Phillips71bbb3d2013-01-16 13:59:43 +000052#define FDT_TAGSIZE sizeof(fdt32_t)
Gerald Van Baren7cd5da02007-03-31 11:59:59 -040053
Wolfgang Denka5f601f2007-11-26 19:18:21 +010054#define FDT_BEGIN_NODE 0x1 /* Start node: full name */
55#define FDT_END_NODE 0x2 /* End node */
56#define FDT_PROP 0x3 /* Property: name off,
Gerald Van Baren7cd5da02007-03-31 11:59:59 -040057 size, content */
58#define FDT_NOP 0x4 /* nop */
59#define FDT_END 0x9
60
Kim Phillips71bbb3d2013-01-16 13:59:43 +000061#define FDT_V1_SIZE (7*sizeof(fdt32_t))
62#define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(fdt32_t))
63#define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(fdt32_t))
Gerald Van Baren7cd5da02007-03-31 11:59:59 -040064#define FDT_V16_SIZE FDT_V3_SIZE
Kim Phillips71bbb3d2013-01-16 13:59:43 +000065#define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t))
Gerald Van Baren7cd5da02007-03-31 11:59:59 -040066
Gerald Van Baren7cd5da02007-03-31 11:59:59 -040067#endif /* _FDT_H */