OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-ppc/] [pci.h] - Blame information for rev 1276

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1276 phoenix
#ifndef __PPC_PCI_H
2
#define __PPC_PCI_H
3
#ifdef __KERNEL__
4
 
5
#include <linux/types.h>
6
#include <linux/slab.h>
7
#include <linux/string.h>
8
#include <asm/scatterlist.h>
9
#include <asm/io.h>
10
 
11
struct pci_dev;
12
 
13
/* Values for the `which' argument to sys_pciconfig_iobase syscall.  */
14
#define IOBASE_BRIDGE_NUMBER    0
15
#define IOBASE_MEMORY           1
16
#define IOBASE_IO               2
17
#define IOBASE_ISA_IO           3
18
#define IOBASE_ISA_MEM          4
19
 
20
/*
21
 * Set this to 1 if you want the kernel to re-assign all PCI
22
 * bus numbers
23
 */
24
extern int pci_assign_all_busses;
25
 
26
#define pcibios_assign_all_busses()     (pci_assign_all_busses)
27
#define pcibios_scan_all_fns()          0
28
 
29
#define PCIBIOS_MIN_IO          0x1000
30
#define PCIBIOS_MIN_MEM         0x10000000
31
 
32
extern inline void pcibios_set_master(struct pci_dev *dev)
33
{
34
        /* No special bus mastering setup handling */
35
}
36
 
37
extern inline void pcibios_penalize_isa_irq(int irq)
38
{
39
        /* We don't do dynamic PCI IRQ allocation */
40
}
41
 
42
extern unsigned long pci_resource_to_bus(struct pci_dev *pdev, struct resource *res);
43
 
44
/*
45
 * The PCI bus bridge can translate addresses issued by the processor(s)
46
 * into a different address on the PCI bus.  On 32-bit cpus, we assume
47
 * this mapping is 1-1, but on 64-bit systems it often isn't.
48
 *
49
 * Obsolete ! Drivers should now use pci_resource_to_bus
50
 */
51
extern unsigned long phys_to_bus(unsigned long pa);
52
extern unsigned long pci_phys_to_bus(unsigned long pa, int busnr);
53
extern unsigned long pci_bus_to_phys(unsigned int ba, int busnr);
54
 
55
/*
56
 * Dynamic DMA Mapping stuff
57
 * Originally stolen from i386 by ajoshi and updated by paulus
58
 * Non-consistent cache support by Dan Malek
59
 */
60
 
61
/* The PCI address space does equal the physical memory
62
 * address space.  The networking and block device layers use
63
 * this boolean for bounce buffer decisions.
64
 */
65
#define PCI_DMA_BUS_IS_PHYS     (1)
66
 
67
/* Allocate and map kernel buffer using consistent mode DMA for a device.
68
 * hwdev should be valid struct pci_dev pointer for PCI devices,
69
 * NULL for PCI-like buses (ISA, EISA).
70
 * Returns non-NULL cpu-view pointer to the buffer if successful and
71
 * sets *dma_addrp to the pci side dma address as well, else *dma_addrp
72
 * is undefined.
73
 */
74
extern void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
75
                                  dma_addr_t *dma_handle);
76
 
77
/* Free and unmap a consistent DMA buffer.
78
 * cpu_addr is what was returned from pci_alloc_consistent,
79
 * size must be the same as what as passed into pci_alloc_consistent,
80
 * and likewise dma_addr must be the same as what *dma_addrp was set to.
81
 *
82
 * References to the memory and mappings associated with cpu_addr/dma_addr
83
 * past this call are illegal.
84
 */
85
extern void pci_free_consistent(struct pci_dev *hwdev, size_t size,
86
                                void *vaddr, dma_addr_t dma_handle);
87
 
88
/* Map a single buffer of the indicated size for DMA in streaming mode.
89
 * The 32-bit bus address to use is returned.
90
 *
91
 * Once the device is given the dma address, the device owns this memory
92
 * until either pci_unmap_single or pci_dma_sync_single is performed.
93
 */
94
static inline dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr,
95
                                        size_t size, int direction)
96
{
97
        BUG_ON(direction == PCI_DMA_NONE);
98
        consistent_sync(ptr, size, direction);
99
        return virt_to_bus(ptr);
100
}
101
 
102
static inline void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
103
                                    size_t size, int direction)
104
{
105
        if (direction == PCI_DMA_NONE)
106
                BUG();
107
        /* nothing to do */
108
}
109
 
110
/* pci_unmap_{page,single} is a nop so... */
111
#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
112
#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
113
#define pci_unmap_addr(PTR, ADDR_NAME)          (0)
114
#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
115
#define pci_unmap_len(PTR, LEN_NAME)            (0)
116
#define pci_unmap_len_set(PTR, LEN_NAME, VAL)   do { } while (0)
117
 
118
/*
119
 * pci_{map,unmap}_single_page maps a kernel page to a dma_addr_t. identical
120
 * to pci_map_single, but takes a struct page instead of a virtual address
121
 */
122
static inline dma_addr_t pci_map_page(struct pci_dev *hwdev, struct page *page,
123
                                      unsigned long offset, size_t size,
124
                                      int direction)
125
{
126
        BUG_ON(direction == PCI_DMA_NONE);
127
        consistent_sync_page(page, offset, size, direction);
128
        return (page - mem_map) * PAGE_SIZE + PCI_DRAM_OFFSET + offset;
129
}
130
 
131
static inline void pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address,
132
                                  size_t size, int direction)
133
{
134
        if (direction == PCI_DMA_NONE)
135
                BUG();
136
        /* Nothing to do */
137
}
138
 
