• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/block/paride/

Lines Matching refs:disk

231 	int changed;		/* Have we seen a disk change ? */
248 static inline int status_reg(struct pd_unit *disk)
250 return pi_read_regr(disk->pi, 1, 6);
253 static inline int read_reg(struct pd_unit *disk, int reg)
255 return pi_read_regr(disk->pi, 0, reg);
258 static inline void write_status(struct pd_unit *disk, int val)
260 pi_write_regr(disk->pi, 1, 6, val);
263 static inline void write_reg(struct pd_unit *disk, int reg, int val)
265 pi_write_regr(disk->pi, 0, reg, val);
268 static inline u8 DRIVE(struct pd_unit *disk)
270 return 0xa0+0x10*disk->drive;
275 static void pd_print_error(struct pd_unit *disk, char *msg, int status)
279 printk("%s: %s: status = 0x%x =", disk->name, msg, status);
286 static void pd_reset(struct pd_unit *disk)
288 write_status(disk, 4);
290 write_status(disk, 0);
296 static int pd_wait_for(struct pd_unit *disk, int w, char *msg)
302 r = status_reg(disk);
308 e = (read_reg(disk, 1) << 8) + read_reg(disk, 7);
312 pd_print_error(disk, msg, e);
316 static void pd_send_command(struct pd_unit *disk, int n, int s, int h, int c0, int c1, int func)
318 write_reg(disk, 6, DRIVE(disk) + h);
319 write_reg(disk, 1, 0); /* the IDE task file */
320 write_reg(disk, 2, n);
321 write_reg(disk, 3, s);
322 write_reg(disk, 4, c0);
323 write_reg(disk, 5, c1);
324 write_reg(disk, 7, func);
329 static void pd_ide_command(struct pd_unit *disk, int func, int block, int count)
333 if (disk->can_lba) {
339 s = (block % disk->sectors) + 1;
340 h = (block /= disk->sectors) % disk->heads;
341 c0 = (block /= disk->heads) % 256;
344 pd_send_command(disk, count, s, h, c0, c1, func);
585 static void pd_init_dev_parms(struct pd_unit *disk)
587 pd_wait_for(disk, 0, DBMSG("before init_dev_parms"));
588 pd_send_command(disk, disk->sectors, 0, disk->heads - 1, 0, 0,
591 pd_wait_for(disk, 0, "Initialise device parameters");
594 static enum action pd_door_lock(struct pd_unit *disk)
596 if (!(pd_wait_for(disk, STAT_READY, "Lock") & STAT_ERR)) {
597 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_DOORLOCK);
598 pd_wait_for(disk, STAT_READY, "Lock done");
603 static enum action pd_door_unlock(struct pd_unit *disk)
605 if (!(pd_wait_for(disk, STAT_READY, "Lock") & STAT_ERR)) {
606 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_DOORUNLOCK);
607 pd_wait_for(disk, STAT_READY, "Lock done");
612 static enum action pd_eject(struct pd_unit *disk)
614 pd_wait_for(disk, 0, DBMSG("before unlock on eject"));
615 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_DOORUNLOCK);
616 pd_wait_for(disk, 0, DBMSG("after unlock on eject"));
617 pd_wait_for(disk, 0, DBMSG("before eject"));
618 pd_send_command(disk, 0, 0, 0, 0, 0, IDE_EJECT);
619 pd_wait_for(disk, 0, DBMSG("after eject"));
623 static enum action pd_media_check(struct pd_unit *disk)
625 int r = pd_wait_for(disk, STAT_READY, DBMSG("before media_check"));
627 pd_send_command(disk, 1, 1, 0, 0, 0, IDE_READ_VRFY);
628 r = pd_wait_for(disk, STAT_READY, DBMSG("RDY after READ_VRFY"));
630 disk->changed = 1; /* say changed if other error */
632 disk->changed = 1;
633 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_ACKCHANGE);
634 pd_wait_for(disk, STAT_READY, DBMSG("RDY after ACKCHANGE"));
635 pd_send_command(disk, 1, 1, 0, 0, 0, IDE_READ_VRFY);
636 r = pd_wait_for(disk, STAT_READY, DBMSG("RDY after VRFY"));
641 static void pd_standby_off(struct pd_unit *disk)
643 pd_wait_for(disk, 0, DBMSG("before STANDBY"));
644 pd_send_command(disk, 0, 0, 0, 0, 0, IDE_STANDBY);
645 pd_wait_for(disk, 0, DBMSG("after STANDBY"));
648 static enum action pd_identify(struct pd_unit *disk)
659 if (disk->drive == 0)
660 pd_reset(disk);
662 write_reg(disk, 6, DRIVE(disk));
663 pd_wait_for(disk, 0, DBMSG("before IDENT"));
664 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_IDENTIFY);
666 if (pd_wait_for(disk, STAT_DRQ, DBMSG("IDENT DRQ")) & STAT_ERR)
668 pi_read_block(disk->pi, pd_scratch, 512);
669 disk->can_lba = pd_scratch[99] & 2;
670 disk->sectors = le16_to_cpu(*(__le16 *) (pd_scratch + 12));
671 disk->heads = le16_to_cpu(*(__le16 *) (pd_scratch + 6));
672 disk->cylinders = le16_to_cpu(*(__le16 *) (pd_scratch + 2));
673 if (disk->can_lba)
674 disk->capacity = le32_to_cpu(*(__le32 *) (pd_scratch + 120));
676 disk->capacity = disk->sectors * disk->heads * disk->cylinders;
686 disk->removable = pd_scratch[0] & 0x80;
689 disk->name, id,
690 disk->drive ? "slave" : "master",
691 disk->capacity, disk->capacity / 2048,
692 disk->cylinders, disk->heads, disk->sectors,
693 disk->removable ? "removable" : "fixed");
695 if (disk->capacity)
696 pd_init_dev_parms(disk);
697 if (!disk->standby)
698 pd_standby_off(disk);
716 static int pd_special_command(struct pd_unit *disk,
717 enum action (*func)(struct pd_unit *disk))
722 rq = blk_get_request(disk->gd->queue, READ, __GFP_WAIT);
727 err = blk_execute_rq(disk->gd->queue, disk->gd, rq, 0);
737 struct pd_unit *disk = bdev->bd_disk->private_data;
740 disk->access++;
742 if (disk->removable) {
743 pd_special_command(disk, pd_media_check);
744 pd_special_command(disk, pd_door_lock);
752 struct pd_unit *disk = bdev->bd_disk->private_data;
754 if (disk->alt_geom) {
757 geo->cylinders = disk->capacity / (geo->heads * geo->sectors);
759 geo->heads = disk->heads;
760 geo->sectors = disk->sectors;
761 geo->cylinders = disk->cylinders;
770 struct pd_unit *disk = bdev->bd_disk->private_data;
775 if (disk->access == 1)
776 pd_special_command(disk, pd_eject);
786 struct pd_unit *disk = p->private_data;
789 if (!--disk->access && disk->removable)
790 pd_special_command(disk, pd_door_unlock);
798 struct pd_unit *disk = p->private_data;
800 if (!disk->removable)
802 pd_special_command(disk, pd_media_check);
803 r = disk->changed;
804 disk->changed = 0;
810 struct pd_unit *disk = p->private_data;
811 if (pd_special_command(disk, pd_identify) == 0)
812 set_capacity(p, disk->capacity);
830 static void pd_probe_drive(struct pd_unit *disk)
835 strcpy(p->disk_name, disk->name);
838 p->first_minor = (disk - pd) << PD_BITS;
839 disk->gd = p;
840 p->private_data = disk;
843 if (disk->drive == -1) {
844 for (disk->drive = 0; disk->drive <= 1; disk->drive++)
845 if (pd_special_command(disk, pd_identify) == 0)
847 } else if (pd_special_command(disk, pd_identify) == 0)
849 disk->gd = NULL;
856 struct pd_unit *disk;
860 struct pd_unit *disk = pd + unit;
861 disk->pi = &disk->pia;
862 disk->access = 0;
863 disk->changed = 1;
864 disk->capacity = 0;
865 disk->drive = parm[D_SLV];
866 snprintf(disk->name, PD_NAMELEN, "%s%c", name, 'a'+unit);
867 disk->alt_geom = parm[D_GEO];
868 disk->standby = parm[D_SBY];
874 disk = pd;
875 if (pi_init(disk->pi, 1, -1, -1, -1, -1, -1, pd_scratch,
876 PI_PD, verbose, disk->name)) {
877 pd_probe_drive(disk);
878 if (!disk->gd)
879 pi_release(disk->pi);
883 for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) {
887 if (pi_init(disk->pi, 0, parm[D_PRT], parm[D_MOD],
889 pd_scratch, PI_PD, verbose, disk->name)) {
890 pd_probe_drive(disk);
891 if (!disk->gd)
892 pi_release(disk->pi);
896 for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) {
897 if (disk->gd) {
898 set_capacity(disk->gd, disk->capacity);
899 add_disk(disk->gd);
939 struct pd_unit *disk;
942 for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) {
943 struct gendisk *p = disk->gd;
945 disk->gd = NULL;
948 pi_release(disk->pi);