linux/drivers/usb/storage/ene_ub6250.c

// SPDX-License-Identifier: GPL-2.0+
#include <linux/jiffies.h>
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/slab.h>

#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>

#include <linux/firmware.h>

#include "usb.h"
#include "transport.h"
#include "protocol.h"
#include "debug.h"
#include "scsiglue.h"

#define SD_INIT1_FIRMWARE
#define SD_INIT2_FIRMWARE
#define SD_RW_FIRMWARE
#define MS_INIT_FIRMWARE
#define MSP_RW_FIRMWARE
#define MS_RW_FIRMWARE

#define DRV_NAME

MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_IMPORT_NS();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();

/*
 * The table of devices
 */
#define UNUSUAL_DEV

static struct usb_device_id ene_ub6250_usb_ids[] =;
MODULE_DEVICE_TABLE(usb, ene_ub6250_usb_ids);

#undef UNUSUAL_DEV

/*
 * The flags table
 */
#define UNUSUAL_DEV

static struct us_unusual_dev ene_ub6250_unusual_dev_list[] =;

#undef UNUSUAL_DEV



/* ENE bin code len */
#define ENE_BIN_CODE_LEN
/* EnE HW Register */
#define REG_CARD_STATUS
#define REG_HW_TRAP1

/* SRB Status */
#define SS_SUCCESS
#define SS_NOT_READY
#define SS_MEDIUM_ERR
#define SS_HW_ERR
#define SS_ILLEGAL_REQUEST
#define SS_UNIT_ATTENTION

/* ENE Load FW Pattern */
#define SD_INIT1_PATTERN
#define SD_INIT2_PATTERN
#define SD_RW_PATTERN
#define MS_INIT_PATTERN
#define MSP_RW_PATTERN
#define MS_RW_PATTERN
#define SM_INIT_PATTERN
#define SM_RW_PATTERN

#define FDIR_WRITE
#define FDIR_READ

/* For MS Card */

/* Status Register 1 */
#define MS_REG_ST1_MB
#define MS_REG_ST1_FB1
#define MS_REG_ST1_DTER
#define MS_REG_ST1_UCDT
#define MS_REG_ST1_EXER
#define MS_REG_ST1_UCEX
#define MS_REG_ST1_FGER
#define MS_REG_ST1_UCFG
#define MS_REG_ST1_DEFAULT

/* Overwrite Area */
#define MS_REG_OVR_BKST
#define MS_REG_OVR_BKST_OK
#define MS_REG_OVR_BKST_NG
#define MS_REG_OVR_PGST0
#define MS_REG_OVR_PGST1
#define MS_REG_OVR_PGST_MASK
#define MS_REG_OVR_PGST_OK
#define MS_REG_OVR_PGST_NG
#define MS_REG_OVR_PGST_DATA_ERROR
#define MS_REG_OVR_UDST
#define MS_REG_OVR_UDST_UPDATING
#define MS_REG_OVR_UDST_NO_UPDATE
#define MS_REG_OVR_RESERVED
#define MS_REG_OVR_DEFAULT

/* Management Flag */
#define MS_REG_MNG_SCMS0
#define MS_REG_MNG_SCMS1
#define MS_REG_MNG_SCMS_MASK
#define MS_REG_MNG_SCMS_COPY_OK
#define MS_REG_MNG_SCMS_ONE_COPY
#define MS_REG_MNG_SCMS_NO_COPY
#define MS_REG_MNG_ATFLG
#define MS_REG_MNG_ATFLG_OTHER
#define MS_REG_MNG_ATFLG_ATTBL
#define MS_REG_MNG_SYSFLG
#define MS_REG_MNG_SYSFLG_USER
#define MS_REG_MNG_SYSFLG_BOOT
#define MS_REG_MNG_RESERVED
#define MS_REG_MNG_DEFAULT


#define MS_MAX_PAGES_PER_BLOCK
#define MS_MAX_INITIAL_ERROR_BLOCKS
#define MS_LIB_BITS_PER_BYTE

#define MS_SYSINF_FORMAT_FAT
#define MS_SYSINF_USAGE_GENERAL

#define MS_SYSINF_MSCLASS_TYPE_1
#define MS_SYSINF_PAGE_SIZE

#define MS_SYSINF_CARDTYPE_RDONLY
#define MS_SYSINF_CARDTYPE_RDWR
#define MS_SYSINF_CARDTYPE_HYBRID
#define MS_SYSINF_SECURITY
#define MS_SYSINF_SECURITY_NO_SUPPORT
#define MS_SYSINF_SECURITY_SUPPORT

#define MS_SYSINF_RESERVED1
#define MS_SYSINF_RESERVED2

#define MS_SYSENT_TYPE_INVALID_BLOCK
#define MS_SYSENT_TYPE_CIS_IDI

#define SIZE_OF_KIRO
#define BYTE_MASK

