SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
Macros | Functions | Variables
sys-mmc.c File Reference
#include <barrier.h>
#include <io.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <types.h>
#include <log.h>
#include <timer.h>
#include <sys-clk.h>
#include <sys-gpio.h>
#include <mmc/sys-mmc.h>
#include <mmc/sys-sdhci.h>
Include dependency graph for sys-mmc.c:

Macros

#define UNSTUFF_BITS(resp, start, size)
 Extracts a specified bit field from a response buffer.
 

Functions

static int sunxi_mmc_host_is_spi (mmc_t *mmc)
 Checks if the MMC host operates in SPI mode.
 
static int sunxi_mmc_device_is_sd (mmc_t *mmc)
 Checks if the MMC device is an SD card.
 
static uint32_t extract_mid (mmc_t *card)
 Extracts the Manufacturer ID from the MMC card.
 
static uint32_t extract_oid (mmc_t *card)
 Extracts the OEM/Application ID from the MMC card.
 
static uint32_t extract_prv (mmc_t *card)
 Extracts the Product Revision from the MMC card.
 
static uint32_t extract_psn (mmc_t *card)
 Extracts the Product Serial Number (PSN) from the MMC card.
 
static uint32_t extract_month (mmc_t *card)
 Extracts the manufacturing month from the MMC card.
 
static uint32_t extract_year (mmc_t *card)
 Extracts the manufacturing year from the MMC card.
 
static int sunxi_mmc_send_status (sunxi_sdhci_t *sdhci, uint32_t timeout)
 Sends status command to the SD/MMC card and waits for the card to be ready.
 
static int sunxi_mmc_set_block_len (sunxi_sdhci_t *sdhci, uint32_t len)
 Sets the block length for data transfer on the SD/MMC card.
 
static uint32_t sunxi_mmc_read_blocks (sunxi_sdhci_t *sdhci, void *dst, uint32_t start, uint32_t blkcnt)
 Reads blocks from the SD/MMC card.
 
static uint32_t sunxi_mmc_write_blocks (sunxi_sdhci_t *sdhci, void *dst, uint32_t start, uint32_t blkcnt)
 Writes blocks of data to the MMC device.
 
static int sunxi_mmc_go_idle (sunxi_sdhci_t *sdhci)
 Sends the SD/MMC card to idle state.
 
static int sunxi_mmc_sd_send_op_cond (sunxi_sdhci_t *sdhci)
 Sends SD card initialization sequence and waits for it to become ready.
 
static int sunxi_mmc_mmc_send_op_cond (sunxi_sdhci_t *sdhci)
 Send the SEND_OP_COND command to the MMC/SD card.
 
static int sunxi_mmc_send_ext_csd (sunxi_sdhci_t *sdhci, char *ext_csd)
 Send the SEND_EXT_CSD command to retrieve the Extended CSD from the MMC/SD card.
 
static int sunxi_mmc_switch (sunxi_sdhci_t *sdhci, uint8_t set, uint8_t index, uint8_t value)
 Send the SWITCH command to the MMC/SD card to change a specified mode or setting.
 
static int sunxi_mmc_mmc_change_freq (sunxi_sdhci_t *sdhci)
 Change the frequency of the MMC/SD card to support high-speed modes.
 
static int sunxi_mmc_sd_switch (sunxi_sdhci_t *sdhci, int mode, int group, uint8_t value, uint8_t *resp)
 Switch the functionality of the SD card.
 
static int sunxi_mmc_sd_change_freq (sunxi_sdhci_t *sdhci)
 Change the frequency of the SD card.
 
static void sunxi_mmc_set_clock (sunxi_sdhci_t *sdhci, uint32_t clock)
 Set the clock frequency for the Sunxi SDHCI controller.
 
static void sunxi_mmc_set_bus_width (sunxi_sdhci_t *sdhci, uint32_t width)
 Set the bus width for the Sunxi SDHCI controller.
 
