version 1.2, 2007/12/20 15:23:15 |
version 1.4, 2007/12/25 14:08:10 |
|
|
#ifndef _DEV_SDMMC_SDMMCVAR_H |
#ifndef _DEV_SDMMC_SDMMCVAR_H |
#define _DEV_SDMMC_SDMMCVAR_H |
#define _DEV_SDMMC_SDMMCVAR_H |
|
|
|
#define SDMMC_BLOCK_SIZE 512 |
|
|
/* |
/* |
* SD/MMC simplified commands set. |
* SD/MMC simplified commands set. |
*/ |
*/ |
|
|
|
|
|
|
/* |
/* |
|
* Tokens. |
|
*/ |
|
#define TOK_READ_BLOCK 0xfe |
|
#define TOK_READ_BLOCK_MULTIPLE 0xfe |
|
#define TOK_WRITE_BLOCK 0xfe |
|
#define TOK_WRITE_BLOCK_MULTIPLE 0xfc |
|
#define TOK_STOP_MULTIPLE 0xfd |
|
|
|
|
|
/* |
* Read Error Token bits. |
* Read Error Token bits. |
*/ |
*/ |
#define RE_UNSPECIFIED_ERROR 0x01 |
#define RE_UNSPECIFIED_ERROR 0x01 |
|
|
#define RE_CARD_LOCKED 0x10 |
#define RE_CARD_LOCKED 0x10 |
|
|
/* |
/* |
|
* Card CID (Card ID) register. |
|
*/ |
|
struct sdmmc_cid { |
|
uint8_t cid_mid; |
|
uint16_t cid_oid; |
|
uint8_t cid_pnm[5]; |
|
uint8_t cid_prv; |
|
uint32_t cid_psn; |
|
uint16_t cid_mdt; |
|
uint8_t cid_crc; |
|
|
|
} __attribute__((packed)); |
|
|
|
/* |
* SD/MMC bus handle. |
* SD/MMC bus handle. |
*/ |
*/ |
struct sdmmc_bus_handle { |
struct sdmmc_bus_handle { |
void (*sb_send_command)(void *dd, uint8_t cmd, uint32_t arg); |
uint8_t (*sb_init)(void *dd); |
uint8_t (*sb_get_response)(void *dd); |
uint8_t (*sb_send_command)(void *dd, uint8_t cmd, uint32_t arg, uint8_t crc); |
uint8_t (*sb_get_spec_response)(void *dd, uint8_t response); |
uint8_t (*sb_set_block_size)(void *dd, uint16_t size); |
uint8_t (*sb_read_register)(void *dd, uint8_t reg); |
uint8_t (*sb_read_block)(void *dd, uint32_t addr, void *buff); |
uint8_t (*sb_read_block)(void *dd, uint32_t addr, uint32_t count); |
|
uint8_t (*sb_write_block)(void *dd, uint32_t addr, void *data); |
uint8_t (*sb_write_block)(void *dd, uint32_t addr, void *data); |
uint8_t (*sb_check_busy)(void *dd); |
/* |
|
* XXX implement {read,write}_multiple_block() when we will have DMA. |
|
*/ |
void *sb_dd; |
void *sb_dd; |
}; |
}; |
|
|
/* |
/* |
* Functions. |
* Functions. |
*/ |
*/ |
|
uint8_t sdmmc_init(void *dd); |
|
uint8_t sdmmc_send_command(void *dd, uint8_t cmd, uint32_t arg, uint8_t crc); |
|
uint8_t sdmmc_set_block_size(void *dd, uint16_t size); |
|
uint8_t sdmmc_read_block(void *dd, uint32_t addr, void *buff); |
|
uint8_t sdmmc_write_block(void *dd, uint32_t addr, void *data); |
|
|
|
|
struct sdmmc_cmdframe sdmmc_command(uint8_t cmd, uint32_t arg, uint8_t crc); |
struct sdmmc_cmdframe sdmmc_command(uint8_t cmd, uint32_t arg, uint8_t crc); |
|
|
|
|