2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-21 03:33:59 +08:00

Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6: (27 commits)
  xsysace: Fix dereferencing of cf_id after hd_driveid removal
  at91_ide: turn on PIO 6 support
  at91_ide: remove unused ide_mm_{outb,inb}
  ide-cd: reverse NOT_READY sense key logic
  ide: refactor tf_read() method
  ide: refactor tf_load() method
  ide: call write_devctl() method from tf_read() method
  ide: move common code out of tf_load() method
  ide: simplify 'struct ide_taskfile'
  ide: replace IDE_TFLAG_* flags by IDE_VALID_*
  ide-cd: fix intendation in cdrom_decode_status()
  ide-cd: unify handling of fs and pc requests in cdrom_decode_status()
  ide-cd: convert cdrom_decode_status() to use switch statements
  ide-cd: update debugging support
  ide-cd: respect REQ_QUIET for fs requests in cdrom_decode_status()
  ide: remove unused #include <linux/version.h>
  tx4939ide: Fix tx4939ide_{in,out}put_data_swap argument
  tx493[89]ide: Remove big endian version of tx493[89]ide_tf_{load,read}
  ide-cd: carve out an ide_cd_breathe()-helper for fs write requests
  ide-cd: move status checking into the IRQ handler
  ...
This commit is contained in:
Linus Torvalds 2009-04-09 16:43:30 -07:00
commit 6594d0b1cd
26 changed files with 466 additions and 921 deletions

View File

