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

Subversion Repositories or1k

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

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

Line No. Rev Author Line
1 1275 phoenix
#ifndef __ASM_SH_PCI_H
2
#define __ASM_SH_PCI_H
3
 
4
#ifdef __KERNEL__
5
 
6
#include <linux/config.h>
7
 
8
/* Can be used to override the logic in pci_scan_bus for skipping
9
   already-configured bus numbers - to be used for buggy BIOSes
10
   or architectures with incomplete PCI setup by the loader */
11
 
12
#define pcibios_assign_all_busses()     1
13
#define pcibios_scan_all_fns()          0
14
 
15
#if defined(CONFIG_CPU_SUBTYPE_ST40)
16
/* These are currently the correct values for the ST40 based chips.
17
 * We need some way of setting this on a board specific way, it will
18
 * not be the same on other boards I think
19
 */
20
#define PCIBIOS_MIN_IO          0x2000
21
#define PCIBIOS_MIN_MEM         0x10000000
22
 
23
#elif defined(CONFIG_SH_DREAMCAST)
24
#define PCIBIOS_MIN_IO          0x2000
25
#define PCIBIOS_MIN_MEM         0x10000000
26
#elif defined(CONFIG_SH_BIGSUR) && defined(CONFIG_CPU_SUBTYPE_SH7751)
27
#define PCIBIOS_MIN_IO          0x2000
28
#define PCIBIOS_MIN_MEM         0xFD000000
29
#elif defined(CONFIG_SH_7751_SOLUTION_ENGINE) || defined(CONFIG_SH_SECUREEDGE5410)
30
#define PCIBIOS_MIN_IO          0x4000
31
#define PCIBIOS_MIN_MEM         0xFD000000
32
#elif defined(CONFIG_PCI_SD0001)
33
#define PCIBIOS_MIN_IO          0x2000
34
#define PCIBIOS_MIN_MEM         0x01000000L
35
#endif
36
 
37
struct pci_dev;
38
 
39
extern void pcibios_set_master(struct pci_dev *dev);
40
 
41
static inline void pcibios_penalize_isa_irq(int irq)
42
{
43
        /* We don't do dynamic PCI IRQ allocation */
44
}
45
 
46
/* Dynamic DMA mapping stuff.
47
 * SuperH has everything mapped statically like x86.
48
 */
49
 
50
#include <linux/types.h>
51
#include <linux/slab.h>
52
#include <asm/scatterlist.h>
53
#include <linux/string.h>
54
#include <asm/io.h>
55
 
56
struct pci_dev;
57
 
58
/* The PCI address space does equal the physical memory
59
 * address space.  The networking and block device layers use
60
 * this boolean for bounce buffer decisions.
61
 */
62
#define PCI_DMA_BUS_IS_PHYS     (1)
63
 
64
/* Allocate and map kernel buffer using consistent mode DMA for a device.
65
 * hwdev should be valid struct pci_dev pointer for PCI devices,
66
 * NULL for PCI-like buses (ISA, EISA).
67
 * Returns non-NULL cpu-view pointer to the buffer if successful and
68
 * sets *dma_addrp to the pci side dma address as well, else *dma_addrp
69
 * is undefined.
70
 */
71
extern void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
72
                                  dma_addr_t *dma_handle);
73
 
74
/* Free and unmap a consistent DMA buffer.
75
 * cpu_addr is what was returned from pci_alloc_consistent,
76
 * size must be the same as what as passed into pci_alloc_consistent,
77
 * and likewise dma_addr must be the same as what *dma_addrp was set to.
78
 *
79
 * References to the memory and mappings associated with cpu_addr/dma_addr
80
 * past this call are illegal.
81
 */
82
extern void pci_free_consistent(struct pci_dev *hwdev, size_t size,
83
                                void *vaddr, dma_addr_t dma_handle);
84
 
85
/* Map a single buffer of the indicated size for DMA in streaming mode.
86
 * The 32-bit bus address to use is returned.
87
 *
88
 * Once the device is given the dma address, the device owns this memory
89
 * until either pci_unmap_single or pci_dma_sync_single is performed.
90
 */
91
static inline dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr,
92
                                        size_t size, int direction)
93
{
94
        if (direction == PCI_DMA_NONE)
95
                BUG();
96
 
97
#ifdef CONFIG_SH_PCIDMA_NONCOHERENT
98
        dma_cache_wback_inv(ptr, size);
99
#endif
100
        return virt_to_bus(ptr);
101
}
102
 
103
/* pci_unmap_{single,page} being a nop depends upon the
104
 * configuration.
105
 */
106
#ifdef CONFIG_SH_PCIDMA_NONCOHERENT
107
#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)       \
108
        dma_addr_t ADDR_NAME;
109
#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)         \
110
        __u32 LEN_NAME;
111
#define pci_unmap_addr(PTR, ADDR_NAME)                  \
112
        ((PTR)->ADDR_NAME)
113
#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)         \
114
        (((PTR)->ADDR_NAME) = (VAL))
115
#define pci_unmap_len(PTR, LEN_NAME)                    \
116
        ((PTR)->LEN_NAME)
117
#define pci_unmap_len_set(PTR, LEN_NAME, VAL)           \
118
        (((PTR)->LEN_NAME) = (VAL))
