blob: e28dee1423f6348117a7a98cbf4faacd8c79b94e [file] [log] [blame]
Soby Mathewb9fccca2017-11-06 13:56:40 +00001/*
Alexei Fedorov2de82fc2020-01-29 16:21:28 +00002 * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved.
Soby Mathewb9fccca2017-11-06 13:56:40 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7/* Helper functions to offer easier navigation of Device Tree Blob */
8
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +00009#ifndef FDT_WRAPPERS_H
10#define FDT_WRAPPERS_H
Soby Mathewb9fccca2017-11-06 13:56:40 +000011
12/* Number of cells, given total length in bytes. Each cell is 4 bytes long */
Antonio Nino Diazf0b14cf2018-10-04 09:55:23 +010013#define NCELLS(len) ((len) / 4U)
Soby Mathewb9fccca2017-11-06 13:56:40 +000014
Andre Przywarafe5bdf52020-03-26 11:22:37 +000015int fdt_read_uint32(const void *dtb, int node, const char *prop_name,
16 uint32_t *value);
17int fdt_read_uint64(const void *dtb, int node, const char *prop_name,
18 uint64_t *value);
Andre Przywara6cf6a1b2020-03-30 23:21:13 +010019int fdt_read_uint32_array(const void *dtb, int node, const char *prop_name,
20 unsigned int cells, uint32_t *value);
Antonio Nino Diazd85c8782018-06-26 10:34:07 +010021int fdtw_read_string(const void *dtb, int node, const char *prop,
22 char *str, size_t size);
Soby Mathewb9fccca2017-11-06 13:56:40 +000023int fdtw_write_inplace_cells(void *dtb, int node, const char *prop,
24 unsigned int cells, void *value);
Alexei Fedorov2de82fc2020-01-29 16:21:28 +000025int fdtw_read_bytes(const void *dtb, int node, const char *prop,
26 unsigned int length, void *value);
27int fdtw_write_inplace_bytes(void *dtb, int node, const char *prop,
28 unsigned int length, const void *data);
Antonio Nino Diazd85c8782018-06-26 10:34:07 +010029
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000030#endif /* FDT_WRAPPERS_H */