Merge tag 'trace-v4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
[linux/fpc-iii.git] / arch / alpha / kernel / pci-noop.c
blobb995987b1557e1cb9e4e54bfd0546367f3e58ba4
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * linux/arch/alpha/kernel/pci-noop.c
5 * Stub PCI interfaces for Jensen-specific kernels.
6 */
8 #include <linux/pci.h>
9 #include <linux/init.h>
10 #include <linux/bootmem.h>
11 #include <linux/gfp.h>
12 #include <linux/capability.h>
13 #include <linux/mm.h>
14 #include <linux/errno.h>
15 #include <linux/sched.h>
16 #include <linux/dma-mapping.h>
17 #include <linux/scatterlist.h>
19 #include "proto.h"
23 * The PCI controller list.
26 struct pci_controller *hose_head, **hose_tail = &hose_head;
27 struct pci_controller *pci_isa_hose;
30 struct pci_controller * __init
31 alloc_pci_controller(void)
33 struct pci_controller *hose;
35 hose = alloc_bootmem(sizeof(*hose));
37 *hose_tail = hose;
38 hose_tail = &hose->next;
40 return hose;
43 struct resource * __init
44 alloc_resource(void)
46 return alloc_bootmem(sizeof(struct resource));
49 asmlinkage long
50 sys_pciconfig_iobase(long which, unsigned long bus, unsigned long dfn)
52 struct pci_controller *hose;
54 /* from hose or from bus.devfn */
55 if (which & IOBASE_FROM_HOSE) {
56 for (hose = hose_head; hose; hose = hose->next)
57 if (hose->index == bus)
58 break;
59 if (!hose)
60 return -ENODEV;
61 } else {
62 /* Special hook for ISA access. */
63 if (bus == 0 && dfn == 0)
64 hose = pci_isa_hose;
65 else
66 return -ENODEV;
69 switch (which & ~IOBASE_FROM_HOSE) {
70 case IOBASE_HOSE:
71 return hose->index;
72 case IOBASE_SPARSE_MEM:
73 return hose->sparse_mem_base;
74 case IOBASE_DENSE_MEM:
75 return hose->dense_mem_base;
76 case IOBASE_SPARSE_IO:
77 return hose->sparse_io_base;
78 case IOBASE_DENSE_IO:
79 return hose->dense_io_base;
80 case IOBASE_ROOT_BUS:
81 return hose->bus->number;
84 return -EOPNOTSUPP;
87 asmlinkage long
88 sys_pciconfig_read(unsigned long bus, unsigned long dfn,
89 unsigned long off, unsigned long len, void *buf)
91 if (!capable(CAP_SYS_ADMIN))
92 return -EPERM;
93 else
94 return -ENODEV;
97 asmlinkage long
98 sys_pciconfig_write(unsigned long bus, unsigned long dfn,
99 unsigned long off, unsigned long len, void *buf)
101 if (!capable(CAP_SYS_ADMIN))
102 return -EPERM;
103 else
104 return -ENODEV;
107 static void *alpha_noop_alloc_coherent(struct device *dev, size_t size,
108 dma_addr_t *dma_handle, gfp_t gfp,
109 unsigned long attrs)
111 void *ret;
113 if (!dev || *dev->dma_mask >= 0xffffffffUL)
114 gfp &= ~GFP_DMA;
115 ret = (void *)__get_free_pages(gfp, get_order(size));
116 if (ret) {
117 memset(ret, 0, size);
118 *dma_handle = virt_to_phys(ret);
120 return ret;
123 static int alpha_noop_supported(struct device *dev, u64 mask)
125 return mask < 0x00ffffffUL ? 0 : 1;
128 const struct dma_map_ops alpha_noop_ops = {
129 .alloc = alpha_noop_alloc_coherent,
130 .free = dma_noop_free_coherent,
131 .map_page = dma_noop_map_page,
132 .map_sg = dma_noop_map_sg,
133 .mapping_error = dma_noop_mapping_error,
134 .dma_supported = alpha_noop_supported,
137 const struct dma_map_ops *dma_ops = &alpha_noop_ops;
138 EXPORT_SYMBOL(dma_ops);