swim3.c (f06d9a2b52e246a66b606130cea3f0d7b7be17a7) swim3.c (467ca759fc83fc35cb7d15aec0d74c62cffc4481)
1/*
2 * Driver for the SWIM3 (Super Woz Integrated Machine 3)
3 * floppy controller found on Power Macintoshes.
4 *
5 * Copyright (C) 1996 Paul Mackerras.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License

--- 305 unchanged lines hidden (view full) ---

314#if 0
315 printk("do_fd_req: dev=%s cmd=%d sec=%ld nr_sec=%ld buf=%p\n",
316 req->rq_disk->disk_name, req->cmd,
317 (long)req->sector, req->nr_sectors, req->buffer);
318 printk(" errors=%d current_nr_sectors=%ld\n",
319 req->errors, req->current_nr_sectors);
320#endif
321
1/*
2 * Driver for the SWIM3 (Super Woz Integrated Machine 3)
3 * floppy controller found on Power Macintoshes.
4 *
5 * Copyright (C) 1996 Paul Mackerras.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License

--- 305 unchanged lines hidden (view full) ---

314#if 0
315 printk("do_fd_req: dev=%s cmd=%d sec=%ld nr_sec=%ld buf=%p\n",
316 req->rq_disk->disk_name, req->cmd,
317 (long)req->sector, req->nr_sectors, req->buffer);
318 printk(" errors=%d current_nr_sectors=%ld\n",
319 req->errors, req->current_nr_sectors);
320#endif
321
322 if (req->sector < 0 || req->sector >= fs->total_secs) {
322 if (req->sector >= fs->total_secs) {
323 __blk_end_request_cur(req, -EIO);
324 continue;
325 }
323 __blk_end_request_cur(req, -EIO);
324 continue;
325 }
326 if (req->current_nr_sectors == 0) {
327 __blk_end_request_cur(req, 0);
328 continue;
329 }
330 if (fs->ejected) {
331 __blk_end_request_cur(req, -EIO);
332 continue;
333 }
334
335 if (rq_data_dir(req) == WRITE) {
336 if (fs->write_prot < 0)
337 fs->write_prot = swim3_readbit(fs, WRITE_PROT);

--- 250 unchanged lines hidden (view full) ---

588 start_request(fs);
589}
590
591static void xfer_timeout(unsigned long data)
592{
593 struct floppy_state *fs = (struct floppy_state *) data;
594 struct swim3 __iomem *sw = fs->swim3;
595 struct dbdma_regs __iomem *dr = fs->dma;
326 if (fs->ejected) {
327 __blk_end_request_cur(req, -EIO);
328 continue;
329 }
330
331 if (rq_data_dir(req) == WRITE) {
332 if (fs->write_prot < 0)
333 fs->write_prot = swim3_readbit(fs, WRITE_PROT);

--- 250 unchanged lines hidden (view full) ---

584 start_request(fs);
585}
586
587static void xfer_timeout(unsigned long data)
588{
589 struct floppy_state *fs = (struct floppy_state *) data;
590 struct swim3 __iomem *sw = fs->swim3;
591 struct dbdma_regs __iomem *dr = fs->dma;
596 struct dbdma_cmd *cp = fs->dma_cmd;
597 unsigned long s;
598 int n;
599
600 fs->timeout_pending = 0;
601 out_le32(&dr->control, RUN << 16);
602 /* We must wait a bit for dbdma to stop */
603 for (n = 0; (in_le32(&dr->status) & ACTIVE) && n < 1000; n++)
604 udelay(1);
605 out_8(&sw->intr_enable, 0);
606 out_8(&sw->control_bic, WRITE_SECTORS | DO_ACTION);
607 out_8(&sw->select, RELAX);
592 int n;
593
594 fs->timeout_pending = 0;
595 out_le32(&dr->control, RUN << 16);
596 /* We must wait a bit for dbdma to stop */
597 for (n = 0; (in_le32(&dr->status) & ACTIVE) && n < 1000; n++)
598 udelay(1);
599 out_8(&sw->intr_enable, 0);
600 out_8(&sw->control_bic, WRITE_SECTORS | DO_ACTION);
601 out_8(&sw->select, RELAX);
608 if (rq_data_dir(fd_req) == WRITE)
609 ++cp;
610 if (ld_le16(&cp->xfer_status) != 0)
611 s = fs->scount - ((ld_le16(&cp->res_count) + 511) >> 9);
612 else
613 s = 0;
614 fd_req->sector += s;
615 fd_req->current_nr_sectors -= s;
616 printk(KERN_ERR "swim3: timeout %sing sector %ld\n",
617 (rq_data_dir(fd_req)==WRITE? "writ": "read"), (long)fd_req->sector);
618 __blk_end_request_cur(fd_req, -EIO);
619 fs->state = idle;
620 start_request(fs);
621}
622
623static irqreturn_t swim3_interrupt(int irq, void *dev_id)

