dtc2278.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * linux/drivers/ide/legacy/dtc2278.c Version 0.02 Feb 10, 1996
  3. *
  4. * Copyright (C) 1996 Linus Torvalds & author (see below)
  5. */
  6. #undef REALLY_SLOW_IO /* most systems can safely undef this */
  7. #include <linux/module.h>
  8. #include <linux/config.h>
  9. #include <linux/types.h>
  10. #include <linux/kernel.h>
  11. #include <linux/delay.h>
  12. #include <linux/timer.h>
  13. #include <linux/mm.h>
  14. #include <linux/ioport.h>
  15. #include <linux/blkdev.h>
  16. #include <linux/hdreg.h>
  17. #include <linux/ide.h>
  18. #include <linux/init.h>
  19. #include <asm/io.h>
  20. /*
  21. * Changing this #undef to #define may solve start up problems in some systems.
  22. */
  23. #undef ALWAYS_SET_DTC2278_PIO_MODE
  24. /*
  25. * From: andy@cercle.cts.com (Dyan Wile)
  26. *
  27. * Below is a patch for DTC-2278 - alike software-programmable controllers
  28. * The code enables the secondary IDE controller and the PIO4 (3?) timings on
  29. * the primary (EIDE). You may probably have to enable the 32-bit support to
  30. * get the full speed. You better get the disk interrupts disabled ( hdparm -u0
  31. * /dev/hd.. ) for the drives connected to the EIDE interface. (I get my
  32. * filesystem corrupted with -u1, but under heavy disk load only :-)
  33. *
  34. * This card is now forced to use the "serialize" feature,
  35. * and irq-unmasking is disallowed. If io_32bit is enabled,
  36. * it must be done for BOTH drives on each interface.
  37. *
  38. * This code was written for the DTC2278E, but might work with any of these:
  39. *
  40. * DTC2278S has only a single IDE interface.
  41. * DTC2278D has two IDE interfaces and is otherwise identical to the S version.
  42. * DTC2278E also has serial ports and a printer port
  43. * DTC2278EB: has onboard BIOS, and "works like a charm" -- Kent Bradford <kent@theory.caltech.edu>
  44. *
  45. * There may be a fourth controller type. The S and D versions use the
  46. * Winbond chip, and I think the E version does also.
  47. *
  48. */
  49. static void sub22 (char b, char c)
  50. {
  51. int i;
  52. for(i = 0; i < 3; ++i) {
  53. inb(0x3f6);
  54. outb_p(b,0xb0);
  55. inb(0x3f6);
  56. outb_p(c,0xb4);
  57. inb(0x3f6);
  58. if(inb(0xb4) == c) {
  59. outb_p(7,0xb0);
  60. inb(0x3f6);
  61. return; /* success */
  62. }
  63. }
  64. }
  65. static void tune_dtc2278 (ide_drive_t *drive, u8 pio)
  66. {
  67. unsigned long flags;
  68. pio = ide_get_best_pio_mode(drive, pio, 4, NULL);
  69. if (pio >= 3) {
  70. spin_lock_irqsave(&ide_lock, flags);
  71. /*
  72. * This enables PIO mode4 (3?) on the first interface
  73. */
  74. sub22(1,0xc3);
  75. sub22(0,0xa0);
  76. spin_unlock_irqrestore(&ide_lock, flags);
  77. } else {
  78. /* we don't know how to set it back again.. */
  79. }
  80. /*
  81. * 32bit I/O has to be enabled for *both* drives at the same time.
  82. */
  83. drive->io_32bit = 1;
  84. HWIF(drive)->drives[!drive->select.b.unit].io_32bit = 1;
  85. }
  86. static int __init probe_dtc2278(void)
  87. {
  88. unsigned long flags;
  89. ide_hwif_t *hwif, *mate;
  90. hwif = &ide_hwifs[0];
  91. mate = &ide_hwifs[1];
  92. if (hwif->chipset != ide_unknown || mate->chipset != ide_unknown)
  93. return 1;
  94. local_irq_save(flags);
  95. /*
  96. * This enables the second interface
  97. */
  98. outb_p(4,0xb0);
  99. inb(0x3f6);
  100. outb_p(0x20,0xb4);
  101. inb(0x3f6);
  102. #ifdef ALWAYS_SET_DTC2278_PIO_MODE
  103. /*
  104. * This enables PIO mode4 (3?) on the first interface
  105. * and may solve start-up problems for some people.
  106. */
  107. sub22(1,0xc3);
  108. sub22(0,0xa0);
  109. #endif
  110. local_irq_restore(flags);
  111. hwif->serialized = 1;
  112. hwif->chipset = ide_dtc2278;
  113. hwif->tuneproc = &tune_dtc2278;
  114. hwif->drives[0].no_unmask = 1;
  115. hwif->drives[1].no_unmask = 1;
  116. hwif->mate = mate;
  117. mate->serialized = 1;
  118. mate->chipset = ide_dtc2278;
  119. mate->drives[0].no_unmask = 1;
  120. mate->drives[1].no_unmask = 1;
  121. mate->mate = hwif;
  122. mate->channel = 1;
  123. probe_hwif_init(hwif);
  124. probe_hwif_init(mate);
  125. create_proc_ide_interfaces();
  126. return 0;
  127. }
  128. /* Can be called directly from ide.c. */
  129. int __init dtc2278_init(void)
  130. {
  131. if (probe_dtc2278()) {
  132. printk(KERN_ERR "dtc2278: ide interfaces already in use!\n");
  133. return -EBUSY;
  134. }
  135. return 0;
  136. }
  137. #ifdef MODULE
  138. module_init(dtc2278_init);
  139. #endif
  140. MODULE_AUTHOR("See Local File");
  141. MODULE_DESCRIPTION("support of DTC-2278 VLB IDE chipsets");
  142. MODULE_LICENSE("GPL");