platform/msm_shared/mmc.c
static unsigned int
mmc_boot_read_reg(struct mmc_boot_card *card,
		  unsigned int data_len,
		  unsigned int command, unsigned int addr, unsigned int *out)
{
	struct mmc_boot_command cmd;
	unsigned int mmc_ret = MMC_BOOT_E_SUCCESS;
	unsigned int mmc_reg = 0;

	/* Set the FLOW_ENA bit of MCI_CLK register to 1 */
	mmc_reg = readl(MMC_BOOT_MCI_CLK);
	mmc_reg |= MMC_BOOT_MCI_CLK_ENA_FLOW;
	writel(mmc_reg, MMC_BOOT_MCI_CLK);

	/* Write data timeout period to MCI_DATA_TIMER register. */
	/* Data timeout period should be in card bus clock periods */
	mmc_reg = 0xFFFFFFFF;
	writel(mmc_reg, MMC_BOOT_MCI_DATA_TIMER);
	writel(data_len, MMC_BOOT_MCI_DATA_LENGTH);

	/* Set appropriate fields and write the MCI_DATA_CTL register. */
	/* Set ENABLE bit to 1 to enable the data transfer. */
	mmc_reg =
	    MMC_BOOT_MCI_DATA_ENABLE | MMC_BOOT_MCI_DATA_DIR | (data_len <<
								MMC_BOOT_MCI_BLKSIZE_POS);

#if MMC_BOOT_ADM
	mmc_reg |= MMC_BOOT_MCI_DATA_DM_ENABLE;
#endif

	writel(mmc_reg, MMC_BOOT_MCI_DATA_CTL);

	memset((struct mmc_boot_command *)&cmd, 0,
	       sizeof(struct mmc_boot_command));

	cmd.cmd_index = command;
	cmd.argument = addr;
	cmd.cmd_type = MMC_BOOT_CMD_ADDRESS;
	cmd.resp_type = MMC_BOOT_RESP_R1;

	/* send command */
	mmc_ret = mmc_boot_send_command(&cmd);
	if (mmc_ret != MMC_BOOT_E_SUCCESS) {
		return mmc_ret;
	}

	/* Read the transfer data from SDCC FIFO. */
	mmc_ret =
	    mmc_boot_fifo_data_transfer(out, data_len, MMC_BOOT_DATA_READ);

	if (mmc_ret != MMC_BOOT_E_SUCCESS) {
		dprintf(CRITICAL, "Error No.%d: Failure on data transfer from the \
                Card(RCA:%x)\n", mmc_ret,
			card->rca);
		return mmc_ret;
	}

	return MMC_BOOT_E_SUCCESS;
}
/*
 * Function to read registers from MMC or SD card
 */
Function to read registers from MMC or SD card
Function to read registers from MMC or SD card
static unsigned int
mmc_boot_read_reg(struct mmc_boot_card *card,
		  unsigned int data_len,
		  unsigned int command, unsigned int addr, unsigned int *out)
{
	struct mmc_boot_command cmd;
	unsigned int mmc_ret = MMC_BOOT_E_SUCCESS;
	unsigned int mmc_reg = 0;
	mmc_reg = readl(MMC_BOOT_MCI_CLK);
	mmc_reg |= MMC_BOOT_MCI_CLK_ENA_FLOW;
	writel(mmc_reg, MMC_BOOT_MCI_CLK);
	mmc_reg = 0xFFFFFFFF;
	writel(mmc_reg, MMC_BOOT_MCI_DATA_TIMER);
	writel(data_len, MMC_BOOT_MCI_DATA_LENGTH);
	mmc_reg =
	    MMC_BOOT_MCI_DATA_ENABLE | MMC_BOOT_MCI_DATA_DIR | (data_len <<
								MMC_BOOT_MCI_BLKSIZE_POS);
#if MMC_BOOT_ADM
	mmc_reg |= MMC_BOOT_MCI_DATA_DM_ENABLE;
#endif
	writel(mmc_reg, MMC_BOOT_MCI_DATA_CTL);
	memset((struct mmc_boot_command *)&cmd, 0,
	       sizeof(struct mmc_boot_command));
	cmd.cmd_index = command;
	cmd.argument = addr;
	cmd.cmd_type = MMC_BOOT_CMD_ADDRESS;
	cmd.resp_type = MMC_BOOT_RESP_R1;
	mmc_ret = mmc_boot_send_command(&cmd);
	if (mmc_ret != MMC_BOOT_E_SUCCESS) {
		return mmc_ret;
	}
	mmc_ret =
	    mmc_boot_fifo_data_transfer(out, data_len, MMC_BOOT_DATA_READ);
	if (mmc_ret != MMC_BOOT_E_SUCCESS) {
		dprintf(CRITICAL, "Error No.%d: Failure on data transfer from the \
                Card(RCA:%x)\n", mmc_ret,
			card->rca);
		return mmc_ret;
	}
	return MMC_BOOT_E_SUCCESS;
}
static unsigned int mmc_boot_read_reg ( struct mmc_boot_card * card , unsigned int data_len , unsigned int command , unsigned int addr , unsigned int * out ) { struct mmc_boot_command cmd ; unsigned int mmc_ret = MMC_BOOT_E_SUCCESS ; unsigned int mmc_reg = 0 ; mmc_reg = readl ( MMC_BOOT_MCI_CLK ) ; mmc_reg |= MMC_BOOT_MCI_CLK_ENA_FLOW ; writel ( mmc_reg , MMC_BOOT_MCI_CLK ) ; mmc_reg = 0xFFFFFFFF ; writel ( mmc_reg , MMC_BOOT_MCI_DATA_TIMER ) ; writel ( data_len , MMC_BOOT_MCI_DATA_LENGTH ) ; mmc_reg = MMC_BOOT_MCI_DATA_ENABLE | MMC_BOOT_MCI_DATA_DIR | ( data_len << MMC_BOOT_MCI_BLKSIZE_POS ) ; #if MMC_BOOT_ADM mmc_reg |= MMC_BOOT_MCI_DATA_DM_ENABLE ; #endif writel ( mmc_reg , MMC_BOOT_MCI_DATA_CTL ) ; memset ( ( struct mmc_boot_command * ) & cmd , 0 , sizeof ( struct mmc_boot_command ) ) ; cmd . cmd_index = command ; cmd . argument = addr ; cmd . cmd_type = MMC_BOOT_CMD_ADDRESS ; cmd . resp_type = MMC_BOOT_RESP_R1 ; mmc_ret = mmc_boot_send_command ( & cmd ) ; if ( mmc_ret != MMC_BOOT_E_SUCCESS ) { return mmc_ret ; } mmc_ret = mmc_boot_fifo_data_transfer ( out , data_len , MMC_BOOT_DATA_READ ) ; if ( mmc_ret != MMC_BOOT_E_SUCCESS ) { dprintf ( CRITICAL , " \
 \n " , mmc_ret , card -> rca ) ; return mmc_ret ; } return MMC_BOOT_E_SUCCESS ; }
Function to read registers from MMC or SD card
Function to read registers from MMC or SD card
/* Set the FLOW_ENA bit of MCI_CLK register to 1 */ /* Write data timeout period to MCI_DATA_TIMER register. */ /* Data timeout period should be in card bus clock periods */ /* Set appropriate fields and write the MCI_DATA_CTL register. */ /* Set ENABLE bit to 1 to enable the data transfer. */ /* send command */ /* Read the transfer data from SDCC FIFO. */