--- 90 unchanged lines hidden (view full) ---

714 }
715 /* turn off DMA */
716 out_le32(&dr->control, (RUN | PAUSE) << 16);
717 stat = ld_le16(&cp->xfer_status);
718 resid = ld_le16(&cp->res_count);
719 if (intr & ERROR_INTR) {
720 n = fs->scount - 1 - resid / 512;
721 if (n > 0) {
602 printk(KERN_ERR "swim3: timeout %sing sector %ld\n",
603 (rq_data_dir(fd_req)==WRITE? "writ": "read"), (long)fd_req->sector);
604 __blk_end_request_cur(fd_req, -EIO);
605 fs->state = idle;
606 start_request(fs);
607}
608
609static irqreturn_t swim3_interrupt(int irq, void *dev_id)

--- 90 unchanged lines hidden (view full) ---

700 }
701 /* turn off DMA */
702 out_le32(&dr->control, (RUN | PAUSE) << 16);
703 stat = ld_le16(&cp->xfer_status);
704 resid = ld_le16(&cp->res_count);
705 if (intr & ERROR_INTR) {
706 n = fs->scount - 1 - resid / 512;
707 if (n > 0) {
722 fd_req->sector += n;
723 fd_req->current_nr_sectors -= n;
724 fd_req->buffer += n * 512;
708 blk_update_request(fd_req, 0, n << 9);
725 fs->req_sector += n;
726 }
727 if (fs->retries < 5) {
728 ++fs->retries;
729 act(fs);
730 } else {
731 printk("swim3: error %sing block %ld (err=%x)\n",
732 rq_data_dir(fd_req) == WRITE? "writ": "read",

--- 7 unchanged lines hidden (view full) ---

740 printk(KERN_ERR "swim3: fd dma: stat=%x resid=%d\n", stat, resid);
741 printk(KERN_ERR " state=%d, dir=%x, intr=%x, err=%x\n",
742 fs->state, rq_data_dir(fd_req), intr, err);
743 __blk_end_request_cur(fd_req, -EIO);
744 fs->state = idle;
745 start_request(fs);
746 break;
747 }
709 fs->req_sector += n;
710 }
711 if (fs->retries < 5) {
712 ++fs->retries;
713 act(fs);
714 } else {
715 printk("swim3: error %sing block %ld (err=%x)\n",
716 rq_data_dir(fd_req) == WRITE? "writ": "read",

--- 7 unchanged lines hidden (view full) ---

724 printk(KERN_ERR "swim3: fd dma: stat=%x resid=%d\n", stat, resid);
725 printk(KERN_ERR " state=%d, dir=%x, intr=%x, err=%x\n",
726 fs->state, rq_data_dir(fd_req), intr, err);
727 __blk_end_request_cur(fd_req, -EIO);
728 fs->state = idle;
729 start_request(fs);
730 break;
731 }
748 fd_req->sector += fs->scount;
749 fd_req->current_nr_sectors -= fs->scount;
750 fd_req->buffer += fs->scount * 512;
751 if (fd_req->current_nr_sectors <= 0) {
752 __blk_end_request_cur(fd_req, 0);
753 fs->state = idle;
754 } else {
732 if (__blk_end_request(fd_req, 0, fs->scount << 9)) {
755 fs->req_sector += fs->scount;
756 if (fs->req_sector > fs->secpertrack) {
757 fs->req_sector -= fs->secpertrack;
758 if (++fs->head > 1) {
759 fs->head = 0;
760 ++fs->req_cyl;
761 }
762 }
763 act(fs);
733 fs->req_sector += fs->scount;
734 if (fs->req_sector > fs->secpertrack) {
735 fs->req_sector -= fs->secpertrack;
736 if (++fs->head > 1) {
737 fs->head = 0;
738 ++fs->req_cyl;
739 }
740 }
741 act(fs);
764 }
742 } else
743 fs->state = idle;
765 }
766 if (fs->state == idle)
767 start_request(fs);
768 break;
769 default:
770 printk(KERN_ERR "swim3: don't know what to do in state %d\n", fs->state);
771 }
772 return IRQ_HANDLED;

--- 416 unchanged lines hidden ---
744 }
745 if (fs->state == idle)
746 start_request(fs);
747 break;
748 default:
749 printk(KERN_ERR "swim3: don't know what to do in state %d\n", fs->state);
750 }
751 return IRQ_HANDLED;

--- 416 unchanged lines hidden ---