5 #include <linux/kernel.h>
6 #include <linux/delay.h>
9 static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason)
11 ide_hwif_t *hwif = drive->hwif;
14 while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) {
15 printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing "
16 "a packet command, retrying\n", drive->name);
18 ireason = hwif->INB(hwif->io_ports.nsect_addr);
20 printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing "
21 "a packet command, ignoring\n",
31 ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc,
32 ide_handler_t *handler, unsigned int timeout,
35 ide_hwif_t *hwif = drive->hwif;
36 ide_startstop_t startstop;
39 if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) {
40 printk(KERN_ERR "%s: Strange, packet command initiated yet "
41 "DRQ isn't asserted\n", drive->name);
45 ireason = hwif->INB(hwif->io_ports.nsect_addr);
46 if (drive->media == ide_tape && !drive->scsi)
47 ireason = ide_wait_ireason(drive, ireason);
49 if ((ireason & CD) == 0 || (ireason & IO)) {
50 printk(KERN_ERR "%s: (IO,CoD) != (0,1) while issuing "
51 "a packet command\n", drive->name);
52 return ide_do_reset(drive);
55 /* Set the interrupt routine */
56 ide_set_handler(drive, handler, timeout, expiry);
58 /* Begin DMA, if necessary */
59 if (pc->flags & PC_FLAG_DMA_OK) {
60 pc->flags |= PC_FLAG_DMA_IN_PROGRESS;
61 hwif->dma_ops->dma_start(drive);
64 /* Send the actual packet */
65 if ((pc->flags & PC_FLAG_ZIP_DRIVE) == 0)
66 hwif->output_data(drive, NULL, pc->c, 12);
70 EXPORT_SYMBOL_GPL(ide_transfer_pc);