rz1000.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 1995-1998 Linus Torvalds & author (see below)
  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. #include <linux/types.h>
  16. #include <linux/module.h>
  17. #include <linux/kernel.h>
  18. #include <linux/pci.h>
  19. #include <linux/ide.h>
  20. #include <linux/init.h>
  21. #define DRV_NAME "rz1000"
  22. static int rz1000_disable_readahead(struct pci_dev *dev)
  23. {
  24. u16 reg;
  25. if (!pci_read_config_word (dev, 0x40, &reg) &&
  26. !pci_write_config_word(dev, 0x40, reg & 0xdfff)) {
  27. printk(KERN_INFO "%s: disabled chipset read-ahead "
  28. "(buggy RZ1000/RZ1001)\n", pci_name(dev));
  29. return 0;
  30. } else {
  31. printk(KERN_INFO "%s: serialized, disabled unmasking "
  32. "(buggy RZ1000/RZ1001)\n", pci_name(dev));
  33. return 1;
  34. }
  35. }
  36. static const struct ide_port_info rz1000_chipset = {
  37. .name = DRV_NAME,
  38. .host_flags = IDE_HFLAG_NO_DMA,
  39. };
  40. static int rz1000_init_one(struct pci_dev *dev, const struct pci_device_id *id)
  41. {
  42. struct ide_port_info d = rz1000_chipset;
  43. int rc;
  44. rc = pci_enable_device(dev);
  45. if (rc)
  46. return rc;
  47. if (rz1000_disable_readahead(dev)) {
  48. d.host_flags |= IDE_HFLAG_SERIALIZE;
  49. d.host_flags |= IDE_HFLAG_NO_UNMASK_IRQS;
  50. }
  51. return ide_pci_init_one(dev, &d, NULL);
  52. }
  53. static void rz1000_remove(struct pci_dev *dev)
  54. {
  55. ide_pci_remove(dev);
  56. pci_disable_device(dev);
  57. }
  58. static const struct pci_device_id rz1000_pci_tbl[] = {
  59. { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1000), 0 },
  60. { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1001), 0 },
  61. { 0, },
  62. };
  63. MODULE_DEVICE_TABLE(pci, rz1000_pci_tbl);
  64. static struct pci_driver rz1000_pci_driver = {
  65. .name = "RZ1000_IDE",
  66. .id_table = rz1000_pci_tbl,
  67. .probe = rz1000_init_one,
  68. .remove = rz1000_remove,
  69. };
  70. static int __init rz1000_ide_init(void)
  71. {
  72. return ide_pci_register_driver(&rz1000_pci_driver);
  73. }
  74. static void __exit rz1000_ide_exit(void)
  75. {
  76. pci_unregister_driver(&rz1000_pci_driver);
  77. }
  78. module_init(rz1000_ide_init);
  79. module_exit(rz1000_ide_exit);
  80. MODULE_AUTHOR("Andre Hedrick");
  81. MODULE_DESCRIPTION("PCI driver module for RZ1000 IDE");
  82. MODULE_LICENSE("GPL");