]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/ide.h
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
[linux-2.6-omap-h63xx.git] / include / linux / ide.h
index 67f83c60845f7a534655bbbcaa0dddebc1c95b04..5f3e82ae901a94a54a7e99602dca5f06052191d4 100644 (file)
@@ -23,7 +23,6 @@
 #include <asm/byteorder.h>
 #include <asm/system.h>
 #include <asm/io.h>
-#include <asm/semaphore.h>
 #include <asm/mutex.h>
 
 #if defined(CONFIG_CRIS) || defined(CONFIG_FRV)
@@ -82,24 +81,10 @@ typedef unsigned char       byte;   /* used everywhere */
 
 #define IDE_FEATURE_OFFSET     IDE_ERROR_OFFSET
 #define IDE_COMMAND_OFFSET     IDE_STATUS_OFFSET
-
-#define IDE_DATA_REG           (HWIF(drive)->io_ports[IDE_DATA_OFFSET])
-#define IDE_ERROR_REG          (HWIF(drive)->io_ports[IDE_ERROR_OFFSET])
-#define IDE_NSECTOR_REG                (HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET])
-#define IDE_SECTOR_REG         (HWIF(drive)->io_ports[IDE_SECTOR_OFFSET])
-#define IDE_LCYL_REG           (HWIF(drive)->io_ports[IDE_LCYL_OFFSET])
-#define IDE_HCYL_REG           (HWIF(drive)->io_ports[IDE_HCYL_OFFSET])
-#define IDE_SELECT_REG         (HWIF(drive)->io_ports[IDE_SELECT_OFFSET])
-#define IDE_STATUS_REG         (HWIF(drive)->io_ports[IDE_STATUS_OFFSET])
-#define IDE_CONTROL_REG                (HWIF(drive)->io_ports[IDE_CONTROL_OFFSET])
-#define IDE_IRQ_REG            (HWIF(drive)->io_ports[IDE_IRQ_OFFSET])
-
-#define IDE_FEATURE_REG                IDE_ERROR_REG
-#define IDE_COMMAND_REG                IDE_STATUS_REG
-#define IDE_ALTSTATUS_REG      IDE_CONTROL_REG
-#define IDE_IREASON_REG                IDE_NSECTOR_REG
-#define IDE_BCOUNTL_REG                IDE_LCYL_REG
-#define IDE_BCOUNTH_REG                IDE_HCYL_REG
+#define IDE_ALTSTATUS_OFFSET   IDE_CONTROL_OFFSET
+#define IDE_IREASON_OFFSET     IDE_NSECTOR_OFFSET
+#define IDE_BCOUNTL_OFFSET     IDE_LCYL_OFFSET
+#define IDE_BCOUNTH_OFFSET     IDE_HCYL_OFFSET
 
 #define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good))
 #define BAD_R_STAT             (BUSY_STAT   | ERR_STAT)
