blob: fce2b7de5a19ac2f550084e2cae9b3e7bb190de7 [file] [log] [blame]
Thomas Gleixner09c434b2019-05-19 13:08:20 +01001// SPDX-License-Identifier: GPL-2.0-only
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * Copyright (C) 1995-1998 Linus Torvalds & author (see below)
4 */
5
6/*
7 * Principal Author: mlord@pobox.com (Mark Lord)
8 *
9 * See linux/MAINTAINERS for address of current maintainer.
10 *
11 * This file provides support for disabling the buggy read-ahead
12 * mode of the RZ1000 IDE chipset, commonly used on Intel motherboards.
13 *
14 * Dunno if this fixes both ports, or only the primary port (?).
15 */
16
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/types.h>
18#include <linux/module.h>
19#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <linux/pci.h>
21#include <linux/ide.h>
22#include <linux/init.h>
23
Bartlomiej Zolnierkiewiczced3ec82008-07-24 22:53:32 +020024#define DRV_NAME "rz1000"
25
Greg Kroah-Hartmanfe31edc2012-12-21 13:21:03 -080026static int rz1000_disable_readahead(struct pci_dev *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070027{
28 u16 reg;
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 if (!pci_read_config_word (dev, 0x40, &reg) &&
31 !pci_write_config_word(dev, 0x40, reg & 0xdfff)) {
32 printk(KERN_INFO "%s: disabled chipset read-ahead "
Bartlomiej Zolnierkiewicz7f1ac8c2008-12-29 20:27:33 +010033 "(buggy RZ1000/RZ1001)\n", pci_name(dev));
34 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 printk(KERN_INFO "%s: serialized, disabled unmasking "
Bartlomiej Zolnierkiewicz7f1ac8c2008-12-29 20:27:33 +010037 "(buggy RZ1000/RZ1001)\n", pci_name(dev));
38 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 }
40}
41
Greg Kroah-Hartmanfe31edc2012-12-21 13:21:03 -080042static const struct ide_port_info rz1000_chipset = {
Bartlomiej Zolnierkiewiczced3ec82008-07-24 22:53:32 +020043 .name = DRV_NAME,
Bartlomiej Zolnierkiewicz5e71d9c2008-04-26 17:36:35 +020044 .host_flags = IDE_HFLAG_NO_DMA,
Linus Torvalds1da177e2005-04-16 15:20:36 -070045};
46
Greg Kroah-Hartmanfe31edc2012-12-21 13:21:03 -080047static int rz1000_init_one(struct pci_dev *dev, const struct pci_device_id *id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070048{
Bartlomiej Zolnierkiewicz7f1ac8c2008-12-29 20:27:33 +010049 struct ide_port_info d = rz1000_chipset;
50 int rc;
51
52 rc = pci_enable_device(dev);
53 if (rc)
54 return rc;
55
56 if (rz1000_disable_readahead(dev)) {
57 d.host_flags |= IDE_HFLAG_SERIALIZE;
58 d.host_flags |= IDE_HFLAG_NO_UNMASK_IRQS;
59 }
60
61 return ide_pci_init_one(dev, &d, NULL);
62}
63
64static void rz1000_remove(struct pci_dev *dev)
65{
66 ide_pci_remove(dev);
67 pci_disable_device(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070068}
69
Bartlomiej Zolnierkiewicz9cbcc5e2007-10-16 22:29:56 +020070static const struct pci_device_id rz1000_pci_tbl[] = {
71 { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1000), 0 },
72 { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1001), 0 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 { 0, },
74};
75MODULE_DEVICE_TABLE(pci, rz1000_pci_tbl);
76
Bartlomiej Zolnierkiewicza9ab09e22008-10-13 21:39:41 +020077static struct pci_driver rz1000_pci_driver = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 .name = "RZ1000_IDE",
79 .id_table = rz1000_pci_tbl,
80 .probe = rz1000_init_one,
Bartlomiej Zolnierkiewicz7f1ac8c2008-12-29 20:27:33 +010081 .remove = rz1000_remove,
Linus Torvalds1da177e2005-04-16 15:20:36 -070082};
83
Bartlomiej Zolnierkiewicz82ab1ee2007-01-27 13:46:56 +010084static int __init rz1000_ide_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070085{
Bartlomiej Zolnierkiewicza9ab09e22008-10-13 21:39:41 +020086 return ide_pci_register_driver(&rz1000_pci_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -070087}
88
Bartlomiej Zolnierkiewicz0fd18802008-07-24 22:53:24 +020089static void __exit rz1000_ide_exit(void)
90{
Bartlomiej Zolnierkiewicza9ab09e22008-10-13 21:39:41 +020091 pci_unregister_driver(&rz1000_pci_driver);
Bartlomiej Zolnierkiewicz0fd18802008-07-24 22:53:24 +020092}
93
Linus Torvalds1da177e2005-04-16 15:20:36 -070094module_init(rz1000_ide_init);
Bartlomiej Zolnierkiewicz0fd18802008-07-24 22:53:24 +020095module_exit(rz1000_ide_exit);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
97MODULE_AUTHOR("Andre Hedrick");
98MODULE_DESCRIPTION("PCI driver module for RZ1000 IDE");
99MODULE_LICENSE("GPL");
100