[tools] autoconf: another relocatability fix for autom4te, substitute hardcoded prefi...
[openwrt.git] / target / linux / ar71xx / patches-3.2 / 117-MIPS-ath79-allow-to-use-SoC-specific-PCI-IRQ-maps.patch
1 From 8a1a5852aa7f8cfc027b2b0bb51cbbac4309e144 Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Sun, 20 Nov 2011 14:32:09 +0100
4 Subject: [PATCH 17/35] MIPS: ath79: allow to use SoC specific PCI IRQ maps
5
6 The PCI controllers in the AR71XX and in the
7 AR724X SoCs are different, and both of them
8 uses different IRQ wiring.
9
10 The patch modifies the 'pcibios_map_irq' function
11 in order to allow to use different IRQ maps for
12 the different SoCs. The patch also adds a function,
13 which lets the board setup code to override the
14 default IRQ map.
15
16 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
17
18 v2: - no changes
19 ---
20 arch/mips/ath79/pci.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++---
21 arch/mips/ath79/pci.h | 9 ++++++
22 2 files changed, 77 insertions(+), 4 deletions(-)
23
24 --- a/arch/mips/ath79/pci.c
25 +++ b/arch/mips/ath79/pci.c
26 @@ -8,6 +8,7 @@
27 * by the Free Software Foundation.
28 */
29
30 +#include <linux/init.h>
31 #include <linux/pci.h>
32 #include <asm/mach-ath79/ath79.h>
33 #include <asm/mach-ath79/irq.h>
34 @@ -15,9 +16,35 @@
35 #include "pci.h"
36
37 static int (*ath79_pci_plat_dev_init)(struct pci_dev *dev);
38 +static const struct ath79_pci_irq *ath79_pci_irq_map __initdata;
39 +static unsigned ath79_pci_nr_irqs __initdata;
40 static struct ar724x_pci_data *pci_data;
41 static int pci_data_size;
42
43 +static const struct ath79_pci_irq ar71xx_pci_irq_map[] __initconst = {
44 + {
45 + .slot = 17,
46 + .pin = 1,
47 + .irq = ATH79_PCI_IRQ(0),
48 + }, {
49 + .slot = 18,
50 + .pin = 1,
51 + .irq = ATH79_PCI_IRQ(1),
52 + }, {
53 + .slot = 19,
54 + .pin = 1,
55 + .irq = ATH79_PCI_IRQ(2),
56 + }
57 +};
58 +
59 +static const struct ath79_pci_irq ar724x_pci_irq_map[] __initconst = {
60 + {
61 + .slot = 0,
62 + .pin = 1,
63 + .irq = ATH79_PCI_IRQ(0),
64 + }
65 +};
66 +
67 void ar724x_pci_add_data(struct ar724x_pci_data *data, int size)
68 {
69 pci_data = data;
70 @@ -26,13 +53,40 @@ void ar724x_pci_add_data(struct ar724x_p
71
72 int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
73 {
74 - unsigned int devfn = dev->devfn;
75 int irq = -1;
76 + int i;
77
78 - if (devfn > pci_data_size - 1)
79 - return irq;
80 -
81 - irq = pci_data[devfn].irq;
82 + if (ath79_pci_nr_irqs == 0 ||
83 + ath79_pci_irq_map == NULL) {
84 + if (soc_is_ar71xx()) {
85 + ath79_pci_irq_map = ar71xx_pci_irq_map;
86 + ath79_pci_nr_irqs = ARRAY_SIZE(ar71xx_pci_irq_map);
87 + } else if (soc_is_ar724x()) {
88 + ath79_pci_irq_map = ar724x_pci_irq_map;
89 + ath79_pci_nr_irqs = ARRAY_SIZE(ar724x_pci_irq_map);
90 + } else {
91 + pr_crit("pci %s: invalid irq map\n",
92 + pci_name((struct pci_dev *) dev));
93 + return irq;
94 + }
95 + }
96 +
97 + for (i = 0; i < ath79_pci_nr_irqs; i++) {
98 + const struct ath79_pci_irq *entry;
99 +
100 + entry = &ath79_pci_irq_map[i];
101 + if (entry->slot == slot && entry->pin == pin) {
102 + irq = entry->irq;
103 + break;
104 + }
105 + }
106 +
107 + if (irq < 0)
108 + pr_crit("pci %s: no irq found for pin %u\n",
109 + pci_name((struct pci_dev *) dev), pin);
110 + else
111 + pr_info("pci %s: using irq %d for pin %u\n",
112 + pci_name((struct pci_dev *) dev), irq, pin);
113
114 return irq;
115 }
116 @@ -45,6 +99,13 @@ int pcibios_plat_dev_init(struct pci_dev
117 return 0;
118 }
119
120 +void __init ath79_pci_set_irq_map(unsigned nr_irqs,
121 + const struct ath79_pci_irq *map)
122 +{
123 + ath79_pci_nr_irqs = nr_irqs;
124 + ath79_pci_irq_map = map;
125 +}
126 +
127 void __init ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *dev))
128 {
129 ath79_pci_plat_dev_init = func;
130 @@ -52,6 +113,9 @@ void __init ath79_pci_set_plat_dev_init(
131
132 int __init ath79_register_pci(void)
133 {
134 + if (soc_is_ar71xx())
135 + return ar71xx_pcibios_init();
136 +
137 if (soc_is_ar724x())
138 return ar724x_pcibios_init(ATH79_CPU_IRQ_IP2);
139
140 --- a/arch/mips/ath79/pci.h
141 +++ b/arch/mips/ath79/pci.h
142 @@ -15,13 +15,22 @@ struct ar724x_pci_data {
143 int irq;
144 };
145
146 +struct ath79_pci_irq {
147 + u8 slot;
148 + u8 pin;
149 + int irq;
150 +};
151 +
152 void ar724x_pci_add_data(struct ar724x_pci_data *data, int size);
153
154 #ifdef CONFIG_PCI
155 +void ath79_pci_set_irq_map(unsigned nr_irqs, const struct ath79_pci_irq *map);
156 void ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *dev));
157 int ath79_register_pci(void);
158 #else
159 static inline void
160 +ath79_pci_set_irq_map(unsigned nr_irqs, const struct ath79_pci_irq *map) {}
161 +static inline void
162 ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *)) {}
163 static inline int ath79_register_pci(void) { return 0; }
164 #endif
This page took 0.04953 seconds and 5 git commands to generate.