agp: use dev_printk when possible
[safe/jmp/linux-2.6] / drivers / char / agp / sis-agp.c
index 60342b7..52c2db6 100644 (file)
@@ -14,6 +14,9 @@
 #define SIS_TLBCNTRL   0x97
 #define SIS_TLBFLUSH   0x98
 
+#define PCI_DEVICE_ID_SI_662   0x0662
+#define PCI_DEVICE_ID_SI_671   0x0671
+
 static int __devinitdata agp_sis_force_delay = 0;
 static int __devinitdata agp_sis_agp_spec = -1;
 
@@ -27,8 +30,8 @@ static int sis_fetch_size(void)
        values = A_SIZE_8(agp_bridge->driver->aperture_sizes);
        for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) {
                if ((temp_size == values[i].size_value) ||
-                   ((temp_size & ~(0x03)) ==
-                    (values[i].size_value & ~(0x03)))) {
+                   ((temp_size & ~(0x07)) ==
+                    (values[i].size_value & ~(0x07)))) {
                        agp_bridge->previous_size =
                            agp_bridge->current_size = (void *) (values + i);
 
@@ -76,10 +79,8 @@ static void sis_delayed_enable(struct agp_bridge_data *bridge, u32 mode)
        u32 command;
        int rate;
 
-       printk(KERN_INFO PFX "Found an AGP %d.%d compliant device at %s.\n",
-               agp_bridge->major_version,
-               agp_bridge->minor_version,
-               pci_name(agp_bridge->dev));
+       dev_info(&agp_bridge->dev->dev, "AGP %d.%d bridge\n",
+                agp_bridge->major_version, agp_bridge->minor_version);
 
        pci_read_config_dword(agp_bridge->dev, agp_bridge->capndx + PCI_AGP_STATUS, &command);
        command = agp_collect_device_status(bridge, mode, command);
@@ -91,8 +92,8 @@ static void sis_delayed_enable(struct agp_bridge_data *bridge, u32 mode)
                if (!agp)
                        continue;
 
-               printk(KERN_INFO PFX "Putting AGP V3 device at %s into %dx mode\n",
-                       pci_name(device), rate);
+               dev_info(&agp_bridge->dev->dev, "putting AGP V3 device at %s into %dx mode\n",
+                        pci_name(device), rate);
 
                pci_write_config_dword(device, agp + PCI_AGP_COMMAND, command);
 
@@ -102,13 +103,13 @@ static void sis_delayed_enable(struct agp_bridge_data *bridge, u32 mode)
                 * cannot be configured
                 */
                if (device->device == bridge->dev->device) {
-                       printk(KERN_INFO PFX "SiS delay workaround: giving bridge time to recover.\n");
+                       dev_info(&agp_bridge->dev->dev, "SiS delay workaround: giving bridge time to recover\n");
                        msleep(10);
                }
        }
 }
 
