Soby Mathew | e5674e1 | 2017-11-06 13:56:40 +0000 | [diff] [blame] | 1 | /* |
Alexei Fedorov | 0a2ab6e | 2020-01-29 16:21:28 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved. |
Soby Mathew | e5674e1 | 2017-11-06 13:56:40 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | /* Helper functions to offer easier navigation of Device Tree Blob */ |
| 8 | |
Antonio Nino Diaz | c3cf06f | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 9 | #ifndef FDT_WRAPPERS_H |
| 10 | #define FDT_WRAPPERS_H |
Soby Mathew | e5674e1 | 2017-11-06 13:56:40 +0000 | [diff] [blame] | 11 | |
| 12 | /* Number of cells, given total length in bytes. Each cell is 4 bytes long */ |
Antonio Nino Diaz | 81542c0 | 2018-10-04 09:55:23 +0100 | [diff] [blame] | 13 | #define NCELLS(len) ((len) / 4U) |
Soby Mathew | e5674e1 | 2017-11-06 13:56:40 +0000 | [diff] [blame] | 14 | |
| 15 | int fdtw_read_cells(const void *dtb, int node, const char *prop, |
| 16 | unsigned int cells, void *value); |
Antonio Nino Diaz | 73f1ac6 | 2018-06-26 10:34:10 +0100 | [diff] [blame] | 17 | int fdtw_read_array(const void *dtb, int node, const char *prop, |
| 18 | unsigned int cells, void *value); |
Antonio Nino Diaz | 2747362 | 2018-06-26 10:34:07 +0100 | [diff] [blame] | 19 | int fdtw_read_string(const void *dtb, int node, const char *prop, |
| 20 | char *str, size_t size); |
Soby Mathew | e5674e1 | 2017-11-06 13:56:40 +0000 | [diff] [blame] | 21 | int fdtw_write_inplace_cells(void *dtb, int node, const char *prop, |
| 22 | unsigned int cells, void *value); |
Alexei Fedorov | 0a2ab6e | 2020-01-29 16:21:28 +0000 | [diff] [blame] | 23 | int fdtw_read_bytes(const void *dtb, int node, const char *prop, |
| 24 | unsigned int length, void *value); |
| 25 | int fdtw_write_inplace_bytes(void *dtb, int node, const char *prop, |
| 26 | unsigned int length, const void *data); |
Antonio Nino Diaz | 2747362 | 2018-06-26 10:34:07 +0100 | [diff] [blame] | 27 | |
Antonio Nino Diaz | c3cf06f | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 28 | #endif /* FDT_WRAPPERS_H */ |