Skip to contentSkip to conversation

arm/versatile PCI support, second try

PATCH New Arnd Bergmann 5 participants 16 messages Oct 14, 2010 – Oct 18, 2010 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover arm/versatile PCI support, second try

With lots of help and testing from Peter Maydell, I've completed a second version of the PCI support for the versatile platform, which works much better now on real hardware, although it does not improve existing qemu setups.

Please review and test.

Arnd Bergmann (7):
arm/versatile: move pci code to plat-versatile arm/versatile: boot-time configure xilinx-pci arm/versatile: enable PCI I/O space
arm/versatile: use correct PCI IRQ swizzling arm/realview: fix building PB-A8 and PBX with CONFIG_PCI arm/realview: enable PCI for realview-eb and realview-pb1176
arm: Enable support for virtio

 arch/arm/Kconfig                                   |    9 +-
 arch/arm/mach-realview/include/mach/board-eb.h     |   19 +
 arch/arm/mach-realview/include/mach/board-pb1176.h |    1 +
 arch/arm/mach-realview/include/mach/hardware.h     |   14 +-
 arch/arm/mach-realview/include/mach/io.h           |    6 +-
 arch/arm/mach-realview/include/mach/irqs-eb.h      |    5 +
 arch/arm/mach-realview/include/mach/irqs-pb1176.h  |    5 +-
 arch/arm/mach-realview/realview_eb.c               |   84 +++++-
 arch/arm/mach-realview/realview_pb1176.c           |  102 ++++++
 arch/arm/mach-realview/realview_pba8.c             |    2 +-
 arch/arm/mach-realview/realview_pbx.c              |    2 +-
 arch/arm/mach-versatile/Makefile                   |    1 -
 arch/arm/mach-versatile/core.c                     |   19 +-
 arch/arm/mach-versatile/include/mach/hardware.h    |   15 +-
 arch/arm/mach-versatile/include/mach/io.h          |    6 +-
 arch/arm/mach-versatile/include/mach/platform.h    |    4 +-
 arch/arm/mach-versatile/pci.c                      |  361 --------------------
 arch/arm/mach-versatile/versatile_pb.c             |   62 ++++
 arch/arm/plat-versatile/Makefile                   |    1 +
 arch/arm/plat-versatile/include/plat/xilinx-pci.h  |   28 ++
 arch/arm/plat-versatile/xilinx-pci.c               |  356 +++++++++++++++++++
 21 files changed, 705 insertions(+), 397 deletions(-)
 delete mode 100644 arch/arm/mach-versatile/pci.c
 create mode 100644 arch/arm/plat-versatile/include/plat/xilinx-pci.h
 create mode 100644 arch/arm/plat-versatile/xilinx-pci.c
#1 lore raw

PATCH 1/7 arm/versatile: move pci code to plat-versatile

The Xilinx PCI macro is used on both versatile-pb and realview-eb, so we should move the implementation to place where it can be shared.

---
 arch/arm/Kconfig                     |    5 +
 arch/arm/mach-versatile/Makefile     |    1 -
 arch/arm/mach-versatile/pci.c        |  361 ----------------------------------
 arch/arm/plat-versatile/Makefile     |    1 +
 arch/arm/plat-versatile/xilinx-pci.c |  361 ++++++++++++++++++++++++++++++++++
 5 files changed, 367 insertions(+), 362 deletions(-)
 delete mode 100644 arch/arm/mach-versatile/pci.c
 create mode 100644 arch/arm/plat-versatile/xilinx-pci.c
arch/arm/Kconfig +5 -0
index b8f976a..5bf08c7 100644
@@ -1172,6 +1172,11 @@ config PCI_HOST_ITE8152
 	default y
 	select DMABOUNCE
 
+config PCI_HOST_XILINX
+	bool
+	depends on PCI && (ARCH_VERSATILE_PB || MACH_REALVIEW_EB || MACH_REALVIEW_PB1176)
+	default y
+
 source "drivers/pci/Kconfig"
 
 source "drivers/pcmcia/Kconfig"
arch/arm/mach-versatile/Makefile +0 -1
index 97cf4d8..191b65b 100644
@@ -5,4 +5,3 @@
 obj-y					:= core.o
 obj-$(CONFIG_ARCH_VERSATILE_PB)		+= versatile_pb.o
 obj-$(CONFIG_MACH_VERSATILE_AB)		+= versatile_ab.o
-obj-$(CONFIG_PCI)			+= pci.o
arch/arm/mach-versatile/pci.c deleted +0 -361

361 lines not on this page · raw message

arch/arm/plat-versatile/Makefile +1 -0
index 5cf88e8..de870b7 100644
@@ -6,3 +6,4 @@ ifeq ($(CONFIG_LEDS_CLASS),y)
 obj-$(CONFIG_ARCH_REALVIEW) += leds.o
 obj-$(CONFIG_ARCH_VERSATILE) += leds.o
 endif
+obj-$(CONFIG_PCI_HOST_XILINX) += xilinx-pci.o
arch/arm/plat-versatile/xilinx-pci.c new file +361 -0

361 lines not on this page · raw message

Signature · 1 line
1.7.1
#2 lore raw

PATCH 1/7 arm/versatile: move pci code to plat-versatile

2010/10/14 Arnd Bergmann <[email protected]>:

Quoted 9 lines

The Xilinx PCI macro is used on both versatile-pb and realview-eb, so we should move the implementation to place where it can be shared.

?arch/arm/Kconfig ? ? ? ? ? ? ? ? ? ? | ? ?5 +
?arch/arm/mach-versatile/Makefile ? ? | ? ?1 -
?arch/arm/mach-versatile/pci.c ? ? ? ?| ?361 ----------------------------------
?arch/arm/plat-versatile/Makefile ? ? | ? ?1 +
?arch/arm/plat-versatile/xilinx-pci.c | ?361 ++++++++++++++++++++++++++++++++++