-static struct aper_size_info_8 sis_generic_sizes[7] =
+static const struct aper_size_info_8 sis_generic_sizes[7] =
 {
        {256, 65536, 6, 99},
        {128, 32768, 5, 83},
@@ -143,96 +144,6 @@ static struct agp_bridge_driver sis_driver = {
        .agp_type_to_mask_type  = agp_generic_type_to_mask_type,
 };
 
-static struct agp_device_ids sis_agp_device_ids[] __devinitdata =
-{
-       {
-               .device_id      = PCI_DEVICE_ID_SI_5591_AGP,
-               .chipset_name   = "5591",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_530,
-               .chipset_name   = "530",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_540,
-               .chipset_name   = "540",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_550,
-               .chipset_name   = "550",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_620,
-               .chipset_name   = "620",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_630,
-               .chipset_name   = "630",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_635,
-               .chipset_name   = "635",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_645,
-               .chipset_name   = "645",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_646,
-               .chipset_name   = "646",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_648,
-               .chipset_name   = "648",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_650,
-               .chipset_name   = "650",
-       },
-       {
-               .device_id  = PCI_DEVICE_ID_SI_651,
-               .chipset_name   = "651",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_655,
-               .chipset_name   = "655",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_661,
-               .chipset_name   = "661",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_730,
-               .chipset_name   = "730",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_735,
-               .chipset_name   = "735",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_740,
-               .chipset_name   = "740",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_741,
-               .chipset_name   = "741",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_745,
-               .chipset_name   = "745",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_746,
-               .chipset_name   = "746",
-       },
-       {
-               .device_id      = PCI_DEVICE_ID_SI_760,
-               .chipset_name   = "760",
-       },
-       { }, /* dummy final entry, always present */
-};
-
-
 // chipsets that require the 'delay hack'
 static int sis_broken_chipsets[] __devinitdata = {
        PCI_DEVICE_ID_SI_648,
@@ -269,29 +180,16 @@ static void __devinit sis_get_driver(struct agp_bridge_data *bridge)
 static int __devinit agp_sis_probe(struct pci_dev *pdev,
                                   const struct pci_device_id *ent)
 {
-       struct agp_device_ids *devs = sis_agp_device_ids;
        struct agp_bridge_data *bridge;
        u8 cap_ptr;
-       int j;
 
        cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
        if (!cap_ptr)
                return -ENODEV;
 
-       /* probe for known chipsets */
-       for (j = 0; devs[j].chipset_name; j++) {
-               if (pdev->device == devs[j].device_id) {
-                       printk(KERN_INFO PFX "Detected SiS %s chipset\n",
-                                       devs[j].chipset_name);
-                       goto found;
-               }
-       }
-
-       printk(KERN_ERR PFX "Unsupported SiS chipset (device id: %04x)\n",
-                   pdev->device);
-       return -ENODEV;
 
-found:
+       dev_info(&pdev->dev, "SiS chipset [%04x/%04x]\n",
+                pdev->vendor, pdev->device);
        bridge = agp_alloc_bridge();
        if (!bridge)
                return -ENOMEM;
@@ -318,14 +216,210 @@ static void __devexit agp_sis_remove(struct pci_dev *pdev)
        agp_put_bridge(bridge);
 }
 
+#ifdef CONFIG_PM
+
+static int agp_sis_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+       pci_save_state(pdev);
+       pci_set_power_state(pdev, pci_choose_state(pdev, state));
+
+       return 0;
+}
+
+static int agp_sis_resume(struct pci_dev *pdev)
+{
+       pci_set_power_state(pdev, PCI_D0);
+       pci_restore_state(pdev);
+
+       return sis_driver.configure();
+}
+
+#endif /* CONFIG_PM */
+
 static struct pci_device_id agp_sis_pci_table[] = {
        {
-       .class          = (PCI_CLASS_BRIDGE_HOST << 8),
-       .class_mask     = ~0,
-       .vendor         = PCI_VENDOR_ID_SI,
-       .device         = PCI_ANY_ID,
-       .subvendor      = PCI_ANY_ID,
-       .subdevice      = PCI_ANY_ID,
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_5591_AGP,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_530,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_540,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_550,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_620,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_630,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_635,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_645,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_646,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_648,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_650,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_651,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_655,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_661,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_662,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_671,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_730,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_735,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_740,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_741,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_745,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_746,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+       },
+       {
+               .class          = (PCI_CLASS_BRIDGE_HOST << 8),
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_SI,
+               .device         = PCI_DEVICE_ID_SI_760,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
        },
        { }
 };
@@ -337,6 +431,10 @@ static struct pci_driver agp_sis_pci_driver = {
        .id_table       = agp_sis_pci_table,
        .probe          = agp_sis_probe,
        .remove         = agp_sis_remove,
+#ifdef CONFIG_PM
+       .suspend        = agp_sis_suspend,
+       .resume         = agp_sis_resume,
+#endif
 };
 
 static int __init agp_sis_init(void)