blob: 855a69dcc86e08c2cc2e6b89166353e1976a96d7 [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
16static struct ath724x_pci_data *pci_data;
17static int pci_data_size;
18
19void ath724x_pci_add_data(struct ath724x_pci_data *data, int size)
20{
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())
53 return ath724x_pcibios_init();
54
55 return -ENODEV;
56}