pata_rz1000.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * RZ1000/1001 driver based upon
  3. *
  4. * linux/drivers/ide/pci/rz1000.c Version 0.06 January 12, 2003
  5. * Copyright (C) 1995-1998 Linus Torvalds & author (see below)
  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. #include <linux/kernel.h>
  14. #include <linux/module.h>
  15. #include <linux/pci.h>
  16. #include <linux/blkdev.h>
  17. #include <linux/delay.h>
  18. #include <scsi/scsi_host.h>
  19. #include <linux/libata.h>
  20. #define DRV_NAME "pata_rz1000"
  21. #define DRV_VERSION "0.2.4"
  22. /**
  23. * rz1000_set_mode - mode setting function
  24. * @link: ATA link
  25. * @unused: returned device on set_mode failure
  26. *
  27. * Use a non standard set_mode function. We don't want to be tuned. We
  28. * would prefer to be BIOS generic but for the fact our hardware is
  29. * whacked out.
  30. */
  31. static int rz1000_set_mode(struct ata_link *link, struct ata_device **unused)
  32. {
  33. struct ata_device *dev;
  34. ata_for_each_dev(dev, link, ENABLED) {
  35. /* We don't really care */
  36. dev->pio_mode = XFER_PIO_0;
  37. dev->xfer_mode = XFER_PIO_0;
  38. dev->xfer_shift = ATA_SHIFT_PIO;
  39. dev->flags |= ATA_DFLAG_PIO;
  40. ata_dev_info(dev, "configured for PIO\n");
  41. }
  42. return 0;
  43. }
  44. static struct scsi_host_template rz1000_sht = {
  45. ATA_PIO_SHT(DRV_NAME),
  46. };
  47. static struct ata_port_operations rz1000_port_ops = {
  48. .inherits = &ata_sff_port_ops,
  49. .cable_detect = ata_cable_40wire,
  50. .set_mode = rz1000_set_mode,
  51. };
  52. static int rz1000_fifo_disable(struct pci_dev *pdev)
  53. {
  54. u16 reg;
  55. /* Be exceptionally paranoid as we must be sure to apply the fix */
  56. if (pci_read_config_word(pdev, 0x40, &reg) != 0)
  57. return -1;
  58. reg &= 0xDFFF;
  59. if (pci_write_config_word(pdev, 0x40, reg) != 0)
  60. return -1;
  61. printk(KERN_INFO DRV_NAME ": disabled chipset readahead.\n");
  62. return 0;
  63. }
  64. /**
  65. * rz1000_init_one - Register RZ1000 ATA PCI device with kernel services
  66. * @pdev: PCI device to register
  67. * @ent: Entry in rz1000_pci_tbl matching with @pdev
  68. *
  69. * Configure an RZ1000 interface. This doesn't require much special
  70. * handling except that we *MUST* kill the chipset readahead or the
  71. * user may experience data corruption.
  72. */
  73. static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
  74. {
  75. static const struct ata_port_info info = {
  76. .flags = ATA_FLAG_SLAVE_POSS,
  77. .pio_mask = ATA_PIO4,
  78. .port_ops = &rz1000_port_ops
  79. };
  80. const struct ata_port_info *ppi[] = { &info, NULL };
  81. ata_print_version_once(&pdev->dev, DRV_VERSION);
  82. if (rz1000_fifo_disable(pdev) == 0)
  83. return ata_pci_sff_init_one(pdev, ppi, &rz1000_sht, NULL, 0);
  84. printk(KERN_ERR DRV_NAME ": failed to disable read-ahead on chipset..\n");
  85. /* Not safe to use so skip */
  86. return -ENODEV;
  87. }
  88. #ifdef CONFIG_PM_SLEEP
  89. static int rz1000_reinit_one(struct pci_dev *pdev)
  90. {
  91. struct ata_host *host = pci_get_drvdata(pdev);
  92. int rc;
  93. rc = ata_pci_device_do_resume(pdev);
  94. if (rc)
  95. return rc;
  96. /* If this fails on resume (which is a "can't happen" case), we
  97. must stop as any progress risks data loss */
  98. if (rz1000_fifo_disable(pdev))
  99. panic("rz1000 fifo");
  100. ata_host_resume(host);
  101. return 0;
  102. }
  103. #endif
  104. static const struct pci_device_id pata_rz1000[] = {
  105. { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1000), },
  106. { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1001), },
  107. { },
  108. };
  109. static struct pci_driver rz1000_pci_driver = {
  110. .name = DRV_NAME,
  111. .id_table = pata_rz1000,
  112. .probe = rz1000_init_one,
  113. .remove = ata_pci_remove_one,
  114. #ifdef CONFIG_PM_SLEEP
  115. .suspend = ata_pci_device_suspend,
  116. .resume = rz1000_reinit_one,
  117. #endif
  118. };
  119. module_pci_driver(rz1000_pci_driver);
  120. MODULE_AUTHOR("Alan Cox");
  121. MODULE_DESCRIPTION("low-level driver for RZ1000 PCI ATA");
  122. MODULE_LICENSE("GPL");
  123. MODULE_DEVICE_TABLE(pci, pata_rz1000);
  124. MODULE_VERSION(DRV_VERSION);