2 * linux/arch/alpha/kernel/pci-noop.c
4 * Stub PCI interfaces for Jensen-specific kernels.
8 #include <linux/init.h>
9 #include <linux/bootmem.h>
10 #include <linux/capability.h>
12 #include <linux/errno.h>
13 #include <linux/sched.h>
14 #include <linux/dma-mapping.h>
15 #include <linux/scatterlist.h>
21 * The PCI controller list.
24 struct pci_controller *hose_head, **hose_tail = &hose_head;
25 struct pci_controller *pci_isa_hose;
28 struct pci_controller * __init
29 alloc_pci_controller(void)
31 struct pci_controller *hose;
33 hose = alloc_bootmem(sizeof(*hose));
36 hose_tail = &hose->next;
41 struct resource * __init
46 res = alloc_bootmem(sizeof(*res));
52 sys_pciconfig_iobase(long which, unsigned long bus, unsigned long dfn)
54 struct pci_controller *hose;
56 /* from hose or from bus.devfn */
57 if (which & IOBASE_FROM_HOSE) {
58 for (hose = hose_head; hose; hose = hose->next)
59 if (hose->index == bus)
64 /* Special hook for ISA access. */
65 if (bus == 0 && dfn == 0)
71 switch (which & ~IOBASE_FROM_HOSE) {
74 case IOBASE_SPARSE_MEM:
75 return hose->sparse_mem_base;
76 case IOBASE_DENSE_MEM:
77 return hose->dense_mem_base;
78 case IOBASE_SPARSE_IO:
79 return hose->sparse_io_base;
81 return hose->dense_io_base;
83 return hose->bus->number;
90 sys_pciconfig_read(unsigned long bus, unsigned long dfn,
91 unsigned long off, unsigned long len, void *buf)
93 if (!capable(CAP_SYS_ADMIN))
100 sys_pciconfig_write(unsigned long bus, unsigned long dfn,
101 unsigned long off, unsigned long len, void *buf)
103 if (!capable(CAP_SYS_ADMIN))
109 static void *alpha_noop_alloc_coherent(struct device *dev, size_t size,
110 dma_addr_t *dma_handle, gfp_t gfp)
114 if (!dev || *dev->dma_mask >= 0xffffffffUL)
116 ret = (void *)__get_free_pages(gfp, get_order(size));
118 memset(ret, 0, size);
119 *dma_handle = virt_to_phys(ret);
124 static void alpha_noop_free_coherent(struct device *dev, size_t size,
125 void *cpu_addr, dma_addr_t dma_addr)
127 free_pages((unsigned long)cpu_addr, get_order(size));
130 static dma_addr_t alpha_noop_map_page(struct device *dev, struct page *page,
131 unsigned long offset, size_t size,
132 enum dma_data_direction dir,
133 struct dma_attrs *attrs)
135 return page_to_pa(page) + offset;
138 static int alpha_noop_map_sg(struct device *dev, struct scatterlist *sgl, int nents,
139 enum dma_data_direction dir, struct dma_attrs *attrs)
142 struct scatterlist *sg;
144 for_each_sg(sgl, sg, nents, i) {
147 BUG_ON(!sg_page(sg));
149 sg_dma_address(sg) = (dma_addr_t)virt_to_phys(va);
150 sg_dma_len(sg) = sg->length;
156 static int alpha_noop_mapping_error(struct device *dev, dma_addr_t dma_addr)
161 static int alpha_noop_supported(struct device *dev, u64 mask)
163 return mask < 0x00ffffffUL ? 0 : 1;
166 static int alpha_noop_set_mask(struct device *dev, u64 mask)
168 if (!dev->dma_mask || !dma_supported(dev, mask))
171 *dev->dma_mask = mask;
175 struct dma_map_ops alpha_noop_ops = {
176 .alloc_coherent = alpha_noop_alloc_coherent,
177 .free_coherent = alpha_noop_free_coherent,
178 .map_page = alpha_noop_map_page,
179 .map_sg = alpha_noop_map_sg,
180 .mapping_error = alpha_noop_mapping_error,
181 .dma_supported = alpha_noop_supported,
182 .set_dma_mask = alpha_noop_set_mask,
185 struct dma_map_ops *dma_ops = &alpha_noop_ops;
186 EXPORT_SYMBOL(dma_ops);
188 void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
193 void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
197 EXPORT_SYMBOL(pci_iomap);
198 EXPORT_SYMBOL(pci_iounmap);