1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0+ */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Definitions for building a device tree by calling into the 4*4882a593Smuzhiyun * Open Firmware PROM. 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * Copyright (C) 2010 Andres Salomon <dilinger@queued.net> 7*4882a593Smuzhiyun */ 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun #ifndef _LINUX_OF_PDT_H 10*4882a593Smuzhiyun #define _LINUX_OF_PDT_H 11*4882a593Smuzhiyun 12*4882a593Smuzhiyun /* overridable operations for calling into the PROM */ 13*4882a593Smuzhiyun struct of_pdt_ops { 14*4882a593Smuzhiyun /* 15*4882a593Smuzhiyun * buf should be 32 bytes; return 0 on success. 16*4882a593Smuzhiyun * If prev is NULL, the first property will be returned. 17*4882a593Smuzhiyun */ 18*4882a593Smuzhiyun int (*nextprop)(phandle node, char *prev, char *buf); 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun /* for both functions, return proplen on success; -1 on error */ 21*4882a593Smuzhiyun int (*getproplen)(phandle node, const char *prop); 22*4882a593Smuzhiyun int (*getproperty)(phandle node, const char *prop, char *buf, 23*4882a593Smuzhiyun int bufsize); 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun /* phandles are 0 if no child or sibling exists */ 26*4882a593Smuzhiyun phandle (*getchild)(phandle parent); 27*4882a593Smuzhiyun phandle (*getsibling)(phandle node); 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun /* return 0 on success; fill in 'len' with number of bytes in path */ 30*4882a593Smuzhiyun int (*pkg2path)(phandle node, char *buf, const int buflen, int *len); 31*4882a593Smuzhiyun }; 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun extern void *prom_early_alloc(unsigned long size); 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun /* for building the device tree */ 36*4882a593Smuzhiyun extern void of_pdt_build_devicetree(phandle root_node, struct of_pdt_ops *ops); 37*4882a593Smuzhiyun 38*4882a593Smuzhiyun #endif /* _LINUX_OF_PDT_H */ 39