11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * Cobalt Qube/Raq PCI support 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * This file is subject to the terms and conditions of the GNU General Public 51da177e4SLinus Torvalds * License. See the file "COPYING" in the main directory of this archive 61da177e4SLinus Torvalds * for more details. 71da177e4SLinus Torvalds * 81da177e4SLinus Torvalds * Copyright (C) 1995, 1996, 1997, 2002, 2003 by Ralf Baechle 91da177e4SLinus Torvalds * Copyright (C) 2001, 2002, 2003 by Liam Davies (ldavies@agile.tv) 101da177e4SLinus Torvalds */ 111da177e4SLinus Torvalds #include <linux/types.h> 121da177e4SLinus Torvalds #include <linux/pci.h> 131da177e4SLinus Torvalds #include <linux/kernel.h> 141da177e4SLinus Torvalds #include <linux/init.h> 151da177e4SLinus Torvalds 161da177e4SLinus Torvalds #include <asm/pci.h> 171da177e4SLinus Torvalds #include <asm/io.h> 181da177e4SLinus Torvalds #include <asm/gt64120.h> 191da177e4SLinus Torvalds 2011ed6d5bSRalf Baechle #include <asm/mach-cobalt/cobalt.h> 211da177e4SLinus Torvalds 221da177e4SLinus Torvalds extern int cobalt_board_id; 231da177e4SLinus Torvalds 24c4ed38a0SRalf Baechle static void qube_raq_galileo_early_fixup(struct pci_dev *dev) 25c4ed38a0SRalf Baechle { 26c4ed38a0SRalf Baechle if (dev->devfn == PCI_DEVFN(0, 0) && 27c4ed38a0SRalf Baechle (dev->class >> 8) == PCI_CLASS_MEMORY_OTHER) { 28c4ed38a0SRalf Baechle 29c4ed38a0SRalf Baechle dev->class = (PCI_CLASS_BRIDGE_HOST << 8) | (dev->class & 0xff); 30c4ed38a0SRalf Baechle 31c4ed38a0SRalf Baechle printk(KERN_INFO "Galileo: fixed bridge class\n"); 32c4ed38a0SRalf Baechle } 33c4ed38a0SRalf Baechle } 34c4ed38a0SRalf Baechle 35c4ed38a0SRalf Baechle DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_GT64111, 36c4ed38a0SRalf Baechle qube_raq_galileo_early_fixup); 37c4ed38a0SRalf Baechle 381da177e4SLinus Torvalds static void qube_raq_via_bmIDE_fixup(struct pci_dev *dev) 391da177e4SLinus Torvalds { 401da177e4SLinus Torvalds unsigned short cfgword; 411da177e4SLinus Torvalds unsigned char lt; 421da177e4SLinus Torvalds 431da177e4SLinus Torvalds /* Enable Bus Mastering and fast back to back. */ 441da177e4SLinus Torvalds pci_read_config_word(dev, PCI_COMMAND, &cfgword); 451da177e4SLinus Torvalds cfgword |= (PCI_COMMAND_FAST_BACK | PCI_COMMAND_MASTER); 461da177e4SLinus Torvalds pci_write_config_word(dev, PCI_COMMAND, cfgword); 471da177e4SLinus Torvalds 481da177e4SLinus Torvalds /* Enable both ide interfaces. ROM only enables primary one. */ 491da177e4SLinus Torvalds pci_write_config_byte(dev, 0x40, 0xb); 501da177e4SLinus Torvalds 511da177e4SLinus Torvalds /* Set latency timer to reasonable value. */ 521da177e4SLinus Torvalds pci_read_config_byte(dev, PCI_LATENCY_TIMER, <); 531da177e4SLinus Torvalds if (lt < 64) 541da177e4SLinus Torvalds pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64); 5552378445SPeter Horton pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 8); 561da177e4SLinus Torvalds } 571da177e4SLinus Torvalds 581da177e4SLinus Torvalds DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, 591da177e4SLinus Torvalds qube_raq_via_bmIDE_fixup); 601da177e4SLinus Torvalds 611da177e4SLinus Torvalds static void qube_raq_galileo_fixup(struct pci_dev *dev) 621da177e4SLinus Torvalds { 631da177e4SLinus Torvalds unsigned short galileo_id; 641da177e4SLinus Torvalds 65c4ed38a0SRalf Baechle if (dev->devfn != PCI_DEVFN(0, 0)) 66c4ed38a0SRalf Baechle return; 67c4ed38a0SRalf Baechle 681da177e4SLinus Torvalds /* Fix PCI latency-timer and cache-line-size values in Galileo 691da177e4SLinus Torvalds * host bridge. 701da177e4SLinus Torvalds */ 711da177e4SLinus Torvalds pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64); 7252378445SPeter Horton pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 8); 731da177e4SLinus Torvalds 741da177e4SLinus Torvalds /* 75c4ed38a0SRalf Baechle * The code described by the comment below has been removed 76c4ed38a0SRalf Baechle * as it causes bus mastering by the Ethernet controllers 77c4ed38a0SRalf Baechle * to break under any kind of network load. We always set 78c4ed38a0SRalf Baechle * the retry timeouts to their maximum. 79c4ed38a0SRalf Baechle * 80c4ed38a0SRalf Baechle * --x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x-- 81c4ed38a0SRalf Baechle * 821da177e4SLinus Torvalds * On all machines prior to Q2, we had the STOP line disconnected 831da177e4SLinus Torvalds * from Galileo to VIA on PCI. The new Galileo does not function 841da177e4SLinus Torvalds * correctly unless we have it connected. 851da177e4SLinus Torvalds * 861da177e4SLinus Torvalds * Therefore we must set the disconnect/retry cycle values to 871da177e4SLinus Torvalds * something sensible when using the new Galileo. 881da177e4SLinus Torvalds */ 891da177e4SLinus Torvalds pci_read_config_word(dev, PCI_REVISION_ID, &galileo_id); 901da177e4SLinus Torvalds galileo_id &= 0xff; /* mask off class info */ 91c4ed38a0SRalf Baechle 92c4ed38a0SRalf Baechle printk(KERN_INFO "Galileo: revision %u\n", galileo_id); 93c4ed38a0SRalf Baechle 94c4ed38a0SRalf Baechle #if 0 951da177e4SLinus Torvalds if (galileo_id >= 0x10) { 961da177e4SLinus Torvalds /* New Galileo, assumes PCI stop line to VIA is connected. */ 9756ae5833SYoichi Yuasa GT_WRITE(GT_PCI0_TOR_OFS, 0x4020); 98c4ed38a0SRalf Baechle } else if (galileo_id == 0x1 || galileo_id == 0x2) 99c4ed38a0SRalf Baechle #endif 100c4ed38a0SRalf Baechle { 1011da177e4SLinus Torvalds signed int timeo; 1021da177e4SLinus Torvalds /* XXX WE MUST DO THIS ELSE GALILEO LOCKS UP! -DaveM */ 10356ae5833SYoichi Yuasa timeo = GT_READ(GT_PCI0_TOR_OFS); 1041da177e4SLinus Torvalds /* Old Galileo, assumes PCI STOP line to VIA is disconnected. */ 10556ae5833SYoichi Yuasa GT_WRITE(GT_PCI0_TOR_OFS, 106c4ed38a0SRalf Baechle (0xff << 16) | /* retry count */ 107c4ed38a0SRalf Baechle (0xff << 8) | /* timeout 1 */ 10856ae5833SYoichi Yuasa 0xff); /* timeout 0 */ 109c4ed38a0SRalf Baechle 110c4ed38a0SRalf Baechle /* enable PCI retry exceeded interrupt */ 11156ae5833SYoichi Yuasa GT_WRITE(GT_INTRMASK_OFS, GT_INTR_RETRYCTR0_MSK | GT_READ(GT_INTRMASK_OFS)); 1121da177e4SLinus Torvalds } 1131da177e4SLinus Torvalds } 1141da177e4SLinus Torvalds 115c4ed38a0SRalf Baechle DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_GT64111, 1161da177e4SLinus Torvalds qube_raq_galileo_fixup); 1171da177e4SLinus Torvalds 118c4ed38a0SRalf Baechle static char irq_tab_qube1[] __initdata = { 119c4ed38a0SRalf Baechle [COBALT_PCICONF_CPU] = 0, 120c4ed38a0SRalf Baechle [COBALT_PCICONF_ETH0] = COBALT_QUBE1_ETH0_IRQ, 121c4ed38a0SRalf Baechle [COBALT_PCICONF_RAQSCSI] = COBALT_SCSI_IRQ, 122c4ed38a0SRalf Baechle [COBALT_PCICONF_VIA] = 0, 123c4ed38a0SRalf Baechle [COBALT_PCICONF_PCISLOT] = COBALT_QUBE_SLOT_IRQ, 124c4ed38a0SRalf Baechle [COBALT_PCICONF_ETH1] = 0 125c4ed38a0SRalf Baechle }; 126c4ed38a0SRalf Baechle 1271da177e4SLinus Torvalds static char irq_tab_cobalt[] __initdata = { 1281da177e4SLinus Torvalds [COBALT_PCICONF_CPU] = 0, 1291da177e4SLinus Torvalds [COBALT_PCICONF_ETH0] = COBALT_ETH0_IRQ, 1301da177e4SLinus Torvalds [COBALT_PCICONF_RAQSCSI] = COBALT_SCSI_IRQ, 1311da177e4SLinus Torvalds [COBALT_PCICONF_VIA] = 0, 1321da177e4SLinus Torvalds [COBALT_PCICONF_PCISLOT] = COBALT_QUBE_SLOT_IRQ, 1331da177e4SLinus Torvalds [COBALT_PCICONF_ETH1] = COBALT_ETH1_IRQ 1341da177e4SLinus Torvalds }; 1351da177e4SLinus Torvalds 1361da177e4SLinus Torvalds static char irq_tab_raq2[] __initdata = { 1371da177e4SLinus Torvalds [COBALT_PCICONF_CPU] = 0, 1381da177e4SLinus Torvalds [COBALT_PCICONF_ETH0] = COBALT_ETH0_IRQ, 1391da177e4SLinus Torvalds [COBALT_PCICONF_RAQSCSI] = COBALT_RAQ_SCSI_IRQ, 1401da177e4SLinus Torvalds [COBALT_PCICONF_VIA] = 0, 1411da177e4SLinus Torvalds [COBALT_PCICONF_PCISLOT] = COBALT_QUBE_SLOT_IRQ, 1421da177e4SLinus Torvalds [COBALT_PCICONF_ETH1] = COBALT_ETH1_IRQ 1431da177e4SLinus Torvalds }; 1441da177e4SLinus Torvalds 1451da177e4SLinus Torvalds int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) 1461da177e4SLinus Torvalds { 147c4ed38a0SRalf Baechle if (cobalt_board_id < COBALT_BRD_ID_QUBE2) 148c4ed38a0SRalf Baechle return irq_tab_qube1[slot]; 149c4ed38a0SRalf Baechle 1501da177e4SLinus Torvalds if (cobalt_board_id == COBALT_BRD_ID_RAQ2) 1511da177e4SLinus Torvalds return irq_tab_raq2[slot]; 1521da177e4SLinus Torvalds 1531da177e4SLinus Torvalds return irq_tab_cobalt[slot]; 1541da177e4SLinus Torvalds } 1551da177e4SLinus Torvalds 1561da177e4SLinus Torvalds /* Do platform specific device initialization at pci_enable_device() time */ 1571da177e4SLinus Torvalds int pcibios_plat_dev_init(struct pci_dev *dev) 1581da177e4SLinus Torvalds { 1591da177e4SLinus Torvalds return 0; 1601da177e4SLinus Torvalds } 161