linux/drivers/staging/rts5208/rtsx_scsi.h

/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Driver for Realtek PCI-Express card reader
 *
 * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
 *
 * Author:
 *   Wei WANG ([email protected])
 *   Micky Ching ([email protected])
 */

#ifndef __REALTEK_RTSX_SCSI_H
#define __REALTEK_RTSX_SCSI_H

#include "rtsx.h"
#include "rtsx_chip.h"

#define MS_SP_CMND
#define MS_FORMAT
#define GET_MS_INFORMATION

#define VENDOR_CMND

#define READ_STATUS

#define READ_EEPROM
#define WRITE_EEPROM
#define READ_MEM
#define WRITE_MEM
#define GET_BUS_WIDTH
#define GET_SD_CSD
#define TOGGLE_GPIO
#define TRACE_MSG

#define SCSI_APP_CMD

#define PP_READ10
#define PP_WRITE10
#define READ_HOST_REG
#define WRITE_HOST_REG
#define SET_VAR
#define GET_VAR
#define DMA_READ
#define DMA_WRITE
#define GET_DEV_STATUS
#define SET_CHIP_MODE
#define SUIT_CMD
#define WRITE_PHY
#define READ_PHY
#define WRITE_EEPROM2
#define READ_EEPROM2
#define ERASE_EEPROM2
#define WRITE_EFUSE
#define READ_EFUSE
#define WRITE_CFG
#define READ_CFG

#define SPI_VENDOR_COMMAND

#define SCSI_SPI_GETSTATUS
#define SCSI_SPI_SETPARAMETER
#define SCSI_SPI_READFALSHID
#define SCSI_SPI_READFLASH
#define SCSI_SPI_WRITEFLASH
#define SCSI_SPI_WRITEFLASHSTATUS
#define SCSI_SPI_ERASEFLASH

#define INIT_BATCHCMD
#define ADD_BATCHCMD
#define SEND_BATCHCMD
#define GET_BATCHRSP

#define CHIP_NORMALMODE
#define CHIP_DEBUGMODE

/* SD Pass Through Command Extension */
#define SD_PASS_THRU_MODE
#define SD_EXECUTE_NO_DATA
#define SD_EXECUTE_READ
#define SD_EXECUTE_WRITE
#define SD_GET_RSP
#define SD_HW_RST

#ifdef SUPPORT_MAGIC_GATE
#define CMD_MSPRO_MG_RKEY
#define CMD_MSPRO_MG_SKEY

/* CBWCB field: key class */
#define KC_MG_R_PRO

/* CBWCB field: key format */
#define KF_SET_LEAF_ID
#define KF_GET_LOC_EKB
#define KF_CHG_HOST
#define KF_RSP_CHG
#define KF_RSP_HOST
#define KF_GET_ICV
#define KF_SET_ICV
#endif

/* Sense type */
#define SENSE_TYPE_NO_SENSE
#define SENSE_TYPE_MEDIA_CHANGE
#define SENSE_TYPE_MEDIA_NOT_PRESENT
#define SENSE_TYPE_MEDIA_LBA_OVER_RANGE
#define SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT
#define SENSE_TYPE_MEDIA_WRITE_PROTECT
#define SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
#define SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR
#define SENSE_TYPE_MEDIA_WRITE_ERR
#define SENSE_TYPE_FORMAT_IN_PROGRESS
#define SENSE_TYPE_FORMAT_CMD_FAILED
#ifdef SUPPORT_MAGIC_GATE
#define SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB
#define SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN
#define SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM
#define SENSE_TYPE_MG_WRITE_ERR
#endif
#ifdef SUPPORT_SD_LOCK
/* FOR Locked SD card*/
#define SENSE_TYPE_MEDIA_READ_FORBIDDEN
#endif

void scsi_show_command(struct rtsx_chip *chip);
void set_sense_type(struct rtsx_chip *chip, unsigned int lun, int sense_type);
void set_sense_data(struct rtsx_chip *chip, unsigned int lun, u8 err_code,
		    u8 sense_key, u32 info, u8 asc, u8 ascq,
		    u8 sns_key_info0, u16 sns_key_info1);
int rtsx_scsi_handler(struct scsi_cmnd *srb, struct rtsx_chip *chip);

#endif   /* __REALTEK_RTSX_SCSI_H */