static int sunxi_mmc_mmc_switch_ds (sunxi_sdhci_t *sdhci)
 Switch the Sunxi SDHCI controller to Double Speed (DS) mode.
 
static int sunxi_mmc_mmc_switch_hs (sunxi_sdhci_t *sdhci)
 Switch the Sunxi SDHCI controller to High Speed (HS) mode.
 
static int sunxi_mmc_mmc_switch_hs200 (sunxi_sdhci_t *sdhci)
 Switch the Sunxi SDHCI controller to High Speed 200 (HS200) mode.
 
static int sunxi_mmc_mmc_switch_hs400 (sunxi_sdhci_t *sdhci)
 Switch the Sunxi SDHCI controller to High Speed 400 (HS400) mode.
 
static int sunxi_mmc_mmc_switch_speed_mode (sunxi_sdhci_t *sdhci, uint32_t spd_mode)
 Switches the speed mode of the MMC controller.
 
static int sunxi_mmc_check_bus_width (sunxi_sdhci_t *sdhci, uint32_t emmc_hs_ddr, uint32_t bus_width)
 Checks if the specified bus width is supported by the MMC controller.
 
static int sunxi_mmc_mmc_switch_bus_width (sunxi_sdhci_t *sdhci, uint32_t spd_mode, uint32_t width)
 Switches the bus width of the MMC controller.
 
static int sunxi_mmc_mmc_switch_bus_mode (sunxi_sdhci_t *sdhci, uint32_t spd_mode, uint32_t width)
 Switches the speed mode and bus width of the MMC controller.
 
static int sunxi_mmc_sd_send_if_cond (sunxi_sdhci_t *sdhci)
 Sends the SD CMD8 (SEND_IF_COND) command to the MMC controller.
 
static void sunxi_mmc_show_card_info (sunxi_sdhci_t *sdhci)
 Displays information about the SD/MMC card attached to the given host controller.
 
static int sunxi_mmc_probe (sunxi_sdhci_t *sdhci)
 Probes the SD/MMC card attached to the given host controller.
 
int sunxi_mmc_init (void *sdhci_hdl)
 Initializes the SD/MMC host controller and attached card.
 
uint32_t sunxi_mmc_blk_read (void *sdhci, void *dst, uint32_t start, uint32_t blkcnt)
 Read blocks from the Sunxi MMC block device.
 
uint32_t sunxi_mmc_blk_write (void *sdhci, void *dst, uint32_t start, uint32_t blkcnt)
 Writes blocks of data to the MMC device using the specified SDHCI instance.
 

Variables

static const int tran_speed_unit []
 
static const int tran_speed_time []
 

Macro Definition Documentation

◆ UNSTUFF_BITS

#define UNSTUFF_BITS (   resp,
  start,
  size 
)
Value:
({ \
const int __size = size; \
const uint32_t __mask = (__size < 32 ? 1 << __size : 0) - 1; \
const int __off = 3 - ((start) / 32); \
const int __shft = (start) &31; \
uint32_t __res; \
\
__res = resp[__off] >> __shft; \
if (__size + __shft > 32) \
__res |= resp[__off - 1] << ((32 - __shft) % 32); \
__res &__mask; \
})
u32_t uint32_t
Definition stdint.h:13

Extracts a specified bit field from a response buffer.

This macro extracts a specified bit field from a response buffer or an array of integers. It calculates the offset, shift amount, and bitmask based on the starting position and size of the field, then performs the extraction and applies the bitmask to isolate the desired bits.

Parameters
respThe response buffer or array of integers.
startThe starting bit position of the field within the response buffer.
sizeThe size (in bits) of the field to be extracted.
Returns
The extracted bit field.

Function Documentation

◆ extract_mid()

static uint32_t extract_mid ( mmc_t card)
inlinestatic

Extracts the Manufacturer ID from the MMC card.

This function extracts the Manufacturer ID from the MMC card's CID (Card Identification Data) register. The extraction is performed based on the MMC version and CID structure.

