fixup-cobalt.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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 <cobalt.h>
  19. static void qube_raq_galileo_early_fixup(struct pci_dev *dev)
  20. {
  21. if (dev->devfn == PCI_DEVFN(0, 0) &&
  22. (dev->class >> 8) == PCI_CLASS_MEMORY_OTHER) {
  23. dev->class = (PCI_CLASS_BRIDGE_HOST << 8) | (dev->class & 0xff);
  24. printk(KERN_INFO "Galileo: fixed bridge class\n");
  25. }
  26. }
  27. DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_GT64111,
  28. qube_raq_galileo_early_fixup);
  29. static void qube_raq_via_bmIDE_fixup(struct pci_dev *dev)
  30. {
  31. unsigned short cfgword;
  32. unsigned char lt;
  33. /* Enable Bus Mastering and fast back to back. */
  34. pci_read_config_word(dev, PCI_COMMAND, &cfgword);
  35. cfgword |= (PCI_COMMAND_FAST_BACK | PCI_COMMAND_MASTER);
  36. pci_write_config_word(dev, PCI_COMMAND, cfgword);
  37. /* Enable both ide interfaces. ROM only enables primary one. */
  38. pci_write_config_byte(dev, 0x40, 0xb);
  39. /* Set latency timer to reasonable value. */
  40. pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lt);
  41. if (lt < 64)
  42. pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
  43. pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 8);
  44. }
  45. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1,
  46. qube_raq_via_bmIDE_fixup);
  47. static void qube_raq_galileo_fixup(struct pci_dev *dev)
  48. {
  49. unsigned short galileo_id;
  50. if (dev->devfn != PCI_DEVFN(0, 0))
  51. return;
  52. /* Fix PCI latency-timer and cache-line-size values in Galileo
  53. * host bridge.
  54. */
  55. pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
  56. pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 8);
  57. /*
  58. * The code described by the comment below has been removed
  59. * as it causes bus mastering by the Ethernet controllers
  60. * to break under any kind of network load. We always set
  61. * the retry timeouts to their maximum.
  62. *
  63. * --x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--
  64. *
  65. * On all machines prior to Q2, we had the STOP line disconnected
  66. * from Galileo to VIA on PCI. The new Galileo does not function
  67. * correctly unless we have it connected.
  68. *
  69. * Therefore we must set the disconnect/retry cycle values to
  70. * something sensible when using the new Galileo.
  71. */
  72. pci_read_config_word(dev, PCI_REVISION_ID, &galileo_id);
  73. galileo_id &= 0xff; /* mask off class info */
  74. printk(KERN_INFO "Galileo: revision %u\n", galileo_id);
  75. #if 0
  76. if (galileo_id >= 0x10) {
  77. /* New Galileo, assumes PCI stop line to VIA is connected. */
  78. GT_WRITE(GT_PCI0_TOR_OFS, 0x4020);
  79. } else if (galileo_id == 0x1 || galileo_id == 0x2)
  80. #endif
  81. {
  82. signed int timeo;
  83. /* XXX WE MUST DO THIS ELSE GALILEO LOCKS UP! -DaveM */
  84. timeo = GT_READ(GT_PCI0_TOR_OFS);
  85. /* Old Galileo, assumes PCI STOP line to VIA is disconnected. */
  86. GT_WRITE(GT_PCI0_TOR_OFS,
  87. (0xff << 16) | /* retry count */
  88. (0xff << 8) | /* timeout 1 */
  89. 0xff); /* timeout 0 */
  90. /* enable PCI retry exceeded interrupt */
  91. GT_WRITE(GT_INTRMASK_OFS, GT_INTR_RETRYCTR0_MSK | GT_READ(GT_INTRMASK_OFS));
  92. }
  93. }
  94. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_GT64111,
  95. qube_raq_galileo_fixup);
  96. int cobalt_board_id;
  97. static void qube_raq_via_board_id_fixup(struct pci_dev *dev)
  98. {
  99. u8 id;
  100. int retval;
  101. retval = pci_read_config_byte(dev, VIA_COBALT_BRD_ID_REG, &id);
  102. if (retval) {
  103. panic("Cannot read board ID");
  104. return;
  105. }
  106. cobalt_board_id = VIA_COBALT_BRD_REG_to_ID(id);
  107. printk(KERN_INFO "Cobalt board ID: %d\n", cobalt_board_id);
  108. }
  109. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_0,
  110. qube_raq_via_board_id_fixup);
  111. static char irq_tab_qube1[] __initdata = {
  112. [COBALT_PCICONF_CPU] = 0,
  113. [COBALT_PCICONF_ETH0] = COBALT_QUBE1_ETH0_IRQ,
  114. [COBALT_PCICONF_RAQSCSI] = COBALT_SCSI_IRQ,
  115. [COBALT_PCICONF_VIA] = 0,
  116. [COBALT_PCICONF_PCISLOT] = COBALT_QUBE_SLOT_IRQ,
  117. [COBALT_PCICONF_ETH1] = 0
  118. };
  119. static char irq_tab_cobalt[] __initdata = {
  120. [COBALT_PCICONF_CPU] = 0,
  121. [COBALT_PCICONF_ETH0] = COBALT_ETH0_IRQ,
  122. [COBALT_PCICONF_RAQSCSI] = COBALT_SCSI_IRQ,
  123. [COBALT_PCICONF_VIA] = 0,
  124. [COBALT_PCICONF_PCISLOT] = COBALT_QUBE_SLOT_IRQ,
  125. [COBALT_PCICONF_ETH1] = COBALT_ETH1_IRQ
  126. };
  127. static char irq_tab_raq2[] __initdata = {
  128. [COBALT_PCICONF_CPU] = 0,
  129. [COBALT_PCICONF_ETH0] = COBALT_ETH0_IRQ,
  130. [COBALT_PCICONF_RAQSCSI] = COBALT_RAQ_SCSI_IRQ,
  131. [COBALT_PCICONF_VIA] = 0,
  132. [COBALT_PCICONF_PCISLOT] = COBALT_QUBE_SLOT_IRQ,
  133. [COBALT_PCICONF_ETH1] = COBALT_ETH1_IRQ
  134. };
  135. int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  136. {
  137. if (cobalt_board_id < COBALT_BRD_ID_QUBE2)
  138. return irq_tab_qube1[slot];
  139. if (cobalt_board_id == COBALT_BRD_ID_RAQ2)
  140. return irq_tab_raq2[slot];
  141. return irq_tab_cobalt[slot];
  142. }
  143. /* Do platform specific device initialization at pci_enable_device() time */
  144. int pcibios_plat_dev_init(struct pci_dev *dev)
  145. {
  146. return 0;
  147. }