blob: 31b2f5dfd589b723757a0d597f8e72f86ac91a3a [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
David Gibson2e601612007-06-13 14:52:54 +10002#ifndef _PPC_BOOT_OF_H_
3#define _PPC_BOOT_OF_H_
4
Cédric Le Goater98fd4332014-04-24 09:23:33 +02005#include "swab.h"
6
David Gibson2e601612007-06-13 14:52:54 +10007typedef void *phandle;
Cédric Le Goater64130102014-04-24 09:23:31 +02008typedef u32 ihandle;
David Gibson2e601612007-06-13 14:52:54 +10009
10void of_init(void *promptr);
11int of_call_prom(const char *service, int nargs, int nret, ...);
Cédric Le Goater034e55e2014-04-24 09:23:30 +020012unsigned int of_claim(unsigned long virt, unsigned long size,
13 unsigned long align);
David Gibson08464712007-06-27 16:54:58 +100014void *of_vmlinux_alloc(unsigned long size);
David Gibson2e601612007-06-13 14:52:54 +100015void of_exit(void);
David Gibson08464712007-06-27 16:54:58 +100016void *of_finddevice(const char *name);
17int of_getprop(const void *phandle, const char *name, void *buf,
18 const int buflen);
19int of_setprop(const void *phandle, const char *name, const void *buf,
20 const int buflen);
David Gibson2e601612007-06-13 14:52:54 +100021
22/* Console functions */
23void of_console_init(void);
24
Rob Herringf1ec7182015-04-29 16:02:30 -050025typedef u16 __be16;
Cédric Le Goaterfed23ed2014-04-24 09:23:26 +020026typedef u32 __be32;
Rob Herringf1ec7182015-04-29 16:02:30 -050027typedef u64 __be64;
Cédric Le Goaterfed23ed2014-04-24 09:23:26 +020028
Cédric Le Goater98fd4332014-04-24 09:23:33 +020029#ifdef __LITTLE_ENDIAN__
Jeremy Kerr6c87b222015-02-11 12:55:44 +080030#define cpu_to_be16(x) swab16(x)
31#define be16_to_cpu(x) swab16(x)
Cédric Le Goater98fd4332014-04-24 09:23:33 +020032#define cpu_to_be32(x) swab32(x)
33#define be32_to_cpu(x) swab32(x)
Jeremy Kerr6c87b222015-02-11 12:55:44 +080034#define cpu_to_be64(x) swab64(x)
35#define be64_to_cpu(x) swab64(x)
Cédric Le Goater98fd4332014-04-24 09:23:33 +020036#else
Jeremy Kerr6c87b222015-02-11 12:55:44 +080037#define cpu_to_be16(x) (x)
38#define be16_to_cpu(x) (x)
Cédric Le Goater926e6942014-04-24 09:23:28 +020039#define cpu_to_be32(x) (x)
40#define be32_to_cpu(x) (x)
Jeremy Kerr6c87b222015-02-11 12:55:44 +080041#define cpu_to_be64(x) (x)
42#define be64_to_cpu(x) (x)
Cédric Le Goater98fd4332014-04-24 09:23:33 +020043#endif
Cédric Le Goater926e6942014-04-24 09:23:28 +020044
Cédric Le Goater9cc36bb2014-04-24 09:23:29 +020045#define PROM_ERROR (-1u)
46
David Gibson2e601612007-06-13 14:52:54 +100047#endif /* _PPC_BOOT_OF_H_ */