linux/drivers/staging/rts5208/ms.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_MS_H
#define __REALTEK_RTSX_MS_H

#define MS_DELAY_WRITE

#define MS_MAX_RETRY_COUNT

#define MS_EXTRA_SIZE

#define WRT_PRTCT

/* Error Code */
#define MS_NO_ERROR
#define MS_CRC16_ERROR
#define MS_TO_ERROR
#define MS_NO_CARD
#define MS_NO_MEMORY
#define MS_CMD_NK
#define MS_FLASH_READ_ERROR
#define MS_FLASH_WRITE_ERROR
#define MS_BREQ_ERROR
#define MS_NOT_FOUND

/* Transfer Protocol Command */
#define READ_PAGE_DATA
#define READ_REG
#define GET_INT
#define WRITE_PAGE_DATA
#define WRITE_REG
#define SET_RW_REG_ADRS
#define SET_CMD

#define PRO_READ_LONG_DATA
#define PRO_READ_SHORT_DATA
#define PRO_READ_REG
#define PRO_READ_QUAD_DATA
#define PRO_GET_INT
#define PRO_WRITE_LONG_DATA
#define PRO_WRITE_SHORT_DATA
#define PRO_WRITE_QUAD_DATA
#define PRO_WRITE_REG
#define PRO_SET_RW_REG_ADRS
#define PRO_SET_CMD
#define PRO_EX_SET_CMD

#ifdef SUPPORT_MAGIC_GATE

#define MG_GET_ID
#define MG_SET_LID
#define MG_GET_LEKB
#define MG_SET_RD
#define MG_MAKE_RMS
#define MG_MAKE_KSE
#define MG_SET_IBD
#define MG_GET_IBD

#endif

#ifdef XC_POWERCLASS
#define XC_CHG_POWER
#endif

#define BLOCK_READ
#define BLOCK_WRITE
#define BLOCK_END
#define BLOCK_ERASE
#define FLASH_STOP

#define SLEEP
#define CLEAR_BUF
#define MS_RESET

#define PRO_READ_DATA
#define PRO_WRITE_DATA
#define PRO_READ_ATRB
#define PRO_STOP
#define PRO_ERASE
#define PRO_READ_2K_DATA
#define PRO_WRITE_2K_DATA

#define PRO_FORMAT
#define PRO_SLEEP

#define INT_REG
#define STATUS_REG0
#define STATUS_REG1

#define SYSTEM_PARAM
#define BLOCK_ADRS
#define CMD_PARM
#define PAGE_ADRS

#define OVERWRITE_FLAG
#define MANAGEMEN_FLAG
#define LOGICAL_ADRS
#define RESERVE_AREA

#define PRO_INT_REG
#define PRO_STATUS_REG
#define PRO_TYPE_REG
#define PRO_IF_mode_REG
#define PRO_CATEGORY_REG
#define PRO_CLASS_REG

#define PRO_SYSTEM_PARAM
#define PRO_DATA_COUNT1
#define PRO_DATA_COUNT0
#define PRO_DATA_ADDR3
#define PRO_DATA_ADDR2
#define PRO_DATA_ADDR1
#define PRO_DATA_ADDR0

#define PRO_TPC_PARM
#define PRO_CMD_PARM

#define INT_REG_CED
#define INT_REG_ERR
#define INT_REG_BREQ
#define INT_REG_CMDNK

#define BLOCK_BOOT
#define BLOCK_OK
#define PAGE_OK
#define DATA_COMPL

#define NOT_BOOT_BLOCK
#define NOT_TRANSLATION_TABLE

#define HEADER_ID0
#define HEADER_ID1
#define DISABLED_BLOCK0
#define DISABLED_BLOCK1
#define DISABLED_BLOCK2
#define DISABLED_BLOCK3
#define BLOCK_SIZE_0
#define BLOCK_SIZE_1
#define BLOCK_COUNT_0
#define BLOCK_COUNT_1
#define EBLOCK_COUNT_0
#define EBLOCK_COUNT_1
#define PAGE_SIZE_0
#define PAGE_SIZE_1

#define MS_device_type

#define MS_4bit_support

#define set_PS_NG
#define set_PS_error

#define PARALLEL_8BIT_IF
#define PARALLEL_4BIT_IF
#define SERIAL_IF

#define BUF_FULL
#define BUF_EMPTY

#define MEDIA_BUSY
#define FLASH_BUSY
#define DATA_ERROR
#define STS_UCDT
#define EXTRA_ERROR
#define STS_UCEX
#define FLAG_ERROR
#define STS_UCFG

#define MS_SHORT_DATA_LEN

#define FORMAT_SUCCESS
#define FORMAT_FAIL
#define FORMAT_IN_PROGRESS

#define MS_SET_BAD_BLOCK_FLG(ms_card)
#define MS_CLR_BAD_BLOCK_FLG(ms_card)
#define MS_TST_BAD_BLOCK_FLG(ms_card)

void mspro_polling_format_status(struct rtsx_chip *chip);

void mspro_stop_seq_mode(struct rtsx_chip *chip);
int reset_ms_card(struct rtsx_chip *chip);
int ms_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
	  u32 start_sector, u16 sector_cnt);
int mspro_format(struct scsi_cmnd *srb, struct rtsx_chip *chip,
		 int short_data_len, bool quick_format);
void ms_free_l2p_tbl(struct rtsx_chip *chip);
void ms_cleanup_work(struct rtsx_chip *chip);
int ms_power_off_card3v3(struct rtsx_chip *chip);
int release_ms_card(struct rtsx_chip *chip);
#ifdef MS_DELAY_WRITE
int ms_delay_write(struct rtsx_chip *chip);
#endif

#ifdef SUPPORT_MAGIC_GATE
int mg_set_leaf_id(struct scsi_cmnd *srb, struct rtsx_chip *chip);
int mg_get_local_EKB(struct scsi_cmnd *srb, struct rtsx_chip *chip);
int mg_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip);
int mg_get_rsp_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip);
int mg_rsp(struct scsi_cmnd *srb, struct rtsx_chip *chip);
int mg_get_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip);
int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip);
#endif

#endif  /* __REALTEK_RTSX_MS_H */