What about arch/arm/common?

PCI drivers seem like they could be useful for others than ARM reference designs too. Xilinx FPGAs are probably quite common anyway.

arch/arm/plat-versatile/xilinx-pci.c line 2

Quoted 10 lines

(...)

arch/arm/plat-versatile/Makefile +1 -0
+obj-$(CONFIG_PCI_HOST_XILINX) += xilinx-pci.o
arch/arm/plat-versatile/xilinx-pci.c new file +2 -0
new file mode 100644
index 0000000..13c7e5f
@@ -0,0 +1,361 @@
+/*
+ * ?linux/arch/arm/mach-versatile/pci.c

Hm this file path seems inappropriate why not just delete it.

Yours,
Linus Walleij

#3 lore raw

PATCH 1/7 arm/versatile: move pci code to plat-versatile

Quoted 12 lines · Linus Walleij

2010/10/14 Arnd Bergmann <[email protected]>:

Quoted 9 lines

The Xilinx PCI macro is used on both versatile-pb and realview-eb, so we should move the implementation to place where it can be shared.

 arch/arm/Kconfig                     |    5 +
 arch/arm/mach-versatile/Makefile     |    1 -
 arch/arm/mach-versatile/pci.c        |  361 ----------------------------------
 arch/arm/plat-versatile/Makefile     |    1 +
 arch/arm/plat-versatile/xilinx-pci.c |  361 ++++++++++++++++++++++++++++++++++
Quoted 4 lines

What about arch/arm/common?

PCI drivers seem like they could be useful for others than ARM reference designs too. Xilinx FPGAs are probably quite common anyway.

I don't care either way while we don't have any other users. Most likely a new platform using the same code would need some extra tweaks so we could just as well move it again then.

OTOH it may also be nice as a generic PCI implementation for qemu on other platforms which don't have their own PCI. If we ever get device tree support running, qemu could just define the PCI host on any platform and Linux can instantiate it from the dt.

Quoted 4 lines
Quoted 4 lines

(...)

arch/arm/plat-versatile/Makefile +1 -0
+obj-$(CONFIG_PCI_HOST_XILINX) += xilinx-pci.o
arch/arm/plat-versatile/xilinx-pci.c new file +0 -0
new file mode 100644
Quoted 8 lines

arch/arm/plat-versatile/xilinx-pci.c line 2

Quoted 6 lines

index 0000000..13c7e5f

arch/arm/plat-versatile/xilinx-pci.c new file +2 -0
@@ -0,0 +1,361 @@
+/*
+ *  linux/arch/arm/mach-versatile/pci.c

Hm this file path seems inappropriate why not just delete it.

Right, will do.

Thanks,

Arnd

#4 lore raw

PATCH 2/7 arm/versatile: boot-time configure xilinx-pci

In reply to Arnd Bergmann

The Xilinx-pci code is currently hardcoded to the registers used on the versatile-pb platform. Make all dependencies on specific register locations set at boot time so we can use the same code on realview.

---
 arch/arm/mach-versatile/versatile_pb.c            |   61 +++++++
 arch/arm/plat-versatile/include/plat/xilinx-pci.h |   27 +++
 arch/arm/plat-versatile/xilinx-pci.c              |  201 +++++++++------------
 3 files changed, 177 insertions(+), 112 deletions(-)
 create mode 100644 arch/arm/plat-versatile/include/plat/xilinx-pci.h
arch/arm/mach-versatile/versatile_pb.c +61 -0
index 239cd30..4e5e1c7 100644
@@ -28,6 +28,8 @@
 #include <linux/io.h>
 
 #include <mach/hardware.h>
+#include <plat/xilinx-pci.h>
+
 #include <asm/irq.h>
 #include <asm/mach-types.h>
 
@@ -94,6 +96,63 @@ static struct amba_device *amba_devs[] __initdata = {
 	&mmc1_device,
 };
 
+#ifdef CONFIG_PCI_HOST_XILINX
+/*
+ * these spaces are mapped using the following base registers:
+ *
+ * Usage Local Bus Memory         Base/Map registers used
+ *
+ * Mem   44000000 - 4FFFFFFF      LB_BASE0/LB_MAP0,  unused
+ * Mem   50000000 - 5FFFFFFF      LB_BASE1/LB_MAP1,  non prefetch
+ * Mem   60000000 - 6FFFFFFF      LB_BASE2/LB_MAP2,  prefetch
+ * IO    43000000 - 43FFFFFF      IO space
+ * Cfg   42000000 - 42FFFFFF	  PCI config
+ *
+ */
+#define __IO_ADDRESS(n) ((void __iomem *)(unsigned long)IO_ADDRESS(n))
+static struct xilinx_pci_data versatile_pci_io = {
+	.base		= VERSATILE_PCI_VIRT_BASE,
+	.cfg_base	= VERSATILE_PCI_CFG_VIRT_BASE,
+	.io_base	= NULL,
+	.sys_pcictl	= __IO_ADDRESS(VERSATILE_SYS_PCICTL),
+	.core_base	= __IO_ADDRESS(VERSATILE_PCI_CORE_BASE),
+	.base_irq	= 27,
+
+	/* identity map outbound AHB addresses to PCI addresses */
+	.imap		= {
+		VERSATILE_PCI_MEM_BASE0 >> 28, /* 0x44000000 */
+		VERSATILE_PCI_MEM_BASE1 >> 28, /* 0x50000000 */
+		VERSATILE_PCI_MEM_BASE2 >> 28, /* 0x60000000 */
+	 },
+
+	/* map all three BARs of the inbound space to RAM */
+	.smap		= {
+		PHYS_OFFSET >> 28, /* inbound memory space mapping 0 */
+		PHYS_OFFSET >> 28, /* inbound memory space mapping 1 */
+		PHYS_OFFSET >> 28, /* inbound I/O space mapping */
+	 },
+
+	.mem_spaces	= {
+		{
+			.name	= "PCI unused",
+			.start	= VERSATILE_PCI_MEM_BASE0,
+			.end	= VERSATILE_PCI_MEM_BASE0+VERSATILE_PCI_MEM_BASE0_SIZE-1,
+			.flags	= IORESOURCE_IO,
+		}, {
+			.name	= "PCI non-prefetchable",
+			.start	= VERSATILE_PCI_MEM_BASE1,
+			.end	= VERSATILE_PCI_MEM_BASE1+VERSATILE_PCI_MEM_BASE1_SIZE-1,
+			.flags	= IORESOURCE_MEM,
+		}, {
+			.name	= "PCI prefetchable",
+			.start	= VERSATILE_PCI_MEM_BASE2,
+			.end	= VERSATILE_PCI_MEM_BASE2+VERSATILE_PCI_MEM_BASE2_SIZE-1,
+			.flags	= IORESOURCE_MEM | IORESOURCE_PREFETCH,
+		},
+	},
+};
+#endif
+
 static void __init versatile_pb_init(void)
 {
 	int i;
@@ -104,6 +163,8 @@ static void __init versatile_pb_init(void)
 		struct amba_device *d = amba_devs[i];
 		amba_device_register(d, &iomem_resource);
 	}