Parameters
cardPointer to the MMC card structure.
Returns
The Manufacturer ID.

◆ extract_month()

static uint32_t extract_month ( mmc_t card)
inlinestatic

Extracts the manufacturing month from the MMC card.

This function extracts the manufacturing month from the MMC card's CID (Card Identification Data) register.

Parameters
cardPointer to the MMC card structure.
Returns
The manufacturing month.

◆ extract_oid()

static uint32_t extract_oid ( mmc_t card)
inlinestatic

Extracts the OEM/Application ID from the MMC card.

This function extracts the OEM/Application ID from the MMC card's CID (Card Identification Data) register.

Parameters
cardPointer to the MMC card structure.
Returns
The OEM/Application ID.

◆ extract_prv()

static uint32_t extract_prv ( mmc_t card)
inlinestatic

Extracts the Product Revision from the MMC card.

This function extracts the Product Revision from the MMC card's CID (Card Identification Data) register.

Parameters
cardPointer to the MMC card structure.
Returns
The Product Revision.

◆ extract_psn()

static uint32_t extract_psn ( mmc_t card)
inlinestatic

Extracts the Product Serial Number (PSN) from the MMC card.

This function extracts the Product Serial Number (PSN) from the MMC card based on its version and CSD/CID structure.

Parameters
cardPointer to the MMC card structure.
Returns
The Product Serial Number.

◆ extract_year()

static uint32_t extract_year ( mmc_t card)
inlinestatic

Extracts the manufacturing year from the MMC card.

This function extracts the manufacturing year from the MMC card's CID (Card Identification Data) register.

Parameters
cardPointer to the MMC card structure.
Returns
The manufacturing year.

◆ sunxi_mmc_blk_read()

uint32_t sunxi_mmc_blk_read ( void *  sdhci,
void *  dst,
uint32_t  start,
uint32_t  blkcnt 
)

Read blocks from the Sunxi MMC block device.

This function reads a specified number of blocks from the Sunxi MMC block device and stores the data into the destination buffer.

Parameters
sdhciPointer to the Sunxi SD Host Controller instance
dstPointer to the destination buffer where the read data will be stored
startThe starting block number to read from
blkcntThe number of blocks to read
Returns
Returns 0 on success, or an error code if the operation fails

◆ sunxi_mmc_blk_write()

uint32_t sunxi_mmc_blk_write ( void *  sdhci,
void *  dst,
uint32_t  start,
uint32_t  blkcnt 
)

Writes blocks of data to the MMC device using the specified SDHCI instance.

This function writes a specified number of blocks to the MMC (MultiMediaCard) device associated with the given SDHCI (SD Host Controller Interface) instance. It serves as a wrapper around the sunxi_mmc_write_blocks function, providing a simplified interface for block data write operations.

Parameters
[in]sdhciA pointer to the SDHCI instance.
[in]dstA pointer to the destination buffer from which data will be written to the MMC.
[in]startThe starting block number where the data writing begins.
[in]blkcntThe number of blocks to write.
Returns
The number of blocks successfully written, or 0 if writing failed.

◆ sunxi_mmc_check_bus_width()

static int sunxi_mmc_check_bus_width ( sunxi_sdhci_t sdhci,
uint32_t  emmc_hs_ddr,
uint32_t  bus_width 
)
static

Checks if the specified bus width is supported by the MMC controller.

This function checks if the specified bus width is supported by the MMC controller, based on the provided parameters.

Parameters
sdhciPointer to the SD/MMC host controller structure.
emmc_hs_ddrFlag indicating if eMMC high-speed DDR mode is enabled.
bus_widthThe bus width to be checked.
Returns
Returns 0 if the bus width is supported, -1 if not.

◆ sunxi_mmc_device_is_sd()

static int sunxi_mmc_device_is_sd ( mmc_t mmc)
inlinestatic

Checks if the MMC device is an SD card.

