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
6 The PCI controllers in the AR71XX and in the
7 AR724X SoCs are different, and both of them
8 uses different IRQ wiring.
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
16 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
20 arch/mips/ath79/pci.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++---
21 arch/mips/ath79/pci.h | 9 ++++++
22 2 files changed, 77 insertions(+), 4 deletions(-)
24 --- a/arch/mips/ath79/pci.c
25 +++ b/arch/mips/ath79/pci.c
27 * by the Free Software Foundation.
30 +#include <linux/init.h>
31 #include <linux/pci.h>
32 #include <asm/mach-ath79/ath79.h>
33 #include <asm/mach-ath79/irq.h>
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;
43 +static const struct ath79_pci_irq ar71xx_pci_irq_map[] __initconst = {
47 + .irq = ATH79_PCI_IRQ(0),
51 + .irq = ATH79_PCI_IRQ(1),
55 + .irq = ATH79_PCI_IRQ(2),
59 +static const struct ath79_pci_irq ar724x_pci_irq_map[] __initconst = {
63 + .irq = ATH79_PCI_IRQ(0),
67 void ar724x_pci_add_data(struct ar724x_pci_data *data, int size)
70 @@ -26,13 +53,40 @@ void ar724x_pci_add_data(struct ar724x_p
72 int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
74 - unsigned int devfn = dev->devfn;
78 - if (devfn > pci_data_size - 1)
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);
91 + pr_crit("pci %s: invalid irq map\n",
92 + pci_name((struct pci_dev *) dev));
97 + for (i = 0; i < ath79_pci_nr_irqs; i++) {
98 + const struct ath79_pci_irq *entry;
100 + entry = &ath79_pci_irq_map[i];
101 + if (entry->slot == slot && entry->pin == pin) {
108 + pr_crit("pci %s: no irq found for pin %u\n",
109 + pci_name((struct pci_dev *) dev), pin);
111 + pr_info("pci %s: using irq %d for pin %u\n",
112 + pci_name((struct pci_dev *) dev), irq, pin);
116 @@ -45,6 +99,13 @@ int pcibios_plat_dev_init(struct pci_dev
120 +void __init ath79_pci_set_irq_map(unsigned nr_irqs,
121 + const struct ath79_pci_irq *map)
123 + ath79_pci_nr_irqs = nr_irqs;
124 + ath79_pci_irq_map = map;
127 void __init ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *dev))
129 ath79_pci_plat_dev_init = func;
130 @@ -52,6 +113,9 @@ void __init ath79_pci_set_plat_dev_init(
132 int __init ath79_register_pci(void)
134 + if (soc_is_ar71xx())
135 + return ar71xx_pcibios_init();
138 return ar724x_pcibios_init(ATH79_CPU_IRQ_IP2);
140 --- a/arch/mips/ath79/pci.h
141 +++ b/arch/mips/ath79/pci.h
142 @@ -15,13 +15,22 @@ struct ar724x_pci_data {
146 +struct ath79_pci_irq {
152 void ar724x_pci_add_data(struct ar724x_pci_data *data, int size);
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);
160 +ath79_pci_set_irq_map(unsigned nr_irqs, const struct ath79_pci_irq *map) {}
162 ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *)) {}
163 static inline int ath79_register_pci(void) { return 0; }