vserver 1.9.5.x5
[linux-2.6.git] / arch / arm / mach-ixp4xx / prpmc1100-pci.c
1 /*
2  * arch/arm/mach-ixp4xx/prpmc1100-pci.c 
3  *
4  * PrPMC1100 PCI initialization
5  *
6  * Copyright (C) 2003-2004 MontaVista Sofwtare, Inc. 
7  * Based on IXDP425 code originally (C) Intel Corporation
8  *
9  * Author: Deepak Saxena <dsaxena@plexity.net>
10  *
11  * PrPMC1100 PCI init code.  GPIO usage is similar to that on 
12  * IXDP425, but the IRQ routing is completely different and
13  * depends on what carrier you are using. This code is written
14  * to work on the Motorola PrPMC800 ATX carrier board.
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License version 2 as
18  * published by the Free Software Foundation.
19  *
20  */
21
22 #include <linux/kernel.h>
23 #include <linux/config.h>
24 #include <linux/pci.h>
25 #include <linux/init.h>
26
27 #include <asm/mach-types.h>
28 #include <asm/irq.h>
29 #include <asm/hardware.h>
30
31 #include <asm/mach/pci.h>
32
33
34 void __init prpmc1100_pci_preinit(void)
35 {
36         gpio_line_config(PRPMC1100_PCI_INTA_PIN, 
37                                 IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
38         gpio_line_config(PRPMC1100_PCI_INTB_PIN, 
39                                 IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
40         gpio_line_config(PRPMC1100_PCI_INTC_PIN, 
41                                 IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
42         gpio_line_config(PRPMC1100_PCI_INTD_PIN, 
43                                 IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
44
45         gpio_line_isr_clear(PRPMC1100_PCI_INTA_PIN);
46         gpio_line_isr_clear(PRPMC1100_PCI_INTB_PIN);
47         gpio_line_isr_clear(PRPMC1100_PCI_INTC_PIN);
48         gpio_line_isr_clear(PRPMC1100_PCI_INTD_PIN);
49
50         ixp4xx_pci_preinit();
51 }
52
53
54 static int __init prpmc1100_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
55 {
56         int irq = -1;
57
58         static int pci_irq_table[][4] = { 
59                 {       /* IDSEL 16 - PMC A1 */
60                         IRQ_PRPMC1100_PCI_INTD, 
61                         IRQ_PRPMC1100_PCI_INTA, 
62                         IRQ_PRPMC1100_PCI_INTB, 
63                         IRQ_PRPMC1100_PCI_INTC
64                 }, {    /* IDSEL 17 - PRPMC-A-B */
65                         IRQ_PRPMC1100_PCI_INTD, 
66                         IRQ_PRPMC1100_PCI_INTA, 
67                         IRQ_PRPMC1100_PCI_INTB, 
68                         IRQ_PRPMC1100_PCI_INTC
69                 }, {    /* IDSEL 18 - PMC A1-B */
70                         IRQ_PRPMC1100_PCI_INTA, 
71                         IRQ_PRPMC1100_PCI_INTB, 
72                         IRQ_PRPMC1100_PCI_INTC, 
73                         IRQ_PRPMC1100_PCI_INTD
74                 }, {    /* IDSEL 19 - Unused */
75                         0, 0, 0, 0 
76                 }, {    /* IDSEL 20 - P2P Bridge */
77                         IRQ_PRPMC1100_PCI_INTA, 
78                         IRQ_PRPMC1100_PCI_INTB, 
79                         IRQ_PRPMC1100_PCI_INTC, 
80                         IRQ_PRPMC1100_PCI_INTD
81                 }, {    /* IDSEL 21 - PMC A2 */
82                         IRQ_PRPMC1100_PCI_INTC, 
83                         IRQ_PRPMC1100_PCI_INTD, 
84                         IRQ_PRPMC1100_PCI_INTA, 
85                         IRQ_PRPMC1100_PCI_INTB
86                 }, {    /* IDSEL 22 - PMC A2-B */
87                         IRQ_PRPMC1100_PCI_INTD, 
88                         IRQ_PRPMC1100_PCI_INTA, 
89                         IRQ_PRPMC1100_PCI_INTB, 
90                         IRQ_PRPMC1100_PCI_INTC
91                 },
92         };
93
94         if (slot >= PRPMC1100_PCI_MIN_DEVID && slot <= PRPMC1100_PCI_MAX_DEVID 
95                 && pin >= 1 && pin <= PRPMC1100_PCI_IRQ_LINES) {
96                 irq = pci_irq_table[slot - PRPMC1100_PCI_MIN_DEVID][pin - 1];
97         }
98
99         return irq;
100 }
101
102
103 struct hw_pci prpmc1100_pci __initdata = {
104         .nr_controllers = 1,
105         .preinit =        prpmc1100_pci_preinit,
106         .swizzle =        pci_std_swizzle,
107         .setup =          ixp4xx_setup,
108         .scan =           ixp4xx_scan_bus,
109         .map_irq =        prpmc1100_map_irq,
110 };
111
112 int __init prpmc1100_pci_init(void)
113 {
114         if (machine_is_prpmc1100())
115                 pci_common_init(&prpmc1100_pci);
116         return 0;
117 }
118
119 subsys_initcall(prpmc1100_pci_init);
120