This function checks if the MMC device is an SD card based on its version information.

Parameters
mmcPointer to the MMC structure.
Returns
1 if the device is an SD card, 0 otherwise.

◆ sunxi_mmc_go_idle()

static int sunxi_mmc_go_idle ( sunxi_sdhci_t sdhci)
static

Sends the SD/MMC card to idle state.

This function sends the SD/MMC card to the idle state, preparing it for further commands.

Parameters
sdhciPointer to the SDHCI controller structure.
Returns
0 on success, error code otherwise.

◆ sunxi_mmc_host_is_spi()

static int sunxi_mmc_host_is_spi ( mmc_t mmc)
inlinestatic

Checks if the MMC host operates in SPI mode.

This function checks if the MMC host operates in SPI mode based on its capabilities.

Parameters
mmcPointer to the MMC structure.
Returns
1 if the host operates in SPI mode, 0 otherwise.

◆ sunxi_mmc_init()

int sunxi_mmc_init ( void *  sdhci_hdl)

Initializes the SD/MMC host controller and attached card.

This function initializes the specified SD/MMC host controller and the attached SD/MMC card. It initializes the host controller core, sets the bus width and clock speed, resets the card, and initializes the card based on its type (SD or eMMC). Finally, it probes the card to retrieve card-specific data.

Parameters
sdhci_hdlPointer to the SD/MMC host controller structure.
Returns
0 on success, or an error code if an error occurred during initialization.

◆ sunxi_mmc_mmc_change_freq()

static int sunxi_mmc_mmc_change_freq ( sunxi_sdhci_t sdhci)
static

Change the frequency of the MMC/SD card to support high-speed modes.

This function changes the frequency of the MMC/SD card to support high-speed modes. It checks if the card supports high-speed modes and switches to the appropriate mode if possible.

Parameters
sdhciPointer to the Sunxi SDHCI controller structure.
Returns
Returns 0 on success, indicating successful completion of the frequency change, or an error code indicating failure. Possible error codes:
  • Negative value: indicates a communication error with the MMC/SD card.
  • Positive value: indicates an internal error within the function.

◆ sunxi_mmc_mmc_send_op_cond()

static int sunxi_mmc_mmc_send_op_cond ( sunxi_sdhci_t sdhci)
static

Send the SEND_OP_COND command to the MMC/SD card.

This function sends the SEND_OP_COND command to the MMC/SD card to initialize and check its capabilities. It waits for the card to respond and initializes it, updating the MMC structure with card information upon successful initialization.

Parameters
sdhciPointer to the Sunxi SDHCI controller structure.
Returns
Returns 0 on success, indicating successful initialization of the card, or an error code indicating failure. Possible error codes:
  • Negative value: indicates a communication error with the MMC/SD card.
  • Positive value: indicates an internal error within the function.
  • UNUSABLE_ERR: indicates failure to initialize the card within the timeout.

◆ sunxi_mmc_mmc_switch_bus_mode()

static int sunxi_mmc_mmc_switch_bus_mode ( sunxi_sdhci_t sdhci,
uint32_t  spd_mode,
uint32_t  width 
)
static

Switches the speed mode and bus width of the MMC controller.

This function switches the speed mode and bus width of the MMC controller based on the provided parameters. If the device is an SD card, no action is taken and the function returns successfully.

Parameters
sdhciPointer to the SD/MMC host controller structure.
spd_modeSpeed mode to be switched to.
widthThe bus width to be set.
Returns
Returns 0 upon success, an error code if an error occurs.

◆ sunxi_mmc_mmc_switch_bus_width()

static int sunxi_mmc_mmc_switch_bus_width ( sunxi_sdhci_t sdhci,
uint32_t  spd_mode,
uint32_t  width 
)
static

Switches the bus width of the MMC controller.

This function switches the bus width of the MMC controller based on the provided parameters.