@ -563,7 +563,7 @@ static void ace_fsm_dostate(struct ace_device *ace)
case ACE_FSM_STATE_IDENTIFY_PREPARE: case ACE_FSM_STATE_IDENTIFY_PREPARE:
/* Send identify command */ /* Send identify command */
ace->fsm_task = ACE_TASK_IDENTIFY; ace->fsm_task = ACE_TASK_IDENTIFY;
ace->data_ptr = &ace->cf_id; ace->data_ptr = ace->cf_id;
ace->data_count = ACE_BUF_PER_SECTOR; ace->data_count = ACE_BUF_PER_SECTOR;
ace_out(ace, ACE_SECCNTCMD, ACE_SECCNTCMD_IDENTIFY); ace_out(ace, ACE_SECCNTCMD, ACE_SECCNTCMD_IDENTIFY);
@ -608,8 +608,8 @@ static void ace_fsm_dostate(struct ace_device *ace)
break; break;
case ACE_FSM_STATE_IDENTIFY_COMPLETE: case ACE_FSM_STATE_IDENTIFY_COMPLETE:
ace_fix_driveid(&ace->cf_id[0]); ace_fix_driveid(ace->cf_id);
ace_dump_mem(&ace->cf_id, 512); /* Debug: Dump out disk ID */ ace_dump_mem(ace->cf_id, 512); /* Debug: Dump out disk ID */
if (ace->data_result) { if (ace->data_result) {
/* Error occured, disable the disk */ /* Error occured, disable the disk */
@ -622,9 +622,9 @@ static void ace_fsm_dostate(struct ace_device *ace)
/* Record disk parameters */ /* Record disk parameters */
set_capacity(ace->gd, set_capacity(ace->gd,
ata_id_u32(&ace->cf_id, ATA_ID_LBA_CAPACITY)); ata_id_u32(ace->cf_id, ATA_ID_LBA_CAPACITY));
dev_info(ace->dev, "capacity: %i sectors\n", dev_info(ace->dev, "capacity: %i sectors\n",
ata_id_u32(&ace->cf_id, ATA_ID_LBA_CAPACITY)); ata_id_u32(ace->cf_id, ATA_ID_LBA_CAPACITY));
} }
/* We're done, drop to IDLE state and notify waiters */ /* We're done, drop to IDLE state and notify waiters */
@ -923,7 +923,7 @@ static int ace_release(struct gendisk *disk, fmode_t mode)
static int ace_getgeo(struct block_device *bdev, struct hd_geometry *geo) static int ace_getgeo(struct block_device *bdev, struct hd_geometry *geo)
{ {
struct ace_device *ace = bdev->bd_disk->private_data; struct ace_device *ace = bdev->bd_disk->private_data;
u16 *cf_id = &ace->cf_id[0]; u16 *cf_id = ace->cf_id;
dev_dbg(ace->dev, "ace_getgeo()\n"); dev_dbg(ace->dev, "ace_getgeo()\n");

View File

@ -20,7 +20,6 @@
* *
*/ */
#include <linux/version.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/clk.h> #include <linux/clk.h>
@ -175,90 +174,6 @@ static void at91_ide_output_data(ide_drive_t *drive, struct ide_cmd *cmd,
leave_16bit(chipselect, mode); leave_16bit(chipselect, mode);
} }
static u8 ide_mm_inb(unsigned long port)
{
return readb((void __iomem *) port);
}
static void ide_mm_outb(u8 value, unsigned long port)
{
writeb(value, (void __iomem *) port);
}
static void at91_ide_tf_load(ide_drive_t *drive, struct ide_cmd *cmd)
{
ide_hwif_t *hwif = drive->hwif;
struct ide_io_ports *io_ports = &hwif->io_ports;
struct ide_taskfile *tf = &cmd->tf;
u8 HIHI = (cmd->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF;
if (cmd->ftf_flags & IDE_FTFLAG_FLAGGED)
HIHI = 0xFF;
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE)
ide_mm_outb(tf->hob_feature, io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_NSECT)
ide_mm_outb(tf->hob_nsect, io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAL)
ide_mm_outb(tf->hob_lbal, io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAM)
ide_mm_outb(tf->hob_lbam, io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAH)
ide_mm_outb(tf->hob_lbah, io_ports->lbah_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_FEATURE)
ide_mm_outb(tf->feature, io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_NSECT)
ide_mm_outb(tf->nsect, io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_LBAL)
ide_mm_outb(tf->lbal, io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_LBAM)
ide_mm_outb(tf->lbam, io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_LBAH)
ide_mm_outb(tf->lbah, io_ports->lbah_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_DEVICE)
ide_mm_outb((tf->device & HIHI) | drive->select, io_ports->device_addr);
}
static void at91_ide_tf_read(ide_drive_t *drive, struct ide_cmd *cmd)
{
ide_hwif_t *hwif = drive->hwif;
struct ide_io_ports *io_ports = &hwif->io_ports;
struct ide_taskfile *tf = &cmd->tf;
/* be sure we're looking at the low order bits */
ide_mm_outb(ATA_DEVCTL_OBS, io_ports->ctl_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_ERROR)
tf->error = ide_mm_inb(io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_NSECT)
tf->nsect = ide_mm_inb(io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAL)
tf->lbal = ide_mm_inb(io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAM)
tf->lbam = ide_mm_inb(io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAH)
tf->lbah = ide_mm_inb(io_ports->lbah_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_DEVICE)
tf->device = ide_mm_inb(io_ports->device_addr);
if (cmd->tf_flags & IDE_TFLAG_LBA48) {
ide_mm_outb(ATA_HOB | ATA_DEVCTL_OBS, io_ports->ctl_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_ERROR)
tf->hob_error = ide_mm_inb(io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_NSECT)
tf->hob_nsect = ide_mm_inb(io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAL)
tf->hob_lbal = ide_mm_inb(io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAM)
tf->hob_lbam = ide_mm_inb(io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAH)
tf->hob_lbah = ide_mm_inb(io_ports->lbah_addr);
}
}
static void at91_ide_set_pio_mode(ide_drive_t *drive, const u8 pio) static void at91_ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
{ {
struct ide_timing *timing; struct ide_timing *timing;
@ -284,8 +199,8 @@ static const struct ide_tp_ops at91_ide_tp_ops = {
.write_devctl = ide_write_devctl, .write_devctl = ide_write_devctl,
.dev_select = ide_dev_select, .dev_select = ide_dev_select,
.tf_load = at91_ide_tf_load, .tf_load = ide_tf_load,
.tf_read = at91_ide_tf_read, .tf_read = ide_tf_read,
.input_data = at91_ide_input_data, .input_data = at91_ide_input_data,
.output_data = at91_ide_output_data, .output_data = at91_ide_output_data,
@ -300,7 +215,7 @@ static const struct ide_port_info at91_ide_port_info __initdata = {
.tp_ops = &at91_ide_tp_ops, .tp_ops = &at91_ide_tp_ops,
.host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA | IDE_HFLAG_SINGLE | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA | IDE_HFLAG_SINGLE |
IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_UNMASK_IRQS, IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_UNMASK_IRQS,
.pio_mask = ATA_PIO5, .pio_mask = ATA_PIO6,
}; };
/* /*

View File

@ -20,6 +20,7 @@
#include <asm/atarihw.h> #include <asm/atarihw.h>
#include <asm/atariints.h> #include <asm/atariints.h>
#include <asm/atari_stdma.h> #include <asm/atari_stdma.h>
#include <asm/ide.h>
#define DRV_NAME "falconide" #define DRV_NAME "falconide"
@ -67,8 +68,10 @@ static void falconide_input_data(ide_drive_t *drive, struct ide_cmd *cmd,
{ {
unsigned long data_addr = drive->hwif->io_ports.data_addr; unsigned long data_addr = drive->hwif->io_ports.data_addr;
if (drive->media == ide_disk && cmd && (cmd->tf_flags & IDE_TFLAG_FS)) if (drive->media == ide_disk && cmd && (cmd->tf_flags & IDE_TFLAG_FS)) {
return insw(data_addr, buf, (len + 1) / 2); __ide_mm_insw(data_addr, buf, (len + 1) / 2);
return;
}
raw_insw_swapw((u16 *)data_addr, buf, (len + 1) / 2); raw_insw_swapw((u16 *)data_addr, buf, (len + 1) / 2);
} }
@ -78,8 +81,10 @@ static void falconide_output_data(ide_drive_t *drive, struct ide_cmd *cmd,
{ {
unsigned long data_addr = drive->hwif->io_ports.data_addr; unsigned long data_addr = drive->hwif->io_ports.data_addr;
if (drive->media == ide_disk && cmd && (cmd->tf_flags & IDE_TFLAG_FS)) if (drive->media == ide_disk && cmd && (cmd->tf_flags & IDE_TFLAG_FS)) {
return outsw(data_addr, buf, (len + 1) / 2); __ide_mm_outsw(data_addr, buf, (len + 1) / 2);
return;
}
raw_outsw_swapw((u16 *)data_addr, buf, (len + 1) / 2); raw_outsw_swapw((u16 *)data_addr, buf, (len + 1) / 2);
} }

View File

@ -318,8 +318,9 @@ static int do_drive_set_taskfiles(ide_drive_t *drive,
/* convert GTF to taskfile */ /* convert GTF to taskfile */
memset(&cmd, 0, sizeof(cmd)); memset(&cmd, 0, sizeof(cmd));
memcpy(&cmd.tf_array[7], gtf, REGS_PER_GTF); memcpy(&cmd.tf.feature, gtf, REGS_PER_GTF);
cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
err = ide_no_data_taskfile(drive, &cmd); err = ide_no_data_taskfile(drive, &cmd);
if (err) { if (err) {

View File

@ -254,16 +254,13 @@ EXPORT_SYMBOL_GPL(ide_cd_get_xferlen);
void ide_read_bcount_and_ireason(ide_drive_t *drive, u16 *bcount, u8 *ireason) void ide_read_bcount_and_ireason(ide_drive_t *drive, u16 *bcount, u8 *ireason)
{ {
struct ide_cmd cmd; struct ide_taskfile tf;
memset(&cmd, 0, sizeof(cmd)); drive->hwif->tp_ops->tf_read(drive, &tf, IDE_VALID_NSECT |
cmd.tf_flags = IDE_TFLAG_IN_LBAH | IDE_TFLAG_IN_LBAM | IDE_VALID_LBAM | IDE_VALID_LBAH);
IDE_TFLAG_IN_NSECT;
drive->hwif->tp_ops->tf_read(drive, &cmd); *bcount = (tf.lbah << 8) | tf.lbam;
*ireason = tf.nsect & 3;
*bcount = (cmd.tf.lbah << 8) | cmd.tf.lbam;
*ireason = cmd.tf.nsect & 3;
} }
EXPORT_SYMBOL_GPL(ide_read_bcount_and_ireason); EXPORT_SYMBOL_GPL(ide_read_bcount_and_ireason);
@ -439,12 +436,12 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
return ide_started; return ide_started;
} }
static void ide_init_packet_cmd(struct ide_cmd *cmd, u32 tf_flags, static void ide_init_packet_cmd(struct ide_cmd *cmd, u8 valid_tf,
u16 bcount, u8 dma) u16 bcount, u8 dma)
{ {
cmd->protocol = dma ? ATAPI_PROT_DMA : ATAPI_PROT_PIO; cmd->protocol = dma ? ATAPI_PROT_DMA : ATAPI_PROT_PIO;
cmd->tf_flags |= IDE_TFLAG_OUT_LBAH | IDE_TFLAG_OUT_LBAM | cmd->valid.out.tf = IDE_VALID_LBAH | IDE_VALID_LBAM |
IDE_TFLAG_OUT_FEATURE | tf_flags; IDE_VALID_FEATURE | valid_tf;
cmd->tf.command = ATA_CMD_PACKET; cmd->tf.command = ATA_CMD_PACKET;
cmd->tf.feature = dma; /* Use PIO/DMA */ cmd->tf.feature = dma; /* Use PIO/DMA */
cmd->tf.lbam = bcount & 0xff; cmd->tf.lbam = bcount & 0xff;
@ -453,14 +450,11 @@ static void ide_init_packet_cmd(struct ide_cmd *cmd, u32 tf_flags,
static u8 ide_read_ireason(ide_drive_t *drive) static u8 ide_read_ireason(ide_drive_t *drive)
{ {
struct ide_cmd cmd; struct ide_taskfile tf;
memset(&cmd, 0, sizeof(cmd)); drive->hwif->tp_ops->tf_read(drive, &tf, IDE_VALID_NSECT);
cmd.tf_flags = IDE_TFLAG_IN_NSECT;
drive->hwif->tp_ops->tf_read(drive, &cmd); return tf.nsect & 3;
return cmd.tf.nsect & 3;
} }
static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason) static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason)
@ -588,12 +582,12 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd)
ide_expiry_t *expiry = NULL; ide_expiry_t *expiry = NULL;
struct request *rq = hwif->rq; struct request *rq = hwif->rq;
unsigned int timeout; unsigned int timeout;
u32 tf_flags;
u16 bcount; u16 bcount;
u8 valid_tf;
u8 drq_int = !!(drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT); u8 drq_int = !!(drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT);
if (dev_is_idecd(drive)) { if (dev_is_idecd(drive)) {
tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL; valid_tf = IDE_VALID_NSECT | IDE_VALID_LBAL;
bcount = ide_cd_get_xferlen(rq); bcount = ide_cd_get_xferlen(rq);
expiry = ide_cd_expiry; expiry = ide_cd_expiry;
timeout = ATAPI_WAIT_PC; timeout = ATAPI_WAIT_PC;
@ -607,7 +601,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd)
pc->xferred = 0; pc->xferred = 0;
pc->cur_pos = pc->buf; pc->cur_pos = pc->buf;
tf_flags = IDE_TFLAG_OUT_DEVICE; valid_tf = IDE_VALID_DEVICE;
bcount = ((drive->media == ide_tape) ? bcount = ((drive->media == ide_tape) ?
pc->req_xfer : pc->req_xfer :
min(pc->req_xfer, 63 * 1024)); min(pc->req_xfer, 63 * 1024));
@ -627,7 +621,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd)
: WAIT_TAPE_CMD; : WAIT_TAPE_CMD;
} }
ide_init_packet_cmd(cmd, tf_flags, bcount, drive->dma); ide_init_packet_cmd(cmd, valid_tf, bcount, drive->dma);
(void)do_rw_taskfile(drive, cmd); (void)do_rw_taskfile(drive, cmd);

View File

@ -265,35 +265,62 @@ static void ide_cd_complete_failed_rq(ide_drive_t *drive, struct request *rq)
cdrom_analyze_sense_data(drive, NULL, sense); cdrom_analyze_sense_data(drive, NULL, sense);
} }
/* /*
* Allow the drive 5 seconds to recover; some devices will return NOT_READY
* while flushing data from cache.
*
* returns: 0 failed (write timeout expired)
* 1 success
*/
static int ide_cd_breathe(ide_drive_t *drive, struct request *rq)
{
struct cdrom_info *info = drive->driver_data;
if (!rq->errors)
info->write_timeout = jiffies + ATAPI_WAIT_WRITE_BUSY;
rq->errors = 1;
if (time_after(jiffies, info->write_timeout))
return 0;
else {
struct request_queue *q = drive->queue;
unsigned long flags;
/*
* take a breather relying on the unplug timer to kick us again
*/
spin_lock_irqsave(q->queue_lock, flags);
blk_plug_device(q);
spin_unlock_irqrestore(q->queue_lock, flags);
return 1;
}
}
/**
* Returns: * Returns:
* 0: if the request should be continued. * 0: if the request should be continued.
* 1: if the request will be going through error recovery. * 1: if the request will be going through error recovery.
* 2: if the request should be ended. * 2: if the request should be ended.
*/ */
static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
{ {
ide_hwif_t *hwif = drive->hwif; ide_hwif_t *hwif = drive->hwif;
struct request *rq = hwif->rq; struct request *rq = hwif->rq;
int stat, err, sense_key; int err, sense_key, do_end_request = 0;
u8 quiet = rq->cmd_flags & REQ_QUIET;
/* check for errors */
stat = hwif->tp_ops->read_status(hwif);
if (stat_ret)
*stat_ret = stat;
if (OK_STAT(stat, good_stat, BAD_R_STAT))
return 0;
/* get the IDE error register */ /* get the IDE error register */
err = ide_read_error(drive); err = ide_read_error(drive);
sense_key = err >> 4; sense_key = err >> 4;
ide_debug_log(IDE_DBG_RQ, "stat: 0x%x, good_stat: 0x%x, cmd[0]: 0x%x, " ide_debug_log(IDE_DBG_RQ, "cmd: 0x%x, rq->cmd_type: 0x%x, err: 0x%x, "
"rq->cmd_type: 0x%x, err: 0x%x", "stat 0x%x",
stat, good_stat, rq->cmd[0], rq->cmd_type, rq->cmd[0], rq->cmd_type, err, stat);
err);
if (blk_sense_request(rq)) { if (blk_sense_request(rq)) {
/* /*
@ -303,151 +330,108 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
*/ */
rq->cmd_flags |= REQ_FAILED; rq->cmd_flags |= REQ_FAILED;
return 2; return 2;
} else if (blk_pc_request(rq) || rq->cmd_type == REQ_TYPE_ATA_PC) { }
/* All other functions, except for READ. */
/* /* if we have an error, pass CHECK_CONDITION as the SCSI status byte */
* if we have an error, pass back CHECK_CONDITION as the if (blk_pc_request(rq) && !rq->errors)
* scsi status byte rq->errors = SAM_STAT_CHECK_CONDITION;
*/
if (blk_pc_request(rq) && !rq->errors)
rq->errors = SAM_STAT_CHECK_CONDITION;
/* check for tray open */ if (blk_noretry_request(rq))
if (sense_key == NOT_READY) { do_end_request = 1;
switch (sense_key) {
case NOT_READY:
if (blk_fs_request(rq) && rq_data_dir(rq) == WRITE) {
if (ide_cd_breathe(drive, rq))
return 1;
} else {
cdrom_saw_media_change(drive); cdrom_saw_media_change(drive);
} else if (sense_key == UNIT_ATTENTION) {
/* check for media change */
cdrom_saw_media_change(drive);
return 0;
} else if (sense_key == ILLEGAL_REQUEST &&
rq->cmd[0] == GPCMD_START_STOP_UNIT) {
/*
* Don't print error message for this condition--
* SFF8090i indicates that 5/24/00 is the correct
* response to a request to close the tray if the
* drive doesn't have that capability.
* cdrom_log_sense() knows this!
*/
} else if (!(rq->cmd_flags & REQ_QUIET)) {
/* otherwise, print an error */
ide_dump_status(drive, "packet command error", stat);
}
rq->cmd_flags |= REQ_FAILED; if (blk_fs_request(rq) && !quiet)
/*
* instead of playing games with moving completions around,
* remove failed request completely and end it when the
* request sense has completed
*/
goto end_request;
} else if (blk_fs_request(rq)) {
int do_end_request = 0;
/* handle errors from READ and WRITE requests */
if (blk_noretry_request(rq))
do_end_request = 1;
if (sense_key == NOT_READY) {
/* tray open */
if (rq_data_dir(rq) == READ) {
cdrom_saw_media_change(drive);
/* fail the request */
printk(KERN_ERR PFX "%s: tray open\n", printk(KERN_ERR PFX "%s: tray open\n",
drive->name); drive->name);
do_end_request = 1; }
} else { do_end_request = 1;
struct cdrom_info *info = drive->driver_data; break;
case UNIT_ATTENTION:
cdrom_saw_media_change(drive);
/* if (blk_fs_request(rq) == 0)
* Allow the drive 5 seconds to recover, some return 0;
* devices will return this error while flushing
* data from cache.
*/
if (!rq->errors)
info->write_timeout = jiffies +
ATAPI_WAIT_WRITE_BUSY;
rq->errors = 1;
if (time_after(jiffies, info->write_timeout))
do_end_request = 1;
else {
struct request_queue *q = drive->queue;
unsigned long flags;
/* /*
* take a breather relying on the unplug * Arrange to retry the request but be sure to give up if we've
* timer to kick us again * retried too many times.
*/ */
spin_lock_irqsave(q->queue_lock, flags); if (++rq->errors > ERROR_MAX)
blk_plug_device(q); do_end_request = 1;
spin_unlock_irqrestore(q->queue_lock, flags); break;
case ILLEGAL_REQUEST:
return 1; /*
} * Don't print error message for this condition -- SFF8090i
} * indicates that 5/24/00 is the correct response to a request
} else if (sense_key == UNIT_ATTENTION) { * to close the tray if the drive doesn't have that capability.
/* media change */ *
cdrom_saw_media_change(drive); * cdrom_log_sense() knows this!
*/
/* if (rq->cmd[0] == GPCMD_START_STOP_UNIT)
* Arrange to retry the request but be sure to give up break;
* if we've retried too many times. /* fall-through */
*/ case DATA_PROTECT:
if (++rq->errors > ERROR_MAX) /*
do_end_request = 1; * No point in retrying after an illegal request or data
} else if (sense_key == ILLEGAL_REQUEST || * protect error.
sense_key == DATA_PROTECT) { */
/* if (!quiet)
* No point in retrying after an illegal request or data
* protect error.
*/
ide_dump_status(drive, "command error", stat); ide_dump_status(drive, "command error", stat);
do_end_request = 1; do_end_request = 1;
} else if (sense_key == MEDIUM_ERROR) { break;
/* case MEDIUM_ERROR:
* No point in re-trying a zillion times on a bad /*
* sector. If we got here the error is not correctable. * No point in re-trying a zillion times on a bad sector.
*/ * If we got here the error is not correctable.
ide_dump_status(drive, "media error (bad sector)", */
if (!quiet)
ide_dump_status(drive, "media error "
"(bad sector)", stat);
do_end_request = 1;
break;
case BLANK_CHECK:
/* disk appears blank? */
if (!quiet)
ide_dump_status(drive, "media error (blank)",
stat); stat);
do_end_request = 1; do_end_request = 1;
} else if (sense_key == BLANK_CHECK) { break;
/* disk appears blank ?? */ default:
ide_dump_status(drive, "media error (blank)", stat); if (blk_fs_request(rq) == 0)
do_end_request = 1; break;
} else if ((err & ~ATA_ABORTED) != 0) { if (err & ~ATA_ABORTED) {
/* go to the default handler for other errors */ /* go to the default handler for other errors */
ide_error(drive, "cdrom_decode_status", stat); ide_error(drive, "cdrom_decode_status", stat);
return 1; return 1;
} else if ((++rq->errors > ERROR_MAX)) { } else if (++rq->errors > ERROR_MAX)
/* we've racked up too many retries, abort */ /* we've racked up too many retries, abort */
do_end_request = 1; do_end_request = 1;
}
/*
* End a request through request sense analysis when we have
* sense data. We need this in order to perform end of media
* processing.
*/
if (do_end_request)
goto end_request;
/*
* If we got a CHECK_CONDITION status, queue
* a request sense command.
*/
if (stat & ATA_ERR)
cdrom_queue_request_sense(drive, NULL, NULL);
return 1;
} else {
blk_dump_rq_flags(rq, PFX "bad rq");
return 2;
} }
if (blk_fs_request(rq) == 0) {
rq->cmd_flags |= REQ_FAILED;
do_end_request = 1;
}
/*
* End a request through request sense analysis when we have sense data.
* We need this in order to perform end of media processing.
*/
if (do_end_request)
goto end_request;
/* if we got a CHECK_CONDITION status, queue a request sense command */
if (stat & ATA_ERR)
cdrom_queue_request_sense(drive, NULL, NULL);
return 1;
end_request: end_request:
if (stat & ATA_ERR) { if (stat & ATA_ERR) {
struct request_queue *q = drive->queue; struct request_queue *q = drive->queue;
@ -624,15 +608,14 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
struct ide_cmd *cmd = &hwif->cmd; struct ide_cmd *cmd = &hwif->cmd;
struct request *rq = hwif->rq; struct request *rq = hwif->rq;
ide_expiry_t *expiry = NULL; ide_expiry_t *expiry = NULL;
int dma_error = 0, dma, stat, thislen, uptodate = 0; int dma_error = 0, dma, thislen, uptodate = 0;
int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc, nsectors; int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc, nsectors;
int sense = blk_sense_request(rq); int sense = blk_sense_request(rq);
unsigned int timeout; unsigned int timeout;
u16 len; u16 len;
u8 ireason; u8 ireason, stat;
ide_debug_log(IDE_DBG_PC, "cmd[0]: 0x%x, write: 0x%x", ide_debug_log(IDE_DBG_PC, "cmd: 0x%x, write: 0x%x", rq->cmd[0], write);
rq->cmd[0], write);
/* check for errors */ /* check for errors */
dma = drive->dma; dma = drive->dma;
@ -648,11 +631,16 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
} }
} }
rc = cdrom_decode_status(drive, 0, &stat); /* check status */
if (rc) { stat = hwif->tp_ops->read_status(hwif);
if (rc == 2)
goto out_end; if (!OK_STAT(stat, 0, BAD_R_STAT)) {
return ide_stopped; rc = cdrom_decode_status(drive, stat);
if (rc) {
if (rc == 2)
goto out_end;
return ide_stopped;
}
} }
/* using dma, transfer is complete now */ /* using dma, transfer is complete now */

View File

@ -97,35 +97,38 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
} }
memset(&cmd, 0, sizeof(cmd)); memset(&cmd, 0, sizeof(cmd));
cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
if (drive->dev_flags & IDE_DFLAG_LBA) { if (drive->dev_flags & IDE_DFLAG_LBA) {
if (lba48) { if (lba48) {
pr_debug("%s: LBA=0x%012llx\n", drive->name, pr_debug("%s: LBA=0x%012llx\n", drive->name,
(unsigned long long)block); (unsigned long long)block);
tf->hob_nsect = (nsectors >> 8) & 0xff;
tf->hob_lbal = (u8)(block >> 24);
if (sizeof(block) != 4) {
tf->hob_lbam = (u8)((u64)block >> 32);
tf->hob_lbah = (u8)((u64)block >> 40);
}
tf->nsect = nsectors & 0xff; tf->nsect = nsectors & 0xff;
tf->lbal = (u8) block; tf->lbal = (u8) block;
tf->lbam = (u8)(block >> 8); tf->lbam = (u8)(block >> 8);
tf->lbah = (u8)(block >> 16); tf->lbah = (u8)(block >> 16);
tf->device = ATA_LBA;
cmd.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_HOB); tf = &cmd.hob;
tf->nsect = (nsectors >> 8) & 0xff;
tf->lbal = (u8)(block >> 24);
if (sizeof(block) != 4) {
tf->lbam = (u8)((u64)block >> 32);
tf->lbah = (u8)((u64)block >> 40);
}
cmd.valid.out.hob = IDE_VALID_OUT_HOB;
cmd.valid.in.hob = IDE_VALID_IN_HOB;
cmd.tf_flags |= IDE_TFLAG_LBA48;
} else { } else {
tf->nsect = nsectors & 0xff; tf->nsect = nsectors & 0xff;
tf->lbal = block; tf->lbal = block;
tf->lbam = block >>= 8; tf->lbam = block >>= 8;
tf->lbah = block >>= 8; tf->lbah = block >>= 8;
tf->device = (block >> 8) & 0xf; tf->device = ((block >> 8) & 0xf) | ATA_LBA;
} }
tf->device |= ATA_LBA;
} else { } else {
unsigned int sect, head, cyl, track; unsigned int sect, head, cyl, track;
@ -220,15 +223,19 @@ static u64 idedisk_read_native_max_address(ide_drive_t *drive, int lba48)
tf->command = ATA_CMD_READ_NATIVE_MAX; tf->command = ATA_CMD_READ_NATIVE_MAX;
tf->device = ATA_LBA; tf->device = ATA_LBA;
cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
if (lba48) cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
cmd.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_HOB); if (lba48) {
cmd.valid.out.hob = IDE_VALID_OUT_HOB;
cmd.valid.in.hob = IDE_VALID_IN_HOB;
cmd.tf_flags = IDE_TFLAG_LBA48;
}
ide_no_data_taskfile(drive, &cmd); ide_no_data_taskfile(drive, &cmd);
/* if OK, compute maximum address value */ /* if OK, compute maximum address value */
if (!(tf->status & ATA_ERR)) if (!(tf->status & ATA_ERR))
addr = ide_get_lba_addr(tf, lba48) + 1; addr = ide_get_lba_addr(&cmd, lba48) + 1;
return addr; return addr;
} }
@ -250,9 +257,9 @@ static u64 idedisk_set_max_address(ide_drive_t *drive, u64 addr_req, int lba48)
tf->lbam = (addr_req >>= 8) & 0xff; tf->lbam = (addr_req >>= 8) & 0xff;
tf->lbah = (addr_req >>= 8) & 0xff; tf->lbah = (addr_req >>= 8) & 0xff;
if (lba48) { if (lba48) {
tf->hob_lbal = (addr_req >>= 8) & 0xff; cmd.hob.lbal = (addr_req >>= 8) & 0xff;
tf->hob_lbam = (addr_req >>= 8) & 0xff; cmd.hob.lbam = (addr_req >>= 8) & 0xff;
tf->hob_lbah = (addr_req >>= 8) & 0xff; cmd.hob.lbah = (addr_req >>= 8) & 0xff;
tf->command = ATA_CMD_SET_MAX_EXT; tf->command = ATA_CMD_SET_MAX_EXT;
} else { } else {
tf->device = (addr_req >>= 8) & 0x0f; tf->device = (addr_req >>= 8) & 0x0f;
@ -260,15 +267,19 @@ static u64 idedisk_set_max_address(ide_drive_t *drive, u64 addr_req, int lba48)
} }
tf->device |= ATA_LBA; tf->device |= ATA_LBA;
cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
if (lba48) cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
cmd.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_HOB); if (lba48) {
cmd.valid.out.hob = IDE_VALID_OUT_HOB;
cmd.valid.in.hob = IDE_VALID_IN_HOB;
cmd.tf_flags = IDE_TFLAG_LBA48;
}
ide_no_data_taskfile(drive, &cmd); ide_no_data_taskfile(drive, &cmd);
/* if OK, compute maximum address value */ /* if OK, compute maximum address value */
if (!(tf->status & ATA_ERR)) if (!(tf->status & ATA_ERR))
addr_set = ide_get_lba_addr(tf, lba48) + 1; addr_set = ide_get_lba_addr(&cmd, lba48) + 1;
return addr_set; return addr_set;
} }
@ -395,8 +406,8 @@ static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
cmd->tf.command = ATA_CMD_FLUSH_EXT; cmd->tf.command = ATA_CMD_FLUSH_EXT;
else else
cmd->tf.command = ATA_CMD_FLUSH; cmd->tf.command = ATA_CMD_FLUSH;
cmd->tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE | cmd->valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
IDE_TFLAG_DYN; cmd->tf_flags = IDE_TFLAG_DYN;
cmd->protocol = ATA_PROT_NODATA; cmd->protocol = ATA_PROT_NODATA;
rq->cmd_type = REQ_TYPE_ATA_TASKFILE; rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
@ -457,7 +468,8 @@ static int ide_do_setfeature(ide_drive_t *drive, u8 feature, u8 nsect)
cmd.tf.feature = feature; cmd.tf.feature = feature;
cmd.tf.nsect = nsect; cmd.tf.nsect = nsect;
cmd.tf.command = ATA_CMD_SET_FEATURES; cmd.tf.command = ATA_CMD_SET_FEATURES;
cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
return ide_no_data_taskfile(drive, &cmd); return ide_no_data_taskfile(drive, &cmd);
} }
@ -533,7 +545,8 @@ static int do_idedisk_flushcache(ide_drive_t *drive)
cmd.tf.command = ATA_CMD_FLUSH_EXT; cmd.tf.command = ATA_CMD_FLUSH_EXT;
else else
cmd.tf.command = ATA_CMD_FLUSH; cmd.tf.command = ATA_CMD_FLUSH;
cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
return ide_no_data_taskfile(drive, &cmd); return ide_no_data_taskfile(drive, &cmd);
} }
@ -715,7 +728,8 @@ static int ide_disk_set_doorlock(ide_drive_t *drive, struct gendisk *disk,
memset(&cmd, 0, sizeof(cmd)); memset(&cmd, 0, sizeof(cmd));
cmd.tf.command = on ? ATA_CMD_MEDIA_LOCK : ATA_CMD_MEDIA_UNLOCK; cmd.tf.command = on ? ATA_CMD_MEDIA_LOCK : ATA_CMD_MEDIA_UNLOCK;
cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
ret = ide_no_data_taskfile(drive, &cmd); ret = ide_no_data_taskfile(drive, &cmd);

View File

@ -13,7 +13,8 @@ static int smart_enable(ide_drive_t *drive)
tf->lbam = ATA_SMART_LBAM_PASS; tf->lbam = ATA_SMART_LBAM_PASS;
tf->lbah = ATA_SMART_LBAH_PASS; tf->lbah = ATA_SMART_LBAH_PASS;
tf->command = ATA_CMD_SMART; tf->command = ATA_CMD_SMART;
cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
return ide_no_data_taskfile(drive, &cmd); return ide_no_data_taskfile(drive, &cmd);
} }
@ -29,7 +30,8 @@ static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd)
tf->lbam = ATA_SMART_LBAM_PASS; tf->lbam = ATA_SMART_LBAM_PASS;
tf->lbah = ATA_SMART_LBAH_PASS; tf->lbah = ATA_SMART_LBAH_PASS;
tf->command = ATA_CMD_SMART; tf->command = ATA_CMD_SMART;
cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
cmd.protocol = ATA_PROT_PIO; cmd.protocol = ATA_PROT_PIO;
return ide_raw_taskfile(drive, &cmd, buf, 1); return ide_raw_taskfile(drive, &cmd, buf, 1);

