dtc2278.c 4.1 KB

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