blob: 6f3788e3363e32f82f069692cfa5568a6f13c59c [file] [log] [blame]
Jan Glaubercd248342012-11-29 12:50:30 +01001/*
2 * Copyright IBM Corp. 2012
3 *
4 * Author(s):
5 * Jan Glauber <jang@linux.vnet.ibm.com>
6 *
7 * The System z PCI code is a rewrite from a prototype by
8 * the following people (Kudoz!):
Jan Glauberbedef752012-12-06 14:06:28 +01009 * Alexander Schmidt
10 * Christoph Raisch
11 * Hannes Hering
12 * Hoang-Nam Nguyen
13 * Jan-Bernd Themann
14 * Stefan Roscher
15 * Thomas Klein
Jan Glaubercd248342012-11-29 12:50:30 +010016 */
17
18#define COMPONENT "zPCI"
19#define pr_fmt(fmt) COMPONENT ": " fmt
20
21#include <linux/kernel.h>
22#include <linux/slab.h>
23#include <linux/err.h>
24#include <linux/export.h>
25#include <linux/delay.h>
Jan Glauber9a4da8a2012-11-29 13:05:05 +010026#include <linux/irq.h>
27#include <linux/kernel_stat.h>
Jan Glaubercd248342012-11-29 12:50:30 +010028#include <linux/seq_file.h>
29#include <linux/pci.h>
30#include <linux/msi.h>
31
Jan Glauber9a4da8a2012-11-29 13:05:05 +010032#include <asm/isc.h>
33#include <asm/airq.h>
Jan Glaubercd248342012-11-29 12:50:30 +010034#include <asm/facility.h>
35#include <asm/pci_insn.h>
Jan Glaubera755a452012-11-29 12:55:21 +010036#include <asm/pci_clp.h>
Jan Glauber828b35f2012-11-29 14:33:30 +010037#include <asm/pci_dma.h>
Jan Glaubercd248342012-11-29 12:50:30 +010038
39#define DEBUG /* enable pr_debug */
40
Jan Glauber9a4da8a2012-11-29 13:05:05 +010041#define SIC_IRQ_MODE_ALL 0
42#define SIC_IRQ_MODE_SINGLE 1
43
Jan Glaubercd248342012-11-29 12:50:30 +010044#define ZPCI_NR_DMA_SPACES 1
45#define ZPCI_NR_DEVICES CONFIG_PCI_NR_FUNCTIONS
46
47/* list of all detected zpci devices */
Sebastian Ott67f43f32013-08-29 19:33:16 +020048static LIST_HEAD(zpci_list);
Sebastian Ott57b59182013-08-29 19:40:01 +020049static DEFINE_SPINLOCK(zpci_list_lock);
Martin Schwidefsky1f44a222013-06-27 09:01:09 +020050
51static void zpci_enable_irq(struct irq_data *data);
52static void zpci_disable_irq(struct irq_data *data);
53
54static struct irq_chip zpci_irq_chip = {
55 .name = "zPCI",
56 .irq_unmask = zpci_enable_irq,
57 .irq_mask = zpci_disable_irq,
58};
59
Jan Glaubercd248342012-11-29 12:50:30 +010060static DECLARE_BITMAP(zpci_domain, ZPCI_NR_DEVICES);
61static DEFINE_SPINLOCK(zpci_domain_lock);
62
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +020063static struct airq_iv *zpci_aisb_iv;
Martin Schwidefsky1f44a222013-06-27 09:01:09 +020064static struct airq_iv *zpci_aibv[ZPCI_NR_DEVICES];
Jan Glauber9a4da8a2012-11-29 13:05:05 +010065
Martin Schwidefskyf4eae942013-06-24 10:30:41 +020066/* Adapter interrupt definitions */
67static void zpci_irq_handler(struct airq_struct *airq);
68
69static struct airq_struct zpci_airq = {
70 .handler = zpci_irq_handler,
71 .isc = PCI_ISC,
72};
Jan Glauber9a4da8a2012-11-29 13:05:05 +010073
Jan Glaubercd248342012-11-29 12:50:30 +010074/* I/O Map */
75static DEFINE_SPINLOCK(zpci_iomap_lock);
76static DECLARE_BITMAP(zpci_iomap, ZPCI_IOMAP_MAX_ENTRIES);
77struct zpci_iomap_entry *zpci_iomap_start;
78EXPORT_SYMBOL_GPL(zpci_iomap_start);
79
Jan Glauberd0b08852012-12-11 14:53:35 +010080static struct kmem_cache *zdev_fmb_cache;
81
Jan Glaubercd248342012-11-29 12:50:30 +010082struct zpci_dev *get_zdev(struct pci_dev *pdev)
83{
84 return (struct zpci_dev *) pdev->sysdata;
85}
86
87struct zpci_dev *get_zdev_by_fid(u32 fid)
88{
89 struct zpci_dev *tmp, *zdev = NULL;
90
Sebastian Ott57b59182013-08-29 19:40:01 +020091 spin_lock(&zpci_list_lock);
Jan Glaubercd248342012-11-29 12:50:30 +010092 list_for_each_entry(tmp, &zpci_list, entry) {
93 if (tmp->fid == fid) {
94 zdev = tmp;
95 break;
96 }
97 }
Sebastian Ott57b59182013-08-29 19:40:01 +020098 spin_unlock(&zpci_list_lock);
Jan Glaubercd248342012-11-29 12:50:30 +010099 return zdev;
100}
101
Jan Glaubercd248342012-11-29 12:50:30 +0100102static struct zpci_dev *get_zdev_by_bus(struct pci_bus *bus)
103{
104 return (bus && bus->sysdata) ? (struct zpci_dev *) bus->sysdata : NULL;
105}
106
107int pci_domain_nr(struct pci_bus *bus)
108{
109 return ((struct zpci_dev *) bus->sysdata)->domain;
110}
111EXPORT_SYMBOL_GPL(pci_domain_nr);
112
113int pci_proc_domain(struct pci_bus *bus)
114{
115 return pci_domain_nr(bus);
116}
117EXPORT_SYMBOL_GPL(pci_proc_domain);
118
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100119/* Modify PCI: Register adapter interruptions */
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200120static int zpci_set_airq(struct zpci_dev *zdev)
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100121{
122 u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_REG_INT);
Sebastian Ottcb4deb62013-10-22 15:19:24 +0200123 struct zpci_fib fib = {0};
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100124
Sebastian Ottcb4deb62013-10-22 15:19:24 +0200125 fib.isc = PCI_ISC;
126 fib.sum = 1; /* enable summary notifications */
127 fib.noi = airq_iv_end(zdev->aibv);
128 fib.aibv = (unsigned long) zdev->aibv->vector;
129 fib.aibvo = 0; /* each zdev has its own interrupt vector */
130 fib.aisb = (unsigned long) zpci_aisb_iv->vector + (zdev->aisb/64)*8;
131 fib.aisbo = zdev->aisb & 63;
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100132
Sebastian Ottcb4deb62013-10-22 15:19:24 +0200133 return zpci_mod_fc(req, &fib);
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100134}
135
136struct mod_pci_args {
137 u64 base;
138 u64 limit;
139 u64 iota;
Jan Glauberd0b08852012-12-11 14:53:35 +0100140 u64 fmb_addr;
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100141};
142
143static int mod_pci(struct zpci_dev *zdev, int fn, u8 dmaas, struct mod_pci_args *args)
144{
145 u64 req = ZPCI_CREATE_REQ(zdev->fh, dmaas, fn);
Sebastian Ottcb4deb62013-10-22 15:19:24 +0200146 struct zpci_fib fib = {0};
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100147
Sebastian Ottcb4deb62013-10-22 15:19:24 +0200148 fib.pba = args->base;
149 fib.pal = args->limit;
150 fib.iota = args->iota;
151 fib.fmb_addr = args->fmb_addr;
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100152
Sebastian Ottcb4deb62013-10-22 15:19:24 +0200153 return zpci_mod_fc(req, &fib);
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100154}
155
Jan Glauber828b35f2012-11-29 14:33:30 +0100156/* Modify PCI: Register I/O address translation parameters */
157int zpci_register_ioat(struct zpci_dev *zdev, u8 dmaas,
158 u64 base, u64 limit, u64 iota)
159{
Jan Glauberd0b08852012-12-11 14:53:35 +0100160 struct mod_pci_args args = { base, limit, iota, 0 };
Jan Glauber828b35f2012-11-29 14:33:30 +0100161
162 WARN_ON_ONCE(iota & 0x3fff);
163 args.iota |= ZPCI_IOTA_RTTO_FLAG;
164 return mod_pci(zdev, ZPCI_MOD_FC_REG_IOAT, dmaas, &args);
165}
166
167/* Modify PCI: Unregister I/O address translation parameters */
168int zpci_unregister_ioat(struct zpci_dev *zdev, u8 dmaas)
169{
Jan Glauberd0b08852012-12-11 14:53:35 +0100170 struct mod_pci_args args = { 0, 0, 0, 0 };
Jan Glauber828b35f2012-11-29 14:33:30 +0100171
172 return mod_pci(zdev, ZPCI_MOD_FC_DEREG_IOAT, dmaas, &args);
173}
174
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100175/* Modify PCI: Unregister adapter interruptions */
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200176static int zpci_clear_airq(struct zpci_dev *zdev)
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100177{
Jan Glauberd0b08852012-12-11 14:53:35 +0100178 struct mod_pci_args args = { 0, 0, 0, 0 };
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100179
180 return mod_pci(zdev, ZPCI_MOD_FC_DEREG_INT, 0, &args);
181}
182
Jan Glauberd0b08852012-12-11 14:53:35 +0100183/* Modify PCI: Set PCI function measurement parameters */
184int zpci_fmb_enable_device(struct zpci_dev *zdev)
185{
186 struct mod_pci_args args = { 0, 0, 0, 0 };
187
188 if (zdev->fmb)
189 return -EINVAL;
190
Wei Yongjun08b42122013-02-25 22:09:25 +0800191 zdev->fmb = kmem_cache_zalloc(zdev_fmb_cache, GFP_KERNEL);
Jan Glauberd0b08852012-12-11 14:53:35 +0100192 if (!zdev->fmb)
193 return -ENOMEM;
Jan Glauberd0b08852012-12-11 14:53:35 +0100194 WARN_ON((u64) zdev->fmb & 0xf);
195
196 args.fmb_addr = virt_to_phys(zdev->fmb);
197 return mod_pci(zdev, ZPCI_MOD_FC_SET_MEASURE, 0, &args);
198}
199
200/* Modify PCI: Disable PCI function measurement */
201int zpci_fmb_disable_device(struct zpci_dev *zdev)
202{
203 struct mod_pci_args args = { 0, 0, 0, 0 };
204 int rc;
205
206 if (!zdev->fmb)
207 return -EINVAL;
208
209 /* Function measurement is disabled if fmb address is zero */
210 rc = mod_pci(zdev, ZPCI_MOD_FC_SET_MEASURE, 0, &args);
211
212 kmem_cache_free(zdev_fmb_cache, zdev->fmb);
213 zdev->fmb = NULL;
214 return rc;
215}
216
Jan Glaubercd248342012-11-29 12:50:30 +0100217#define ZPCI_PCIAS_CFGSPC 15
218
219static int zpci_cfg_load(struct zpci_dev *zdev, int offset, u32 *val, u8 len)
220{
221 u64 req = ZPCI_CREATE_REQ(zdev->fh, ZPCI_PCIAS_CFGSPC, len);
222 u64 data;
223 int rc;
224
Martin Schwidefsky93893392013-06-25 14:52:23 +0200225 rc = zpci_load(&data, req, offset);
Sebastian Ottb170bad2013-04-16 14:17:15 +0200226 if (!rc) {
227 data = data << ((8 - len) * 8);
228 data = le64_to_cpu(data);
Jan Glaubercd248342012-11-29 12:50:30 +0100229 *val = (u32) data;
Sebastian Ottb170bad2013-04-16 14:17:15 +0200230 } else
Jan Glaubercd248342012-11-29 12:50:30 +0100231 *val = 0xffffffff;
232 return rc;
233}
234
235static int zpci_cfg_store(struct zpci_dev *zdev, int offset, u32 val, u8 len)
236{
237 u64 req = ZPCI_CREATE_REQ(zdev->fh, ZPCI_PCIAS_CFGSPC, len);
238 u64 data = val;
239 int rc;
240
241 data = cpu_to_le64(data);
242 data = data >> ((8 - len) * 8);
Martin Schwidefsky93893392013-06-25 14:52:23 +0200243 rc = zpci_store(data, req, offset);
Jan Glaubercd248342012-11-29 12:50:30 +0100244 return rc;
245}
246
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200247static int zpci_msi_set_mask_bits(struct msi_desc *msi, u32 mask, u32 flag)
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100248{
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200249 int offset, pos;
250 u32 mask_bits;
251
252 if (msi->msi_attrib.is_msix) {
253 offset = msi->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE +
254 PCI_MSIX_ENTRY_VECTOR_CTRL;
255 msi->masked = readl(msi->mask_base + offset);
256 writel(flag, msi->mask_base + offset);
257 } else if (msi->msi_attrib.maskbit) {
258 pos = (long) msi->mask_base;
259 pci_read_config_dword(msi->dev, pos, &mask_bits);
260 mask_bits &= ~(mask);
261 mask_bits |= flag & mask;
262 pci_write_config_dword(msi->dev, pos, mask_bits);
263 } else
264 return 0;
265
266 msi->msi_attrib.maskbit = !!flag;
267 return 1;
268}
269
270static void zpci_enable_irq(struct irq_data *data)
271{
272 struct msi_desc *msi = irq_get_msi_desc(data->irq);
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100273
274 zpci_msi_set_mask_bits(msi, 1, 0);
275}
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100276
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200277static void zpci_disable_irq(struct irq_data *data)
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100278{
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200279 struct msi_desc *msi = irq_get_msi_desc(data->irq);
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100280
281 zpci_msi_set_mask_bits(msi, 1, 1);
282}
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100283
Greg Kroah-Hartmanb881bc42012-12-21 14:06:37 -0800284void pcibios_fixup_bus(struct pci_bus *bus)
Jan Glaubercd248342012-11-29 12:50:30 +0100285{
286}
287
288resource_size_t pcibios_align_resource(void *data, const struct resource *res,
289 resource_size_t size,
290 resource_size_t align)
291{
292 return 0;
293}
294
Jan Glauber87bc3592012-12-06 14:30:28 +0100295/* combine single writes by using store-block insn */
296void __iowrite64_copy(void __iomem *to, const void *from, size_t count)
297{
298 zpci_memcpy_toio(to, from, count);
299}
300
Jan Glaubercd248342012-11-29 12:50:30 +0100301/* Create a virtual mapping cookie for a PCI BAR */
302void __iomem *pci_iomap(struct pci_dev *pdev, int bar, unsigned long max)
303{
304 struct zpci_dev *zdev = get_zdev(pdev);
305 u64 addr;
306 int idx;
307
308 if ((bar & 7) != bar)
309 return NULL;
310
311 idx = zdev->bars[bar].map_idx;
312 spin_lock(&zpci_iomap_lock);
313 zpci_iomap_start[idx].fh = zdev->fh;
314 zpci_iomap_start[idx].bar = bar;
315 spin_unlock(&zpci_iomap_lock);
316
317 addr = ZPCI_IOMAP_ADDR_BASE | ((u64) idx << 48);
318 return (void __iomem *) addr;
319}
320EXPORT_SYMBOL_GPL(pci_iomap);
321
322void pci_iounmap(struct pci_dev *pdev, void __iomem *addr)
323{
324 unsigned int idx;
325
326 idx = (((__force u64) addr) & ~ZPCI_IOMAP_ADDR_BASE) >> 48;
327 spin_lock(&zpci_iomap_lock);
328 zpci_iomap_start[idx].fh = 0;
329 zpci_iomap_start[idx].bar = 0;
330 spin_unlock(&zpci_iomap_lock);
331}
332EXPORT_SYMBOL_GPL(pci_iounmap);
333
334static int pci_read(struct pci_bus *bus, unsigned int devfn, int where,
335 int size, u32 *val)
336{
337 struct zpci_dev *zdev = get_zdev_by_bus(bus);
Sebastian Ott2c3700b2013-04-16 14:18:41 +0200338 int ret;
Jan Glaubercd248342012-11-29 12:50:30 +0100339
340 if (!zdev || devfn != ZPCI_DEVFN)
Sebastian Ott2c3700b2013-04-16 14:18:41 +0200341 ret = -ENODEV;
342 else
343 ret = zpci_cfg_load(zdev, where, val, size);
344
345 return ret;
Jan Glaubercd248342012-11-29 12:50:30 +0100346}
347
348static int pci_write(struct pci_bus *bus, unsigned int devfn, int where,
349 int size, u32 val)
350{
351 struct zpci_dev *zdev = get_zdev_by_bus(bus);
Sebastian Ott2c3700b2013-04-16 14:18:41 +0200352 int ret;
Jan Glaubercd248342012-11-29 12:50:30 +0100353
354 if (!zdev || devfn != ZPCI_DEVFN)
Sebastian Ott2c3700b2013-04-16 14:18:41 +0200355 ret = -ENODEV;
356 else
357 ret = zpci_cfg_store(zdev, where, val, size);
358
359 return ret;
Jan Glaubercd248342012-11-29 12:50:30 +0100360}
361
362static struct pci_ops pci_root_ops = {
363 .read = pci_read,
364 .write = pci_write,
365};
366
Martin Schwidefskyf4eae942013-06-24 10:30:41 +0200367static void zpci_irq_handler(struct airq_struct *airq)
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100368{
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200369 unsigned long si, ai;
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200370 struct airq_iv *aibv;
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200371 int irqs_on = 0;
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100372
Heiko Carstens420f42e2013-01-02 15:18:18 +0100373 inc_irq_stat(IRQIO_PCI);
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200374 for (si = 0;;) {
375 /* Scan adapter summary indicator bit vector */
376 si = airq_iv_scan(zpci_aisb_iv, si, airq_iv_end(zpci_aisb_iv));
377 if (si == -1UL) {
378 if (irqs_on++)
379 /* End of second scan with interrupts on. */
380 break;
381 /* First scan complete, reenable interrupts. */
382 zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC);
383 si = 0;
384 continue;
385 }
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100386
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200387 /* Scan the adapter interrupt vector for this device. */
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200388 aibv = zpci_aibv[si];
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200389 for (ai = 0;;) {
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200390 ai = airq_iv_scan(aibv, ai, airq_iv_end(aibv));
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200391 if (ai == -1UL)
392 break;
Heiko Carstens420f42e2013-01-02 15:18:18 +0100393 inc_irq_stat(IRQIO_MSI);
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200394 airq_iv_lock(aibv, ai);
395 generic_handle_irq(airq_iv_get_data(aibv, ai));
396 airq_iv_unlock(aibv, ai);
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100397 }
398 }
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100399}
400
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200401int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100402{
403 struct zpci_dev *zdev = get_zdev(pdev);
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200404 unsigned int hwirq, irq, msi_vecs;
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200405 unsigned long aisb;
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100406 struct msi_desc *msi;
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200407 struct msi_msg msg;
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100408 int rc;
409
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200410 if (type != PCI_CAP_ID_MSIX && type != PCI_CAP_ID_MSI)
411 return -EINVAL;
Alexander Gordeeva384c892013-12-16 09:34:54 +0100412 if (type == PCI_CAP_ID_MSI && nvec > 1)
413 return 1;
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200414 msi_vecs = min(nvec, ZPCI_MSI_VEC_MAX);
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200415 msi_vecs = min_t(unsigned int, msi_vecs, CONFIG_PCI_NR_MSI);
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100416
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200417 /* Allocate adapter summary indicator bit */
418 rc = -EIO;
419 aisb = airq_iv_alloc_bit(zpci_aisb_iv);
420 if (aisb == -1UL)
421 goto out;
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100422 zdev->aisb = aisb;
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100423
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200424 /* Create adapter interrupt vector */
425 rc = -ENOMEM;
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200426 zdev->aibv = airq_iv_create(msi_vecs, AIRQ_IV_DATA | AIRQ_IV_BITLOCK);
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200427 if (!zdev->aibv)
428 goto out_si;
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100429
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200430 /* Wire up shortcut pointer */
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200431 zpci_aibv[aisb] = zdev->aibv;
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200432
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200433 /* Request MSI interrupts */
434 hwirq = 0;
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100435 list_for_each_entry(msi, &pdev->msi_list, list) {
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200436 rc = -EIO;
437 irq = irq_alloc_desc(0); /* Alloc irq on node 0 */
438 if (irq == NO_IRQ)
439 goto out_msi;
440 rc = irq_set_msi_desc(irq, msi);
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100441 if (rc)
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200442 goto out_msi;
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200443 irq_set_chip_and_handler(irq, &zpci_irq_chip,
444 handle_simple_irq);
445 msg.data = hwirq;
446 msg.address_lo = zdev->msi_addr & 0xffffffff;
447 msg.address_hi = zdev->msi_addr >> 32;
448 write_msi_msg(irq, &msg);
449 airq_iv_set_data(zdev->aibv, hwirq, irq);
450 hwirq++;
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100451 }
452
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200453 /* Enable adapter interrupts */
454 rc = zpci_set_airq(zdev);
455 if (rc)
456 goto out_msi;
457
458 return (msi_vecs == nvec) ? 0 : msi_vecs;
459
460out_msi:
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200461 list_for_each_entry(msi, &pdev->msi_list, list) {
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200462 if (hwirq-- == 0)
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200463 break;
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200464 irq_set_msi_desc(msi->irq, NULL);
465 irq_free_desc(msi->irq);
466 msi->msg.address_lo = 0;
467 msi->msg.address_hi = 0;
468 msi->msg.data = 0;
469 msi->irq = 0;
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100470 }
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200471 zpci_aibv[aisb] = NULL;
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200472 airq_iv_release(zdev->aibv);
473out_si:
474 airq_iv_free_bit(zpci_aisb_iv, aisb);
475out:
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200476 return rc;
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100477}
478
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200479void arch_teardown_msi_irqs(struct pci_dev *pdev)
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100480{
481 struct zpci_dev *zdev = get_zdev(pdev);
482 struct msi_desc *msi;
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200483 int rc;
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100484
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200485 /* Disable adapter interrupts */
486 rc = zpci_clear_airq(zdev);
Sebastian Ott1f1dcbd2013-10-22 15:17:19 +0200487 if (rc)
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100488 return;
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100489
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200490 /* Release MSI interrupts */
491 list_for_each_entry(msi, &pdev->msi_list, list) {
492 zpci_msi_set_mask_bits(msi, 1, 1);
493 irq_set_msi_desc(msi->irq, NULL);
494 irq_free_desc(msi->irq);
495 msi->msg.address_lo = 0;
496 msi->msg.address_hi = 0;
497 msi->msg.data = 0;
498 msi->irq = 0;
499 }
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100500
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200501 zpci_aibv[zdev->aisb] = NULL;
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200502 airq_iv_release(zdev->aibv);
503 airq_iv_free_bit(zpci_aisb_iv, zdev->aisb);
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100504}
505
Jan Glaubercd248342012-11-29 12:50:30 +0100506static void zpci_map_resources(struct zpci_dev *zdev)
507{
508 struct pci_dev *pdev = zdev->pdev;
509 resource_size_t len;
510 int i;
511
512 for (i = 0; i < PCI_BAR_COUNT; i++) {
513 len = pci_resource_len(pdev, i);
514 if (!len)
515 continue;
516 pdev->resource[i].start = (resource_size_t) pci_iomap(pdev, i, 0);
517 pdev->resource[i].end = pdev->resource[i].start + len - 1;
Jan Glaubercd248342012-11-29 12:50:30 +0100518 }
Sebastian Ott944239c2013-06-05 16:06:16 +0200519}
520
521static void zpci_unmap_resources(struct zpci_dev *zdev)
522{
523 struct pci_dev *pdev = zdev->pdev;
524 resource_size_t len;
525 int i;
526
527 for (i = 0; i < PCI_BAR_COUNT; i++) {
528 len = pci_resource_len(pdev, i);
529 if (!len)
530 continue;
531 pci_iounmap(pdev, (void *) pdev->resource[i].start);
532 }
533}
Jan Glaubercd248342012-11-29 12:50:30 +0100534
Jan Glauber1e8da952012-11-29 14:36:55 +0100535int pcibios_add_platform_entries(struct pci_dev *pdev)
536{
537 return zpci_sysfs_add_device(&pdev->dev);
538}
539
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100540static int __init zpci_irq_init(void)
541{
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200542 int rc;
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100543
Martin Schwidefskyf4eae942013-06-24 10:30:41 +0200544 rc = register_adapter_interrupt(&zpci_airq);
545 if (rc)
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200546 goto out;
Martin Schwidefskyf4eae942013-06-24 10:30:41 +0200547 /* Set summary to 1 to be called every time for the ISC. */
548 *zpci_airq.lsi_ptr = 1;
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100549
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200550 rc = -ENOMEM;
551 zpci_aisb_iv = airq_iv_create(ZPCI_NR_DEVICES, AIRQ_IV_ALLOC);
552 if (!zpci_aisb_iv)
553 goto out_airq;
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100554
Martin Schwidefsky93893392013-06-25 14:52:23 +0200555 zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC);
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100556 return 0;
557
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200558out_airq:
559 unregister_adapter_interrupt(&zpci_airq);
560out:
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100561 return rc;
562}
563
564static void zpci_irq_exit(void)
565{
Martin Schwidefsky5d0d8f42013-06-25 16:36:29 +0200566 airq_iv_release(zpci_aisb_iv);
Martin Schwidefskyf4eae942013-06-24 10:30:41 +0200567 unregister_adapter_interrupt(&zpci_airq);
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100568}
569
Jan Glaubercd248342012-11-29 12:50:30 +0100570static int zpci_alloc_iomap(struct zpci_dev *zdev)
571{
572 int entry;
573
574 spin_lock(&zpci_iomap_lock);
575 entry = find_first_zero_bit(zpci_iomap, ZPCI_IOMAP_MAX_ENTRIES);
576 if (entry == ZPCI_IOMAP_MAX_ENTRIES) {
577 spin_unlock(&zpci_iomap_lock);
578 return -ENOSPC;
579 }
580 set_bit(entry, zpci_iomap);
581 spin_unlock(&zpci_iomap_lock);
582 return entry;
583}
584
585static void zpci_free_iomap(struct zpci_dev *zdev, int entry)
586{
587 spin_lock(&zpci_iomap_lock);
588 memset(&zpci_iomap_start[entry], 0, sizeof(struct zpci_iomap_entry));
589 clear_bit(entry, zpci_iomap);
590 spin_unlock(&zpci_iomap_lock);
591}
592
Sebastian Ott7a572a3a2013-11-12 19:33:06 +0100593static struct resource *__alloc_res(struct zpci_dev *zdev, unsigned long start,
594 unsigned long size, unsigned long flags)
595{
596 struct resource *r;
597
598 r = kzalloc(sizeof(*r), GFP_KERNEL);
599 if (!r)
600 return NULL;
601
602 r->start = start;
603 r->end = r->start + size - 1;
604 r->flags = flags;
605 r->name = zdev->res_name;
606
607 if (request_resource(&iomem_resource, r)) {
608 kfree(r);
609 return NULL;
610 }
611 return r;
612}
613
614static int zpci_setup_bus_resources(struct zpci_dev *zdev,
615 struct list_head *resources)
616{
617 unsigned long addr, size, flags;
618 struct resource *res;
619 int i, entry;
620
621 snprintf(zdev->res_name, sizeof(zdev->res_name),
622 "PCI Bus %04x:%02x", zdev->domain, ZPCI_BUS_NR);
623
624 for (i = 0; i < PCI_BAR_COUNT; i++) {
625 if (!zdev->bars[i].size)
626 continue;
627 entry = zpci_alloc_iomap(zdev);
628 if (entry < 0)
629 return entry;
630 zdev->bars[i].map_idx = entry;
631
632 /* only MMIO is supported */
633 flags = IORESOURCE_MEM;
634 if (zdev->bars[i].val & 8)
635 flags |= IORESOURCE_PREFETCH;
636 if (zdev->bars[i].val & 4)
637 flags |= IORESOURCE_MEM_64;
638
639 addr = ZPCI_IOMAP_ADDR_BASE + ((u64) entry << 48);
640
641 size = 1UL << zdev->bars[i].size;
642
643 res = __alloc_res(zdev, addr, size, flags);
644 if (!res) {
645 zpci_free_iomap(zdev, entry);
646 return -ENOMEM;
647 }
648 zdev->bars[i].res = res;
649 pci_add_resource(resources, res);
650 }
651
652 return 0;
653}
654
655static void zpci_cleanup_bus_resources(struct zpci_dev *zdev)
656{
657 int i;
658
659 for (i = 0; i < PCI_BAR_COUNT; i++) {
660 if (!zdev->bars[i].size)
661 continue;
662
663 zpci_free_iomap(zdev, zdev->bars[i].map_idx);
664 release_resource(zdev->bars[i].res);
665 kfree(zdev->bars[i].res);
666 }
667}
668
Sebastian Ottaf0a8a82013-04-16 14:13:21 +0200669int pcibios_add_device(struct pci_dev *pdev)
670{
671 struct zpci_dev *zdev = get_zdev(pdev);
Sebastian Ottcb809182013-08-29 19:34:37 +0200672 struct resource *res;
673 int i;
674
675 zdev->pdev = pdev;
676 zpci_map_resources(zdev);
677
678 for (i = 0; i < PCI_BAR_COUNT; i++) {
679 res = &pdev->resource[i];
680 if (res->parent || !res->flags)
681 continue;
682 pci_claim_resource(pdev, i);
683 }
684
685 return 0;
686}
687
688int pcibios_enable_device(struct pci_dev *pdev, int mask)
689{
690 struct zpci_dev *zdev = get_zdev(pdev);
691 struct resource *res;
692 u16 cmd;
693 int i;
Sebastian Ottaf0a8a82013-04-16 14:13:21 +0200694
Sebastian Ott1c213512013-04-25 14:49:48 +0200695 zdev->pdev = pdev;
Sebastian Ottaf0a8a82013-04-16 14:13:21 +0200696 zpci_debug_init_device(zdev);
697 zpci_fmb_enable_device(zdev);
698 zpci_map_resources(zdev);
699
Sebastian Ottcb809182013-08-29 19:34:37 +0200700 pci_read_config_word(pdev, PCI_COMMAND, &cmd);
701 for (i = 0; i < PCI_BAR_COUNT; i++) {
702 res = &pdev->resource[i];
703
704 if (res->flags & IORESOURCE_IO)
705 return -EINVAL;
706
707 if (res->flags & IORESOURCE_MEM)
708 cmd |= PCI_COMMAND_MEMORY;
709 }
710 pci_write_config_word(pdev, PCI_COMMAND, cmd);
Sebastian Ottaf0a8a82013-04-16 14:13:21 +0200711 return 0;
712}
713
Sebastian Ottcb809182013-08-29 19:34:37 +0200714void pcibios_disable_device(struct pci_dev *pdev)
Sebastian Ott944239c2013-06-05 16:06:16 +0200715{
716 struct zpci_dev *zdev = get_zdev(pdev);
717
718 zpci_unmap_resources(zdev);
719 zpci_fmb_disable_device(zdev);
720 zpci_debug_exit_device(zdev);
721 zdev->pdev = NULL;
722}
723
Sebastian Ott69db3b52013-09-25 12:27:43 +0200724#ifdef CONFIG_HIBERNATE_CALLBACKS
725static int zpci_restore(struct device *dev)
726{
727 struct zpci_dev *zdev = get_zdev(to_pci_dev(dev));
728 int ret = 0;
729
730 if (zdev->state != ZPCI_FN_STATE_ONLINE)
731 goto out;
732
733 ret = clp_enable_fh(zdev, ZPCI_NR_DMA_SPACES);
734 if (ret)
735 goto out;
736
737 zpci_map_resources(zdev);
738 zpci_register_ioat(zdev, 0, zdev->start_dma + PAGE_OFFSET,
739 zdev->start_dma + zdev->iommu_size - 1,
740 (u64) zdev->dma_table);
741
742out:
743 return ret;
744}
745
746static int zpci_freeze(struct device *dev)
747{
748 struct zpci_dev *zdev = get_zdev(to_pci_dev(dev));
749
750 if (zdev->state != ZPCI_FN_STATE_ONLINE)
751 return 0;
752
753 zpci_unregister_ioat(zdev, 0);
754 return clp_disable_fh(zdev);
755}
756
757struct dev_pm_ops pcibios_pm_ops = {
758 .thaw_noirq = zpci_restore,
759 .freeze_noirq = zpci_freeze,
760 .restore_noirq = zpci_restore,
761 .poweroff_noirq = zpci_freeze,
762};
763#endif /* CONFIG_HIBERNATE_CALLBACKS */
764
Jan Glaubercd248342012-11-29 12:50:30 +0100765static int zpci_alloc_domain(struct zpci_dev *zdev)
766{
767 spin_lock(&zpci_domain_lock);
768 zdev->domain = find_first_zero_bit(zpci_domain, ZPCI_NR_DEVICES);
769 if (zdev->domain == ZPCI_NR_DEVICES) {
770 spin_unlock(&zpci_domain_lock);
771 return -ENOSPC;
772 }
773 set_bit(zdev->domain, zpci_domain);
774 spin_unlock(&zpci_domain_lock);
775 return 0;
776}
777
778static void zpci_free_domain(struct zpci_dev *zdev)
779{
780 spin_lock(&zpci_domain_lock);
781 clear_bit(zdev->domain, zpci_domain);
782 spin_unlock(&zpci_domain_lock);
783}
784
Sebastian Ott7d594322013-11-12 19:35:01 +0100785void pcibios_remove_bus(struct pci_bus *bus)
786{
787 struct zpci_dev *zdev = get_zdev_by_bus(bus);
788
789 zpci_exit_slot(zdev);
790 zpci_cleanup_bus_resources(zdev);
791 zpci_free_domain(zdev);
792
793 spin_lock(&zpci_list_lock);
794 list_del(&zdev->entry);
795 spin_unlock(&zpci_list_lock);
796
797 kfree(zdev);
798}
799
800static int zpci_scan_bus(struct zpci_dev *zdev)
801{
802 LIST_HEAD(resources);
803 int ret;
804
805 ret = zpci_setup_bus_resources(zdev, &resources);
806 if (ret)
807 return ret;
808
809 zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
810 zdev, &resources);
811 if (!zdev->bus) {
812 zpci_cleanup_bus_resources(zdev);
813 return -EIO;
814 }
815
816 zdev->bus->max_bus_speed = zdev->max_bus_speed;
817 return 0;
818}
819
Jan Glaubera755a452012-11-29 12:55:21 +0100820int zpci_enable_device(struct zpci_dev *zdev)
821{
822 int rc;
823
824 rc = clp_enable_fh(zdev, ZPCI_NR_DMA_SPACES);
825 if (rc)
826 goto out;
Jan Glauber828b35f2012-11-29 14:33:30 +0100827
828 rc = zpci_dma_init_device(zdev);
829 if (rc)
830 goto out_dma;
Sebastian Ott0ff70ec2013-08-29 19:35:19 +0200831
832 zdev->state = ZPCI_FN_STATE_ONLINE;
Jan Glaubera755a452012-11-29 12:55:21 +0100833 return 0;
Jan Glauber828b35f2012-11-29 14:33:30 +0100834
835out_dma:
836 clp_disable_fh(zdev);
Jan Glaubera755a452012-11-29 12:55:21 +0100837out:
838 return rc;
839}
840EXPORT_SYMBOL_GPL(zpci_enable_device);
841
Sebastian Ottcb65a662013-04-16 14:12:17 +0200842int zpci_disable_device(struct zpci_dev *zdev)
843{
844 zpci_dma_exit_device(zdev);
845 return clp_disable_fh(zdev);
846}
847EXPORT_SYMBOL_GPL(zpci_disable_device);
848
Jan Glaubercd248342012-11-29 12:50:30 +0100849int zpci_create_device(struct zpci_dev *zdev)
850{
851 int rc;
852
853 rc = zpci_alloc_domain(zdev);
854 if (rc)
855 goto out;
856
Sebastian Ott1c213512013-04-25 14:49:48 +0200857 if (zdev->state == ZPCI_FN_STATE_CONFIGURED) {
858 rc = zpci_enable_device(zdev);
859 if (rc)
860 goto out_free;
Sebastian Ott1c213512013-04-25 14:49:48 +0200861 }
862 rc = zpci_scan_bus(zdev);
Jan Glaubercd248342012-11-29 12:50:30 +0100863 if (rc)
Sebastian Ott1c213512013-04-25 14:49:48 +0200864 goto out_disable;
Jan Glaubercd248342012-11-29 12:50:30 +0100865
Sebastian Ott57b59182013-08-29 19:40:01 +0200866 spin_lock(&zpci_list_lock);
Jan Glaubercd248342012-11-29 12:50:30 +0100867 list_add_tail(&zdev->entry, &zpci_list);
Sebastian Ott57b59182013-08-29 19:40:01 +0200868 spin_unlock(&zpci_list_lock);
Jan Glaubercd248342012-11-29 12:50:30 +0100869
Sebastian Ott67f43f32013-08-29 19:33:16 +0200870 zpci_init_slot(zdev);
871
Jan Glaubercd248342012-11-29 12:50:30 +0100872 return 0;
873
Sebastian Ott1c213512013-04-25 14:49:48 +0200874out_disable:
875 if (zdev->state == ZPCI_FN_STATE_ONLINE)
876 zpci_disable_device(zdev);
877out_free:
Jan Glaubercd248342012-11-29 12:50:30 +0100878 zpci_free_domain(zdev);
879out:
880 return rc;
881}
882
883void zpci_stop_device(struct zpci_dev *zdev)
884{
Jan Glauber828b35f2012-11-29 14:33:30 +0100885 zpci_dma_exit_device(zdev);
Jan Glaubercd248342012-11-29 12:50:30 +0100886 /*
887 * Note: SCLP disables fh via set-pci-fn so don't
888 * do that here.
889 */
890}
891EXPORT_SYMBOL_GPL(zpci_stop_device);
892
Jan Glaubercd248342012-11-29 12:50:30 +0100893static inline int barsize(u8 size)
894{
895 return (size) ? (1 << size) >> 10 : 0;
896}
897
898static int zpci_mem_init(void)
899{
Jan Glauberd0b08852012-12-11 14:53:35 +0100900 zdev_fmb_cache = kmem_cache_create("PCI_FMB_cache", sizeof(struct zpci_fmb),
901 16, 0, NULL);
902 if (!zdev_fmb_cache)
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200903 goto error_zdev;
Jan Glauberd0b08852012-12-11 14:53:35 +0100904
Jan Glaubercd248342012-11-29 12:50:30 +0100905 /* TODO: use realloc */
906 zpci_iomap_start = kzalloc(ZPCI_IOMAP_MAX_ENTRIES * sizeof(*zpci_iomap_start),
907 GFP_KERNEL);
908 if (!zpci_iomap_start)
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100909 goto error_iomap;
Jan Glaubercd248342012-11-29 12:50:30 +0100910 return 0;
911
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100912error_iomap:
Jan Glauberd0b08852012-12-11 14:53:35 +0100913 kmem_cache_destroy(zdev_fmb_cache);
Jan Glaubercd248342012-11-29 12:50:30 +0100914error_zdev:
915 return -ENOMEM;
916}
917
918static void zpci_mem_exit(void)
919{
920 kfree(zpci_iomap_start);
Jan Glauberd0b08852012-12-11 14:53:35 +0100921 kmem_cache_destroy(zdev_fmb_cache);
Jan Glaubercd248342012-11-29 12:50:30 +0100922}
923
Sebastian Ott67f43f32013-08-29 19:33:16 +0200924static unsigned int s390_pci_probe;
Jan Glaubercd248342012-11-29 12:50:30 +0100925
926char * __init pcibios_setup(char *str)
927{
Sebastian Ott89b0dc952013-04-16 14:19:22 +0200928 if (!strcmp(str, "on")) {
929 s390_pci_probe = 1;
Jan Glaubercd248342012-11-29 12:50:30 +0100930 return NULL;
931 }
932 return str;
933}
934
935static int __init pci_base_init(void)
936{
937 int rc;
938
Heiko Carstens1e5635d2013-01-30 15:52:16 +0100939 if (!s390_pci_probe)
Jan Glaubercd248342012-11-29 12:50:30 +0100940 return 0;
941
942 if (!test_facility(2) || !test_facility(69)
943 || !test_facility(71) || !test_facility(72))
944 return 0;
945
Jan Glauberd0b08852012-12-11 14:53:35 +0100946 rc = zpci_debug_init();
947 if (rc)
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200948 goto out;
Jan Glauberd0b08852012-12-11 14:53:35 +0100949
Jan Glaubercd248342012-11-29 12:50:30 +0100950 rc = zpci_mem_init();
951 if (rc)
952 goto out_mem;
953
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100954 rc = zpci_irq_init();
955 if (rc)
956 goto out_irq;
957
Jan Glauber828b35f2012-11-29 14:33:30 +0100958 rc = zpci_dma_init();
959 if (rc)
960 goto out_dma;
961
Sebastian Ott1d578962013-08-29 19:37:28 +0200962 rc = clp_scan_pci_devices();
Jan Glaubera755a452012-11-29 12:55:21 +0100963 if (rc)
964 goto out_find;
965
Jan Glaubercd248342012-11-29 12:50:30 +0100966 return 0;
967
Jan Glaubera755a452012-11-29 12:55:21 +0100968out_find:
Jan Glauber828b35f2012-11-29 14:33:30 +0100969 zpci_dma_exit();
970out_dma:
Jan Glauber9a4da8a2012-11-29 13:05:05 +0100971 zpci_irq_exit();
972out_irq:
Jan Glaubercd248342012-11-29 12:50:30 +0100973 zpci_mem_exit();
974out_mem:
Jan Glauberd0b08852012-12-11 14:53:35 +0100975 zpci_debug_exit();
Martin Schwidefsky1f44a222013-06-27 09:01:09 +0200976out:
Jan Glaubercd248342012-11-29 12:50:30 +0100977 return rc;
978}
Sebastian Ott67f43f32013-08-29 19:33:16 +0200979subsys_initcall_sync(pci_base_init);
Sebastian Ott57b59182013-08-29 19:40:01 +0200980
981void zpci_rescan(void)
982{
983 clp_rescan_pci_devices_simple();
984}