blob: 8ac08311f5a51bd765145b461b76864f550d38f1 [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>
FUJITA Tomonori8c8d7212007-11-21 12:26:31 +010015#include <linux/scatterlist.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
17#include "proto.h"
18
19
20/*
21 * The PCI controller list.
22 */
23
24struct pci_controller *hose_head, **hose_tail = &hose_head;
25struct pci_controller *pci_isa_hose;
26
27
28struct pci_controller * __init
29alloc_pci_controller(void)
30{
31 struct pci_controller *hose;
32
33 hose = alloc_bootmem(sizeof(*hose));
34
35 *hose_tail = hose;
36 hose_tail = &hose->next;
37
38 return hose;
39}
40
41struct resource * __init
42alloc_resource(void)
43{
44 struct resource *res;
45
46 res = alloc_bootmem(sizeof(*res));
47
48 return res;
49}
50
51asmlinkage long
52sys_pciconfig_iobase(long which, unsigned long bus, unsigned long dfn)
53{
54 struct pci_controller *hose;
55
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)
60 break;
61 if (!hose)
62 return -ENODEV;
63 } else {
64 /* Special hook for ISA access. */
65 if (bus == 0 && dfn == 0)
66 hose = pci_isa_hose;
67 else
68 return -ENODEV;
69 }
70
71 switch (which & ~IOBASE_FROM_HOSE) {
72 case IOBASE_HOSE:
73 return hose->index;
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;
80 case IOBASE_DENSE_IO:
81 return hose->dense_io_base;
82 case IOBASE_ROOT_BUS:
83 return hose->bus->number;
84 }
85
86 return -EOPNOTSUPP;
87}
88
89asmlinkage long
90sys_pciconfig_read(unsigned long bus, unsigned long dfn,
91 unsigned long off, unsigned long len, void *buf)
92{
93 if (!capable(CAP_SYS_ADMIN))
94 return -EPERM;
95 else
96 return -ENODEV;
97}
98
99asmlinkage long
100sys_pciconfig_write(unsigned long bus, unsigned long dfn,
101 unsigned long off, unsigned long len, void *buf)
102{
103 if (!capable(CAP_SYS_ADMIN))
104 return -EPERM;
105 else
106 return -ENODEV;
107}
108
109/* Stubs for the routines in pci_iommu.c: */
110
111void *
112pci_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_addrp)
113{
114 return NULL;
115}
116
117void
118pci_free_consistent(struct pci_dev *pdev, size_t size, void *cpu_addr,
119 dma_addr_t dma_addr)
120{
121}
122
123dma_addr_t
124pci_map_single(struct pci_dev *pdev, void *cpu_addr, size_t size,
125 int direction)
126{
127 return (dma_addr_t) 0;
128}
129
130void
131pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, size_t size,
132 int direction)
133{
134}
135
136int
137pci_map_sg(struct pci_dev *pdev, struct scatterlist *sg, int nents,
138 int direction)
139{
140 return 0;
141}
142
143void
144pci_unmap_sg(struct pci_dev *pdev, struct scatterlist *sg, int nents,
145 int direction)
146{
147}
148
149int
150pci_dma_supported(struct pci_dev *hwdev, dma_addr_t mask)
151{
152 return 0;
153}
154
155/* Generic DMA mapping functions: */
156
157void *
158dma_alloc_coherent(struct device *dev, size_t size,
Al Viro55c5d742005-10-21 03:21:08 -0400159 dma_addr_t *dma_handle, gfp_t gfp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160{
161 void *ret;
162
163 if (!dev || *dev->dma_mask >= 0xffffffffUL)
164 gfp &= ~GFP_DMA;
165 ret = (void *)__get_free_pages(gfp, get_order(size));
166 if (ret) {
167 memset(ret, 0, size);
FUJITA Tomonorifd2e2632008-02-04 22:30:02 -0800168 *dma_handle = virt_to_phys(ret);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 }
170 return ret;
171}
172
173EXPORT_SYMBOL(dma_alloc_coherent);
174
175int
FUJITA Tomonori8c8d7212007-11-21 12:26:31 +0100176dma_map_sg(struct device *dev, struct scatterlist *sgl, int nents,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 enum dma_data_direction direction)
178{
179 int i;
FUJITA Tomonori8c8d7212007-11-21 12:26:31 +0100180 struct scatterlist *sg;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181
FUJITA Tomonori8c8d7212007-11-21 12:26:31 +0100182 for_each_sg(sgl, sg, nents, i) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 void *va;
184
FUJITA Tomonori8c8d7212007-11-21 12:26:31 +0100185 BUG_ON(!sg_page(sg));
186 va = sg_virt(sg);
FUJITA Tomonorifd2e2632008-02-04 22:30:02 -0800187 sg_dma_address(sg) = (dma_addr_t)virt_to_phys(va);
FUJITA Tomonori8c8d7212007-11-21 12:26:31 +0100188 sg_dma_len(sg) = sg->length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 }
190
191 return nents;
192}
193
194EXPORT_SYMBOL(dma_map_sg);
195
196int
197dma_set_mask(struct device *dev, u64 mask)
198{
199 if (!dev->dma_mask || !dma_supported(dev, mask))
200 return -EIO;
201
202 *dev->dma_mask = mask;
203
204 return 0;
205}
Al Virocff52da2006-10-11 17:40:22 +0100206EXPORT_SYMBOL(dma_set_mask);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207
208void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
209{
210 return NULL;
211}
212
213void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
214{
215}
216
217EXPORT_SYMBOL(pci_iomap);
218EXPORT_SYMBOL(pci_iounmap);