diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/device.h | 2 | ||||
| -rw-r--r-- | include/linux/dma-contiguous.h | 62 | ||||
| -rw-r--r-- | include/linux/of_fdt.h | 3 | ||||
| -rw-r--r-- | include/linux/of_reserved_mem.h | 14 |
4 files changed, 78 insertions, 3 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index f46646e49235..2a9d6ed59579 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
| @@ -737,7 +737,7 @@ struct device { | |||
| 737 | 737 | ||
| 738 | struct dma_coherent_mem *dma_mem; /* internal for coherent mem | 738 | struct dma_coherent_mem *dma_mem; /* internal for coherent mem |
| 739 | override */ | 739 | override */ |
| 740 | #ifdef CONFIG_CMA | 740 | #ifdef CONFIG_DMA_CMA |
| 741 | struct cma *cma_area; /* contiguous memory area for dma | 741 | struct cma *cma_area; /* contiguous memory area for dma |
| 742 | allocations */ | 742 | allocations */ |
| 743 | #endif | 743 | #endif |
diff --git a/include/linux/dma-contiguous.h b/include/linux/dma-contiguous.h index 00141d3325fe..3b28f937d959 100644 --- a/include/linux/dma-contiguous.h +++ b/include/linux/dma-contiguous.h | |||
| @@ -67,9 +67,53 @@ struct device; | |||
| 67 | 67 | ||
| 68 | extern struct cma *dma_contiguous_default_area; | 68 | extern struct cma *dma_contiguous_default_area; |
| 69 | 69 | ||
| 70 | static inline struct cma *dev_get_cma_area(struct device *dev) | ||
| 71 | { | ||
| 72 | if (dev && dev->cma_area) | ||
| 73 | return dev->cma_area; | ||
| 74 | return dma_contiguous_default_area; | ||
| 75 | } | ||
| 76 | |||
| 77 | static inline void dev_set_cma_area(struct device *dev, struct cma *cma) | ||
| 78 | { | ||
| 79 | if (dev) | ||
| 80 | dev->cma_area = cma; | ||
| 81 | } | ||
| 82 | |||
| 83 | static inline void dma_contiguous_set_default(struct cma *cma) | ||
| 84 | { | ||
| 85 | dma_contiguous_default_area = cma; | ||
| 86 | } | ||
| 87 | |||
| 70 | void dma_contiguous_reserve(phys_addr_t addr_limit); | 88 | void dma_contiguous_reserve(phys_addr_t addr_limit); |
| 71 | int dma_declare_contiguous(struct device *dev, phys_addr_t size, | 89 | |
| 72 | phys_addr_t base, phys_addr_t limit); | 90 | int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base, |
| 91 | phys_addr_t limit, struct cma **res_cma); | ||
| 92 | |||
| 93 | /** | ||
| 94 | * dma_declare_contiguous() - reserve area for contiguous memory handling | ||
| 95 | * for particular device | ||
| 96 | * @dev: Pointer to device structure. | ||
| 97 | * @size: Size of the reserved memory. | ||
| 98 | * @base: Start address of the reserved memory (optional, 0 for any). | ||
| 99 | * @limit: End address of the reserved memory (optional, 0 for any). | ||
| 100 | * | ||
| 101 | * This function reserves memory for specified device. It should be | ||
| 102 | * called by board specific code when early allocator (memblock or bootmem) | ||
| 103 | * is still activate. | ||
| 104 | */ | ||
| 105 | |||
| 106 | static inline int dma_declare_contiguous(struct device *dev, phys_addr_t size, | ||
| 107 | phys_addr_t base, phys_addr_t limit) | ||
| 108 | { | ||
| 109 | struct cma *cma; | ||
| 110 | int ret; | ||
| 111 | ret = dma_contiguous_reserve_area(size, base, limit, &cma); | ||
| 112 | if (ret == 0) | ||
| 113 | dev_set_cma_area(dev, cma); | ||
| 114 | |||
| 115 | return ret; | ||
| 116 | } | ||
| 73 | 117 | ||
| 74 | struct page *dma_alloc_from_contiguous(struct device *dev, int count, | 118 | struct page *dma_alloc_from_contiguous(struct device *dev, int count, |
| 75 | unsigned int order); | 119 | unsigned int order); |
| @@ -80,8 +124,22 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages, | |||
| 80 | 124 | ||
| 81 | #define MAX_CMA_AREAS (0) | 125 | #define MAX_CMA_AREAS (0) |
| 82 | 126 | ||
| 127 | static inline struct cma *dev_get_cma_area(struct device *dev) | ||
| 128 | { | ||
| 129 | return NULL; | ||
| 130 | } | ||
| 131 | |||
| 132 | static inline void dev_set_cma_area(struct device *dev, struct cma *cma) { } | ||
| 133 | |||
| 134 | static inline void dma_contiguous_set_default(struct cma *cma) { } | ||
| 135 | |||
| 83 | static inline void dma_contiguous_reserve(phys_addr_t limit) { } | 136 | static inline void dma_contiguous_reserve(phys_addr_t limit) { } |
| 84 | 137 | ||
| 138 | static inline int dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base, | ||
| 139 | phys_addr_t limit, struct cma **res_cma) { | ||
| 140 | return -ENOSYS; | ||
| 141 | } | ||
| 142 | |||
| 85 | static inline | 143 | static inline |
| 86 | int dma_declare_contiguous(struct device *dev, phys_addr_t size, | 144 | int dma_declare_contiguous(struct device *dev, phys_addr_t size, |
| 87 | phys_addr_t base, phys_addr_t limit) | 145 | phys_addr_t base, phys_addr_t limit) |
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index ed136ad698ce..19f26f8d2202 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h | |||
| @@ -90,6 +90,9 @@ extern void *of_get_flat_dt_prop(unsigned long node, const char *name, | |||
| 90 | extern int of_flat_dt_is_compatible(unsigned long node, const char *name); | 90 | extern int of_flat_dt_is_compatible(unsigned long node, const char *name); |
| 91 | extern int of_flat_dt_match(unsigned long node, const char *const *matches); | 91 | extern int of_flat_dt_match(unsigned long node, const char *const *matches); |
| 92 | extern unsigned long of_get_flat_dt_root(void); | 92 | extern unsigned long of_get_flat_dt_root(void); |
| 93 | extern int of_scan_flat_dt_by_path(const char *path, | ||
| 94 | int (*it)(unsigned long node, const char *name, int depth, void *data), | ||
| 95 | void *data); | ||
| 93 | 96 | ||
| 94 | extern int early_init_dt_scan_chosen(unsigned long node, const char *uname, | 97 | extern int early_init_dt_scan_chosen(unsigned long node, const char *uname, |
| 95 | int depth, void *data); | 98 | int depth, void *data); |
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h new file mode 100644 index 000000000000..c84128255814 --- /dev/null +++ b/include/linux/of_reserved_mem.h | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | #ifndef __OF_RESERVED_MEM_H | ||
| 2 | #define __OF_RESERVED_MEM_H | ||
| 3 | |||
| 4 | #ifdef CONFIG_OF_RESERVED_MEM | ||
| 5 | void of_reserved_mem_device_init(struct device *dev); | ||
| 6 | void of_reserved_mem_device_release(struct device *dev); | ||
| 7 | void early_init_dt_scan_reserved_mem(void); | ||
| 8 | #else | ||
| 9 | static inline void of_reserved_mem_device_init(struct device *dev) { } | ||
| 10 | static inline void of_reserved_mem_device_release(struct device *dev) { } | ||
| 11 | static inline void early_init_dt_scan_reserved_mem(void) { } | ||
| 12 | #endif | ||
| 13 | |||
| 14 | #endif /* __OF_RESERVED_MEM_H */ | ||