View File

@ -277,8 +277,6 @@ void ide_dma_start(ide_drive_t *drive)
dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD);
outb(dma_cmd | ATA_DMA_START, hwif->dma_base + ATA_DMA_CMD); outb(dma_cmd | ATA_DMA_START, hwif->dma_base + ATA_DMA_CMD);
} }
wmb();
} }
EXPORT_SYMBOL_GPL(ide_dma_start); EXPORT_SYMBOL_GPL(ide_dma_start);
@ -286,7 +284,7 @@ EXPORT_SYMBOL_GPL(ide_dma_start);
int ide_dma_end(ide_drive_t *drive) int ide_dma_end(ide_drive_t *drive)
{ {
ide_hwif_t *hwif = drive->hwif; ide_hwif_t *hwif = drive->hwif;
u8 dma_stat = 0, dma_cmd = 0, mask; u8 dma_stat = 0, dma_cmd = 0;
/* stop DMA */ /* stop DMA */
if (hwif->host_flags & IDE_HFLAG_MMIO) { if (hwif->host_flags & IDE_HFLAG_MMIO) {
@ -304,11 +302,10 @@ int ide_dma_end(ide_drive_t *drive)
/* clear INTR & ERROR bits */ /* clear INTR & ERROR bits */
ide_dma_sff_write_status(hwif, dma_stat | ATA_DMA_ERR | ATA_DMA_INTR); ide_dma_sff_write_status(hwif, dma_stat | ATA_DMA_ERR | ATA_DMA_INTR);
wmb(); #define CHECK_DMA_MASK (ATA_DMA_ACTIVE | ATA_DMA_ERR | ATA_DMA_INTR)
/* verify good DMA status */ /* verify good DMA status */
mask = ATA_DMA_ACTIVE | ATA_DMA_ERR | ATA_DMA_INTR; if ((dma_stat & CHECK_DMA_MASK) != ATA_DMA_INTR)
if ((dma_stat & mask) != ATA_DMA_INTR)
return 0x10 | dma_stat; return 0x10 | dma_stat;
return 0; return 0;
} }

View File

@ -22,103 +22,6 @@
(r); \ (r); \
}) })
static void mm_outw(u16 d, unsigned long a)
{
__asm__("mov.b %w0,r2h\n\t"
"mov.b %x0,r2l\n\t"
"mov.w r2,@%1"
:
:"r"(d),"r"(a)
:"er2");
}
static u16 mm_inw(unsigned long a)
{
register u16 r __asm__("er0");
__asm__("mov.w @%1,r2\n\t"
"mov.b r2l,%x0\n\t"
"mov.b r2h,%w0"
:"=r"(r)
:"r"(a)
:"er2");
return r;
}
static void h8300_tf_load(ide_drive_t *drive, struct ide_cmd *cmd)
{
ide_hwif_t *hwif = drive->hwif;
struct ide_io_ports *io_ports = &hwif->io_ports;
struct ide_taskfile *tf = &cmd->tf;
u8 HIHI = (cmd->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF;
if (cmd->ftf_flags & IDE_FTFLAG_FLAGGED)
HIHI = 0xFF;
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE)
outb(tf->hob_feature, io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_NSECT)
outb(tf->hob_nsect, io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAL)
outb(tf->hob_lbal, io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAM)
outb(tf->hob_lbam, io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAH)
outb(tf->hob_lbah, io_ports->lbah_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_FEATURE)
outb(tf->feature, io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_NSECT)
outb(tf->nsect, io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_LBAL)
outb(tf->lbal, io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_LBAM)
outb(tf->lbam, io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_LBAH)
outb(tf->lbah, io_ports->lbah_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_DEVICE)
outb((tf->device & HIHI) | drive->select,
io_ports->device_addr);
}
static void h8300_tf_read(ide_drive_t *drive, struct ide_cmd *cmd)
{
ide_hwif_t *hwif = drive->hwif;
struct ide_io_ports *io_ports = &hwif->io_ports;
struct ide_taskfile *tf = &cmd->tf;
/* be sure we're looking at the low order bits */
outb(ATA_DEVCTL_OBS, io_ports->ctl_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_ERROR)
tf->error = inb(io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_NSECT)
tf->nsect = inb(io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAL)
tf->lbal = inb(io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAM)
tf->lbam = inb(io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAH)
tf->lbah = inb(io_ports->lbah_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_DEVICE)
tf->device = inb(io_ports->device_addr);
if (cmd->tf_flags & IDE_TFLAG_LBA48) {
outb(ATA_HOB | ATA_DEVCTL_OBS, io_ports->ctl_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_ERROR)
tf->hob_error = inb(io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_NSECT)
tf->hob_nsect = inb(io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAL)
tf->hob_lbal = inb(io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAM)
tf->hob_lbam = inb(io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAH)
tf->hob_lbah = inb(io_ports->lbah_addr);
}
}
static void mm_outsw(unsigned long addr, void *buf, u32 len) static void mm_outsw(unsigned long addr, void *buf, u32 len)
{ {
unsigned short *bp = (unsigned short *)buf; unsigned short *bp = (unsigned short *)buf;
@ -152,8 +55,8 @@ static const struct ide_tp_ops h8300_tp_ops = {
.write_devctl = ide_write_devctl, .write_devctl = ide_write_devctl,
.dev_select = ide_dev_select, .dev_select = ide_dev_select,
.tf_load = h8300_tf_load, .tf_load = ide_tf_load,
.tf_read = h8300_tf_read, .tf_read = ide_tf_read,
.input_data = h8300_input_data, .input_data = h8300_input_data,
.output_data = h8300_output_data, .output_data = h8300_output_data,

View File

@ -85,98 +85,57 @@ void ide_dev_select(ide_drive_t *drive)
} }
EXPORT_SYMBOL_GPL(ide_dev_select); EXPORT_SYMBOL_GPL(ide_dev_select);
void ide_tf_load(ide_drive_t *drive, struct ide_cmd *cmd) void ide_tf_load(ide_drive_t *drive, struct ide_taskfile *tf, u8 valid)
{ {
ide_hwif_t *hwif = drive->hwif; ide_hwif_t *hwif = drive->hwif;
struct ide_io_ports *io_ports = &hwif->io_ports; struct ide_io_ports *io_ports = &hwif->io_ports;
struct ide_taskfile *tf = &cmd->tf;
void (*tf_outb)(u8 addr, unsigned long port); void (*tf_outb)(u8 addr, unsigned long port);
u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
u8 HIHI = (cmd->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF;
if (mmio) if (mmio)
tf_outb = ide_mm_outb; tf_outb = ide_mm_outb;
else else
tf_outb = ide_outb; tf_outb = ide_outb;
if (cmd->ftf_flags & IDE_FTFLAG_FLAGGED) if (valid & IDE_VALID_FEATURE)
HIHI = 0xFF;
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE)
tf_outb(tf->hob_feature, io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_NSECT)
tf_outb(tf->hob_nsect, io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAL)
tf_outb(tf->hob_lbal, io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAM)
tf_outb(tf->hob_lbam, io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAH)
tf_outb(tf->hob_lbah, io_ports->lbah_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_FEATURE)
tf_outb(tf->feature, io_ports->feature_addr); tf_outb(tf->feature, io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_NSECT) if (valid & IDE_VALID_NSECT)
tf_outb(tf->nsect, io_ports->nsect_addr); tf_outb(tf->nsect, io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_LBAL) if (valid & IDE_VALID_LBAL)
tf_outb(tf->lbal, io_ports->lbal_addr); tf_outb(tf->lbal, io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_LBAM) if (valid & IDE_VALID_LBAM)
tf_outb(tf->lbam, io_ports->lbam_addr); tf_outb(tf->lbam, io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_LBAH) if (valid & IDE_VALID_LBAH)
tf_outb(tf->lbah, io_ports->lbah_addr); tf_outb(tf->lbah, io_ports->lbah_addr);
if (valid & IDE_VALID_DEVICE)
if (cmd->tf_flags & IDE_TFLAG_OUT_DEVICE) tf_outb(tf->device, io_ports->device_addr);
tf_outb((tf->device & HIHI) | drive->select,
io_ports->device_addr);
} }
EXPORT_SYMBOL_GPL(ide_tf_load); EXPORT_SYMBOL_GPL(ide_tf_load);
void ide_tf_read(ide_drive_t *drive, struct ide_cmd *cmd) void ide_tf_read(ide_drive_t *drive, struct ide_taskfile *tf, u8 valid)
{ {
ide_hwif_t *hwif = drive->hwif; ide_hwif_t *hwif = drive->hwif;
struct ide_io_ports *io_ports = &hwif->io_ports; struct ide_io_ports *io_ports = &hwif->io_ports;
struct ide_taskfile *tf = &cmd->tf;
void (*tf_outb)(u8 addr, unsigned long port);
u8 (*tf_inb)(unsigned long port); u8 (*tf_inb)(unsigned long port);
u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
if (mmio) { if (mmio)
tf_outb = ide_mm_outb;
tf_inb = ide_mm_inb; tf_inb = ide_mm_inb;
} else { else
tf_outb = ide_outb;
tf_inb = ide_inb; tf_inb = ide_inb;
}
/* be sure we're looking at the low order bits */ if (valid & IDE_VALID_ERROR)
tf_outb(ATA_DEVCTL_OBS, io_ports->ctl_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_ERROR)
tf->error = tf_inb(io_ports->feature_addr); tf->error = tf_inb(io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_NSECT) if (valid & IDE_VALID_NSECT)
tf->nsect = tf_inb(io_ports->nsect_addr); tf->nsect = tf_inb(io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAL) if (valid & IDE_VALID_LBAL)
tf->lbal = tf_inb(io_ports->lbal_addr); tf->lbal = tf_inb(io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAM) if (valid & IDE_VALID_LBAM)
tf->lbam = tf_inb(io_ports->lbam_addr); tf->lbam = tf_inb(io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAH) if (valid & IDE_VALID_LBAH)
tf->lbah = tf_inb(io_ports->lbah_addr); tf->lbah = tf_inb(io_ports->lbah_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_DEVICE) if (valid & IDE_VALID_DEVICE)
tf->device = tf_inb(io_ports->device_addr); tf->device = tf_inb(io_ports->device_addr);
if (cmd->tf_flags & IDE_TFLAG_LBA48) {
tf_outb(ATA_HOB | ATA_DEVCTL_OBS, io_ports->ctl_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_ERROR)
tf->hob_error = tf_inb(io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_NSECT)
tf->hob_nsect = tf_inb(io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAL)
tf->hob_lbal = tf_inb(io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAM)
tf->hob_lbam = tf_inb(io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAH)
tf->hob_lbah = tf_inb(io_ports->lbah_addr);
}
} }
EXPORT_SYMBOL_GPL(ide_tf_read); EXPORT_SYMBOL_GPL(ide_tf_read);

View File

@ -86,18 +86,18 @@ void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err)
tp_ops->input_data(drive, cmd, data, 2); tp_ops->input_data(drive, cmd, data, 2);
tf->data = data[0]; cmd->tf.data = data[0];
tf->hob_data = data[1]; cmd->hob.data = data[1];
} }
tp_ops->tf_read(drive, cmd); ide_tf_readback(drive, cmd);
if ((cmd->tf_flags & IDE_TFLAG_CUSTOM_HANDLER) && if ((cmd->tf_flags & IDE_TFLAG_CUSTOM_HANDLER) &&
tf_cmd == ATA_CMD_IDLEIMMEDIATE) { tf_cmd == ATA_CMD_IDLEIMMEDIATE) {
if (tf->lbal != 0xc4) { if (tf->lbal != 0xc4) {
printk(KERN_ERR "%s: head unload failed!\n", printk(KERN_ERR "%s: head unload failed!\n",
drive->name); drive->name);
ide_tf_dump(drive->name, tf); ide_tf_dump(drive->name, cmd);
} else } else
drive->dev_flags |= IDE_DFLAG_PARKED; drive->dev_flags |= IDE_DFLAG_PARKED;
} }
@ -205,8 +205,9 @@ static ide_startstop_t ide_disk_special(ide_drive_t *drive)
return ide_stopped; return ide_stopped;
} }
cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE | cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
IDE_TFLAG_CUSTOM_HANDLER; cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
cmd.tf_flags = IDE_TFLAG_CUSTOM_HANDLER;
do_rw_taskfile(drive, &cmd); do_rw_taskfile(drive, &cmd);

