diff options
Diffstat (limited to 'arch/arm/include')
-rw-r--r-- | arch/arm/include/asm/dma-mapping.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index e701a4d9aa59..c45b61a4b4a5 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h | |||
@@ -58,21 +58,37 @@ static inline int dma_set_mask(struct device *dev, u64 mask) | |||
58 | #ifndef __arch_pfn_to_dma | 58 | #ifndef __arch_pfn_to_dma |
59 | static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) | 59 | static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) |
60 | { | 60 | { |
61 | if (dev) | ||
62 | pfn -= dev->dma_pfn_offset; | ||
61 | return (dma_addr_t)__pfn_to_bus(pfn); | 63 | return (dma_addr_t)__pfn_to_bus(pfn); |
62 | } | 64 | } |
63 | 65 | ||
64 | static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr) | 66 | static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr) |
65 | { | 67 | { |
66 | return __bus_to_pfn(addr); | 68 | unsigned long pfn = __bus_to_pfn(addr); |
69 | |||
70 | if (dev) | ||
71 | pfn += dev->dma_pfn_offset; | ||
72 | |||
73 | return pfn; | ||
67 | } | 74 | } |
68 | 75 | ||
69 | static inline void *dma_to_virt(struct device *dev, dma_addr_t addr) | 76 | static inline void *dma_to_virt(struct device *dev, dma_addr_t addr) |
70 | { | 77 | { |
78 | if (dev) { | ||
79 | unsigned long pfn = dma_to_pfn(dev, addr); | ||
80 | |||
81 | return phys_to_virt(__pfn_to_phys(pfn)); | ||
82 | } | ||
83 | |||
71 | return (void *)__bus_to_virt((unsigned long)addr); | 84 | return (void *)__bus_to_virt((unsigned long)addr); |
72 | } | 85 | } |
73 | 86 | ||
74 | static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) | 87 | static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) |
75 | { | 88 | { |
89 | if (dev) | ||
90 | return pfn_to_dma(dev, virt_to_pfn(addr)); | ||
91 | |||
76 | return (dma_addr_t)__virt_to_bus((unsigned long)(addr)); | 92 | return (dma_addr_t)__virt_to_bus((unsigned long)(addr)); |
77 | } | 93 | } |
78 | 94 | ||
@@ -105,6 +121,13 @@ static inline unsigned long dma_max_pfn(struct device *dev) | |||
105 | } | 121 | } |
106 | #define dma_max_pfn(dev) dma_max_pfn(dev) | 122 | #define dma_max_pfn(dev) dma_max_pfn(dev) |
107 | 123 | ||
124 | static inline int set_arch_dma_coherent_ops(struct device *dev) | ||
125 | { | ||
126 | set_dma_ops(dev, &arm_coherent_dma_ops); | ||
127 | return 0; | ||
128 | } | ||
129 | #define set_arch_dma_coherent_ops(dev) set_arch_dma_coherent_ops(dev) | ||
130 | |||
108 | static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) | 131 | static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) |
109 | { | 132 | { |
110 | unsigned int offset = paddr & ~PAGE_MASK; | 133 | unsigned int offset = paddr & ~PAGE_MASK; |