aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/ath79
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
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')
-rw-r--r--arch/mips/ath79/pci.c72
-rw-r--r--arch/mips/ath79/pci.h9
2 files changed, 77 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
diff --git a/arch/mips/ath79/pci.h b/arch/mips/ath79/pci.h
index de30e158932d..a5c4e5856202 100644
--- a/arch/mips/ath79/pci.h
+++ b/arch/mips/ath79/pci.h
@@ -15,13 +15,22 @@ struct ar724x_pci_data {
15 int irq; 15 int irq;
16}; 16};
17 17
18struct ath79_pci_irq {
19 u8 slot;
20 u8 pin;
21 int irq;
22};
23
18void ar724x_pci_add_data(struct ar724x_pci_data *data, int size); 24void ar724x_pci_add_data(struct ar724x_pci_data *data, int size);
19 25
20#ifdef CONFIG_PCI 26#ifdef CONFIG_PCI
27void ath79_pci_set_irq_map(unsigned nr_irqs, const struct ath79_pci_irq *map);
21void ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *dev)); 28void ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *dev));
22int ath79_register_pci(void); 29int ath79_register_pci(void);
23#else 30#else
24static inline void 31static inline void
32ath79_pci_set_irq_map(unsigned nr_irqs, const struct ath79_pci_irq *map) {}
33static inline void
25ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *)) {} 34ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *)) {}
26static inline int ath79_register_pci(void) { return 0; } 35static inline int ath79_register_pci(void) { return 0; }
27#endif 36#endif