ppc64: Don't set Kp bit on SLB
[openbios/afaerber.git] / drivers / ide.h
blobd6c4b9f5d8ab4b6336c9af56da96b650c58039fe
1 #ifndef IDE_H
2 #define IDE_H
4 #include "hdreg.h"
6 /*
7 * legacy ide ports
8 */
9 #define IDEREG_DATA 0x00
10 #define IDEREG_ERROR 0x01
11 #define IDEREG_FEATURE IDEREG_ERROR
12 #define IDEREG_NSECTOR 0x02
13 #define IDEREG_SECTOR 0x03
14 #define IDEREG_LCYL 0x04
15 #define IDEREG_HCYL 0x05
16 #define IDEREG_CURRENT 0x06
17 #define IDEREG_STATUS 0x07
18 #define IDEREG_COMMAND IDEREG_STATUS
19 #define IDEREG_CONTROL 0x08
20 #define IDEREG_ASTATUS IDEREG_CONTROL
23 * device control bits
25 #define IDECON_NIEN 0x02
26 #define IDECON_SRST 0x04
29 * device head bits
31 #define IDEHEAD_LBA 0x40
32 #define IDEHEAD_DEV0 0x00
33 #define IDEHEAD_DEV1 0x10
36 * status bytes
38 #define ERR_STAT 0x01
39 #define DRQ_STAT 0x08
40 #define SEEK_STAT 0x10
41 #define WRERR_STAT 0x20
42 #define READY_STAT 0x40
43 #define BUSY_STAT 0x80
45 #define IREASON_CD 0x01
46 #define IREASON_IO 0x02
49 * ATA opcodes
51 #define WIN_READ 0x20
52 #define WIN_READ_EXT 0x24
53 #define WIN_IDENTIFY 0xEC
54 #define WIN_PACKET 0xA0
55 #define WIN_IDENTIFY_PACKET 0xA1
58 * ATAPI opcodes
60 #define ATAPI_TUR 0x00
61 #define ATAPI_READ_10 0x28
62 #define ATAPI_REQ_SENSE 0x03
63 #define ATAPI_START_STOP_UNIT 0x1b
64 #define ATAPI_READ_CAPACITY 0x25
67 * atapi sense keys
69 #define ATAPI_SENSE_NOT_READY 0x02
72 * supported device types
74 enum {
75 ide_type_unknown,
76 ide_type_ata,
77 ide_type_atapi,
80 enum {
81 ide_media_floppy = 0x00,
82 ide_media_cdrom = 0x05,
83 ide_media_optical = 0x07,
84 ide_media_disk = 0x20,
88 * drive addressing
90 enum {
91 ide_chs = 1,
92 ide_lba28,
93 ide_lba48,
97 * simple ata command that works for everything (except 48-bit lba commands)
99 struct ata_command {
100 unsigned char *buffer;
101 unsigned int buflen;
104 * data register
106 unsigned char data;
107 unsigned char feature;
108 unsigned char nsector;
109 unsigned char sector;
110 unsigned char lcyl;
111 unsigned char hcyl;
112 unsigned char device_head;
113 unsigned char command;
114 unsigned char control;
117 * or tasklet, just for lba48 for now (above could be scrapped)
119 unsigned char task[10];
122 * output
124 unsigned char stat;
125 unsigned int bytes;
128 struct atapi_command {
129 unsigned char cdb[12];
130 unsigned char *buffer;
131 unsigned int buflen;
132 unsigned char data_direction;
134 unsigned char stat;
135 unsigned char sense_valid;
136 struct request_sense sense;
137 unsigned char old_cdb;
140 struct ide_channel;
142 struct ide_drive {
143 char unit; /* 0: master, 1: slave */
144 char present; /* there or not */
145 char type; /* ata or atapi */
146 char media; /* disk, cdrom, etc */
147 char addressing; /* chs/lba28/lba48 */
149 char model[41]; /* name */
150 int nr;
152 unsigned long sectors;
154 unsigned int max_sectors;
157 * for legacy chs crap
159 unsigned int cyl;
160 unsigned int head;
161 unsigned int sect;
163 unsigned int bs; /* block size */
165 struct ide_channel *channel;
168 struct ide_channel {
170 char name[32];
171 struct ide_channel *next;
174 * either mmio or io_regs is set to indicate mmio or not
176 unsigned long mmio;
177 int io_regs[10];
180 * can be set to a mmio hook, default it legacy outb/inb
182 void (*obide_outb)(struct ide_channel *chan,
183 unsigned char addr, unsigned int port);
184 unsigned char (*obide_inb)(struct ide_channel *chan,
185 unsigned int port);
186 void (*obide_insw)(struct ide_channel *chan,
187 unsigned int port, unsigned char *addr,
188 unsigned int count);
189 void (*obide_outsw)(struct ide_channel *chan,
190 unsigned int port, unsigned char *addr,
191 unsigned int count);
193 struct ide_drive drives[2];
194 char selected;
195 char present;
198 * only one can be busy per channel
200 struct ata_command ata_cmd;
201 struct atapi_command atapi_cmd;
205 enum {
206 atapi_ddir_none,
207 atapi_ddir_read,
208 atapi_ddir_write,
211 static int ob_ide_atapi_request_sense(struct ide_drive *drive);
213 #endif