blob: f4b66f7ec9fd2153c47c45e87b73e84d9c85c161 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/types.h>
17#include <linux/module.h>
18#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <linux/pci.h>
20#include <linux/ide.h>
21#include <linux/init.h>
22
Bartlomiej Zolnierkiewiczced3ec82008-07-24 22:53:32 +020023#define DRV_NAME "rz1000"
24
Greg Kroah-Hartmanfe31edc2012-12-21 13:21:03 -080025static int rz1000_disable_readahead(struct pci_dev *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070026{
27 u16 reg;
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 if (!pci_read_config_word (dev, 0x40, &reg) &&
30 !pci_write_config_word(dev, 0x40, reg & 0xdfff)) {
31 printk(KERN_INFO "%s: disabled chipset read-ahead "
Bartlomiej Zolnierkiewicz7f1ac8c2008-12-29 20:27:33 +010032 "(buggy RZ1000/RZ1001)\n", pci_name(dev));
33 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 printk(KERN_INFO "%s: serialized, disabled unmasking "
Bartlomiej Zolnierkiewicz7f1ac8c2008-12-29 20:27:33 +010036 "(buggy RZ1000/RZ1001)\n", pci_name(dev));
37 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 }
39}
40
Greg Kroah-Hartmanfe31edc2012-12-21 13:21:03 -080041static const struct ide_port_info rz1000_chipset = {
Bartlomiej Zolnierkiewiczced3ec82008-07-24 22:53:32 +020042 .name = DRV_NAME,
Bartlomiej Zolnierkiewicz5e71d9c2008-04-26 17:36:35 +020043 .host_flags = IDE_HFLAG_NO_DMA,
Linus Torvalds1da177e2005-04-16 15:20:36 -070044};
45
Greg Kroah-Hartmanfe31edc2012-12-21 13:21:03 -080046static int rz1000_init_one(struct pci_dev *dev, const struct pci_device_id *id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070047{
Bartlomiej Zolnierkiewicz7f1ac8c2008-12-29 20:27:33 +010048 struct ide_port_info d = rz1000_chipset;
49 int rc;
50
51 rc = pci_enable_device(dev);
52 if (rc)
53 return rc;
54
55 if (rz1000_disable_readahead(dev)) {
56 d.host_flags |= IDE_HFLAG_SERIALIZE;
57 d.host_flags |= IDE_HFLAG_NO_UNMASK_IRQS;
58 }
59
60 return ide_pci_init_one(dev, &d, NULL);
61}
62
63static void rz1000_remove(struct pci_dev *dev)
64{
65 ide_pci_remove(dev);
66 pci_disable_device(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070067}
68
Bartlomiej Zolnierkiewicz9cbcc5e2007-10-16 22:29:56 +020069static const struct pci_device_id rz1000_pci_tbl[] = {
70 { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1000), 0 },
71 { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1001), 0 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 { 0, },
73};
74MODULE_DEVICE_TABLE(pci, rz1000_pci_tbl);
75
Bartlomiej Zolnierkiewicza9ab09e2008-10-13 21:39:41 +020076static struct pci_driver rz1000_pci_driver = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 .name = "RZ1000_IDE",
78 .id_table = rz1000_pci_tbl,
79 .probe = rz1000_init_one,
Bartlomiej Zolnierkiewicz7f1ac8c2008-12-29 20:27:33 +010080 .remove = rz1000_remove,
Linus Torvalds1da177e2005-04-16 15:20:36 -070081};
82
Bartlomiej Zolnierkiewicz82ab1ee2007-01-27 13:46:56 +010083static int __init rz1000_ide_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070084{
Bartlomiej Zolnierkiewicza9ab09e2008-10-13 21:39:41 +020085 return ide_pci_register_driver(&rz1000_pci_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -070086}
87
Bartlomiej Zolnierkiewicz0fd18802008-07-24 22:53:24 +020088static void __exit rz1000_ide_exit(void)
89{
Bartlomiej Zolnierkiewicza9ab09e2008-10-13 21:39:41 +020090 pci_unregister_driver(&rz1000_pci_driver);
Bartlomiej Zolnierkiewicz0fd18802008-07-24 22:53:24 +020091}
92
Linus Torvalds1da177e2005-04-16 15:20:36 -070093module_init(rz1000_ide_init);
Bartlomiej Zolnierkiewicz0fd18802008-07-24 22:53:24 +020094module_exit(rz1000_ide_exit);
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
96MODULE_AUTHOR("Andre Hedrick");
97MODULE_DESCRIPTION("PCI driver module for RZ1000 IDE");
98MODULE_LICENSE("GPL");
99