HPM SDK
HPMicro Software Development Kit
hpm_sdmmc_emmc.h File Reference
#include "hpm_sdmmc_common.h"
#include "hpm_sdmmc_card.h"
#include "hpm_sdmmc_port.h"

Go to the source code of this file.

Data Structures

union  emmc_switch_cmd_arg_t
 
union  emmc_ocr_t
 
union  emmc_cid_t
 
union  emmc_card_status_t
 
struct  emmc_csd_t
 
union  emmc_device_type_t
 
struct  emmc_ext_csd_t
 
union  emmc_power_class_t
 
struct  boot_info_t
 
struct  secure_feature_info_t
 
struct  emmc_boot_setting_t
 
struct  emmc_device_attribute_t
 
struct  emmc_config_partition_option_t
 

Macros

#define EMMC_EXT_CSD_INDEX_CMD_SET   (191)
 
#define EMMC_EXT_CSD_INDEX_POWER_CLASS   (187)
 
#define EMMC_EXT_CSD_INDEX_HS_TIMING   (185)
 
#define EMMC_EXT_CSD_INDEX_BUS_WDITH   (183)
 
#define EMMC_EXT_CSD_INDEX_PARTITION_CONFIG   (179)
 
#define EMMC_EXT_CSD_INDEX_BOOT_CONFIG_PROT   (178)
 
#define EMMC_EXT_CSD_INDEX_BOOT_BUS_CONDITIONS   (177)
 
#define EMMC_EXT_CSD_INDEX_ERASE_GROUP_DEF   (175)
 
#define EMMC_EXT_CSD_INDEX_BOOT_WP   (173)
 
#define EMMC_EXT_CSD_INDEX_USER_WP   (171)
 
#define EMMC_EXT_CSD_INDEX_FW_CONFIG   (169)
 
#define EMMC_EXT_CSD_INDEX_WR_REL_SET   (167)
 
#define EMMC_EXT_CSD_INDEX_SANITIZE_START   (165)
 
#define EMMC_EXT_CSD_INDEX_BKOPS_START   (164)
 
#define EMMC_EXT_CSD_INDEX_BKOPS_EN   (163)
 
#define EMMC_EXT_CSD_INDEX_RSTn_FUNCTION   (162)
 
#define EMMC_EXT_CSD_INDEX_HPI_MGMT   (161)
 
#define EMMC_EXT_CSD_INDEX_PARTITIONS_ATTRIBUTE   (156)
 
#define EMMC_EXT_CSD_INDEX_PARTITION_SETTING_COMPLETED   (155)
 
#define EMMC_EXT_CSD_INDEX_SEC_BAD_BLK_MGMNT   (134)
 
#define EMMC_EXT_CSD_INDEX_PRODUCTION_STATE_AWARENESS   (133)
 
#define EMMC_EXT_CSD_INDEX_PERIODIC_WAKEUP   (131)
 
#define EMMC_EXT_CSD_INDEX_USE_NATIVE_SECTOR   (62)
 
#define EMMC_EXT_CSD_INDEX_CLASS_6_CTRL   (59)
 
#define EMMC_EXT_CSD_INDEX_POWER_OFF_NOTIFICATION   (34)
 
#define EMMC_EXT_CSD_INDEX_CACHE_CTRL   (33)
 
#define EMMC_EXT_CSD_INDEX_FLUSH_CACHE   (32)
 
#define EMMC_EXT_CSD_INDEX_BARRIER_CTRL   (31)
 
#define EMMC_EXT_CSD_INDEX_MODE_CONFIG   (30)
 
#define EMMC_EXT_CSD_INDEX_PRODUCT_STATE_AWARENESS_ENABLEMENT   (17)
 
#define EMMC_EXT_CSD_INDEX_SECURE_REMOVAL_TYPE   (16)
 
#define EMMC_EXT_CSD_INDEX_CMDQ_MODE_EN   (15)
 

Typedefs

typedef enum vdd_current_min_def vdd_current_min_t
 
typedef enum vdd_current_max_def vdd_current_max_t
 
typedef enum _emmc_partition emmc_partition_t
 
typedef enum _emmc_hs_timing emmc_hs_timing_t
 
typedef struct _sdmmc_emmc emmc_card_t
 

Enumerations

enum  emmc_switch_cmd_access_mode_t { emmc_switch_cmd_access_mode_command_set = 0 , emmc_switch_cmd_access_mode_set_bits = 1 , emmc_switch_cmd_access_mode_clear_bits = 2 , emmc_switch_cmd_access_mode_write_byte = 3 }
 
