Gerald Van Baren | 7cd5da0 | 2007-03-31 11:59:59 -0400 | [diff] [blame] | 1 | #ifndef _FDT_H |
| 2 | #define _FDT_H |
Justin Sobota | 1258f14 | 2013-02-15 11:06:10 -0500 | [diff] [blame] | 3 | /* |
| 4 | * libfdt - Flat Device Tree manipulation |
| 5 | * Copyright (C) 2006 David Gibson, IBM Corporation. |
| 6 | * Copyright 2012 Kim Phillips, Freescale Semiconductor. |
| 7 | * |
Simon Glass | c40bfba | 2017-05-27 07:38:14 -0600 | [diff] [blame^] | 8 | * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause |
Justin Sobota | 1258f14 | 2013-02-15 11:06:10 -0500 | [diff] [blame] | 9 | */ |
Gerald Van Baren | 7cd5da0 | 2007-03-31 11:59:59 -0400 | [diff] [blame] | 10 | |
| 11 | #ifndef __ASSEMBLY__ |
| 12 | |
| 13 | struct fdt_header { |
Kim Phillips | 71bbb3d | 2013-01-16 13:59:43 +0000 | [diff] [blame] | 14 | 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 Baren | 7cd5da0 | 2007-03-31 11:59:59 -0400 | [diff] [blame] | 21 | |
Wolfgang Denk | a5f601f | 2007-11-26 19:18:21 +0100 | [diff] [blame] | 22 | /* version 2 fields below */ |
Kim Phillips | 71bbb3d | 2013-01-16 13:59:43 +0000 | [diff] [blame] | 23 | fdt32_t boot_cpuid_phys; /* Which physical CPU id we're |
Gerald Van Baren | 7cd5da0 | 2007-03-31 11:59:59 -0400 | [diff] [blame] | 24 | booting on */ |
| 25 | /* version 3 fields below */ |
Kim Phillips | 71bbb3d | 2013-01-16 13:59:43 +0000 | [diff] [blame] | 26 | fdt32_t size_dt_strings; /* size of the strings block */ |
Gerald Van Baren | 7cd5da0 | 2007-03-31 11:59:59 -0400 | [diff] [blame] | 27 | |
| 28 | /* version 17 fields below */ |
Kim Phillips | 71bbb3d | 2013-01-16 13:59:43 +0000 | [diff] [blame] | 29 | fdt32_t size_dt_struct; /* size of the structure block */ |
Gerald Van Baren | 7cd5da0 | 2007-03-31 11:59:59 -0400 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | struct fdt_reserve_entry { |
Kim Phillips | 71bbb3d | 2013-01-16 13:59:43 +0000 | [diff] [blame] | 33 | fdt64_t address; |
| 34 | fdt64_t size; |
Gerald Van Baren | 7cd5da0 | 2007-03-31 11:59:59 -0400 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | struct fdt_node_header { |
Kim Phillips | 71bbb3d | 2013-01-16 13:59:43 +0000 | [diff] [blame] | 38 | fdt32_t tag; |
Gerald Van Baren | 7cd5da0 | 2007-03-31 11:59:59 -0400 | [diff] [blame] | 39 | char name[0]; |
| 40 | }; |
| 41 | |
| 42 | struct fdt_property { |
Kim Phillips | 71bbb3d | 2013-01-16 13:59:43 +0000 | [diff] [blame] | 43 | fdt32_t tag; |
| 44 | fdt32_t len; |
| 45 | fdt32_t nameoff; |
Gerald Van Baren | 7cd5da0 | 2007-03-31 11:59:59 -0400 | [diff] [blame] | 46 | char data[0]; |
| 47 | }; |
| 48 | |
| 49 | #endif /* !__ASSEMBLY */ |
| 50 | |
Wolfgang Denk | a5f601f | 2007-11-26 19:18:21 +0100 | [diff] [blame] | 51 | #define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */ |
Kim Phillips | 71bbb3d | 2013-01-16 13:59:43 +0000 | [diff] [blame] | 52 | #define FDT_TAGSIZE sizeof(fdt32_t) |
Gerald Van Baren | 7cd5da0 | 2007-03-31 11:59:59 -0400 | [diff] [blame] | 53 | |
Wolfgang Denk | a5f601f | 2007-11-26 19:18:21 +0100 | [diff] [blame] | 54 | #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 Baren | 7cd5da0 | 2007-03-31 11:59:59 -0400 | [diff] [blame] | 57 | size, content */ |
| 58 | #define FDT_NOP 0x4 /* nop */ |
| 59 | #define FDT_END 0x9 |
| 60 | |
Kim Phillips | 71bbb3d | 2013-01-16 13:59:43 +0000 | [diff] [blame] | 61 | #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 Baren | 7cd5da0 | 2007-03-31 11:59:59 -0400 | [diff] [blame] | 64 | #define FDT_V16_SIZE FDT_V3_SIZE |
Kim Phillips | 71bbb3d | 2013-01-16 13:59:43 +0000 | [diff] [blame] | 65 | #define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t)) |
Gerald Van Baren | 7cd5da0 | 2007-03-31 11:59:59 -0400 | [diff] [blame] | 66 | |
Gerald Van Baren | 7cd5da0 | 2007-03-31 11:59:59 -0400 | [diff] [blame] | 67 | #endif /* _FDT_H */ |