Skip to contentSkip to conversation

sh: sh7751 pci controller io port fix

DISCUSSION Aurelien Jarno 1 participant 1 message Jan 18, 2011 SuperH

lore
Share & tools
lore
#0 lore raw

Hi,

Quoted 5 lines · Magnus Damm

From: Magnus Damm <[email protected]>

This patch updates the sh7751 pci code to handle io ports correctly. The code is based on the sh7788x implementation.

Quoted 7 lines

Tested on a R2D-1 board with CONFIG_8139TOO_PIO=y.

---
arch/sh/drivers/pci/pci-sh7751.c | 5 +++--

 1 file changed, 3 insertions(+), 2 deletions(-)

Sorry to contact you so long after this patch has been submitted, but it appears to break PCI I/O support in QEMU emulating an R2D board. My guess is that one address translation layer is not fully emulated (some PCI registers are ignored), so I would like to ask a question.

Quoted 11 lines
arch/sh/drivers/pci/pci-sh7751.c +1 -0
@@ -17,6 +17,7 @@
 #include <linux/io.h>
 #include "pci-sh4.h"
 #include <asm/addrspace.h>
+#include <asm/sizes.h>
 
 static int __init __area_sdram_check(struct pci_channel *chan,
 				     unsigned int area)

arch/sh/drivers/pci/pci-sh7751.c static int __init __area_sdram_check(str · line 55

Quoted 10 lines
arch/sh/drivers/pci/pci-sh7751.c +2 -2
@@ -47,8 +48,8 @@ static int __init __area_sdram_check(str
 static struct resource sh7751_pci_resources[] = {
 	{
 		.name	= "SH7751_IO",
-		.start	= SH7751_PCI_IO_BASE,
-		.end	= SH7751_PCI_IO_BASE + SH7751_PCI_IO_SIZE - 1,
+		.start	= 0x1000,
+		.end	= SZ_4M - 1,
 		.flags	= IORESOURCE_IO
 	}, {
 		.name	= "SH7751_mem",

The address in start is used later in the code to write the PCI I/O base register:

|        /* Make sure the MSB's of IO window are set to access PCI space
|         * correctly */
|        word = chan->resources[0].start & SH4_PCIIOBR_MASK;
|        pr_debug("PCI: Setting upper bits of IO window to 0x%x\n", word);
|        pci_write_reg(chan, word, SH4_PCIIOBR);

With this change, 0 is written to this register (SH4_PCIIOBR_MASK is 0xFFFC0000), so QEMU maps the I/O port range starting at address 0x00000000. However the kernel still use the SH7751_PCI_IO_BASE value to define .io_map_base. As a results access to the PCI I/O space end up in the 0xFE240000 range.

It seems that the PCI IO space range is not only computed from the PCI I/O base register, but also from some other registers. However, I fail to find how in the datasheet. Would it be possible to tell me how it is computed?

Thanks,
Aurelien

Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net