/* ms error code */
#define MS_STATUS_WRITE_PROTECT
#define MS_STATUS_SUCCESS
#define MS_ERROR_FLASH_READ
#define MS_ERROR_FLASH_ERASE
#define MS_LB_ERROR
#define MS_LB_BOOT_BLOCK
#define MS_LB_INITIAL_ERROR
#define MS_STATUS_SUCCESS_WITH_ECC
#define MS_LB_ACQUIRED_ERROR
#define MS_LB_NOT_USED_ERASED
#define MS_NOCARD_ERROR
#define MS_NO_MEMORY_ERROR
#define MS_STATUS_INT_ERROR
#define MS_STATUS_ERROR
#define MS_LB_NOT_USED

#define MS_REG_MNG_SYSFLG
#define MS_REG_MNG_SYSFLG_USER

#define MS_BOOT_BLOCK_ID
#define MS_BOOT_BLOCK_FORMAT_VERSION
#define MS_BOOT_BLOCK_DATA_ENTRIES

#define MS_NUMBER_OF_SYSTEM_ENTRY
#define MS_NUMBER_OF_BOOT_BLOCK
#define MS_BYTES_PER_PAGE
#define MS_LOGICAL_BLOCKS_PER_SEGMENT
#define MS_LOGICAL_BLOCKS_IN_1ST_SEGMENT

#define MS_PHYSICAL_BLOCKS_PER_SEGMENT
#define MS_PHYSICAL_BLOCKS_PER_SEGMENT_MASK

/* overwrite area */
#define MS_REG_OVR_BKST
#define MS_REG_OVR_BKST_OK
#define MS_REG_OVR_BKST_NG

/* Status Register 1 */
#define MS_REG_ST1_DTER
#define MS_REG_ST1_EXER
#define MS_REG_ST1_FGER

/* MemoryStick Register */
/* Status Register 0 */
#define MS_REG_ST0_WP
#define MS_REG_ST0_WP_ON

#define MS_LIB_CTRL_RDONLY
#define MS_LIB_CTRL_WRPROTECT

/*dphy->log table */
#define ms_libconv_to_logical(pdx, PhyBlock)
#define ms_libconv_to_physical(pdx, LogBlock)

#define ms_lib_ctrl_set(pdx, Flag)
#define ms_lib_ctrl_reset(pdx, Flag)
#define ms_lib_ctrl_check(pdx, Flag)

#define ms_lib_iswritable(pdx)
#define ms_lib_clear_pagemap(pdx)
#define memstick_logaddr(logadr1, logadr0)


/* SD_STATUS bits */
#define SD_Insert
#define SD_Ready
#define SD_MediaChange
#define SD_IsMMC
#define SD_HiCapacity
#define SD_HiSpeed
#define SD_WtP
			/* Bit 7 reserved */

/* MS_STATUS bits */
#define MS_Insert
#define MS_Ready
#define MS_MediaChange
#define MS_IsMSPro
#define MS_IsMSPHG
			/* Bit 5 reserved */
#define MS_WtP
			/* Bit 7 reserved */

/* SM_STATUS bits */
#define SM_Insert
#define SM_Ready
#define SM_MediaChange
			/* Bits 3-5 reserved */
#define SM_WtP
#define SM_IsMS

struct ms_bootblock_cis {} ;

struct ms_bootblock_idi {};

struct ms_bootblock_sysent_rec {};

struct ms_bootblock_sysent {};

struct ms_bootblock_sysinf {};

struct ms_bootblock_header {};

struct ms_bootblock_page0 {};

struct ms_bootblock_cis_idi {};

/* ENE MS Lib struct */
struct ms_lib_type_extdat {};

struct ms_lib_ctrl {};


/* SD Block Length */
/* 2^9 = 512 Bytes, The HW maximum read/write data length */
#define SD_BLOCK_LEN

struct ene_ub6250_info {};

static int ene_sd_init(struct us_data *us);
static int ene_ms_init(struct us_data *us);
static int ene_load_bincode(struct us_data *us, unsigned char flag);

static void ene_ub6250_info_destructor(void *extra)
{}

static int ene_send_scsi_cmd(struct us_data *us, u8 fDir, void *buf, int use_sg)
{}

static int do_scsi_request_sense(struct us_data *us, struct scsi_cmnd *srb)
{}

static int do_scsi_inquiry(struct us_data *us, struct scsi_cmnd *srb)
{}

static int sd_scsi_test_unit_ready(struct us_data *us, struct scsi_cmnd *srb)
{}

static int sd_scsi_mode_sense(struct us_data *us, struct scsi_cmnd *srb)
{}

static int sd_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb)
{}

static int sd_scsi_read(struct us_data *us, struct scsi_cmnd *srb)
{}

static int sd_scsi_write(struct us_data *us, struct scsi_cmnd *srb)
{}

