Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*  Driver for the PPA3 parallel port SCSI HBA embedded in 
0003  * the Iomega ZIP drive
0004  * 
0005  * (c) 1996     Grant R. Guenther  grant@torque.net
0006  *              David Campbell
0007  *
0008  *      All comments to David.
0009  */
0010 
0011 #ifndef _PPA_H
0012 #define _PPA_H
0013 
0014 #define   PPA_VERSION   "2.07 (for Linux 2.4.x)"
0015 
0016 /* 
0017  * this driver has been hacked by Matteo Frigo (athena@theory.lcs.mit.edu)
0018  * to support EPP and scatter-gather.                        [0.26-athena]
0019  *
0020  * additional hacks by David Campbell
0021  * in response to this driver "mis-behaving" on his machine.
0022  *      Fixed EPP to handle "software" changing of EPP port data direction.
0023  *      Chased down EPP timeouts
0024  *      Made this driver "kernel version friendly"           [0.28-athena]
0025  *
0026  * [ Stuff removed ]
0027  *
0028  * Corrected ppa.h for 2.1.x kernels (>=2.1.85)
0029  * Modified "Nat Semi Kludge" for extended chipsets
0030  *                                                      [1.41]
0031  *
0032  * Fixed id_probe for EPP 1.9 chipsets (misdetected as EPP 1.7)
0033  *                                                      [1.42]
0034  *
0035  * Development solely for 2.1.x kernels from now on!
0036  *                                                      [2.00]
0037  *
0038  * Hack and slash at the init code (EPP device check routine)
0039  * Added INSANE option.
0040  *                                                      [2.01]
0041  *
0042  * Patch applied to sync against the 2.1.x kernel code
0043  * Included qboot_zip.sh
0044  *                                                      [2.02]
0045  *
0046  * Cleaned up the mess left by someone else trying to fix the
0047  * asm section to keep egcc happy. The asm section no longer
0048  * exists, the nibble code is *almost* as fast as the asm code
0049  * providing it is compiled with egcc.
0050  *
0051  * Other clean ups include the follow changes:
0052  *    CONFIG_SCSI_PPA_HAVE_PEDANTIC => CONFIG_SCSI_IZIP_EPP16
0053  *    added CONFIG_SCSI_IZIP_SLOW_CTR option
0054  *                                                      [2.03]
0055  *
0056  * Use ppa_wait() to check for ready AND connected status bits
0057  * Add ppa_wait() calls to ppa_completion()
0058  *  by Peter Cherriman <pjc@ecs.soton.ac.uk> and
0059  *     Tim Waugh <twaugh@redhat.com>
0060  *                          [2.04]
0061  *
0062  * Fix kernel panic on scsi timeout, 2000-08-18     [2.05]
0063  *
0064  * Avoid io_request_lock problems.
0065  * John Cavan <johncavan@home.com>          [2.06]
0066  *
0067  * Busy wait for connected status bit in ppa_completion()
0068  *  in order to cope with some hardware that has this bit low
0069  *  for short periods of time.
0070  * Add udelay() to ppa_select()
0071  *  by Peter Cherriman <pjc@ecs.soton.ac.uk> and
0072  *     Oleg Makarenko <omakarenko@cyberplat.ru>         
0073  *                                                      [2.07]
0074  */
0075 /* ------ END OF USER CONFIGURABLE PARAMETERS ----- */
0076 
0077 #include  <linux/stddef.h>
0078 #include  <linux/module.h>
0079 #include  <linux/kernel.h>
0080 #include  <linux/ioport.h>
0081 #include  <linux/delay.h>
0082 #include  <linux/proc_fs.h>
0083 #include  <linux/stat.h>
0084 #include  <linux/blkdev.h>
0085 #include  <linux/sched.h>
0086 #include  <linux/interrupt.h>
0087 
0088 #include  <asm/io.h>
0089 #include  <scsi/scsi_host.h>
0090 /* batteries not included :-) */
0091 
0092 /*
0093  * modes in which the driver can operate 
0094  */
0095 #define   PPA_AUTODETECT        0   /* Autodetect mode                */
0096 #define   PPA_NIBBLE            1   /* work in standard 4 bit mode    */
0097 #define   PPA_PS2               2   /* PS/2 byte mode         */
0098 #define   PPA_EPP_8             3   /* EPP mode, 8 bit                */
0099 #define   PPA_EPP_16            4   /* EPP mode, 16 bit               */
0100 #define   PPA_EPP_32            5   /* EPP mode, 32 bit               */
0101 #define   PPA_UNKNOWN           6   /* Just in case...                */
0102 
0103 static char *PPA_MODE_STRING[] =
0104 {
0105     "Autodetect",
0106     "SPP",
0107     "PS/2",
0108     "EPP 8 bit",
0109     "EPP 16 bit",
0110 #ifdef CONFIG_SCSI_IZIP_EPP16
0111     "EPP 16 bit",
0112 #else
0113     "EPP 32 bit",
0114 #endif
0115     "Unknown"};
0116 
0117 /* other options */
0118 #define PPA_BURST_SIZE  512 /* data burst size */
0119 #define PPA_SELECT_TMO  5000    /* how long to wait for target ? */
0120 #define PPA_SPIN_TMO    50000   /* ppa_wait loop limiter */
0121 #define PPA_RECON_TMO   500 /* scsi reconnection loop limiter */
0122 #define PPA_DEBUG   0   /* debugging option */
0123 #define IN_EPP_MODE(x) (x == PPA_EPP_8 || x == PPA_EPP_16 || x == PPA_EPP_32)
0124 
0125 /* args to ppa_connect */
0126 #define CONNECT_EPP_MAYBE 1
0127 #define CONNECT_NORMAL  0
0128 
0129 #define r_dtr(x)        (unsigned char)inb((x))
0130 #define r_str(x)        (unsigned char)inb((x)+1)
0131 #define r_ctr(x)        (unsigned char)inb((x)+2)
0132 #define r_epp(x)        (unsigned char)inb((x)+4)
0133 #define r_fifo(x)       (unsigned char)inb((x)) /* x must be base_hi */
0134                     /* On PCI is base+0x400 != base_hi */
0135 #define r_ecr(x)        (unsigned char)inb((x)+0x2) /* x must be base_hi */
0136 
0137 #define w_dtr(x,y)      outb(y, (x))
0138 #define w_str(x,y)      outb(y, (x)+1)
0139 #define w_epp(x,y)      outb(y, (x)+4)
0140 #define w_fifo(x,y)     outb(y, (x))    /* x must be base_hi */
0141 #define w_ecr(x,y)      outb(y, (x)+0x2)/* x must be base_hi */
0142 
0143 #ifdef CONFIG_SCSI_IZIP_SLOW_CTR
0144 #define w_ctr(x,y)      outb_p(y, (x)+2)
0145 #else
0146 #define w_ctr(x,y)      outb(y, (x)+2)
0147 #endif
0148 
0149 static int ppa_engine(ppa_struct *, struct scsi_cmnd *);
0150 
0151 #endif              /* _PPA_H */