blob: fff5cf93e8164a6a465f5c538d16350d271307e0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/alpha/kernel/pci-noop.c
3 *
4 * Stub PCI interfaces for Jensen-specific kernels.
5 */
6
7#include <linux/pci.h>
8#include <linux/init.h>
9#include <linux/bootmem.h>
Randy Dunlapa9415642006-01-11 12:17:48 -080010#include <linux/capability.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/mm.h>
12#include <linux/errno.h>
13#include <linux/sched.h>
14#include <linux/dma-mapping.h>
15
16#include "proto.h"
17
18
19/*
20 * The PCI controller list.
21 */
22
23struct pci_controller *hose_head, **hose_tail = &hose_head;
24struct pci_controller *pci_isa_hose;
25
26
27struct pci_controller * __init
28alloc_pci_controller(void)
29{
30 struct pci_controller *hose;
31
32 hose = alloc_bootmem(sizeof(*hose));
33
34 *hose_tail = hose;
35 hose_tail = &hose->next;
36
37 return hose;
38}
39
40struct resource * __init
41alloc_resource(void)
42{
43 struct resource *res;
44
45 res = alloc_bootmem(sizeof(*res));
46
47 return res;
48}
49
50asmlinkage long
51sys_pciconfig_iobase(long which, unsigned long bus, unsigned long dfn)
52{
53 struct pci_controller *hose;
54
55 /* from hose or from bus.devfn */
56 if (which & IOBASE_FROM_HOSE) {
57 for (hose = hose_head; hose; hose = hose->next)
58 if (hose->index == bus)
59 break;
60 if (!hose)
61 return -ENODEV;
62 } else {
63 /* Special hook for ISA access. */
64 if (bus == 0 && dfn == 0)
65 hose = pci_isa_hose;
66 else
67 return -ENODEV;
68 }
69
70 switch (which & ~IOBASE_FROM_HOSE) {
71 case IOBASE_HOSE:
72 return hose->index;
73 case IOBASE_SPARSE_MEM:
74 return hose->sparse_mem_base;
75 case IOBASE_DENSE_MEM:
76 return hose->dense_mem_base;
77 case IOBASE_SPARSE_IO:
78 return hose->sparse_io_base;
79 case IOBASE_DENSE_IO:
80 return hose->dense_io_base;
81 case IOBASE_ROOT_BUS:
82 return hose->bus->number;
83 }
84
85 return -EOPNOTSUPP;
86}
87
88asmlinkage long
89sys_pciconfig_read(unsigned long bus, unsigned long dfn,
90 unsigned long off, unsigned long len, void *buf)
91{
92 if (!capable(CAP_SYS_ADMIN))
93 return -EPERM;
94 else
95 return -ENODEV;
96}
97
98asmlinkage long
99sys_pciconfig_write(unsigned long bus, unsigned long dfn,
100 unsigned long off, unsigned long len, void *buf)
101{
102 if (!capable(CAP_SYS_ADMIN))
103 return -EPERM;
104 else
105 return -ENODEV;
106}
107
108/* Stubs for the routines in pci_iommu.c: */
109
110void *
111pci_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_addrp)
112{
113 return NULL;
114}
115
116void
117pci_free_consistent(struct pci_dev *pdev, size_t size, void *cpu_addr,
118 dma_addr_t dma_addr)
119{
120}
121
122dma_addr_t
123pci_map_single(struct pci_dev *pdev, void *cpu_addr, size_t size,
124 int direction)
125{
126 return (dma_addr_t) 0;
127}
128
129void
130pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, size_t size,
131 int direction)
132{
133}
134
135int
136pci_map_sg(struct pci_dev *pdev, struct scatterlist *sg, int nents,
137 int direction)
138{
139 return 0;
140}
141
142void
143pci_unmap_sg(struct pci_dev *pdev, struct scatterlist *sg, int nents,
144 int direction)
145{
146}
147
148int
149pci_dma_supported(struct pci_dev *hwdev, dma_addr_t mask)
150{
151 return 0;
152}
153
154/* Generic DMA mapping functions: */
155
156void *
157dma_alloc_coherent(struct device *dev, size_t size,
Al Viro55c5d742005-10-21 03:21:08 -0400158 dma_addr_t *dma_handle, gfp_t gfp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159{
160 void *ret;
161
162 if (!dev || *dev->dma_mask >= 0xffffffffUL)
163 gfp &= ~GFP_DMA;
164 ret = (void *)__get_free_pages(gfp, get_order(size));
165 if (ret) {
166 memset(ret, 0, size);
167 *dma_handle = virt_to_bus(ret);
168 }
169 return ret;
170}
171
172EXPORT_SYMBOL(dma_alloc_coherent);
173
174int
175dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
176 enum dma_data_direction direction)
177{
178 int i;
179
180 for (i = 0; i < nents; i++ ) {
181 void *va;
182
183 BUG_ON(!sg[i].page);
184 va = page_address(sg[i].page) + sg[i].offset;
185 sg_dma_address(sg + i) = (dma_addr_t)virt_to_bus(va);
186 sg_dma_len(sg + i) = sg[i].length;
187 }
188
189 return nents;
190}
191
192EXPORT_SYMBOL(dma_map_sg);
193
194int
195dma_set_mask(struct device *dev, u64 mask)
196{
197 if (!dev->dma_mask || !dma_supported(dev, mask))
198 return -EIO;
199
200 *dev->dma_mask = mask;
201
202 return 0;
203}
204
205void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
206{
207 return NULL;
208}
209
210void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
211{
212}
213
214EXPORT_SYMBOL(pci_iomap);
215EXPORT_SYMBOL(pci_iounmap);