]> git.ipfire.org Git - thirdparty/linux.git/blob - arch/arm/mach-ixp4xx/avila-pci.c
ARM: ixp4xx: Convert to SPARSE_IRQ
[thirdparty/linux.git] / arch / arm / mach-ixp4xx / avila-pci.c
1 /*
2 * arch/arm/mach-ixp4xx/avila-pci.c
3 *
4 * Gateworks Avila board-level PCI initialization
5 *
6 * Author: Michael-Luke Jones <mlj28@cam.ac.uk>
7 *
8 * Based on ixdp-pci.c
9 * Copyright (C) 2002 Intel Corporation.
10 * Copyright (C) 2003-2004 MontaVista Software, Inc.
11 *
12 * Maintainer: Deepak Saxena <dsaxena@plexity.net>
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2 as
16 * published by the Free Software Foundation.
17 *
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/pci.h>
22 #include <linux/init.h>
23 #include <linux/irq.h>
24 #include <linux/delay.h>
25 #include <asm/mach/pci.h>
26 #include <asm/irq.h>
27 #include <mach/hardware.h>
28 #include <asm/mach-types.h>
29
30 #include "irqs.h"
31
32 #define AVILA_MAX_DEV 4
33 #define LOFT_MAX_DEV 6
34 #define IRQ_LINES 4
35
36 /* PCI controller GPIO to IRQ pin mappings */
37 #define INTA 11
38 #define INTB 10
39 #define INTC 9
40 #define INTD 8
41
42 void __init avila_pci_preinit(void)
43 {
44 irq_set_irq_type(IXP4XX_GPIO_IRQ(INTA), IRQ_TYPE_LEVEL_LOW);
45 irq_set_irq_type(IXP4XX_GPIO_IRQ(INTB), IRQ_TYPE_LEVEL_LOW);
46 irq_set_irq_type(IXP4XX_GPIO_IRQ(INTC), IRQ_TYPE_LEVEL_LOW);
47 irq_set_irq_type(IXP4XX_GPIO_IRQ(INTD), IRQ_TYPE_LEVEL_LOW);
48 ixp4xx_pci_preinit();
49 }
50
51 static int __init avila_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
52 {
53 static int pci_irq_table[IRQ_LINES] = {
54 IXP4XX_GPIO_IRQ(INTA),
55 IXP4XX_GPIO_IRQ(INTB),
56 IXP4XX_GPIO_IRQ(INTC),
57 IXP4XX_GPIO_IRQ(INTD)
58 };
59
60 if (slot >= 1 &&
61 slot <= (machine_is_loft() ? LOFT_MAX_DEV : AVILA_MAX_DEV) &&
62 pin >= 1 && pin <= IRQ_LINES)
63 return pci_irq_table[(slot + pin - 2) % 4];
64
65 return -1;
66 }
67
68 struct hw_pci avila_pci __initdata = {
69 .nr_controllers = 1,
70 .ops = &ixp4xx_ops,
71 .preinit = avila_pci_preinit,
72 .setup = ixp4xx_setup,
73 .map_irq = avila_map_irq,
74 };
75
76 int __init avila_pci_init(void)
77 {
78 if (machine_is_avila() || machine_is_loft())
79 pci_common_init(&avila_pci);
80 return 0;
81 }
82
83 subsys_initcall(avila_pci_init);