• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/src/linux/linux-2.6/drivers/block/paride/

Lines Matching refs:disk

229 	int changed;		/* Have we seen a disk change ? */
246 static inline int status_reg(struct pd_unit *disk)
248 return pi_read_regr(disk->pi, 1, 6);
251 static inline int read_reg(struct pd_unit *disk, int reg)
253 return pi_read_regr(disk->pi, 0, reg);
256 static inline void write_status(struct pd_unit *disk, int val)
258 pi_write_regr(disk->pi, 1, 6, val);
261 static inline void write_reg(struct pd_unit *disk, int reg, int val)
263 pi_write_regr(disk->pi, 0, reg, val);
266 static inline u8 DRIVE(struct pd_unit *disk)
268 return 0xa0+0x10*disk->drive;
273 static void pd_print_error(struct pd_unit *disk, char *msg, int status)
277 printk("%s: %s: status = 0x%x =", disk->name, msg, status);
284 static void pd_reset(struct pd_unit *disk)
286 write_status(disk, 4);
288 write_status(disk, 0);
294 static int pd_wait_for(struct pd_unit *disk, int w, char *msg)
300 r = status_reg(disk);
306 e = (read_reg(disk, 1) << 8) + read_reg(disk, 7);
310 pd_print_error(disk, msg, e);
314 static void pd_send_command(struct pd_unit *disk, int n, int s, int h, int c0, int c1, int func)
316 write_reg(disk, 6, DRIVE(disk) + h);
317 write_reg(disk, 1, 0); /* the IDE task file */
318 write_reg(disk, 2, n);
319 write_reg(disk, 3, s);
320 write_reg(disk, 4, c0);
321 write_reg(disk, 5, c1);
322 write_reg(disk, 7, func);
327 static void pd_ide_command(struct pd_unit *disk, int func, int block, int count)
331 if (disk->can_lba) {
337 s = (block % disk->sectors) + 1;
338 h = (block /= disk->sectors) % disk->heads;
339 c0 = (block /= disk->heads) % 256;
342 pd_send_command(disk, count, s, h, c0, c1, func);
581 static void pd_init_dev_parms(struct pd_unit *disk)
583 pd_wait_for(disk, 0, DBMSG("before init_dev_parms"));
584 pd_send_command(disk, disk->sectors, 0, disk->heads - 1, 0, 0,
587 pd_wait_for(disk, 0, "Initialise device parameters");
590 static enum action pd_door_lock(struct pd_unit *disk)
592 if (!(pd_wait_for(disk, STAT_READY, "Lock") & STAT_ERR)) {
593 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_DOORLOCK);
594 pd_wait_for(disk, STAT_READY, "Lock done");
599 static enum action pd_door_unlock(struct pd_unit *disk)
601 if (!(pd_wait_for(disk, STAT_READY, "Lock") & STAT_ERR)) {
602 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_DOORUNLOCK);
603 pd_wait_for(disk, STAT_READY, "Lock done");
608 static enum action pd_eject(struct pd_unit *disk)
610 pd_wait_for(disk, 0, DBMSG("before unlock on eject"));
611 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_DOORUNLOCK);
612 pd_wait_for(disk, 0, DBMSG("after unlock on eject"));
613 pd_wait_for(disk, 0, DBMSG("before eject"));
614 pd_send_command(disk, 0, 0, 0, 0, 0, IDE_EJECT);
615 pd_wait_for(disk, 0, DBMSG("after eject"));
619 static enum action pd_media_check(struct pd_unit *disk)
621 int r = pd_wait_for(disk, STAT_READY, DBMSG("before media_check"));
623 pd_send_command(disk, 1, 1, 0, 0, 0, IDE_READ_VRFY);
624 r = pd_wait_for(disk, STAT_READY, DBMSG("RDY after READ_VRFY"));
626 disk->changed = 1; /* say changed if other error */
628 disk->changed = 1;
629 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_ACKCHANGE);
630 pd_wait_for(disk, STAT_READY, DBMSG("RDY after ACKCHANGE"));
631 pd_send_command(disk, 1, 1, 0, 0, 0, IDE_READ_VRFY);
632 r = pd_wait_for(disk, STAT_READY, DBMSG("RDY after VRFY"));
637 static void pd_standby_off(struct pd_unit *disk)
639 pd_wait_for(disk, 0, DBMSG("before STANDBY"));
640 pd_send_command(disk, 0, 0, 0, 0, 0, IDE_STANDBY);
641 pd_wait_for(disk, 0, DBMSG("after STANDBY"));
644 static enum action pd_identify(struct pd_unit *disk)
655 if (disk->drive == 0)
656 pd_reset(disk);
658 write_reg(disk, 6, DRIVE(disk));
659 pd_wait_for(disk, 0, DBMSG("before IDENT"));
660 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_IDENTIFY);
662 if (pd_wait_for(disk, STAT_DRQ, DBMSG("IDENT DRQ")) & STAT_ERR)
664 pi_read_block(disk->pi, pd_scratch, 512);
665 disk->can_lba = pd_scratch[99] & 2;
666 disk->sectors = le16_to_cpu(*(__le16 *) (pd_scratch + 12));
667 disk->heads = le16_to_cpu(*(__le16 *) (pd_scratch + 6));
668 disk->cylinders = le16_to_cpu(*(__le16 *) (pd_scratch + 2));
669 if (disk->can_lba)
670 disk->capacity = le32_to_cpu(*(__le32 *) (pd_scratch + 120));
672 disk->capacity = disk->sectors * disk->heads * disk->cylinders;
682 disk->removable = pd_scratch[0] & 0x80;
685 disk->name, id,
686 disk->drive ? "slave" : "master",
687 disk->capacity, disk->capacity / 2048,
688 disk->cylinders, disk->heads, disk->sectors,
689 disk->removable ? "removable" : "fixed");
691 if (disk->capacity)
692 pd_init_dev_parms(disk);
693 if (!disk->standby)
694 pd_standby_off(disk);
712 static int pd_special_command(struct pd_unit *disk,
713 enum action (*func)(struct pd_unit *disk))
721 rq.rq_disk = disk->gd;
725 blk_insert_request(disk->gd->queue, &rq, 0, func);
737 struct pd_unit *disk = inode->i_bdev->bd_disk->private_data;
739 disk->access++;
741 if (disk->removable) {
742 pd_special_command(disk, pd_media_check);
743 pd_special_command(disk, pd_door_lock);
750 struct pd_unit *disk = bdev->bd_disk->private_data;
752 if (disk->alt_geom) {
755 geo->cylinders = disk->capacity / (geo->heads * geo->sectors);
757 geo->heads = disk->heads;
758 geo->sectors = disk->sectors;
759 geo->cylinders = disk->cylinders;
768 struct pd_unit *disk = inode->i_bdev->bd_disk->private_data;
772 if (disk->access == 1)
773 pd_special_command(disk, pd_eject);
782 struct pd_unit *disk = inode->i_bdev->bd_disk->private_data;
784 if (!--disk->access && disk->removable)
785 pd_special_command(disk, pd_door_unlock);
792 struct pd_unit *disk = p->private_data;
794 if (!disk->removable)
796 pd_special_command(disk, pd_media_check);
797 r = disk->changed;
798 disk->changed = 0;
804 struct pd_unit *disk = p->private_data;
805 if (pd_special_command(disk, pd_identify) == 0)
806 set_capacity(p, disk->capacity);
824 static void pd_probe_drive(struct pd_unit *disk)
829 strcpy(p->disk_name, disk->name);
832 p->first_minor = (disk - pd) << PD_BITS;
833 disk->gd = p;
834 p->private_data = disk;
837 if (disk->drive == -1) {
838 for (disk->drive = 0; disk->drive <= 1; disk->drive++)
839 if (pd_special_command(disk, pd_identify) == 0)
841 } else if (pd_special_command(disk, pd_identify) == 0)
843 disk->gd = NULL;
850 struct pd_unit *disk;
854 struct pd_unit *disk = pd + unit;
855 disk->pi = &disk->pia;
856 disk->access = 0;
857 disk->changed = 1;
858 disk->capacity = 0;
859 disk->drive = parm[D_SLV];
860 snprintf(disk->name, PD_NAMELEN, "%s%c", name, 'a'+unit);
861 disk->alt_geom = parm[D_GEO];
862 disk->standby = parm[D_SBY];
868 disk = pd;
869 if (pi_init(disk->pi, 1, -1, -1, -1, -1, -1, pd_scratch,
870 PI_PD, verbose, disk->name)) {
871 pd_probe_drive(disk);
872 if (!disk->gd)
873 pi_release(disk->pi);
877 for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) {
881 if (pi_init(disk->pi, 0, parm[D_PRT], parm[D_MOD],
883 pd_scratch, PI_PD, verbose, disk->name)) {
884 pd_probe_drive(disk);
885 if (!disk->gd)
886 pi_release(disk->pi);
890 for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) {
891 if (disk->gd) {
892 set_capacity(disk->gd, disk->capacity);
893 add_disk(disk->gd);
933 struct pd_unit *disk;
936 for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) {
937 struct gendisk *p = disk->gd;
939 disk->gd = NULL;
942 pi_release(disk->pi);