triflex.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * IDE Chipset driver for the Compaq TriFlex IDE controller.
  3. *
  4. * Known to work with the Compaq Workstation 5x00 series.
  5. *
  6. * Copyright (C) 2002 Hewlett-Packard Development Group, L.P.
  7. * Author: Torben Mathiasen <torben.mathiasen@hp.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. * Loosely based on the piix & svwks drivers.
  23. *
  24. * Documentation:
  25. * Not publically available.
  26. */
  27. #include <linux/types.h>
  28. #include <linux/module.h>
  29. #include <linux/kernel.h>
  30. #include <linux/hdreg.h>
  31. #include <linux/pci.h>
  32. #include <linux/ide.h>
  33. #include <linux/init.h>
  34. static void triflex_set_mode(ide_drive_t *drive, const u8 speed)
  35. {
  36. ide_hwif_t *hwif = HWIF(drive);
  37. struct pci_dev *dev = to_pci_dev(hwif->dev);
  38. u8 channel_offset = hwif->channel ? 0x74 : 0x70;
  39. u16 timing = 0;
  40. u32 triflex_timings = 0;
  41. u8 unit = (drive->select.b.unit & 0x01);
  42. pci_read_config_dword(dev, channel_offset, &triflex_timings);
  43. switch(speed) {
  44. case XFER_MW_DMA_2:
  45. timing = 0x0103;
  46. break;
  47. case XFER_MW_DMA_1:
  48. timing = 0x0203;
  49. break;
  50. case XFER_MW_DMA_0:
  51. timing = 0x0808;
  52. break;
  53. case XFER_SW_DMA_2:
  54. case XFER_SW_DMA_1:
  55. case XFER_SW_DMA_0:
  56. timing = 0x0f0f;
  57. break;
  58. case XFER_PIO_4:
  59. timing = 0x0202;
  60. break;
  61. case XFER_PIO_3:
  62. timing = 0x0204;
  63. break;
  64. case XFER_PIO_2:
  65. timing = 0x0404;
  66. break;
  67. case XFER_PIO_1:
  68. timing = 0x0508;
  69. break;
  70. case XFER_PIO_0:
  71. timing = 0x0808;
  72. break;
  73. }
  74. triflex_timings &= ~(0xFFFF << (16 * unit));
  75. triflex_timings |= (timing << (16 * unit));
  76. pci_write_config_dword(dev, channel_offset, triflex_timings);
  77. }
  78. static void triflex_set_pio_mode(ide_drive_t *drive, const u8 pio)
  79. {
  80. triflex_set_mode(drive, XFER_PIO_0 + pio);
  81. }
  82. static void __devinit init_hwif_triflex(ide_hwif_t *hwif)
  83. {
  84. hwif->set_pio_mode = &triflex_set_pio_mode;
  85. hwif->set_dma_mode = &triflex_set_mode;
  86. }
  87. static const struct ide_port_info triflex_device __devinitdata = {
  88. .name = "TRIFLEX",
  89. .init_hwif = init_hwif_triflex,
  90. .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}},
  91. .pio_mask = ATA_PIO4,
  92. .swdma_mask = ATA_SWDMA2,
  93. .mwdma_mask = ATA_MWDMA2,
  94. };
  95. static int __devinit triflex_init_one(struct pci_dev *dev,
  96. const struct pci_device_id *id)
  97. {
  98. return ide_setup_pci_device(dev, &triflex_device);
  99. }
  100. static const struct pci_device_id triflex_pci_tbl[] = {
  101. { PCI_VDEVICE(COMPAQ, PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE), 0 },
  102. { 0, },
  103. };
  104. MODULE_DEVICE_TABLE(pci, triflex_pci_tbl);
  105. static struct pci_driver driver = {
  106. .name = "TRIFLEX_IDE",
  107. .id_table = triflex_pci_tbl,
  108. .probe = triflex_init_one,
  109. };
  110. static int __init triflex_ide_init(void)
  111. {
  112. return ide_pci_register_driver(&driver);
  113. }
  114. module_init(triflex_ide_init);
  115. MODULE_AUTHOR("Torben Mathiasen");
  116. MODULE_DESCRIPTION("PCI driver module for Compaq Triflex IDE");
  117. MODULE_LICENSE("GPL");