2014-02-28 20:42:48 +07:00
|
|
|
#ifndef __OF_RESERVED_MEM_H
|
|
|
|
#define __OF_RESERVED_MEM_H
|
|
|
|
|
2016-05-24 20:31:24 +07:00
|
|
|
#include <linux/device.h>
|
|
|
|
|
2014-02-28 20:42:49 +07:00
|
|
|
struct of_phandle_args;
|
|
|
|
struct reserved_mem_ops;
|
|
|
|
|
2014-02-28 20:42:48 +07:00
|
|
|
struct reserved_mem {
|
|
|
|
const char *name;
|
|
|
|
unsigned long fdt_node;
|
2014-07-14 15:28:04 +07:00
|
|
|
unsigned long phandle;
|
2014-02-28 20:42:49 +07:00
|
|
|
const struct reserved_mem_ops *ops;
|
2014-02-28 20:42:48 +07:00
|
|
|
phys_addr_t base;
|
|
|
|
phys_addr_t size;
|
2014-02-28 20:42:49 +07:00
|
|
|
void *priv;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct reserved_mem_ops {
|
2014-10-30 04:50:29 +07:00
|
|
|
int (*device_init)(struct reserved_mem *rmem,
|
2014-02-28 20:42:49 +07:00
|
|
|
struct device *dev);
|
|
|
|
void (*device_release)(struct reserved_mem *rmem,
|
|
|
|
struct device *dev);
|
2014-02-28 20:42:48 +07:00
|
|
|
};
|
|
|
|
|
2014-05-09 04:06:17 +07:00
|
|
|
typedef int (*reservedmem_of_init_fn)(struct reserved_mem *rmem);
|
|
|
|
|
2014-05-09 04:09:24 +07:00
|
|
|
#define RESERVEDMEM_OF_DECLARE(name, compat, init) \
|
|
|
|
_OF_DECLARE(reservedmem, name, compat, init, reservedmem_of_init_fn)
|
2014-02-28 20:42:49 +07:00
|
|
|
|
2014-02-28 20:42:48 +07:00
|
|
|
#ifdef CONFIG_OF_RESERVED_MEM
|
2016-05-24 20:31:24 +07:00
|
|
|
|
|
|
|
int of_reserved_mem_device_init_by_idx(struct device *dev,
|
|
|
|
struct device_node *np, int idx);
|
2014-07-14 15:28:04 +07:00
|
|
|
void of_reserved_mem_device_release(struct device *dev);
|
|
|
|
|
2016-06-09 17:38:34 +07:00
|
|
|
int early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
|
|
|
|
phys_addr_t align,
|
|
|
|
phys_addr_t start,
|
|
|
|
phys_addr_t end,
|
|
|
|
bool nomap,
|
|
|
|
phys_addr_t *res_base);
|
|
|
|
|
2014-02-28 20:42:48 +07:00
|
|
|
void fdt_init_reserved_mem(void);
|
|
|
|
void fdt_reserved_mem_save_node(unsigned long node, const char *uname,
|
|
|
|
phys_addr_t base, phys_addr_t size);
|
|
|
|
#else
|
2016-05-24 20:31:24 +07:00
|
|
|
static inline int of_reserved_mem_device_init_by_idx(struct device *dev,
|
|
|
|
struct device_node *np, int idx)
|
2014-10-30 04:50:29 +07:00
|
|
|
{
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
2014-07-14 15:28:04 +07:00
|
|
|
static inline void of_reserved_mem_device_release(struct device *pdev) { }
|
|
|
|
|
2014-02-28 20:42:48 +07:00
|
|
|
static inline void fdt_init_reserved_mem(void) { }
|
|
|
|
static inline void fdt_reserved_mem_save_node(unsigned long node,
|
|
|
|
const char *uname, phys_addr_t base, phys_addr_t size) { }
|
|
|
|
#endif
|
|
|
|
|
2016-05-24 20:31:24 +07:00
|
|
|
/**
|
|
|
|
* of_reserved_mem_device_init() - assign reserved memory region to given device
|
|
|
|
* @dev: Pointer to the device to configure
|
|
|
|
*
|
|
|
|
* This function assigns respective DMA-mapping operations based on the first
|
|
|
|
* reserved memory region specified by 'memory-region' property in device tree
|
|
|
|
* node of the given device.
|
|
|
|
*
|
|
|
|
* Returns error code or zero on success.
|
|
|
|
*/
|
|
|
|
static inline int of_reserved_mem_device_init(struct device *dev)
|
|
|
|
{
|
|
|
|
return of_reserved_mem_device_init_by_idx(dev, dev->of_node, 0);
|
|
|
|
}
|
|
|
|
|
2014-02-28 20:42:48 +07:00
|
|
|
#endif /* __OF_RESERVED_MEM_H */
|