/*
 * ENE MS Card
 */

static int ms_lib_set_logicalpair(struct us_data *us, u16 logblk, u16 phyblk)
{}

static int ms_lib_set_logicalblockmark(struct us_data *us, u16 phyblk, u16 mark)
{}

static int ms_lib_set_initialerrorblock(struct us_data *us, u16 phyblk)
{}

static int ms_lib_set_bootblockmark(struct us_data *us, u16 phyblk)
{}

static int ms_lib_free_logicalmap(struct us_data *us)
{}

static int ms_lib_alloc_logicalmap(struct us_data *us)
{}

static void ms_lib_clear_writebuf(struct us_data *us)
{}

static int ms_count_freeblock(struct us_data *us, u16 PhyBlock)
{}

static int ms_read_readpage(struct us_data *us, u32 PhyBlockAddr,
		u8 PageNum, u32 *PageBuf, struct ms_lib_type_extdat *ExtraDat)
{}

static int ms_lib_process_bootblock(struct us_data *us, u16 PhyBlock, u8 *PageData)
{}

static void ms_lib_free_writebuf(struct us_data *us)
{}


static void ms_lib_free_allocatedarea(struct us_data *us)
{}


static int ms_lib_alloc_writebuf(struct us_data *us)
{}

static int ms_lib_force_setlogical_pair(struct us_data *us, u16 logblk, u16 phyblk)
{}

static int ms_read_copyblock(struct us_data *us, u16 oldphy, u16 newphy,
			u16 PhyBlockAddr, u8 PageNum, unsigned char *buf, u16 len)
{}

static int ms_read_eraseblock(struct us_data *us, u32 PhyBlockAddr)
{}

static int ms_lib_check_disableblock(struct us_data *us, u16 PhyBlock)
{}

static int ms_lib_setacquired_errorblock(struct us_data *us, u16 phyblk)
{}

static int ms_lib_overwrite_extra(struct us_data *us, u32 PhyBlockAddr,
				u8 PageNum, u8 OverwriteFlag)
{}

static int ms_lib_error_phyblock(struct us_data *us, u16 phyblk)
{}

static int ms_lib_erase_phyblock(struct us_data *us, u16 phyblk)
{}

static int ms_lib_read_extra(struct us_data *us, u32 PhyBlock,
				u8 PageNum, struct ms_lib_type_extdat *ExtraDat)
{}

static int ms_libsearch_block_from_physical(struct us_data *us, u16 phyblk)
{}
static int ms_libsearch_block_from_logical(struct us_data *us, u16 logblk)
{}

static int ms_scsi_test_unit_ready(struct us_data *us, struct scsi_cmnd *srb)
{}

static int ms_scsi_mode_sense(struct us_data *us, struct scsi_cmnd *srb)
{}

static int ms_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb)
{}

static void ms_lib_phy_to_log_range(u16 PhyBlock, u16 *LogStart, u16 *LogEnde)
{}

static int ms_lib_read_extrablock(struct us_data *us, u32 PhyBlock,
	u8 PageNum, u8 blen, void *buf)
{}

static int ms_lib_scan_logicalblocknumber(struct us_data *us, u16 btBlk1st)
{}


static int ms_scsi_read(struct us_data *us, struct scsi_cmnd *srb)
{}

static int ms_scsi_write(struct us_data *us, struct scsi_cmnd *srb)
{}

/*
 * ENE MS Card
 */

static int ene_get_card_type(struct us_data *us, u16 index, void *buf)
{}

static int ene_get_card_status(struct us_data *us, u8 *buf)
{}

static int ene_load_bincode(struct us_data *us, unsigned char flag)
{}

static int ms_card_init(struct us_data *us)
{}

static int ene_ms_init(struct us_data *us)
{}

static int ene_sd_init(struct us_data *us)
{}


static int ene_init(struct us_data *us)
{}

/*----- sd_scsi_irp() ---------*/
static int sd_scsi_irp(struct us_data *us, struct scsi_cmnd *srb)
{}

/*
 * ms_scsi_irp()
 */
static int ms_scsi_irp(struct us_data *us, struct scsi_cmnd *srb)
{}

static int ene_transport(struct scsi_cmnd *srb, struct us_data *us)
{}

static struct scsi_host_template ene_ub6250_host_template;

static int ene_ub6250_probe(struct usb_interface *intf,
			 const struct usb_device_id *id)
{}


#ifdef CONFIG_PM

static int ene_ub6250_resume(struct usb_interface *iface)
{}

static int ene_ub6250_reset_resume(struct usb_interface *iface)
{}

#else

#define ene_ub6250_resume
#define ene_ub6250_reset_resume

#endif

static struct usb_driver ene_ub6250_driver =;

module_usb_stor_driver(ene_ub6250_driver, ene_ub6250_host_template, DRV_NAME);