3 * Daniel Engström, Omicron Ceti AB <daniel@omicron.se>.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 /* stuff specific for the sc520, but independent of implementation */
29 #include <asm/ic/sc520.h>
36 { SC520_IRQ0, 0, 0x01 },
37 { SC520_IRQ1, 0, 0x02 },
38 { SC520_IRQ2, 1, 0x02 },
39 { SC520_IRQ3, 0, 0x08 },
40 { SC520_IRQ4, 0, 0x10 },
41 { SC520_IRQ5, 0, 0x20 },
42 { SC520_IRQ6, 0, 0x40 },
43 { SC520_IRQ7, 0, 0x80 },
45 { SC520_IRQ8, 1, 0x01 },
46 { SC520_IRQ9, 1, 0x02 },
47 { SC520_IRQ10, 1, 0x04 },
48 { SC520_IRQ11, 1, 0x08 },
49 { SC520_IRQ12, 1, 0x10 },
50 { SC520_IRQ13, 1, 0x20 },
51 { SC520_IRQ14, 1, 0x40 },
52 { SC520_IRQ15, 1, 0x80 }
56 /* The interrupt used for PCI INTA-INTD */
57 int sc520_pci_ints[15] = {
58 -1, -1, -1, -1, -1, -1, -1, -1,
59 -1, -1, -1, -1, -1, -1, -1
62 /* utility function to configure a pci interrupt */
63 int pci_sc520_set_irq(int pci_pin, int irq)
68 printf("set_irq(): map INT%c to IRQ%d\n", pci_pin + 'A', irq);
70 if (irq < 0 || irq > 15) {
71 return -1; /* illegal irq */
74 if (pci_pin < 0 || pci_pin > 15) {
75 return -1; /* illegal pci int pin */
78 /* first disable any non-pci interrupt source that use
81 /* PCI interrupt mapping (A through D)*/
82 for (i=0; i<=3 ;i++) {
83 if (sc520_mmcr->pci_int_map[i] == sc520_irq[irq].priority)
84 sc520_mmcr->pci_int_map[i] = SC520_IRQ_DISABLED;
87 /* GP IRQ interrupt mapping */
88 for (i=0; i<=10 ;i++) {
89 if (sc520_mmcr->gp_int_map[i] == sc520_irq[irq].priority)
90 sc520_mmcr->gp_int_map[i] = SC520_IRQ_DISABLED;
93 /* Set the trigger to level */
94 sc520_mmcr->pic_mode[sc520_irq[irq].level_reg] =
95 sc520_mmcr->pic_mode[sc520_irq[irq].level_reg] | sc520_irq[irq].level_bit;
100 /* route the interrupt */
101 sc520_mmcr->pci_int_map[pci_pin] = sc520_irq[irq].priority;
103 /* GPIRQ0-GPIRQ10 used for additional PCI INTS */
104 sc520_mmcr->gp_int_map[pci_pin - 4] = sc520_irq[irq].priority;
106 /* also set the polarity in this case */
107 sc520_mmcr->intpinpol = sc520_mmcr->intpinpol | (1 << (pci_pin-4));
110 /* register the pin */
111 sc520_pci_ints[pci_pin] = irq;
117 void pci_sc520_init(struct pci_controller *hose)
119 hose->first_busno = 0;
120 hose->last_busno = 0xff;
122 /* System memory space */
123 pci_set_region(hose->regions + 0,
124 SC520_PCI_MEMORY_BUS,
125 SC520_PCI_MEMORY_PHYS,
126 SC520_PCI_MEMORY_SIZE,
127 PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
129 /* PCI memory space */
130 pci_set_region(hose->regions + 1,
136 /* ISA/PCI memory space */
137 pci_set_region(hose->regions + 2,
144 pci_set_region(hose->regions + 3,
150 /* ISA/PCI I/O space */
151 pci_set_region(hose->regions + 4,
157 hose->region_count = 5;
159 pci_setup_type1(hose,
163 pci_register_hose(hose);
165 hose->last_busno = pci_hose_scan(hose);
167 /* enable target memory acceses on host brige */
168 pci_write_config_word(0, PCI_COMMAND,
169 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);