pci.c 3.1 KB

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