pci.h stubs (for EDD build error)
[powerpc.git] / drivers / pnp / quirks.c
index 596a02d..967a8e2 100644 (file)
  *  Copyright (c) 1999 Martin Mares <mj@ucw.cz>
  */
 
-#include <linux/config.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/slab.h>
-
-#ifdef CONFIG_PNP_DEBUG
-       #define DEBUG
-#else
-       #undef DEBUG
-#endif
-
 #include <linux/pnp.h>
+#include <linux/io.h>
 #include "base.h"
 
 
@@ -114,6 +107,64 @@ static void quirk_sb16audio_resources(struct pnp_dev *dev)
        return;
 }
 
+static int quirk_smc_fir_enabled(struct pnp_dev *dev)
+{
+       unsigned long firbase;
+       u8 bank, high, low, chip;
+
+       if (!pnp_port_valid(dev, 1))
+               return 0;
+
+       firbase = pnp_port_start(dev, 1);
+
+       /* Select register bank 3 */
+       bank = inb(firbase + 7);
+       bank &= 0xf0;
+       bank |= 3;
+       outb(bank, firbase + 7);
+
+       high = inb(firbase + 0);
+       low  = inb(firbase + 1);
+       chip = inb(firbase + 2);
+
+       /* This corresponds to the check in smsc_ircc_present() */
+       if (high == 0x10 && low == 0xb8 && (chip == 0xf1 || chip == 0xf2))
+               return 1;
+
+       return 0;
+}
+
+static void quirk_smc_enable(struct pnp_dev *dev)
+{
+       /*
+        * If the BIOS left the device disabled, or it is enabled and
+        * responding correctly, we're in good shape.
+        */
+       if (!dev->active || quirk_smc_fir_enabled(dev))
+               return;
+
+       /*
+        * Sometimes the BIOS claims the device is enabled, but it reports
+        * the wrong FIR resources or doesn't properly configure ISA or LPC
+        * bridges on the way to the device.
+        *
+        * HP nc6000 and nc8000/nw8000 laptops have known problems like
+        * this.  Fortunately, they do fix things up if we auto-configure
+        * the device using its _PRS and _SRS methods.
+        */
+       dev_err(&dev->dev, "%s device not responding, auto-configuring "
+               "resources\n", dev->id->id);
+
+       pnp_disable_dev(dev);
+       pnp_init_resource_table(&dev->res);
+       pnp_auto_config_dev(dev);
+       pnp_activate_dev(dev);
+
+       if (!quirk_smc_fir_enabled(dev))
+               dev_err(&dev->dev, "giving up; try \"smsc-ircc2.nopnp\"\n");
+}
+
+
 /*
  *  PnP Quirks
  *  Cards or devices that need some tweaking due to incomplete resource info
@@ -134,6 +185,7 @@ static struct pnp_fixup pnp_fixups[] = {
        { "CTL0043", quirk_sb16audio_resources },
        { "CTL0044", quirk_sb16audio_resources },
        { "CTL0045", quirk_sb16audio_resources },
+       { "SMCf010", quirk_smc_enable },
        { "" }
 };