1#ifndef _LINUX_XD_H
2#define _LINUX_XD_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16#include <linux/interrupt.h>
17
18
19#define XD_DATA (xd_iobase + 0x00)
20#define XD_RESET (xd_iobase + 0x01)
21#define XD_STATUS (xd_iobase + 0x01)
22#define XD_SELECT (xd_iobase + 0x02)
23#define XD_JUMPER (xd_iobase + 0x02)
24#define XD_CONTROL (xd_iobase + 0x03)
25#define XD_RESERVED (xd_iobase + 0x03)
26
27
28#define CMD_TESTREADY 0x00
29#define CMD_RECALIBRATE 0x01
30#define CMD_SENSE 0x03
31#define CMD_FORMATDRV 0x04
32#define CMD_VERIFY 0x05
33#define CMD_FORMATTRK 0x06
34#define CMD_FORMATBAD 0x07
35#define CMD_READ 0x08
36#define CMD_WRITE 0x0A
37#define CMD_SEEK 0x0B
38
39
40#define CMD_DTCSETPARAM 0x0C
41#define CMD_DTCGETECC 0x0D
42#define CMD_DTCREADBUF 0x0E
43#define CMD_DTCWRITEBUF 0x0F
44#define CMD_DTCREMAPTRK 0x11
45#define CMD_DTCGETPARAM 0xFB
46#define CMD_DTCSETSTEP 0xFC
47#define CMD_DTCSETGEOM 0xFE
48#define CMD_DTCGETGEOM 0xFF
49#define CMD_ST11GETGEOM 0xF8
50#define CMD_WDSETPARAM 0x0C
51#define CMD_XBSETPARAM 0x0C
52
53
54#define CSB_ERROR 0x02
55#define CSB_LUN 0x20
56
57
58#define STAT_READY 0x01
59#define STAT_INPUT 0x02
60#define STAT_COMMAND 0x04
61#define STAT_SELECT 0x08
62#define STAT_REQUEST 0x10
63#define STAT_INTERRUPT 0x20
64
65
66#define PIO_MODE 0x00
67#define DMA_MODE 0x03
68
69#define XD_MAXDRIVES 2
70#define XD_TIMEOUT HZ
71#define XD_RETRIES 4
72
73#undef DEBUG
74
75#ifdef DEBUG
76 #define DEBUG_STARTUP
77 #define DEBUG_OVERRIDE
78 #define DEBUG_READWRITE
79 #define DEBUG_OTHER
80 #define DEBUG_COMMAND
81#endif
82
83
84typedef struct {
85 u_char heads;
86 u_short cylinders;
87 u_char sectors;
88 u_char control;
89 int unit;
90} XD_INFO;
91
92
93typedef struct {
94 unsigned int offset;
95 const char *string;
96 void (*init_controller)(unsigned int address);
97 void (*init_drive)(u_char drive);
98 const char *name;
99} XD_SIGNATURE;
100
101#ifndef MODULE
102static int xd_manual_geo_init (char *command);
103#endif
104static u_char xd_detect (u_char *controller, unsigned int *address);
105static u_char xd_initdrives (void (*init_drive)(u_char drive));
106
107static void do_xd_request (struct request_queue * q);
108static int xd_ioctl (struct block_device *bdev,fmode_t mode,unsigned int cmd,unsigned long arg);
109static int xd_readwrite (u_char operation,XD_INFO *disk,char *buffer,u_int block,u_int count);
110static void xd_recalibrate (u_char drive);
111
112static irqreturn_t xd_interrupt_handler(int irq, void *dev_id);
113static u_char xd_setup_dma (u_char opcode,u_char *buffer,u_int count);
114static u_char *xd_build (u_char *cmdblk,u_char command,u_char drive,u_char head,u_short cylinder,u_char sector,u_char count,u_char control);
115static void xd_watchdog (unsigned long unused);
116static inline u_char xd_waitport (u_short port,u_char flags,u_char mask,u_long timeout);
117static u_int xd_command (u_char *command,u_char mode,u_char *indata,u_char *outdata,u_char *sense,u_long timeout);
118
119
120static void xd_dtc_init_controller (unsigned int address);
121static void xd_dtc5150cx_init_drive (u_char drive);
122static void xd_dtc_init_drive (u_char drive);
123static void xd_wd_init_controller (unsigned int address);
124static void xd_wd_init_drive (u_char drive);
125static void xd_seagate_init_controller (unsigned int address);
126static void xd_seagate_init_drive (u_char drive);
127static void xd_omti_init_controller (unsigned int address);
128static void xd_omti_init_drive (u_char drive);
129static void xd_xebec_init_controller (unsigned int address);
130static void xd_xebec_init_drive (u_char drive);
131static void xd_setparam (u_char command,u_char drive,u_char heads,u_short cylinders,u_short rwrite,u_short wprecomp,u_char ecc);
132static void xd_override_init_drive (u_char drive);
133
134#endif
135