1#ifndef _IDE_H
2#define _IDE_H
3/*
4 *  linux/include/linux/ide.h
5 *
6 *  Copyright (C) 1994-1998  Linus Torvalds & authors
7 */
8
9#include <linux/config.h>
10#include <linux/init.h>
11#include <linux/ioport.h>
12#include <linux/hdreg.h>
13#include <linux/hdsmart.h>
14#include <linux/blkdev.h>
15#include <linux/proc_fs.h>
16#include <linux/devfs_fs_kernel.h>
17#include <asm/hdreg.h>
18
19/*
20 * This is the multiple IDE interface driver, as evolved from hd.c.
21 * It supports up to four IDE interfaces, on one or more IRQs (usually 14 & 15).
22 * There can be up to two drives per interface, as per the ATA-2 spec.
23 *
24 * Primary i/f:    ide0: major=3;  (hda)         minor=0; (hdb)         minor=64
25 * Secondary i/f:  ide1: major=22; (hdc or hd1a) minor=0; (hdd or hd1b) minor=64
26 * Tertiary i/f:   ide2: major=33; (hde)         minor=0; (hdf)         minor=64
27 * Quaternary i/f: ide3: major=34; (hdg)         minor=0; (hdh)         minor=64
28 */
29
30/******************************************************************************
31 * IDE driver configuration options (play with these as desired):
32 *
33 * REALLY_SLOW_IO can be defined in ide.c and ide-cd.c, if necessary
34 */
35#undef REALLY_FAST_IO			/* define if ide ports are perfect */
36#define INITIAL_MULT_COUNT	0	/* off=0; on=2,4,8,16,32, etc.. */
37
38#ifndef SUPPORT_SLOW_DATA_PORTS		    /* 1 to support slow data ports */
39#define SUPPORT_SLOW_DATA_PORTS	1	/* 0 to reduce kernel size */
40#endif
41#ifndef SUPPORT_VLB_SYNC		    /* 1 to support weird 32-bit chips */
42#define SUPPORT_VLB_SYNC	1	/* 0 to reduce kernel size */
43#endif
44#ifndef DISK_RECOVERY_TIME		    /* off=0; on=access_delay_time */
45#define DISK_RECOVERY_TIME	0	/*  for hardware that needs it */
46#endif
47#ifndef OK_TO_RESET_CONTROLLER		    /* 1 needed for good error recovery */
48#define OK_TO_RESET_CONTROLLER	1	/* 0 for use with AH2372A/B interface */
49#endif
50#ifndef FANCY_STATUS_DUMPS		    /* 1 for human-readable drive errors */
51#define FANCY_STATUS_DUMPS	1	/* 0 to reduce kernel size */
52#endif
53
54#ifdef CONFIG_BLK_DEV_CMD640
55#endif  /* CONFIG_BLK_DEV_CMD640 */
56
57#ifndef DISABLE_IRQ_NOSYNC
58#define DISABLE_IRQ_NOSYNC	0
59#endif
60
61/*
62 * IDE_DRIVE_CMD is used to implement many features of the hdparm utility
63 */
64#define IDE_DRIVE_CMD			99	/* (magic) undef to reduce kernel size*/
65
66#define IDE_DRIVE_TASK			98
67
68/*
69 * IDE_DRIVE_TASKFILE is used to implement many features needed for raw tasks
70 */
71#define IDE_DRIVE_TASKFILE		97
72
73/*
74 *  "No user-serviceable parts" beyond this point  :)
75 *****************************************************************************/
76
77typedef unsigned char	byte;	/* used everywhere */
78
79/*
80 * Probably not wise to fiddle with these
81 */
82#define ERROR_MAX	8	/* Max read/write errors per sector */
83#define ERROR_RESET	3	/* Reset controller every 4th retry */
84#define ERROR_RECAL	1	/* Recalibrate every 2nd retry */
85
86/*
87 * state flags
88 */
89#define DMA_PIO_RETRY	1	/* retrying in PIO */
90
91/*
92 * Ensure that various configuration flags have compatible settings
93 */
94#ifdef REALLY_SLOW_IO
95#undef REALLY_FAST_IO
96#endif
97
98#define HWIF(drive)		((ide_hwif_t *)((drive)->hwif))
99#define HWGROUP(drive)		((ide_hwgroup_t *)(HWIF(drive)->hwgroup))
100
101/*
102 * Definitions for accessing IDE controller registers
103 */
104#define IDE_NR_PORTS		(10)
105
106#define IDE_DATA_OFFSET		(0)
107#define IDE_ERROR_OFFSET	(1)
108#define IDE_NSECTOR_OFFSET	(2)
109#define IDE_SECTOR_OFFSET	(3)
110#define IDE_LCYL_OFFSET		(4)
111#define IDE_HCYL_OFFSET		(5)
112#define IDE_SELECT_OFFSET	(6)
113#define IDE_STATUS_OFFSET	(7)
114#define IDE_CONTROL_OFFSET	(8)
115#define IDE_IRQ_OFFSET		(9)
116
117#define IDE_FEATURE_OFFSET	IDE_ERROR_OFFSET
118#define IDE_COMMAND_OFFSET	IDE_STATUS_OFFSET
119
120#define IDE_DATA_OFFSET_HOB	(0)
121#define IDE_ERROR_OFFSET_HOB	(1)
122#define IDE_NSECTOR_OFFSET_HOB	(2)
123#define IDE_SECTOR_OFFSET_HOB	(3)
124#define IDE_LCYL_OFFSET_HOB	(4)
125#define IDE_HCYL_OFFSET_HOB	(5)
126#define IDE_SELECT_OFFSET_HOB	(6)
127#define IDE_CONTROL_OFFSET_HOB	(7)
128
129#define IDE_FEATURE_OFFSET_HOB	IDE_ERROR_OFFSET_HOB
130
131#define IDE_DATA_REG		(HWIF(drive)->io_ports[IDE_DATA_OFFSET])
132#define IDE_ERROR_REG		(HWIF(drive)->io_ports[IDE_ERROR_OFFSET])
133#define IDE_NSECTOR_REG		(HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET])
134#define IDE_SECTOR_REG		(HWIF(drive)->io_ports[IDE_SECTOR_OFFSET])
135#define IDE_LCYL_REG		(HWIF(drive)->io_ports[IDE_LCYL_OFFSET])
136#define IDE_HCYL_REG		(HWIF(drive)->io_ports[IDE_HCYL_OFFSET])
137#define IDE_SELECT_REG		(HWIF(drive)->io_ports[IDE_SELECT_OFFSET])
138#define IDE_STATUS_REG		(HWIF(drive)->io_ports[IDE_STATUS_OFFSET])
139#define IDE_CONTROL_REG		(HWIF(drive)->io_ports[IDE_CONTROL_OFFSET])
140#define IDE_IRQ_REG		(HWIF(drive)->io_ports[IDE_IRQ_OFFSET])
141
142#define IDE_DATA_REG_HOB	(HWIF(drive)->io_ports[IDE_DATA_OFFSET])
143#define IDE_ERROR_REG_HOB	(HWIF(drive)->io_ports[IDE_ERROR_OFFSET])
144#define IDE_NSECTOR_REG_HOB	(HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET])
145#define IDE_SECTOR_REG_HOB	(HWIF(drive)->io_ports[IDE_SECTOR_OFFSET])
146#define IDE_LCYL_REG_HOB	(HWIF(drive)->io_ports[IDE_LCYL_OFFSET])
147#define IDE_HCYL_REG_HOB	(HWIF(drive)->io_ports[IDE_HCYL_OFFSET])
148#define IDE_SELECT_REG_HOB	(HWIF(drive)->io_ports[IDE_SELECT_OFFSET])
149#define IDE_STATUS_REG_HOB	(HWIF(drive)->io_ports[IDE_STATUS_OFFSET])
150#define IDE_CONTROL_REG_HOB	(HWIF(drive)->io_ports[IDE_CONTROL_OFFSET])
151
152#define IDE_FEATURE_REG		IDE_ERROR_REG
153#define IDE_COMMAND_REG		IDE_STATUS_REG
154#define IDE_ALTSTATUS_REG	IDE_CONTROL_REG
155#define IDE_IREASON_REG		IDE_NSECTOR_REG
156#define IDE_BCOUNTL_REG		IDE_LCYL_REG
157#define IDE_BCOUNTH_REG		IDE_HCYL_REG
158
159#define GET_ERR()		IN_BYTE(IDE_ERROR_REG)
160#define GET_STAT()		IN_BYTE(IDE_STATUS_REG)
161#define GET_ALTSTAT()		IN_BYTE(IDE_CONTROL_REG)
162#define OK_STAT(stat,good,bad)	(((stat)&((good)|(bad)))==(good))
163#define BAD_R_STAT		(BUSY_STAT   | ERR_STAT)
164#define BAD_W_STAT		(BAD_R_STAT  | WRERR_STAT)
165#define BAD_STAT		(BAD_R_STAT  | DRQ_STAT)
166#define DRIVE_READY		(READY_STAT  | SEEK_STAT)
167#define DATA_READY		(DRQ_STAT)
168
169/*
170 * Some more useful definitions
171 */
172#define IDE_MAJOR_NAME	"hd"	/* the same for all i/f; see also genhd.c */
173#define MAJOR_NAME	IDE_MAJOR_NAME
174#define PARTN_BITS	6	/* number of minor dev bits for partitions */
175#define PARTN_MASK	((1<<PARTN_BITS)-1)	/* a useful bit mask */
176#define MAX_DRIVES	2	/* per interface; 2 assumed by lots of code */
177#define CASCADE_DRIVES	8	/* per interface; 8|2 assumed by lots of code */
178#define SECTOR_SIZE	512
179#define SECTOR_WORDS	(SECTOR_SIZE / 4)	/* number of 32bit words per sector */
180#define IDE_LARGE_SEEK(b1,b2,t)	(((b1) > (b2) + (t)) || ((b2) > (b1) + (t)))
181#define IDE_MIN(a,b)	((a)<(b) ? (a):(b))
182#define IDE_MAX(a,b)	((a)>(b) ? (a):(b))
183
184#ifndef SPLIT_WORD
185#  define SPLIT_WORD(W,HB,LB) ((HB)=(W>>8), (LB)=(W-((W>>8)<<8)))
186#endif
187#ifndef MAKE_WORD
188#  define MAKE_WORD(W,HB,LB) ((W)=((HB<<8)+LB))
189#endif
190
191
192/*
193 * Timeouts for various operations:
194 */
195#define WAIT_DRQ	(5*HZ/100)	/* 50msec - spec allows up to 20ms */
196#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
197#define WAIT_READY	(5*HZ)		/* 5sec - some laptops are very slow */
198#else
199#define WAIT_READY	(3*HZ/100)	/* 30msec - should be instantaneous */
200#endif /* CONFIG_APM || CONFIG_APM_MODULE */
201#define WAIT_PIDENTIFY	(10*HZ)	/* 10sec  - should be less than 3ms (?), if all ATAPI CD is closed at boot */
202#define WAIT_WORSTCASE	(30*HZ)	/* 30sec  - worst case when spinning up */
203#define WAIT_CMD	(10*HZ)	/* 10sec  - maximum wait for an IRQ to happen */
204#define WAIT_MIN_SLEEP	(2*HZ/100)	/* 20msec - minimum sleep time */
205
206#define SELECT_DRIVE(hwif,drive)				\
207{								\
208	if (hwif->selectproc)					\
209		hwif->selectproc(drive);			\
210	OUT_BYTE((drive)->select.all, hwif->io_ports[IDE_SELECT_OFFSET]); \
211}
212
213#define SELECT_INTERRUPT(hwif,drive)				\
214{								\
215	if (hwif->intrproc)					\
216		hwif->intrproc(drive);				\
217	else							\
218		OUT_BYTE((drive)->ctl|2, hwif->io_ports[IDE_CONTROL_OFFSET]);	\
219}
220
221#define SELECT_MASK(hwif,drive,mask)				\
222{								\
223	if (hwif->maskproc)					\
224		hwif->maskproc(drive,mask);			\
225}
226
227#define SELECT_READ_WRITE(hwif,drive,func)			\
228{								\
229	if (hwif->rwproc)					\
230		hwif->rwproc(drive,func);			\
231}
232
233#define QUIRK_LIST(hwif,drive)					\
234{								\
235	if (hwif->quirkproc)					\
236		(drive)->quirk_list = hwif->quirkproc(drive);	\
237}
238
239#define HOST(hwif,chipset)					\
240{								\
241	return ((hwif)->chipset == chipset) ? 1 : 0;		\
242}
243
244#define IDE_DEBUG(lineno) \
245	printk("%s,%s,line=%d\n", __FILE__, __FUNCTION__, (lineno))
246
247/*
248 * Check for an interrupt and acknowledge the interrupt status
249 */
250struct hwif_s;
251typedef int (ide_ack_intr_t)(struct hwif_s *);
252
253#ifndef NO_DMA
254#define NO_DMA  255
255#endif
256
257/*
258 * hwif_chipset_t is used to keep track of the specific hardware
259 * chipset used by each IDE interface, if known.
260 */
261typedef enum {	ide_unknown,	ide_generic,	ide_pci,
262		ide_cmd640,	ide_dtc2278,	ide_ali14xx,
263		ide_qd65xx,	ide_umc8672,	ide_ht6560b,
264		ide_pdc4030,	ide_rz1000,	ide_trm290,
265		ide_cmd646,	ide_cy82c693,	ide_4drives,
266		ide_pmac,	ide_etrax100
267} hwif_chipset_t;
268
269/*
270 * Structure to hold all information about the location of this port
271 */
272typedef struct hw_regs_s {
273	ide_ioreg_t	io_ports[IDE_NR_PORTS];	/* task file registers */
274	int		irq;			/* our irq number */
275	int		dma;			/* our dma entry */
276	ide_ack_intr_t	*ack_intr;		/* acknowledge interrupt */
277	void		*priv;			/* interface specific data */
278	hwif_chipset_t  chipset;
279} hw_regs_t;
280
281/*
282 * Register new hardware with ide
283 */
284int ide_register_hw(hw_regs_t *hw, struct hwif_s **hwifp);
285
286/*
287 * Set up hw_regs_t structure before calling ide_register_hw (optional)
288 */
289void ide_setup_ports(	hw_regs_t *hw,
290			ide_ioreg_t base,
291			int *offsets,
292			ide_ioreg_t ctrl,
293			ide_ioreg_t intr,
294			ide_ack_intr_t *ack_intr,
295			int irq);
296
297#include <asm/ide.h>
298
299/*
300 * If the arch-dependant ide.h did not declare/define any OUT_BYTE
301 * or IN_BYTE functions, we make some defaults here.
302 */
303
304#ifndef HAVE_ARCH_OUT_BYTE
305#ifdef REALLY_FAST_IO
306#define OUT_BYTE(b,p)          outb((b),(p))
307#define OUT_WORD(w,p)          outw((w),(p))
308#else
309#define OUT_BYTE(b,p)          outb_p((b),(p))
310#define OUT_WORD(w,p)          outw_p((w),(p))
311#endif
312#endif
313
314#ifndef HAVE_ARCH_IN_BYTE
315#ifdef REALLY_FAST_IO
316#define IN_BYTE(p)             (byte)inb(p)
317#define IN_WORD(p)             (short)inw(p)
318#else
319#define IN_BYTE(p)             (byte)inb_p(p)
320#define IN_WORD(p)             (short)inw_p(p)
321#endif
322#endif
323
324/*
325 * Now for the data we need to maintain per-drive:  ide_drive_t
326 */
327
328#define ide_scsi	0x21
329#define ide_disk	0x20
330#define ide_optical	0x7
331#define ide_cdrom	0x5
332#define ide_tape	0x1
333#define ide_floppy	0x0
334
335typedef union {
336	unsigned all			: 8;	/* all of the bits together */
337	struct {
338		unsigned set_geometry	: 1;	/* respecify drive geometry */
339		unsigned recalibrate	: 1;	/* seek to cyl 0      */
340		unsigned set_multmode	: 1;	/* set multmode count */
341		unsigned set_tune	: 1;	/* tune interface for drive */
342		unsigned reserved	: 4;	/* unused */
343	} b;
344} special_t;
345
346typedef struct ide_drive_s {
347	request_queue_t		 queue;	/* request queue */
348	struct ide_drive_s 	*next;	/* circular list of hwgroup drives */
349	unsigned long sleep;		/* sleep until this time */
350	unsigned long service_start;	/* time we started last request */
351	unsigned long service_time;	/* service time of last request */
352	unsigned long timeout;		/* max time to wait for irq */
353	special_t	special;	/* special action flags */
354	byte     keep_settings;		/* restore settings after drive reset */
355	byte     using_dma;		/* disk is using dma for read/write */
356	byte	 retry_pio;		/* retrying dma capable host in pio */
357	byte	 state;			/* retry state */
358	byte     waiting_for_dma;	/* dma currently in progress */
359	byte     unmask;		/* flag: okay to unmask other irqs */
360	byte     slow;			/* flag: slow data port */
361	byte     bswap;			/* flag: byte swap data */
362	byte     dsc_overlap;		/* flag: DSC overlap */
363	byte     nice1;			/* flag: give potential excess bandwidth */
364	unsigned present	: 1;	/* drive is physically present */
365	unsigned noprobe 	: 1;	/* from:  hdx=noprobe */
366	unsigned busy		: 1;	/* currently doing revalidate_disk() */
367	unsigned removable	: 1;	/* 1 if need to do check_media_change */
368	unsigned forced_geom	: 1;	/* 1 if hdx=c,h,s was given at boot */
369	unsigned no_unmask	: 1;	/* disallow setting unmask bit */
370	unsigned no_io_32bit	: 1;	/* disallow enabling 32bit I/O */
371	unsigned nobios		: 1;	/* flag: do not probe bios for drive */
372	unsigned revalidate	: 1;	/* request revalidation */
373	unsigned atapi_overlap	: 1;	/* flag: ATAPI overlap (not supported) */
374	unsigned nice0		: 1;	/* flag: give obvious excess bandwidth */
375	unsigned nice2		: 1;	/* flag: give a share in our own bandwidth */
376	unsigned doorlocking	: 1;	/* flag: for removable only: door lock/unlock works */
377	unsigned autotune	: 2;	/* 1=autotune, 2=noautotune, 0=default */
378	unsigned remap_0_to_1	: 2;	/* 0=remap if ezdrive, 1=remap, 2=noremap */
379	unsigned ata_flash	: 1;	/* 1=present, 0=default */
380	unsigned	addressing;	/* : 2; 0=28-bit, 1=48-bit, 2=64-bit */
381	byte		scsi;		/* 0=default, 1=skip current ide-subdriver for ide-scsi emulation */
382	byte		media;		/* disk, cdrom, tape, floppy, ... */
383	select_t	select;		/* basic drive/head select reg value */
384	byte		ctl;		/* "normal" value for IDE_CONTROL_REG */
385	byte		ready_stat;	/* min status value for drive ready */
386	byte		mult_count;	/* current multiple sector setting */
387	byte 		mult_req;	/* requested multiple sector setting */
388	byte 		tune_req;	/* requested drive tuning setting */
389	byte		io_32bit;	/* 0=16-bit, 1=32-bit, 2/3=32bit+sync */
390	byte		bad_wstat;	/* used for ignoring WRERR_STAT */
391	byte		nowerr;		/* used for ignoring WRERR_STAT */
392	byte		sect0;		/* offset of first sector for DM6:DDO */
393	unsigned int	usage;		/* current "open()" count for drive */
394	byte 		head;		/* "real" number of heads */
395	byte		sect;		/* "real" sectors per track */
396	byte		bios_head;	/* BIOS/fdisk/LILO number of heads */
397	byte		bios_sect;	/* BIOS/fdisk/LILO sectors per track */
398	unsigned int	bios_cyl;	/* BIOS/fdisk/LILO number of cyls */
399	unsigned int	cyl;		/* "real" number of cyls */
400	unsigned long	capacity;	/* total number of sectors */
401	unsigned long long capacity48;	/* total number of sectors */
402	unsigned int	drive_data;	/* for use by tuneproc/selectproc as needed */
403	void		  *hwif;	/* actually (ide_hwif_t *) */
404	wait_queue_head_t wqueue;	/* used to wait for drive in open() */
405	struct hd_driveid *id;		/* drive model identification info */
406	struct hd_struct  *part;	/* drive partition table */
407	char		name[4];	/* drive name, such as "hda" */
408	void 		*driver;	/* (ide_driver_t *) */
409	void		*driver_data;	/* extra driver data */
410	devfs_handle_t	de;		/* directory for device */
411	struct proc_dir_entry *proc;	/* /proc/ide/ directory entry */
412	void		*settings;	/* /proc/ide/ drive settings */
413	char		driver_req[10];	/* requests specific driver */
414	int		last_lun;	/* last logical unit */
415	int		forced_lun;	/* if hdxlun was given at boot */
416	int		lun;		/* logical unit */
417	int		crc_count;	/* crc counter to reduce drive speed */
418	byte		quirk_list;	/* drive is considered quirky if set for a specific host */
419	byte		suspend_reset;	/* drive suspend mode flag, soft-reset recovers */
420	byte		init_speed;	/* transfer rate set at boot */
421	byte		current_speed;	/* current transfer rate set */
422	byte		dn;		/* now wide spread use */
423	byte		wcache;		/* status of write cache */
424	byte		acoustic;	/* acoustic management */
425	unsigned int	failures;	/* current failure count */
426	unsigned int	max_failures;	/* maximum allowed failure count */
427} ide_drive_t;
428
429/*
430 * An ide_dmaproc_t() initiates/aborts DMA read/write operations on a drive.
431 *
432 * The caller is assumed to have selected the drive and programmed the drive's
433 * sector address using CHS or LBA.  All that remains is to prepare for DMA
434 * and then issue the actual read/write DMA/PIO command to the drive.
435 *
436 * Returns 0 if all went well.
437 * Returns 1 if DMA read/write could not be started, in which case the caller
438 * should either try again later, or revert to PIO for the current request.
439 */
440typedef enum {	ide_dma_read,	ide_dma_write,		ide_dma_begin,
441		ide_dma_end,	ide_dma_check,		ide_dma_on,
442		ide_dma_off,	ide_dma_off_quietly,	ide_dma_test_irq,
443		ide_dma_bad_drive,			ide_dma_good_drive,
444		ide_dma_verbose,			ide_dma_retune,
445		ide_dma_lostirq,			ide_dma_timeout
446} ide_dma_action_t;
447
448typedef int (ide_dmaproc_t)(ide_dma_action_t, ide_drive_t *);
449
450/*
451 * An ide_ideproc_t() performs CPU-polled transfers to/from a drive.
452 * Arguments are: the drive, the buffer pointer, and the length (in bytes or
453 * words depending on if it's an IDE or ATAPI call).
454 *
455 * If it is not defined for a controller, standard-code is used from ide.c.
456 *
457 * Controllers which are not memory-mapped in the standard way need to
458 * override that mechanism using this function to work.
459 *
460 */
461typedef enum { ideproc_ide_input_data,    ideproc_ide_output_data,
462	       ideproc_atapi_input_bytes, ideproc_atapi_output_bytes
463} ide_ide_action_t;
464
465typedef void (ide_ideproc_t)(ide_ide_action_t, ide_drive_t *, void *, unsigned int);
466
467/*
468 * An ide_tuneproc_t() is used to set the speed of an IDE interface
469 * to a particular PIO mode.  The "byte" parameter is used
470 * to select the PIO mode by number (0,1,2,3,4,5), and a value of 255
471 * indicates that the interface driver should "auto-tune" the PIO mode
472 * according to the drive capabilities in drive->id;
473 *
474 * Not all interface types support tuning, and not all of those
475 * support all possible PIO settings.  They may silently ignore
476 * or round values as they see fit.
477 */
478typedef void (ide_tuneproc_t) (ide_drive_t *, byte);
479typedef int (ide_speedproc_t) (ide_drive_t *, byte);
480
481/*
482 * This is used to provide support for strange interfaces
483 */
484typedef void (ide_selectproc_t) (ide_drive_t *);
485typedef void (ide_resetproc_t) (ide_drive_t *);
486typedef int (ide_quirkproc_t) (ide_drive_t *);
487typedef void (ide_intrproc_t) (ide_drive_t *);
488typedef void (ide_maskproc_t) (ide_drive_t *, int);
489typedef void (ide_rw_proc_t) (ide_drive_t *, ide_dma_action_t);
490
491/*
492 * ide soft-power support
493 */
494typedef int (ide_busproc_t) (ide_drive_t *, int);
495
496#define IDE_CHIPSET_PCI_MASK	\
497    ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx))
498#define IDE_CHIPSET_IS_PCI(c)	((IDE_CHIPSET_PCI_MASK >> (c)) & 1)
499
500#ifdef CONFIG_BLK_DEV_IDEPCI
501typedef struct ide_pci_devid_s {
502	unsigned short	vid;
503	unsigned short	did;
504} ide_pci_devid_t;
505
506#define IDE_PCI_DEVID_NULL	((ide_pci_devid_t){0,0})
507#define IDE_PCI_DEVID_EQ(a,b)	(a.vid == b.vid && a.did == b.did)
508#endif /* CONFIG_BLK_DEV_IDEPCI */
509
510typedef struct hwif_s {
511	struct hwif_s	*next;		/* for linked-list in ide_hwgroup_t */
512	void		*hwgroup;	/* actually (ide_hwgroup_t *) */
513	ide_ioreg_t	io_ports[IDE_NR_PORTS];	/* task file registers */
514	hw_regs_t	hw;		/* Hardware info */
515	ide_drive_t	drives[MAX_DRIVES];	/* drive info */
516	struct gendisk	*gd;		/* gendisk structure */
517	ide_tuneproc_t	*tuneproc;	/* routine to tune PIO mode for drives */
518	ide_speedproc_t	*speedproc;	/* routine to retune DMA modes for drives */
519	ide_selectproc_t *selectproc;	/* tweaks hardware to select drive */
520	ide_resetproc_t	*resetproc;	/* routine to reset controller after a disk reset */
521	ide_intrproc_t	*intrproc;	/* special interrupt handling for shared pci interrupts */
522	ide_maskproc_t	*maskproc;	/* special host masking for drive selection */
523	ide_quirkproc_t	*quirkproc;	/* check host's drive quirk list */
524	ide_rw_proc_t	*rwproc;	/* adjust timing based upon rq->cmd direction */
525	ide_ideproc_t   *ideproc;       /* CPU-polled transfer routine */
526	ide_dmaproc_t	*dmaproc;	/* dma read/write/abort routine */
527	unsigned int	*dmatable_cpu;	/* dma physical region descriptor table (cpu view) */
528	dma_addr_t	dmatable_dma;	/* dma physical region descriptor table (dma view) */
529	struct scatterlist *sg_table;	/* Scatter-gather list used to build the above */
530	int sg_nents;			/* Current number of entries in it */
531	int sg_dma_direction;		/* dma transfer direction */
532	int sg_dma_active;		/* is it in use */
533	struct hwif_s	*mate;		/* other hwif from same PCI chip */
534	unsigned long	dma_base;	/* base addr for dma ports */
535	unsigned	dma_extra;	/* extra addr for dma ports */
536	unsigned long	config_data;	/* for use by chipset-specific code */
537	unsigned long	select_data;	/* for use by chipset-specific code */
538	struct proc_dir_entry *proc;	/* /proc/ide/ directory entry */
539	int		irq;		/* our irq number */
540	byte		major;		/* our major number */
541	char 		name[6];	/* name of interface, eg. "ide0" */
542	byte		index;		/* 0 for ide0; 1 for ide1; ... */
543	hwif_chipset_t	chipset;	/* sub-module for tuning.. */
544	unsigned	noprobe    : 1;	/* don't probe for this interface */
545	unsigned	present    : 1;	/* this interface exists */
546	unsigned	serialized : 1;	/* serialized operation with mate hwif */
547	unsigned	sharing_irq: 1;	/* 1 = sharing irq with another hwif */
548	unsigned	reset      : 1;	/* reset after probe */
549	unsigned	autodma    : 1;	/* automatically try to enable DMA at boot */
550	unsigned	udma_four  : 1;	/* 1=ATA-66 capable, 0=default */
551	unsigned	no_highio  : 1; /* don't trust pci dma mask, bounce */
552	byte		channel;	/* for dual-port chips: 0=primary, 1=secondary */
553#ifdef CONFIG_BLK_DEV_IDEPCI
554	struct pci_dev	*pci_dev;	/* for pci chipsets */
555	ide_pci_devid_t	pci_devid;	/* for pci chipsets: {VID,DID} */
556#endif /* CONFIG_BLK_DEV_IDEPCI */
557#if (DISK_RECOVERY_TIME > 0)
558	unsigned long	last_time;	/* time when previous rq was done */
559#endif
560	byte		straight8;	/* Alan's straight 8 check */
561	void		*hwif_data;	/* extra hwif data */
562	ide_busproc_t	*busproc;	/* driver soft-power interface */
563	byte		bus_state;	/* power state of the IDE bus */
564} ide_hwif_t;
565
566/*
567 * Status returned from various ide_ functions
568 */
569typedef enum {
570	ide_stopped,	/* no drive operation was started */
571	ide_started	/* a drive operation was started, and a handler was set */
572} ide_startstop_t;
573
574/*
575 *  internal ide interrupt handler type
576 */
577typedef ide_startstop_t (ide_pre_handler_t)(ide_drive_t *, struct request *);
578typedef ide_startstop_t (ide_handler_t)(ide_drive_t *);
579typedef ide_startstop_t (ide_post_handler_t)(ide_drive_t *);
580
581/*
582 * when ide_timer_expiry fires, invoke a handler of this type
583 * to decide what to do.
584 */
585typedef int (ide_expiry_t)(ide_drive_t *);
586
587typedef struct hwgroup_s {
588	ide_handler_t		*handler;/* irq handler, if active */
589	volatile int		busy;	/* BOOL: protects all fields below */
590	int			sleeping; /* BOOL: wake us up on timer expiry */
591	ide_drive_t		*drive;	/* current drive */
592	ide_hwif_t		*hwif;	/* ptr to current hwif in linked-list */
593	struct request		*rq;	/* current request */
594	struct timer_list	timer;	/* failsafe timer */
595	struct request		wrq;	/* local copy of current write rq */
596	unsigned long		poll_timeout;	/* timeout value during long polls */
597	ide_expiry_t		*expiry;	/* queried upon timeouts */
598} ide_hwgroup_t;
599
600/* structure attached to the request for IDE_TASK_CMDS */
601
602/*
603 * configurable drive settings
604 */
605
606#define TYPE_INT	0
607#define TYPE_INTA	1
608#define TYPE_BYTE	2
609#define TYPE_SHORT	3
610
611#define SETTING_READ	(1 << 0)
612#define SETTING_WRITE	(1 << 1)
613#define SETTING_RW	(SETTING_READ | SETTING_WRITE)
614
615typedef int (ide_procset_t)(ide_drive_t *, int);
616typedef struct ide_settings_s {
617	char			*name;
618	int			rw;
619	int			read_ioctl;
620	int			write_ioctl;
621	int			data_type;
622	int			min;
623	int			max;
624	int			mul_factor;
625	int			div_factor;
626	void			*data;
627	ide_procset_t		*set;
628	int			auto_remove;
629	struct ide_settings_s	*next;
630} ide_settings_t;
631
632void ide_add_setting(ide_drive_t *drive, const char *name, int rw, int read_ioctl, int write_ioctl, int data_type, int min, int max, int mul_factor, int div_factor, void *data, ide_procset_t *set);
633void ide_remove_setting(ide_drive_t *drive, char *name);
634ide_settings_t *ide_find_setting_by_name(ide_drive_t *drive, char *name);
635int ide_read_setting(ide_drive_t *t, ide_settings_t *setting);
636int ide_write_setting(ide_drive_t *drive, ide_settings_t *setting, int val);
637void ide_add_generic_settings(ide_drive_t *drive);
638
639/*
640 * /proc/ide interface
641 */
642typedef struct {
643	const char	*name;
644	mode_t		mode;
645	read_proc_t	*read_proc;
646	write_proc_t	*write_proc;
647} ide_proc_entry_t;
648
649#ifdef CONFIG_PROC_FS
650void proc_ide_create(void);
651void proc_ide_destroy(void);
652void recreate_proc_ide_device(ide_hwif_t *, ide_drive_t *);
653void destroy_proc_ide_device(ide_hwif_t *, ide_drive_t *);
654void destroy_proc_ide_drives(ide_hwif_t *);
655void create_proc_ide_interfaces(void);
656void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p, void *data);
657void ide_remove_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p);
658read_proc_t proc_ide_read_capacity;
659read_proc_t proc_ide_read_geometry;
660
661/*
662 * Standard exit stuff:
663 */
664#define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) \
665{					\
666	len -= off;			\
667	if (len < count) {		\
668		*eof = 1;		\
669		if (len <= 0)		\
670			return 0;	\
671	} else				\
672		len = count;		\
673	*start = page + off;		\
674	return len;			\
675}
676#else
677#define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0;
678#endif
679
680/*
681 * Subdrivers support.
682 */
683#define IDE_SUBDRIVER_VERSION	1
684
685typedef int		(ide_cleanup_proc)(ide_drive_t *);
686typedef int		(ide_standby_proc)(ide_drive_t *);
687typedef int		(ide_flushcache_proc)(ide_drive_t *);
688typedef ide_startstop_t	(ide_do_request_proc)(ide_drive_t *, struct request *, unsigned long);
689typedef void		(ide_end_request_proc)(byte, ide_hwgroup_t *);
690typedef int		(ide_ioctl_proc)(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long);
691typedef int		(ide_open_proc)(struct inode *, struct file *, ide_drive_t *);
692typedef void		(ide_release_proc)(struct inode *, struct file *, ide_drive_t *);
693typedef int		(ide_check_media_change_proc)(ide_drive_t *);
694typedef void		(ide_revalidate_proc)(ide_drive_t *);
695typedef void		(ide_pre_reset_proc)(ide_drive_t *);
696typedef unsigned long	(ide_capacity_proc)(ide_drive_t *);
697typedef ide_startstop_t	(ide_special_proc)(ide_drive_t *);
698typedef void		(ide_setting_proc)(ide_drive_t *);
699typedef int		(ide_reinit_proc)(ide_drive_t *);
700typedef void		(ata_prebuilder_proc)(ide_drive_t *);
701typedef void		(atapi_prebuilder_proc)(ide_drive_t *);
702
703typedef struct ide_driver_s {
704	const char			*name;
705	const char			*version;
706	byte				media;
707	unsigned busy			: 1;
708	unsigned supports_dma		: 1;
709	unsigned supports_dsc_overlap	: 1;
710	ide_cleanup_proc		*cleanup;
711	ide_standby_proc		*standby;
712	ide_flushcache_proc		*flushcache;
713	ide_do_request_proc		*do_request;
714	ide_end_request_proc		*end_request;
715	ide_ioctl_proc			*ioctl;
716	ide_open_proc			*open;
717	ide_release_proc		*release;
718	ide_check_media_change_proc	*media_change;
719	ide_revalidate_proc		*revalidate;
720	ide_pre_reset_proc		*pre_reset;
721	ide_capacity_proc		*capacity;
722	ide_special_proc		*special;
723	ide_proc_entry_t		*proc;
724	ide_reinit_proc			*reinit;
725	ata_prebuilder_proc		*ata_prebuilder;
726	atapi_prebuilder_proc		*atapi_prebuilder;
727} ide_driver_t;
728
729#define DRIVER(drive)		((ide_driver_t *)((drive)->driver))
730
731/*
732 * IDE modules.
733 */
734#define IDE_CHIPSET_MODULE		0	/* not supported yet */
735#define IDE_PROBE_MODULE		1
736#define IDE_DRIVER_MODULE		2
737
738typedef int	(ide_module_init_proc)(void);
739
740typedef struct ide_module_s {
741	int				type;
742	ide_module_init_proc		*init;
743	void				*info;
744	struct ide_module_s		*next;
745} ide_module_t;
746
747/*
748 * ide_hwifs[] is the master data structure used to keep track
749 * of just about everything in ide.c.  Whenever possible, routines
750 * should be using pointers to a drive (ide_drive_t *) or
751 * pointers to a hwif (ide_hwif_t *), rather than indexing this
752 * structure directly (the allocation/layout may change!).
753 *
754 */
755#ifndef _IDE_C
756extern	ide_hwif_t	ide_hwifs[];		/* master data repository */
757extern	ide_module_t	*ide_modules;
758extern	ide_module_t	*ide_probe;
759#endif
760extern int noautodma;
761
762/*
763 * We need blk.h, but we replace its end_request by our own version.
764 */
765#define IDE_DRIVER		/* Toggle some magic bits in blk.h */
766#define LOCAL_END_REQUEST	/* Don't generate end_request in blk.h */
767#include <linux/blk.h>
768
769void ide_end_request(byte uptodate, ide_hwgroup_t *hwgroup);
770
771void ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount);
772void ide_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount);
773
774void atapi_input_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount);
775void atapi_output_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount);
776
777int drive_is_ready (ide_drive_t *drive);
778
779/*
780 * This is used on exit from the driver, to designate the next irq handler
781 * and also to start the safety timer.
782 */
783void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry);
784
785/*
786 * Error reporting, in human readable form (luxurious, but a memory hog).
787 */
788byte ide_dump_status (ide_drive_t *drive, const char *msg, byte stat);
789
790/*
791 * ide_error() takes action based on the error returned by the controller.
792 * The caller should return immediately after invoking this.
793 */
794ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat);
795
796/*
797 * Issue a simple drive command
798 * The drive must be selected beforehand.
799 */
800void ide_cmd (ide_drive_t *drive, byte cmd, byte nsect, ide_handler_t *handler);
801
802/*
803 * ide_fixstring() cleans up and (optionally) byte-swaps a text string,
804 * removing leading/trailing blanks and compressing internal blanks.
805 * It is primarily used to tidy up the model name/number fields as
806 * returned by the WIN_[P]IDENTIFY commands.
807 */
808void ide_fixstring (byte *s, const int bytecount, const int byteswap);
809
810/*
811 * This routine busy-waits for the drive status to be not "busy".
812 * It then checks the status for all of the "good" bits and none
813 * of the "bad" bits, and if all is okay it returns 0.  All other
814 * cases return 1 after doing "*startstop = ide_error()", and the
815 * caller should return the updated value of "startstop" in this case.
816 * "startstop" is unchanged when the function returns 0;
817 */
818int ide_wait_stat (ide_startstop_t *startstop, ide_drive_t *drive, byte good, byte bad, unsigned long timeout);
819
820int ide_wait_noerr (ide_drive_t *drive, byte good, byte bad, unsigned long timeout);
821
822/*
823 * This routine is called from the partition-table code in genhd.c
824 * to "convert" a drive to a logical geometry with fewer than 1024 cyls.
825 */
826int ide_xlate_1024 (kdev_t, int, int, const char *);
827
828/*
829 * Convert kdev_t structure into ide_drive_t * one.
830 */
831ide_drive_t *get_info_ptr (kdev_t i_rdev);
832
833/*
834 * Return the current idea about the total capacity of this drive.
835 */
836unsigned long current_capacity (ide_drive_t *drive);
837
838/*
839 * Start a reset operation for an IDE interface.
840 * The caller should return immediately after invoking this.
841 */
842ide_startstop_t ide_do_reset (ide_drive_t *);
843
844/*
845 * Re-Start an operation for an IDE interface.
846 * The caller should return immediately after invoking this.
847 */
848ide_startstop_t restart_request (ide_drive_t *);
849
850/*
851 * This function is intended to be used prior to invoking ide_do_drive_cmd().
852 */
853void ide_init_drive_cmd (struct request *rq);
854
855/*
856 * "action" parameter type for ide_do_drive_cmd() below.
857 */
858typedef enum {
859	ide_wait,	/* insert rq at end of list, and wait for it */
860	ide_next,	/* insert rq immediately after current request */
861	ide_preempt,	/* insert rq in front of current request */
862	ide_end		/* insert rq at end of list, but don't wait for it */
863} ide_action_t;
864
865/*
866 * temporarily mapping a (possible) highmem bio
867 */
868#define ide_rq_offset(rq) (((rq)->hard_cur_sectors - (rq)->current_nr_sectors) << 9)
869
870extern inline void *ide_map_buffer(struct request *rq, unsigned long *flags)
871{
872	return bh_kmap_irq(rq->bh, flags) + ide_rq_offset(rq);
873}
874
875extern inline void ide_unmap_buffer(char *buffer, unsigned long *flags)
876{
877	bh_kunmap_irq(buffer, flags);
878}
879
880/*
881 * This function issues a special IDE device request
882 * onto the request queue.
883 *
884 * If action is ide_wait, then the rq is queued at the end of the
885 * request queue, and the function sleeps until it has been processed.
886 * This is for use when invoked from an ioctl handler.
887 *
888 * If action is ide_preempt, then the rq is queued at the head of
889 * the request queue, displacing the currently-being-processed
890 * request and this function returns immediately without waiting
891 * for the new rq to be completed.  This is VERY DANGEROUS, and is
892 * intended for careful use by the ATAPI tape/cdrom driver code.
893 *
894 * If action is ide_next, then the rq is queued immediately after
895 * the currently-being-processed-request (if any), and the function
896 * returns without waiting for the new rq to be completed.  As above,
897 * This is VERY DANGEROUS, and is intended for careful use by the
898 * ATAPI tape/cdrom driver code.
899 *
900 * If action is ide_end, then the rq is queued at the end of the
901 * request queue, and the function returns immediately without waiting
902 * for the new rq to be completed. This is again intended for careful
903 * use by the ATAPI tape/cdrom driver code.
904 */
905int ide_do_drive_cmd (ide_drive_t *drive, struct request *rq, ide_action_t action);
906
907/*
908 * Clean up after success/failure of an explicit drive cmd.
909 * stat/err are used only when (HWGROUP(drive)->rq->cmd == IDE_DRIVE_CMD).
910 * stat/err are used only when (HWGROUP(drive)->rq->cmd == IDE_DRIVE_TASK_MASK).
911 */
912void ide_end_drive_cmd (ide_drive_t *drive, byte stat, byte err);
913
914/*
915 * Issue ATA command and wait for completion. use for implementing commands in kernel
916 */
917int ide_wait_cmd (ide_drive_t *drive, int cmd, int nsect, int feature, int sectors, byte *buf);
918
919int ide_wait_cmd_task (ide_drive_t *drive, byte *buf);
920
921typedef struct ide_task_s {
922	task_ioreg_t		tfRegister[8];
923	task_ioreg_t		hobRegister[8];
924	ide_reg_valid_t		tf_out_flags;
925	ide_reg_valid_t		tf_in_flags;
926	int			data_phase;
927	int			command_type;
928	ide_pre_handler_t	*prehandler;
929	ide_handler_t		*handler;
930	ide_post_handler_t	*posthandler;
931	void			*special;	/* valid_t generally */
932	struct request		*rq;		/* copy of request */
933	unsigned long		block;		/* copy of block */
934} ide_task_t;
935
936typedef struct pkt_task_s {
937	task_ioreg_t		tfRegister[8];
938	int			data_phase;
939	int			command_type;
940	ide_handler_t		*handler;
941	void			*special;
942	struct request		*rq;		/* copy of request */
943	unsigned long		block;		/* copy of block */
944} pkt_task_t;
945
946/*
947 * taskfile io for disks for now...
948 */
949ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task);
950
951/*
952 * Builds request from ide_ioctl
953 */
954void do_taskfile (ide_drive_t *drive, struct hd_drive_task_hdr *taskfile, struct hd_drive_hob_hdr *hobfile, ide_handler_t *handler);
955
956/*
957 * Special Flagged Register Validation Caller
958 */
959// ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task);
960
961ide_startstop_t set_multmode_intr (ide_drive_t *drive);
962ide_startstop_t set_geometry_intr (ide_drive_t *drive);
963ide_startstop_t recal_intr (ide_drive_t *drive);
964ide_startstop_t task_no_data_intr (ide_drive_t *drive);
965ide_startstop_t task_in_intr (ide_drive_t *drive);
966ide_startstop_t task_mulin_intr (ide_drive_t *drive);
967ide_startstop_t pre_task_out_intr (ide_drive_t *drive, struct request *rq);
968ide_startstop_t task_out_intr (ide_drive_t *drive);
969ide_startstop_t task_mulout_intr (ide_drive_t *drive);
970void ide_init_drive_taskfile (struct request *rq);
971
972int ide_wait_taskfile (ide_drive_t *drive, struct hd_drive_task_hdr *taskfile, struct hd_drive_hob_hdr *hobfile, byte *buf);
973
974int ide_raw_taskfile (ide_drive_t *drive, ide_task_t *cmd, byte *buf);
975
976ide_pre_handler_t * ide_pre_handler_parser (struct hd_drive_task_hdr *taskfile, struct hd_drive_hob_hdr *hobfile);
977ide_handler_t * ide_handler_parser (struct hd_drive_task_hdr *taskfile, struct hd_drive_hob_hdr *hobfile);
978/* Expects args is a full set of TF registers and parses the command type */
979int ide_cmd_type_parser (ide_task_t *args);
980
981int ide_taskfile_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
982
983#ifdef CONFIG_PKT_TASK_IOCTL
984int pkt_taskfile_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
985#endif /* CONFIG_PKT_TASK_IOCTL */
986
987void ide_delay_50ms (void);
988int system_bus_clock(void);
989
990byte ide_auto_reduce_xfer (ide_drive_t *drive);
991int ide_driveid_update (ide_drive_t *drive);
992int ide_ata66_check (ide_drive_t *drive, ide_task_t *args);
993int ide_config_drive_speed (ide_drive_t *drive, byte speed);
994byte eighty_ninty_three (ide_drive_t *drive);
995int set_transfer (ide_drive_t *drive, ide_task_t *args);
996
997/*
998 * ide_system_bus_speed() returns what we think is the system VESA/PCI
999 * bus speed (in MHz).  This is used for calculating interface PIO timings.
1000 * The default is 40 for known PCI systems, 50 otherwise.
1001 * The "idebus=xx" parameter can be used to override this value.
1002 */
1003int ide_system_bus_speed (void);
1004
1005/*
1006 * ide_multwrite() transfers a block of up to mcount sectors of data
1007 * to a drive as part of a disk multwrite operation.
1008 */
1009int ide_multwrite (ide_drive_t *drive, unsigned int mcount);
1010
1011/*
1012 * ide_stall_queue() can be used by a drive to give excess bandwidth back
1013 * to the hwgroup by sleeping for timeout jiffies.
1014 */
1015void ide_stall_queue (ide_drive_t *drive, unsigned long timeout);
1016
1017/*
1018 * ide_get_queue() returns the queue which corresponds to a given device.
1019 */
1020request_queue_t *ide_get_queue (kdev_t dev);
1021
1022/*
1023 * CompactFlash cards and their brethern pretend to be removable hard disks,
1024 * but they never have a slave unit, and they don't have doorlock mechanisms.
1025 * This test catches them, and is invoked elsewhere when setting appropriate config bits.
1026 */
1027int drive_is_flashcard (ide_drive_t *drive);
1028
1029int ide_spin_wait_hwgroup (ide_drive_t *drive);
1030void ide_timer_expiry (unsigned long data);
1031void ide_intr (int irq, void *dev_id, struct pt_regs *regs);
1032void do_ide_request (request_queue_t * q);
1033void ide_init_subdrivers (void);
1034
1035#ifndef _IDE_C
1036extern struct block_device_operations ide_fops[];
1037extern ide_proc_entry_t generic_subdriver_entries[];
1038#endif
1039
1040int ide_reinit_drive (ide_drive_t *drive);
1041
1042#ifdef _IDE_C
1043#ifdef CONFIG_BLK_DEV_IDE
1044int ideprobe_init (void);
1045#endif /* CONFIG_BLK_DEV_IDE */
1046#ifdef CONFIG_BLK_DEV_IDEDISK
1047int idedisk_reinit (ide_drive_t *drive);
1048int idedisk_init (void);
1049#endif /* CONFIG_BLK_DEV_IDEDISK */
1050#ifdef CONFIG_BLK_DEV_IDECD
1051int ide_cdrom_reinit (ide_drive_t *drive);
1052int ide_cdrom_init (void);
1053#endif /* CONFIG_BLK_DEV_IDECD */
1054#ifdef CONFIG_BLK_DEV_IDETAPE
1055int idetape_reinit (ide_drive_t *drive);
1056int idetape_init (void);
1057#endif /* CONFIG_BLK_DEV_IDETAPE */
1058#ifdef CONFIG_BLK_DEV_IDEFLOPPY
1059int idefloppy_reinit (ide_drive_t *drive);
1060int idefloppy_init (void);
1061#endif /* CONFIG_BLK_DEV_IDEFLOPPY */
1062#ifdef CONFIG_BLK_DEV_IDESCSI
1063int idescsi_reinit (ide_drive_t *drive);
1064int idescsi_init (void);
1065#endif /* CONFIG_BLK_DEV_IDESCSI */
1066#endif /* _IDE_C */
1067
1068int ide_register_module (ide_module_t *module);
1069void ide_unregister_module (ide_module_t *module);
1070ide_drive_t *ide_scan_devices (byte media, const char *name, ide_driver_t *driver, int n);
1071int ide_register_subdriver (ide_drive_t *drive, ide_driver_t *driver, int version);
1072int ide_unregister_subdriver (ide_drive_t *drive);
1073int ide_replace_subdriver(ide_drive_t *drive, const char *driver);
1074
1075#ifdef CONFIG_BLK_DEV_IDEPCI
1076#define ON_BOARD		1
1077#define NEVER_BOARD		0
1078#ifdef CONFIG_BLK_DEV_OFFBOARD
1079#  define OFF_BOARD		ON_BOARD
1080#else /* CONFIG_BLK_DEV_OFFBOARD */
1081#  define OFF_BOARD		NEVER_BOARD
1082#endif /* CONFIG_BLK_DEV_OFFBOARD */
1083
1084unsigned long ide_find_free_region (unsigned short size) __init;
1085void ide_scan_pcibus (int scan_direction) __init;
1086#endif
1087#ifdef CONFIG_BLK_DEV_IDEDMA
1088#define BAD_DMA_DRIVE		0
1089#define GOOD_DMA_DRIVE		1
1090int ide_build_dmatable (ide_drive_t *drive, ide_dma_action_t func);
1091void ide_destroy_dmatable (ide_drive_t *drive);
1092ide_startstop_t ide_dma_intr (ide_drive_t *drive);
1093int check_drive_lists (ide_drive_t *drive, int good_bad);
1094int report_drive_dmaing (ide_drive_t *drive);
1095int ide_dmaproc (ide_dma_action_t func, ide_drive_t *drive);
1096int ide_release_dma (ide_hwif_t *hwif);
1097void ide_setup_dma (ide_hwif_t *hwif, unsigned long dmabase, unsigned int num_ports) __init;
1098unsigned long ide_get_or_set_dma_base (ide_hwif_t *hwif, int extra, const char *name) __init;
1099#endif
1100
1101void hwif_unregister (ide_hwif_t *hwif);
1102
1103void export_ide_init_queue (ide_drive_t *drive);
1104byte export_probe_for_drive (ide_drive_t *drive);
1105
1106#endif /* _IDE_H */
1107