blob: cb7697dec2941e3c52099b72e152cbdeace2d34a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _PARISC_DMA_MAPPING_H
2#define _PARISC_DMA_MAPPING_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#include <asm/cacheflush.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
Linus Torvalds1da177e2005-04-16 15:20:36 -07006/*
Christoph Hellwig79387172016-01-20 15:01:47 -08007** We need to support 4 different coherent dma models with one binary:
8**
Linus Torvalds1da177e2005-04-16 15:20:36 -07009** I/O MMU consistent method dma_sync behavior
10** ============= ====================== =======================
11** a) PA-7x00LC uncachable host memory flush/purge
12** b) U2/Uturn cachable host memory NOP
13** c) Ike/Astro cachable host memory NOP
14** d) EPIC/SAGA memory on EPIC/SAGA flush/reset DMA channel
15**
16** PA-7[13]00LC processors have a GSC bus interface and no I/O MMU.
17**
18** Systems (eg PCX-T workstations) that don't fall into the above
19** categories will need to modify the needed drivers to perform
20** flush/purge and allocate "regular" cacheable pages for everything.
21*/
22
Thomas Bogendoerfer8ed89cf2017-07-03 10:38:05 +020023#define DMA_ERROR_CODE (~(dma_addr_t)0)
24
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#ifdef CONFIG_PA11
Christoph Hellwig79387172016-01-20 15:01:47 -080026extern struct dma_map_ops pcxl_dma_ops;
27extern struct dma_map_ops pcx_dma_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#endif
29
Christoph Hellwig79387172016-01-20 15:01:47 -080030extern struct dma_map_ops *hppa_dma_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
Christoph Hellwig79387172016-01-20 15:01:47 -080032static inline struct dma_map_ops *get_dma_ops(struct device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033{
Christoph Hellwig79387172016-01-20 15:01:47 -080034 return hppa_dma_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035}
36
Linus Torvalds1da177e2005-04-16 15:20:36 -070037static inline void
Ralf Baechled3fa72e2006-12-06 20:38:56 -080038dma_cache_sync(struct device *dev, void *vaddr, size_t size,
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 enum dma_data_direction direction)
40{
Christoph Hellwig79387172016-01-20 15:01:47 -080041 if (hppa_dma_ops->sync_single_for_cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 flush_kernel_dcache_range((unsigned long)vaddr, size);
43}
44
45static inline void *
46parisc_walk_tree(struct device *dev)
47{
48 struct device *otherdev;
49 if(likely(dev->platform_data != NULL))
50 return dev->platform_data;
51 /* OK, just traverse the bus to find it */
52 for(otherdev = dev->parent; otherdev;
53 otherdev = otherdev->parent) {
54 if(otherdev->platform_data) {
55 dev->platform_data = otherdev->platform_data;
56 break;
57 }
58 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 return dev->platform_data;
60}
Thomas Bogendoerfer8ed89cf2017-07-03 10:38:05 +020061
62#define GET_IOC(dev) ({ \
63 void *__pdata = parisc_walk_tree(dev); \
64 __pdata ? HBA_DATA(__pdata)->iommu : NULL; \
65})
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
67#ifdef CONFIG_IOMMU_CCIO
68struct parisc_device;
69struct ioc;
70void * ccio_get_iommu(const struct parisc_device *dev);
71int ccio_request_resource(const struct parisc_device *dev,
72 struct resource *res);
73int ccio_allocate_resource(const struct parisc_device *dev,
74 struct resource *res, unsigned long size,
75 unsigned long min, unsigned long max, unsigned long align);
76#else /* !CONFIG_IOMMU_CCIO */
77#define ccio_get_iommu(dev) NULL
Ryan Bradetich328d9682006-10-26 01:27:18 +000078#define ccio_request_resource(dev, res) insert_resource(&iomem_resource, res)
Linus Torvalds1da177e2005-04-16 15:20:36 -070079#define ccio_allocate_resource(dev, res, size, min, max, align) \
80 allocate_resource(&iomem_resource, res, size, min, max, \
81 align, NULL, NULL)
82#endif /* !CONFIG_IOMMU_CCIO */
83
84#ifdef CONFIG_IOMMU_SBA
85struct parisc_device;
86void * sba_get_iommu(struct parisc_device *dev);
87#endif
88
Linus Torvalds1da177e2005-04-16 15:20:36 -070089#endif