View File

@ -141,11 +141,12 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg)
tf->lbal = args[1]; tf->lbal = args[1];
tf->lbam = 0x4f; tf->lbam = 0x4f;
tf->lbah = 0xc2; tf->lbah = 0xc2;
cmd.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_IN_NSECT; cmd.valid.out.tf = IDE_VALID_OUT_TF;
cmd.valid.in.tf = IDE_VALID_NSECT;
} else { } else {
tf->nsect = args[1]; tf->nsect = args[1];
cmd.tf_flags = IDE_TFLAG_OUT_FEATURE | IDE_TFLAG_OUT_NSECT | cmd.valid.out.tf = IDE_VALID_FEATURE | IDE_VALID_NSECT;
IDE_TFLAG_IN_NSECT; cmd.valid.in.tf = IDE_VALID_NSECT;
} }
tf->command = args[0]; tf->command = args[0];
cmd.protocol = args[3] ? ATA_PROT_PIO : ATA_PROT_NODATA; cmd.protocol = args[3] ? ATA_PROT_PIO : ATA_PROT_NODATA;
@ -205,14 +206,15 @@ static int ide_task_ioctl(ide_drive_t *drive, unsigned long arg)
return -EFAULT; return -EFAULT;
memset(&cmd, 0, sizeof(cmd)); memset(&cmd, 0, sizeof(cmd));
memcpy(&cmd.tf_array[7], &args[1], 6); memcpy(&cmd.tf.feature, &args[1], 6);
cmd.tf.command = args[0]; cmd.tf.command = args[0];
cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
err = ide_no_data_taskfile(drive, &cmd); err = ide_no_data_taskfile(drive, &cmd);
args[0] = cmd.tf.command; args[0] = cmd.tf.command;
memcpy(&args[1], &cmd.tf_array[7], 6); memcpy(&args[1], &cmd.tf.feature, 6);
if (copy_to_user(p, args, 7)) if (copy_to_user(p, args, 7))
err = -EFAULT; err = -EFAULT;

View File

