Rev 6102 | Rev 6588 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6102 | Rev 6125 | ||
---|---|---|---|
1 | /* include this file if the platform implements the dma_ DMA Mapping API |
1 | /* include this file if the platform implements the dma_ DMA Mapping API |
2 | * and wants to provide the pci_ DMA Mapping API in terms of it */ |
2 | * and wants to provide the pci_ DMA Mapping API in terms of it */ |
3 | 3 | ||
4 | #ifndef _ASM_GENERIC_PCI_DMA_COMPAT_H |
4 | #ifndef _ASM_GENERIC_PCI_DMA_COMPAT_H |
5 | #define _ASM_GENERIC_PCI_DMA_COMPAT_H |
5 | #define _ASM_GENERIC_PCI_DMA_COMPAT_H |
6 | 6 | ||
7 | #include |
7 | #include |
8 | 8 | ||
9 | static inline void * |
9 | static inline void * |
10 | pci_zalloc_consistent(struct pci_dev *hwdev, size_t size, |
10 | pci_zalloc_consistent(struct pci_dev *hwdev, size_t size, |
11 | dma_addr_t *dma_handle) |
11 | dma_addr_t *dma_handle) |
12 | { |
12 | { |
13 | return dma_zalloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, |
13 | return dma_zalloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, |
14 | size, dma_handle, GFP_ATOMIC); |
14 | size, dma_handle, GFP_ATOMIC); |
15 | } |
15 | } |
16 | 16 | ||
17 | static inline dma_addr_t |
17 | static inline dma_addr_t |
18 | pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction) |
18 | pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction) |
19 | { |
19 | { |
20 | return dma_map_single(hwdev == NULL ? NULL : &hwdev->dev, ptr, size, (enum dma_data_direction)direction); |
20 | return dma_map_single(hwdev == NULL ? NULL : &hwdev->dev, ptr, size, (enum dma_data_direction)direction); |
21 | } |
21 | } |
22 | 22 | ||
23 | static inline void |
23 | static inline void |
24 | pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, |
24 | pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, |
25 | size_t size, int direction) |
25 | size_t size, int direction) |
26 | { |
26 | { |
27 | dma_unmap_single(hwdev == NULL ? NULL : &hwdev->dev, dma_addr, size, (enum dma_data_direction)direction); |
27 | dma_unmap_single(hwdev == NULL ? NULL : &hwdev->dev, dma_addr, size, (enum dma_data_direction)direction); |
28 | } |
28 | } |
29 | 29 | ||
30 | static inline dma_addr_t |
30 | static inline dma_addr_t |
31 | pci_map_page(struct pci_dev *hwdev, struct page *page, |
31 | pci_map_page(struct pci_dev *hwdev, struct page *page, |
32 | unsigned long offset, size_t size, int direction) |
32 | unsigned long offset, size_t size, int direction) |
33 | { |
33 | { |
34 | return (dma_addr_t)( (offset)+page_to_phys(page)); |
34 | return (dma_addr_t)( (offset)+page_to_phys(page)); |
35 | } |
35 | } |
36 | 36 | ||
37 | static inline void |
37 | static inline void |
38 | pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address, |
38 | pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address, |
39 | size_t size, int direction) |
39 | size_t size, int direction) |
40 | { |
40 | { |
41 | 41 | ||
42 | } |
42 | } |
43 | #define pci_map_page(dev, page, offset, size, direction) \ |
43 | #define pci_map_page(dev, page, offset, size, direction) \ |
44 | (dma_addr_t)( (offset)+page_to_phys(page)) |
44 | (dma_addr_t)( (offset)+page_to_phys(page)) |
45 | 45 | ||
46 | #define pci_unmap_page(dev, dma_address, size, direction) |
46 | #define pci_unmap_page(dev, dma_address, size, direction) |
47 | 47 | ||
48 | static inline int |
48 | static inline int |
49 | pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg, |
49 | pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg, |
50 | int nents, int direction) |
50 | int nents, int direction) |
51 | { |
51 | { |
52 | return dma_map_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction); |
52 | return dma_map_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction); |
53 | } |
53 | } |
54 | 54 | ||
55 | static inline void |
55 | static inline void |
56 | pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, |
56 | pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, |
57 | int nents, int direction) |
57 | int nents, int direction) |
58 | { |
58 | { |
59 | dma_unmap_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction); |
59 | dma_unmap_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction); |
60 | } |
60 | } |
61 | 61 | ||
62 | static inline void |
62 | static inline void |
63 | pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle, |
63 | pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle, |
64 | size_t size, int direction) |
64 | size_t size, int direction) |
65 | { |
65 | { |
66 | dma_sync_single_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction); |
66 | dma_sync_single_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction); |
67 | } |
67 | } |
68 | 68 | ||
69 | static inline void |
69 | static inline void |
70 | pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle, |
70 | pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle, |
71 | size_t size, int direction) |
71 | size_t size, int direction) |
72 | { |
72 | { |
73 | dma_sync_single_for_device(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction); |
73 | dma_sync_single_for_device(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction); |
74 | } |
74 | } |
75 | 75 | ||
76 | static inline void |
76 | static inline void |
77 | pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg, |
77 | pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg, |
78 | int nelems, int direction) |
78 | int nelems, int direction) |
79 | { |
79 | { |
80 | dma_sync_sg_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction); |
80 | dma_sync_sg_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction); |
81 | } |
81 | } |
82 | 82 | ||
83 | static inline void |
83 | static inline void |
84 | pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg, |
84 | pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg, |
85 | int nelems, int direction) |
85 | int nelems, int direction) |
86 | { |
86 | { |
87 | dma_sync_sg_for_device(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction); |
87 | dma_sync_sg_for_device(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction); |
88 | } |
88 | } |
89 | 89 | ||
90 | static inline int |
90 | static inline int |
91 | pci_dma_mapping_error(struct pci_dev *pdev, dma_addr_t dma_addr) |
91 | pci_dma_mapping_error(struct pci_dev *pdev, dma_addr_t dma_addr) |
92 | { |
92 | { |
93 | return dma_mapping_error(&pdev->dev, dma_addr); |
93 | return dma_mapping_error(&pdev->dev, dma_addr); |
94 | } |
94 | } |
95 | 95 | ||
96 | #ifdef CONFIG_PCI |
96 | #ifdef CONFIG_PCI |
97 | static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) |
97 | static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) |
98 | { |
98 | { |
99 | return dma_set_mask(&dev->dev, mask); |
99 | return 0; |
100 | } |
100 | } |
101 | 101 | ||
102 | static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) |
102 | static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) |
103 | { |
103 | { |
104 | return dma_set_coherent_mask(&dev->dev, mask); |
104 | return 0; |
105 | } |
105 | } |
106 | #endif |
106 | #endif |
107 | 107 | ||
108 | #endif |
108 | #endif |