Lines Matching full:drive
53 * - added trackbuffer for each drive to speed things up
102 #define DSKSEL3 (0x1<<6) /* select drive 3 when low */
103 #define DSKSEL2 (0x1<<5) /* select drive 2 when low */
104 #define DSKSEL1 (0x1<<4) /* select drive 1 when low */
105 #define DSKSEL0 (0x1<<3) /* select drive 0 when low */
176 unsigned long code; /* code returned from drive */
177 char *name; /* description of drive */
199 int disk; /* disk in drive (-1 == unknown) */
201 int busy; /* true when drive is active */
227 #define FD_DD_3 0xffffffff /* double-density 3.5" (880K) drive */
228 #define FD_HD_3 0x55555555 /* high-density 3.5" (1760K) drive */
229 #define FD_DD_5 0xaaaaaaaa /* double-density 5.25" (440K) drive */
245 #define SELMASK(drive) (1 << (3 + (drive & 3))) argument
253 { FD_NODRIVE, "No Drive", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
282 static volatile int selected = -1; /* currently selected drive */
359 static inline int try_fdc(int drive) in try_fdc() argument
361 drive &= 3; in try_fdc()
362 return ((fdc_busy < 0) || (fdc_busy == drive)); in try_fdc()
365 static void get_fdc(int drive) in get_fdc() argument
369 drive &= 3; in get_fdc()
371 printk("get_fdc: drive %d fdc_busy %d fdc_nested %d\n",drive,fdc_busy,fdc_nested); in get_fdc()
374 wait_event(fdc_wait, try_fdc(drive)); in get_fdc()
375 fdc_busy = drive; in get_fdc()
394 static void fd_select (int drive) in fd_select() argument
398 drive&=3; in fd_select()
400 printk("selecting %d\n",drive); in fd_select()
402 if (drive == selected) in fd_select()
404 get_fdc(drive); in fd_select()
405 selected = drive; in fd_select()
407 if (unit[drive].track % 2 != 0) in fd_select()
409 if (unit[drive].motor == 1) in fd_select()
413 prb &= ~SELMASK(drive); in fd_select()
418 static void fd_deselect (int drive) in fd_deselect() argument
423 drive&=3; in fd_deselect()
425 printk("deselecting %d\n",drive); in fd_deselect()
427 if (drive != selected) { in fd_deselect()
428 printk(KERN_WARNING "Deselecting drive %d while %d was selected!\n",drive,selected); in fd_deselect()
432 get_fdc(drive); in fd_deselect()
481 …printk (KERN_WARNING "DSKRDY not set after 1.5 seconds - assuming drive is spinning notwithstandin… in fd_motor_on()
490 unsigned long drive = ((unsigned long)timer - in fd_motor_off() local
494 drive&=3; in fd_motor_off()
495 if (!try_fdc(drive)) { in fd_motor_off()
501 unit[drive].motor = 0; in fd_motor_off()
502 fd_select(drive); in fd_motor_off()
504 fd_deselect(drive); in fd_motor_off()
509 int drive; in floppy_off() local
511 drive = nr & 3; in floppy_off()
512 mod_timer(motor_off_timer + drive, jiffies + 3*HZ); in floppy_off()
515 static int fd_calibrate(int drive) in fd_calibrate() argument
520 drive &= 3; in fd_calibrate()
521 get_fdc(drive); in fd_calibrate()
522 if (!fd_motor_on (drive)) in fd_calibrate()
524 fd_select (drive); in fd_calibrate()
529 for (n = unit[drive].type->tracks/2; n != 0; --n) { in fd_calibrate()
537 ms_delay(unit[drive].type->step_delay); in fd_calibrate()
539 ms_delay (unit[drive].type->settle_time); in fd_calibrate()
541 n = unit[drive].type->tracks + 20; in fd_calibrate()
548 ms_delay(unit[drive].type->step_delay + 1); in fd_calibrate()
552 printk (KERN_ERR "fd%d: calibrate failed, turning motor off\n", drive); in fd_calibrate()
553 fd_motor_off (motor_off_timer + drive); in fd_calibrate()
554 unit[drive].track = -1; in fd_calibrate()
559 unit[drive].track = 0; in fd_calibrate()
560 ms_delay(unit[drive].type->settle_time); in fd_calibrate()
563 fd_deselect(drive); in fd_calibrate()
567 static int fd_seek(int drive, int track) in fd_seek() argument
573 printk("seeking drive %d to track %d\n",drive,track); in fd_seek()
575 drive &= 3; in fd_seek()
576 get_fdc(drive); in fd_seek()
577 if (unit[drive].track == track) { in fd_seek()
581 if (!fd_motor_on(drive)) { in fd_seek()
585 if (unit[drive].track < 0 && !fd_calibrate(drive)) { in fd_seek()
590 fd_select (drive); in fd_seek()
591 cnt = unit[drive].track/2 - track/2; in fd_seek()
601 if (track % 2 != unit[drive].track % 2) in fd_seek()
602 ms_delay (unit[drive].type->side_time); in fd_seek()
603 unit[drive].track = track; in fd_seek()
606 fd_deselect(drive); in fd_seek()
615 ms_delay (unit[drive].type->step_delay); in fd_seek()
617 ms_delay (unit[drive].type->settle_time); in fd_seek()
620 fd_deselect(drive); in fd_seek()
624 static unsigned long fd_get_drive_id(int drive) in fd_get_drive_id() argument
629 drive&=3; in fd_get_drive_id()
630 get_fdc(drive); in fd_get_drive_id()
634 SELECT(SELMASK(drive)); in fd_get_drive_id()
636 DESELECT(SELMASK(drive)); in fd_get_drive_id()
640 SELECT(SELMASK(drive)); in fd_get_drive_id()
642 DESELECT(SELMASK(drive)); in fd_get_drive_id()
647 SELECT(SELMASK(drive)); in fd_get_drive_id()
654 DESELECT(SELMASK(drive)); in fd_get_drive_id()
661 * As every (real) Amiga has at least a 3.5" DD drive as df0: in fd_get_drive_id()
665 if(drive == 0 && id == FD_NODRIVE) in fd_get_drive_id()
668 … printk(KERN_NOTICE "fd: drive 0 didn't identify, setting default %08lx\n", (ulong)fd_def_df0); in fd_get_drive_id()
692 static void raw_read(int drive) in raw_read() argument
694 drive&=3; in raw_read()
695 get_fdc(drive); in raw_read()
697 fd_select(drive); in raw_read()
706 custom.dsklen = unit[drive].type->read_size/sizeof(short) | DSKLEN_DMAEN; in raw_read()
707 custom.dsklen = unit[drive].type->read_size/sizeof(short) | DSKLEN_DMAEN; in raw_read()
714 fd_deselect(drive); in raw_read()
718 static int raw_write(int drive) in raw_write() argument
722 drive&=3; in raw_write()
723 get_fdc(drive); /* corresponds to rel_fdc() in post_write() */ in raw_write()
729 fd_select(drive); in raw_write()
734 if ((ulong)unit[drive].track >= unit[drive].type->precomp2) in raw_write()
736 else if ((ulong)unit[drive].track >= unit[drive].type->precomp1) in raw_write()
742 custom.dsklen = unit[drive].type->write_size/sizeof(short) | DSKLEN_DMAEN|DSKLEN_WRITE; in raw_write()
743 custom.dsklen = unit[drive].type->write_size/sizeof(short) | DSKLEN_DMAEN|DSKLEN_WRITE; in raw_write()
753 static void post_write (unsigned long drive) in post_write() argument
756 printk("post_write for drive %ld\n",drive); in post_write()
758 drive &= 3; in post_write()
763 unit[drive].dirty = 0; in post_write()
765 fd_deselect(drive); in post_write()
836 static int amiga_read(int drive) in amiga_read() argument
844 drive&=3; in amiga_read()
846 end = raw + unit[drive].type->read_size; in amiga_read()
848 for (scnt = 0;scnt < unit[drive].dtype->sects * unit[drive].type->sect_mult; scnt++) { in amiga_read()
875 if (hdr.track != unit[drive].track) { in amiga_read()
876 printk(KERN_INFO "MFM_TRACK: %d, %d\n", hdr.track, unit[drive].track); in amiga_read()
880 raw = decode ((ulong *)(unit[drive].trackbuf + hdr.sect*512), in amiga_read()
882 csum = checksum((ulong *)(unit[drive].trackbuf + hdr.sect*512), 512); in amiga_read()
889 ((ulong *)(unit[drive].trackbuf+hdr.sect*512))[0], in amiga_read()
890 ((ulong *)(unit[drive].trackbuf+hdr.sect*512))[1], in amiga_read()
891 ((ulong *)(unit[drive].trackbuf+hdr.sect*512))[2], in amiga_read()
892 ((ulong *)(unit[drive].trackbuf+hdr.sect*512))[3]); in amiga_read()
1151 static int dos_read(int drive) in dos_read() argument
1159 drive&=3; in dos_read()
1161 end = raw + unit[drive].type->read_size; in dos_read()
1163 for (scnt=0; scnt < unit[drive].dtype->sects * unit[drive].type->sect_mult; scnt++) { in dos_read()
1168 unit[drive].track,drive,scnt); in dos_read()
1189 if (hdr.track != unit[drive].track/unit[drive].type->heads) { in dos_read()
1192 unit[drive].track/unit[drive].type->heads); in dos_read()
1196 if (hdr.side != unit[drive].track%unit[drive].type->heads) { in dos_read()
1199 unit[drive].track%unit[drive].type->heads); in dos_read()
1214 unit[drive].track, drive, scnt, hdr.sec); in dos_read()
1229 …raw = dos_decode((unsigned char *)(unit[drive].trackbuf + (hdr.sec - 1) * 512), (ushort *) raw, 51… in dos_read()
1231 crc = dos_data_crc(unit[drive].trackbuf + (hdr.sec - 1) * 512); in dos_read()
1238 ((ulong *)(unit[drive].trackbuf+(hdr.sec-1)*512))[0], in dos_read()
1239 ((ulong *)(unit[drive].trackbuf+(hdr.sec-1)*512))[1], in dos_read()
1240 ((ulong *)(unit[drive].trackbuf+(hdr.sec-1)*512))[2], in dos_read()
1241 ((ulong *)(unit[drive].trackbuf+(hdr.sec-1)*512))[3]); in dos_read()
1272 static unsigned long *ms_putsec(int drive, unsigned long *raw, int cnt) in ms_putsec() argument
1279 drive&=3; in ms_putsec()
1289 hdr.track=unit[drive].track/unit[drive].type->heads; in ms_putsec()
1290 hdr.side=unit[drive].track%unit[drive].type->heads; in ms_putsec()
1308 (unsigned char *)unit[drive].trackbuf+cnt*512,512); in ms_putsec()
1312 crc[0]=dos_data_crc(unit[drive].trackbuf+cnt*512); in ms_putsec()
1363 /* FIXME: this assumes the drive is still spinning -
1424 static int get_track(int drive, int track) in get_track() argument
1428 drive&=3; in get_track()
1429 if (unit[drive].track == track) in get_track()
1431 get_fdc(drive); in get_track()
1432 if (!fd_motor_on(drive)) { in get_track()
1437 if (unit[drive].dirty == 1) { in get_track()
1438 del_timer (flush_track_timer + drive); in get_track()
1439 non_int_flush_track (drive); in get_track()
1443 if (!fd_seek(drive, track)) in get_track()
1445 raw_read(drive); in get_track()
1446 error = (*unit[drive].dtype->read_fkt)(drive); in get_track()
1452 unit[drive].track = -1; in get_track()
1462 int drive = floppy - unit; in amiflop_rw_cur_segment() local
1481 if (get_track(drive, track) == -1) in amiflop_rw_cur_segment()
1489 /* keep the drive spinning while writes are scheduled */ in amiflop_rw_cur_segment()
1490 if (!fd_motor_on(drive)) in amiflop_rw_cur_segment()
1498 mod_timer (flush_track_timer + drive, jiffies + 1); in amiflop_rw_cur_segment()
1528 int drive = MINOR(bdev->bd_dev) & 3; in fd_getgeo() local
1530 geo->heads = unit[drive].type->heads; in fd_getgeo()
1531 geo->sectors = unit[drive].dtype->sects * unit[drive].type->sect_mult; in fd_getgeo()
1532 geo->cylinders = unit[drive].type->tracks; in fd_getgeo()
1540 int drive = p - unit; in fd_locked_ioctl() local
1546 get_fdc(drive); in fd_locked_ioctl()
1547 if (fd_ref[drive] > 1) { in fd_locked_ioctl()
1551 if (fd_motor_on(drive) == 0) { in fd_locked_ioctl()
1555 if (fd_calibrate(drive) == 0) { in fd_locked_ioctl()
1559 floppy_off(drive); in fd_locked_ioctl()
1565 get_fdc(drive); in fd_locked_ioctl()
1566 if (fd_seek(drive,param) != 0){ in fd_locked_ioctl()
1569 non_int_flush_track(drive); in fd_locked_ioctl()
1571 floppy_off(drive); in fd_locked_ioctl()
1578 floppy_off(drive); in fd_locked_ioctl()
1594 del_timer (flush_track_timer + drive); in fd_locked_ioctl()
1595 non_int_flush_track(drive); in fd_locked_ioctl()
1626 int drive; in fd_probe() local
1628 drive = dev & 3; in fd_probe()
1629 code = fd_get_drive_id(drive); in fd_probe()
1631 /* get drive type */ in fd_probe()
1637 printk(KERN_WARNING "fd_probe: unsupported drive type " in fd_probe()
1639 unit[drive].type = &drive_types[num_dr_types-1]; /* FD_NODRIVE */ in fd_probe()
1643 unit[drive].type = drive_types + type; in fd_probe()
1644 unit[drive].track = -1; in fd_probe()
1646 unit[drive].disk = -1; in fd_probe()
1647 unit[drive].motor = 0; in fd_probe()
1648 unit[drive].busy = 0; in fd_probe()
1649 unit[drive].status = -1; in fd_probe()
1655 * drive with different device numbers.
1659 int drive = disk->first_minor & 3; in floppy_open() local
1665 old_dev = fd_device[drive]; in floppy_open()
1667 if (fd_ref[drive] && old_dev != system) { in floppy_open()
1672 if (unit[drive].type->code == FD_NODRIVE) { in floppy_open()
1681 get_fdc(drive); in floppy_open()
1682 fd_select (drive); in floppy_open()
1684 fd_deselect (drive); in floppy_open()
1694 fd_ref[drive]++; in floppy_open()
1695 fd_device[drive] = system; in floppy_open()
1698 unit[drive].dtype=&data_types[system]; in floppy_open()
1699 unit[drive].blocks=unit[drive].type->heads*unit[drive].type->tracks* in floppy_open()
1700 data_types[system].sects*unit[drive].type->sect_mult; in floppy_open()
1701 set_capacity(unit[drive].gendisk[system], unit[drive].blocks); in floppy_open()
1703 printk(KERN_INFO "fd%d: accessing %s-disk with %s-layout\n",drive, in floppy_open()
1704 unit[drive].type->name, data_types[system].name); in floppy_open()
1713 int drive = p - unit; in floppy_release() local
1716 if (unit[drive].dirty == 1) { in floppy_release()
1717 del_timer (flush_track_timer + drive); in floppy_release()
1718 non_int_flush_track (drive); in floppy_release()
1721 if (!fd_ref[drive]--) { in floppy_release()
1723 fd_ref[drive] = 0; in floppy_release()
1726 floppy_off (drive); in floppy_release()
1734 * to the desired drive, but it will probably not survive the sleep if
1740 int drive = p - unit; in amiga_check_events() local
1747 get_fdc(drive); in amiga_check_events()
1748 fd_select (drive); in amiga_check_events()
1750 fd_deselect (drive); in amiga_check_events()
1755 fd_probe(drive); in amiga_check_events()
1778 static int fd_alloc_disk(int drive, int system) in fd_alloc_disk() argument
1786 disk = blk_mq_alloc_disk(&unit[drive].tag_set, &lim, NULL); in fd_alloc_disk()
1791 disk->first_minor = drive + system; in fd_alloc_disk()
1797 sprintf(disk->disk_name, "fd%d_msdos", drive); in fd_alloc_disk()
1799 sprintf(disk->disk_name, "fd%d", drive); in fd_alloc_disk()
1800 disk->private_data = &unit[drive]; in fd_alloc_disk()
1803 unit[drive].gendisk[system] = disk; in fd_alloc_disk()
1810 static int fd_alloc_drive(int drive) in fd_alloc_drive() argument
1812 unit[drive].trackbuf = kmalloc(FLOPPY_MAX_SECTORS * 512, GFP_KERNEL); in fd_alloc_drive()
1813 if (!unit[drive].trackbuf) in fd_alloc_drive()
1816 memset(&unit[drive].tag_set, 0, sizeof(unit[drive].tag_set)); in fd_alloc_drive()
1817 unit[drive].tag_set.ops = &amiflop_mq_ops; in fd_alloc_drive()
1818 unit[drive].tag_set.nr_hw_queues = 1; in fd_alloc_drive()
1819 unit[drive].tag_set.nr_maps = 1; in fd_alloc_drive()
1820 unit[drive].tag_set.queue_depth = 2; in fd_alloc_drive()
1821 unit[drive].tag_set.numa_node = NUMA_NO_NODE; in fd_alloc_drive()
1822 unit[drive].tag_set.flags = BLK_MQ_F_SHOULD_MERGE; in fd_alloc_drive()
1823 if (blk_mq_alloc_tag_set(&unit[drive].tag_set)) in fd_alloc_drive()
1826 pr_cont(" fd%d", drive); in fd_alloc_drive()
1828 if (fd_alloc_disk(drive, 0) || fd_alloc_disk(drive, 1)) in fd_alloc_drive()
1833 blk_mq_free_tag_set(&unit[drive].tag_set); in fd_alloc_drive()
1835 kfree(unit[drive].trackbuf); in fd_alloc_drive()
1837 unit[drive].type->code = FD_NODRIVE; in fd_alloc_drive()
1843 int drive,drives,nomem; in fd_probe_drives() local
1848 for(drive=0;drive<FD_MAX_UNITS;drive++) { in fd_probe_drives()
1849 fd_probe(drive); in fd_probe_drives()
1850 if (unit[drive].type->code == FD_NODRIVE) in fd_probe_drives()
1853 if (fd_alloc_drive(drive) < 0) { in fd_probe_drives()
1854 pr_cont(" no mem for fd%d", drive); in fd_probe_drives()