dtc2278.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:3k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  *  linux/drivers/ide/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/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. #include "ide_modes.h"
  19. /*
  20.  * Changing this #undef to #define may solve start up problems in some systems.
  21.  */
  22. #undef ALWAYS_SET_DTC2278_PIO_MODE
  23. /*
  24.  * From: andy@cercle.cts.com (Dyan Wile)
  25.  *
  26.  * Below is a patch for DTC-2278 - alike software-programmable controllers
  27.  * The code enables the secondary IDE controller and the PIO4 (3?) timings on
  28.  * the primary (EIDE). You may probably have to enable the 32-bit support to
  29.  * get the full speed. You better get the disk interrupts disabled ( hdparm -u0
  30.  * /dev/hd.. ) for the drives connected to the EIDE interface. (I get my
  31.  * filesystem  corrupted with -u1, but under heavy disk load only :-)
  32.  *
  33.  * This card is now forced to use the "serialize" feature,
  34.  * and irq-unmasking is disallowed.  If io_32bit is enabled,
  35.  * it must be done for BOTH drives on each interface.
  36.  *
  37.  * This code was written for the DTC2278E, but might work with any of these:
  38.  *
  39.  * DTC2278S has only a single IDE interface.
  40.  * DTC2278D has two IDE interfaces and is otherwise identical to the S version.
  41.  * DTC2278E also has serial ports and a printer port
  42.  * DTC2278EB: has onboard BIOS, and "works like a charm" -- Kent Bradford <kent@theory.caltech.edu>
  43.  *
  44.  * There may be a fourth controller type. The S and D versions use the
  45.  * Winbond chip, and I think the E version does also.
  46.  *
  47.  */
  48. static void sub22 (char b, char c)
  49. {
  50. int i;
  51. for(i = 0; i < 3; ++i) {
  52. inb(0x3f6);
  53. outb_p(b,0xb0);
  54. inb(0x3f6);
  55. outb_p(c,0xb4);
  56. inb(0x3f6);
  57. if(inb(0xb4) == c) {
  58. outb_p(7,0xb0);
  59. inb(0x3f6);
  60. return; /* success */
  61. }
  62. }
  63. }
  64. static void tune_dtc2278 (ide_drive_t *drive, byte pio)
  65. {
  66. unsigned long flags;
  67. pio = ide_get_best_pio_mode(drive, pio, 4, NULL);
  68. if (pio >= 3) {
  69. save_flags(flags); /* all CPUs */
  70. cli(); /* all CPUs */
  71. /*
  72.  * This enables PIO mode4 (3?) on the first interface
  73.  */
  74. sub22(1,0xc3);
  75. sub22(0,0xa0);
  76. restore_flags(flags); /* all CPUs */
  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. void __init init_dtc2278 (void)
  87. {
  88. unsigned long flags;
  89. __save_flags(flags); /* local CPU only */
  90. __cli(); /* local CPU only */
  91. /*
  92.  * This enables the second interface
  93.  */
  94. outb_p(4,0xb0);
  95. inb(0x3f6);
  96. outb_p(0x20,0xb4);
  97. inb(0x3f6);
  98. #ifdef ALWAYS_SET_DTC2278_PIO_MODE
  99. /*
  100.  * This enables PIO mode4 (3?) on the first interface
  101.  * and may solve start-up problems for some people.
  102.  */
  103. sub22(1,0xc3);
  104. sub22(0,0xa0);
  105. #endif
  106. __restore_flags(flags); /* local CPU only */
  107. ide_hwifs[0].serialized = 1;
  108. ide_hwifs[1].serialized = 1;
  109. ide_hwifs[0].chipset = ide_dtc2278;
  110. ide_hwifs[1].chipset = ide_dtc2278;
  111. ide_hwifs[0].tuneproc = &tune_dtc2278;
  112. ide_hwifs[0].drives[0].no_unmask = 1;
  113. ide_hwifs[0].drives[1].no_unmask = 1;
  114. ide_hwifs[1].drives[0].no_unmask = 1;
  115. ide_hwifs[1].drives[1].no_unmask = 1;
  116. ide_hwifs[0].mate = &ide_hwifs[1];
  117. ide_hwifs[1].mate = &ide_hwifs[0];
  118. ide_hwifs[1].channel = 1;
  119. }