Loading...
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * 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
17#include <linux/types.h>
18#include <linux/module.h>
19#include <linux/kernel.h>
20#include <linux/pci.h>
21#include <linux/ide.h>
22#include <linux/init.h>
23
24#define DRV_NAME "rz1000"
25
26static int rz1000_disable_readahead(struct pci_dev *dev)
27{
28 u16 reg;
29
30 if (!pci_read_config_word (dev, 0x40, ®) &&
31 !pci_write_config_word(dev, 0x40, reg & 0xdfff)) {
32 printk(KERN_INFO "%s: disabled chipset read-ahead "
33 "(buggy RZ1000/RZ1001)\n", pci_name(dev));
34 return 0;
35 } else {
36 printk(KERN_INFO "%s: serialized, disabled unmasking "
37 "(buggy RZ1000/RZ1001)\n", pci_name(dev));
38 return 1;
39 }
40}
41
42static const struct ide_port_info rz1000_chipset = {
43 .name = DRV_NAME,
44 .host_flags = IDE_HFLAG_NO_DMA,
45};
46
47static int rz1000_init_one(struct pci_dev *dev, const struct pci_device_id *id)
48{
49 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);
68}
69
70static 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 },
73 { 0, },
74};
75MODULE_DEVICE_TABLE(pci, rz1000_pci_tbl);
76
77static struct pci_driver rz1000_pci_driver = {
78 .name = "RZ1000_IDE",
79 .id_table = rz1000_pci_tbl,
80 .probe = rz1000_init_one,
81 .remove = rz1000_remove,
82};
83
84static int __init rz1000_ide_init(void)
85{
86 return ide_pci_register_driver(&rz1000_pci_driver);
87}
88
89static void __exit rz1000_ide_exit(void)
90{
91 pci_unregister_driver(&rz1000_pci_driver);
92}
93
94module_init(rz1000_ide_init);
95module_exit(rz1000_ide_exit);
96
97MODULE_AUTHOR("Andre Hedrick");
98MODULE_DESCRIPTION("PCI driver module for RZ1000 IDE");
99MODULE_LICENSE("GPL");
100
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/pci.h>
20#include <linux/ide.h>
21#include <linux/init.h>
22
23#define DRV_NAME "rz1000"
24
25static int __devinit rz1000_disable_readahead(struct pci_dev *dev)
26{
27 u16 reg;
28
29 if (!pci_read_config_word (dev, 0x40, ®) &&
30 !pci_write_config_word(dev, 0x40, reg & 0xdfff)) {
31 printk(KERN_INFO "%s: disabled chipset read-ahead "
32 "(buggy RZ1000/RZ1001)\n", pci_name(dev));
33 return 0;
34 } else {
35 printk(KERN_INFO "%s: serialized, disabled unmasking "
36 "(buggy RZ1000/RZ1001)\n", pci_name(dev));
37 return 1;
38 }
39}
40
41static const struct ide_port_info rz1000_chipset __devinitdata = {
42 .name = DRV_NAME,
43 .host_flags = IDE_HFLAG_NO_DMA,
44};
45
46static int __devinit rz1000_init_one(struct pci_dev *dev, const struct pci_device_id *id)
47{
48 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);
67}
68
69static 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 },
72 { 0, },
73};
74MODULE_DEVICE_TABLE(pci, rz1000_pci_tbl);
75
76static struct pci_driver rz1000_pci_driver = {
77 .name = "RZ1000_IDE",
78 .id_table = rz1000_pci_tbl,
79 .probe = rz1000_init_one,
80 .remove = rz1000_remove,
81};
82
83static int __init rz1000_ide_init(void)
84{
85 return ide_pci_register_driver(&rz1000_pci_driver);
86}
87
88static void __exit rz1000_ide_exit(void)
89{
90 pci_unregister_driver(&rz1000_pci_driver);
91}
92
93module_init(rz1000_ide_init);
94module_exit(rz1000_ide_exit);
95
96MODULE_AUTHOR("Andre Hedrick");
97MODULE_DESCRIPTION("PCI driver module for RZ1000 IDE");
98MODULE_LICENSE("GPL");
99