Parameters
sdhciPointer to the SD/MMC host controller structure.
spd_modeSpeed mode of the MMC controller.
widthThe bus width to be set.
Returns
Returns 0 upon success, -1 if an error occurs.

◆ sunxi_mmc_mmc_switch_ds()

static int sunxi_mmc_mmc_switch_ds ( sunxi_sdhci_t sdhci)
static

Switch the Sunxi SDHCI controller to Double Speed (DS) mode.

This function switches the Secure Digital Host Controller Interface (SDHCI) in a Sunxi system-on-a-chip (SoC) environment to Double Speed (DS) mode.

Parameters
sdhciA pointer to the Sunxi SDHCI controller structure.
Returns
Returns 0 on success, or a negative error code on failure.

◆ sunxi_mmc_mmc_switch_hs()

static int sunxi_mmc_mmc_switch_hs ( sunxi_sdhci_t sdhci)
static

Switch the Sunxi SDHCI controller to High Speed (HS) mode.

This function switches the Secure Digital Host Controller Interface (SDHCI) in a Sunxi system-on-a-chip (SoC) environment to High Speed (HS) mode.

Parameters
sdhciA pointer to the Sunxi SDHCI controller structure.
Returns
Returns 0 on success, or a negative error code on failure.

◆ sunxi_mmc_mmc_switch_hs200()

static int sunxi_mmc_mmc_switch_hs200 ( sunxi_sdhci_t sdhci)
static

Switch the Sunxi SDHCI controller to High Speed 200 (HS200) mode.

This function switches the Secure Digital Host Controller Interface (SDHCI) in a Sunxi system-on-a-chip (SoC) environment to High Speed 200 (HS200) mode.

Parameters
sdhciA pointer to the Sunxi SDHCI controller structure.
Returns
Returns 0 on success, or a negative error code on failure.

◆ sunxi_mmc_mmc_switch_hs400()

static int sunxi_mmc_mmc_switch_hs400 ( sunxi_sdhci_t sdhci)
static

Switch the Sunxi SDHCI controller to High Speed 400 (HS400) mode.

This function switches the Secure Digital Host Controller Interface (SDHCI) in a Sunxi system-on-a-chip (SoC) environment to High Speed 400 (HS400) mode.

Parameters
sdhciA pointer to the Sunxi SDHCI controller structure.
Returns
Returns 0 on success, or a negative error code on failure.

◆ sunxi_mmc_mmc_switch_speed_mode()

static int sunxi_mmc_mmc_switch_speed_mode ( sunxi_sdhci_t sdhci,
uint32_t  spd_mode 
)
static

Switches the speed mode of the MMC controller.

This function switches the speed mode of the MMC controller based on the provided speed mode.

Parameters
sdhciPointer to the SD/MMC host controller structure.
spd_modeSpeed mode to be switched to.
Returns
Returns 0 upon success, -1 if an error occurs.

◆ sunxi_mmc_probe()

static int sunxi_mmc_probe ( sunxi_sdhci_t sdhci)
static

Probes the SD/MMC card attached to the given host controller.

This function probes the SD/MMC card attached to the specified host controller, retrieves various card-specific data such as CID and CSD, and sets the card to the appropriate mode. It also handles sending commands and checking for errors.

Parameters
sdhciPointer to the SD/MMC host controller structure.
Returns
0 on success, or an error code if an error occurred during probing.

◆ sunxi_mmc_read_blocks()

static uint32_t sunxi_mmc_read_blocks ( sunxi_sdhci_t sdhci,
void *  dst,
uint32_t  start,
uint32_t  blkcnt 
)
static

Reads blocks from the SD/MMC card.

This function reads blocks from the SD/MMC card starting from the specified block address. It supports reading multiple blocks and handles high capacity cards appropriately.

Parameters
sdhciPointer to the SDHCI controller structure.
dstPointer to the destination buffer where the data will be stored.
startStart block address from where to read the data.
blkcntNumber of blocks to read.
Returns
Number of blocks read on success, 0 otherwise.