enum  emmc_csd_vdd_current_min_t {
  emmc_csd_vdd_current_min_0_5ma , emmc_csd_vdd_current_min_1ma , emmc_csd_vdd_current_min_5ma , emmc_csd_vdd_current_min_10ma ,
  emmc_csd_vdd_current_min_25ma , emmc_csd_vdd_current_min_35ma , emmc_csd_vdd_current_min_60ma , emmc_csd_vdd_current_min_100ma
}
 
enum  emmc_csd_vdd_current_max_t {
  emmc_csd_vdd_current_max_1ma , emmc_csd_vdd_current_max_5ma , emmc_csd_vdd_current_max_10ma , emmc_csd_vdd_current_max_25ma ,
  emmc_csd_vdd_current_max_35ma , emmc_csd_vdd_current_max_45ma , emmc_csd_vdd_current_max_80ma , emmc_csd_vdd_current_max_200ma
}
 
enum  vdd_current_min_def {
  vdd_current_min_0_5ma , vdd_current_min_1ma , vdd_current_min_5ma , vdd_current_min_10ma ,
  vdd_current_min_25ma , vdd_current_min_35ma , vdd_current_min_60ma , vdd_current_min_100ma
}
 
enum  vdd_current_max_def {
  vdd_current_max_1ma , vdd_current_max_5ma , vdd_current_max_10ma , vdd_current_max_25ma ,
  vdd_current_max_35ma , vdd_current_max_45ma , vdd_current_max_80ma , vdd_current_max_200ma
}
 
enum  emmc_csd_file_format_t { emmc_csd_file_format_hard_disk_like_file_system_with_partition_table , emmc_csd_file_format_dos_fat_with_boot_sector_only , emmc_csd_file_format_universal_file_format , emmc_csd_file_format_others_or_unknown }
 
enum  emmc_power_class_3v6_t {
  emmc_power_3v6_max_rms_100ma_peak_200ma = 0 , emmc_power_3v6_max_rms_120ma_peak_220ma = 1 , emmc_power_3v6_max_rms_150ma_peak_250ma = 2 , emmc_power_3v6_max_rms_180ma_peak_280ma = 3 ,
  emmc_power_3v6_max_rms_200ma_peak_300ma = 4 , emmc_power_3v6_max_rms_220ma_peak_320ma = 5 , emmc_power_3v6_max_rms_250ma_peak_350ma = 6 , emmc_power_3v6_max_rms_300ma_peak_400ma = 7 ,
  emmc_power_3v6_max_rms_350ma_peak_450ma = 8 , emmc_power_3v6_max_rms_400ma_peak_500ma = 9 , emmc_power_3v6_max_rms_450ma_peak_550ma = 10 , emmc_power_3v6_max_rms_500ma_peak_600ma = 11 ,
  emmc_power_3v6_max_rms_600ma_peak_700ma = 12 , emmc_power_3v6_max_rms_700ma_peak_800ma = 13 , emmc_power_3v6_max_rms_800ma_peak_900ma = 14 , emmc_power_3v6_max_rms_gt800ma_peak_gt900ma = 15
}
 
enum  emmc_power_class_1v95_t {
  emmc_power_1v95_max_rms_65ma_peak_130ma = 0 , emmc_power_1v95_max_rms_70ma_peak_140ma = 1 , emmc_power_1v95_max_rms_80ma_peak_160ma = 2 , emmc_power_1v95_max_rms_90ma_peak_180ma = 3 ,
  emmc_power_1v95_max_rms_100ma_peak_200ma = 4 , emmc_power_1v95_max_rms_120ma_peak_220ma = 5 , emmc_power_1v95_max_rms_140ma_peak_240ma = 6 , emmc_power_1v95_max_rms_160ma_peak_260ma = 7 ,
  emmc_power_1v95_max_rms_180ma_peak_280ma = 8 , emmc_power_1v95_max_rms_200ma_peak_300ma = 9 , emmc_power_1v95_max_rms_250ma_peak_350ma = 10 , emmc_power_1v95_max_rms_300ma_peak_400ma = 11 ,
  emmc_power_1v95_max_rms_350ma_peak_450ma = 12 , emmc_power_1v95_max_rms_400ma_peak_500ma = 13 , emmc_power_1v95_max_rms_500ma_peak_600ma = 14 , emmc_power_1v95_max_rms_gt500ma_peak_gt600ma = 15
}
 
enum  emmc_bus_mode_t {
  emmc_bus_mode_x1_sdr = 0 , emmc_bus_mode_x4_sdr = 1 , emmc_bus_mode_x8_sdr = 2 , emmc_bus_mode_x4_ddr = 5 ,
  emmc_bus_mode_x8_ddr = 6 , emmc_bus_mode_x8_ddr_ds = 0x86
}
 
