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, SC520_MPICMODE, 0x01 },
37 { SC520_IRQ1, SC520_MPICMODE, 0x02 },
38 { SC520_IRQ2, SC520_SL1PICMODE, 0x02 },
39 { SC520_IRQ3, SC520_MPICMODE, 0x08 },
40 { SC520_IRQ4, SC520_MPICMODE, 0x10 },
41 { SC520_IRQ5, SC520_MPICMODE, 0x20 },
42 { SC520_IRQ6, SC520_MPICMODE, 0x40 },
43 { SC520_IRQ7, SC520_MPICMODE, 0x80 },
45 { SC520_IRQ8, SC520_SL1PICMODE, 0x01 },
46 { SC520_IRQ9, SC520_SL1PICMODE, 0x02 },
47 { SC520_IRQ10, SC520_SL1PICMODE, 0x04 },
48 { SC520_IRQ11, SC520_SL1PICMODE, 0x08 },
49 { SC520_IRQ12, SC520_SL1PICMODE, 0x10 },
50 { SC520_IRQ13, SC520_SL1PICMODE, 0x20 },
51 { SC520_IRQ14, SC520_SL1PICMODE, 0x40 },
52 { SC520_IRQ15, SC520_SL1PICMODE, 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
80 for (i=SC520_GPTMR0MAP;i<=SC520_GP10IMAP;i++) {
81 if (i>=SC520_PCIINTAMAP&&i<=SC520_PCIINTDMAP) {
84 if (read_mmcr_byte(i) == sc520_irq[irq].priority) {
85 write_mmcr_byte(i, SC520_IRQ_DISABLED);
89 /* Set the trigger to level */
90 write_mmcr_byte(sc520_irq[irq].level_reg,
91 read_mmcr_byte(sc520_irq[irq].level_reg) | sc520_irq[irq].level_bit);
96 /* route the interrupt */
97 write_mmcr_byte(SC520_PCIINTAMAP + pci_pin, sc520_irq[irq].priority);
101 /* GPIRQ0-GPIRQ10 used for additional PCI INTS */
102 write_mmcr_byte(SC520_GP0IMAP + pci_pin - 4, sc520_irq[irq].priority);
104 /* also set the polarity in this case */
105 write_mmcr_word(SC520_INTPINPOL,
106 read_mmcr_word(SC520_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_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);