blob: 55d28230855cca15d3917e6643e6d40faf4525b7 [file] [log] [blame]
Ronald G. Minnich6226f132007-09-08 18:32:53 +00001/*
Ronald G. Minnich6503cd92007-11-07 23:13:43 +00002* This file is part of the LinuxBIOS project.
3*
4* Copyright (C) 2007 Advanced Micro Devices, Inc.
5*
6* This program is free software; you can redistribute it and/or modify
7* it under the terms of the GNU General Public License version 2 as
8* published by the Free Software Foundation.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program; if not, write to the Free Software
17* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18*/
Ronald G. Minnich6226f132007-09-08 18:32:53 +000019
20#include <arch/pirq_routing.h>
21#include <console/console.h>
22#include <arch/io.h>
23#include <arch/pirq_routing.h>
24#include "../../../southbridge/amd/cs5536/cs5536.h"
25
26/* Platform IRQs */
27#define PIRQA 11
Ronald G. Minnich6503cd92007-11-07 23:13:43 +000028#define PIRQB 10
29#define PIRQC 11
30#define PIRQD 9
Ronald G. Minnich6226f132007-09-08 18:32:53 +000031
32/* Map */
Ronald G. Minnich6503cd92007-11-07 23:13:43 +000033#define M_PIRQA (1 << PIRQA) /* Bitmap of supported IRQs */
34#define M_PIRQB (1 << PIRQB) /* Bitmap of supported IRQs */
35#define M_PIRQC (1 << PIRQC) /* Bitmap of supported IRQs */
36#define M_PIRQD (1 << PIRQD) /* Bitmap of supported IRQs */
Ronald G. Minnich6226f132007-09-08 18:32:53 +000037
38/* Link */
Ronald G. Minnich6503cd92007-11-07 23:13:43 +000039#define L_PIRQA 1 /* Means Slot INTx# Connects To Chipset INTA# */
40#define L_PIRQB 2 /* Means Slot INTx# Connects To Chipset INTB# */
41#define L_PIRQC 3 /* Means Slot INTx# Connects To Chipset INTC# */
42#define L_PIRQD 4 /* Means Slot INTx# Connects To Chipset INTD# */
Ronald G. Minnich6226f132007-09-08 18:32:53 +000043
Ronald G. Minnich6503cd92007-11-07 23:13:43 +000044/* ALIX 1c interrupt wiring. Devices are:
45 * 00:01.0 Host bridge: Advanced Micro Devices [AMD] CS5536 [Geode companion] Host Bridge (rev 31)
46 * 00:01.2 Entertainment encryption device: Advanced Micro Devices [AMD] Geode LX AES Security Block
47 * 00:0d.0 Ethernet controller: VIA Technologies, Inc. VT6105M [Rhine-III] (rev 96)
48 * 00:0e.0 Network controller: Intersil Corporation Prism 2.5 Wavelan chipset (rev 01)
49 * 00:0f.0 ISA bridge: Advanced Micro Devices [AMD] CS5536 [Geode companion] ISA (rev 03)
50 * 00:0f.2 IDE interface: Advanced Micro Devices [AMD] CS5536 [Geode companion] IDE (rev 01)
51 * 00:0f.3 Multimedia audio controller: Advanced Micro Devices [AMD] CS5536 [Geode companion] Audio (rev 01)
52 * 00:0f.4 USB Controller: Advanced Micro Devices [AMD] CS5536 [Geode companion] OHC (rev 02)
53 * 00:0f.5 USB Controller: Advanced Micro Devices [AMD] CS5536 [Geode companion] EHC (rev 02)
54 * The only devices that interrupt are:
55 * What device IRQ PIN PIN WIRED TO
56 * AES 00:01.2 0a 01 A A
57 * 3VPCI 00:0c.0 0a 01 A A
58 * eth0 00:0d.0 0b 01 A B
59 * mpci 00:0e.0 0a 01 A A
60 * usb 00:0f.3 0b 02 B B
61 * usb 00:0f.4 0b 04 D D
62 * usb 00:0f.5 0b 04 D D
63 *
64 * The only swizzled interrupt is eth0, where INTA is wired to interrupt controller line B
65*/
Ronald G. Minnich6226f132007-09-08 18:32:53 +000066const struct irq_routing_table intel_irq_routing_table = {
Ronald G. Minnich6503cd92007-11-07 23:13:43 +000067PIRQ_SIGNATURE, /* u32 signature */
68PIRQ_VERSION, /* u16 version */
6932 + 16 * IRQ_SLOT_COUNT,
700x00, /* Where the interrupt router lies (bus) */
71(0x0F << 3) | 0x0, /* Where the interrupt router lies (dev) */
720x00, /* IRQs devoted exclusively to PCI usage */
730x100B, /* Vendor */
740x002B, /* Device */
750, /* Crap (miniport) */
76{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* u8 rfu[11] */
770x00, /* u8 checksum , this has to set to
78 * some value that would give 0
79 * after the sum of all bytes
80 * for this structure
81 * (including checksum)
82 */
83{
84 /* If you change the number of entries,
85 * change the IRQ_SLOT_COUNT above!
86 */
87 /* bus, dev|fn, {link, bitmap}, {link, bitmap}, {link, bitmap}, {link, bitmap}, slot, rfu */
88 {0x00, (0x01 << 3) | 0x0, {{L_PIRQA, M_PIRQA}, {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}}, 0x0, 0x0}, /* cpu */
89 /* PCI SLOT */
90 {0x00, (0x0C << 3) | 0x0, {{L_PIRQA, M_PIRQA}, {L_PIRQB, M_PIRQB}, {L_PIRQC, M_PIRQC}, {L_PIRQD, M_PIRQD}}, 0x4, 0x0}, /* slot1 */
91 /* ONBOARD ETHER */
92 {0x00, (0x0D << 3) | 0x0, {{L_PIRQB, M_PIRQB}, {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}}, 0x0, 0x0}, /* ethernet */
93 /* MINI PCI */
94 {0x00, (0x0E << 3) | 0x0, {{L_PIRQA, M_PIRQA}, {L_PIRQB, M_PIRQB}, {L_PIRQC, M_PIRQC}, {L_PIRQD, M_PIRQD}}, 0x1, 0x0}, /* mini slot2 */
95 /* Chipset slots -- f.3 wires to B, and f.4 and f.5 wires to D */
96 {0x00, (0x0F << 3) | 0x0, {{L_PIRQA, M_PIRQA}, {L_PIRQB, M_PIRQB}, {L_PIRQC, M_PIRQC}, {L_PIRQD, M_PIRQD}}, 0x0, 0x0}, /* chipset */
Ronald G. Minnich6226f132007-09-08 18:32:53 +000097 }
98};
99
Ronald G. Minnich6503cd92007-11-07 23:13:43 +0000100unsigned long write_pirq_routing_table(unsigned long addr)
101{
102 int i, j, k, num_entries;
103 unsigned char pirq[4];
104 uint16_t chipset_irq_map;
105 uint32_t pciAddr, pirtable_end;
106 struct irq_routing_table *pirq_tbl;
Ronald G. Minnich6226f132007-09-08 18:32:53 +0000107
Ronald G. Minnich6503cd92007-11-07 23:13:43 +0000108 pirtable_end = copy_pirq_routing_table(addr);
Ronald G. Minnich6226f132007-09-08 18:32:53 +0000109
Ronald G. Minnich6503cd92007-11-07 23:13:43 +0000110 /* Set up chipset IRQ steering. */
111 pciAddr = 0x80000000 | (CHIPSET_DEV_NUM << 11) | 0x5C;
112 chipset_irq_map = (PIRQD << 12 | PIRQC << 8 | PIRQB << 4 | PIRQA);
113 printk_debug("%s(%08X, %04X)\n", __FUNCTION__, pciAddr,
114 chipset_irq_map);
115 outl(pciAddr & ~3, 0xCF8);
116 outl(chipset_irq_map, 0xCFC);
Ronald G. Minnich6226f132007-09-08 18:32:53 +0000117
Ronald G. Minnich6503cd92007-11-07 23:13:43 +0000118 pirq_tbl = (struct irq_routing_table *) (addr);
119 num_entries = (pirq_tbl->size - 32) / 16;
Ronald G. Minnich6226f132007-09-08 18:32:53 +0000120
Ronald G. Minnich6503cd92007-11-07 23:13:43 +0000121 /* Set PCI IRQs. */
122 for (i = 0; i < num_entries; i++) {
123 printk_debug("PIR Entry %d Dev/Fn: %X Slot: %d\n", i,
124 pirq_tbl->slots[i].devfn, pirq_tbl->slots[i].slot);
125 for (j = 0; j < 4; j++) {
126 printk_debug("INT: %c bitmap: %x ", 'A' + j,
127 pirq_tbl->slots[i].irq[j].bitmap);
128 /* Finds lsb in bitmap to IRQ#. */
129 for (k = 0;
130 (!((pirq_tbl->slots[i].irq[j].bitmap >> k) & 1))
131 && (pirq_tbl->slots[i].irq[j].bitmap != 0);
132 k++);
133 pirq[j] = k;
134 printk_debug("PIRQ: %d\n", k);
135 }
Ronald G. Minnich6226f132007-09-08 18:32:53 +0000136
Ronald G. Minnich6503cd92007-11-07 23:13:43 +0000137 /* Bus, device, slots IRQs for {A,B,C,D}. */
138 pci_assign_irqs(pirq_tbl->slots[i].bus,
139 pirq_tbl->slots[i].devfn >> 3, pirq);
140 }
Ronald G. Minnich6226f132007-09-08 18:32:53 +0000141
Ronald G. Minnich6503cd92007-11-07 23:13:43 +0000142 /* Put the PIR table in memory and checksum. */
143 return pirtable_end;
Ronald G. Minnich6226f132007-09-08 18:32:53 +0000144}