#ifndef SDCARD_INCLUDED #define SDCARD_INCLUDED #define SDIO_HAS_CARD_DETECT enum SDIO_CLOCK_DIV { SDIO_24MHZ = 0, SDIO_16MHZ, SDIO_12MHZ, SDIO_8MHZ, SDIO_4MHZ, SDIO_1MHZ, SDIO_400KHZ }; enum SDIO_POWER_STATE { SDIO_POWER_ON, SDIO_POWER_OFF }; #define SDIO_CARD_CCS(c) (((c)->ocr & 0x40000000) != 0) #define SDIO_CARD_UHS2(c) (((c)->ocr & 0x40000000) != 0) #define SDIO_CARD_LVOK(c) (((c)->ocr & 0x01000000) != 0) typedef struct SDIO_CARD_DATA { uint32_t props; uint32_t ocr; uint32_t cid[4]; uint32_t csd[4]; uint32_t scr[2]; uint32_t status[16]; uint32_t size; uint16_t rca; } * SDIO_CARD; struct dev_sd { struct device *dev; uint32_t base; uint32_t *rcc_rst_reg; uint32_t rcc_rst; SDIO_CARD card; }; /* API for sd_bus clock setting */ enum SD_CLOCK_DIV { CLOCK_24MHZ = 0, CLOCK_16MHZ, CLOCK_12MHZ, CLOCK_8MHZ, CLOCK_4MHZ, CLOCK_1MHZ, CLOCK_400KHZ }; //int stm32_sd_bus(int bits, enum SD_CLOCK_DIV freq); void *sdcard_open(void); int sdcard_read(void *dev, void *_buf, uint32_t lba); int sdcard_write(void *dev, void *_buf, uint32_t lba); int sdcard_sense(void); int sdcard_detect(void); uint32_t sdcard_getsize(void *dev); void sdcard_hw_init(void); #endif