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

1 // SPDX-License-Identifier: GPL-2.0-or-later
16 #include <linux/dma-mapping.h>
20 #include <linux/blk-mq.h>
80 {UNIT_ATTENTION, "Device needs attention - disk may have been changed"},
159 * been hit by a serious failure - but we'll in gdrom_identifydevice()
160 * try to return a sense key even so */ in gdrom_identifydevice()
233 return -ENOMEM; in gdrom_preparedisk_cmd()
234 spin_command->cmd[0] = 0x70; in gdrom_preparedisk_cmd()
235 spin_command->cmd[2] = 0x1f; in gdrom_preparedisk_cmd()
236 spin_command->buflen = 0; in gdrom_preparedisk_cmd()
247 return -EIO; in gdrom_preparedisk_cmd()
267 return -ENOMEM; in gdrom_readtoc_cmd()
269 toc_command->cmd[0] = 0x14; in gdrom_readtoc_cmd()
270 toc_command->cmd[1] = session; in gdrom_readtoc_cmd()
271 toc_command->cmd[3] = tocsize >> 8; in gdrom_readtoc_cmd()
272 toc_command->cmd[4] = tocsize & 0xff; in gdrom_readtoc_cmd()
273 toc_command->buflen = tocsize; in gdrom_readtoc_cmd()
275 err = -EBUSY; in gdrom_readtoc_cmd()
283 err = -EINVAL; in gdrom_readtoc_cmd()
288 err = -EINVAL; in gdrom_readtoc_cmd()
300 return (cpu_to_be32(track & 0xffffff00) - GD_SESSION_OFFSET); in get_entry_lba()
319 return -ENOMEM; in gdrom_get_last_session()
321 /* Check if GD-ROM */ in gdrom_get_last_session()
323 /* Not a GD-ROM so check if standard CD-ROM */ in gdrom_get_last_session()
328 return -ENXIO; in gdrom_get_last_session()
332 fentry = get_entry_track(gd.toc->first); in gdrom_get_last_session()
333 lentry = get_entry_track(gd.toc->last); in gdrom_get_last_session()
335 track = get_entry_track(gd.toc->last); in gdrom_get_last_session()
337 data = gd.toc->entry[track - 1]; in gdrom_get_last_session()
340 track--; in gdrom_get_last_session()
343 if ((track > 100) || (track < get_entry_track(gd.toc->first))) { in gdrom_get_last_session()
346 return -ENXIO; in gdrom_get_last_session()
349 ms_info->addr_format = CDROM_LBA; in gdrom_get_last_session()
350 ms_info->addr.lba = get_entry_lba(data); in gdrom_get_last_session()
351 ms_info->xa_flag = 1; in gdrom_get_last_session()
368 /* read the sense key */ in gdrom_drivestatus()
369 char sense = __raw_readb(GDROM_ERROR_REG); in gdrom_drivestatus() local
370 sense &= 0xF0; in gdrom_drivestatus()
371 if (sense == 0) in gdrom_drivestatus()
373 if (sense == 0x20) in gdrom_drivestatus()
382 /* check the sense key */ in gdrom_check_events()
398 * CD Rom specification - returning int */
402 gdrom_spicommand(&command->cmd, command->buflen); in gdrom_packetcommand()
406 /* Get Sense SPI command
415 short sense[5]; in gdrom_getsense() local
417 int err = -EIO; in gdrom_getsense()
421 return -ENOMEM; in gdrom_getsense()
422 sense_command->cmd[0] = 0x13; in gdrom_getsense()
423 sense_command->cmd[4] = 10; in gdrom_getsense()
424 sense_command->buflen = 10; in gdrom_getsense()
426 * the sense key if possible */ in gdrom_getsense()
428 err = -EBUSY; in gdrom_getsense()
437 insw(GDROM_DATA_REG, &sense, sense_command->buflen/2); in gdrom_getsense()
438 if (sense[1] & 40) { in gdrom_getsense()
439 pr_info("Drive not ready - command aborted\n"); in gdrom_getsense()
442 sense_key = sense[1] & 0x0F; in gdrom_getsense()
446 pr_err("Unknown sense key: %d\n", sense_key); in gdrom_getsense()
447 if (bufstring) /* return addional sense data */ in gdrom_getsense()
448 memcpy(bufstring, &sense[4], 2); in gdrom_getsense()
462 return -EINVAL; in gdrom_audio_ioctl()
478 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode) in gdrom_bdops_open() argument
485 ret = cdrom_open(gd.cd_info, bdev, mode); in gdrom_bdops_open()
490 static void gdrom_bdops_release(struct gendisk *disk, fmode_t mode) in gdrom_bdops_release() argument
493 cdrom_release(gd.cd_info, mode); in gdrom_bdops_release()
503 static int gdrom_bdops_ioctl(struct block_device *bdev, fmode_t mode, in gdrom_bdops_ioctl() argument
509 ret = cdrom_ioctl(gd.cd_info, bdev, mode, cmd, arg); in gdrom_bdops_ioctl()
562 * 0 -> 0x30
563 * 1 -> mode
564 * 2 -> block >> 16
565 * 3 -> block >> 8
566 * 4 -> block
567 * 8 -> sectors >> 16
568 * 9 -> sectors >> 8
569 * 10 -> sectors
582 read_command->cmd[0] = 0x30; in gdrom_readdisk_dma()
583 read_command->cmd[1] = 0x20; in gdrom_readdisk_dma()
586 __raw_writel(virt_to_phys(bio_data(req->bio)), GDROM_DMA_STARTADDR_REG); 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 strcpy(gd.disk->disk_name, GDROM_DEV_NAME); in probe_gdrom_setupdisk()
731 gd.disk->queue = gd.gdrom_rq; in probe_gdrom_setupqueue()
749 return -ENODEV; in probe_gdrom()
753 return -ENOMEM; in probe_gdrom()
763 err = -ENOMEM; in probe_gdrom()
769 err = -ENODEV; in probe_gdrom()
774 err = -ENODEV; in probe_gdrom()
777 gd.disk->fops = &gdrom_bdops; in probe_gdrom()
778 gd.disk->events = DISK_EVENT_MEDIA_CHANGE; in probe_gdrom()
800 err = -ENOMEM; in probe_gdrom()
820 pr_warn("Probe failed - error is 0x%X\n", err); in probe_gdrom()
853 pd = platform_device_register_simple(GDROM_DEV_NAME, -1, NULL, 0); in init_gdrom()
872 MODULE_DESCRIPTION("SEGA Dreamcast GD-ROM Driver");