blob: 72281fb5360fae62881581c7d1d27aab378c5dc3 [file] [log] [blame]
Gabor Juhose2dbdc42012-03-14 10:29:21 +01001/*
2 * Atheros AR71XX/AR724X specific PCI setup code
3 *
4 * Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 */
10
11#include <linux/pci.h>
Gabor Juhos6335aef2012-03-14 10:29:24 +010012#include <asm/mach-ath79/ath79.h>
13#include <asm/mach-ath79/pci.h>
Gabor Juhos3a6208d2012-03-14 10:29:22 +010014#include "pci.h"
Gabor Juhose2dbdc42012-03-14 10:29:21 +010015
Gabor Juhosd624bd32012-03-14 10:29:26 +010016static struct ar724x_pci_data *pci_data;
Gabor Juhose2dbdc42012-03-14 10:29:21 +010017static int pci_data_size;
18
Gabor Juhosd624bd32012-03-14 10:29:26 +010019void ar724x_pci_add_data(struct ar724x_pci_data *data, int size)
Gabor Juhose2dbdc42012-03-14 10:29:21 +010020{
21 pci_data = data;
22 pci_data_size = size;
23}
24
25int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
26{
27 unsigned int devfn = dev->devfn;
28 int irq = -1;
29
30 if (devfn > pci_data_size - 1)
31 return irq;
32
33 irq = pci_data[devfn].irq;
34
35 return irq;
36}
37
38int pcibios_plat_dev_init(struct pci_dev *dev)
39{
40 unsigned int devfn = dev->devfn;
41
42 if (devfn > pci_data_size - 1)
43 return PCIBIOS_DEVICE_NOT_FOUND;
44
45 dev->dev.platform_data = pci_data[devfn].pdata;
46
47 return PCIBIOS_SUCCESSFUL;
48}
Gabor Juhos6335aef2012-03-14 10:29:24 +010049
50int __init ath79_register_pci(void)
51{
52 if (soc_is_ar724x())
Gabor Juhosd624bd32012-03-14 10:29:26 +010053 return ar724x_pcibios_init();
Gabor Juhos6335aef2012-03-14 10:29:24 +010054
55 return -ENODEV;
56}