pci.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * arch/ppc64/kernel/pSeries_pci.c
  3. *
  4. * Copyright (C) 2001 Dave Engebretsen, IBM Corporation
  5. * Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM
  6. *
  7. * pSeries specific routines for PCI.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #include <linux/init.h>
  24. #include <linux/ioport.h>
  25. #include <linux/kernel.h>
  26. #include <linux/pci.h>
  27. #include <linux/string.h>
  28. #include <asm/pci-bridge.h>
  29. #include <asm/prom.h>
  30. #include <asm/ppc-pci.h>
  31. static int __devinitdata s7a_workaround = -1;
  32. #if 0
  33. void pcibios_name_device(struct pci_dev *dev)
  34. {
  35. struct device_node *dn;
  36. /*
  37. * Add IBM loc code (slot) as a prefix to the device names for service
  38. */
  39. dn = pci_device_to_OF_node(dev);
  40. if (dn) {
  41. char *loc_code = get_property(dn, "ibm,loc-code", 0);
  42. if (loc_code) {
  43. int loc_len = strlen(loc_code);
  44. if (loc_len < sizeof(dev->dev.name)) {
  45. memmove(dev->dev.name+loc_len+1, dev->dev.name,
  46. sizeof(dev->dev.name)-loc_len-1);
  47. memcpy(dev->dev.name, loc_code, loc_len);
  48. dev->dev.name[loc_len] = ' ';
  49. dev->dev.name[sizeof(dev->dev.name)-1] = '\0';
  50. }
  51. }
  52. }
  53. }
  54. DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_name_device);
  55. #endif
  56. static void __devinit check_s7a(void)
  57. {
  58. struct device_node *root;
  59. char *model;
  60. s7a_workaround = 0;
  61. root = of_find_node_by_path("/");
  62. if (root) {
  63. model = get_property(root, "model", NULL);
  64. if (model && !strcmp(model, "IBM,7013-S7A"))
  65. s7a_workaround = 1;
  66. of_node_put(root);
  67. }
  68. }
  69. void __devinit pSeries_irq_bus_setup(struct pci_bus *bus)
  70. {
  71. struct pci_dev *dev;
  72. if (s7a_workaround < 0)
  73. check_s7a();
  74. list_for_each_entry(dev, &bus->devices, bus_list) {
  75. pci_read_irq_line(dev);
  76. if (s7a_workaround) {
  77. if (dev->irq > 16) {
  78. dev->irq -= 3;
  79. pci_write_config_byte(dev, PCI_INTERRUPT_LINE,
  80. dev->irq);
  81. }
  82. }
  83. }
  84. }
  85. static void __init pSeries_request_regions(void)
  86. {
  87. if (!isa_io_base)
  88. return;
  89. request_region(0x20,0x20,"pic1");
  90. request_region(0xa0,0x20,"pic2");
  91. request_region(0x00,0x20,"dma1");
  92. request_region(0x40,0x20,"timer");
  93. request_region(0x80,0x10,"dma page reg");
  94. request_region(0xc0,0x20,"dma2");
  95. }
  96. void __init pSeries_final_fixup(void)
  97. {
  98. pSeries_request_regions();
  99. pci_addr_cache_build();
  100. }
  101. /*
  102. * Assume the winbond 82c105 is the IDE controller on a
  103. * p610. We should probably be more careful in case
  104. * someone tries to plug in a similar adapter.
  105. */
  106. static void fixup_winbond_82c105(struct pci_dev* dev)
  107. {
  108. int i;
  109. unsigned int reg;
  110. if (!platform_is_pseries())
  111. return;
  112. printk("Using INTC for W82c105 IDE controller.\n");
  113. pci_read_config_dword(dev, 0x40, &reg);
  114. /* Enable LEGIRQ to use INTC instead of ISA interrupts */
  115. pci_write_config_dword(dev, 0x40, reg | (1<<11));
  116. for (i = 0; i < DEVICE_COUNT_RESOURCE; ++i) {
  117. /* zap the 2nd function of the winbond chip */
  118. if (dev->resource[i].flags & IORESOURCE_IO
  119. && dev->bus->number == 0 && dev->devfn == 0x81)
  120. dev->resource[i].flags &= ~IORESOURCE_IO;
  121. }
  122. }
  123. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
  124. fixup_winbond_82c105);