fixup-cobalt.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * Cobalt Qube/Raq PCI support
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 1995, 1996, 1997, 2002, 2003 by Ralf Baechle
  9. * Copyright (C) 2001, 2002, 2003 by Liam Davies (ldavies@agile.tv)
  10. */
  11. #include <linux/types.h>
  12. #include <linux/pci.h>
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <asm/pci.h>
  16. #include <asm/io.h>
  17. #include <asm/gt64120.h>
  18. #include <asm/mach-cobalt/cobalt.h>
  19. extern int cobalt_board_id;
  20. static void qube_raq_galileo_early_fixup(struct pci_dev *dev)
  21. {
  22. if (dev->devfn == PCI_DEVFN(0, 0) &&
  23. (dev->class >> 8) == PCI_CLASS_MEMORY_OTHER) {
  24. dev->class = (PCI_CLASS_BRIDGE_HOST << 8) | (dev->class & 0xff);
  25. printk(KERN_INFO "Galileo: fixed bridge class\n");
  26. }
  27. }
  28. DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_GT64111,
  29. qube_raq_galileo_early_fixup);
  30. static void qube_raq_via_bmIDE_fixup(struct pci_dev *dev)
  31. {
  32. unsigned short cfgword;
  33. unsigned char lt;
  34. /* Enable Bus Mastering and fast back to back. */
  35. pci_read_config_word(dev, PCI_COMMAND, &cfgword);
  36. cfgword |= (PCI_COMMAND_FAST_BACK | PCI_COMMAND_MASTER);
  37. pci_write_config_word(dev, PCI_COMMAND, cfgword);
  38. /* Enable both ide interfaces. ROM only enables primary one. */
  39. pci_write_config_byte(dev, 0x40, 0xb);
  40. /* Set latency timer to reasonable value. */
  41. pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lt);
  42. if (lt < 64)
  43. pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
  44. pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 8);
  45. }
  46. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1,
  47. qube_raq_via_bmIDE_fixup);
  48. static void qube_raq_galileo_fixup(struct pci_dev *dev)
  49. {
  50. unsigned short galileo_id;
  51. if (dev->devfn != PCI_DEVFN(0, 0))
  52. return;
  53. /* Fix PCI latency-timer and cache-line-size values in Galileo
  54. * host bridge.
  55. */
  56. pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
  57. pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 8);
  58. /*
  59. * The code described by the comment below has been removed
  60. * as it causes bus mastering by the Ethernet controllers
  61. * to break under any kind of network load. We always set
  62. * the retry timeouts to their maximum.
  63. *
  64. * --x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--
  65. *
  66. * On all machines prior to Q2, we had the STOP line disconnected
  67. * from Galileo to VIA on PCI. The new Galileo does not function
  68. * correctly unless we have it connected.
  69. *
  70. * Therefore we must set the disconnect/retry cycle values to
  71. * something sensible when using the new Galileo.
  72. */
  73. pci_read_config_word(dev, PCI_REVISION_ID, &galileo_id);
  74. galileo_id &= 0xff; /* mask off class info */
  75. printk(KERN_INFO "Galileo: revision %u\n", galileo_id);
  76. #if 0
  77. if (galileo_id >= 0x10) {
  78. /* New Galileo, assumes PCI stop line to VIA is connected. */
  79. GT_WRITE(GT_PCI0_TOR_OFS, 0x4020);
  80. } else if (galileo_id == 0x1 || galileo_id == 0x2)
  81. #endif
  82. {
  83. signed int timeo;
  84. /* XXX WE MUST DO THIS ELSE GALILEO LOCKS UP! -DaveM */
  85. timeo = GT_READ(GT_PCI0_TOR_OFS);
  86. /* Old Galileo, assumes PCI STOP line to VIA is disconnected. */
  87. GT_WRITE(GT_PCI0_TOR_OFS,
  88. (0xff << 16) | /* retry count */
  89. (0xff << 8) | /* timeout 1 */
  90. 0xff); /* timeout 0 */
  91. /* enable PCI retry exceeded interrupt */
  92. GT_WRITE(GT_INTRMASK_OFS, GT_INTR_RETRYCTR0_MSK | GT_READ(GT_INTRMASK_OFS));
  93. }
  94. }
  95. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_GT64111,
  96. qube_raq_galileo_fixup);
  97. static char irq_tab_qube1[] __initdata = {
  98. [COBALT_PCICONF_CPU] = 0,
  99. [COBALT_PCICONF_ETH0] = COBALT_QUBE1_ETH0_IRQ,
  100. [COBALT_PCICONF_RAQSCSI] = COBALT_SCSI_IRQ,
  101. [COBALT_PCICONF_VIA] = 0,
  102. [COBALT_PCICONF_PCISLOT] = COBALT_QUBE_SLOT_IRQ,
  103. [COBALT_PCICONF_ETH1] = 0
  104. };
  105. static char irq_tab_cobalt[] __initdata = {
  106. [COBALT_PCICONF_CPU] = 0,
  107. [COBALT_PCICONF_ETH0] = COBALT_ETH0_IRQ,
  108. [COBALT_PCICONF_RAQSCSI] = COBALT_SCSI_IRQ,
  109. [COBALT_PCICONF_VIA] = 0,
  110. [COBALT_PCICONF_PCISLOT] = COBALT_QUBE_SLOT_IRQ,
  111. [COBALT_PCICONF_ETH1] = COBALT_ETH1_IRQ
  112. };
  113. static char irq_tab_raq2[] __initdata = {
  114. [COBALT_PCICONF_CPU] = 0,
  115. [COBALT_PCICONF_ETH0] = COBALT_ETH0_IRQ,
  116. [COBALT_PCICONF_RAQSCSI] = COBALT_RAQ_SCSI_IRQ,
  117. [COBALT_PCICONF_VIA] = 0,
  118. [COBALT_PCICONF_PCISLOT] = COBALT_QUBE_SLOT_IRQ,
  119. [COBALT_PCICONF_ETH1] = COBALT_ETH1_IRQ
  120. };
  121. int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  122. {
  123. if (cobalt_board_id < COBALT_BRD_ID_QUBE2)
  124. return irq_tab_qube1[slot];
  125. if (cobalt_board_id == COBALT_BRD_ID_RAQ2)
  126. return irq_tab_raq2[slot];
  127. return irq_tab_cobalt[slot];
  128. }
  129. /* Do platform specific device initialization at pci_enable_device() time */
  130. int pcibios_plat_dev_init(struct pci_dev *dev)
  131. {
  132. return 0;
  133. }