@ -37,14 +37,11 @@ void SELECT_MASK(ide_drive_t *drive, int mask)
u8 ide_read_error(ide_drive_t *drive) u8 ide_read_error(ide_drive_t *drive)
{ {
struct ide_cmd cmd; struct ide_taskfile tf;
memset(&cmd, 0, sizeof(cmd)); drive->hwif->tp_ops->tf_read(drive, &tf, IDE_VALID_ERROR);
cmd.tf_flags = IDE_TFLAG_IN_ERROR;
drive->hwif->tp_ops->tf_read(drive, &cmd); return tf.error;
return cmd.tf.error;
} }
EXPORT_SYMBOL_GPL(ide_read_error); EXPORT_SYMBOL_GPL(ide_read_error);
@ -312,10 +309,10 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
{ {
ide_hwif_t *hwif = drive->hwif; ide_hwif_t *hwif = drive->hwif;
const struct ide_tp_ops *tp_ops = hwif->tp_ops; const struct ide_tp_ops *tp_ops = hwif->tp_ops;
struct ide_taskfile tf;
u16 *id = drive->id, i; u16 *id = drive->id, i;
int error = 0; int error = 0;
u8 stat; u8 stat;
struct ide_cmd cmd;
#ifdef CONFIG_BLK_DEV_IDEDMA #ifdef CONFIG_BLK_DEV_IDEDMA
if (hwif->dma_ops) /* check if host supports DMA */ if (hwif->dma_ops) /* check if host supports DMA */
@ -347,12 +344,11 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
udelay(1); udelay(1);
tp_ops->write_devctl(hwif, ATA_NIEN | ATA_DEVCTL_OBS); tp_ops->write_devctl(hwif, ATA_NIEN | ATA_DEVCTL_OBS);
memset(&cmd, 0, sizeof(cmd)); memset(&tf, 0, sizeof(tf));
cmd.tf_flags = IDE_TFLAG_OUT_FEATURE | IDE_TFLAG_OUT_NSECT; tf.feature = SETFEATURES_XFER;
cmd.tf.feature = SETFEATURES_XFER; tf.nsect = speed;
cmd.tf.nsect = speed;
tp_ops->tf_load(drive, &cmd); tp_ops->tf_load(drive, &tf, IDE_VALID_FEATURE | IDE_VALID_NSECT);
tp_ops->exec_command(hwif, ATA_CMD_SET_FEATURES); tp_ops->exec_command(hwif, ATA_CMD_SET_FEATURES);

View File

@ -49,16 +49,17 @@ static void ide_dump_opcode(ide_drive_t *drive)
printk(KERN_CONT "0x%02x\n", cmd->tf.command); printk(KERN_CONT "0x%02x\n", cmd->tf.command);
} }
u64 ide_get_lba_addr(struct ide_taskfile *tf, int lba48) u64 ide_get_lba_addr(struct ide_cmd *cmd, int lba48)
{ {
struct ide_taskfile *tf = &cmd->tf;
u32 high, low; u32 high, low;
if (lba48)
high = (tf->hob_lbah << 16) | (tf->hob_lbam << 8) |
tf->hob_lbal;
else
high = tf->device & 0xf;
low = (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal; low = (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal;
if (lba48) {
tf = &cmd->hob;
high = (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal;
} else
high = tf->device & 0xf;
return ((u64)high << 24) | low; return ((u64)high << 24) | low;
} }
@ -71,17 +72,18 @@ static void ide_dump_sector(ide_drive_t *drive)
u8 lba48 = !!(drive->dev_flags & IDE_DFLAG_LBA48); u8 lba48 = !!(drive->dev_flags & IDE_DFLAG_LBA48);
memset(&cmd, 0, sizeof(cmd)); memset(&cmd, 0, sizeof(cmd));
if (lba48) if (lba48) {
cmd.tf_flags = IDE_TFLAG_IN_LBA | IDE_TFLAG_IN_HOB_LBA | cmd.valid.in.tf = IDE_VALID_LBA;
IDE_TFLAG_LBA48; cmd.valid.in.hob = IDE_VALID_LBA;
else cmd.tf_flags = IDE_TFLAG_LBA48;
cmd.tf_flags = IDE_TFLAG_IN_LBA | IDE_TFLAG_IN_DEVICE; } else
cmd.valid.in.tf = IDE_VALID_LBA | IDE_VALID_DEVICE;
drive->hwif->tp_ops->tf_read(drive, &cmd); ide_tf_readback(drive, &cmd);
if (lba48 || (tf->device & ATA_LBA)) if (lba48 || (tf->device & ATA_LBA))
printk(KERN_CONT ", LBAsect=%llu", printk(KERN_CONT ", LBAsect=%llu",
(unsigned long long)ide_get_lba_addr(tf, lba48)); (unsigned long long)ide_get_lba_addr(&cmd, lba48));
else else
printk(KERN_CONT ", CHS=%d/%d/%d", (tf->lbah << 8) + tf->lbam, printk(KERN_CONT ", CHS=%d/%d/%d", (tf->lbah << 8) + tf->lbam,
tf->device & 0xf, tf->lbal); tf->device & 0xf, tf->lbal);

View File

@ -74,7 +74,8 @@ ide_startstop_t ide_do_park_unpark(ide_drive_t *drive, struct request *rq)
tf->lbal = 0x4c; tf->lbal = 0x4c;
tf->lbam = 0x4e; tf->lbam = 0x4e;
tf->lbah = 0x55; tf->lbah = 0x55;
cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
} else /* cmd == REQ_UNPARK_HEADS */ } else /* cmd == REQ_UNPARK_HEADS */
tf->command = ATA_CMD_CHK_POWER; tf->command = ATA_CMD_CHK_POWER;

View File

@ -163,7 +163,8 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
return ide_stopped; return ide_stopped;
out_do_tf: out_do_tf:
cmd->tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; cmd->valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
cmd->valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
cmd->protocol = ATA_PROT_NODATA; cmd->protocol = ATA_PROT_NODATA;
return do_rw_taskfile(drive, cmd); return do_rw_taskfile(drive, cmd);

View File

@ -283,13 +283,11 @@ int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id)
* identify command to be sure of reply * identify command to be sure of reply
*/ */
if (cmd == ATA_CMD_ID_ATAPI) { if (cmd == ATA_CMD_ID_ATAPI) {
struct ide_cmd cmd; struct ide_taskfile tf;
memset(&cmd, 0, sizeof(cmd)); memset(&tf, 0, sizeof(tf));
/* disable DMA & overlap */ /* disable DMA & overlap */
cmd.tf_flags = IDE_TFLAG_OUT_FEATURE; tp_ops->tf_load(drive, &tf, IDE_VALID_FEATURE);
tp_ops->tf_load(drive, &cmd);
} }
/* ask drive for ID */ /* ask drive for ID */
@ -337,14 +335,11 @@ int ide_busy_sleep(ide_hwif_t *hwif, unsigned long timeout, int altstatus)
static u8 ide_read_device(ide_drive_t *drive) static u8 ide_read_device(ide_drive_t *drive)
{ {
struct ide_cmd cmd; struct ide_taskfile tf;
memset(&cmd, 0, sizeof(cmd)); drive->hwif->tp_ops->tf_read(drive, &tf, IDE_VALID_DEVICE);
cmd.tf_flags = IDE_TFLAG_IN_DEVICE;
drive->hwif->tp_ops->tf_read(drive, &cmd); return tf.device;
return cmd.tf.device;
} }
/** /**
@ -1314,6 +1309,7 @@ struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws)
host->get_lock = d->get_lock; host->get_lock = d->get_lock;
host->release_lock = d->release_lock; host->release_lock = d->release_lock;
host->host_flags = d->host_flags; host->host_flags = d->host_flags;
host->irq_flags = d->irq_flags;
} }
return host; return host;

View File

@ -204,8 +204,8 @@ static int set_xfer_rate (ide_drive_t *drive, int arg)
cmd.tf.command = ATA_CMD_SET_FEATURES; cmd.tf.command = ATA_CMD_SET_FEATURES;
cmd.tf.feature = SETFEATURES_XFER; cmd.tf.feature = SETFEATURES_XFER;
cmd.tf.nsect = (u8)arg; cmd.tf.nsect = (u8)arg;
cmd.tf_flags = IDE_TFLAG_OUT_FEATURE | IDE_TFLAG_OUT_NSECT | cmd.valid.out.tf = IDE_VALID_FEATURE | IDE_VALID_NSECT;
IDE_TFLAG_IN_NSECT; cmd.valid.in.tf = IDE_VALID_NSECT;
err = ide_no_data_taskfile(drive, &cmd); err = ide_no_data_taskfile(drive, &cmd);

View File

@ -23,17 +23,33 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/io.h> #include <asm/io.h>
void ide_tf_dump(const char *s, struct ide_taskfile *tf) void ide_tf_readback(ide_drive_t *drive, struct ide_cmd *cmd)
{
ide_hwif_t *hwif = drive->hwif;
const struct ide_tp_ops *tp_ops = hwif->tp_ops;
/* Be sure we're looking at the low order bytes */
tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS);
tp_ops->tf_read(drive, &cmd->tf, cmd->valid.in.tf);
if (cmd->tf_flags & IDE_TFLAG_LBA48) {
tp_ops->write_devctl(hwif, ATA_HOB | ATA_DEVCTL_OBS);
tp_ops->tf_read(drive, &cmd->hob, cmd->valid.in.hob);
}
}
void ide_tf_dump(const char *s, struct ide_cmd *cmd)
{ {
#ifdef DEBUG #ifdef DEBUG
printk("%s: tf: feat 0x%02x nsect 0x%02x lbal 0x%02x " printk("%s: tf: feat 0x%02x nsect 0x%02x lbal 0x%02x "
"lbam 0x%02x lbah 0x%02x dev 0x%02x cmd 0x%02x\n", "lbam 0x%02x lbah 0x%02x dev 0x%02x cmd 0x%02x\n",
s, tf->feature, tf->nsect, tf->lbal, s, cmd->tf.feature, cmd->tf.nsect,
tf->lbam, tf->lbah, tf->device, tf->command); cmd->tf.lbal, cmd->tf.lbam, cmd->tf.lbah,
printk("%s: hob: nsect 0x%02x lbal 0x%02x " cmd->tf.device, cmd->tf.command);
"lbam 0x%02x lbah 0x%02x\n", printk("%s: hob: nsect 0x%02x lbal 0x%02x lbam 0x%02x lbah 0x%02x\n",
s, tf->hob_nsect, tf->hob_lbal, s, cmd->hob.nsect, cmd->hob.lbal, cmd->hob.lbam, cmd->hob.lbah);
tf->hob_lbam, tf->hob_lbah);
#endif #endif
} }
@ -47,7 +63,8 @@ int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf)
cmd.tf.command = ATA_CMD_ID_ATA; cmd.tf.command = ATA_CMD_ID_ATA;
else else
cmd.tf.command = ATA_CMD_ID_ATAPI; cmd.tf.command = ATA_CMD_ID_ATAPI;
cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
cmd.protocol = ATA_PROT_PIO; cmd.protocol = ATA_PROT_PIO;
return ide_raw_taskfile(drive, &cmd, buf, 1); return ide_raw_taskfile(drive, &cmd, buf, 1);
@ -79,16 +96,27 @@ ide_startstop_t do_rw_taskfile(ide_drive_t *drive, struct ide_cmd *orig_cmd)
memcpy(cmd, orig_cmd, sizeof(*cmd)); memcpy(cmd, orig_cmd, sizeof(*cmd));
if ((cmd->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) { if ((cmd->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) {
ide_tf_dump(drive->name, tf); ide_tf_dump(drive->name, cmd);
tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS); tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS);
SELECT_MASK(drive, 0); SELECT_MASK(drive, 0);
if (cmd->ftf_flags & IDE_FTFLAG_OUT_DATA) { if (cmd->ftf_flags & IDE_FTFLAG_OUT_DATA) {
u8 data[2] = { tf->data, tf->hob_data }; u8 data[2] = { cmd->tf.data, cmd->hob.data };
tp_ops->output_data(drive, cmd, data, 2); tp_ops->output_data(drive, cmd, data, 2);
} }
tp_ops->tf_load(drive, cmd);
if (cmd->valid.out.tf & IDE_VALID_DEVICE) {
u8 HIHI = (cmd->tf_flags & IDE_TFLAG_LBA48) ?
0xE0 : 0xEF;
if (!(cmd->ftf_flags & IDE_FTFLAG_FLAGGED))
cmd->tf.device &= HIHI;
cmd->tf.device |= drive->select;
}
tp_ops->tf_load(drive, &cmd->hob, cmd->valid.out.hob);
tp_ops->tf_load(drive, &cmd->tf, cmd->valid.out.tf);
} }
switch (cmd->protocol) { switch (cmd->protocol) {
@ -489,16 +517,17 @@ int ide_taskfile_ioctl(ide_drive_t *drive, unsigned long arg)
memset(&cmd, 0, sizeof(cmd)); memset(&cmd, 0, sizeof(cmd));
memcpy(&cmd.tf_array[0], req_task->hob_ports, memcpy(&cmd.hob, req_task->hob_ports, HDIO_DRIVE_HOB_HDR_SIZE - 2);
HDIO_DRIVE_HOB_HDR_SIZE - 2); memcpy(&cmd.tf, req_task->io_ports, HDIO_DRIVE_TASK_HDR_SIZE);
memcpy(&cmd.tf_array[6], req_task->io_ports,
HDIO_DRIVE_TASK_HDR_SIZE);
cmd.tf_flags = IDE_TFLAG_IO_16BIT | IDE_TFLAG_DEVICE | cmd.valid.out.tf = IDE_VALID_DEVICE;
IDE_TFLAG_IN_TF; cmd.valid.in.tf = IDE_VALID_DEVICE | IDE_VALID_IN_TF;
cmd.tf_flags = IDE_TFLAG_IO_16BIT;
if (drive->dev_flags & IDE_DFLAG_LBA48) if (drive->dev_flags & IDE_DFLAG_LBA48) {
cmd.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_IN_HOB); cmd.tf_flags |= IDE_TFLAG_LBA48;
cmd.valid.in.hob = IDE_VALID_IN_HOB;
}
if (req_task->out_flags.all) { if (req_task->out_flags.all) {
cmd.ftf_flags |= IDE_FTFLAG_FLAGGED; cmd.ftf_flags |= IDE_FTFLAG_FLAGGED;
@ -507,28 +536,28 @@ int ide_taskfile_ioctl(ide_drive_t *drive, unsigned long arg)
cmd.ftf_flags |= IDE_FTFLAG_OUT_DATA; cmd.ftf_flags |= IDE_FTFLAG_OUT_DATA;
if (req_task->out_flags.b.nsector_hob) if (req_task->out_flags.b.nsector_hob)
cmd.tf_flags |= IDE_TFLAG_OUT_HOB_NSECT; cmd.valid.out.hob |= IDE_VALID_NSECT;
if (req_task->out_flags.b.sector_hob) if (req_task->out_flags.b.sector_hob)
cmd.tf_flags |= IDE_TFLAG_OUT_HOB_LBAL; cmd.valid.out.hob |= IDE_VALID_LBAL;
if (req_task->out_flags.b.lcyl_hob) if (req_task->out_flags.b.lcyl_hob)
cmd.tf_flags |= IDE_TFLAG_OUT_HOB_LBAM; cmd.valid.out.hob |= IDE_VALID_LBAM;
if (req_task->out_flags.b.hcyl_hob) if (req_task->out_flags.b.hcyl_hob)
cmd.tf_flags |= IDE_TFLAG_OUT_HOB_LBAH; cmd.valid.out.hob |= IDE_VALID_LBAH;
if (req_task->out_flags.b.error_feature) if (req_task->out_flags.b.error_feature)
cmd.tf_flags |= IDE_TFLAG_OUT_FEATURE; cmd.valid.out.tf |= IDE_VALID_FEATURE;
if (req_task->out_flags.b.nsector) if (req_task->out_flags.b.nsector)
cmd.tf_flags |= IDE_TFLAG_OUT_NSECT; cmd.valid.out.tf |= IDE_VALID_NSECT;
if (req_task->out_flags.b.sector) if (req_task->out_flags.b.sector)
cmd.tf_flags |= IDE_TFLAG_OUT_LBAL; cmd.valid.out.tf |= IDE_VALID_LBAL;
if (req_task->out_flags.b.lcyl) if (req_task->out_flags.b.lcyl)
cmd.tf_flags |= IDE_TFLAG_OUT_LBAM; cmd.valid.out.tf |= IDE_VALID_LBAM;
if (req_task->out_flags.b.hcyl) if (req_task->out_flags.b.hcyl)
cmd.tf_flags |= IDE_TFLAG_OUT_LBAH; cmd.valid.out.tf |= IDE_VALID_LBAH;
} else { } else {
cmd.tf_flags |= IDE_TFLAG_OUT_TF; cmd.valid.out.tf |= IDE_VALID_OUT_TF;
if (cmd.tf_flags & IDE_TFLAG_LBA48) if (cmd.tf_flags & IDE_TFLAG_LBA48)
cmd.tf_flags |= IDE_TFLAG_OUT_HOB; cmd.valid.out.hob |= IDE_VALID_OUT_HOB;
} }
if (req_task->in_flags.b.data) if (req_task->in_flags.b.data)
@ -594,7 +623,7 @@ int ide_taskfile_ioctl(ide_drive_t *drive, unsigned long arg)
if (req_task->req_cmd == IDE_DRIVE_TASK_NO_DATA) if (req_task->req_cmd == IDE_DRIVE_TASK_NO_DATA)
nsect = 0; nsect = 0;
else if (!nsect) { else if (!nsect) {
nsect = (cmd.tf.hob_nsect << 8) | cmd.tf.nsect; nsect = (cmd.hob.nsect << 8) | cmd.tf.nsect;
if (!nsect) { if (!nsect) {
printk(KERN_ERR "%s: in/out command without data\n", printk(KERN_ERR "%s: in/out command without data\n",
@ -606,10 +635,8 @@ int ide_taskfile_ioctl(ide_drive_t *drive, unsigned long arg)
err = ide_raw_taskfile(drive, &cmd, data_buf, nsect); err = ide_raw_taskfile(drive, &cmd, data_buf, nsect);
memcpy(req_task->hob_ports, &cmd.tf_array[0], memcpy(req_task->hob_ports, &cmd.hob, HDIO_DRIVE_HOB_HDR_SIZE - 2);
HDIO_DRIVE_HOB_HDR_SIZE - 2); memcpy(req_task->io_ports, &cmd.tf, HDIO_DRIVE_TASK_HDR_SIZE);
memcpy(req_task->io_ports, &cmd.tf_array[6],
HDIO_DRIVE_TASK_HDR_SIZE);
if ((cmd.ftf_flags & IDE_FTFLAG_SET_IN_FLAGS) && if ((cmd.ftf_flags & IDE_FTFLAG_SET_IN_FLAGS) &&
req_task->in_flags.all == 0) { req_task->in_flags.all == 0) {

View File

@ -61,41 +61,23 @@ static u8 superio_dma_sff_read_status(ide_hwif_t *hwif)
return superio_ide_inb(hwif->dma_base + ATA_DMA_STATUS); return superio_ide_inb(hwif->dma_base + ATA_DMA_STATUS);
} }
static void superio_tf_read(ide_drive_t *drive, struct ide_cmd *cmd) static void superio_tf_read(ide_drive_t *drive, struct ide_taskfile *tf,
u8 valid)
{ {
struct ide_io_ports *io_ports = &drive->hwif->io_ports; struct ide_io_ports *io_ports = &drive->hwif->io_ports;
struct ide_taskfile *tf = &cmd->tf;
/* be sure we're looking at the low order bits */ if (valid & IDE_VALID_ERROR)
outb(ATA_DEVCTL_OBS, io_ports->ctl_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_ERROR)
tf->error = inb(io_ports->feature_addr); tf->error = inb(io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_NSECT) if (valid & IDE_VALID_NSECT)
tf->nsect = inb(io_ports->nsect_addr); tf->nsect = inb(io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAL) if (valid & IDE_VALID_LBAL)
tf->lbal = inb(io_ports->lbal_addr); tf->lbal = inb(io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAM) if (valid & IDE_VALID_LBAM)
tf->lbam = inb(io_ports->lbam_addr); tf->lbam = inb(io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAH) if (valid & IDE_VALID_LBAH)
tf->lbah = inb(io_ports->lbah_addr); tf->lbah = inb(io_ports->lbah_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_DEVICE) if (valid & IDE_VALID_DEVICE)
tf->device = superio_ide_inb(io_ports->device_addr); tf->device = superio_ide_inb(io_ports->device_addr);
if (cmd->tf_flags & IDE_TFLAG_LBA48) {
outb(ATA_HOB | ATA_DEVCTL_OBS, io_ports->ctl_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_ERROR)
tf->hob_error = inb(io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_NSECT)
tf->hob_nsect = inb(io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAL)
tf->hob_lbal = inb(io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAM)
tf->hob_lbam = inb(io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAH)
tf->hob_lbah = inb(io_ports->lbah_addr);
}
} }
static void ns87415_dev_select(ide_drive_t *drive); static void ns87415_dev_select(ide_drive_t *drive);

View File

@ -16,6 +16,8 @@
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/ide.h> #include <linux/ide.h>
#include <asm/ide.h>
/* /*
* Bases of the IDE interfaces * Bases of the IDE interfaces
*/ */
@ -77,8 +79,10 @@ static void q40ide_input_data(ide_drive_t *drive, struct ide_cmd *cmd,
{ {
unsigned long data_addr = drive->hwif->io_ports.data_addr; unsigned long data_addr = drive->hwif->io_ports.data_addr;
if (drive->media == ide_disk && cmd && (cmd->tf_flags & IDE_TFLAG_FS)) if (drive->media == ide_disk && cmd && (cmd->tf_flags & IDE_TFLAG_FS)) {
return insw(data_addr, buf, (len + 1) / 2); __ide_mm_insw(data_addr, buf, (len + 1) / 2);
return;
}
raw_insw_swapw((u16 *)data_addr, buf, (len + 1) / 2); raw_insw_swapw((u16 *)data_addr, buf, (len + 1) / 2);
} }
@ -88,8 +92,10 @@ static void q40ide_output_data(ide_drive_t *drive, struct ide_cmd *cmd,
{ {
unsigned long data_addr = drive->hwif->io_ports.data_addr; unsigned long data_addr = drive->hwif->io_ports.data_addr;
if (drive->media == ide_disk && cmd && (cmd->tf_flags & IDE_TFLAG_FS)) if (drive->media == ide_disk && cmd && (cmd->tf_flags & IDE_TFLAG_FS)) {
return outsw(data_addr, buf, (len + 1) / 2); __ide_mm_outsw(data_addr, buf, (len + 1) / 2);
return;
}
raw_outsw_swapw((u16 *)data_addr, buf, (len + 1) / 2); raw_outsw_swapw((u16 *)data_addr, buf, (len + 1) / 2);
} }

View File

@ -337,7 +337,6 @@ static void scc_dma_start(ide_drive_t *drive)
/* start DMA */ /* start DMA */
scc_ide_outb(dma_cmd | 1, hwif->dma_base); scc_ide_outb(dma_cmd | 1, hwif->dma_base);
wmb();
} }
static int __scc_dma_end(ide_drive_t *drive) static int __scc_dma_end(ide_drive_t *drive)
@ -354,7 +353,6 @@ static int __scc_dma_end(ide_drive_t *drive)
/* clear the INTR & ERROR bits */ /* clear the INTR & ERROR bits */
scc_ide_outb(dma_stat | 6, hwif->dma_base + 4); scc_ide_outb(dma_stat | 6, hwif->dma_base + 4);
/* verify good DMA status */ /* verify good DMA status */
wmb();
return (dma_stat & 7) != 4 ? (0x10 | dma_stat) : 0; return (dma_stat & 7) != 4 ? (0x10 | dma_stat) : 0;
} }
@ -647,77 +645,40 @@ static int __devinit init_setup_scc(struct pci_dev *dev,
return rc; return rc;
} }
static void scc_tf_load(ide_drive_t *drive, struct ide_cmd *cmd) static void scc_tf_load(ide_drive_t *drive, struct ide_taskfile *tf, u8 valid)
{ {
struct ide_io_ports *io_ports = &drive->hwif->io_ports; struct ide_io_ports *io_ports = &drive->hwif->io_ports;
struct ide_taskfile *tf = &cmd->tf;
u8 HIHI = (cmd->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF;
if (cmd->ftf_flags & IDE_FTFLAG_FLAGGED) if (valid & IDE_VALID_FEATURE)
HIHI = 0xFF;
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE)
scc_ide_outb(tf->hob_feature, io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_NSECT)
scc_ide_outb(tf->hob_nsect, io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAL)
scc_ide_outb(tf->hob_lbal, io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAM)
scc_ide_outb(tf->hob_lbam, io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAH)
scc_ide_outb(tf->hob_lbah, io_ports->lbah_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_FEATURE)
scc_ide_outb(tf->feature, io_ports->feature_addr); scc_ide_outb(tf->feature, io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_NSECT) if (valid & IDE_VALID_NSECT)
scc_ide_outb(tf->nsect, io_ports->nsect_addr); scc_ide_outb(tf->nsect, io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_LBAL) if (valid & IDE_VALID_LBAL)
scc_ide_outb(tf->lbal, io_ports->lbal_addr); scc_ide_outb(tf->lbal, io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_LBAM) if (valid & IDE_VALID_LBAM)
scc_ide_outb(tf->lbam, io_ports->lbam_addr); scc_ide_outb(tf->lbam, io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_LBAH) if (valid & IDE_VALID_LBAH)
scc_ide_outb(tf->lbah, io_ports->lbah_addr); scc_ide_outb(tf->lbah, io_ports->lbah_addr);
if (valid & IDE_VALID_DEVICE)
if (cmd->tf_flags & IDE_TFLAG_OUT_DEVICE) scc_ide_outb(tf->device, io_ports->device_addr);
scc_ide_outb((tf->device & HIHI) | drive->select,
io_ports->device_addr);
} }
static void scc_tf_read(ide_drive_t *drive, struct ide_cmd *cmd) static void scc_tf_read(ide_drive_t *drive, struct ide_taskfile *tf, u8 valid)
{ {
struct ide_io_ports *io_ports = &drive->hwif->io_ports; struct ide_io_ports *io_ports = &drive->hwif->io_ports;
struct ide_taskfile *tf = &cmd->tf;
/* be sure we're looking at the low order bits */ if (valid & IDE_VALID_ERROR)
scc_ide_outb(ATA_DEVCTL_OBS, io_ports->ctl_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_ERROR)
tf->error = scc_ide_inb(io_ports->feature_addr); tf->error = scc_ide_inb(io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_NSECT) if (valid & IDE_VALID_NSECT)
tf->nsect = scc_ide_inb(io_ports->nsect_addr); tf->nsect = scc_ide_inb(io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAL) if (valid & IDE_VALID_LBAL)
tf->lbal = scc_ide_inb(io_ports->lbal_addr); tf->lbal = scc_ide_inb(io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAM) if (valid & IDE_VALID_LBAM)
tf->lbam = scc_ide_inb(io_ports->lbam_addr); tf->lbam = scc_ide_inb(io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAH) if (valid & IDE_VALID_LBAH)
tf->lbah = scc_ide_inb(io_ports->lbah_addr); tf->lbah = scc_ide_inb(io_ports->lbah_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_DEVICE) if (valid & IDE_VALID_DEVICE)
tf->device = scc_ide_inb(io_ports->device_addr); tf->device = scc_ide_inb(io_ports->device_addr);
if (cmd->tf_flags & IDE_TFLAG_LBA48) {
scc_ide_outb(ATA_HOB | ATA_DEVCTL_OBS, io_ports->ctl_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_ERROR)
tf->hob_error = scc_ide_inb(io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_NSECT)
tf->hob_nsect = scc_ide_inb(io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAL)
tf->hob_lbal = scc_ide_inb(io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAM)
tf->hob_lbam = scc_ide_inb(io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAH)
tf->hob_lbah = scc_ide_inb(io_ports->lbah_addr);
}
} }
static void scc_input_data(ide_drive_t *drive, struct ide_cmd *cmd, static void scc_input_data(ide_drive_t *drive, struct ide_cmd *cmd,

View File

@ -72,91 +72,6 @@ static void tx4938ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
#ifdef __BIG_ENDIAN #ifdef __BIG_ENDIAN
/* custom iops (independent from SWAP_IO_SPACE) */ /* custom iops (independent from SWAP_IO_SPACE) */
static u8 tx4938ide_inb(unsigned long port)
{
return __raw_readb((void __iomem *)port);
}
static void tx4938ide_outb(u8 value, unsigned long port)
{
__raw_writeb(value, (void __iomem *)port);
}
static void tx4938ide_tf_load(ide_drive_t *drive, struct ide_cmd *cmd)
{
ide_hwif_t *hwif = drive->hwif;
struct ide_io_ports *io_ports = &hwif->io_ports;
struct ide_taskfile *tf = &cmd->tf;
u8 HIHI = cmd->tf_flags & IDE_TFLAG_LBA48 ? 0xE0 : 0xEF;
if (cmd->ftf_flags & IDE_FTFLAG_FLAGGED)
HIHI = 0xFF;
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE)
tx4938ide_outb(tf->hob_feature, io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_NSECT)
tx4938ide_outb(tf->hob_nsect, io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAL)
tx4938ide_outb(tf->hob_lbal, io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAM)
tx4938ide_outb(tf->hob_lbam, io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAH)
tx4938ide_outb(tf->hob_lbah, io_ports->lbah_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_FEATURE)
tx4938ide_outb(tf->feature, io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_NSECT)
tx4938ide_outb(tf->nsect, io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_LBAL)
tx4938ide_outb(tf->lbal, io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_LBAM)
tx4938ide_outb(tf->lbam, io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_LBAH)
tx4938ide_outb(tf->lbah, io_ports->lbah_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_DEVICE)
tx4938ide_outb((tf->device & HIHI) | drive->select,
io_ports->device_addr);
}
static void tx4938ide_tf_read(ide_drive_t *drive, struct ide_cmd *cmd)
{
ide_hwif_t *hwif = drive->hwif;
struct ide_io_ports *io_ports = &hwif->io_ports;
struct ide_taskfile *tf = &cmd->tf;
/* be sure we're looking at the low order bits */
tx4938ide_outb(ATA_DEVCTL_OBS, io_ports->ctl_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_ERROR)
tf->error = tx4938ide_inb(io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_NSECT)
tf->nsect = tx4938ide_inb(io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAL)
tf->lbal = tx4938ide_inb(io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAM)
tf->lbam = tx4938ide_inb(io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAH)
tf->lbah = tx4938ide_inb(io_ports->lbah_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_DEVICE)
tf->device = tx4938ide_inb(io_ports->device_addr);
if (cmd->tf_flags & IDE_TFLAG_LBA48) {
tx4938ide_outb(ATA_HOB | ATA_DEVCTL_OBS, io_ports->ctl_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_ERROR)
tf->hob_error = tx4938ide_inb(io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_NSECT)
tf->hob_nsect = tx4938ide_inb(io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAL)
tf->hob_lbal = tx4938ide_inb(io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAM)
tf->hob_lbam = tx4938ide_inb(io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAH)
tf->hob_lbah = tx4938ide_inb(io_ports->lbah_addr);
}
}
static void tx4938ide_input_data_swap(ide_drive_t *drive, struct ide_cmd *cmd, static void tx4938ide_input_data_swap(ide_drive_t *drive, struct ide_cmd *cmd,
void *buf, unsigned int len) void *buf, unsigned int len)
{ {
@ -190,8 +105,8 @@ static const struct ide_tp_ops tx4938ide_tp_ops = {
.write_devctl = ide_write_devctl, .write_devctl = ide_write_devctl,
.dev_select = ide_dev_select, .dev_select = ide_dev_select,
.tf_load = tx4938ide_tf_load, .tf_load = ide_tf_load,
.tf_read = tx4938ide_tf_read, .tf_read = ide_tf_read,
.input_data = tx4938ide_input_data_swap, .input_data = tx4938ide_input_data_swap,
.output_data = tx4938ide_output_data_swap, .output_data = tx4938ide_output_data_swap,

View File

@ -327,15 +327,15 @@ static int tx4939ide_dma_end(ide_drive_t *drive)
/* read and clear the INTR & ERROR bits */ /* read and clear the INTR & ERROR bits */
dma_stat = tx4939ide_clear_dma_status(base); dma_stat = tx4939ide_clear_dma_status(base);
wmb(); #define CHECK_DMA_MASK (ATA_DMA_ACTIVE | ATA_DMA_ERR | ATA_DMA_INTR)
/* verify good DMA status */ /* verify good DMA status */
if ((dma_stat & (ATA_DMA_INTR | ATA_DMA_ERR | ATA_DMA_ACTIVE)) == 0 && if ((dma_stat & CHECK_DMA_MASK) == 0 &&
(ctl & (TX4939IDE_INT_XFEREND | TX4939IDE_INT_HOST)) == (ctl & (TX4939IDE_INT_XFEREND | TX4939IDE_INT_HOST)) ==
(TX4939IDE_INT_XFEREND | TX4939IDE_INT_HOST)) (TX4939IDE_INT_XFEREND | TX4939IDE_INT_HOST))
/* INT_IDE lost... bug? */ /* INT_IDE lost... bug? */
return 0; return 0;
return ((dma_stat & (ATA_DMA_INTR | ATA_DMA_ERR | ATA_DMA_ACTIVE)) != return ((dma_stat & CHECK_DMA_MASK) !=
ATA_DMA_INTR) ? 0x10 | dma_stat : 0; ATA_DMA_INTR) ? 0x10 | dma_stat : 0;
} }
@ -434,97 +434,19 @@ static void tx4939ide_tf_load_fixup(ide_drive_t *drive)
tx4939ide_writew(sysctl, base, TX4939IDE_Sys_Ctl); tx4939ide_writew(sysctl, base, TX4939IDE_Sys_Ctl);
} }
static void tx4939ide_tf_load(ide_drive_t *drive, struct ide_taskfile *tf,
u8 valid)
{
ide_tf_load(drive, tf, valid);
if (valid & IDE_VALID_DEVICE)
tx4939ide_tf_load_fixup(drive);
}
#ifdef __BIG_ENDIAN #ifdef __BIG_ENDIAN
/* custom iops (independent from SWAP_IO_SPACE) */ /* custom iops (independent from SWAP_IO_SPACE) */
static u8 tx4939ide_inb(unsigned long port) static void tx4939ide_input_data_swap(ide_drive_t *drive, struct ide_cmd *cmd,
{
return __raw_readb((void __iomem *)port);
}
static void tx4939ide_outb(u8 value, unsigned long port)
{
__raw_writeb(value, (void __iomem *)port);
}
static void tx4939ide_tf_load(ide_drive_t *drive, struct ide_cmd *cmd)
{
ide_hwif_t *hwif = drive->hwif;
struct ide_io_ports *io_ports = &hwif->io_ports;
struct ide_taskfile *tf = &cmd->tf;
u8 HIHI = cmd->tf_flags & IDE_TFLAG_LBA48 ? 0xE0 : 0xEF;
if (cmd->ftf_flags & IDE_FTFLAG_FLAGGED)
HIHI = 0xFF;
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE)
tx4939ide_outb(tf->hob_feature, io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_NSECT)
tx4939ide_outb(tf->hob_nsect, io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAL)
tx4939ide_outb(tf->hob_lbal, io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAM)
tx4939ide_outb(tf->hob_lbam, io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_HOB_LBAH)
tx4939ide_outb(tf->hob_lbah, io_ports->lbah_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_FEATURE)
tx4939ide_outb(tf->feature, io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_NSECT)
tx4939ide_outb(tf->nsect, io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_LBAL)
tx4939ide_outb(tf->lbal, io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_LBAM)
tx4939ide_outb(tf->lbam, io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_LBAH)
tx4939ide_outb(tf->lbah, io_ports->lbah_addr);
if (cmd->tf_flags & IDE_TFLAG_OUT_DEVICE) {
tx4939ide_outb((tf->device & HIHI) | drive->select,
io_ports->device_addr);
tx4939ide_tf_load_fixup(drive);
}
}
static void tx4939ide_tf_read(ide_drive_t *drive, struct ide_cmd *cmd)
{
ide_hwif_t *hwif = drive->hwif;
struct ide_io_ports *io_ports = &hwif->io_ports;
struct ide_taskfile *tf = &cmd->tf;
/* be sure we're looking at the low order bits */
tx4939ide_outb(ATA_DEVCTL_OBS, io_ports->ctl_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_ERROR)
tf->error = tx4939ide_inb(io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_NSECT)
tf->nsect = tx4939ide_inb(io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAL)
tf->lbal = tx4939ide_inb(io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAM)
tf->lbam = tx4939ide_inb(io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_LBAH)
tf->lbah = tx4939ide_inb(io_ports->lbah_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_DEVICE)
tf->device = tx4939ide_inb(io_ports->device_addr);
if (cmd->tf_flags & IDE_TFLAG_LBA48) {
tx4939ide_outb(ATA_HOB | ATA_DEVCTL_OBS, io_ports->ctl_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_ERROR)
tf->hob_error = tx4939ide_inb(io_ports->feature_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_NSECT)
tf->hob_nsect = tx4939ide_inb(io_ports->nsect_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAL)
tf->hob_lbal = tx4939ide_inb(io_ports->lbal_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAM)
tf->hob_lbam = tx4939ide_inb(io_ports->lbam_addr);
if (cmd->tf_flags & IDE_TFLAG_IN_HOB_LBAH)
tf->hob_lbah = tx4939ide_inb(io_ports->lbah_addr);
}
}
static void tx4939ide_input_data_swap(ide_drive_t *drive, struct request *rq,
void *buf, unsigned int len) void *buf, unsigned int len)
{ {
unsigned long port = drive->hwif->io_ports.data_addr; unsigned long port = drive->hwif->io_ports.data_addr;
@ -536,7 +458,7 @@ static void tx4939ide_input_data_swap(ide_drive_t *drive, struct request *rq,
__ide_flush_dcache_range((unsigned long)buf, roundup(len, 2)); __ide_flush_dcache_range((unsigned long)buf, roundup(len, 2));
} }
static void tx4939ide_output_data_swap(ide_drive_t *drive, struct request *rq, static void tx4939ide_output_data_swap(ide_drive_t *drive, struct ide_cmd *cmd,
void *buf, unsigned int len) void *buf, unsigned int len)
{ {
unsigned long port = drive->hwif->io_ports.data_addr; unsigned long port = drive->hwif->io_ports.data_addr;
@ -558,7 +480,7 @@ static const struct ide_tp_ops tx4939ide_tp_ops = {
.dev_select = ide_dev_select, .dev_select = ide_dev_select,
.tf_load = tx4939ide_tf_load, .tf_load = tx4939ide_tf_load,
.tf_read = tx4939ide_tf_read, .tf_read = ide_tf_read,
.input_data = tx4939ide_input_data_swap, .input_data = tx4939ide_input_data_swap,
.output_data = tx4939ide_output_data_swap, .output_data = tx4939ide_output_data_swap,
@ -566,14 +488,6 @@ static const struct ide_tp_ops tx4939ide_tp_ops = {
#else /* __LITTLE_ENDIAN */ #else /* __LITTLE_ENDIAN */
static void tx4939ide_tf_load(ide_drive_t *drive, struct ide_cmd *cmd)
{
ide_tf_load(drive, cmd);
if (cmd->tf_flags & IDE_TFLAG_OUT_DEVICE)
tx4939ide_tf_load_fixup(drive);
}
static const struct ide_tp_ops tx4939ide_tp_ops = { static const struct ide_tp_ops tx4939ide_tp_ops = {
.exec_command = ide_exec_command, .exec_command = ide_exec_command,
.read_status = ide_read_status, .read_status = ide_read_status,

View File

@ -239,66 +239,39 @@ typedef enum {
ide_started, /* a drive operation was started, handler was set */ ide_started, /* a drive operation was started, handler was set */
} ide_startstop_t; } 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 { enum {
IDE_TFLAG_LBA48 = (1 << 0), IDE_TFLAG_LBA48 = (1 << 0),
IDE_TFLAG_OUT_HOB_FEATURE = (1 << 1), IDE_TFLAG_WRITE = (1 << 1),
IDE_TFLAG_OUT_HOB_NSECT = (1 << 2), IDE_TFLAG_CUSTOM_HANDLER = (1 << 2),
IDE_TFLAG_OUT_HOB_LBAL = (1 << 3), IDE_TFLAG_DMA_PIO_FALLBACK = (1 << 3),
IDE_TFLAG_OUT_HOB_LBAM = (1 << 4),
IDE_TFLAG_OUT_HOB_LBAH = (1 << 5),
IDE_TFLAG_OUT_HOB = IDE_TFLAG_OUT_HOB_FEATURE |
IDE_TFLAG_OUT_HOB_NSECT |
IDE_TFLAG_OUT_HOB_LBAL |
IDE_TFLAG_OUT_HOB_LBAM |
IDE_TFLAG_OUT_HOB_LBAH,
IDE_TFLAG_OUT_FEATURE = (1 << 6),
IDE_TFLAG_OUT_NSECT = (1 << 7),
IDE_TFLAG_OUT_LBAL = (1 << 8),
IDE_TFLAG_OUT_LBAM = (1 << 9),
IDE_TFLAG_OUT_LBAH = (1 << 10),
IDE_TFLAG_OUT_TF = IDE_TFLAG_OUT_FEATURE |
IDE_TFLAG_OUT_NSECT |
IDE_TFLAG_OUT_LBAL |
IDE_TFLAG_OUT_LBAM |
IDE_TFLAG_OUT_LBAH,
IDE_TFLAG_OUT_DEVICE = (1 << 11),
IDE_TFLAG_WRITE = (1 << 12),
IDE_TFLAG_CUSTOM_HANDLER = (1 << 13),
IDE_TFLAG_DMA_PIO_FALLBACK = (1 << 14),
IDE_TFLAG_IN_HOB_ERROR = (1 << 15),
IDE_TFLAG_IN_HOB_NSECT = (1 << 16),
IDE_TFLAG_IN_HOB_LBAL = (1 << 17),
IDE_TFLAG_IN_HOB_LBAM = (1 << 18),
IDE_TFLAG_IN_HOB_LBAH = (1 << 19),
IDE_TFLAG_IN_HOB_LBA = IDE_TFLAG_IN_HOB_LBAL |
IDE_TFLAG_IN_HOB_LBAM |
IDE_TFLAG_IN_HOB_LBAH,
IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_ERROR |
IDE_TFLAG_IN_HOB_NSECT |
IDE_TFLAG_IN_HOB_LBA,
IDE_TFLAG_IN_ERROR = (1 << 20),
IDE_TFLAG_IN_NSECT = (1 << 21),
IDE_TFLAG_IN_LBAL = (1 << 22),
IDE_TFLAG_IN_LBAM = (1 << 23),
IDE_TFLAG_IN_LBAH = (1 << 24),
IDE_TFLAG_IN_LBA = IDE_TFLAG_IN_LBAL |
IDE_TFLAG_IN_LBAM |
IDE_TFLAG_IN_LBAH,
IDE_TFLAG_IN_TF = IDE_TFLAG_IN_NSECT |
IDE_TFLAG_IN_LBA,
IDE_TFLAG_IN_DEVICE = (1 << 25),
IDE_TFLAG_HOB = IDE_TFLAG_OUT_HOB |
IDE_TFLAG_IN_HOB,
IDE_TFLAG_TF = IDE_TFLAG_OUT_TF |
IDE_TFLAG_IN_TF,
IDE_TFLAG_DEVICE = IDE_TFLAG_OUT_DEVICE |
IDE_TFLAG_IN_DEVICE,
/* force 16-bit I/O operations */ /* force 16-bit I/O operations */
IDE_TFLAG_IO_16BIT = (1 << 26), IDE_TFLAG_IO_16BIT = (1 << 4),
/* struct ide_cmd was allocated using kmalloc() */ /* struct ide_cmd was allocated using kmalloc() */
IDE_TFLAG_DYN = (1 << 27), IDE_TFLAG_DYN = (1 << 5),
IDE_TFLAG_FS = (1 << 28), IDE_TFLAG_FS = (1 << 6),
IDE_TFLAG_MULTI_PIO = (1 << 29), IDE_TFLAG_MULTI_PIO = (1 << 7),
}; };
enum { enum {
@ -309,45 +282,34 @@ enum {
}; };
struct ide_taskfile { struct ide_taskfile {
u8 hob_data; /* 0: high data byte (for TASKFILE IOCTL) */ u8 data; /* 0: data byte (for TASKFILE ioctl) */
/* 1-5: additional data to support LBA48 */ union { /* 1: */
union { u8 error; /* read: error */
u8 hob_error; /* read: error */ u8 feature; /* write: feature */
u8 hob_feature; /* write: feature */
}; };
u8 nsect; /* 2: number of sectors */
u8 hob_nsect; u8 lbal; /* 3: LBA low */
u8 hob_lbal; u8 lbam; /* 4: LBA mid */
u8 hob_lbam; u8 lbah; /* 5: LBA high */
u8 hob_lbah; u8 device; /* 6: device select */
union { /* 7: */
u8 data; /* 6: low data byte (for TASKFILE IOCTL) */ u8 status; /* read: status */
union { /*  7: */
u8 error; /* read: error */
u8 feature; /* write: feature */
};
u8 nsect; /* 8: number of sectors */
u8 lbal; /* 9: LBA low */
u8 lbam; /* 10: LBA mid */
u8 lbah; /* 11: LBA high */
u8 device; /* 12: device select */
union { /* 13: */
u8 status; /*  read: status  */
u8 command; /* write: command */ u8 command; /* write: command */
}; };
}; };
struct ide_cmd { struct ide_cmd {
union { struct ide_taskfile tf;
struct ide_taskfile tf; struct ide_taskfile hob;
u8 tf_array[14]; struct {
}; struct {
u8 tf;
u8 hob;
} out, in;
} valid;
u8 tf_flags;
u8 ftf_flags; /* for TASKFILE ioctl */ u8 ftf_flags; /* for TASKFILE ioctl */
u32 tf_flags;
int protocol; int protocol;
int sg_nents; /* number of sg entries */ int sg_nents; /* number of sg entries */
@ -662,8 +624,8 @@ struct ide_tp_ops {
void (*write_devctl)(struct hwif_s *, u8); void (*write_devctl)(struct hwif_s *, u8);
void (*dev_select)(ide_drive_t *); void (*dev_select)(ide_drive_t *);
void (*tf_load)(ide_drive_t *, struct ide_cmd *); void (*tf_load)(ide_drive_t *, struct ide_taskfile *, u8);
void (*tf_read)(ide_drive_t *, struct ide_cmd *); void (*tf_read)(ide_drive_t *, struct ide_taskfile *, u8);
void (*input_data)(ide_drive_t *, struct ide_cmd *, void (*input_data)(ide_drive_t *, struct ide_cmd *,
void *, unsigned int); void *, unsigned int);
@ -1162,7 +1124,8 @@ extern int ide_devset_execute(ide_drive_t *drive,
void ide_complete_cmd(ide_drive_t *, struct ide_cmd *, u8, u8); void ide_complete_cmd(ide_drive_t *, struct ide_cmd *, u8, u8);
int ide_complete_rq(ide_drive_t *, int, unsigned int); int ide_complete_rq(ide_drive_t *, int, unsigned int);
void ide_tf_dump(const char *, struct ide_taskfile *); void ide_tf_readback(ide_drive_t *drive, struct ide_cmd *cmd);
void ide_tf_dump(const char *, struct ide_cmd *);
void ide_exec_command(ide_hwif_t *, u8); void ide_exec_command(ide_hwif_t *, u8);
u8 ide_read_status(ide_hwif_t *); u8 ide_read_status(ide_hwif_t *);
@ -1170,8 +1133,8 @@ u8 ide_read_altstatus(ide_hwif_t *);
void ide_write_devctl(ide_hwif_t *, u8); void ide_write_devctl(ide_hwif_t *, u8);
void ide_dev_select(ide_drive_t *); void ide_dev_select(ide_drive_t *);
void ide_tf_load(ide_drive_t *, struct ide_cmd *); void ide_tf_load(ide_drive_t *, struct ide_taskfile *, u8);
void ide_tf_read(ide_drive_t *, struct ide_cmd *); void ide_tf_read(ide_drive_t *, struct ide_taskfile *, u8);
void ide_input_data(ide_drive_t *, struct ide_cmd *, void *, unsigned int); void ide_input_data(ide_drive_t *, struct ide_cmd *, void *, unsigned int);
void ide_output_data(ide_drive_t *, struct ide_cmd *, void *, unsigned int); void ide_output_data(ide_drive_t *, struct ide_cmd *, void *, unsigned int);
@ -1529,7 +1492,7 @@ static inline void ide_set_hwifdata (ide_hwif_t * hwif, void *data)
extern void ide_toggle_bounce(ide_drive_t *drive, int on); extern void ide_toggle_bounce(ide_drive_t *drive, int on);
u64 ide_get_lba_addr(struct ide_taskfile *, int); u64 ide_get_lba_addr(struct ide_cmd *, int);
u8 ide_dump_status(ide_drive_t *, const char *, u8); u8 ide_dump_status(ide_drive_t *, const char *, u8);
struct ide_timing { struct ide_timing {