139
/* Map a set of buffers described by scatterlist in streaming
140
 * mode for DMA.  This is the scather-gather version of the
141
 * above pci_map_single interface.  Here the scatter gather list
142
 * elements are each tagged with the appropriate dma address
143
 * and length.  They are obtained via sg_dma_{address,len}(SG),
144
 * defined in <asm/scatterlist.h>.
145
 *
146
 * NOTE: An implementation may be able to use a smaller number of
147
 *       DMA address/length pairs than there are SG table elements.
148
 *       (for example via virtual mapping capabilities)
149
 *       The routine returns the number of addr/length pairs actually
150
 *       used, at most nents.
151
 *
152
 * Device ownership issues as mentioned above for pci_map_single are
153
 * the same here.
154
 */
155
static inline int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
156
                             int nents, int direction)
157
{
158
        int i;
159
 
160
        if (direction == PCI_DMA_NONE)
161
                BUG();
162
 
163
        /*
164
         * temporary 2.4 hack
165
         */
166
        for (i = 0; i < nents; i++) {
167
                if (sg[i].address && sg[i].page)
168
                        BUG();
169
                else if (!sg[i].address && !sg[i].page)
170
                        BUG();
171
 
172
                if (sg[i].address) {
173
                        consistent_sync(sg[i].address, sg[i].length, direction);
174
                        sg[i].dma_address = virt_to_bus(sg[i].address);
175
                } else {
176
                        consistent_sync_page(sg[i].page, sg[i].offset,
177
                                             sg[i].length, direction);
178
                        sg[i].dma_address = page_to_bus(sg[i].page) + sg[i].offset;
179
                }
180
                sg[i].dma_length = sg[i].length;
181
        }
182
 
183
        return nents;
184
}
185
 
186
/* Unmap a set of streaming mode DMA translations.
187
 * Again, cpu read rules concerning calls here are the same as for
188
 * pci_unmap_single() above.
189
 */
190
static inline void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
191
                                int nents, int direction)
192
{
193
        BUG_ON(direction == PCI_DMA_NONE);
194
        /* nothing to do */
195
}
196
 
197
/* Make physical memory consistent for a single
198
 * streaming mode DMA translation after a transfer.
199
 *
200
 * If you perform a pci_map_single() but wish to interrogate the
201
 * buffer using the cpu, yet do not wish to teardown the PCI dma
202
 * mapping, you must call this function before doing so.  At the
203
 * next point you give the PCI dma address back to the card, the
204
 * device again owns the buffer.
205
 */
206
static inline void pci_dma_sync_single(struct pci_dev *hwdev,
207
                                       dma_addr_t dma_handle,
208
                                       size_t size, int direction)
209
{
210
        BUG_ON(direction == PCI_DMA_NONE);
211
 
212
        consistent_sync(bus_to_virt(dma_handle), size, direction);
213
}
214
 
215
/* Make physical memory consistent for a set of streaming
216
 * mode DMA translations after a transfer.
217
 *
218
 * The same as pci_dma_sync_single but for a scatter-gather list,
219
 * same rules and usage.
220
 */
221
static inline void pci_dma_sync_sg(struct pci_dev *hwdev,
222
                                   struct scatterlist *sg,
223
                                   int nelems, int direction)
224
{
225
        int i;
226
 
227
        BUG_ON(direction == PCI_DMA_NONE);
228
 
229
        for (i = 0; i < nelems; i++, sg++) {
230
                if (sg->address)
231
                        consistent_sync(sg->address, sg->length, direction);
232
                else
233
                        consistent_sync_page(sg->page, sg->offset,
234
                                        sg->length, direction);
235
        }
236
}
237
 
238
/* Return whether the given PCI device DMA address mask can
239
 * be supported properly.  For example, if your device can
240
 * only drive the low 24-bits during PCI bus mastering, then
241
 * you would pass 0x00ffffff as the mask to this function.
242
 */
243
static inline int pci_dma_supported(struct pci_dev *hwdev, u64 mask)
244
{
245
        return 1;
246
}
247
 
248
/*
249
 * At present there are very few 32-bit PPC machines that can have
250
 * memory above the 4GB point, and we don't support that.
251
 */
252
#define pci_dac_dma_supported(pci_dev, mask)    (0)
253
 
254
static __inline__ dma64_addr_t
255
pci_dac_page_to_dma(struct pci_dev *pdev, struct page *page, unsigned long offset, int direction)
256
{
257
        return (dma64_addr_t) page_to_bus(page) + offset;
258
}
259
 
260
static __inline__ struct page *
261
pci_dac_dma_to_page(struct pci_dev *pdev, dma64_addr_t dma_addr)
262
{
263
        return mem_map + (unsigned long)(dma_addr >> PAGE_SHIFT);
264
}
265
 
266
static __inline__ unsigned long
267
pci_dac_dma_to_offset(struct pci_dev *pdev, dma64_addr_t dma_addr)
268
{
269
        return (dma_addr & ~PAGE_MASK);
270
}
271
 
272
static __inline__ void
273
pci_dac_dma_sync_single(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, int direction)
274
{
275
        /* Nothing to do. */
276
}
277
 
278
/* Return the index of the PCI controller for device PDEV. */
279
extern int pci_controller_num(struct pci_dev *pdev);
280
 
281
/* Map a range of PCI memory or I/O space for a device into user space */
282
int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma,
283
                        enum pci_mmap_state mmap_state, int write_combine);
284
 
285
/* Tell drivers/pci/proc.c that we have pci_mmap_page_range() */
286
#define HAVE_PCI_MMAP   1
287
 
288
#endif  /* __KERNEL__ */
289
 
290
#endif /* __PPC_PCI_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.