1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __OF_RESERVED_MEM_H
3 #define __OF_RESERVED_MEM_H
5 #include <linux/device.h>
8 struct of_phandle_args
;
9 struct reserved_mem_ops
;
13 unsigned long fdt_node
;
14 const struct reserved_mem_ops
*ops
;
20 struct reserved_mem_ops
{
21 int (*device_init
)(struct reserved_mem
*rmem
,
23 void (*device_release
)(struct reserved_mem
*rmem
,
27 typedef int (*reservedmem_of_init_fn
)(struct reserved_mem
*rmem
);
29 #ifdef CONFIG_OF_RESERVED_MEM
31 #define RESERVEDMEM_OF_DECLARE(name, compat, init) \
32 _OF_DECLARE(reservedmem, name, compat, init, reservedmem_of_init_fn)
34 int of_reserved_mem_device_init_by_idx(struct device
*dev
,
35 struct device_node
*np
, int idx
);
36 int of_reserved_mem_device_init_by_name(struct device
*dev
,
37 struct device_node
*np
,
39 void of_reserved_mem_device_release(struct device
*dev
);
41 struct reserved_mem
*of_reserved_mem_lookup(struct device_node
*np
);
44 #define RESERVEDMEM_OF_DECLARE(name, compat, init) \
45 _OF_DECLARE_STUB(reservedmem, name, compat, init, reservedmem_of_init_fn)
47 static inline int of_reserved_mem_device_init_by_idx(struct device
*dev
,
48 struct device_node
*np
, int idx
)
53 static inline int of_reserved_mem_device_init_by_name(struct device
*dev
,
54 struct device_node
*np
,
60 static inline void of_reserved_mem_device_release(struct device
*pdev
) { }
62 static inline struct reserved_mem
*of_reserved_mem_lookup(struct device_node
*np
)
69 * of_reserved_mem_device_init() - assign reserved memory region to given device
70 * @dev: Pointer to the device to configure
72 * This function assigns respective DMA-mapping operations based on the first
73 * reserved memory region specified by 'memory-region' property in device tree
74 * node of the given device.
76 * Returns error code or zero on success.
78 static inline int of_reserved_mem_device_init(struct device
*dev
)
80 return of_reserved_mem_device_init_by_idx(dev
, dev
->of_node
, 0);
83 #endif /* __OF_RESERVED_MEM_H */