Merge upstream kernel changes into 'C/H/S support' branch of libata.
[firefly-linux-kernel-4.4.55.git] / include / linux / libata.h
index 1f7e2039a04e38bb0235c489301c1cfc094f611b..973090be7fc4e863ac27e9b5844550f25b58afd1 100644 (file)
@@ -95,6 +95,7 @@ enum {
        ATA_DFLAG_LBA48         = (1 << 0), /* device supports LBA48 */
        ATA_DFLAG_PIO           = (1 << 1), /* device currently in PIO mode */
        ATA_DFLAG_LOCK_SECTORS  = (1 << 2), /* don't adjust max_sectors */
+       ATA_DFLAG_LBA           = (1 << 3), /* device supports LBA */
 
        ATA_DEV_UNKNOWN         = 0,    /* unknown device */
        ATA_DEV_ATA             = 1,    /* ATA device */
@@ -278,6 +279,11 @@ struct ata_device {
        u8                      xfer_protocol;  /* taskfile xfer protocol */
        u8                      read_cmd;       /* opcode to use on read */
        u8                      write_cmd;      /* opcode to use on write */
+
+       /* for CHS addressing */
+       u16                     cylinders;      /* Number of cylinders */
+       u16                     heads;          /* Number of heads */
+       u16                     sectors;        /* Number of sectors per track */
 };
 
 struct ata_port {
@@ -410,6 +416,7 @@ extern u8 ata_chk_err(struct ata_port *ap);
 extern void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf);
 extern int ata_port_start (struct ata_port *ap);
 extern void ata_port_stop (struct ata_port *ap);
+extern void ata_host_stop (struct ata_host_set *host_set);
 extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
 extern void ata_qc_prep(struct ata_queued_cmd *qc);
 extern int ata_qc_issue_prot(struct ata_queued_cmd *qc);
@@ -420,6 +427,7 @@ extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
 extern unsigned int ata_dev_classify(struct ata_taskfile *tf);
 extern void ata_dev_id_string(u16 *id, unsigned char *s,
                              unsigned int ofs, unsigned int len);
+extern void ata_dev_config(struct ata_port *ap, unsigned int i);
 extern void ata_bmdma_setup (struct ata_queued_cmd *qc);
 extern void ata_bmdma_start (struct ata_queued_cmd *qc);
 extern void ata_bmdma_stop(struct ata_port *ap);
@@ -466,12 +474,34 @@ static inline u8 ata_chk_status(struct ata_port *ap)
        return ap->ops->check_status(ap);
 }
 
+
+/**
+ *     ata_pause - Flush writes and pause 400 nanoseconds.
+ *     @ap: Port to wait for.
+ *
+ *     LOCKING:
+ *     Inherited from caller.
+ */
+
 static inline void ata_pause(struct ata_port *ap)
 {
        ata_altstatus(ap);
        ndelay(400);
 }
 
+
+/**
+ *     ata_busy_wait - Wait for a port status register
+ *     @ap: Port to wait for.
+ *
+ *     Waits up to max*10 microseconds for the selected bits in the port's
+ *     status register to be cleared.
+ *     Returns final value of status register.
+ *
+ *     LOCKING:
+ *     Inherited from caller.
+ */
+
 static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits,
                               unsigned int max)
 {
@@ -486,6 +516,18 @@ static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits,
        return status;
 }
 
+
+/**
+ *     ata_wait_idle - Wait for a port to be idle.
+ *     @ap: Port to wait for.
+ *
+ *     Waits up to 10ms for port's BUSY and DRQ signals to clear.
+ *     Returns final value of status register.
+ *
+ *     LOCKING:
+ *     Inherited from caller.
+ */
+
 static inline u8 ata_wait_idle(struct ata_port *ap)
 {
        u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
@@ -524,6 +566,18 @@ static inline void ata_tf_init(struct ata_port *ap, struct ata_taskfile *tf, uns
                tf->device = ATA_DEVICE_OBS | ATA_DEV1;
 }
 
+
+/**
+ *     ata_irq_on - Enable interrupts on a port.
+ *     @ap: Port on which interrupts are enabled.
+ *
+ *     Enable interrupts on a legacy IDE device using MMIO or PIO,
+ *     wait for idle, clear any pending interrupts.
+ *
+ *     LOCKING:
+ *     Inherited from caller.
+ */
+
 static inline u8 ata_irq_on(struct ata_port *ap)
 {
        struct ata_ioports *ioaddr = &ap->ioaddr;
@@ -543,6 +597,18 @@ static inline u8 ata_irq_on(struct ata_port *ap)
        return tmp;
 }
 
+
+/**
+ *     ata_irq_ack - Acknowledge a device interrupt.
+ *     @ap: Port on which interrupts are enabled.
+ *
+ *     Wait up to 10 ms for legacy IDE device to become idle (BUSY
+ *     or BUSY+DRQ clear).  Obtain dma status and port status from
+ *     device.  Clear the interrupt.  Return port status.
+ *
+ *     LOCKING:
+ */
+
 static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq)
 {
        unsigned int bits = chk_drq ? ATA_BUSY | ATA_DRQ : ATA_BUSY;