Merge commit 'upstream/master'
[pandora-kernel.git] / drivers / ide / pci / rz1000.c
1 /*
2  *  Copyright (C) 1995-1998  Linus Torvalds & author (see below)
3  */
4
5 /*
6  *  Principal Author:  mlord@pobox.com (Mark Lord)
7  *
8  *  See linux/MAINTAINERS for address of current maintainer.
9  *
10  *  This file provides support for disabling the buggy read-ahead
11  *  mode of the RZ1000 IDE chipset, commonly used on Intel motherboards.
12  *
13  *  Dunno if this fixes both ports, or only the primary port (?).
14  */
15
16 #include <linux/types.h>
17 #include <linux/module.h>
18 #include <linux/kernel.h>
19 #include <linux/hdreg.h>
20 #include <linux/pci.h>
21 #include <linux/ide.h>
22 #include <linux/init.h>
23
24 #define DRV_NAME "rz1000"
25
26 static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif)
27 {
28         struct pci_dev *dev = to_pci_dev(hwif->dev);
29         u16 reg;
30
31         if (!pci_read_config_word (dev, 0x40, &reg) &&
32             !pci_write_config_word(dev, 0x40, reg & 0xdfff)) {
33                 printk(KERN_INFO "%s: disabled chipset read-ahead "
34                         "(buggy RZ1000/RZ1001)\n", hwif->name);
35         } else {
36                 if (hwif->mate)
37                         hwif->mate->serialized = hwif->serialized = 1;
38                 hwif->host_flags |= IDE_HFLAG_NO_UNMASK_IRQS;
39                 printk(KERN_INFO "%s: serialized, disabled unmasking "
40                         "(buggy RZ1000/RZ1001)\n", hwif->name);
41         }
42 }
43
44 static const struct ide_port_info rz1000_chipset __devinitdata = {
45         .name           = DRV_NAME,
46         .init_hwif      = init_hwif_rz1000,
47         .chipset        = ide_rz1000,
48         .host_flags     = IDE_HFLAG_NO_DMA,
49 };
50
51 static int __devinit rz1000_init_one(struct pci_dev *dev, const struct pci_device_id *id)
52 {
53         return ide_pci_init_one(dev, &rz1000_chipset, NULL);
54 }
55
56 static const struct pci_device_id rz1000_pci_tbl[] = {
57         { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1000), 0 },
58         { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1001), 0 },
59         { 0, },
60 };
61 MODULE_DEVICE_TABLE(pci, rz1000_pci_tbl);
62
63 static struct pci_driver driver = {
64         .name           = "RZ1000_IDE",
65         .id_table       = rz1000_pci_tbl,
66         .probe          = rz1000_init_one,
67         .remove         = ide_pci_remove,
68 };
69
70 static int __init rz1000_ide_init(void)
71 {
72         return ide_pci_register_driver(&driver);
73 }
74
75 static void __exit rz1000_ide_exit(void)
76 {
77         pci_unregister_driver(&driver);
78 }
79
80 module_init(rz1000_ide_init);
81 module_exit(rz1000_ide_exit);
82
83 MODULE_AUTHOR("Andre Hedrick");
84 MODULE_DESCRIPTION("PCI driver module for RZ1000 IDE");
85 MODULE_LICENSE("GPL");
86