finally fix pci issues (#132)

SVN-Revision: 2716
owl
Felix Fietkau 2005-12-18 05:04:07 +00:00
parent 4ecc713044
commit 69740db1f8
1 changed files with 85 additions and 42 deletions

View File

@ -1247,7 +1247,7 @@ diff -urN linux.old/arch/mips/bcm947xx/broadcom/linux_osl.c linux.dev/arch/mips/
+ +
diff -urN linux.old/arch/mips/bcm947xx/broadcom/nvram.c linux.dev/arch/mips/bcm947xx/broadcom/nvram.c diff -urN linux.old/arch/mips/bcm947xx/broadcom/nvram.c linux.dev/arch/mips/bcm947xx/broadcom/nvram.c
--- linux.old/arch/mips/bcm947xx/broadcom/nvram.c 1970-01-01 01:00:00.000000000 +0100 --- linux.old/arch/mips/bcm947xx/broadcom/nvram.c 1970-01-01 01:00:00.000000000 +0100
+++ linux.dev/arch/mips/bcm947xx/broadcom/nvram.c 2005-12-17 21:41:45.656819500 +0100 +++ linux.dev/arch/mips/bcm947xx/broadcom/nvram.c 2005-12-18 04:59:36.185204500 +0100
@@ -0,0 +1,165 @@ @@ -0,0 +1,165 @@
+/* +/*
+ * NVRAM variable manipulation (Linux kernel half) + * NVRAM variable manipulation (Linux kernel half)
@ -1294,7 +1294,7 @@ diff -urN linux.old/arch/mips/bcm947xx/broadcom/nvram.c linux.dev/arch/mips/bcm9
+extern spinlock_t bcm947xx_sbh_lock; +extern spinlock_t bcm947xx_sbh_lock;
+static int cfe_env; +static int cfe_env;
+ +
+extern char *cfe_env_get(unsigned char *nv_buf, char *name); +extern char *cfe_env_get(char *nv_buf, const char *name);
+ +
+ +
+/* Convenience */ +/* Convenience */
@ -2458,8 +2458,8 @@ diff -urN linux.old/arch/mips/bcm947xx/broadcom/sbmips.c linux.dev/arch/mips/bcm
+ +
diff -urN linux.old/arch/mips/bcm947xx/broadcom/sbpci.c linux.dev/arch/mips/bcm947xx/broadcom/sbpci.c diff -urN linux.old/arch/mips/bcm947xx/broadcom/sbpci.c linux.dev/arch/mips/bcm947xx/broadcom/sbpci.c
--- linux.old/arch/mips/bcm947xx/broadcom/sbpci.c 1970-01-01 01:00:00.000000000 +0100 --- linux.old/arch/mips/bcm947xx/broadcom/sbpci.c 1970-01-01 01:00:00.000000000 +0100
+++ linux.dev/arch/mips/bcm947xx/broadcom/sbpci.c 2005-12-15 23:50:31.846688500 +0100 +++ linux.dev/arch/mips/bcm947xx/broadcom/sbpci.c 2005-12-18 05:36:53.351735500 +0100
@@ -0,0 +1,531 @@ @@ -0,0 +1,533 @@
+/* +/*
+ * Low-Level PCI and SB support for BCM47xx + * Low-Level PCI and SB support for BCM47xx
+ * + *
@ -2873,9 +2873,11 @@ diff -urN linux.old/arch/mips/bcm947xx/broadcom/sbpci.c linux.dev/arch/mips/bcm9
+ subclass = PCI_MEMORY_RAM; + subclass = PCI_MEMORY_RAM;
+ break; + break;
+ case SB_PCI: + case SB_PCI:
+#if 0
+ class = PCI_CLASS_BRIDGE; + class = PCI_CLASS_BRIDGE;
+ subclass = PCI_BRIDGE_PCI; + subclass = PCI_BRIDGE_PCI;
+ break; + break;
+#endif
+ case SB_MIPS: + case SB_MIPS:
+ case SB_MIPS33: + case SB_MIPS33:
+ class = PCI_CLASS_CPU; + class = PCI_CLASS_CPU;
@ -11219,8 +11221,8 @@ diff -urN linux.old/arch/mips/bcm947xx/irq.c linux.dev/arch/mips/bcm947xx/irq.c
+} +}
diff -urN linux.old/arch/mips/bcm947xx/pci.c linux.dev/arch/mips/bcm947xx/pci.c diff -urN linux.old/arch/mips/bcm947xx/pci.c linux.dev/arch/mips/bcm947xx/pci.c
--- linux.old/arch/mips/bcm947xx/pci.c 1970-01-01 01:00:00.000000000 +0100 --- linux.old/arch/mips/bcm947xx/pci.c 1970-01-01 01:00:00.000000000 +0100
+++ linux.dev/arch/mips/bcm947xx/pci.c 2005-12-17 18:11:52.350836000 +0100 +++ linux.dev/arch/mips/bcm947xx/pci.c 2005-12-18 04:44:18.736590500 +0100
@@ -0,0 +1,92 @@ @@ -0,0 +1,91 @@
+#include <linux/kernel.h> +#include <linux/kernel.h>
+#include <linux/init.h> +#include <linux/init.h>
+#include <linux/pci.h> +#include <linux/pci.h>
@ -11263,7 +11265,6 @@ diff -urN linux.old/arch/mips/bcm947xx/pci.c linux.dev/arch/mips/bcm947xx/pci.c
+ .write = sb_pci_write_config, + .write = sb_pci_write_config,
+}; +};
+ +
+
+static struct resource sb_pci_mem_resource = { +static struct resource sb_pci_mem_resource = {
+ .name = "SB PCI Memory resources", + .name = "SB PCI Memory resources",
+ .start = SB_ENUM_BASE, + .start = SB_ENUM_BASE,
@ -11273,8 +11274,8 @@ diff -urN linux.old/arch/mips/bcm947xx/pci.c linux.dev/arch/mips/bcm947xx/pci.c
+ +
+static struct resource sb_pci_io_resource = { +static struct resource sb_pci_io_resource = {
+ .name = "SB PCI I/O resources", + .name = "SB PCI I/O resources",
+ .start = 0x100, + .start = 0x000,
+ .end = 0x1FF, + .end = 0x0FF,
+ .flags = IORESOURCE_IO, + .flags = IORESOURCE_IO,
+}; +};
+ +
@ -11287,27 +11288,27 @@ diff -urN linux.old/arch/mips/bcm947xx/pci.c linux.dev/arch/mips/bcm947xx/pci.c
+static struct resource ext_pci_mem_resource = { +static struct resource ext_pci_mem_resource = {
+ .name = "Ext PCI Memory resources", + .name = "Ext PCI Memory resources",
+ .start = 0x40000000, + .start = 0x40000000,
+ .end = 0x40ffffff, + .end = 0x7fffffff,
+ .flags = IORESOURCE_MEM, + .flags = IORESOURCE_MEM,
+}; +};
+ +
+static struct resource ext_pci_io_resource = { +static struct resource ext_pci_io_resource = {
+ .name = "Ext PCI I/O resources", + .name = "Ext PCI I/O resources",
+ .start = 0x200, + .start = 0x100,
+ .end = 0x2FF, + .end = 0x1FF,
+ .flags = IORESOURCE_IO, + .flags = IORESOURCE_IO,
+}; +};
+ +
+static struct pci_controller bcm47xx_ext_pci_controller = { +static struct pci_controller bcm47xx_ext_pci_controller = {
+ .pci_ops = &sb_pci_ops, + .pci_ops = &sb_pci_ops,
+ .mem_resource = &ext_pci_mem_resource,
+ .io_resource = &ext_pci_io_resource, + .io_resource = &ext_pci_io_resource,
+ .mem_resource = &ext_pci_mem_resource,
+ .mem_offset = 0x24000000,
+}; +};
+ +
+void bcm47xx_pci_init(void) +void bcm47xx_pci_init(void)
+{ +{
+ sbpci_init(sbh); + sbpci_init(sbh);
+
+ set_io_port_base((unsigned long) ioremap_nocache(SB_PCI_MEM, 0x04000000)); + set_io_port_base((unsigned long) ioremap_nocache(SB_PCI_MEM, 0x04000000));
+ +
+ register_pci_controller(&bcm47xx_sb_pci_controller); + register_pci_controller(&bcm47xx_sb_pci_controller);
@ -11378,7 +11379,7 @@ diff -urN linux.old/arch/mips/bcm947xx/prom.c linux.dev/arch/mips/bcm947xx/prom.
+} +}
diff -urN linux.old/arch/mips/bcm947xx/setup.c linux.dev/arch/mips/bcm947xx/setup.c diff -urN linux.old/arch/mips/bcm947xx/setup.c linux.dev/arch/mips/bcm947xx/setup.c
--- linux.old/arch/mips/bcm947xx/setup.c 1970-01-01 01:00:00.000000000 +0100 --- linux.old/arch/mips/bcm947xx/setup.c 1970-01-01 01:00:00.000000000 +0100
+++ linux.dev/arch/mips/bcm947xx/setup.c 2005-12-17 22:14:27.619043750 +0100 +++ linux.dev/arch/mips/bcm947xx/setup.c 2005-12-18 04:58:53.946564750 +0100
@@ -0,0 +1,155 @@ @@ -0,0 +1,155 @@
+/* +/*
+ * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org) + * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
@ -11423,6 +11424,8 @@ diff -urN linux.old/arch/mips/bcm947xx/setup.c linux.dev/arch/mips/bcm947xx/setu
+#include <sbpci.h> +#include <sbpci.h>
+#include <sbconfig.h> +#include <sbconfig.h>
+#include <bcmdevs.h> +#include <bcmdevs.h>
+#include <bcmutils.h>
+#include <bcmnvram.h>
+ +
+extern void bcm47xx_pci_init(void); +extern void bcm47xx_pci_init(void);
+extern void bcm47xx_time_init(void); +extern void bcm47xx_time_init(void);
@ -11504,13 +11507,11 @@ diff -urN linux.old/arch/mips/bcm947xx/setup.c linux.dev/arch/mips/bcm947xx/setu
+ char *s; + char *s;
+ int i; + int i;
+ +
+ sbh = sb_kattach(); + sbh = (void *) sb_kattach();
+ sb_mips_init(sbh); + sb_mips_init(sbh);
+ +
+ bcm47xx_pci_init(); + bcm47xx_pci_init();
+ +
+ set_io_port_base((unsigned long) ioremap_nocache(SB_PCI_MEM, 0x04000000));
+
+ sb_serial_init(sbh, serial_add); + sb_serial_init(sbh, serial_add);
+ boardflags = getintvar(NULL, "boardflags"); + boardflags = getintvar(NULL, "boardflags");
+ +
@ -11695,16 +11696,14 @@ diff -urN linux.old/arch/mips/pci/Makefile linux.dev/arch/mips/pci/Makefile
# These are still pretty much in the old state, watch, go blind. # These are still pretty much in the old state, watch, go blind.
diff -urN linux.old/arch/mips/pci/fixup-bcm47xx.c linux.dev/arch/mips/pci/fixup-bcm47xx.c diff -urN linux.old/arch/mips/pci/fixup-bcm47xx.c linux.dev/arch/mips/pci/fixup-bcm47xx.c
--- linux.old/arch/mips/pci/fixup-bcm47xx.c 1970-01-01 01:00:00.000000000 +0100 --- linux.old/arch/mips/pci/fixup-bcm47xx.c 1970-01-01 01:00:00.000000000 +0100
+++ linux.dev/arch/mips/pci/fixup-bcm47xx.c 2005-12-15 12:57:27.945158000 +0100 +++ linux.dev/arch/mips/pci/fixup-bcm47xx.c 2005-12-18 04:42:58.079549750 +0100
@@ -0,0 +1,23 @@ @@ -0,0 +1,78 @@
+#include <linux/init.h> +#include <linux/init.h>
+#include <linux/pci.h> +#include <linux/pci.h>
+ +#include <typedefs.h>
+/* Do platform specific device initialization at pci_enable_device() time */ +#include <sbconfig.h>
+int pcibios_plat_dev_init(struct pci_dev *dev) +#include <bcmdevs.h>
+{ +#include <pcicfg.h>
+ return 0;
+}
+ +
+int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
+{ +{
@ -11717,22 +11716,66 @@ diff -urN linux.old/arch/mips/pci/fixup-bcm47xx.c linux.dev/arch/mips/pci/fixup-
+ return irq + 2; + return irq + 2;
+} +}
+ +
+struct pci_fixup pcibios_fixups[] = { +u32 pci_iobase = 0x100;
+ { 0 } +u32 pci_membase = SB_PCI_DMA;
+}; +
diff -urN linux.old/arch/mips/pci/pci.c linux.dev/arch/mips/pci/pci.c +static void bcm47xx_fixup_device(struct pci_dev *d)
--- linux.old/arch/mips/pci/pci.c 2005-12-15 13:26:49.814003000 +0100 +{
+++ linux.dev/arch/mips/pci/pci.c 2005-12-17 18:08:13.553162000 +0100 + struct resource *res;
@@ -307,7 +307,8 @@ + int pos, size;
if (res->flags & IORESOURCE_IO) + u32 *base;
offset = hose->io_offset; +
else if (res->flags & IORESOURCE_MEM) + if (d->bus->number == 0)
- offset = hose->mem_offset; + return;
+// offset = hose->mem_offset; +
+ offset = 0x24000000; + printk("PCI: Fixing up device %s\n", pci_name(d));
+
res->start = region->start + offset; + /* Fix up resource bases */
res->end = region->end + offset; + for (pos = 0; pos < 6; pos++) {
+ res = &d->resource[pos];
+ base = ((res->flags & IORESOURCE_IO) ? &pci_iobase : &pci_membase);
+ if (res->end) {
+ size = res->end - res->start + 1;
+ if (*base & (size - 1))
+ *base = (*base + size) & ~(size - 1);
+ res->start = *base;
+ res->end = res->start + size - 1;
+ *base += size;
+ pci_write_config_dword(d, PCI_BASE_ADDRESS_0 + (pos << 2), res->start);
+ }
+ /* Fix up PCI bridge BAR0 only */
+ if (d->bus->number == 1 && PCI_SLOT(d->devfn) == 0)
+ break;
+ }
+ /* Fix up interrupt lines */
+ if (pci_find_device(VENDOR_BROADCOM, SB_PCI, NULL))
+ d->irq = (pci_find_device(VENDOR_BROADCOM, SB_PCI, NULL))->irq;
+ pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
+}
+
+static void bcm47xx_fixup_bridge(struct pci_dev *dev)
+{
+ if (dev->bus->number != 1 || PCI_SLOT(dev->devfn) != 0)
+ return;
+
+ printk("PCI: fixing up bridge\n");
+
+ /* Enable PCI bridge bus mastering and memory space */
+ pci_set_master(dev);
+ pcibios_enable_device(dev, ~0);
+
+ /* Enable PCI bridge BAR1 prefetch and burst */
+ pci_write_config_dword(dev, PCI_BAR1_CONTROL, 3);
+}
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+ bcm47xx_fixup_device(dev);
+ return 0;
+}
+
+DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, bcm47xx_fixup_bridge);
diff -urN linux.old/include/asm-mips/bootinfo.h linux.dev/include/asm-mips/bootinfo.h diff -urN linux.old/include/asm-mips/bootinfo.h linux.dev/include/asm-mips/bootinfo.h
--- linux.old/include/asm-mips/bootinfo.h 2005-12-15 13:26:49.818001250 +0100 --- linux.old/include/asm-mips/bootinfo.h 2005-12-15 13:26:49.818001250 +0100
+++ linux.dev/include/asm-mips/bootinfo.h 2005-12-15 12:57:27.969147500 +0100 +++ linux.dev/include/asm-mips/bootinfo.h 2005-12-15 12:57:27.969147500 +0100