+
+	xilinx_pci_init(&versatile_pci_io);
 }
 
 MACHINE_START(VERSATILE_PB, "ARM-Versatile PB")
arch/arm/plat-versatile/include/plat/xilinx-pci.h new file +27 -0
new file mode 100644
index 0000000..b0394c5
@@ -0,0 +1,27 @@
+#ifndef _PLAT_VERSATILE_XILINX_PCI_H
+#define _PLAT_VERSATILE_XILINX_PCI_H
+
+#include <linux/ioport.h>
+#include <linux/compiler.h>
+
+struct xilinx_pci_data {
+	void __iomem *sys_pcictl;
+	void __iomem *base;
+	void __iomem *core_base;
+	void __iomem *cfg_base;
+	void __iomem *io_base;
+	int base_irq;
+
+	u32 imap[3];
+	u32 smap[3];
+
+	struct resource mem_spaces[3];
+};
+
+#ifdef CONFIG_PCI_HOST_XILINX
+extern int __init xilinx_pci_init(struct xilinx_pci_data *x);
+#else
+#define xilinx_pci_init(x) do { } while (0)
+#endif
+
+#endif
arch/arm/plat-versatile/xilinx-pci.c +89 -112

313 lines not on this page · raw message

Signature · 1 line
1.7.1
#5 lore raw

PATCH 3/7 arm/versatile: enable PCI I/O space

In reply to Arnd Bergmann

I/O space handling on the versatile platform is currently broken in multiple ways. Most importantly, the ports do not get mapped into the virtual address space at all.

Also, there is some amount of confusion between PCI I/O space and other statically mapped MMIO registers in the platform code:

* The __io_address() macro that is used to access the platform register maps to the same __io macro that gets used for I/O space.

* The IO_SPACE_LIMIT is set to a value that is much larger than the total available space.

* The I/O resource of the PCI bus is set to the physical address of the mapping, which is way outside of the actual I/O space limit as well as the address range that gets decoded by traditional PCI cards.

* No attempt is made to stay outside of the ISA port range that some device drivers try access.

* No resource gets requested as a child of ioport_resource, but an IORESOURCE_IO type mapping gets requested as a child of iomem_resource.

This patch attempts to correct all of the above. This makes it possible to use virtio-pci based virtual devices as well as actual PCI cards including those with legacy ISA port ranges like VGA.

Some of the issues seem to be duplicated on other platforms.

---
 arch/arm/mach-versatile/core.c                  |   19 +++----------------
 arch/arm/mach-versatile/include/mach/hardware.h |   15 +++++++--------
 arch/arm/mach-versatile/include/mach/io.h       |    6 ++++--
 arch/arm/mach-versatile/include/mach/platform.h |    4 +++-
 arch/arm/mach-versatile/versatile_pb.c          |    4 ++--
 arch/arm/plat-versatile/xilinx-pci.c            |   19 +++++++++++++++++--
 6 files changed, 36 insertions(+), 31 deletions(-)
arch/arm/mach-versatile/core.c +3 -16
index e38acb0..b03a6d5 100644
@@ -201,26 +201,13 @@ static struct map_desc versatile_io_desc[] __initdata = {
 		.pfn		= __phys_to_pfn(VERSATILE_PCI_CFG_BASE),
 		.length		= VERSATILE_PCI_CFG_BASE_SIZE,
 		.type		= MT_DEVICE
-	},
-#if 0
- 	{
-		.virtual	=  VERSATILE_PCI_VIRT_MEM_BASE0,
-		.pfn		= __phys_to_pfn(VERSATILE_PCI_MEM_BASE0),
-		.length		= SZ_16M,
-		.type		= MT_DEVICE
 	}, {
-		.virtual	=  VERSATILE_PCI_VIRT_MEM_BASE1,
-		.pfn		= __phys_to_pfn(VERSATILE_PCI_MEM_BASE1),
-		.length		= SZ_16M,
-		.type		= MT_DEVICE
-	}, {
-		.virtual	=  VERSATILE_PCI_VIRT_MEM_BASE2,
-		.pfn		= __phys_to_pfn(VERSATILE_PCI_MEM_BASE2),
-		.length		= SZ_16M,
+		.virtual	=  (unsigned long)PCIO_BASE,
+		.pfn		= __phys_to_pfn(VERSATILE_PCI_IO_BASE),
+		.length		= IO_SPACE_LIMIT,
 		.type		= MT_DEVICE
 	},
 #endif
