Merge branch 'upstream-fixes' into upstream
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / alpha / kernel / pci-noop.c
blobfff5cf93e8164a6a465f5c538d16350d271307e0
1 /*
2 * linux/arch/alpha/kernel/pci-noop.c
4 * Stub PCI interfaces for Jensen-specific kernels.
5 */
7 #include <linux/pci.h>
8 #include <linux/init.h>
9 #include <linux/bootmem.h>
10 #include <linux/capability.h>
11 #include <linux/mm.h>
12 #include <linux/errno.h>
13 #include <linux/sched.h>
14 #include <linux/dma-mapping.h>
16 #include "proto.h"
20 * The PCI controller list.
23 struct pci_controller *hose_head, **hose_tail = &hose_head;
24 struct pci_controller *pci_isa_hose;
27 struct pci_controller * __init
28 alloc_pci_controller(void)
30 struct pci_controller *hose;
32 hose = alloc_bootmem(sizeof(*hose));
34 *hose_tail = hose;
35 hose_tail = &hose->next;
37 return hose;
40 struct resource * __init
41 alloc_resource(void)
43 struct resource *res;
45 res = alloc_bootmem(sizeof(*res));
47 return res;
50 asmlinkage long
51 sys_pciconfig_iobase(long which, unsigned long bus, unsigned long dfn)
53 struct pci_controller *hose;
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;
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;
85 return -EOPNOTSUPP;
88 asmlinkage long
89 sys_pciconfig_read(unsigned long bus, unsigned long dfn,
90 unsigned long off, unsigned long len, void *buf)
92 if (!capable(CAP_SYS_ADMIN))
93 return -EPERM;
94 else
95 return -ENODEV;
98 asmlinkage long
99 sys_pciconfig_write(unsigned long bus, unsigned long dfn,
100 unsigned long off, unsigned long len, void *buf)
102 if (!capable(CAP_SYS_ADMIN))
103 return -EPERM;
104 else
105 return -ENODEV;
108 /* Stubs for the routines in pci_iommu.c: */
110 void *
111 pci_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_addrp)
113 return NULL;
116 void
117 pci_free_consistent(struct pci_dev *pdev, size_t size, void *cpu_addr,
118 dma_addr_t dma_addr)
122 dma_addr_t
123 pci_map_single(struct pci_dev *pdev, void *cpu_addr, size_t size,
124 int direction)
126 return (dma_addr_t) 0;
129 void
130 pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, size_t size,
131 int direction)
136 pci_map_sg(struct pci_dev *pdev, struct scatterlist *sg, int nents,
137 int direction)
139 return 0;
142 void
143 pci_unmap_sg(struct pci_dev *pdev, struct scatterlist *sg, int nents,
144 int direction)
149 pci_dma_supported(struct pci_dev *hwdev, dma_addr_t mask)
151 return 0;
154 /* Generic DMA mapping functions: */
156 void *
157 dma_alloc_coherent(struct device *dev, size_t size,
158 dma_addr_t *dma_handle, gfp_t gfp)
160 void *ret;
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);
169 return ret;
172 EXPORT_SYMBOL(dma_alloc_coherent);
175 dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
176 enum dma_data_direction direction)
178 int i;
180 for (i = 0; i < nents; i++ ) {
181 void *va;
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;
189 return nents;
192 EXPORT_SYMBOL(dma_map_sg);
195 dma_set_mask(struct device *dev, u64 mask)
197 if (!dev->dma_mask || !dma_supported(dev, mask))
198 return -EIO;
200 *dev->dma_mask = mask;
202 return 0;
205 void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
207 return NULL;
210 void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
214 EXPORT_SYMBOL(pci_iomap);
215 EXPORT_SYMBOL(pci_iounmap);