18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 38c2ecf20Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 48c2ecf20Sopenharmony_ci * for more details. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 2000, 2001 Keith M Wesolowski 78c2ecf20Sopenharmony_ci * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org) 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci#include <linux/kernel.h> 108c2ecf20Sopenharmony_ci#include <linux/init.h> 118c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 128c2ecf20Sopenharmony_ci#include <linux/pci.h> 138c2ecf20Sopenharmony_ci#include <linux/types.h> 148c2ecf20Sopenharmony_ci#include <asm/ip32/mace.h> 158c2ecf20Sopenharmony_ci#include <asm/ip32/ip32_ints.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#undef DEBUG_MACE_PCI 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* 208c2ecf20Sopenharmony_ci * Handle errors from the bridge. This includes master and target aborts, 218c2ecf20Sopenharmony_ci * various command and address errors, and the interrupt test. This gets 228c2ecf20Sopenharmony_ci * registered on the bridge error irq. It's conceivable that some of these 238c2ecf20Sopenharmony_ci * conditions warrant a panic. Anybody care to say which ones? 248c2ecf20Sopenharmony_ci */ 258c2ecf20Sopenharmony_cistatic irqreturn_t macepci_error(int irq, void *dev) 268c2ecf20Sopenharmony_ci{ 278c2ecf20Sopenharmony_ci char s; 288c2ecf20Sopenharmony_ci unsigned int flags = mace->pci.error; 298c2ecf20Sopenharmony_ci unsigned int addr = mace->pci.error_addr; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci if (flags & MACEPCI_ERROR_MEMORY_ADDR) 328c2ecf20Sopenharmony_ci s = 'M'; 338c2ecf20Sopenharmony_ci else if (flags & MACEPCI_ERROR_CONFIG_ADDR) 348c2ecf20Sopenharmony_ci s = 'C'; 358c2ecf20Sopenharmony_ci else 368c2ecf20Sopenharmony_ci s = 'X'; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci if (flags & MACEPCI_ERROR_MASTER_ABORT) { 398c2ecf20Sopenharmony_ci printk("MACEPCI: Master abort at 0x%08x (%c)\n", addr, s); 408c2ecf20Sopenharmony_ci flags &= ~MACEPCI_ERROR_MASTER_ABORT; 418c2ecf20Sopenharmony_ci } 428c2ecf20Sopenharmony_ci if (flags & MACEPCI_ERROR_TARGET_ABORT) { 438c2ecf20Sopenharmony_ci printk("MACEPCI: Target abort at 0x%08x (%c)\n", addr, s); 448c2ecf20Sopenharmony_ci flags &= ~MACEPCI_ERROR_TARGET_ABORT; 458c2ecf20Sopenharmony_ci } 468c2ecf20Sopenharmony_ci if (flags & MACEPCI_ERROR_DATA_PARITY_ERR) { 478c2ecf20Sopenharmony_ci printk("MACEPCI: Data parity error at 0x%08x (%c)\n", addr, s); 488c2ecf20Sopenharmony_ci flags &= ~MACEPCI_ERROR_DATA_PARITY_ERR; 498c2ecf20Sopenharmony_ci } 508c2ecf20Sopenharmony_ci if (flags & MACEPCI_ERROR_RETRY_ERR) { 518c2ecf20Sopenharmony_ci printk("MACEPCI: Retry error at 0x%08x (%c)\n", addr, s); 528c2ecf20Sopenharmony_ci flags &= ~MACEPCI_ERROR_RETRY_ERR; 538c2ecf20Sopenharmony_ci } 548c2ecf20Sopenharmony_ci if (flags & MACEPCI_ERROR_ILLEGAL_CMD) { 558c2ecf20Sopenharmony_ci printk("MACEPCI: Illegal command at 0x%08x (%c)\n", addr, s); 568c2ecf20Sopenharmony_ci flags &= ~MACEPCI_ERROR_ILLEGAL_CMD; 578c2ecf20Sopenharmony_ci } 588c2ecf20Sopenharmony_ci if (flags & MACEPCI_ERROR_SYSTEM_ERR) { 598c2ecf20Sopenharmony_ci printk("MACEPCI: System error at 0x%08x (%c)\n", addr, s); 608c2ecf20Sopenharmony_ci flags &= ~MACEPCI_ERROR_SYSTEM_ERR; 618c2ecf20Sopenharmony_ci } 628c2ecf20Sopenharmony_ci if (flags & MACEPCI_ERROR_PARITY_ERR) { 638c2ecf20Sopenharmony_ci printk("MACEPCI: Parity error at 0x%08x (%c)\n", addr, s); 648c2ecf20Sopenharmony_ci flags &= ~MACEPCI_ERROR_PARITY_ERR; 658c2ecf20Sopenharmony_ci } 668c2ecf20Sopenharmony_ci if (flags & MACEPCI_ERROR_OVERRUN) { 678c2ecf20Sopenharmony_ci printk("MACEPCI: Overrun error at 0x%08x (%c)\n", addr, s); 688c2ecf20Sopenharmony_ci flags &= ~MACEPCI_ERROR_OVERRUN; 698c2ecf20Sopenharmony_ci } 708c2ecf20Sopenharmony_ci if (flags & MACEPCI_ERROR_SIG_TABORT) { 718c2ecf20Sopenharmony_ci printk("MACEPCI: Signaled target abort (clearing)\n"); 728c2ecf20Sopenharmony_ci flags &= ~MACEPCI_ERROR_SIG_TABORT; 738c2ecf20Sopenharmony_ci } 748c2ecf20Sopenharmony_ci if (flags & MACEPCI_ERROR_INTERRUPT_TEST) { 758c2ecf20Sopenharmony_ci printk("MACEPCI: Interrupt test triggered (clearing)\n"); 768c2ecf20Sopenharmony_ci flags &= ~MACEPCI_ERROR_INTERRUPT_TEST; 778c2ecf20Sopenharmony_ci } 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci mace->pci.error = flags; 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci return IRQ_HANDLED; 828c2ecf20Sopenharmony_ci} 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ciextern struct pci_ops mace_pci_ops; 868c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT 878c2ecf20Sopenharmony_cistatic struct resource mace_pci_mem_resource = { 888c2ecf20Sopenharmony_ci .name = "SGI O2 PCI MEM", 898c2ecf20Sopenharmony_ci .start = MACEPCI_HI_MEMORY, 908c2ecf20Sopenharmony_ci .end = 0x2FFFFFFFFUL, 918c2ecf20Sopenharmony_ci .flags = IORESOURCE_MEM, 928c2ecf20Sopenharmony_ci}; 938c2ecf20Sopenharmony_cistatic struct resource mace_pci_io_resource = { 948c2ecf20Sopenharmony_ci .name = "SGI O2 PCI IO", 958c2ecf20Sopenharmony_ci .start = 0x00000000UL, 968c2ecf20Sopenharmony_ci .end = 0xffffffffUL, 978c2ecf20Sopenharmony_ci .flags = IORESOURCE_IO, 988c2ecf20Sopenharmony_ci}; 998c2ecf20Sopenharmony_ci#define MACE_PCI_MEM_OFFSET 0x200000000 1008c2ecf20Sopenharmony_ci#else 1018c2ecf20Sopenharmony_cistatic struct resource mace_pci_mem_resource = { 1028c2ecf20Sopenharmony_ci .name = "SGI O2 PCI MEM", 1038c2ecf20Sopenharmony_ci .start = MACEPCI_LOW_MEMORY, 1048c2ecf20Sopenharmony_ci .end = MACEPCI_LOW_MEMORY + 0x2000000 - 1, 1058c2ecf20Sopenharmony_ci .flags = IORESOURCE_MEM, 1068c2ecf20Sopenharmony_ci}; 1078c2ecf20Sopenharmony_cistatic struct resource mace_pci_io_resource = { 1088c2ecf20Sopenharmony_ci .name = "SGI O2 PCI IO", 1098c2ecf20Sopenharmony_ci .start = 0x00000000, 1108c2ecf20Sopenharmony_ci .end = 0xFFFFFFFF, 1118c2ecf20Sopenharmony_ci .flags = IORESOURCE_IO, 1128c2ecf20Sopenharmony_ci}; 1138c2ecf20Sopenharmony_ci#define MACE_PCI_MEM_OFFSET (MACEPCI_LOW_MEMORY - 0x80000000) 1148c2ecf20Sopenharmony_ci#endif 1158c2ecf20Sopenharmony_cistatic struct pci_controller mace_pci_controller = { 1168c2ecf20Sopenharmony_ci .pci_ops = &mace_pci_ops, 1178c2ecf20Sopenharmony_ci .mem_resource = &mace_pci_mem_resource, 1188c2ecf20Sopenharmony_ci .io_resource = &mace_pci_io_resource, 1198c2ecf20Sopenharmony_ci .mem_offset = MACE_PCI_MEM_OFFSET, 1208c2ecf20Sopenharmony_ci .io_offset = 0, 1218c2ecf20Sopenharmony_ci .io_map_base = CKSEG1ADDR(MACEPCI_LOW_IO), 1228c2ecf20Sopenharmony_ci}; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_cistatic int __init mace_init(void) 1258c2ecf20Sopenharmony_ci{ 1268c2ecf20Sopenharmony_ci PCIBIOS_MIN_IO = 0x1000; 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci /* Clear any outstanding errors and enable interrupts */ 1298c2ecf20Sopenharmony_ci mace->pci.error_addr = 0; 1308c2ecf20Sopenharmony_ci mace->pci.error = 0; 1318c2ecf20Sopenharmony_ci mace->pci.control = 0xff008500; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci printk("MACE PCI rev %d\n", mace->pci.rev); 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci BUG_ON(request_irq(MACE_PCI_BRIDGE_IRQ, macepci_error, 0, 1368c2ecf20Sopenharmony_ci "MACE PCI error", NULL)); 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci /* extend memory resources */ 1398c2ecf20Sopenharmony_ci iomem_resource.end = mace_pci_mem_resource.end; 1408c2ecf20Sopenharmony_ci ioport_resource = mace_pci_io_resource; 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci register_pci_controller(&mace_pci_controller); 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci return 0; 1458c2ecf20Sopenharmony_ci} 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ciarch_initcall(mace_init); 148