aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-versatile
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2013-09-09 20:31:04 -0400
committerOlof Johansson <olof@lixom.net>2013-09-09 20:31:04 -0400
commit23c43df854b14cf49231e84c0161a4485b5613a2 (patch)
tree30cf92eed60ef64cf6696b07828f8ce2e0ea2f24 /arch/arm/mach-versatile
parent3a116a5eaa68046646e557b4988a49e18f129ce8 (diff)
parent99f2b130370b904ca5300079243fdbcafa2c708b (diff)
Merge branch 'versatile/fixes' into fixes
From Peter Maydell: These patches fix a number of issues with the PCI controller code for mach-versatile: (1) The irq mapping matched neither hardware nor QEMU; we correct it to match the hardware, which means it will also work on recent (1.5 or later) QEMU. (2) The code was confused between the PCI I/O window (at 0x43000000) and the first PCI memory window (at 0x44000000), which meant that PCI devices using PCI PIO rather than MMIO didn't work. This is fixed (and some variables/labels are renamed to avoid further confusion in future). (3) The SMAP register offsets were all off-by-four, though by fluke this didn't actually have any ill effects. All these changes have been tested on real hardware (PB926 plus the PCI backplane), as well as on QEMU. I have confirmed that IRQs and PCI PIO and MMIO work OK. PCI bus-master DMA doesn't seem to work on h/w -- as far as I can tell the device is correctly managing to DMA to the right places in memory, but every other 32 bit word is corrupt (at least judging from rtl8139 debug dumps of the frames it's receiving). I'm not sure what's going on here, but since this is disjoint from the irq and I/O issues I don't think that applying the patches that fix those should be stalled on trying to debug DMA problems. (DMA works fine on QEMU, incidentally.) * versatile/fixes: ARM: PCI: versatile: Fix SMAP register offsets ARM: PCI: versatile: Fix PCI I/O ARM: PCI: versatile: Fix map_irq function to match hardware Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'arch/arm/mach-versatile')
-rw-r--r--arch/arm/mach-versatile/include/mach/platform.h2
-rw-r--r--arch/arm/mach-versatile/pci.c47
2 files changed, 32 insertions, 17 deletions
diff --git a/arch/arm/mach-versatile/include/mach/platform.h b/arch/arm/mach-versatile/include/mach/platform.h
index ec087407b163..6f938ccb0c54 100644
--- a/arch/arm/mach-versatile/include/mach/platform.h
+++ b/arch/arm/mach-versatile/include/mach/platform.h
@@ -231,12 +231,14 @@
231/* PCI space */ 231/* PCI space */
232#define VERSATILE_PCI_BASE 0x41000000 /* PCI Interface */ 232#define VERSATILE_PCI_BASE 0x41000000 /* PCI Interface */
233#define VERSATILE_PCI_CFG_BASE 0x42000000 233#define VERSATILE_PCI_CFG_BASE 0x42000000
234#define VERSATILE_PCI_IO_BASE 0x43000000
234#define VERSATILE_PCI_MEM_BASE0 0x44000000 235#define VERSATILE_PCI_MEM_BASE0 0x44000000
235#define VERSATILE_PCI_MEM_BASE1 0x50000000 236#define VERSATILE_PCI_MEM_BASE1 0x50000000
236#define VERSATILE_PCI_MEM_BASE2 0x60000000 237#define VERSATILE_PCI_MEM_BASE2 0x60000000
237/* Sizes of above maps */ 238/* Sizes of above maps */
238#define VERSATILE_PCI_BASE_SIZE 0x01000000 239#define VERSATILE_PCI_BASE_SIZE 0x01000000
239#define VERSATILE_PCI_CFG_BASE_SIZE 0x02000000 240#define VERSATILE_PCI_CFG_BASE_SIZE 0x02000000
241#define VERSATILE_PCI_IO_BASE_SIZE 0x01000000
240#define VERSATILE_PCI_MEM_BASE0_SIZE 0x0c000000 /* 32Mb */ 242#define VERSATILE_PCI_MEM_BASE0_SIZE 0x0c000000 /* 32Mb */
241#define VERSATILE_PCI_MEM_BASE1_SIZE 0x10000000 /* 256Mb */ 243#define VERSATILE_PCI_MEM_BASE1_SIZE 0x10000000 /* 256Mb */
242#define VERSATILE_PCI_MEM_BASE2_SIZE 0x10000000 /* 256Mb */ 244#define VERSATILE_PCI_MEM_BASE2_SIZE 0x10000000 /* 256Mb */
diff --git a/arch/arm/mach-versatile/pci.c b/arch/arm/mach-versatile/pci.c
index e92e5e0705bc..c97be4ea76d2 100644
--- a/arch/arm/mach-versatile/pci.c
+++ b/arch/arm/mach-versatile/pci.c
@@ -43,9 +43,9 @@
43#define PCI_IMAP0 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x0) 43#define PCI_IMAP0 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x0)
44#define PCI_IMAP1 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x4) 44#define PCI_IMAP1 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x4)
45#define PCI_IMAP2 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x8) 45#define PCI_IMAP2 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x8)
46#define PCI_SMAP0 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x10) 46#define PCI_SMAP0 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x14)
47#define PCI_SMAP1 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x14) 47#define PCI_SMAP1 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x18)
48#define PCI_SMAP2 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x18) 48#define PCI_SMAP2 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x1c)
49#define PCI_SELFID __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0xc) 49#define PCI_SELFID __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0xc)
50 50
51#define DEVICE_ID_OFFSET 0x00 51#define DEVICE_ID_OFFSET 0x00
@@ -170,8 +170,8 @@ static struct pci_ops pci_versatile_ops = {
170 .write = versatile_write_config, 170 .write = versatile_write_config,
171}; 171};
172 172
173static struct resource io_mem = { 173static struct resource unused_mem = {
174 .name = "PCI I/O space", 174 .name = "PCI unused",
175 .start = VERSATILE_PCI_MEM_BASE0, 175 .start = VERSATILE_PCI_MEM_BASE0,
176 .end = VERSATILE_PCI_MEM_BASE0+VERSATILE_PCI_MEM_BASE0_SIZE-1, 176 .end = VERSATILE_PCI_MEM_BASE0+VERSATILE_PCI_MEM_BASE0_SIZE-1,
177 .flags = IORESOURCE_MEM, 177 .flags = IORESOURCE_MEM,
@@ -195,9 +195,9 @@ static int __init pci_versatile_setup_resources(struct pci_sys_data *sys)
195{ 195{
196 int ret = 0; 196 int ret = 0;
197 197
198 ret = request_resource(&iomem_resource, &io_mem); 198 ret = request_resource(&iomem_resource, &unused_mem);
199 if (ret) { 199 if (ret) {
200 printk(KERN_ERR "PCI: unable to allocate I/O " 200 printk(KERN_ERR "PCI: unable to allocate unused "
201 "memory region (%d)\n", ret); 201 "memory region (%d)\n", ret);
202 goto out; 202 goto out;
203 } 203 }
@@ -205,7 +205,7 @@ static int __init pci_versatile_setup_resources(struct pci_sys_data *sys)
205 if (ret) { 205 if (ret) {
206 printk(KERN_ERR "PCI: unable to allocate non-prefetchable " 206 printk(KERN_ERR "PCI: unable to allocate non-prefetchable "
207 "memory region (%d)\n", ret); 207 "memory region (%d)\n", ret);
208 goto release_io_mem; 208 goto release_unused_mem;
209 } 209 }
210 ret = request_resource(&iomem_resource, &pre_mem); 210 ret = request_resource(&iomem_resource, &pre_mem);
211 if (ret) { 211 if (ret) {
@@ -225,8 +225,8 @@ static int __init pci_versatile_setup_resources(struct pci_sys_data *sys)
225 225
226 release_non_mem: 226 release_non_mem:
227 release_resource(&non_mem); 227 release_resource(&non_mem);
228 release_io_mem: 228 release_unused_mem:
229 release_resource(&io_mem); 229 release_resource(&unused_mem);
230 out: 230 out:
231 return ret; 231 return ret;
232} 232}
@@ -246,7 +246,7 @@ int __init pci_versatile_setup(int nr, struct pci_sys_data *sys)
246 goto out; 246 goto out;
247 } 247 }
248 248
249 ret = pci_ioremap_io(0, VERSATILE_PCI_MEM_BASE0); 249 ret = pci_ioremap_io(0, VERSATILE_PCI_IO_BASE);
250 if (ret) 250 if (ret)
251 goto out; 251 goto out;
252 252
@@ -295,6 +295,19 @@ int __init pci_versatile_setup(int nr, struct pci_sys_data *sys)
295 __raw_writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_2); 295 __raw_writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_2);
296 296
297 /* 297 /*
298 * For many years the kernel and QEMU were symbiotically buggy
299 * in that they both assumed the same broken IRQ mapping.
300 * QEMU therefore attempts to auto-detect old broken kernels
301 * so that they still work on newer QEMU as they did on old
302 * QEMU. Since we now use the correct (ie matching-hardware)
303 * IRQ mapping we write a definitely different value to a
304 * PCI_INTERRUPT_LINE register to tell QEMU that we expect
305 * real hardware behaviour and it need not be backwards
306 * compatible for us. This write is harmless on real hardware.
307 */
308 __raw_writel(0, VERSATILE_PCI_VIRT_BASE+PCI_INTERRUPT_LINE);
309
310 /*
298 * Do not to map Versatile FPGA PCI device into memory space 311 * Do not to map Versatile FPGA PCI device into memory space
299 */ 312 */
300 pci_slot_ignore |= (1 << myslot); 313 pci_slot_ignore |= (1 << myslot);
@@ -327,13 +340,13 @@ static int __init versatile_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
327{ 340{
328 int irq; 341 int irq;
329 342
330 /* slot, pin, irq 343 /*
331 * 24 1 IRQ_SIC_PCI0 344 * Slot INTA INTB INTC INTD
332 * 25 1 IRQ_SIC_PCI1 345 * 31 PCI1 PCI2 PCI3 PCI0
333 * 26 1 IRQ_SIC_PCI2 346 * 30 PCI0 PCI1 PCI2 PCI3
334 * 27 1 IRQ_SIC_PCI3 347 * 29 PCI3 PCI0 PCI1 PCI2
335 */ 348 */
336 irq = IRQ_SIC_PCI0 + ((slot - 24 + pin - 1) & 3); 349 irq = IRQ_SIC_PCI0 + ((slot + 2 + pin - 1) & 3);
337 350
338 return irq; 351 return irq;
339} 352}