-#endif
 };
 
 void __init versatile_map_io(void)
arch/arm/mach-versatile/include/mach/hardware.h +7 -8
index b5e75bb..59b7716 100644
@@ -24,21 +24,20 @@
 
 #include <asm/sizes.h>
 
+/* macro to get at MMIO space when running virtually */
+#define IO_ADDRESS(x)		(((x) & 0x0fffffff) + (((x) >> 4) & 0x0f000000) + 0xf0000000)
+#define __io_address(n)		((void __iomem *)(IO_ADDRESS(n)))
+
 /*
  * PCI space virtual addresses
  */
 #define VERSATILE_PCI_VIRT_BASE		(void __iomem *)0xe8000000ul
 #define VERSATILE_PCI_CFG_VIRT_BASE	(void __iomem *)0xe9000000ul
+#define VERSATILE_PCI_IO_VIRT_BASE	(void __iomem *)PCIO_BASE
 
-/* CIK guesswork */
-#define PCIBIOS_MIN_IO			0x44000000
-#define PCIBIOS_MIN_MEM			0x50000000
+#define PCIBIOS_MIN_IO			0x00001000
+#define PCIBIOS_MIN_MEM			0x00000000
 
 #define pcibios_assign_all_busses()     1
 
-/* macro to get at IO space when running virtually */
-#define IO_ADDRESS(x)		(((x) & 0x0fffffff) + (((x) >> 4) & 0x0f000000) + 0xf0000000)
-
-#define __io_address(n)		__io(IO_ADDRESS(n))
-
 #endif
arch/arm/mach-versatile/include/mach/io.h +4 -2
index f067c14..07f3aaf 100644
@@ -20,9 +20,11 @@
 #ifndef __ASM_ARM_ARCH_IO_H
 #define __ASM_ARM_ARCH_IO_H
 
-#define IO_SPACE_LIMIT 0xffffffff
+#define PCIO_BASE	(void __iomem *)0xeb000000ul
+#define PCIO_SIZE	0x00100000ul
+#define IO_SPACE_LIMIT  (PCIO_SIZE - 1)
 
-#define __io(a)		__typesafe_io(a)
+#define __io(a)		((a) + PCIO_BASE)
 #define __mem_pci(a)	(a)
 
 #endif
arch/arm/mach-versatile/include/mach/platform.h +3 -1
index ec08740..efb5328 100644
@@ -231,12 +231,14 @@
 /* PCI space */
 #define VERSATILE_PCI_BASE             0x41000000	/* PCI Interface */
 #define VERSATILE_PCI_CFG_BASE	       0x42000000
+#define VERSATILE_PCI_IO_BASE	       0x43000000
 #define VERSATILE_PCI_MEM_BASE0        0x44000000
 #define VERSATILE_PCI_MEM_BASE1        0x50000000
 #define VERSATILE_PCI_MEM_BASE2        0x60000000
 /* Sizes of above maps */
 #define VERSATILE_PCI_BASE_SIZE	       0x01000000
-#define VERSATILE_PCI_CFG_BASE_SIZE    0x02000000
+#define VERSATILE_PCI_CFG_BASE_SIZE    0x01000000
+#define VERSATILE_PCI_IO_BASE_SIZE     0x01000000
 #define VERSATILE_PCI_MEM_BASE0_SIZE   0x0c000000	/* 32Mb */
 #define VERSATILE_PCI_MEM_BASE1_SIZE   0x10000000	/* 256Mb */
 #define VERSATILE_PCI_MEM_BASE2_SIZE   0x10000000	/* 256Mb */
