=================================================================== RCS file: /cvs/funnyos/dev/sdmmc/sdmmcvar.h,v retrieving revision 1.2 retrieving revision 1.4 diff -u -r1.2 -r1.4 --- funnyos/dev/sdmmc/sdmmcvar.h 2007/12/20 15:23:15 1.2 +++ funnyos/dev/sdmmc/sdmmcvar.h 2007/12/25 14:08:10 1.4 @@ -1,9 +1,11 @@ /* - * $Id: sdmmcvar.h,v 1.2 2007/12/20 15:23:15 nbrk Exp $ + * $Id: sdmmcvar.h,v 1.4 2007/12/25 14:08:10 nbrk Exp $ */ #ifndef _DEV_SDMMC_SDMMCVAR_H #define _DEV_SDMMC_SDMMCVAR_H +#define SDMMC_BLOCK_SIZE 512 + /* * SD/MMC simplified commands set. */ @@ -92,6 +94,16 @@ /* + * 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. */ #define RE_UNSPECIFIED_ERROR 0x01 @@ -101,23 +113,44 @@ #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. */ struct sdmmc_bus_handle { - void (*sb_send_command)(void *dd, uint8_t cmd, uint32_t arg); - uint8_t (*sb_get_response)(void *dd); - uint8_t (*sb_get_spec_response)(void *dd, uint8_t response); - uint8_t (*sb_read_register)(void *dd, uint8_t reg); - uint8_t (*sb_read_block)(void *dd, uint32_t addr, uint32_t count); + uint8_t (*sb_init)(void *dd); + uint8_t (*sb_send_command)(void *dd, uint8_t cmd, uint32_t arg, uint8_t crc); + uint8_t (*sb_set_block_size)(void *dd, uint16_t size); + uint8_t (*sb_read_block)(void *dd, uint32_t addr, void *buff); 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; }; /* * 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);