Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Gabor Juhos and committed by
Ralf Baechle
d22ce25f f8365ec4

+77 -4
+68 -4
arch/mips/ath79/pci.c
··· 8 8 * by the Free Software Foundation. 9 9 */ 10 10 11 + #include <linux/init.h> 11 12 #include <linux/pci.h> 12 13 #include <asm/mach-ath79/ath79.h> 13 14 #include <asm/mach-ath79/irq.h> ··· 16 15 #include "pci.h" 17 16 18 17 static int (*ath79_pci_plat_dev_init)(struct pci_dev *dev); 18 + static const struct ath79_pci_irq *ath79_pci_irq_map __initdata; 19 + static unsigned ath79_pci_nr_irqs __initdata; 19 20 static struct ar724x_pci_data *pci_data; 20 21 static int pci_data_size; 22 + 23 + static const struct ath79_pci_irq ar71xx_pci_irq_map[] __initconst = { 24 + { 25 + .slot = 17, 26 + .pin = 1, 27 + .irq = ATH79_PCI_IRQ(0), 28 + }, { 29 + .slot = 18, 30 + .pin = 1, 31 + .irq = ATH79_PCI_IRQ(1), 32 + }, { 33 + .slot = 19, 34 + .pin = 1, 35 + .irq = ATH79_PCI_IRQ(2), 36 + } 37 + }; 38 + 39 + static const struct ath79_pci_irq ar724x_pci_irq_map[] __initconst = { 40 + { 41 + .slot = 0, 42 + .pin = 1, 43 + .irq = ATH79_PCI_IRQ(0), 44 + } 45 + }; 21 46 22 47 void ar724x_pci_add_data(struct ar724x_pci_data *data, int size) 23 48 { ··· 53 26 54 27 int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin) 55 28 { 56 - unsigned int devfn = dev->devfn; 57 29 int irq = -1; 30 + int i; 58 31 59 - if (devfn > pci_data_size - 1) 60 - return irq; 32 + if (ath79_pci_nr_irqs == 0 || 33 + ath79_pci_irq_map == NULL) { 34 + if (soc_is_ar71xx()) { 35 + ath79_pci_irq_map = ar71xx_pci_irq_map; 36 + ath79_pci_nr_irqs = ARRAY_SIZE(ar71xx_pci_irq_map); 37 + } else if (soc_is_ar724x()) { 38 + ath79_pci_irq_map = ar724x_pci_irq_map; 39 + ath79_pci_nr_irqs = ARRAY_SIZE(ar724x_pci_irq_map); 40 + } else { 41 + pr_crit("pci %s: invalid irq map\n", 42 + pci_name((struct pci_dev *) dev)); 43 + return irq; 44 + } 45 + } 61 46 62 - irq = pci_data[devfn].irq; 47 + for (i = 0; i < ath79_pci_nr_irqs; i++) { 48 + const struct ath79_pci_irq *entry; 49 + 50 + entry = &ath79_pci_irq_map[i]; 51 + if (entry->slot == slot && entry->pin == pin) { 52 + irq = entry->irq; 53 + break; 54 + } 55 + } 56 + 57 + if (irq < 0) 58 + pr_crit("pci %s: no irq found for pin %u\n", 59 + pci_name((struct pci_dev *) dev), pin); 60 + else 61 + pr_info("pci %s: using irq %d for pin %u\n", 62 + pci_name((struct pci_dev *) dev), irq, pin); 63 63 64 64 return irq; 65 65 } ··· 99 45 return 0; 100 46 } 101 47 48 + void __init ath79_pci_set_irq_map(unsigned nr_irqs, 49 + const struct ath79_pci_irq *map) 50 + { 51 + ath79_pci_nr_irqs = nr_irqs; 52 + ath79_pci_irq_map = map; 53 + } 54 + 102 55 void __init ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *dev)) 103 56 { 104 57 ath79_pci_plat_dev_init = func; ··· 113 52 114 53 int __init ath79_register_pci(void) 115 54 { 55 + if (soc_is_ar71xx()) 56 + return ar71xx_pcibios_init(); 57 + 116 58 if (soc_is_ar724x()) 117 59 return ar724x_pcibios_init(ATH79_CPU_IRQ_IP2); 118 60
+9
arch/mips/ath79/pci.h
··· 15 15 int irq; 16 16 }; 17 17 18 + struct ath79_pci_irq { 19 + u8 slot; 20 + u8 pin; 21 + int irq; 22 + }; 23 + 18 24 void ar724x_pci_add_data(struct ar724x_pci_data *data, int size); 19 25 20 26 #ifdef CONFIG_PCI 27 + void ath79_pci_set_irq_map(unsigned nr_irqs, const struct ath79_pci_irq *map); 21 28 void ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *dev)); 22 29 int ath79_register_pci(void); 23 30 #else 31 + static inline void 32 + ath79_pci_set_irq_map(unsigned nr_irqs, const struct ath79_pci_irq *map) {} 24 33 static inline void 25 34 ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *)) {} 26 35 static inline int ath79_register_pci(void) { return 0; }