119
#else
120
#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
121
#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
122
#define pci_unmap_addr(PTR, ADDR_NAME)          (0)
123
#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
124
#define pci_unmap_len(PTR, LEN_NAME)            (0)
125
#define pci_unmap_len_set(PTR, LEN_NAME, VAL)   do { } while (0)
126
#endif
127
 
128
/* Unmap a single streaming mode DMA translation.  The dma_addr and size
129
 * must match what was provided for in a previous pci_map_single call.  All
130
 * other usages are undefined.
131
 *
132
 * After this call, reads by the cpu to the buffer are guarenteed to see
133
 * whatever the device wrote there.
134
 */
135
static inline void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
136
                                    size_t size,int direction)
137
{
138
        /* Nothing to do */
139
}
140
 
141
/* Map a set of buffers described by scatterlist in streaming
142
 * mode for DMA.  This is the scather-gather version of the
143
 * above pci_map_single interface.  Here the scatter gather list
144
 * elements are each tagged with the appropriate dma address
145
 * and length.  They are obtained via sg_dma_{address,length}(SG).
146
 *
147
 * NOTE: An implementation may be able to use a smaller number of
148
 *       DMA address/length pairs than there are SG table elements.
149
 *       (for example via virtual mapping capabilities)
150
 *       The routine returns the number of addr/length pairs actually
151
 *       used, at most nents.
152
 *
153
 * Device ownership issues as mentioned above for pci_map_single are
154
 * the same here.
155
 */
156
static inline int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
157
                             int nents, int direction)
158
{
159
#ifdef CONFIG_SH_PCIDMA_NONCOHERENT
160
        int i;
161
 
162
        for (i=0; i<nents; i++)
163
                dma_cache_wback_inv(sg[i].address, sg[i].length);
164
#endif
165
        if (direction == PCI_DMA_NONE)
166
                BUG();
167
 
168
        return nents;
169
}
170
 
171
/* Unmap a set of streaming mode DMA translations.
172
 * Again, cpu read rules concerning calls here are the same as for
173
 * pci_unmap_single() above.
174
 */
175
static inline void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
176
                                int nents, int direction)
177
{
178
        /* Nothing to do */
179
}
180
 
181
/* Make physical memory consistent for a single
182
 * streaming mode DMA translation after a transfer.
183
 *
184
 * If you perform a pci_map_single() but wish to interrogate the
185
 * buffer using the cpu, yet do not wish to teardown the PCI dma
186
 * mapping, you must call this function before doing so.  At the
187
 * next point you give the PCI dma address back to the card, the
188
 * device again owns the buffer.
189
 */
190
static inline void pci_dma_sync_single(struct pci_dev *hwdev,
191
                                       dma_addr_t dma_handle,
192
                                       size_t size, int direction)
193
{
194
        if (direction == PCI_DMA_NONE)
195
                BUG();
196
 
197
#ifdef CONFIG_SH_PCIDMA_NONCOHERENT
198
        dma_cache_wback_inv(bus_to_virt(dma_handle), size);
199
#endif
200
 
201
}
202
 
203
/* Make physical memory consistent for a set of streaming
204
 * mode DMA translations after a transfer.
205
 *
206
 * The same as pci_dma_sync_single but for a scatter-gather list,
207
 * same rules and usage.
208
 */
209
static inline void pci_dma_sync_sg(struct pci_dev *hwdev,
210
                                   struct scatterlist *sg,
211
                                   int nelems, int direction)
212
{
213
        if (direction == PCI_DMA_NONE)
214
                BUG();
215
 
216
#ifdef CONFIG_SH_PCIDMA_NONCOHERENT
217
        int i;
218
 
219
        for (i=0; i<nelems; i++)
220
                dma_cache_wback_inv(sg[i].address, sg[i].length);
221
#endif
222
}
223
 
224
 
225
/* Return whether the given PCI device DMA address mask can
226
 * be supported properly.  For example, if your device can
227
 * only drive the low 24-bits during PCI bus mastering, then
228
 * you would pass 0x00ffffff as the mask to this function.
229
 */
230
static inline int pci_dma_supported(struct pci_dev *hwdev, u64 mask)
231
{
232
        return 1;
233
}
234
 
235
/* Not supporting more than 32-bit PCI bus addresses now, but
236
 * must satisfy references to this function.  Change if needed.
237
 */
238
#define pci_dac_dma_supported(pci_dev, mask) (0)
239
 
240
/* Return the index of the PCI controller for device PDEV. */
241
#define pci_controller_num(PDEV)        (0)
242
 
243
/* These macros should be used after a pci_map_sg call has been done
244
 * to get bus addresses of each of the SG entries and their lengths.
245
 * You should only work with the number of sg entries pci_map_sg
246
 * returns, or alternatively stop on the first sg_dma_len(sg) which
247
 * is 0.
248
 */
249
#define sg_dma_address(sg)      (virt_to_bus((sg)->address))
250
#define sg_dma_len(sg)          ((sg)->length)
251
 
252
#endif /* __KERNEL__ */
253
 
254
 
255
#endif /* __ASM_SH_PCI_H */
256
 

powered by: WebSVN 2.1.0

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