home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lxapi32.zip / PCI / pci-pc.c < prev    next >
C/C++ Source or Header  |  2002-04-26  |  19KB  |  608 lines

  1. /* $Id: pci-pc.c,v 1.2 2002/04/26 23:09:35 smilcke Exp $ */
  2.  
  3. /*
  4.  * pci-pc.c
  5.  * Autor:               Stefan Milcke
  6.  * Erstellt am:         25.10.2001
  7.  * Letzte Aenderung am: 12.01.2002
  8.  *
  9. */
  10.  
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/poll.h>
  14. #include <asm/uaccess.h>
  15. #include <asm/hardirq.h>
  16. #include <asm/io.h>
  17. #include <linux/pci.h>
  18. #include <linux/list.h>
  19.  
  20. #include "pci-i386.h"
  21.  
  22. #define LINUX
  23. #include <ldefos2.h>
  24. #include <stacktoflat.h>
  25.  
  26. #define PCI_CONFIG_ADDRESS 0xCF8
  27. #define PCI_CONFIG_DATA    0xCFC
  28. #define PCI_CONFIG_ENABLE  0x80000000
  29.  
  30.  
  31. unsigned int pci_probe=PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2;
  32. int pcibios_last_bus=-1;
  33. struct pci_bus *pci_root_bus=NULL;
  34. struct pci_ops *pci_root_ops=NULL;
  35.  
  36. int (*pci_config_read)(int seg,int bus,int dev,int fn,int reg,int len,u32 *value)=NULL;
  37. int (*pci_config_write)(int seg,int bus,int dev,int fn,int reg,int len,u32 value)=NULL;
  38.  
  39. #define PCI_CONF1_ADDRESS(bus, dev, fn, reg) \
  40.     (0x80000000 | (bus << 16) | (dev << 11) | (fn << 8) | (reg & ~3))
  41.  
  42. //------------------------------- pci_conf1_read -------------------------------
  43. static int pci_conf1_read(int seg,int bus,int dev,int fn,int reg,int len,u32 *value)
  44. {
  45.  unsigned long flags;
  46.  if (!value || (bus > 255) || (dev > 31) || (fn > 7) || (reg > 255))
  47.   return -EINVAL;
  48.  outl(PCI_CONF1_ADDRESS(bus, dev, fn, reg), 0xCF8);
  49.  switch (len)
  50.  {
  51.   case 1:
  52.    *value = inb(0xCFC + (reg & 3));
  53.    break;
  54.   case 2:
  55.    *value = inw(0xCFC + (reg & 2));
  56.    break;
  57.   case 4:
  58.    *value = inl(0xCFC);
  59.    break;
  60.  }
  61.  return 0;
  62. }
  63.  
  64. //------------------------------ pci_conf1_write -------------------------------
  65. static int pci_conf1_write(int seg,int bus,int dev,int fn,int reg,int len,u32 value)
  66. {
  67.  unsigned long flags;
  68.  if ((bus > 255) || (dev > 31) || (fn > 7) || (reg > 255))
  69.   return -EINVAL;
  70.  outl(PCI_CONF1_ADDRESS(bus, dev, fn, reg), 0xCF8);
  71.  switch (len)
  72.  {
  73.   case 1:
  74.    outb((u8)value, 0xCFC + (reg & 3));
  75.    break;
  76.   case 2:
  77.    outw((u16)value, 0xCFC + (reg & 2));
  78.     break;
  79.   case 4:
  80.     outl((u32)value, 0xCFC);
  81.     break;
  82.  }
  83.  return 0;
  84. }
  85.  
  86. #undef PCI_CONF1_ADDRESS
  87.  
  88. //------------------------- pci_conf1_read_config_byte -------------------------
  89. static int pci_conf1_read_config_byte(struct pci_dev *dev,int where,u8 *value)
  90. {
  91.  int result;
  92.  u32 data;
  93.  if(!value)
  94.   return -EINVAL;
  95.  result=pci_conf1_read(0,dev->bus->number,PCI_SLOT(dev->devfn),
  96.                        PCI_FUNC(dev->devfn), where, 1, &data);
  97.  *value = (u8)data;
  98.  return result;
  99. }
  100.  
  101. //------------------------- pci_conf1_read_config_word -------------------------
  102. static int pci_conf1_read_config_word(struct pci_dev *dev,int where,u16 *value)
  103. {
  104.  int result;
  105.  u32 data;
  106.  if(!value)
  107.   return -EINVAL;
  108.  result=pci_conf1_read(0,dev->bus->number,PCI_SLOT(dev->devfn),
  109.                        PCI_FUNC(dev->devfn), where, 2, &data);
  110.  *value = (u16)data;
  111.  return result;
  112. }
  113.  
  114. //------------------------ pci_conf1_read_config_dword -------------------------
  115. static int pci_conf1_read_config_dword(struct pci_dev *dev,int where,u32 *value)
  116. {
  117.  if(!value)
  118.   return -EINVAL;
  119.  return pci_conf1_read(0,dev->bus->number,PCI_SLOT(dev->devfn),
  120.                        PCI_FUNC(dev->devfn),where,4,value);
  121. }
  122.  
  123. //------------------------ pci_conf1_write_config_byte -------------------------
  124. static int pci_conf1_write_config_byte(struct pci_dev *dev,int where,u8 value)
  125. {
  126.  return pci_conf1_write(0,dev->bus->number,PCI_SLOT(dev->devfn),
  127.                         PCI_FUNC(dev->devfn),where,1,value);
  128. }
  129.  
  130. //------------------------ pci_conf1_write_config_word -------------------------
  131. static int pci_conf1_write_config_word(struct pci_dev *dev,int where,u16 value)
  132. {
  133.  return pci_conf1_write(0,dev->bus->number,PCI_SLOT(dev->devfn),
  134.                         PCI_FUNC(dev->devfn),where,2,value);
  135. }
  136.  
  137. //------------------------ pci_conf1_write_config_dword ------------------------
  138. static int pci_conf1_write_config_dword(struct pci_dev *dev,int where,u32 value)
  139. {
  140.  return pci_conf1_write(0,dev->bus->number,PCI_SLOT(dev->devfn),
  141.                         PCI_FUNC(dev->devfn), where, 4, value);
  142. }
  143.  
  144. //------------------------- (pci_ops) pci_direct_conf1 -------------------------
  145. static struct pci_ops pci_direct_conf1 = {
  146.     pci_conf1_read_config_byte,
  147.     pci_conf1_read_config_word,
  148.     pci_conf1_read_config_dword,
  149.     pci_conf1_write_config_byte,
  150.     pci_conf1_write_config_word,
  151.     pci_conf1_write_config_dword
  152. };
  153.  
  154.  
  155. /*
  156.  * Functions for accessing PCI configuration space with type 2 accesses
  157.  */
  158.  
  159. #define PCI_CONF2_ADDRESS(dev, reg)    (u16)(0xC000 | (dev << 8) | reg)
  160.  
  161. //------------------------------- pci_conf2_read -------------------------------
  162. static int pci_conf2_read(int seg,int bus,int dev,int fn,int reg,int len,u32 *value)
  163. {
  164.  unsigned long flags;
  165.  if(!value || (bus > 255) || (dev > 31) || (fn > 7) || (reg > 255))
  166.   return -EINVAL;
  167.  if(dev & 0x10)
  168.   return PCIBIOS_DEVICE_NOT_FOUND;
  169.  outb((u8)(0xF0 | (fn << 1)), 0xCF8);
  170.  outb((u8)bus, 0xCFA);
  171.  switch (len)
  172.  {
  173.   case 1:
  174.    *value = inb(PCI_CONF2_ADDRESS(dev, reg));
  175.    break;
  176.   case 2:
  177.    *value = inw(PCI_CONF2_ADDRESS(dev, reg));
  178.    break;
  179.   case 4:
  180.    *value = inl(PCI_CONF2_ADDRESS(dev, reg));
  181.    break;
  182.  }
  183.  outb (0, 0xCF8);
  184.  return 0;
  185. }
  186.  
  187. //------------------------------ pci_conf2_write -------------------------------
  188. static int pci_conf2_write (int seg,int bus,int dev,int fn,int reg,int len,u32 value)
  189. {
  190.  unsigned long flags;
  191.  if((bus > 255) || (dev > 31) || (fn > 7) || (reg > 255))
  192.   return -EINVAL;
  193.  if(dev & 0x10)
  194.   return PCIBIOS_DEVICE_NOT_FOUND;
  195.  outb((u8)(0xF0 | (fn << 1)), 0xCF8);
  196.  outb((u8)bus, 0xCFA);
  197.  switch (len)
  198.  {
  199.   case 1:
  200.    outb ((u8)value, PCI_CONF2_ADDRESS(dev, reg));
  201.    break;
  202.   case 2:
  203.    outw ((u16)value, PCI_CONF2_ADDRESS(dev, reg));
  204.    break;
  205.   case 4:
  206.    outl ((u32)value, PCI_CONF2_ADDRESS(dev, reg));
  207.    break;
  208.  }
  209.  outb (0, 0xCF8);
  210.  return 0;
  211. }
  212.  
  213. #undef PCI_CONF2_ADDRESS
  214.  
  215. //------------------------- pci_conf2_read_config_byte -------------------------
  216. static int pci_conf2_read_config_byte(struct pci_dev *dev,int where,u8 *value)
  217. {
  218.  int result;
  219.  u32 data;
  220.  result=pci_conf2_read(0,dev->bus->number,PCI_SLOT(dev->devfn),
  221.                        PCI_FUNC(dev->devfn),where,1,&data);
  222.  *value = (u8)data;
  223.  return result;
  224. }
  225.  
  226. //------------------------- pci_conf2_read_config_word -------------------------
  227. static int pci_conf2_read_config_word(struct pci_dev *dev,int where, u16 *value)
  228. {
  229.  int result;
  230.  u32 data;
  231.  result=pci_conf2_read(0, dev->bus->number, PCI_SLOT(dev->devfn),
  232.                        PCI_FUNC(dev->devfn),where,2,&data);
  233.  *value = (u16)data;
  234.  return result;
  235. }
  236.  
  237. //------------------------ pci_conf2_read_config_dword -------------------------
  238. static int pci_conf2_read_config_dword(struct pci_dev *dev,int where,u32 *value)
  239. {
  240.  return pci_conf2_read(0,dev->bus->number,PCI_SLOT(dev->devfn),
  241.                        PCI_FUNC(dev->devfn),where,4,value);
  242. }
  243.  
  244. //------------------------ pci_conf2_write_config_byte -------------------------
  245. static int pci_conf2_write_config_byte(struct pci_dev *dev,int where,u8 value)
  246. {
  247.  return pci_conf2_write(0,dev->bus->number,PCI_SLOT(dev->devfn),
  248.                         PCI_FUNC(dev->devfn),where,1,value);
  249. }
  250.  
  251. //------------------------ pci_conf2_write_config_word -------------------------
  252. static int pci_conf2_write_config_word(struct pci_dev *dev,int where,u16 value)
  253. {
  254.  return pci_conf2_write(0,dev->bus->number,PCI_SLOT(dev->devfn),
  255.                         PCI_FUNC(dev->devfn),where,2,value);
  256. }
  257.  
  258. //------------------------ pci_conf2_write_config_dword ------------------------
  259. static int pci_conf2_write_config_dword(struct pci_dev *dev,int where,u32 value)
  260. {
  261.  return pci_conf2_write(0,dev->bus->number,PCI_SLOT(dev->devfn),
  262.                         PCI_FUNC(dev->devfn),where,4,value);
  263. }
  264.  
  265. //------------------------- (pci_ops) pci_direct_conf2 -------------------------
  266. static struct pci_ops pci_direct_conf2 = {
  267.     pci_conf2_read_config_byte,
  268.     pci_conf2_read_config_word,
  269.     pci_conf2_read_config_dword,
  270.     pci_conf2_write_config_byte,
  271.     pci_conf2_write_config_word,
  272.     pci_conf2_write_config_dword
  273. };
  274.  
  275. /*
  276.  * Before we decide to use direct hardware access mechanisms, we try to do some
  277.  * trivial checks to ensure it at least _seems_ to be working -- we just test
  278.  * whether bus 00 contains a host bridge (this is similar to checking
  279.  * techniques used in XFree86, but ours should be more reliable since we
  280.  * attempt to make use of direct access hints provided by the PCI BIOS).
  281.  *
  282.  * This should be close to trivial, but it isn't, because there are buggy
  283.  * chipsets (yes, you guessed it, by Intel and Compaq) that have no class ID.
  284.  */
  285. //------------------------------ pci_sanity_check ------------------------------
  286. static int __init pci_sanity_check(struct pci_ops *o)
  287. {
  288.  u16 x;
  289.  struct pci_bus bus;        /* Fake bus and device */
  290.  struct pci_dev dev;
  291.  if(pci_probe & PCI_NO_CHECKS)
  292.   return 1;
  293.  bus.number = 0;
  294.  dev.bus = &bus;
  295.  for(dev.devfn=0;dev.devfn<0x100;dev.devfn++)
  296.   if((!o->read_word(&dev, PCI_CLASS_DEVICE, &x) &&
  297.      (x == PCI_CLASS_BRIDGE_HOST || x == PCI_CLASS_DISPLAY_VGA)) ||
  298.      (!o->read_word(&dev, PCI_VENDOR_ID, &x) &&
  299.      (x == PCI_VENDOR_ID_INTEL || x == PCI_VENDOR_ID_COMPAQ)))
  300.    return 1;
  301.  return 0;
  302. }
  303.  
  304. //------------------------------ pci_check_direct ------------------------------
  305. static struct pci_ops *pci_check_direct(void)
  306. {
  307.  unsigned int tmp;
  308.  unsigned long flags;
  309.  if(pci_probe & PCI_PROBE_CONF1)
  310.  {
  311.   outb(0x01,0xCFB);
  312.   tmp=inl(0xCF8);
  313.   outl(0x80000000,0xCF8);
  314.   if(inl(0xCF8)==0x80000000 && pci_sanity_check(&pci_direct_conf1))
  315.   {
  316.    outl(tmp,0xCF8);
  317.    return &pci_direct_conf1;
  318.   }
  319.   outl(tmp,0xCF8);
  320.  }
  321.  if(pci_probe&PCI_PROBE_CONF2)
  322.  {
  323.   outb(0x00,0xCFB);
  324.   outb(0x00,0xCF8);
  325.   outb(0x00,0xCFA);
  326.   if(inb(0xCF8)==0x00 && inb(0xCFA)==00 && pci_sanity_check(&pci_direct_conf2))
  327.   {
  328.    return &pci_direct_conf2;
  329.   }
  330.  }
  331.  return NULL;
  332. }
  333.  
  334. //---------------------------- pcibios_fixup_ghosts ----------------------------
  335. static void __init pcibios_fixup_ghosts(struct pci_bus *b)
  336. {
  337.  struct list_head *ln,*mn;
  338.  struct pci_dev *d,*e;
  339.  int mirror=PCI_DEVFN(16,0);
  340.  int seen_host_bridge=0;
  341.  int i;
  342.  // DBG("PCI: Scanning for ghost devices on bus %d\n",b->number);
  343.  for(ln=b->devices.next;ln!=&b->devices;ln=ln->next)
  344.  {
  345.   d=pci_dev_b(ln);
  346.   if((d->pciclass>>8)==PCI_CLASS_BRIDGE_HOST)
  347.    seen_host_bridge++;
  348.   for(mn=ln->next;mn!=&b->devices;mn=mn->next)
  349.   {
  350.    e=pci_dev_b(mn);
  351.    if(e->devfn!=d->devfn+mirror ||
  352.       e->vendor!=d->vendor ||
  353.       e->device!=d->device ||
  354.       e->pciclass !=d->pciclass)
  355.     continue;
  356.    for(i=0;i<PCI_NUM_RESOURCES;i++)
  357.     if(e->resource[i].start!=d->resource[i].start ||
  358.        e->resource[i].end!=d->resource[i].end ||
  359.        e->resource[i].flags!=d->resource[i].flags)
  360.      continue;
  361.    break;
  362.   }
  363.   if(mn==&b->devices)
  364.    return;
  365.  }
  366.  if(!seen_host_bridge)
  367.   return;
  368.  CPK(printk("PCI: Ignoring ghost devices on bus %02x\n",b->number));
  369.  ln=&b->devices;
  370.  while(ln->next!=&b->devices)
  371.  {
  372.   d=pci_dev_b(ln->next);
  373.   if(d->devfn>=mirror)
  374.   {
  375.    list_del(&d->global_list);
  376.    list_del(&d->bus_list);
  377.    kfree(d);
  378.   }
  379.   else
  380.    ln=ln->next;
  381.  }
  382. }
  383.  
  384. //------------------------- pcibios_fixup_peer_bridges -------------------------
  385. static void __init pcibios_fixup_peer_bridges(void)
  386. {
  387.  int n;
  388.  struct pci_bus bus;
  389.  struct pci_dev dev;
  390.  u16 l;
  391.  if(pcibios_last_bus<=0 || pcibios_last_bus >= 0xff)
  392.   return;
  393. // DBG("PCI: Peer bridge fixup\n");
  394.  for(n=0;n<=pcibios_last_bus;n++)
  395.  {
  396.   if(pci_bus_exists(&pci_root_buses,n))
  397.    continue;
  398.   bus.number=n;
  399.   bus.ops=pci_root_ops;
  400.   dev.bus=&bus;
  401.   for(dev.devfn=0;dev.devfn<256;dev.devfn+=8)
  402.    if(!pci_read_config_word(&dev,PCI_VENDOR_ID,&l) &&
  403.        l!=0x000 && l!=0xffff)
  404.    {
  405. //    DBG("Found device at %02x:%02x [%04x]\n",n,dev.devfn,l);
  406.     CPK(printk("PCI: Discovered peer bus %02x\n",n));
  407.     pci_scan_bus(n,pci_root_ops,NULL);
  408.     break;
  409.    }
  410.  }
  411. }
  412.  
  413. //------------------------------ pci_fixup_i450nx ------------------------------
  414. static void __init pci_fixup_i450nx(struct pci_dev *d)
  415. {
  416.  // i450NX -- Find and scan all secondary buses on all PXB's.
  417.  int pxb, reg;
  418.  u8 busno, suba, subb;
  419.  CPK(printk("PCI: Searching for i450NX host bridges on %s\n", d->slot_name));
  420.  reg = 0xd0;
  421.  for(pxb=0; pxb<2; pxb++)
  422.  {
  423.   pci_read_config_byte(d, reg++, &busno);
  424.   pci_read_config_byte(d, reg++, &suba);
  425.   pci_read_config_byte(d, reg++, &subb);
  426. //  DBG("i450NX PXB %d: %02x/%02x/%02x\n", pxb, busno, suba, subb);
  427.   if(busno)
  428.    pci_scan_bus(busno, pci_root_ops, NULL);    /* Bus A */
  429.   if (suba < subb)
  430.    pci_scan_bus(suba+1, pci_root_ops, NULL);    /* Bus B */
  431.  }
  432.  pcibios_last_bus = -1;
  433. }
  434.  
  435. //------------------------------ pci_fixup_i450gx ------------------------------
  436. static void __init pci_fixup_i450gx(struct pci_dev *d)
  437. {
  438.  // i450GX and i450KX -- Find and scan all secondary buses.
  439.  // (called separately for each PCI bridge found)
  440.  u8 busno;
  441.  pci_read_config_byte(d, 0x4a, &busno);
  442.  CPK(printk("PCI: i440KX/GX host bridge %s: secondary bus %02x\n",
  443.             d->slot_name, busno));
  444.  pci_scan_bus(busno, pci_root_ops, NULL);
  445.  pcibios_last_bus = -1;
  446. }
  447.  
  448. //----------------------------- pci_fixup_umc_ide ------------------------------
  449. static void __init pci_fixup_umc_ide(struct pci_dev *d)
  450. {
  451.  // UM8886BF IDE controller sets region type bits incorrectly,
  452.  //therefore they look like memory despite of them being I/O.
  453.  int i;
  454.  CPK(printk("PCI: Fixing base address flags for device %s\n", d->slot_name));
  455.  for(i=0; i<4; i++)
  456.   d->resource[i].flags |= PCI_BASE_ADDRESS_SPACE_IO;
  457. }
  458.  
  459. //---------------------------- pci_fixup_ide_bases -----------------------------
  460. static void __init pci_fixup_ide_bases(struct pci_dev *d)
  461. {
  462.  // PCI IDE controllers use non-standard I/O port decoding, respect it.
  463.  int i;
  464.  if ((d->pciclass >> 8) != PCI_CLASS_STORAGE_IDE)
  465.   return;
  466. // DBG("PCI: IDE base address fixup for %s\n", d->slot_name);
  467.  for(i=0; i<4; i++)
  468.  {
  469.   struct resource *r = &d->resource[i];
  470.   if ((r->start & ~0x80) == 0x374)
  471.   {
  472.    r->start |= 2;
  473.    r->end = r->start;
  474.   }
  475.  }
  476. }
  477.  
  478. //---------------------------- pci_fixup_ide_trash -----------------------------
  479. static void __init pci_fixup_ide_trash(struct pci_dev *d)
  480. {
  481.  // There exist PCI IDE controllers which have utter garbage
  482.  // in first four base registers. Ignore that.
  483.  int i;
  484. // DBG("PCI: IDE base address trash cleared for %s\n", d->slot_name);
  485.  for(i=0; i<4; i++)
  486.   d->resource[i].start = d->resource[i].end = d->resource[i].flags = 0;
  487. }
  488.  
  489. //----------------------------- pci_fixup_latency ------------------------------
  490. static void __init pci_fixup_latency(struct pci_dev *d)
  491. {
  492.  // SiS 5597 and 5598 chipsets require latency timer set to
  493.  // at most 32 to avoid lockups.
  494. // DBG("PCI: Setting max latency to 32\n");
  495.  pcibios_max_latency = 32;
  496. }
  497.  
  498. //---------------------------- pci_fixup_piix4_acpi ----------------------------
  499. static void __init pci_fixup_piix4_acpi(struct pci_dev *d)
  500. {
  501.  // PIIX4 ACPI device: hardwired IRQ9
  502.  d->irq = 9;
  503. }
  504.  
  505. /*
  506.  * Nobody seems to know what this does. Damn.
  507.  *
  508.  * But it does seem to fix some unspecified problem
  509.  * with 'movntq' copies on Athlons.
  510.  *
  511.  * VIA 8363 chipset:
  512.  *  - bit 7 at offset 0x55: Debug (RW)
  513.  */
  514. //-------------------------- pci_fixup_via_athlon_bug --------------------------
  515. static void __init pci_fixup_via_athlon_bug(struct pci_dev *d)
  516. {
  517.  u8 v;
  518.  pci_read_config_byte(d, 0x55, &v);
  519.  if (v & 0x80)
  520.  {
  521.   CPK(printk("Trying to stomp on Athlon bug...\n"));
  522.   v &= 0x7f; /* clear bit 55.7 */
  523.   pci_write_config_byte(d, 0x55, v);
  524.  }
  525. }
  526.  
  527. struct pci_fixup pcibios_fixups[] = {
  528.     { PCI_FIXUP_HEADER,    PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_82451NX,    pci_fixup_i450nx },
  529.     { PCI_FIXUP_HEADER,    PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_82454GX,    pci_fixup_i450gx },
  530. #if 0
  531. /* Until we get proper handling pray the BIOS gets it right */
  532.     { PCI_FIXUP_HEADER,    PCI_VENDOR_ID_SERVERWORKS,    PCI_DEVICE_ID_SERVERWORKS_HE,        pci_fixup_serverworks },
  533.     { PCI_FIXUP_HEADER,    PCI_VENDOR_ID_SERVERWORKS,    PCI_DEVICE_ID_SERVERWORKS_LE,        pci_fixup_serverworks },
  534.     { PCI_FIXUP_HEADER,    PCI_VENDOR_ID_SERVERWORKS,    PCI_DEVICE_ID_SERVERWORKS_CMIC_HE,    pci_fixup_serverworks },
  535. #endif    
  536. #if 0
  537. /* Our bus code shouldnt need this fixup any more. Delete once verified */
  538.     { PCI_FIXUP_HEADER,    PCI_VENDOR_ID_COMPAQ,    PCI_DEVICE_ID_COMPAQ_6010,    pci_fixup_compaq },
  539. #endif    
  540.     { PCI_FIXUP_HEADER,    PCI_VENDOR_ID_UMC,    PCI_DEVICE_ID_UMC_UM8886BF,    pci_fixup_umc_ide },
  541.     { PCI_FIXUP_HEADER,    PCI_VENDOR_ID_SI,    PCI_DEVICE_ID_SI_5513,        pci_fixup_ide_trash },
  542.     { PCI_FIXUP_HEADER,    PCI_ANY_ID,        PCI_ANY_ID,            pci_fixup_ide_bases },
  543.     { PCI_FIXUP_HEADER,    PCI_VENDOR_ID_SI,    PCI_DEVICE_ID_SI_5597,        pci_fixup_latency },
  544.     { PCI_FIXUP_HEADER,    PCI_VENDOR_ID_SI,    PCI_DEVICE_ID_SI_5598,        pci_fixup_latency },
  545.      { PCI_FIXUP_HEADER,    PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_82371AB_3,    pci_fixup_piix4_acpi },
  546.     { PCI_FIXUP_HEADER,    PCI_VENDOR_ID_VIA,    PCI_DEVICE_ID_VIA_8363_0,    pci_fixup_via_athlon_bug },
  547.     { 0 }
  548. };
  549.  
  550. //----------------------------- pcibios_fixup_bus ------------------------------
  551. void __init pcibios_fixup_bus(struct pci_bus *b)
  552. {
  553.  pcibios_fixup_ghosts(b);
  554.  pci_read_bridge_bases(b);
  555. }
  556.  
  557. //---------------------------- pcibios_config_init -----------------------------
  558. void pcibios_config_init(void)
  559. {
  560.  if((pci_probe & (PCI_PROBE_CONF1 | PCI_PROBE_CONF2))
  561.     &&(pci_root_ops=pci_check_direct()))
  562.  {
  563.   if(pci_root_ops=&pci_direct_conf1)
  564.   {
  565.    pci_config_read=pci_conf1_read;
  566.    pci_config_write=pci_conf1_write;
  567.   }
  568.   else
  569.   {
  570.    pci_config_read=pci_conf1_read;
  571.    pci_config_write=pci_conf1_write;
  572.   }
  573.  }
  574. }
  575.  
  576. //-------------------------------- pcibios_init --------------------------------
  577. void pcibios_init(void)
  578. {
  579.  if(!pci_root_ops)
  580.   pcibios_config_init();
  581.  if(!pci_root_ops)
  582.   return;
  583.  pci_root_bus=pci_scan_bus(0,pci_root_ops,NULL);
  584.  pcibios_irq_init();
  585.  pcibios_fixup_peer_bridges();
  586.  pcibios_resource_survey();
  587.  // Incomplete (SM)
  588.  /*
  589.  if((pci_probe&PCI_BIOS_SORT) && !(pci_probe&PCI_NO_SORT))
  590.   pcibios_sort();
  591.  */
  592. }
  593.  
  594. //-------------------------- pcibios_assign_all_buses --------------------------
  595. unsigned int pcibios_assign_all_busses(void)
  596. {
  597.  return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0;
  598. }
  599.  
  600. //--------------------------- pcibios_enable_device ----------------------------
  601. int pcibios_enable_device(struct pci_dev *dev)
  602. {
  603.  int err;
  604.  if((err=pcibios_enable_resources(dev))<0)
  605.   return err;
  606.  pcibios_enable_irq(dev);
  607.  return 0;
  608. }