Lines Matching +full:sense +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0-or-later
16 #include <linux/dma-mapping.h>
19 #include <linux/blk-mq.h>
79 {UNIT_ATTENTION, "Device needs attention - disk may have been changed"},
158 * been hit by a serious failure - but we'll in gdrom_identifydevice()
159 * try to return a sense key even so */ in gdrom_identifydevice()
232 return -ENOMEM; in gdrom_preparedisk_cmd()
233 spin_command->cmd[0] = 0x70; in gdrom_preparedisk_cmd()
234 spin_command->cmd[2] = 0x1f; in gdrom_preparedisk_cmd()
235 spin_command->buflen = 0; in gdrom_preparedisk_cmd()
246 return -EIO; in gdrom_preparedisk_cmd()
266 return -ENOMEM; in gdrom_readtoc_cmd()
268 toc_command->cmd[0] = 0x14; in gdrom_readtoc_cmd()
269 toc_command->cmd[1] = session; in gdrom_readtoc_cmd()
270 toc_command->cmd[3] = tocsize >> 8; in gdrom_readtoc_cmd()
271 toc_command->cmd[4] = tocsize & 0xff; in gdrom_readtoc_cmd()
272 toc_command->buflen = tocsize; in gdrom_readtoc_cmd()
274 err = -EBUSY; in gdrom_readtoc_cmd()
282 err = -EINVAL; in gdrom_readtoc_cmd()
287 err = -EINVAL; in gdrom_readtoc_cmd()
299 return (cpu_to_be32(track & 0xffffff00) - GD_SESSION_OFFSET); in get_entry_lba()
318 return -ENOMEM; in gdrom_get_last_session()
320 /* Check if GD-ROM */ in gdrom_get_last_session()
322 /* Not a GD-ROM so check if standard CD-ROM */ in gdrom_get_last_session()
327 return -ENXIO; in gdrom_get_last_session()
331 fentry = get_entry_track(gd.toc->first); in gdrom_get_last_session()
332 lentry = get_entry_track(gd.toc->last); in gdrom_get_last_session()
334 track = get_entry_track(gd.toc->last); in gdrom_get_last_session()
336 data = gd.toc->entry[track - 1]; in gdrom_get_last_session()
339 track--; in gdrom_get_last_session()
342 if ((track > 100) || (track < get_entry_track(gd.toc->first))) { in gdrom_get_last_session()
345 return -ENXIO; in gdrom_get_last_session()
348 ms_info->addr_format = CDROM_LBA; in gdrom_get_last_session()
349 ms_info->addr.lba = get_entry_lba(data); in gdrom_get_last_session()
350 ms_info->xa_flag = 1; in gdrom_get_last_session()
367 /* read the sense key */ in gdrom_drivestatus()
368 char sense = __raw_readb(GDROM_ERROR_REG); in gdrom_drivestatus() local
369 sense &= 0xF0; in gdrom_drivestatus()
370 if (sense == 0) in gdrom_drivestatus()
372 if (sense == 0x20) in gdrom_drivestatus()
381 /* check the sense key */ in gdrom_check_events()
397 * CD Rom specification - returning int */
401 gdrom_spicommand(&command->cmd, command->buflen); in gdrom_packetcommand()
405 /* Get Sense SPI command
414 short sense[5]; in gdrom_getsense() local
416 int err = -EIO; in gdrom_getsense()
420 return -ENOMEM; in gdrom_getsense()
421 sense_command->cmd[0] = 0x13; in gdrom_getsense()
422 sense_command->cmd[4] = 10; in gdrom_getsense()
423 sense_command->buflen = 10; in gdrom_getsense()
425 * the sense key if possible */ in gdrom_getsense()
427 err = -EBUSY; in gdrom_getsense()
436 insw(GDROM_DATA_REG, &sense, sense_command->buflen/2); in gdrom_getsense()
437 if (sense[1] & 40) { in gdrom_getsense()
438 pr_info("Drive not ready - command aborted\n"); in gdrom_getsense()
441 sense_key = sense[1] & 0x0F; in gdrom_getsense()
445 pr_err("Unknown sense key: %d\n", sense_key); in gdrom_getsense()
446 if (bufstring) /* return addional sense data */ in gdrom_getsense()
447 memcpy(bufstring, &sense[4], 2); in gdrom_getsense()
461 return -EINVAL; in gdrom_audio_ioctl()
477 static int gdrom_bdops_open(struct gendisk *disk, blk_mode_t mode) in gdrom_bdops_open() argument
484 ret = cdrom_open(gd.cd_info, mode); in gdrom_bdops_open()
502 static int gdrom_bdops_ioctl(struct block_device *bdev, blk_mode_t mode, in gdrom_bdops_ioctl() argument
561 * 0 -> 0x30
562 * 1 -> mode
563 * 2 -> block >> 16
564 * 3 -> block >> 8
565 * 4 -> block
566 * 8 -> sectors >> 16
567 * 9 -> sectors >> 8
568 * 10 -> sectors
581 read_command->cmd[0] = 0x30; in gdrom_readdisk_dma()
582 read_command->cmd[1] = 0x20; in gdrom_readdisk_dma()
585 __raw_writel(page_to_phys(bio_page(req->bio)) + bio_offset(req->bio), in gdrom_readdisk_dma()
590 read_command->cmd[2] = (block >> 16) & 0xFF; in gdrom_readdisk_dma()
591 read_command->cmd[3] = (block >> 8) & 0xFF; in gdrom_readdisk_dma()
592 read_command->cmd[4] = block & 0xFF; in gdrom_readdisk_dma()
593 read_command->cmd[8] = (block_cnt >> 16) & 0xFF; in gdrom_readdisk_dma()
594 read_command->cmd[9] = (block_cnt >> 8) & 0xFF; in gdrom_readdisk_dma()
595 read_command->cmd[10] = block_cnt & 0xFF; in gdrom_readdisk_dma()
615 outsw(GDROM_DATA_REG, &read_command->cmd, 6); in gdrom_readdisk_dma()
637 blk_mq_start_request(bd->rq); in gdrom_queue_rq()
639 switch (req_op(bd->rq)) { in gdrom_queue_rq()
641 return gdrom_readdisk_dma(bd->rq); in gdrom_queue_rq()
643 pr_notice("Read only device - write request ignored\n"); in gdrom_queue_rq()
646 printk(KERN_DEBUG "gdrom: Non-fs request ignored\n"); in gdrom_queue_rq()
656 int err = -ENOMEM; in gdrom_outputversion()
663 model_name = kstrndup(id->modname, 16, GFP_KERNEL); in gdrom_outputversion()
666 manuf_name = kstrndup(id->mname, 16, GFP_KERNEL); in gdrom_outputversion()
669 firmw_ver = kstrndup(id->firmver, 16, GFP_KERNEL); in gdrom_outputversion()
685 /* set the default mode for DMA transfer */
691 return -EBUSY; in gdrom_init_dma_mode()
694 return -EBUSY; in gdrom_init_dma_mode()
696 * Bits 31 - 16 security: 0x8843 in gdrom_init_dma_mode()
698 * Bits 14 - 8 start of transfer range in 1 MB blocks OR'ed with 0x80 in gdrom_init_dma_mode()
699 * Bits 6 - 0 end of transfer range in 1 MB blocks OR'ed with 0x80 in gdrom_init_dma_mode()
709 gd.cd_info->ops = &gdrom_ops; in probe_gdrom_setupcd()
710 gd.cd_info->capacity = 1; in probe_gdrom_setupcd()
711 strcpy(gd.cd_info->name, GDROM_DEV_NAME); in probe_gdrom_setupcd()
712 gd.cd_info->mask = CDC_CLOSE_TRAY|CDC_OPEN_TRAY|CDC_LOCK| in probe_gdrom_setupcd()
718 gd.disk->major = gdrom_major; in probe_gdrom_setupdisk()
719 gd.disk->first_minor = 1; in probe_gdrom_setupdisk()
720 gd.disk->minors = 1; in probe_gdrom_setupdisk()
721 gd.disk->flags |= GENHD_FL_NO_PART; in probe_gdrom_setupdisk()
722 strcpy(gd.disk->disk_name, GDROM_DEV_NAME); in probe_gdrom_setupdisk()
727 gd.disk->queue = gd.gdrom_rq; in probe_gdrom_setupqueue()
760 return -ENODEV; in probe_gdrom()
764 return -ENOMEM; in probe_gdrom()
774 err = -ENOMEM; in probe_gdrom()
789 gd.gdrom_rq = gd.disk->queue; in probe_gdrom()
792 err = -ENODEV; in probe_gdrom()
795 gd.disk->fops = &gdrom_bdops; in probe_gdrom()
796 gd.disk->events = DISK_EVENT_MEDIA_CHANGE; in probe_gdrom()
808 err = -ENOMEM; in probe_gdrom()
831 pr_warn("Probe failed - error is 0x%X\n", err); in probe_gdrom()
863 pd = platform_device_register_simple(GDROM_DEV_NAME, -1, NULL, 0); in init_gdrom()
880 MODULE_DESCRIPTION("SEGA Dreamcast GD-ROM Driver");