http://downloads.netgear.com/files/GPL/GPL_Source_V361j_DM111PSP_series_consumer_rele...
[bcm963xx.git] / kernel / linux / 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/config.h>
23 #include <linux/pci.h>
24 #include <linux/init.h>
25
26 #include <asm/mach-types.h>
27 #include <asm/irq.h>
28 #include <asm/hardware.h>
29
30 #include <asm/mach/pci.h>
31
32
33 void __init prpmc1100_pci_preinit(void)
34 {
35         gpio_line_config(PRPMC1100_PCI_INTA_PIN, 
36                                 IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
37         gpio_line_config(PRPMC1100_PCI_INTB_PIN, 
38                                 IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
39         gpio_line_config(PRPMC1100_PCI_INTC_PIN, 
40                                 IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
41         gpio_line_config(PRPMC1100_PCI_INTD_PIN, 
42                                 IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
43
44         gpio_line_isr_clear(PRPMC1100_PCI_INTA_PIN);
45         gpio_line_isr_clear(PRPMC1100_PCI_INTB_PIN);
46         gpio_line_isr_clear(PRPMC1100_PCI_INTC_PIN);
47         gpio_line_isr_clear(PRPMC1100_PCI_INTD_PIN);
48
49         ixp4xx_pci_preinit();
50 }
51
52
53 static int __init prpmc1100_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
54 {
55         int irq = -1;
56
57         static int pci_irq_table[][4] = { 
58                 {       /* IDSEL 16 - PMC A1 */
59                         IRQ_PRPMC1100_PCI_INTD, 
60                         IRQ_PRPMC1100_PCI_INTA, 
61                         IRQ_PRPMC1100_PCI_INTB, 
62                         IRQ_PRPMC1100_PCI_INTC
63                 }, {    /* IDSEL 17 - PRPMC-A-B */
64                         IRQ_PRPMC1100_PCI_INTD, 
65                         IRQ_PRPMC1100_PCI_INTA, 
66                         IRQ_PRPMC1100_PCI_INTB, 
67                         IRQ_PRPMC1100_PCI_INTC
68                 }, {    /* IDSEL 18 - PMC A1-B */
69                         IRQ_PRPMC1100_PCI_INTA, 
70                         IRQ_PRPMC1100_PCI_INTB, 
71                         IRQ_PRPMC1100_PCI_INTC, 
72                         IRQ_PRPMC1100_PCI_INTD
73                 }, {    /* IDSEL 19 - Unused */
74                         0, 0, 0, 0 
75                 }, {    /* IDSEL 20 - P2P Bridge */
76                         IRQ_PRPMC1100_PCI_INTA, 
77                         IRQ_PRPMC1100_PCI_INTB, 
78                         IRQ_PRPMC1100_PCI_INTC, 
79                         IRQ_PRPMC1100_PCI_INTD
80                 }, {    /* IDSEL 21 - PMC A2 */
81                         IRQ_PRPMC1100_PCI_INTC, 
82                         IRQ_PRPMC1100_PCI_INTD, 
83                         IRQ_PRPMC1100_PCI_INTA, 
84                         IRQ_PRPMC1100_PCI_INTB
85                 }, {    /* IDSEL 22 - PMC A2-B */
86                         IRQ_PRPMC1100_PCI_INTD, 
87                         IRQ_PRPMC1100_PCI_INTA, 
88                         IRQ_PRPMC1100_PCI_INTB, 
89                         IRQ_PRPMC1100_PCI_INTC
90                 },
91         };
92
93         if (slot >= PRPMC1100_PCI_MIN_DEVID && slot <= PRPMC1100_PCI_MAX_DEVID 
94                 && pin >= 1 && pin <= PRPMC1100_PCI_IRQ_LINES) {
95                 irq = pci_irq_table[slot - PRPMC1100_PCI_MIN_DEVID][pin - 1];
96         }
97
98         return irq;
99 }
100
101
102 struct hw_pci prpmc1100_pci __initdata = {
103         .nr_controllers = 1,
104         .preinit =        prpmc1100_pci_preinit,
105         .swizzle =        pci_std_swizzle,
106         .setup =          ixp4xx_setup,
107         .scan =           ixp4xx_scan_bus,
108         .map_irq =        prpmc1100_map_irq,
109 };
110
111 int __init prpmc1100_pci_init(void)
112 {
113         if (machine_is_prpmc1100())
114                 pci_common_init(&prpmc1100_pci);
115         return 0;
116 }
117
118 subsys_initcall(prpmc1100_pci_init);
119