1 From fd1dd2f2c317bc0fc2c30fba440d911654bf592e Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Wed, 14 Mar 2012 10:36:11 +0100
4 Subject: [PATCH 20/47] 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>
17 Cc: linux-mips@linux-mips.org
18 Patchwork: https://patchwork.linux-mips.org/patch/3500/
19 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
21 arch/mips/ath79/pci.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++---
22 arch/mips/ath79/pci.h | 9 ++++++
23 2 files changed, 77 insertions(+), 4 deletions(-)
25 --- a/arch/mips/ath79/pci.c
26 +++ b/arch/mips/ath79/pci.c
28 * by the Free Software Foundation.
31 +#include <linux/init.h>
32 #include <linux/pci.h>
33 #include <asm/mach-ath79/ath79.h>
34 #include <asm/mach-ath79/irq.h>
38 static int (*ath79_pci_plat_dev_init)(struct pci_dev *dev);
39 +static const struct ath79_pci_irq *ath79_pci_irq_map __initdata;
40 +static unsigned ath79_pci_nr_irqs __initdata;
41 static struct ar724x_pci_data *pci_data;
42 static int pci_data_size;
44 +static const struct ath79_pci_irq ar71xx_pci_irq_map[] __initconst = {
48 + .irq = ATH79_PCI_IRQ(0),
52 + .irq = ATH79_PCI_IRQ(1),
56 + .irq = ATH79_PCI_IRQ(2),
60 +static const struct ath79_pci_irq ar724x_pci_irq_map[] __initconst = {
64 + .irq = ATH79_PCI_IRQ(0),
68 void ar724x_pci_add_data(struct ar724x_pci_data *data, int size)
71 @@ -26,13 +53,40 @@ void ar724x_pci_add_data(struct ar724x_p
73 int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
75 - unsigned int devfn = dev->devfn;
79 - if (devfn > pci_data_size - 1)
82 - irq = pci_data[devfn].irq;
83 + if (ath79_pci_nr_irqs == 0 ||
84 + ath79_pci_irq_map == NULL) {
85 + if (soc_is_ar71xx()) {
86 + ath79_pci_irq_map = ar71xx_pci_irq_map;
87 + ath79_pci_nr_irqs = ARRAY_SIZE(ar71xx_pci_irq_map);
88 + } else if (soc_is_ar724x()) {
89 + ath79_pci_irq_map = ar724x_pci_irq_map;
90 + ath79_pci_nr_irqs = ARRAY_SIZE(ar724x_pci_irq_map);
92 + pr_crit("pci %s: invalid irq map\n",
93 + pci_name((struct pci_dev *) dev));
98 + for (i = 0; i < ath79_pci_nr_irqs; i++) {
99 + const struct ath79_pci_irq *entry;
101 + entry = &ath79_pci_irq_map[i];
102 + if (entry->slot == slot && entry->pin == pin) {
109 + pr_crit("pci %s: no irq found for pin %u\n",
110 + pci_name((struct pci_dev *) dev), pin);
112 + pr_info("pci %s: using irq %d for pin %u\n",
113 + pci_name((struct pci_dev *) dev), irq, pin);
117 @@ -45,6 +99,13 @@ int pcibios_plat_dev_init(struct pci_dev
121 +void __init ath79_pci_set_irq_map(unsigned nr_irqs,
122 + const struct ath79_pci_irq *map)
124 + ath79_pci_nr_irqs = nr_irqs;
125 + ath79_pci_irq_map = map;
128 void __init ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *dev))
130 ath79_pci_plat_dev_init = func;
131 @@ -52,6 +113,9 @@ void __init ath79_pci_set_plat_dev_init(
133 int __init ath79_register_pci(void)
135 + if (soc_is_ar71xx())
136 + return ar71xx_pcibios_init();
139 return ar724x_pcibios_init(ATH79_CPU_IRQ_IP2);
141 --- a/arch/mips/ath79/pci.h
142 +++ b/arch/mips/ath79/pci.h
143 @@ -15,13 +15,22 @@ struct ar724x_pci_data {
147 +struct ath79_pci_irq {
153 void ar724x_pci_add_data(struct ar724x_pci_data *data, int size);
156 +void ath79_pci_set_irq_map(unsigned nr_irqs, const struct ath79_pci_irq *map);
157 void ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *dev));
158 int ath79_register_pci(void);
161 +ath79_pci_set_irq_map(unsigned nr_irqs, const struct ath79_pci_irq *map) {}
163 ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *)) {}
164 static inline int ath79_register_pci(void) { return 0; }