xref: /openbmc/linux/include/linux/of_pdt.h (revision 1ae367a2)
1af6074fcSRob Herring /* SPDX-License-Identifier: GPL-2.0+ */
23cfc535cSAndres Salomon /*
33cfc535cSAndres Salomon  * Definitions for building a device tree by calling into the
43cfc535cSAndres Salomon  * Open Firmware PROM.
53cfc535cSAndres Salomon  *
63cfc535cSAndres Salomon  * Copyright (C) 2010  Andres Salomon <dilinger@queued.net>
73cfc535cSAndres Salomon  */
83cfc535cSAndres Salomon 
93cfc535cSAndres Salomon #ifndef _LINUX_OF_PDT_H
103cfc535cSAndres Salomon #define _LINUX_OF_PDT_H
113cfc535cSAndres Salomon 
12f90c34bdSAndres Salomon /* overridable operations for calling into the PROM */
13f90c34bdSAndres Salomon struct of_pdt_ops {
14f90c34bdSAndres Salomon 	/*
15f90c34bdSAndres Salomon 	 * buf should be 32 bytes; return 0 on success.
16f90c34bdSAndres Salomon 	 * If prev is NULL, the first property will be returned.
17f90c34bdSAndres Salomon 	 */
18f90c34bdSAndres Salomon 	int (*nextprop)(phandle node, char *prev, char *buf);
19f90c34bdSAndres Salomon 
20f90c34bdSAndres Salomon 	/* for both functions, return proplen on success; -1 on error */
21f90c34bdSAndres Salomon 	int (*getproplen)(phandle node, const char *prop);
22f90c34bdSAndres Salomon 	int (*getproperty)(phandle node, const char *prop, char *buf,
23f90c34bdSAndres Salomon 			int bufsize);
24f90c34bdSAndres Salomon 
25f90c34bdSAndres Salomon 	/* phandles are 0 if no child or sibling exists */
26f90c34bdSAndres Salomon 	phandle (*getchild)(phandle parent);
27f90c34bdSAndres Salomon 	phandle (*getsibling)(phandle node);
28e2f2a93bSAndres Salomon 
29e2f2a93bSAndres Salomon 	/* return 0 on success; fill in 'len' with number of bytes in path */
30e2f2a93bSAndres Salomon 	int (*pkg2path)(phandle node, char *buf, const int buflen, int *len);
31f90c34bdSAndres Salomon };
32f90c34bdSAndres Salomon 
333cfc535cSAndres Salomon extern void *prom_early_alloc(unsigned long size);
343cfc535cSAndres Salomon 
353cfc535cSAndres Salomon /* for building the device tree */
36f90c34bdSAndres Salomon extern void of_pdt_build_devicetree(phandle root_node, struct of_pdt_ops *ops);
373cfc535cSAndres Salomon 
383cfc535cSAndres Salomon #endif /* _LINUX_OF_PDT_H */
39