◆ sunxi_mmc_sd_change_freq()

static int sunxi_mmc_sd_change_freq ( sunxi_sdhci_t sdhci)
static

Change the frequency of the SD card.

This function changes the operating frequency of the SD card based on its capabilities. It reads the SCR (SD Configuration Register) to determine if the card supports higher speeds. If the card supports higher speeds, it adjusts the frequency accordingly.

Parameters
sdhciPointer to the Sunxi SDHCI controller structure.
Returns
Returns 0 on success, indicating successful change of frequency, or an error code indicating failure. Possible error codes:
  • Negative value: indicates a communication error with the SD card.
  • Positive value: indicates an internal error within the function.

◆ sunxi_mmc_sd_send_if_cond()

static int sunxi_mmc_sd_send_if_cond ( sunxi_sdhci_t sdhci)
static

Sends the SD CMD8 (SEND_IF_COND) command to the MMC controller.

This function sends the SD CMD8 command to the MMC controller to check if the card supports the given voltage range.

Parameters
sdhciPointer to the SD/MMC host controller structure.
Returns
Returns 0 upon success, an error code if an error occurs.

◆ sunxi_mmc_sd_send_op_cond()

static int sunxi_mmc_sd_send_op_cond ( sunxi_sdhci_t sdhci)
static

Sends SD card initialization sequence and waits for it to become ready.

This function sends the SD card initialization sequence, which includes sending application-specific commands and checking the card's response until it becomes ready. It also updates the MMC structure with relevant information such as the card version, OCR value, and high capacity flag.

Parameters
sdhciPointer to the SDHCI controller structure.
Returns
0 on success, error code otherwise.

◆ sunxi_mmc_sd_switch()

static int sunxi_mmc_sd_switch ( sunxi_sdhci_t sdhci,
int  mode,
int  group,
uint8_t  value,
uint8_t resp 
)
static

Switch the functionality of the SD card.

This function switches the functionality of the SD card, such as changing the frequency or mode of operation. It sends a SWITCH_FUNC command to the SD card with the specified parameters to perform the desired switch.

Parameters
sdhciPointer to the Sunxi SDHCI controller structure.
modeSwitch mode indicating the type of switch operation to perform.
groupSwitch group indicating the group of functions to switch.
valueValue indicating the specific function or setting to switch to within the specified group.
respPointer to a buffer to store the response from the SD card.
Returns
Returns 0 on success, indicating successful completion of the switch operation, or an error code indicating failure. Possible error codes:
  • Negative value: indicates a communication error with the SD card.
  • Positive value: indicates an internal error within the function.

◆ sunxi_mmc_send_ext_csd()

static int sunxi_mmc_send_ext_csd ( sunxi_sdhci_t sdhci,
char *  ext_csd 
)
static

Send the SEND_EXT_CSD command to retrieve the Extended CSD from the MMC/SD card.

This function sends the SEND_EXT_CSD command to the MMC/SD card to retrieve its Extended CSD register, which contains various configuration parameters and settings. It stores the retrieved Extended CSD data in the provided buffer.

Parameters
sdhciPointer to the Sunxi SDHCI controller structure.
ext_csdPointer to the buffer where the Extended CSD data will be stored.
Returns
Returns 0 on success, indicating successful retrieval of the Extended CSD data, or an error code indicating failure. Possible error codes:
  • Negative value: indicates a communication error with the MMC/SD card.
  • Positive value: indicates an internal error within the function.

◆ sunxi_mmc_send_status()

static int sunxi_mmc_send_status ( sunxi_sdhci_t sdhci,
uint32_t  timeout 
)
static

Sends status command to the SD/MMC card and waits for the card to be ready.

This function sends the status command to the SD/MMC card and waits for the card to be ready for data transfer. It retries sending the command until the card is ready or until the timeout expires.

Parameters
sdhciPointer to the SDHCI controller structure.
timeoutTimeout value in milliseconds.
Returns
0 on success, error code otherwise.

