aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/ath79/pci.c
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2012-03-14 05:36:11 -0400
committerRalf Baechle <ralf@linux-mips.org>2012-05-15 11:49:06 -0400
commitd22ce25f870dff2521d352e20d0fd2a7598fbf87 (patch)
tree1cff72b64ddf1a612d5b6096914ed3d086b774b2 /arch/mips/ath79/pci.c
parentf8365ec4e1b945f70a86e9514dd67ba5f9f2915b (diff)
MIPS: ath79: allow to use SoC specific PCI IRQ maps
The PCI controllers in the AR71XX and in the AR724X SoCs are different, and both of them uses different IRQ wiring. The patch modifies the 'pcibios_map_irq' function in order to allow to use different IRQ maps for the different SoCs. The patch also adds a function, which lets the board setup code to override the default IRQ map. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/3500/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/ath79/pci.c')
-rw-r--r--arch/mips/ath79/pci.c72
1 files changed, 68 insertions, 4 deletions
diff --git a/arch/mips/ath79/pci.c b/arch/mips/ath79/pci.c
index 2b4c730ccbcb..365a8b63e8c5 100644
--- a/arch/mips/ath79/pci.c
+++ b/arch/mips/ath79/pci.c
@@ -8,6 +8,7 @@
8 * by the Free Software Foundation. 8 * by the Free Software Foundation.
9 */ 9 */
10 10
11#include <linux/init.h>
11#include <linux/pci.h> 12#include <linux/pci.h>
12#include <asm/mach-ath79/ath79.h> 13#include <asm/mach-ath79/ath79.h>
13#include <asm/mach-ath79/irq.h> 14#include <asm/mach-ath79/irq.h>
@@ -15,9 +16,35 @@
15#include "pci.h" 16#include "pci.h"
16 17
17static int (*ath79_pci_plat_dev_init)(struct pci_dev *dev); 18static int (*ath79_pci_plat_dev_init)(struct pci_dev *dev);
19static const struct ath79_pci_irq *ath79_pci_irq_map __initdata;
20static unsigned ath79_pci_nr_irqs __initdata;
18static struct ar724x_pci_data *pci_data; 21static struct ar724x_pci_data *pci_data;
19static int pci_data_size; 22static int pci_data_size;
20 23
24static const struct ath79_pci_irq ar71xx_pci_irq_map[] __initconst = {
25 {
26 .slot = 17,
27 .pin = 1,
28 .irq = ATH79_PCI_IRQ(0),
29 }, {
30 .slot = 18,
31 .pin = 1,
32 .irq = ATH79_PCI_IRQ(1),
33 }, {
34 .slot = 19,
35 .pin = 1,
36 .irq = ATH79_PCI_IRQ(2),
37 }
38};
39
40static const struct ath79_pci_irq ar724x_pci_irq_map[] __initconst = {
41 {
42 .slot = 0,
43 .pin = 1,
44 .irq = ATH79_PCI_IRQ(0),
45 }
46};
47
21void ar724x_pci_add_data(struct ar724x_pci_data *data, int size) 48void ar724x_pci_add_data(struct ar724x_pci_data *data, int size)
22{ 49{
23 pci_data = data; 50 pci_data = data;
@@ -26,13 +53,40 @@ void ar724x_pci_add_data(struct ar724x_pci_data *data, int size)
26 53
27int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin) 54int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
28{ 55{
29 unsigned int devfn = dev->devfn;
30 int irq = -1; 56 int irq = -1;
57 int i;
58
59 if (ath79_pci_nr_irqs == 0 ||
60 ath79_pci_irq_map == NULL) {
61 if (soc_is_ar71xx()) {
62 ath79_pci_irq_map = ar71xx_pci_irq_map;
63 ath79_pci_nr_irqs = ARRAY_SIZE(ar71xx_pci_irq_map);
64 } else if (soc_is_ar724x()) {
65 ath79_pci_irq_map = ar724x_pci_irq_map;
66 ath79_pci_nr_irqs = ARRAY_SIZE(ar724x_pci_irq_map);
67 } else {
68 pr_crit("pci %s: invalid irq map\n",
69 pci_name((struct pci_dev *) dev));
70 return irq;
71 }
72 }
73
74 for (i = 0; i < ath79_pci_nr_irqs; i++) {
75 const struct ath79_pci_irq *entry;
31 76
32 if (devfn > pci_data_size - 1) 77 entry = &ath79_pci_irq_map[i];
33 return irq; 78 if (entry->slot == slot && entry->pin == pin) {
79 irq = entry->irq;
80 break;
81 }
82 }
34 83
35 irq = pci_data[devfn].irq; 84 if (irq < 0)
85 pr_crit("pci %s: no irq found for pin %u\n",
86 pci_name((struct pci_dev *) dev), pin);
87 else
88 pr_info("pci %s: using irq %d for pin %u\n",
89 pci_name((struct pci_dev *) dev), irq, pin);
36 90
37 return irq; 91 return irq;
38} 92}
@@ -45,6 +99,13 @@ int pcibios_plat_dev_init(struct pci_dev *dev)
45 return 0; 99 return 0;
46} 100}
47 101
102void __init ath79_pci_set_irq_map(unsigned nr_irqs,
103 const struct ath79_pci_irq *map)
104{
105 ath79_pci_nr_irqs = nr_irqs;
106 ath79_pci_irq_map = map;
107}
108
48void __init ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *dev)) 109void __init ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *dev))
49{ 110{
50 ath79_pci_plat_dev_init = func; 111 ath79_pci_plat_dev_init = func;
@@ -52,6 +113,9 @@ void __init ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *dev))
52 113
53int __init ath79_register_pci(void) 114int __init ath79_register_pci(void)
54{ 115{
116 if (soc_is_ar71xx())
117 return ar71xx_pcibios_init();
118
55 if (soc_is_ar724x()) 119 if (soc_is_ar724x())
56 return ar724x_pcibios_init(ATH79_CPU_IRQ_IP2); 120 return ar724x_pcibios_init(ATH79_CPU_IRQ_IP2);
57 121