arch/arm/mach-versatile/versatile_pb.c +2 -2
index 4e5e1c7..0f39fde 100644
@@ -113,7 +113,7 @@ static struct amba_device *amba_devs[] __initdata = {
 static struct xilinx_pci_data versatile_pci_io = {
 	.base		= VERSATILE_PCI_VIRT_BASE,
 	.cfg_base	= VERSATILE_PCI_CFG_VIRT_BASE,
-	.io_base	= NULL,
+	.io_base	= PCIO_BASE,
 	.sys_pcictl	= __IO_ADDRESS(VERSATILE_SYS_PCICTL),
 	.core_base	= __IO_ADDRESS(VERSATILE_PCI_CORE_BASE),
 	.base_irq	= 27,
@@ -137,7 +137,7 @@ static struct xilinx_pci_data versatile_pci_io = {
 			.name	= "PCI unused",
 			.start	= VERSATILE_PCI_MEM_BASE0,
 			.end	= VERSATILE_PCI_MEM_BASE0+VERSATILE_PCI_MEM_BASE0_SIZE-1,
-			.flags	= IORESOURCE_IO,
+			.flags	= IORESOURCE_MEM,
 		}, {
 			.name	= "PCI non-prefetchable",
 			.start	= VERSATILE_PCI_MEM_BASE1,
arch/arm/plat-versatile/xilinx-pci.c +17 -2
index 28d1d7d..425604a 100644
@@ -164,11 +164,25 @@ static struct pci_ops pci_xilinx_ops = {
 	.write	= xilinx_write_config,
 };
 
+static struct resource io_port = {
+	.name	= "PCI",
+	.start	= 0,
+	.end	= IO_SPACE_LIMIT,
+	.flags	= IORESOURCE_IO,
+};
+
 static int __init pci_xilinx_setup_resources(struct resource **resource)
 {
 	int ret = 0;
 	int i;
 
+	ret = request_resource(&ioport_resource, &io_port);
+	if (ret) {
+		printk(KERN_ERR "PCI: unable to allocate I/O "
+		       "port region (%d)\n", ret);
+		goto out;
+	}
+
 	for (i = 0; i < 3; i++) {
 		ret = request_resource(&iomem_resource,
 					&xilinx_pci->mem_spaces[i]);
@@ -183,7 +197,7 @@ static int __init pci_xilinx_setup_resources(struct resource **resource)
 	 * bus->resource[1] is the mem resource for this bus
 	 * bus->resource[2] is the prefetch mem resource for this bus
 	 */
-	resource[0] = &xilinx_pci->mem_spaces[0];
+	resource[0] = &io_port;
 	resource[1] = &xilinx_pci->mem_spaces[1];
 	resource[2] = &xilinx_pci->mem_spaces[2];
 	goto out;
@@ -194,6 +208,8 @@ static int __init pci_xilinx_setup_resources(struct resource **resource)
 		release_resource(&xilinx_pci->mem_spaces[1]);
 	case 1:
 		release_resource(&xilinx_pci->mem_spaces[0]);
+	case 0:
+		release_resource(&io_port);
 		break;
 	}
  out:
@@ -335,4 +351,3 @@ int __init xilinx_pci_init(struct xilinx_pci_data *x)
 	pci_common_init(&xilinx_hw_pci);
 	return 0;
 }
-
Signature · 1 line
1.7.1
#6 lore raw

PATCH 4/7 arm/versatile: use correct PCI IRQ swizzling

In reply to Arnd Bergmann

The interrupts on the versatile platform only worked for one slot with a single-function device.

This fixes the swizzling and the IRQ assignment to work for both slots on the base plane including multi-function devices and bridges.

---
 arch/arm/mach-versatile/versatile_pb.c            |    1 +
 arch/arm/plat-versatile/include/plat/xilinx-pci.h |    1 +
 arch/arm/plat-versatile/xilinx-pci.c              |   19 +++++++++++--------
 3 files changed, 13 insertions(+), 8 deletions(-)
arch/arm/mach-versatile/versatile_pb.c +1 -0
index 0f39fde..e355057 100644
@@ -117,6 +117,7 @@ static struct xilinx_pci_data versatile_pci_io = {
 	.sys_pcictl	= __IO_ADDRESS(VERSATILE_SYS_PCICTL),
 	.core_base	= __IO_ADDRESS(VERSATILE_PCI_CORE_BASE),
 	.base_irq	= 27,
+	.irq_rotate	= 2,
 
 	/* identity map outbound AHB addresses to PCI addresses */
 	.imap		= {
arch/arm/plat-versatile/include/plat/xilinx-pci.h +1 -0
index b0394c5..9156fcb 100644
@@ -11,6 +11,7 @@ struct xilinx_pci_data {
 	void __iomem *cfg_base;
 	void __iomem *io_base;
 	int base_irq;
+	int irq_rotate;
 
 	u32 imap[3];
 	u32 smap[3];
arch/arm/plat-versatile/xilinx-pci.c +11 -8
index 425604a..8da45e7 100644
@@ -23,6 +23,7 @@
 #include <linux/io.h>
 
 #include <mach/hardware.h>
+#include <mach/platform.h>
 #include <asm/irq.h>
 #include <asm/system.h>
 #include <asm/mach/pci.h>
@@ -323,21 +324,23 @@ static int __init xilinx_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 	int irq;
 	int devslot = PCI_SLOT(dev->devfn);
 
-	/* slot,  pin,	irq
-	 *  24     1     27
-	 *  25     1     28
-	 *  26     1     29
-	 *  27     1     30
+	/*
+	 * Slot to IRQ mapping for RealView Platform Baseboard 926 Backplane
+	 *	name	slot	IntA	IntB	IntC	IntD
+	 *	A	31	IRQ28	IRQ29	IRQ30	IRQ27
+	 *	B	30	IRQ27	IRQ28	IRQ29	IRQ30
+	 *	C	29	IRQ30	IRQ27	IRQ28	IRQ29
 	 */
-	irq = xilinx_pci->base_irq + ((slot + pin - 1) & 3);
+	irq = xilinx_pci->base_irq +
+		((slot + xilinx_pci->irq_rotate + pin - 1) & 3);
 
-	printk("PCI map irq: slot %d, pin %d, devslot %d, irq: %d\n",slot,pin,devslot,irq);
+	pr_debug("PCI map (slot+3) irq: slot %d, pin %d, devslot %d, irq: %d\n",slot,pin,devslot,irq);
 
 	return irq;
 }
 
 static struct hw_pci xilinx_hw_pci __initdata = {
-	.swizzle		= NULL,
+	.swizzle		= pci_std_swizzle,
 	.map_irq		= xilinx_map_irq,
 	.nr_controllers		= 1,
 	.setup			= pci_xilinx_setup,
Signature · 1 line
1.7.1
#7 lore raw

PATCH 5/7 arm/realview: fix building PB-A8 and PBX with CONFIG_PCI

In reply to Arnd Bergmann

In a multi-board kernel configuration with multiple realview boards enabled, you can have CONFIG_PCI enabled on these, which results in a build failure because of unresolved symbols.

Use the same symbol as on the other boards instead to work around this.

---
 arch/arm/mach-realview/realview_pba8.c |    2 +-
 arch/arm/mach-realview/realview_pbx.c  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-realview/realview_pba8.c +1 -1
index 6c37621..6c8c89e 100644
@@ -79,7 +79,7 @@ static struct map_desc realview_pba8_io_desc[] __initdata = {
 	},
 #ifdef CONFIG_PCI
 	{
-		.virtual	= PCIX_UNIT_BASE,
+		.virtual	= (unsigned long)REALVIEW_PCI_VIRT_BASE,
 		.pfn		= __phys_to_pfn(REALVIEW_PBA8_PCI_BASE),
 		.length		= REALVIEW_PBA8_PCI_BASE_SIZE,
 		.type		= MT_DEVICE
arch/arm/mach-realview/realview_pbx.c +1 -1
index 9428eff..07f3647 100644
@@ -80,7 +80,7 @@ static struct map_desc realview_pbx_io_desc[] __initdata = {
 	},
 #ifdef CONFIG_PCI
 	{
-		.virtual	= PCIX_UNIT_BASE,
+		.virtual	= (unsigned long)REALVIEW_PCI_VIRT_BASE,
 		.pfn		= __phys_to_pfn(REALVIEW_PBX_PCI_BASE),
 		.length		= REALVIEW_PBX_PCI_BASE_SIZE,
 		.type		= MT_DEVICE,
Signature · 1 line
1.7.1
#8 lore raw

PATCH 6/7 arm/realview: enable PCI for realview-eb and realview-pb1176

In reply to Arnd Bergmann

These two boards use the Xilinx PCI macro, so enable the code and set up all the I/O windows for it.

---
 arch/arm/Kconfig                                   |    2 +-
 arch/arm/mach-realview/include/mach/board-eb.h     |   19 ++++
 arch/arm/mach-realview/include/mach/board-pb1176.h |    1 +
 arch/arm/mach-realview/include/mach/hardware.h     |   14 +++-
 arch/arm/mach-realview/include/mach/io.h           |    6 +-
 arch/arm/mach-realview/include/mach/irqs-eb.h      |    5 +
 arch/arm/mach-realview/include/mach/irqs-pb1176.h  |    5 +-
 arch/arm/mach-realview/realview_eb.c               |   84 ++++++++++++++++-
 arch/arm/mach-realview/realview_pb1176.c           |  102 ++++++++++++++++++++
 9 files changed, 232 insertions(+), 6 deletions(-)
arch/arm/Kconfig +1 -1
index 5bf08c7..8533bbe 100644
@@ -1146,7 +1146,7 @@ config ISA_DMA_API
 	bool
 
 config PCI
-	bool "PCI support" if ARCH_INTEGRATOR_AP || ARCH_VERSATILE_PB || ARCH_IXP4XX || ARCH_KS8695 || MACH_ARMCORE || ARCH_CNS3XXX
+	bool "PCI support" if ARCH_INTEGRATOR_AP || ARCH_VERSATILE_PB || ARCH_IXP4XX || ARCH_KS8695 || MACH_ARMCORE || ARCH_CNS3XXX || ARCH_REALVIEW
 	help
 	  Find out whether you have a PCI motherboard. PCI is the name of a
 	  bus system, i.e. the way the CPU talks to the other stuff inside
arch/arm/mach-realview/include/mach/board-eb.h +19 -0
index 794a8d9..7510516 100644
@@ -36,6 +36,7 @@
 #define REALVIEW_EB_TIMER2_3_BASE	0x10012000	/* Timer 2 and 3 */
 #define REALVIEW_EB_GPIO0_BASE		0x10013000	/* GPIO port 0 */
 #define REALVIEW_EB_RTC_BASE		0x10017000	/* Real Time Clock */
+#define REALVIEW_EB_PCI_CORE_BASE	0x10019000	/* PCI map and control */
 #define REALVIEW_EB_CLCD_BASE		0x10020000	/* CLCD */
 #define REALVIEW_EB_GIC_CPU_BASE	0x10040000	/* Generic interrupt controller CPU interface */
 #define REALVIEW_EB_GIC_DIST_BASE	0x10041000	/* Generic interrupt controller distributor */
@@ -63,6 +64,24 @@
 #endif
 
 /*
+ * PCI regions
+ */
+#define REALVIEW_EB_PCI_BASE		0x60000000 /* PCI self config */
+#define REALVIEW_EB_PCI_CFG_BASE	0x61000000 /* PCI config */
+#define REALVIEW_EB_PCI_IO_BASE0	0x62000000 /* PCI IO region */
+#define REALVIEW_EB_PCI_MEM_BASE0	0x63000000 /* Memory region 1 */
+#define REALVIEW_EB_PCI_MEM_BASE1	0x64000000 /* Memory region 2 */
+#define REALVIEW_EB_PCI_MEM_BASE2	0x68000000 /* Memory region 3 */
+
+#define REALVIEW_EB_PCI_BASE_SIZE	0x01000000 /* 16MB */
+#define REALVIEW_EB_PCI_CFG_BASE_SIZE	0x01000000 /* 16MB */
+#define REALVIEW_EB_PCI_IO_BASE0_SIZE	0x01000000 /* 16MB */
+#define REALVIEW_EB_PCI_MEM_BASE0_SIZE	0x01000000 /* 16MB */
+#define REALVIEW_EB_PCI_MEM_BASE1_SIZE	0x04000000 /* 64MB */
+#define REALVIEW_EB_PCI_MEM_BASE2_SIZE	0x08000000 /* 128MB */
+
+
+/*
  * Core tile identification (REALVIEW_SYS_PROCID)
  */
 #define REALVIEW_EB_PROC_MASK		0xFF000000
arch/arm/mach-realview/include/mach/board-pb1176.h +1 -0
index 002ab5d..b11a159 100644
@@ -27,6 +27,7 @@
  * Peripheral addresses
  */
 #define REALVIEW_PB1176_UART4_BASE		0x10009000 /* UART 4 */
+#define REALVIEW_PB1176_PCI_CORE_BASE		0x10019000 /* PCI map and control */
 #define REALVIEW_PB1176_SCTL_BASE		0x10100000 /* System controller */
 #define REALVIEW_PB1176_SMC_BASE		0x10111000 /* SMC */
 #define REALVIEW_PB1176_DMC_BASE		0x10109000 /* DMC configuration */
arch/arm/mach-realview/include/mach/hardware.h +13 -1
index 8a638d1..ff60011 100644
@@ -37,6 +37,18 @@
 #else
 #define IO_ADDRESS(x)		(x)
 #endif
-#define __io_address(n)		__io(IO_ADDRESS(n))
+#define __io_address(n)		((void __iomem *)(IO_ADDRESS(n)))
+
+/*
+ * PCI space virtual addresses
+ */
+#define REALVIEW_PCI_VIRT_BASE		(void __iomem *)0xf8000000ul
+#define REALVIEW_PCI_CFG_VIRT_BASE	(void __iomem *)0xf9000000ul
+#define REALVIEW_PCI_IO_VIRT_BASE	(void __iomem *)PCIO_BASE
+
+#define PCIBIOS_MIN_IO			0x00001000
+#define PCIBIOS_MIN_MEM			0x00000000
+
+#define pcibios_assign_all_busses()     1
 
 #endif
arch/arm/mach-realview/include/mach/io.h +4 -2
index f05bcdf..14304f9 100644
@@ -20,9 +20,11 @@
 #ifndef __ASM_ARM_ARCH_IO_H
 #define __ASM_ARM_ARCH_IO_H
 
-#define IO_SPACE_LIMIT 0xffffffff
+#define PCIO_BASE	(void __iomem *)0xfa000000ul
+#define PCIO_SIZE	0x00100000ul
+#define IO_SPACE_LIMIT  (PCIO_SIZE - 1)
 
-#define __io(a)		__typesafe_io(a)
+#define __io(a)		((a) + PCIO_BASE)
 #define __mem_pci(a)	(a)
 
 #endif
arch/arm/mach-realview/include/mach/irqs-eb.h +5 -0
index 204d537..1511518 100644
@@ -59,6 +59,11 @@
 #define IRQ_EB_TSPEN		(IRQ_EB_GIC_START + 30)		/* Touchscreen pen */
 #define IRQ_EB_TSKPAD		(IRQ_EB_GIC_START + 31)		/* Touchscreen keypad */
 
+#define IRQ_EB_PCI0		(IRQ_EB_GIC_START + 48)		/* PCI IntA */
+#define IRQ_EB_PCI1		(IRQ_EB_GIC_START + 49)		/* PCI IntB */
+#define IRQ_EB_PCI2		(IRQ_EB_GIC_START + 50)		/* PCI IntC */
+#define IRQ_EB_PCI3		(IRQ_EB_GIC_START + 51)		/* PCI IntD */
+
 /*
  * RealView EB + ARM11MPCore interrupt sources (primary GIC on the core tile)
  */
arch/arm/mach-realview/include/mach/irqs-pb1176.h +4 -1
index 5c3c625..cf92425 100644
@@ -63,7 +63,10 @@
 #define IRQ_PB1176_GPIO2	(IRQ_PB1176_GIC_START + 9)
 #define IRQ_PB1176_ETH		(IRQ_PB1176_GIC_START + 10)	/* Ethernet controller */
 #define IRQ_PB1176_USB		(IRQ_PB1176_GIC_START + 11)	/* USB controller */
-
+#define IRQ_PB1176_PCI_INTA	(IRQ_PB1176_GIC_START + 12)	/* PCI IntA */
+#define IRQ_PB1176_PCI_INTB	(IRQ_PB1176_GIC_START + 13)	/* PCI IntB */
+#define IRQ_PB1176_PCI_INTC	(IRQ_PB1176_GIC_START + 14)	/* PCI IntC */
+#define IRQ_PB1176_PCI_INTD	(IRQ_PB1176_GIC_START + 15)	/* PCI IntD */
 #define IRQ_PB1176_PISMO	(IRQ_PB1176_GIC_START + 16)
 
 #define IRQ_PB1176_AACI		(IRQ_PB1176_GIC_START + 19)	/* Audio Codec */
arch/arm/mach-realview/realview_eb.c +83 -1

108 lines not on this page · raw message

arch/arm/mach-realview/realview_pb1176.c +102 -0

126 lines not on this page · raw message

Signature · 1 line
1.7.1
#9 lore raw

PATCH 7/7 arm: Enable support for virtio

In reply to Arnd Bergmann

Qemu can use virtio-pci based devices when emulating a machine with PCI. This adds the necessary Kconfig entry that allows users to select those drivers.

---
 arch/arm/Kconfig |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/Kconfig +2 -0
index 8533bbe..319f1a0 100644
@@ -1179,6 +1179,8 @@ config PCI_HOST_XILINX
 
 source "drivers/pci/Kconfig"
 
+source "drivers/virtio/Kconfig"
+
 source "drivers/pcmcia/Kconfig"
 
 endmenu
Signature · 1 line
1.7.1
#10 lore raw

cover arm/versatile PCI support, second try

In reply to Arnd Bergmann

2010/10/14 Arnd Bergmann <[email protected]>:

Quoted 4 lines

With lots of help and testing from Peter Maydell, I've completed a second version of the PCI support for the versatile platform, which works much better now on real hardware, although it does not improve existing qemu setups.

I've got nothing better to do tonite than playing with the PB1176 board so tried this out...

Some fixup is needed in 6/7, the EB patch because I get this:
arch/arm/mach-realview/realview_eb.c:94: error:
'REALVIEW_PCI_CORE_BASE' undeclared here (not in a function) arch/arm/mach-realview/realview_eb.c:110: error:
'REALVIEW_PCI_IO_BASE' undeclared here (not in a function) arch/arm/mach-realview/realview_eb.c:111: error:
'REALVIEW_PCI_IO_BASE_SIZE' undeclared here (not in a function) make[3]: *** [arch/arm/mach-realview/realview_eb.o] Error 1 make[2]: *** [arch/arm/mach-realview] Error 2 make[2]: *** Waiting for unfinished jobs....

No these are indeed named
REALVIEW_EB_PCI_CORE_BASE
REALVIEW_EB_PCI_IO_BASE0
etc...

If I disable the EB support it compiles and boots. Nothing much else happens, not even if I enable PCI debugging. But I guess that's normal since I don't have any PCI enclosure expansion board for this card?

The only visible change is that /sys/bus/pci now exists with no slots nor devices in it.

But it's not causing any regressions for me so with a fix for the compile problem it's

Yours,
Linus Walleij

#11 lore raw

cover arm/versatile PCI support, second try

Quoted 21 lines · Linus Walleij

2010/10/14 Arnd Bergmann <[email protected]>:

Quoted 4 lines

With lots of help and testing from Peter Maydell, I've completed a second version of the PCI support for the versatile platform, which works much better now on real hardware, although it does not improve existing qemu setups.

I've got nothing better to do tonite than playing with the PB1176 board so tried this out...

Some fixup is needed in 6/7, the EB patch because I get this:
arch/arm/mach-realview/realview_eb.c:94: error:
'REALVIEW_PCI_CORE_BASE' undeclared here (not in a function) arch/arm/mach-realview/realview_eb.c:110: error:
'REALVIEW_PCI_IO_BASE' undeclared here (not in a function) arch/arm/mach-realview/realview_eb.c:111: error:
'REALVIEW_PCI_IO_BASE_SIZE' undeclared here (not in a function) make[3]: *** [arch/arm/mach-realview/realview_eb.o] Error 1 make[2]: *** [arch/arm/mach-realview] Error 2 make[2]: *** Waiting for unfinished jobs....

Quoted 4 lines

No these are indeed named
REALVIEW_EB_PCI_CORE_BASE
REALVIEW_EB_PCI_IO_BASE0
etc...

Ah right, I removed these when I prepared the patches for submission, initially I was using the common definitions for the realview boards but I figured it would be bad since newer realviews have a different controller. Apparently I forgot to move over the EB code to use the new definitions I added later.

I'll fix these up.

Quoted 4 lines

If I disable the EB support it compiles and boots. Nothing much else happens, not even if I enable PCI debugging. But I guess that's normal since I don't have any PCI enclosure expansion board for this card?

Yes, without a PCI card to plug into it it's pretty pointless.

Quoted 6 lines

The only visible change is that /sys/bus/pci now exists with no slots nor devices in it.

But it's not causing any regressions for me so with a fix for the compile problem it's

Thanks,

Arnd

#12 lore raw

cover arm/versatile PCI support, second try

In reply to Linus Walleij
Quoted 11 lines

-----Original Message-----
From: Linus Walleij
Sent: 16 October 2010 21:53

Quoted 4 lines

With lots of help and testing from Peter Maydell, I've completed a second version of the PCI support for the versatile platform, which works much better now on real hardware, although it does not improve existing qemu setups.

I've got nothing better to do tonite than playing with the PB1176 board so tried this out...

Note that the PB1176 and EB are in mach-realview rather than mach-versatile like the PB926. This complicates the PCI side of things since the other boards in mach-realview have a different PCI implementation (via a NEC custom Northbridge chip).

I am just about to push the PCI code patches for these boards (PBA8, PB11MPCore and PBX) to the list.

Regards,

Colin

#13 lore raw

cover arm/versatile PCI support, second try

Quoted 5 lines · Colin Tuckley
Quoted 5 lines
Quoted 4 lines

With lots of help and testing from Peter Maydell, I've completed a second version of the PCI support for the versatile platform, which works much better now on real hardware, although it does not improve existing qemu setups.

Quoted 7 lines
Quoted 2 lines

I've got nothing better to do tonite than playing with the PB1176 board so tried this out...

Note that the PB1176 and EB are in mach-realview rather than mach-versatile like the PB926. This complicates the PCI side of things since the other boards in mach-realview have a different PCI implementation (via a NEC custom Northbridge chip).

Yes, I know that. All of them use plat-versatile though, which is where the common code sits.

All the code I added is either specific to the xilinx PCI implementation or specific to one of the boards (pb926, pb1176, eb).

Quoted 2 lines

I am just about to push the PCI code patches for these boards (PBA8, PB11MPCore and PBX) to the list.

I don't expect any conflicts besides my patch 5/7, which will get obsoleted by your patch. If you apply both series, we should be able to enable both Xilinx and NEC PCI support on mach-realview and have it work on all the boards.

Arnd

A message that is not in the archive (sent off-list or not yet received): -1220762139438340023@unknownmsgid

#15 lore raw

cover arm/versatile PCI support, second try

2010/10/18 Colin Tuckley <[email protected]>:

Quoted 4 lines

Note that the PB1176 and EB are in mach-realview rather than mach-versatile like the PB926. This complicates the PCI side of things since the other boards in mach-realview have a different PCI implementation (via a NEC custom Northbridge chip).

Aha, then the platform data for these are all wrong... Arnd you'd better skip the EB and PB1176 platform data patches for now.

Yours,
Linus Walleij

#16 lore raw

cover arm/versatile PCI support, second try

In reply to Arnd Bergmann
Quoted 6 lines · Arnd Bergmann

With lots of help and testing from Peter Maydell, I've completed a second version of the PCI support for the versatile platform, which works much better now on real hardware, although it does not improve existing qemu setups.

Please review and test.

Confirmed that this patchset gives working PCI (tested with a sata_via PCI card and disk) on PB926, and working PCI except for busmaster DMA on PB1176 (same test setup, booting with libata.dma=0). (Without the patchset PCI doesn't work at all because the sata_via driver crashes the first time it tries an I/O access, so even without the 1176 busmastering it's a huge improvement over the existing situation.)

-- PMM