ax25: Fix possible oops in ax25_make_new
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / block / xd.h
blob37cacef16e936d87fbfe2d07980431f885971d81
1 #ifndef _LINUX_XD_H
2 #define _LINUX_XD_H
4 /*
5 * This file contains the definitions for the IO ports and errors etc. for XT hard disk controllers (at least the DTC 5150X).
7 * Author: Pat Mackinlay, pat@it.com.au
8 * Date: 29/09/92
10 * Revised: 01/01/93, ...
12 * Ref: DTC 5150X Controller Specification (thanks to Kevin Fowler, kevinf@agora.rain.com)
13 * Also thanks to: Salvador Abreu, Dave Thaler, Risto Kankkunen and Wim Van Dorst.
16 #include <linux/interrupt.h>
18 /* XT hard disk controller registers */
19 #define XD_DATA (xd_iobase + 0x00) /* data RW register */
20 #define XD_RESET (xd_iobase + 0x01) /* reset WO register */
21 #define XD_STATUS (xd_iobase + 0x01) /* status RO register */
22 #define XD_SELECT (xd_iobase + 0x02) /* select WO register */
23 #define XD_JUMPER (xd_iobase + 0x02) /* jumper RO register */
24 #define XD_CONTROL (xd_iobase + 0x03) /* DMAE/INTE WO register */
25 #define XD_RESERVED (xd_iobase + 0x03) /* reserved */
27 /* XT hard disk controller commands (incomplete list) */
28 #define CMD_TESTREADY 0x00 /* test drive ready */
29 #define CMD_RECALIBRATE 0x01 /* recalibrate drive */
30 #define CMD_SENSE 0x03 /* request sense */
31 #define CMD_FORMATDRV 0x04 /* format drive */
32 #define CMD_VERIFY 0x05 /* read verify */
33 #define CMD_FORMATTRK 0x06 /* format track */
34 #define CMD_FORMATBAD 0x07 /* format bad track */
35 #define CMD_READ 0x08 /* read */
36 #define CMD_WRITE 0x0A /* write */
37 #define CMD_SEEK 0x0B /* seek */
39 /* Controller specific commands */
40 #define CMD_DTCSETPARAM 0x0C /* set drive parameters (DTC 5150X & CX only?) */
41 #define CMD_DTCGETECC 0x0D /* get ecc error length (DTC 5150X only?) */
42 #define CMD_DTCREADBUF 0x0E /* read sector buffer (DTC 5150X only?) */
43 #define CMD_DTCWRITEBUF 0x0F /* write sector buffer (DTC 5150X only?) */
44 #define CMD_DTCREMAPTRK 0x11 /* assign alternate track (DTC 5150X only?) */
45 #define CMD_DTCGETPARAM 0xFB /* get drive parameters (DTC 5150X only?) */
46 #define CMD_DTCSETSTEP 0xFC /* set step rate (DTC 5150X only?) */
47 #define CMD_DTCSETGEOM 0xFE /* set geometry data (DTC 5150X only?) */
48 #define CMD_DTCGETGEOM 0xFF /* get geometry data (DTC 5150X only?) */
49 #define CMD_ST11GETGEOM 0xF8 /* get geometry data (Seagate ST11R/M only?) */
50 #define CMD_WDSETPARAM 0x0C /* set drive parameters (WD 1004A27X only?) */
51 #define CMD_XBSETPARAM 0x0C /* set drive parameters (XEBEC only?) */
53 /* Bits for command status byte */
54 #define CSB_ERROR 0x02 /* error */
55 #define CSB_LUN 0x20 /* logical Unit Number */
57 /* XT hard disk controller status bits */
58 #define STAT_READY 0x01 /* controller is ready */
59 #define STAT_INPUT 0x02 /* data flowing from controller to host */
60 #define STAT_COMMAND 0x04 /* controller in command phase */
61 #define STAT_SELECT 0x08 /* controller is selected */
62 #define STAT_REQUEST 0x10 /* controller requesting data */
63 #define STAT_INTERRUPT 0x20 /* controller requesting interrupt */
65 /* XT hard disk controller control bits */
66 #define PIO_MODE 0x00 /* control bits to set for PIO */
67 #define DMA_MODE 0x03 /* control bits to set for DMA & interrupt */
69 #define XD_MAXDRIVES 2 /* maximum 2 drives */
70 #define XD_TIMEOUT HZ /* 1 second timeout */
71 #define XD_RETRIES 4 /* maximum 4 retries */
73 #undef DEBUG /* define for debugging output */
75 #ifdef DEBUG
76 #define DEBUG_STARTUP /* debug driver initialisation */
77 #define DEBUG_OVERRIDE /* debug override geometry detection */
78 #define DEBUG_READWRITE /* debug each read/write command */
79 #define DEBUG_OTHER /* debug misc. interrupt/DMA stuff */
80 #define DEBUG_COMMAND /* debug each controller command */
81 #endif /* DEBUG */
83 /* this structure defines the XT drives and their types */
84 typedef struct {
85 u_char heads;
86 u_short cylinders;
87 u_char sectors;
88 u_char control;
89 int unit;
90 } XD_INFO;
92 /* this structure defines a ROM BIOS signature */
93 typedef 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;
101 #ifndef MODULE
102 static int xd_manual_geo_init (char *command);
103 #endif /* MODULE */
104 static u_char xd_detect (u_char *controller, unsigned int *address);
105 static u_char xd_initdrives (void (*init_drive)(u_char drive));
107 static void do_xd_request (struct request_queue * q);
108 static int xd_ioctl (struct block_device *bdev,fmode_t mode,unsigned int cmd,unsigned long arg);
109 static int xd_readwrite (u_char operation,XD_INFO *disk,char *buffer,u_int block,u_int count);
110 static void xd_recalibrate (u_char drive);
112 static irqreturn_t xd_interrupt_handler(int irq, void *dev_id);
113 static u_char xd_setup_dma (u_char opcode,u_char *buffer,u_int count);
114 static 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);
115 static void xd_watchdog (unsigned long unused);
116 static inline u_char xd_waitport (u_short port,u_char flags,u_char mask,u_long timeout);
117 static u_int xd_command (u_char *command,u_char mode,u_char *indata,u_char *outdata,u_char *sense,u_long timeout);
119 /* card specific setup and geometry gathering code */
120 static void xd_dtc_init_controller (unsigned int address);
121 static void xd_dtc5150cx_init_drive (u_char drive);
122 static void xd_dtc_init_drive (u_char drive);
123 static void xd_wd_init_controller (unsigned int address);
124 static void xd_wd_init_drive (u_char drive);
125 static void xd_seagate_init_controller (unsigned int address);
126 static void xd_seagate_init_drive (u_char drive);
127 static void xd_omti_init_controller (unsigned int address);
128 static void xd_omti_init_drive (u_char drive);
129 static void xd_xebec_init_controller (unsigned int address);
130 static void xd_xebec_init_drive (u_char drive);
131 static void xd_setparam (u_char command,u_char drive,u_char heads,u_short cylinders,u_short rwrite,u_short wprecomp,u_char ecc);
132 static void xd_override_init_drive (u_char drive);
134 #endif /* _LINUX_XD_H */