1 #ifndef _LINUX_HDREG_H
2 #define _LINUX_HDREG_H
3
4 #include <linux/config.h>
5
6 /*
7 * This file contains some defines for the AT-hd-controller.
8 * Various sources. Check out some definitions (see comments with
9 * a ques).
10 */
11
12 /* Hd controller regs. Ref: IBM AT Bios-listing */
13 /* For a second IDE interface, xor all addresses with 0x80 */
14 #define HD_DATA 0x1f0 /* _CTL when writing */
15 #define HD_ERROR 0x1f1 /* see err-bits */
16 #define HD_NSECTOR 0x1f2 /* nr of sectors to read/write */
17 #define HD_SECTOR 0x1f3 /* starting sector */
18 #define HD_LCYL 0x1f4 /* starting cylinder */
19 #define HD_HCYL 0x1f5 /* high byte of starting cyl */
20 #define HD_CURRENT 0x1f6 /* 101dhhhh , d=drive, hhhh=head */
21 #define HD_STATUS 0x1f7 /* see status-bits */
22 #define HD_FEATURE HD_ERROR /* same io address, read=error, write=feature */
23 #define HD_PRECOMP HD_FEATURE /* obsolete use of this port - predates IDE */
24 #define HD_COMMAND HD_STATUS /* same io address, read=status, write=cmd */
25
26 #define HD_CMD 0x3f6 /* used for resets */
27 #define HD_ALTSTATUS 0x3f6 /* same as HD_STATUS but doesn't clear irq */
28
29 /* Bits of HD_STATUS */
30 #define ERR_STAT 0x01
31 #define INDEX_STAT 0x02
32 #define ECC_STAT 0x04 /* Corrected error */
33 #define DRQ_STAT 0x08
34 #define SEEK_STAT 0x10
35 #define WRERR_STAT 0x20
36 #define READY_STAT 0x40
37 #define BUSY_STAT 0x80
38
39 /* Values for HD_COMMAND */
40 #define WIN_RESTORE 0x10
41 #define WIN_READ 0x20
42 #define WIN_WRITE 0x30
43 #define WIN_VERIFY 0x40
44 #define WIN_FORMAT 0x50
45 #define WIN_INIT 0x60
46 #define WIN_SEEK 0x70
47 #define WIN_DIAGNOSE 0x90
48 #define WIN_SPECIFY 0x91
49 #define WIN_SETIDLE1 0xE3
50 #define WIN_SETIDLE2 0x97
51
52 #define WIN_PIDENTIFY 0xA1 /* identify ATA-PI device */
53 #define WIN_MULTREAD 0xC4 /* read multiple sectors */
54 #define WIN_MULTWRITE 0xC5 /* write multiple sectors */
55 #define WIN_SETMULT 0xC6 /* enable read multiple */
56 #define WIN_IDENTIFY 0xEC /* ask drive to identify itself */
57 #define WIN_SETFEATURES 0xEF /* set special drive features */
58
59 /* Bits for HD_ERROR */
60 #define MARK_ERR 0x01 /* Bad address mark */
61 #define TRK0_ERR 0x02 /* couldn't find track 0 */
62 #define ABRT_ERR 0x04 /* Command aborted */
63 #define ID_ERR 0x10 /* ID field not found */
64 #define ECC_ERR 0x40 /* Uncorrectable ECC error */
65 #define BBD_ERR 0x80 /* block marked bad */
66
67 struct hd_geometry {
68 unsigned char heads;
69 unsigned char sectors;
70 unsigned short cylinders;
71 unsigned long start;
72 };
73
74 /* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x30n/0x31n */
75 #define HDIO_GETGEO 0x301 /* get device geometry */
76 #define HDIO_REQ HDIO_GETGEO /* obsolete, use HDIO_GETGEO */
77 #define HDIO_GET_UNMASKINTR 0x302 /* get current unmask setting */
78 #define HDIO_GET_MULTCOUNT 0x304 /* get current IDE blockmode setting */
79 #define HDIO_GET_IDENTITY 0x307 /* get IDE identification info */
80 #define HDIO_GET_KEEPSETTINGS 0x308 /* get keep-settings-on-reset flag */
81 #define HDIO_GET_CHIPSET 0x309 /* get current interface type setting */
82 #define HDIO_DRIVE_CMD 0x31f /* execute a special drive command */
83
84 /* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x32n/0x33n */
85 #define HDIO_SET_MULTCOUNT 0x321 /* set IDE blockmode */
86 #define HDIO_SET_UNMASKINTR 0x322 /* permit other irqs during I/O */
87 #define HDIO_SET_KEEPSETTINGS 0x323 /* keep ioctl settings on reset */
88 #define HDIO_SET_CHIPSET 0x324 /* optimise driver for interface type */
89
90 /* structure returned by HDIO_GET_IDENTITY, as per ANSI ATA2 rev.2f spec */
91 struct hd_driveid {
92 unsigned short config; /* lots of obsolete bit flags */
93 unsigned short cyls; /* "physical" cyls */
94 unsigned short reserved2; /* reserved (word 2) */
95 unsigned short heads; /* "physical" heads */
96 unsigned short track_bytes; /* unformatted bytes per track */
97 unsigned short sector_bytes; /* unformatted bytes per sector */
98 unsigned short sectors; /* "physical" sectors per track */
99 unsigned short vendor0; /* vendor unique */
100 unsigned short vendor1; /* vendor unique */
101 unsigned short vendor2; /* vendor unique */
102 unsigned char serial_no[20]; /* 0 = not_specified */
103 unsigned short buf_type;
104 unsigned short buf_size; /* 512 byte increments; 0 = not_specified */
105 unsigned short ecc_bytes; /* for r/w long cmds; 0 = not_specified */
106 unsigned char fw_rev[8]; /* 0 = not_specified */
107 unsigned char model[40]; /* 0 = not_specified */
108 unsigned char max_multsect; /* 0=not_implemented */
109 unsigned char vendor3; /* vendor unique */
110 unsigned short dword_io; /* 0=not_implemented; 1=implemented */
111 unsigned char vendor4; /* vendor unique */
112 unsigned char capability; /* bits 0:DMA 1:LBA 2:IORDYsw 3:IORDYsup*/
113 unsigned short reserved50; /* reserved (word 50) */
114 unsigned char vendor5; /* vendor unique */
115 unsigned char tPIO; /* 0=slow, 1=medium, 2=fast */
116 unsigned char vendor6; /* vendor unique */
117 unsigned char tDMA; /* 0=slow, 1=medium, 2=fast */
118 unsigned short field_valid; /* bits 0:cur_ok 1:eide_ok */
119 unsigned short cur_cyls; /* logical cylinders */
120 unsigned short cur_heads; /* logical heads */
121 unsigned short cur_sectors; /* logical sectors per track */
122 unsigned short cur_capacity0; /* logical total sectors on drive */
123 unsigned short cur_capacity1; /* (2 words, misaligned int) */
124 unsigned char multsect; /* current multiple sector count */
125 unsigned char multsect_valid; /* when (bit0==1) multsect is ok */
126 unsigned int lba_capacity; /* total number of sectors */
127 unsigned short dma_1word; /* single-word dma info */
128 unsigned short dma_mword; /* multiple-word dma info */
129 unsigned short eide_pio_modes; /* bits 0:mode3 1:mode4 */
130 unsigned short eide_dma_min; /* min mword dma cycle time (ns) */
131 unsigned short eide_dma_time; /* recommended mword dma cycle time (ns) */
132 unsigned short eide_pio; /* min cycle time (ns), no IORDY */
133 unsigned short eide_pio_iordy; /* min cycle time (ns), with IORDY */
134 unsigned short reserved69; /* reserved (word 69) */
135 unsigned short reserved70; /* reserved (word 70) */
136 /* unsigned short reservedxx[57];*/ /* reserved (words 71-127) */
137 /* unsigned short vendor7 [32];*/ /* vendor unique (words 128-159) */
138 /* unsigned short reservedyy[96];*/ /* reserved (words 160-255) */
139 };
140
141 /*
142 * These routines are used for kernel command line parameters from main.c:
143 */
144 #ifdef CONFIG_BLK_DEV_HD
145 void hd_setup(char *, int *);
146 #endif /* CONFIG_BLK_DEV_HD */
147 #ifdef CONFIG_BLK_DEV_IDE
148 void ide_setup(char *, int *);
149 void hda_setup(char *, int *);
150 void hdb_setup(char *, int *);
151 void hdc_setup(char *, int *);
152 void hdd_setup(char *, int *);
153 #endif /* CONFIG_BLK_DEV_IDE */
154
155 #endif /* _LINUX_HDREG_H */