Here patch to support IRQ routing by LinuxBios. This is necessary for the right setup on the unsupported Linux's chips. This functionality is include through macro PIRQ_ROUTE in Config.lb. Tested on iei/juki-511p(cs5530a) and iei/pcisa-lx(cs5536).
Signed-off-by: Nikolay Petukhov <[EMAIL PROTECTED]> -- Nikolay
diff -Nru LinuxBIOSv2-2986/src/arch/i386/boot/pirq_routing.c LinuxBIOSv2-2986-pirq/src/arch/i386/boot/pirq_routing.c --- LinuxBIOSv2-2986/src/arch/i386/boot/pirq_routing.c 2005-01-19 19:06:41.000000000 +0500 +++ LinuxBIOSv2-2986-pirq/src/arch/i386/boot/pirq_routing.c 2007-11-26 09:39:25.000000000 +0500 @@ -1,6 +1,7 @@ #include <console/console.h> #include <arch/pirq_routing.h> #include <string.h> +#include <device/pci.h> #if (DEBUG==1 && HAVE_PIRQ_TABLE==1) static void check_pirq_routing_table(struct irq_routing_table *rt) @@ -94,6 +95,80 @@ memcpy((void *)addr, &intel_irq_routing_table, intel_irq_routing_table.size); printk_info("done.\n"); verify_copy_pirq_routing_table(addr); + pirq_routing_irqs(addr); return addr + intel_irq_routing_table.size; } #endif + +#if (PIRQ_ROUTE==1 && HAVE_PIRQ_TABLE==1) +void pirq_routing_irqs(unsigned long addr) +{ + int i, j, k, num_entries; + unsigned char irq_slot[4]; + unsigned char pirq[4] = {0, 0, 0, 0}; + struct irq_routing_table *pirq_tbl; + device_t pdev; + + pirq_tbl = (struct irq_routing_table *)(addr); + num_entries = (pirq_tbl->size - 32) / 16; + + /* Set PCI IRQs. */ + for (i = 0; i < num_entries; i++) { + + printk_debug("PIR Entry %d Dev/Fn: %X Slot: %d\n", i, + pirq_tbl->slots[i].devfn >> 3, pirq_tbl->slots[i].slot); + + for (j = 0; j < 4; j++) { + + int link = pirq_tbl->slots[i].irq[j].link; + int bitmap = pirq_tbl->slots[i].irq[j].bitmap & pirq_tbl->exclusive_irqs; + int irq = 0; + + printk_debug("INT: %c link: %x bitmap: %x ", + 'A' + j, link, bitmap); + + if (!bitmap|| !link || link > 4) { + + printk_debug("not routed\n"); + irq_slot[j] = irq; + continue; + } + + /* yet not routed */ + if (!pirq[link - 1]) { + + for (k = 2; k < 15; k++) { + + if (!((bitmap >> k) & 1)) + continue; + + irq = k; + + /* yet not routed */ + if (pirq[0] != irq && pirq[1] != irq && pirq[2] != irq && pirq[3] != irq) + break; + } + + if (irq) + pirq[link - 1] = irq; + } + else + irq = pirq[link - 1]; + + printk_debug("IRQ: %d\n", irq); + irq_slot[j] = irq; + } + + /* Bus, device, slots IRQs for {A,B,C,D}. */ + pci_assign_irqs(pirq_tbl->slots[i].bus, + pirq_tbl->slots[i].devfn >> 3, irq_slot); + } + + printk_debug("PIRQ1: %d\n", pirq[0]); + printk_debug("PIRQ2: %d\n", pirq[1]); + printk_debug("PIRQ3: %d\n", pirq[2]); + printk_debug("PIRQ4: %d\n", pirq[3]); + + pirq_assign_irqs(pirq); +} +#endif diff -Nru LinuxBIOSv2-2986/src/arch/i386/include/arch/pirq_routing.h LinuxBIOSv2-2986-pirq/src/arch/i386/include/arch/pirq_routing.h --- LinuxBIOSv2-2986/src/arch/i386/include/arch/pirq_routing.h 2005-07-07 00:17:35.000000000 +0600 +++ LinuxBIOSv2-2986-pirq/src/arch/i386/include/arch/pirq_routing.h 2007-11-26 09:39:25.000000000 +0500 @@ -42,6 +42,12 @@ #if HAVE_PIRQ_TABLE==1 unsigned long copy_pirq_routing_table(unsigned long start); unsigned long write_pirq_routing_table(unsigned long start); +#if PIRQ_ROUTE==1 +void pirq_routing_irqs(unsigned long start); +void pirq_assign_irqs(const unsigned char pIntAtoD[4]); +#else +#define pirq_routing_irqs(start) {} +#endif #else #define copy_pirq_routing_table(start) (start) #define write_pirq_routing_table(start) (start) diff -Nru LinuxBIOSv2-2986/src/config/Options.lb LinuxBIOSv2-2986-pirq/src/config/Options.lb --- LinuxBIOSv2-2986/src/config/Options.lb 2007-10-08 03:00:02.000000000 +0600 +++ LinuxBIOSv2-2986-pirq/src/config/Options.lb 2007-11-26 09:39:25.000000000 +0500 @@ -726,6 +726,11 @@ export used comment "IOAPIC support" end +define PIRQ_ROUTE + default 0 + export used + comment "Define if we have a PIRQ table and want routing irqs" +end ############################################### # IDE specific options diff -Nru LinuxBIOSv2-2986/src/southbridge/amd/cs5530/Config.lb LinuxBIOSv2-2986-pirq/src/southbridge/amd/cs5530/Config.lb --- LinuxBIOSv2-2986/src/southbridge/amd/cs5530/Config.lb 2007-10-06 03:00:10.000000000 +0600 +++ LinuxBIOSv2-2986-pirq/src/southbridge/amd/cs5530/Config.lb 2007-11-26 09:39:25.000000000 +0500 @@ -23,3 +23,4 @@ driver cs5530_isa.o driver cs5530_ide.o driver cs5530_vga.o +driver cs5530_pirq.o diff -Nru LinuxBIOSv2-2986/src/southbridge/amd/cs5530/cs5530_pirq.c LinuxBIOSv2-2986-pirq/src/southbridge/amd/cs5530/cs5530_pirq.c --- LinuxBIOSv2-2986/src/southbridge/amd/cs5530/cs5530_pirq.c 1970-01-01 05:00:00.000000000 +0500 +++ LinuxBIOSv2-2986-pirq/src/southbridge/amd/cs5530/cs5530_pirq.c 2007-11-26 09:39:25.000000000 +0500 @@ -0,0 +1,39 @@ +/* + * This file is part of the LinuxBIOS project. + * + * Copyright (C) 2007 Nikolay Petukhov <[EMAIL PROTECTED]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <arch/pirq_routing.h> +#include <console/console.h> +#include <device/pci.h> +#include <device/pci_ids.h> + +#if (PIRQ_ROUTE==1 && HAVE_PIRQ_TABLE==1) +void pirq_assign_irqs(const unsigned char pIntAtoD[4]) +{ + device_t pdev; + + pdev = dev_find_device(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_LEGACY, 0); + + if (pdev) { + + pci_write_config8(pdev, 0x5c, (pIntAtoD[1] << 4 | pIntAtoD[0])); + pci_write_config8(pdev, 0x5d, (pIntAtoD[3] << 4 | pIntAtoD[2])); + } +} +#endif diff -Nru LinuxBIOSv2-2986/src/southbridge/amd/cs5536/Config.lb LinuxBIOSv2-2986-pirq/src/southbridge/amd/cs5536/Config.lb --- LinuxBIOSv2-2986/src/southbridge/amd/cs5536/Config.lb 2007-05-22 16:12:49.000000000 +0600 +++ LinuxBIOSv2-2986-pirq/src/southbridge/amd/cs5536/Config.lb 2007-11-26 09:39:25.000000000 +0500 @@ -20,3 +20,4 @@ config chip.h driver cs5536.o driver cs5536_ide.o +driver cs5536_pirq.o diff -Nru LinuxBIOSv2-2986/src/southbridge/amd/cs5536/cs5536_pirq.c LinuxBIOSv2-2986-pirq/src/southbridge/amd/cs5536/cs5536_pirq.c --- LinuxBIOSv2-2986/src/southbridge/amd/cs5536/cs5536_pirq.c 1970-01-01 05:00:00.000000000 +0500 +++ LinuxBIOSv2-2986-pirq/src/southbridge/amd/cs5536/cs5536_pirq.c 2007-11-26 09:48:19.000000000 +0500 @@ -0,0 +1,37 @@ +/* + * This file is part of the LinuxBIOS project. + * + * Copyright (C) 2007 Nikolay Petukhov <[EMAIL PROTECTED]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <arch/pirq_routing.h> +#include <console/console.h> +#include <device/pci.h> +#include <device/pci_ids.h> + +#if (PIRQ_ROUTE==1 && HAVE_PIRQ_TABLE==1) +void pirq_assign_irqs(const unsigned char pIntAtoD[4]) +{ + device_t pdev; + + pdev = dev_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA, 0); + + if (pdev) { + pci_write_config16(pdev, 0x5c, (pIntAtoD[3] << 12 | pIntAtoD[2] << 8 | pIntAtoD[1] << 4 | pIntAtoD[0])); + } +} +#endif
diff -Nru LinuxBIOSv2-2986/src/mainboard/iei/juki-511p/Config.lb LinuxBIOSv2-2986-juki/src/mainboard/iei/juki-511p/Config.lb --- LinuxBIOSv2-2986/src/mainboard/iei/juki-511p/Config.lb 2007-06-08 02:52:42.000000000 +0600 +++ LinuxBIOSv2-2986-juki/src/mainboard/iei/juki-511p/Config.lb 2007-11-26 09:51:35.000000000 +0500 @@ -156,6 +156,10 @@ device pci 0e.0 on end # ETH0 device pci 13.0 on end # USB + device pci 09.0 on end # Slot 1 + device pci 0a.0 on end # Slot 2 + device pci 0b.0 on end # Slot 3 + device pci 0c.0 on end # Slot 4 end end diff -Nru LinuxBIOSv2-2986/src/mainboard/iei/juki-511p/irq_tables.c LinuxBIOSv2-2986-juki/src/mainboard/iei/juki-511p/irq_tables.c --- LinuxBIOSv2-2986/src/mainboard/iei/juki-511p/irq_tables.c 2007-06-08 02:52:42.000000000 +0600 +++ LinuxBIOSv2-2986-juki/src/mainboard/iei/juki-511p/irq_tables.c 2007-11-26 09:51:35.000000000 +0500 @@ -19,48 +19,67 @@ */ #include <arch/pirq_routing.h> +#include <console/console.h> +#include <device/pci.h> -#define IRQ_BITMAP_LINK0 0x0800 /* chipset's INTA# input should be routed to IRQ11 */ -#define IRQ_BITMAP_LINK1 0x0400 /* chipset's INTB# input should be routed to IRQ10 */ -#define IRQ_BITMAP_LINK2 0x0000 /* chipset's INTC# input should be routed to nothing (disabled) */ -#define IRQ_BITMAP_LINK3 0x0000 /* chipset's INTD# input should be routed to nothing (disabled) */ +/* Platform IRQs */ +#define PIRQA 11 +#define PIRQB 9 +#define PIRQC 12 +#define PIRQD 10 + +/* Link */ +#define LINK_PIRQA 1 +#define LINK_PIRQB 2 +#define LINK_PIRQC 3 +#define LINK_PIRQD 4 +#define LINK_NONE 0 + +/* Map */ +#define IRQ_BITMAP_LINKA (1 << PIRQA) +#define IRQ_BITMAP_LINKB (1 << PIRQB) +#define IRQ_BITMAP_LINKC (1 << PIRQC) +#define IRQ_BITMAP_LINKD (1 << PIRQD) +#define IRQ_BITMAP_NOLINK 0x0 + +#define EXCLUSIVE_PCI_IRQS (IRQ_BITMAP_LINKA | IRQ_BITMAP_LINKB | IRQ_BITMAP_LINKC | IRQ_BITMAP_LINKD) const struct irq_routing_table intel_irq_routing_table = { PIRQ_SIGNATURE, /* u32 signature */ PIRQ_VERSION, /* u16 version */ - 32+16*2, /* There can be a total of 2 devices on the bus */ + 32+16*IRQ_SLOT_COUNT, /* There can be a total of IRQ_SLOT_COUNT devices on the bus */ 0x00, /* Where the interrupt router lies (bus) */ (0x12<<3)|0x0, /* Where the interrupt router lies (dev) */ - 0xc00, /* IRQs devoted exclusively to PCI usage */ + EXCLUSIVE_PCI_IRQS, /* IRQs devoted exclusively to PCI usage */ 0x1078, /* Vendor */ 0x2, /* Device */ 0, /* Crap (miniport) */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* u8 rfu[11] */ - 0x57, /* u8 checksum. This has to be set to some + 0x29, /* u8 checksum. This has to be set to some value that would give 0 after the sum of all bytes for this structure (including checksum) */ .slots = { [0] = { - .slot = 0x0, /* should be 0 when it is no real slot. My device is soldered */ + .slot = 0x0, /* means also "on board" */ .bus = 0x00, - .devfn = (0x13<<3)|0x0, /* 0x13 is my USB OHCI */ + .devfn = (0x13<<3)|0x0, /* 0x13 is USB OHCI */ .irq = { [0] = { /* <-- 0 means this is INTA# output from the device or slot */ - .link = 0x01, /* 0x01 means its connected to INTA# input at chipset */ - .bitmap = IRQ_BITMAP_LINK0 + .link = LINK_PIRQA, + .bitmap = IRQ_BITMAP_LINKA }, [1] = { /* <-- 1 means this is INTB# output from the device or slot */ - .link = 0x02, /* 0x02 means its connected to INTB# input at chipset */ - .bitmap = IRQ_BITMAP_LINK1 + .link = LINK_NONE, + .bitmap = IRQ_BITMAP_NOLINK }, [2] = { /* <-- 2 means this is INTC# output from the device or slot */ - .link = 0x03, /* 0x03 means its connected to INTC# input at chipset */ - .bitmap = IRQ_BITMAP_LINK2 + .link = LINK_NONE, + .bitmap = IRQ_BITMAP_NOLINK }, [3] = { /* <-- 3 means this is INTD# output from the device or slot */ - .link = 0x04, /* 0x04 means its connected to INTD# input at chipset */ - .bitmap = IRQ_BITMAP_LINK3 + .link = LINK_NONE, + .bitmap = IRQ_BITMAP_NOLINK } } }, @@ -68,26 +87,135 @@ [1] = { .slot = 0x0, /* means also "on board" */ .bus = 0x00, - .devfn = (0x0e<<3)|0x0, /* 0x0e is my Realtek Network device */ + .devfn = (0x0e<<3)|0x0, /* 0x0e is Realtek Network device */ + .irq = { + [0] = { /* <-- 0 means this is INTA# output from the device or slot */ + .link = LINK_PIRQB, + .bitmap = IRQ_BITMAP_LINKB + }, + [1] = { /* <-- 1 means this is INTB# output from the device or slot */ + .link = LINK_NONE, + .bitmap = IRQ_BITMAP_NOLINK + }, + [2] = { /* <-- 2 means this is INTC# output from the device or slot */ + .link = LINK_NONE, + .bitmap = IRQ_BITMAP_NOLINK + }, + [3] = { /* <-- 3 means this is INTD# output from the device or slot */ + .link = LINK_NONE, + .bitmap = IRQ_BITMAP_NOLINK + } + } + }, + +/* + * ################### backplane ################### + */ + +/* + * Not exist on IP-6S, but it PCI1 on IP-7S. + */ + [2] = { + .slot = 0x1, /* This is real PCI slot. */ + .bus = 0x00, + .devfn = (0x09<<3)|0x0, /* 0x09 is PCI1 */ + .irq = { + [0] = { /* <-- 0 means this is INTA# output from the device or slot */ + .link = LINK_PIRQA, + .bitmap = IRQ_BITMAP_LINKA + }, + [1] = { /* <-- 1 means this is INTB# output from the device or slot */ + .link = LINK_PIRQB, + .bitmap = IRQ_BITMAP_LINKB + }, + [2] = { /* <-- 2 means this is INTC# output from the device or slot */ + .link = LINK_PIRQC, + .bitmap = IRQ_BITMAP_LINKC + }, + [3] = { /* <-- 3 means this is INTD# output from the device or slot */ + .link = LINK_PIRQD, + .bitmap = IRQ_BITMAP_LINKD + } + } + }, +/* + * PCI2 IP-6S + */ + [3] = { + .slot = 0x2, /* This is real PCI slot. */ + .bus = 0x00, + .devfn = (0x0a<<3)|0x0, /* 0x0a is PCI2 on IP-6S */ + .irq = { + [0] = { /* <-- 0 means this is INTA# output from the device or slot */ + .link = LINK_PIRQD, + .bitmap = IRQ_BITMAP_LINKD + }, + [1] = { /* <-- 1 means this is INTB# output from the device or slot */ + .link = LINK_PIRQA, + .bitmap = IRQ_BITMAP_LINKA + }, + [2] = { /* <-- 2 means this is INTC# output from the device or slot */ + .link = LINK_PIRQB, + .bitmap = IRQ_BITMAP_LINKB + }, + [3] = { /* <-- 3 means this is INTD# output from the device or slot */ + .link = LINK_PIRQC, + .bitmap = IRQ_BITMAP_LINKC + } + } + }, +/* + * PCI3 IP-6S + */ + [4] = { + .slot = 0x3, /* This is real PCI slot. */ + .bus = 0x00, + .devfn = (0x0b<<3)|0x0, /* 0x0b is PCI3 on IP-6S */ .irq = { [0] = { /* <-- 0 means this is INTA# output from the device or slot */ - .link = 0x02, /* 0x02 means its connected to INTB# input at chipset */ - .bitmap = IRQ_BITMAP_LINK1 + .link = LINK_PIRQC, + .bitmap = IRQ_BITMAP_LINKC }, [1] = { /* <-- 1 means this is INTB# output from the device or slot */ - .link = 0x03, /* 0x03 means its connected to INTC# input at chipset */ - .bitmap = IRQ_BITMAP_LINK2 + .link = LINK_PIRQD, + .bitmap = IRQ_BITMAP_LINKD }, [2] = { /* <-- 2 means this is INTC# output from the device or slot */ - .link = 0x04, /* 0x04 means its connected to INTD# input at chipset */ - .bitmap = IRQ_BITMAP_LINK3 + .link = LINK_PIRQA, + .bitmap = IRQ_BITMAP_LINKA }, [3] = { /* <-- 3 means this is INTD# output from the device or slot */ - .link = 0x01, /* 0x01 means its connected to INTA# input at chipset */ - .bitmap = IRQ_BITMAP_LINK0 + .link = LINK_PIRQB, + .bitmap = IRQ_BITMAP_LINKB } } - } + }, +/* + * PCI4 IP-6S + */ + [5] = { + .slot = 0x4, /* This is real PCI slot. */ + .bus = 0x00, + .devfn = (0x0c<<3)|0x0, /* 0x0c is PCI4 on IP-6S */ + .irq = { + [0] = { /* <-- 0 means this is INTA# output from the device or slot */ + .link = LINK_PIRQB, + .bitmap = IRQ_BITMAP_LINKB + }, + [1] = { /* <-- 1 means this is INTB# output from the device or slot */ + .link = LINK_PIRQC, + .bitmap = IRQ_BITMAP_LINKC + }, + [2] = { /* <-- 2 means this is INTC# output from the device or slot */ + .link = LINK_PIRQD, + .bitmap = IRQ_BITMAP_LINKD + }, + [3] = { /* <-- 3 means this is INTD# output from the device or slot */ + .link = LINK_PIRQA, + .bitmap = IRQ_BITMAP_LINKA + } + } + }, } }; diff -Nru LinuxBIOSv2-2986/src/mainboard/iei/juki-511p/Options.lb LinuxBIOSv2-2986-juki/src/mainboard/iei/juki-511p/Options.lb --- LinuxBIOSv2-2986/src/mainboard/iei/juki-511p/Options.lb 2007-10-11 16:25:35.000000000 +0600 +++ LinuxBIOSv2-2986-juki/src/mainboard/iei/juki-511p/Options.lb 2007-11-26 09:51:35.000000000 +0500 @@ -42,7 +42,11 @@ uses TTYS0_BAUD uses TTYS0_BASE uses TTYS0_LCS +uses CONFIG_GX1_VIDEO +uses CONFIG_GX1_VIDEOMODE uses CONFIG_VIDEO_MB +uses CONFIG_SPLASH_GRAPHIC +uses PIRQ_ROUTE ## ROM_SIZE is the size of boot ROM that this board will use. default ROM_SIZE = 256*1024 @@ -71,7 +75,8 @@ ## Build code to export a programmable irq routing table ## default HAVE_PIRQ_TABLE=0 -default IRQ_SLOT_COUNT=2 +default IRQ_SLOT_COUNT=6 +default PIRQ_ROUTE=1 #object irq_tables.o ## @@ -140,7 +145,10 @@ default CC="$(CROSS_COMPILE)gcc -m32" default HOSTCC="gcc" -default CONFIG_VIDEO_MB = 0 +default CONFIG_GX1_VIDEO = 1 +default CONFIG_GX1_VIDEOMODE = 0 +default CONFIG_VIDEO_MB = 2 +default CONFIG_SPLASH_GRAPHIC = 1 end diff -Nru LinuxBIOSv2-2986/targets/iei/juki-511p/Config.lb LinuxBIOSv2-2986-juki/targets/iei/juki-511p/Config.lb --- LinuxBIOSv2-2986/targets/iei/juki-511p/Config.lb 2007-06-08 02:52:42.000000000 +0600 +++ LinuxBIOSv2-2986-juki/targets/iei/juki-511p/Config.lb 2007-11-26 09:51:35.000000000 +0500 @@ -28,6 +28,9 @@ option CONFIG_COMPRESS=0 option CONFIG_PRECOMPRESSED_PAYLOAD=0 +option DEFAULT_CONSOLE_LOGLEVEL=0 +option MAXIMUM_CONSOLE_LOGLEVEL=0 + romimage "image" option ROM_IMAGE_SIZE=64*1024 option LINUXBIOS_EXTRA_VERSION="-filo"
-- linuxbios mailing list linuxbios@linuxbios.org http://www.linuxbios.org/mailman/listinfo/linuxbios