#ifndef _IDE_H
#define _IDE_H
/*
* linux/include/linux/ide.h
*
* Copyright (C) 1994-2002 Linus Torvalds & authors
*/
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/ata.h>
#include <linux/blkdev.h>
#include <linux/proc_fs.h>
#include <linux/interrupt.h>
#include <linux/bitops.h>
#include <linux/bio.h>
#include <linux/pci.h>
#include <linux/completion.h>
#include <linux/pm.h>
#include <linux/mutex.h>
/* for request_sense */
#include <linux/cdrom.h>
#include <asm/byteorder.h>
#include <asm/io.h>
#if defined(CONFIG_CRIS) || defined(CONFIG_FRV) || defined(CONFIG_MN10300)
# define SUPPORT_VLB_SYNC 0
#else
# define SUPPORT_VLB_SYNC 1
#endif
/*
* Probably not wise to fiddle with these
*/
#define IDE_DEFAULT_MAX_FAILURES 1
#define ERROR_MAX 8 /* Max read/write errors per sector */
#define ERROR_RESET 3 /* Reset controller every 4th retry */
#define ERROR_RECAL 1 /* Recalibrate every 2nd retry */
struct device;
/* Error codes returned in rq->errors to the higher part of the driver. */
enum {
IDE_DRV_ERROR_GENERAL = 101,
IDE_DRV_ERROR_FILEMARK = 102,
IDE_DRV_ERROR_EOD = 103,
};
/*
* Definitions for accessing IDE controller registers
*/
#define IDE_NR_PORTS (10)
struct ide_io_ports {
unsigned long data_addr;
union {
unsigned long error_addr; /* read: error */
unsigned long feature_addr; /* write: feature */
};
unsigned long nsect_addr;
unsigned long lbal_addr;
unsigned long lbam_addr;
unsigned long lbah_addr;
unsigned long device_addr;
union {
unsigned long status_addr; /* read: status */
unsigned long command_addr; /* write: command */
};
unsigned long ctl_addr;
unsigned long irq_addr;
};
#define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good))
#define BAD_R_STAT (ATA_BUSY | ATA_ERR)
#define BAD_W_STAT (BAD_R_STAT | ATA_DF)
#define BAD_STAT (BAD_R_STAT | ATA_DRQ)
#define DRIVE_READY (ATA_DRDY | ATA_DSC)
#define BAD_CRC (ATA_ABORTED | ATA_ICRC)
#define SATA_NR_PORTS (3) /* 16 possible ?? */
#define SATA_STATUS_OFFSET (0)
#define SATA_ERROR_OFFSET (1)
#define SATA_CONTROL_OFFSET (2)
/*
* Our Physical Region Descriptor (PRD) table should be large enough
* to handle the biggest I/O request we are likely to see. Since requests
* can have no more than 256 sectors, and since the typical blocksize is
* two or more sectors, we could get by with a limit of 128 entries here for
* the usual worst case. Most requests seem to include some contiguous blocks,
* further reducing the number of table entries required.
*
* The driver reverts to PIO mode for individual requests that exceed
* this limit (possible with 512 byte blocksizes, eg. MSDOS f/s), so handling
* 100% of all crazy scenarios here is not necessary.
*
* As it turns out though, we must allocate a full 4KB page for this,
* so the two PRD tables (ide0 & ide1) will each get half of that,
* allowing each to have about 256 entries (8 bytes each) from this.
*/
#define PRD_BYTES 8
#define PRD_ENTRIES 256
/*
* Some more useful definitions
*/
#define PARTN_BITS 6 /* number of minor dev bits for partitions */
#define MAX_DRIVES 2 /* per interface; 2 assumed by lots of code */
#define SECTOR_SIZE 512
/*
* Timeouts for various operations:
*/
enum {
/* spec allows up to 20ms, but CF cards and SSD drives need more */
WAIT_DRQ = 1 * HZ, /* 1s */
/* some laptops are very slow */
WAIT_READY = 5 * HZ, /* 5s */
/* should be less than 3ms (?), if all ATAPI CD is closed at boot */
WAIT_PIDENTIFY = 10 * HZ, /* 10s */
/* worst case when spinning up */
WAIT_WORSTCASE = 30 * HZ, /* 30s */
/* maximum wait for an IRQ to happen */
WAIT_CMD = 10 * HZ, /* 10s */
/* Some drives require a longer IRQ timeout. */
WAIT_FLOPPY_CMD = 50 * HZ, /* 50s */
/*
* Some drives (for example, Seagate STT3401A Travan) require a very
* long timeout, because they don't return an interrupt or clear their
* BSY bit until after the command completes (even retension commands).
*/
WAIT_TAPE_CMD = 900 * HZ, /* 900s */
/* minimum sleep time */
WAIT_MIN_SLEEP = HZ / 50, /* 20ms */
};
/*
* Op codes for special requests to be handled by ide_special_rq().
* Values should be in the range of 0x20 to 0x3f.
*/
#define REQ_DRIVE_RESET 0x20
#define REQ_DEVSET_EXEC 0x21
#define REQ_PARK_HEADS 0x22
#define REQ_UNPARK_HEADS 0x23
/*
* hwif_chipset_t is used to keep track of the specific hardware
* chipset used by each IDE interface, if known.
*/
enum { ide_unknown, ide_generic, ide_pci,
ide_cmd640, ide_dtc2278, ide_ali14xx,
ide_qd65xx, ide_umc8672, ide_ht6560b,
ide_4drives, ide_pmac, ide_acorn,
ide_au1xxx, ide_palm3710
};
typedef u8 hwif_chipset_t;
/*
* Structure to hold all information about the location of this port
*/
struct ide_hw {
union {
struct ide_io_ports io_ports;
unsigned long io_ports_array[IDE_NR_PORTS];
};
int irq; /* our irq number */
struct device *dev, *parent;
unsigned long config;
};
static inline void ide_std_init_ports(struct ide_hw *hw,
unsigned long io_addr,
unsigned long ctl_addr)
{
unsigned int i;
for (i = 0; i <= 7; i++)
hw->io_ports_array[i] = io_addr++;
hw->io_ports.ctl_addr = ctl_addr;
}
#define MAX_HWIFS 10
/*
* Now for the data we need to maintain per-drive: ide_drive_t
*/
#define ide_scsi 0x21
#define ide_disk 0x20
#define ide_optical 0x7
#define ide_cdrom 0x5
#define ide_tape 0x1
#define ide_floppy 0x0
/*
* Special Driver Flags
*/
enum {
IDE_SFLAG_SET_GEOMETRY = (1 << 0),
IDE_SFLAG_RECALIBRATE = (1 << 1),
IDE_SFLAG_SET_MULTMODE = (1 << 2),
};
/*
* Status returned from various ide_ functions
*/
typedef enum {
ide_stopped, /* no drive operation was started */
ide_started, /* a drive operation was started, handler was set */
} ide_startstop_t;
enum {
IDE_VALID_ERROR = (1 << 1),
IDE_VALID_FEATURE = IDE_VALID_ERROR,
IDE_VALID_NSECT = (1 << 2),
IDE_VALID_LBAL = (1 << 3),
IDE_VALID_LBAM = (1 << 4),
IDE_VALID_LBAH = (1 << 5),
IDE_VALID_DEVICE = (1 << 6),
IDE_VALID_LBA = IDE_VALID_LBAL |
IDE_VALID_LBAM |
IDE_VALID_LBAH,
IDE_VALID_OUT_TF = IDE_VALID_FEATURE |
IDE_VALID_NSECT |
IDE_VALID_LBA,
IDE_VALID_IN_TF = IDE_VALID_NSECT |
IDE_VALID_LBA,
IDE_VALID_OUT_HOB = IDE_VALID_OUT_TF,
IDE_VALID_IN_HOB = IDE_VALID_ERROR |
IDE_VALID_NSECT |
IDE_VALID_LBA,
};
enum {
IDE_TFLAG_LBA48 = (1 << 0),
IDE_TFLAG_WRITE = (1 << 1),
IDE_TFLAG_CUSTOM_HANDLER = (1 << 2),
IDE_TFLAG_DMA_PIO_FALLBACK = (1 << 3),
/* force 16-bit I/O operations */
IDE_TFLAG_IO_16BIT = (1 << 4),
/*
|