enum  emmc_write_protection_mode_t { emmc_write_protection_mode_legacy = 0 , emmc_write_protection_mode_secure = 1 }
 
enum  emmc_boot_partition_mode_t { emmc_boot_partition_mode_not_enabled = 0 , emmc_boot_partition_mode_boot_partition1 = 1 , emmc_boot_partition_mode_boot_partition2 = 2 , emmc_boot_partition_mode_user_area = 7 }
 
enum  emmc_partition_access_t {
  emmc_partition_access_boot_partition_disabled = 0 , emmc_partition_access_read_or_write_boot_partition1 = 1 , emmc_partition_access_read_or_write_boot_partition2 = 2 , emmc_partition_access_read_or_write_rpmb = 3 ,
  emmc_partition_access_access_to_gp_partition1 = 4 , emmc_partition_access_access_to_gp_partition2 = 5 , emmc_partition_access_access_to_gp_partition3 = 6 , emmc_partition_access_access_to_gp_partition4 = 7
}
 
enum  emmc_boot_mode_t { emmc_boot_mode_sdr_legacy = 0 , emmc_boot_mode_sdr_high_speed_timing , emmc_boot_mode_ddr }
 
enum  emmc_idle_option_t { emmc_idle_option_go_idle_state = 0 , emmc_idle_option_go_pre_idle_state = 0xF0F0F0F0U , emmc_idle_option_boot_initialization = 0xFFFFFFFAU }
 
enum  emmc_erase_option_t { emmc_erase_option_erase = 0 , emmc_erase_option_trim = 1 , emmc_erase_option_discard = 2 }
 
enum  emmc_boot_partition_enable_option_t { boot_partition_enable_option_not_enabled = 0 , boot_partition_enable_option_boot_partition1 = 1 , boot_partition_enable_option_boot_partition2 = 2 , boot_partition_enable_option_user_area = 7 }
 
enum  emmc_partition_access_option_t {
  partition_access_option_no_access_to_boot_partition = 0 , partition_access_option_read_write_boot_partition1 = 1 , partition_access_option_read_write_boot_partition2 = 2 , partition_access_option_read_write_rpmb = 3 ,
  partition_access_option_access_to_gp_partition1 = 4 , partition_access_option_access_to_gp_partition2 = 5 , partition_access_option_access_to_gp_partition3 = 6 , partition_access_option_access_to_gp_partition4 = 7
}
 

Functions

hpm_stat_t emmc_init (emmc_card_t *card)
 Initialize eMMC device, include both host and the device. More...
 
void emmc_deinit (emmc_card_t *card)
 De-Initialize eMMC device. More...
 
hpm_stat_t emmc_card_init (emmc_card_t *card)
 Initialize eMMC device. More...
 
hpm_stat_t emmc_send_cid (emmc_card_t *card)
 Request eMMC device to send CID to Host. More...
 
hpm_stat_t emmc_probe_device (emmc_card_t *card)
 Probe eMMC device. More...
 
hpm_stat_t emmc_select_card (const emmc_card_t *card, bool is_selected)
 Select eMMC device. More...
 
hpm_stat_t emmc_go_idle (emmc_card_t *card, emmc_idle_option_t option)
 Go to Idle mode. More...
 
hpm_stat_t emmc_switch_function (const emmc_card_t *card, emmc_switch_cmd_arg_t arg, uint32_t timeout_us)
 Switch eMMC function. More...
 
hpm_stat_t emmc_configure_partition (const emmc_card_t *card, emmc_config_partition_option_t option)
 Configure eMMC Partition. More...
 
hpm_stat_t emmc_enable_high_density_erase_group (emmc_card_t *card, bool enable)
 Enable High Density Erase group. More...
 
hpm_stat_t emmc_program_csd (emmc_card_t *card, const uint32_t *raw_csd)
 Program CSD register. More...
 
hpm_stat_t emmc_read_blocks (emmc_card_t *card, uint8_t *buffer, uint32_t start_block, uint32_t block_count)
 Read eMMC blocks. More...
 
hpm_stat_t emmc_write_blocks (emmc_card_t *card, const uint8_t *buffer, uint32_t start_block, uint32_t block_count)
 Write eMMC blocks. More...
 
hpm_stat_t emmc_erase_blocks (emmc_card_t *card, uint32_t start_block, uint32_t block_count, emmc_erase_option_t option)
 Erase eMMC Blocks. More...
 
hpm_stat_t emmc_enter_sleep_mode (const emmc_card_t *card)
 Switch eMMC device into sleep mode. More...
 
hpm_stat_t emmc_exit_sleep_mode (const emmc_card_t *card)
 Switch eMMC device into standby mode. More...