00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef __hw_sd_h
00030 #define __hw_sd_h 1
00031
00032 #define OUT_OF_RANGE (1 << 31)
00033 #define ADDRESS_ERROR (1 << 30)
00034 #define BLOCK_LEN_ERROR (1 << 29)
00035 #define ERASE_SEQ_ERROR (1 << 28)
00036 #define ERASE_PARAM (1 << 27)
00037 #define WP_VIOLATION (1 << 26)
00038 #define CARD_IS_LOCKED (1 << 25)
00039 #define LOCK_UNLOCK_FAILED (1 << 24)
00040 #define COM_CRC_ERROR (1 << 23)
00041 #define ILLEGAL_COMMAND (1 << 22)
00042 #define CARD_ECC_FAILED (1 << 21)
00043 #define CC_ERROR (1 << 20)
00044 #define SD_ERROR (1 << 19)
00045 #define CID_CSD_OVERWRITE (1 << 16)
00046 #define WP_ERASE_SKIP (1 << 15)
00047 #define CARD_ECC_DISABLED (1 << 14)
00048 #define ERASE_RESET (1 << 13)
00049 #define CURRENT_STATE (7 << 9)
00050 #define READY_FOR_DATA (1 << 8)
00051 #define APP_CMD (1 << 5)
00052 #define AKE_SEQ_ERROR (1 << 3)
00053
00054 typedef enum {
00055 sd_none = -1,
00056 sd_bc = 0,
00057 sd_bcr,
00058 sd_ac,
00059 sd_adtc,
00060 } sd_cmd_type_t;
00061
00062 struct sd_request_s {
00063 uint8_t cmd;
00064 uint32_t arg;
00065 uint8_t crc;
00066 };
00067
00068 typedef struct SDState SDState;
00069
00070 SDState *sd_init(BlockDriverState *bs, int is_spi);
00071 int sd_do_command(SDState *sd, struct sd_request_s *req,
00072 uint8_t *response);
00073 void sd_write_data(SDState *sd, uint8_t value);
00074 uint8_t sd_read_data(SDState *sd);
00075 void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq insert);
00076 int sd_data_ready(SDState *sd);
00077 void sd_enable(SDState *sd, int enable);
00078
00079
00080 int ssi_sd_xfer(void *opaque, int val);
00081 void *ssi_sd_init(BlockDriverState *bs);
00082
00083 #endif