rz1000.c 2.3 KB

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