◆ sunxi_mmc_set_block_len()

static int sunxi_mmc_set_block_len ( sunxi_sdhci_t sdhci,
uint32_t  len 
)
static

Sets the block length for data transfer on the SD/MMC card.

This function sets the block length for data transfer on the SD/MMC card, except in DDR mode.

Parameters
sdhciPointer to the SDHCI controller structure.
lenBlock length to be set.
Returns
0 on success, error code otherwise.

◆ sunxi_mmc_set_bus_width()

static void sunxi_mmc_set_bus_width ( sunxi_sdhci_t sdhci,
uint32_t  width 
)
static

Set the bus width for the Sunxi SDHCI controller.

This function sets the bus width for the Secure Digital Host Controller Interface (SDHCI) in a Sunxi system-on-a-chip (SoC) environment.

Parameters
sdhciA pointer to the Sunxi SDHCI controller structure.
widthThe bus width to be set (in bits).

◆ sunxi_mmc_set_clock()

static void sunxi_mmc_set_clock ( sunxi_sdhci_t sdhci,
uint32_t  clock 
)
static

Set the clock frequency for the Sunxi SDHCI controller.

This function sets the clock frequency for the Secure Digital Host Controller Interface (SDHCI) in a Sunxi system-on-a-chip (SoC) environment.

Parameters
sdhciA pointer to the Sunxi SDHCI controller structure.
clockThe desired clock frequency to be set.

◆ sunxi_mmc_show_card_info()

static void sunxi_mmc_show_card_info ( sunxi_sdhci_t sdhci)
static

Displays information about the SD/MMC card attached to the given host controller.

This function prints various details about the SD/MMC card attached to the specified host controller, such as the card type, capacity, CID, CSD, maximum transfer speed, manufacturer ID, OEM/application ID, product name, product revision, serial number, and manufacturing date.

Parameters
sdhciPointer to the SD/MMC host controller structure.

◆ sunxi_mmc_switch()

static int sunxi_mmc_switch ( sunxi_sdhci_t sdhci,
uint8_t  set,
uint8_t  index,
uint8_t  value 
)
static

Send the SWITCH command to the MMC/SD card to change a specified mode or setting.

This function sends the SWITCH command to the MMC/SD card to change a specified mode or setting. It is typically used to modify various parameters or configurations of the card.

Parameters
sdhciPointer to the Sunxi SDHCI controller structure.
setValue indicating the type of setting to be changed.
indexIndex of the setting within the specified set.
valueNew value to set for the specified setting.
Returns
Returns 0 on success, indicating successful completion of the SWITCH command, or an error code indicating failure. Possible error codes:
  • Negative value: indicates a communication error with the MMC/SD card.
  • Positive value: indicates an internal error within the function.

◆ sunxi_mmc_write_blocks()

static uint32_t sunxi_mmc_write_blocks ( sunxi_sdhci_t sdhci,
void *  dst,
uint32_t  start,
uint32_t  blkcnt 
)
static

Writes blocks of data to the MMC device.

This function writes a specified number of blocks to the MMC (MultiMediaCard) device associated with the given SDHCI (SD Host Controller Interface) instance. It supports both single block and multiple block write operations, and handles sending the appropriate commands to the MMC device.

Parameters
[in]sdhciA pointer to the SDHCI instance.
[in]dstA pointer to the destination buffer from which data will be written to the MMC.
[in]startThe starting block number where the data writing begins.
[in]blkcntThe number of blocks to write.
Returns
The number of blocks successfully written, or 0 if writing failed.

Variable Documentation

◆ tran_speed_time

const int tran_speed_time[]
static
Initial value:
= {
0,
10,
12,
13,
15,
20,
25,
30,
35,
40,
45,
50,
55,
60,
70,
80,
}

◆ tran_speed_unit

const int tran_speed_unit[]
static
Initial value:
= {
10000,
100000,
1000000,
10000000,
}