sdmmc: better calculation of erase timeout
Previous version of the code used a fixed constant (500 ms) for the erase timeout and added 1 ms for each sector erased. This commit improves timeouts calculation: - For SD cards, check if erase timeout information is present in the SSR register. If yes, use it for erase timeout calculation. Otherwise assume 250ms per erase block, same as Linux does. - For eMMC assume 250ms per erase block (but no less than 1 second). This has to be improved later to use the erase timeout info in the extended CSD register.
This commit is contained in:
@@ -372,6 +372,9 @@
|
||||
/* SSR (SD Status Register) */
|
||||
#define SSR_DAT_BUS_WIDTH(ssr) MMC_RSP_BITS((ssr), 510, 2)
|
||||
#define SSR_AU_SIZE(ssr) MMC_RSP_BITS((ssr), 428, 4)
|
||||
#define SSR_ERASE_SIZE(ssr) MMC_RSP_BITS((ssr), 408, 16)
|
||||
#define SSR_ERASE_TIMEOUT(ssr) MMC_RSP_BITS((ssr), 402, 6)
|
||||
#define SSR_ERASE_OFFSET(ssr) MMC_RSP_BITS((ssr), 400, 2)
|
||||
#define SSR_DISCARD_SUPPORT(ssr) MMC_RSP_BITS((ssr), 313, 1)
|
||||
#define SSR_FULE_SUPPORT(ssr) MMC_RSP_BITS((ssr), 312, 1)
|
||||
|
||||
|
||||
@@ -71,10 +71,14 @@ typedef struct {
|
||||
* Note: When new member is added, update reserved bits accordingly
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t alloc_unit_kb: 16; /*!< Allocation unit of the card, in multiples of kB (1024 bytes) */
|
||||
uint32_t erase_size_au: 16; /*!< Erase size for the purpose of timeout calculation, in multiples of allocation unit */
|
||||
uint32_t cur_bus_width: 2; /*!< SD current bus width */
|
||||
uint32_t discard_support: 1; /*!< SD discard feature support */
|
||||
uint32_t fule_support: 1; /*!< SD FULE (Full User Area Logical Erase) feature support */
|
||||
uint32_t reserved: 28; /*!< reserved for future expansion */
|
||||
uint32_t erase_timeout: 6; /*!< Timeout (in seconds) for erase of a single allocation unit */
|
||||
uint32_t erase_offset: 2; /*!< Constant timeout offset (in seconds) for any erase operation */
|
||||
uint32_t reserved: 20; /*!< reserved for future expansion */
|
||||
} sdmmc_ssr_t;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user