ppa.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Driver for the PPA3 parallel port SCSI HBA embedded in
  3. * the Iomega ZIP drive
  4. *
  5. * (c) 1996 Grant R. Guenther grant@torque.net
  6. * David Campbell
  7. *
  8. * All comments to David.
  9. */
  10. #ifndef _PPA_H
  11. #define _PPA_H
  12. #define PPA_VERSION "2.07 (for Linux 2.4.x)"
  13. /*
  14. * this driver has been hacked by Matteo Frigo (athena@theory.lcs.mit.edu)
  15. * to support EPP and scatter-gather. [0.26-athena]
  16. *
  17. * additional hacks by David Campbell
  18. * in response to this driver "mis-behaving" on his machine.
  19. * Fixed EPP to handle "software" changing of EPP port data direction.
  20. * Chased down EPP timeouts
  21. * Made this driver "kernel version friendly" [0.28-athena]
  22. *
  23. * [ Stuff removed ]
  24. *
  25. * Corrected ppa.h for 2.1.x kernels (>=2.1.85)
  26. * Modified "Nat Semi Kludge" for extended chipsets
  27. * [1.41]
  28. *
  29. * Fixed id_probe for EPP 1.9 chipsets (misdetected as EPP 1.7)
  30. * [1.42]
  31. *
  32. * Development solely for 2.1.x kernels from now on!
  33. * [2.00]
  34. *
  35. * Hack and slash at the init code (EPP device check routine)
  36. * Added INSANE option.
  37. * [2.01]
  38. *
  39. * Patch applied to sync against the 2.1.x kernel code
  40. * Included qboot_zip.sh
  41. * [2.02]
  42. *
  43. * Cleaned up the mess left by someone else trying to fix the
  44. * asm section to keep egcc happy. The asm section no longer
  45. * exists, the nibble code is *almost* as fast as the asm code
  46. * providing it is compiled with egcc.
  47. *
  48. * Other clean ups include the follow changes:
  49. * CONFIG_SCSI_PPA_HAVE_PEDANTIC => CONFIG_SCSI_IZIP_EPP16
  50. * added CONFIG_SCSI_IZIP_SLOW_CTR option
  51. * [2.03]
  52. *
  53. * Use ppa_wait() to check for ready AND connected status bits
  54. * Add ppa_wait() calls to ppa_completion()
  55. * by Peter Cherriman <pjc@ecs.soton.ac.uk> and
  56. * Tim Waugh <twaugh@redhat.com>
  57. * [2.04]
  58. *
  59. * Fix kernel panic on scsi timeout, 2000-08-18 [2.05]
  60. *
  61. * Avoid io_request_lock problems.
  62. * John Cavan <johncavan@home.com> [2.06]
  63. *
  64. * Busy wait for connected status bit in ppa_completion()
  65. * in order to cope with some hardware that has this bit low
  66. * for short periods of time.
  67. * Add udelay() to ppa_select()
  68. * by Peter Cherriman <pjc@ecs.soton.ac.uk> and
  69. * Oleg Makarenko <omakarenko@cyberplat.ru>
  70. * [2.07]
  71. */
  72. /* ------ END OF USER CONFIGURABLE PARAMETERS ----- */
  73. #include <linux/stddef.h>
  74. #include <linux/module.h>
  75. #include <linux/kernel.h>
  76. #include <linux/ioport.h>
  77. #include <linux/delay.h>
  78. #include <linux/proc_fs.h>
  79. #include <linux/stat.h>
  80. #include <linux/blkdev.h>
  81. #include <linux/sched.h>
  82. #include <linux/interrupt.h>
  83. #include <asm/io.h>
  84. #include <scsi/scsi_host.h>
  85. /* batteries not included :-) */
  86. /*
  87. * modes in which the driver can operate
  88. */
  89. #define PPA_AUTODETECT 0 /* Autodetect mode */
  90. #define PPA_NIBBLE 1 /* work in standard 4 bit mode */
  91. #define PPA_PS2 2 /* PS/2 byte mode */
  92. #define PPA_EPP_8 3 /* EPP mode, 8 bit */
  93. #define PPA_EPP_16 4 /* EPP mode, 16 bit */
  94. #define PPA_EPP_32 5 /* EPP mode, 32 bit */
  95. #define PPA_UNKNOWN 6 /* Just in case... */
  96. static char *PPA_MODE_STRING[] =
  97. {
  98. "Autodetect",
  99. "SPP",
  100. "PS/2",
  101. "EPP 8 bit",
  102. "EPP 16 bit",
  103. #ifdef CONFIG_SCSI_IZIP_EPP16
  104. "EPP 16 bit",
  105. #else
  106. "EPP 32 bit",
  107. #endif
  108. "Unknown"};
  109. /* other options */
  110. #define PPA_BURST_SIZE 512 /* data burst size */
  111. #define PPA_SELECT_TMO 5000 /* how long to wait for target ? */
  112. #define PPA_SPIN_TMO 50000 /* ppa_wait loop limiter */
  113. #define PPA_RECON_TMO 500 /* scsi reconnection loop limiter */
  114. #define PPA_DEBUG 0 /* debugging option */
  115. #define IN_EPP_MODE(x) (x == PPA_EPP_8 || x == PPA_EPP_16 || x == PPA_EPP_32)
  116. /* args to ppa_connect */
  117. #define CONNECT_EPP_MAYBE 1
  118. #define CONNECT_NORMAL 0
  119. #define r_dtr(x) (unsigned char)inb((x))
  120. #define r_str(x) (unsigned char)inb((x)+1)
  121. #define r_ctr(x) (unsigned char)inb((x)+2)
  122. #define r_epp(x) (unsigned char)inb((x)+4)
  123. #define r_fifo(x) (unsigned char)inb((x)) /* x must be base_hi */
  124. /* On PCI is base+0x400 != base_hi */
  125. #define r_ecr(x) (unsigned char)inb((x)+0x2) /* x must be base_hi */
  126. #define w_dtr(x,y) outb(y, (x))
  127. #define w_str(x,y) outb(y, (x)+1)
  128. #define w_epp(x,y) outb(y, (x)+4)
  129. #define w_fifo(x,y) outb(y, (x)) /* x must be base_hi */
  130. #define w_ecr(x,y) outb(y, (x)+0x2)/* x must be base_hi */
  131. #ifdef CONFIG_SCSI_IZIP_SLOW_CTR
  132. #define w_ctr(x,y) outb_p(y, (x)+2)
  133. #else
  134. #define w_ctr(x,y) outb(y, (x)+2)
  135. #endif
  136. static int ppa_engine(ppa_struct *, struct scsi_cmnd *);
  137. #endif /* _PPA_H */