fixup-cobalt.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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/cobalt/cobalt.h>
  19. extern int cobalt_board_id;
  20. static void qube_raq_via_bmIDE_fixup(struct pci_dev *dev)
  21. {
  22. unsigned short cfgword;
  23. unsigned char lt;
  24. /* Enable Bus Mastering and fast back to back. */
  25. pci_read_config_word(dev, PCI_COMMAND, &cfgword);
  26. cfgword |= (PCI_COMMAND_FAST_BACK | PCI_COMMAND_MASTER);
  27. pci_write_config_word(dev, PCI_COMMAND, cfgword);
  28. /* Enable both ide interfaces. ROM only enables primary one. */
  29. pci_write_config_byte(dev, 0x40, 0xb);
  30. /* Set latency timer to reasonable value. */
  31. pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lt);
  32. if (lt < 64)
  33. pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
  34. pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 7);
  35. }
  36. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1,
  37. qube_raq_via_bmIDE_fixup);
  38. static void qube_raq_galileo_fixup(struct pci_dev *dev)
  39. {
  40. unsigned short galileo_id;
  41. /* Fix PCI latency-timer and cache-line-size values in Galileo
  42. * host bridge.
  43. */
  44. pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
  45. pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 7);
  46. /*
  47. * On all machines prior to Q2, we had the STOP line disconnected
  48. * from Galileo to VIA on PCI. The new Galileo does not function
  49. * correctly unless we have it connected.
  50. *
  51. * Therefore we must set the disconnect/retry cycle values to
  52. * something sensible when using the new Galileo.
  53. */
  54. pci_read_config_word(dev, PCI_REVISION_ID, &galileo_id);
  55. galileo_id &= 0xff; /* mask off class info */
  56. if (galileo_id >= 0x10) {
  57. /* New Galileo, assumes PCI stop line to VIA is connected. */
  58. GALILEO_OUTL(0x4020, GT_PCI0_TOR_OFS);
  59. } else if (galileo_id == 0x1 || galileo_id == 0x2) {
  60. signed int timeo;
  61. /* XXX WE MUST DO THIS ELSE GALILEO LOCKS UP! -DaveM */
  62. timeo = GALILEO_INL(GT_PCI0_TOR_OFS);
  63. /* Old Galileo, assumes PCI STOP line to VIA is disconnected. */
  64. GALILEO_OUTL(0xffff, GT_PCI0_TOR_OFS);
  65. }
  66. }
  67. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_GALILEO, PCI_ANY_ID,
  68. qube_raq_galileo_fixup);
  69. static char irq_tab_cobalt[] __initdata = {
  70. [COBALT_PCICONF_CPU] = 0,
  71. [COBALT_PCICONF_ETH0] = COBALT_ETH0_IRQ,
  72. [COBALT_PCICONF_RAQSCSI] = COBALT_SCSI_IRQ,
  73. [COBALT_PCICONF_VIA] = 0,
  74. [COBALT_PCICONF_PCISLOT] = COBALT_QUBE_SLOT_IRQ,
  75. [COBALT_PCICONF_ETH1] = COBALT_ETH1_IRQ
  76. };
  77. static char irq_tab_raq2[] __initdata = {
  78. [COBALT_PCICONF_CPU] = 0,
  79. [COBALT_PCICONF_ETH0] = COBALT_ETH0_IRQ,
  80. [COBALT_PCICONF_RAQSCSI] = COBALT_RAQ_SCSI_IRQ,
  81. [COBALT_PCICONF_VIA] = 0,
  82. [COBALT_PCICONF_PCISLOT] = COBALT_QUBE_SLOT_IRQ,
  83. [COBALT_PCICONF_ETH1] = COBALT_ETH1_IRQ
  84. };
  85. int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  86. {
  87. if (cobalt_board_id == COBALT_BRD_ID_RAQ2)
  88. return irq_tab_raq2[slot];
  89. return irq_tab_cobalt[slot];
  90. }
  91. /* Do platform specific device initialization at pci_enable_device() time */
  92. int pcibios_plat_dev_init(struct pci_dev *dev)
  93. {
  94. return 0;
  95. }