@@ -208,45 +193,6 @@ static inline void ide_std_init_ports(hw_regs_t *hw,
 #define MAX_HWIFS      CONFIG_IDE_MAX_HWIFS
 #endif
 
-/* needed on alpha, x86/x86_64, ia64, mips, ppc32 and sh */
-#ifndef IDE_ARCH_OBSOLETE_DEFAULTS
-# define ide_default_io_base(index)    (0)
-# define ide_default_irq(base)         (0)
-# define ide_init_default_irq(base)    (0)
-#endif
-
-#ifdef CONFIG_IDE_ARCH_OBSOLETE_INIT
-static inline void ide_init_hwif_ports(hw_regs_t *hw,
-                                      unsigned long io_addr,
-                                      unsigned long ctl_addr,
-                                      int *irq)
-{
-       if (!ctl_addr)
-               ide_std_init_ports(hw, io_addr, ide_default_io_ctl(io_addr));
-       else
-               ide_std_init_ports(hw, io_addr, ctl_addr);
-
-       if (irq)
-               *irq = 0;
-
-       hw->io_ports[IDE_IRQ_OFFSET] = 0;
-
-#ifdef CONFIG_PPC32
-       if (ppc_ide_md.ide_init_hwif)
-               ppc_ide_md.ide_init_hwif(hw, io_addr, ctl_addr, irq);
-#endif
-}
-#else
-static inline void ide_init_hwif_ports(hw_regs_t *hw,
-                                      unsigned long io_addr,
-                                      unsigned long ctl_addr,
-                                      int *irq)
-{
-       if (io_addr || ctl_addr)
-               printk(KERN_WARNING "%s: must not be called\n", __FUNCTION__);
-}
-#endif /* CONFIG_IDE_ARCH_OBSOLETE_INIT */
-
 /* Currently only m68k, apus and m8xx need it */
 #ifndef IDE_ARCH_ACK_INTR
 # define ide_ack_intr(hwif) (1)
@@ -401,7 +347,7 @@ typedef struct ide_drive_s {
         u8     wcache;         /* status of write cache */
        u8      acoustic;       /* acoustic management */
        u8      media;          /* disk, cdrom, tape, floppy, ... */
-       u8      ctl;            /* "normal" value for IDE_CONTROL_REG */
+       u8      ctl;            /* "normal" value for Control register */
        u8      ready_stat;     /* min status value for drive ready */
        u8      mult_count;     /* current multiple sector setting */
        u8      mult_req;       /* requested multiple sector setting */
@@ -571,7 +517,6 @@ typedef struct hwif_s {
 
        unsigned        noprobe    : 1; /* don't probe for this interface */
        unsigned        present    : 1; /* this interface exists */
-       unsigned        hold       : 1; /* this interface is always present */
        unsigned        serialized : 1; /* serialized all channel operation */
        unsigned        sharing_irq: 1; /* 1 = sharing irq with another hwif */
        unsigned        reset      : 1; /* reset after probe */
@@ -642,6 +587,68 @@ int set_io_32bit(ide_drive_t *, int);
 int set_pio_mode(ide_drive_t *, int);
 int set_using_dma(ide_drive_t *, int);
 
+/* ATAPI packet command flags */
+enum {
+       /* set when an error is considered normal - no retry (ide-tape) */
+       PC_FLAG_ABORT                   = (1 << 0),
+       PC_FLAG_SUPPRESS_ERROR          = (1 << 1),
+       PC_FLAG_WAIT_FOR_DSC            = (1 << 2),
+       PC_FLAG_DMA_OK                  = (1 << 3),
+       PC_FLAG_DMA_RECOMMENDED         = (1 << 4),
+       PC_FLAG_DMA_IN_PROGRESS         = (1 << 5),
+       PC_FLAG_DMA_ERROR               = (1 << 6),
+       PC_FLAG_WRITING                 = (1 << 7),
+       /* command timed out */
+       PC_FLAG_TIMEDOUT                = (1 << 8),
+};
+
+struct ide_atapi_pc {
+       /* actual packet bytes */
+       u8 c[12];
+       /* incremented on each retry */
+       int retries;
+       int error;
+
+       /* bytes to transfer */
+       int req_xfer;
+       /* bytes actually transferred */
+       int xferred;
+
+       /* data buffer */
+       u8 *buf;
+       /* current buffer position */
+       u8 *cur_pos;
+       int buf_size;
+       /* missing/available data on the current buffer */
+       int b_count;
+
+       /* the corresponding request */
+       struct request *rq;
+
+       unsigned long flags;
+
+       /*
+        * those are more or less driver-specific and some of them are subject
+        * to change/removal later.
+        */
+       u8 pc_buf[256];
+       void (*idefloppy_callback) (ide_drive_t *);
+       ide_startstop_t (*idetape_callback) (ide_drive_t *);
+
+       /* idetape only */
+       struct idetape_bh *bh;
+       char *b_data;
+
+       /* idescsi only for now */
+       struct scatterlist *sg;
+       unsigned int sg_cnt;
+
+       struct scsi_cmnd *scsi_cmd;
+       void (*done) (struct scsi_cmnd *);
+
+       unsigned long timeout;
+};
+
 #ifdef CONFIG_IDE_PROC_FS
 /*
  * configurable drive settings
@@ -1191,7 +1198,7 @@ static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {}
 void ide_remove_port_from_hwgroup(ide_hwif_t *);
 extern int ide_hwif_request_regions(ide_hwif_t *hwif);
 extern void ide_hwif_release_regions(ide_hwif_t* hwif);
-void ide_unregister(unsigned int, int, int);
+void ide_unregister(unsigned int);
 
 void ide_register_region(struct gendisk *);
 void ide_unregister_region(struct gendisk *);
@@ -1306,7 +1313,10 @@ static inline ide_drive_t *ide_get_paired_drive(ide_drive_t *drive)
 
 static inline void ide_set_irq(ide_drive_t *drive, int on)
 {
-       drive->hwif->OUTB(drive->ctl | (on ? 0 : 2), IDE_CONTROL_REG);
+       ide_hwif_t *hwif = drive->hwif;
+
+       hwif->OUTB(drive->ctl | (on ? 0 : 2),
+                  hwif->io_ports[IDE_CONTROL_OFFSET]);
 }
 
 static inline u8 ide_read_status(ide_drive_t *drive)
@@ -1330,4 +1340,26 @@ static inline u8 ide_read_error(ide_drive_t *drive)
        return hwif->INB(hwif->io_ports[IDE_ERROR_OFFSET]);
 }
 
+/*
+ * Too bad. The drive wants to send us data which we are not ready to accept.
+ * Just throw it away.
+ */
+static inline void ide_atapi_discard_data(ide_drive_t *drive, unsigned bcount)
+{
+       ide_hwif_t *hwif = drive->hwif;
+
+       /* FIXME: use ->atapi_input_bytes */
+       while (bcount--)
+               (void)hwif->INB(hwif->io_ports[IDE_DATA_OFFSET]);
+}
+
+static inline void ide_atapi_write_zeros(ide_drive_t *drive, unsigned bcount)
+{
+       ide_hwif_t *hwif = drive->hwif;
+
+       /* FIXME: use ->atapi_output_bytes */
+       while (bcount--)
+               hwif->OUTB(0, hwif->io_ports[IDE_DATA_OFFSET]);
+}
+
 #endif /* _IDE_H */