cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

rtsx_scsi.h (3709B)


      1/* SPDX-License-Identifier: GPL-2.0+ */
      2/*
      3 * Driver for Realtek PCI-Express card reader
      4 *
      5 * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
      6 *
      7 * Author:
      8 *   Wei WANG (wei_wang@realsil.com.cn)
      9 *   Micky Ching (micky_ching@realsil.com.cn)
     10 */
     11
     12#ifndef __REALTEK_RTSX_SCSI_H
     13#define __REALTEK_RTSX_SCSI_H
     14
     15#include "rtsx.h"
     16#include "rtsx_chip.h"
     17
     18#define MS_SP_CMND		0xFA
     19#define MS_FORMAT		0xA0
     20#define GET_MS_INFORMATION	0xB0
     21
     22#define VENDOR_CMND		0xF0
     23
     24#define READ_STATUS		0x09
     25
     26#define READ_EEPROM		0x04
     27#define WRITE_EEPROM		0x05
     28#define READ_MEM		0x0D
     29#define WRITE_MEM		0x0E
     30#define GET_BUS_WIDTH		0x13
     31#define GET_SD_CSD		0x14
     32#define TOGGLE_GPIO		0x15
     33#define TRACE_MSG		0x18
     34
     35#define SCSI_APP_CMD		0x10
     36
     37#define PP_READ10		0x1A
     38#define PP_WRITE10		0x0A
     39#define READ_HOST_REG		0x1D
     40#define WRITE_HOST_REG		0x0D
     41#define SET_VAR			0x05
     42#define GET_VAR			0x15
     43#define DMA_READ		0x16
     44#define DMA_WRITE		0x06
     45#define GET_DEV_STATUS		0x10
     46#define SET_CHIP_MODE		0x27
     47#define SUIT_CMD		0xE0
     48#define WRITE_PHY		0x07
     49#define READ_PHY		0x17
     50#define WRITE_EEPROM2		0x03
     51#define READ_EEPROM2		0x13
     52#define ERASE_EEPROM2		0x23
     53#define WRITE_EFUSE		0x04
     54#define READ_EFUSE		0x14
     55#define WRITE_CFG		0x0E
     56#define READ_CFG		0x1E
     57
     58#define SPI_VENDOR_COMMAND		0x1C
     59
     60#define	SCSI_SPI_GETSTATUS		0x00
     61#define	SCSI_SPI_SETPARAMETER		0x01
     62#define	SCSI_SPI_READFALSHID		0x02
     63#define	SCSI_SPI_READFLASH		0x03
     64#define	SCSI_SPI_WRITEFLASH		0x04
     65#define	SCSI_SPI_WRITEFLASHSTATUS	0x05
     66#define	SCSI_SPI_ERASEFLASH		0x06
     67
     68#define INIT_BATCHCMD		0x41
     69#define ADD_BATCHCMD		0x42
     70#define SEND_BATCHCMD		0x43
     71#define GET_BATCHRSP		0x44
     72
     73#define CHIP_NORMALMODE		0x00
     74#define CHIP_DEBUGMODE		0x01
     75
     76/* SD Pass Through Command Extension */
     77#define SD_PASS_THRU_MODE	0xD0
     78#define SD_EXECUTE_NO_DATA	0xD1
     79#define SD_EXECUTE_READ		0xD2
     80#define SD_EXECUTE_WRITE	0xD3
     81#define SD_GET_RSP		0xD4
     82#define SD_HW_RST		0xD6
     83
     84#ifdef SUPPORT_MAGIC_GATE
     85#define CMD_MSPRO_MG_RKEY	0xA4   /* Report Key Command */
     86#define CMD_MSPRO_MG_SKEY	0xA3   /* Send Key Command */
     87
     88/* CBWCB field: key class */
     89#define KC_MG_R_PRO		0xBE   /* MG-R PRO*/
     90
     91/* CBWCB field: key format */
     92#define KF_SET_LEAF_ID		0x31   /* Set Leaf ID */
     93#define KF_GET_LOC_EKB		0x32   /* Get Local EKB */
     94#define KF_CHG_HOST		0x33   /* Challenge (host) */
     95#define KF_RSP_CHG		0x34   /* Response and Challenge (device)  */
     96#define KF_RSP_HOST		0x35   /* Response (host) */
     97#define KF_GET_ICV		0x36   /* Get ICV */
     98#define KF_SET_ICV		0x37   /* SSet ICV */
     99#endif
    100
    101/* Sense type */
    102#define	SENSE_TYPE_NO_SENSE				0
    103#define	SENSE_TYPE_MEDIA_CHANGE				1
    104#define	SENSE_TYPE_MEDIA_NOT_PRESENT			2
    105#define	SENSE_TYPE_MEDIA_LBA_OVER_RANGE			3
    106#define	SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT		4
    107#define	SENSE_TYPE_MEDIA_WRITE_PROTECT			5
    108#define	SENSE_TYPE_MEDIA_INVALID_CMD_FIELD		6
    109#define	SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR		7
    110#define	SENSE_TYPE_MEDIA_WRITE_ERR			8
    111#define SENSE_TYPE_FORMAT_IN_PROGRESS			9
    112#define SENSE_TYPE_FORMAT_CMD_FAILED			10
    113#ifdef SUPPORT_MAGIC_GATE
    114#define SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB		0x0b
    115#define SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN		0x0c
    116#define SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM		0x0d
    117#define SENSE_TYPE_MG_WRITE_ERR				0x0e
    118#endif
    119#ifdef SUPPORT_SD_LOCK
    120/* FOR Locked SD card*/
    121#define SENSE_TYPE_MEDIA_READ_FORBIDDEN			0x10
    122#endif
    123
    124void scsi_show_command(struct rtsx_chip *chip);
    125void set_sense_type(struct rtsx_chip *chip, unsigned int lun, int sense_type);
    126void set_sense_data(struct rtsx_chip *chip, unsigned int lun, u8 err_code,
    127		    u8 sense_key, u32 info, u8 asc, u8 ascq,
    128		    u8 sns_key_info0, u16 sns_key_info1);
    129int rtsx_scsi_handler(struct scsi_cmnd *srb, struct rtsx_chip *chip);
    130
    131#endif   /* __REALTEK_RTSX_SCSI_H */