blob: 14f981c295d2febec365faec5ea34e6ba8a084b4 [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>
Gabor Juhos4c07c7d2012-03-14 10:36:07 +010013#include <asm/mach-ath79/irq.h>
Gabor Juhos6335aef2012-03-14 10:29:24 +010014#include <asm/mach-ath79/pci.h>
Gabor Juhos3a6208d2012-03-14 10:29:22 +010015#include "pci.h"
Gabor Juhose2dbdc42012-03-14 10:29:21 +010016
Gabor Juhosd624bd32012-03-14 10:29:26 +010017static struct ar724x_pci_data *pci_data;
Gabor Juhose2dbdc42012-03-14 10:29:21 +010018static int pci_data_size;
19
Gabor Juhosd624bd32012-03-14 10:29:26 +010020void ar724x_pci_add_data(struct ar724x_pci_data *data, int size)
Gabor Juhose2dbdc42012-03-14 10:29:21 +010021{
22 pci_data = data;
23 pci_data_size = size;
24}
25
26int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
27{
28 unsigned int devfn = dev->devfn;
29 int irq = -1;
30
31 if (devfn > pci_data_size - 1)
32 return irq;
33
34 irq = pci_data[devfn].irq;
35
36 return irq;
37}
38
39int pcibios_plat_dev_init(struct pci_dev *dev)
40{
41 unsigned int devfn = dev->devfn;
42
43 if (devfn > pci_data_size - 1)
44 return PCIBIOS_DEVICE_NOT_FOUND;
45
46 dev->dev.platform_data = pci_data[devfn].pdata;
47
48 return PCIBIOS_SUCCESSFUL;
49}
Gabor Juhos6335aef2012-03-14 10:29:24 +010050
51int __init ath79_register_pci(void)
52{
53 if (soc_is_ar724x())
Gabor Juhos4c07c7d2012-03-14 10:36:07 +010054 return ar724x_pcibios_init(ATH79_CPU_IRQ_IP2);
Gabor Juhos6335aef2012-03-14 10:29:24 +010055
56 return -ENODEV;
57}