platform/msm_shared/mmc.c
static unsigned int
mmc_boot_init_and_identify_cards(struct mmc_boot_host *host,
				 struct mmc_boot_card *card)
{
	unsigned int mmc_return = MMC_BOOT_E_SUCCESS;
	unsigned int status;

	/* Basic check */
	if (host == NULL) {
		return MMC_BOOT_E_INVAL;
	}

	/* Initialize MMC card structure */
	card->status = MMC_BOOT_STATUS_INACTIVE;
	card->rd_block_len = MMC_BOOT_RD_BLOCK_LEN;
	card->wr_block_len = MMC_BOOT_WR_BLOCK_LEN;

	/* Start initialization process (CMD0 & CMD1) */
	mmc_return = mmc_boot_init_card(host, card);
	if (mmc_return != MMC_BOOT_E_SUCCESS) {
		return mmc_return;
	}

	/* Identify (CMD2, CMD3 & CMD9) and select the card (CMD7) */
	mmc_return = mmc_boot_identify_card(host, card);
	if (mmc_return != MMC_BOOT_E_SUCCESS) {
		return mmc_return;
	}

	if (card->type == MMC_BOOT_TYPE_SDHC
	    || card->type == MMC_BOOT_TYPE_STD_SD) {
		/* Setting sD card to high speed without checking card's capability.
		   Cards that do not support high speed may fail to boot */
		mmc_return = mmc_boot_set_sd_hs(host, card);
		if (mmc_return != MMC_BOOT_E_SUCCESS) {
			return mmc_return;
		}

		mmc_return =
		    mmc_boot_set_sd_bus_width(card, MMC_BOOT_BUS_WIDTH_4_BIT);
		if (mmc_return != MMC_BOOT_E_SUCCESS) {
			dprintf(CRITICAL,
				"Couldn't set 4bit mode for sD card\n");
			mmc_return =
			    mmc_boot_set_sd_bus_width(card,
						      MMC_BOOT_BUS_WIDTH_1_BIT);
			if (mmc_return != MMC_BOOT_E_SUCCESS) {
				dprintf(CRITICAL,
					"Error No.%d: Failed in setting bus width!\n",
					mmc_return);
				return mmc_return;
			}
		}
	} else {
		/* set interface speed */
		mmc_return = mmc_boot_adjust_interface_speed(host, card);
		if (mmc_return != MMC_BOOT_E_SUCCESS) {
			dprintf(CRITICAL,
				"Error No.%d: Error adjusting interface speed!\n",
				mmc_return);
			return mmc_return;
		}

		/* enable wide bus */
		mmc_return =
		    mmc_boot_set_bus_width(card, MMC_BOOT_BUS_WIDTH_4_BIT);
		if (mmc_return != MMC_BOOT_E_SUCCESS) {
			dprintf(CRITICAL,
				"Error No.%d: Failure to set wide bus for Card(RCA:%x)\n",
				mmc_return, card->rca);
			return mmc_return;
		}
	}

	/* Just checking whether we're in TRAN state after changing speed and bus width */
	mmc_return = mmc_boot_get_card_status(card, 0, &status);
	if (mmc_return != MMC_BOOT_E_SUCCESS) {
		return mmc_return;
	}

	if (MMC_BOOT_CARD_STATUS(status) != MMC_BOOT_TRAN_STATE)
		return MMC_BOOT_E_FAILURE;

	return MMC_BOOT_E_SUCCESS;
}
/*
 * Performs initialization and identification of all the MMC cards connected
 * to the host.
 */
Performs initialization and identification of all the MMC cards connected
to the host.
Performs initialization and identification of all the MMC cards connected to the host .
static unsigned int
mmc_boot_init_and_identify_cards(struct mmc_boot_host *host,
				 struct mmc_boot_card *card)
{
	unsigned int mmc_return = MMC_BOOT_E_SUCCESS;
	unsigned int status;
	if (host == NULL) {
		return MMC_BOOT_E_INVAL;
	}
	card->status = MMC_BOOT_STATUS_INACTIVE;
	card->rd_block_len = MMC_BOOT_RD_BLOCK_LEN;
	card->wr_block_len = MMC_BOOT_WR_BLOCK_LEN;
	mmc_return = mmc_boot_init_card(host, card);
	if (mmc_return != MMC_BOOT_E_SUCCESS) {
		return mmc_return;
	}
	mmc_return = mmc_boot_identify_card(host, card);
	if (mmc_return != MMC_BOOT_E_SUCCESS) {
		return mmc_return;
	}
	if (card->type == MMC_BOOT_TYPE_SDHC
	    || card->type == MMC_BOOT_TYPE_STD_SD) {
		mmc_return = mmc_boot_set_sd_hs(host, card);
		if (mmc_return != MMC_BOOT_E_SUCCESS) {
			return mmc_return;
		}
		mmc_return =
		    mmc_boot_set_sd_bus_width(card, MMC_BOOT_BUS_WIDTH_4_BIT);
		if (mmc_return != MMC_BOOT_E_SUCCESS) {
			dprintf(CRITICAL,
				"Couldn't set 4bit mode for sD card\n");
			mmc_return =
			    mmc_boot_set_sd_bus_width(card,
						      MMC_BOOT_BUS_WIDTH_1_BIT);
			if (mmc_return != MMC_BOOT_E_SUCCESS) {
				dprintf(CRITICAL,
					"Error No.%d: Failed in setting bus width!\n",
					mmc_return);
				return mmc_return;
			}
		}
	} else {
		mmc_return = mmc_boot_adjust_interface_speed(host, card);
		if (mmc_return != MMC_BOOT_E_SUCCESS) {
			dprintf(CRITICAL,
				"Error No.%d: Error adjusting interface speed!\n",
				mmc_return);
			return mmc_return;
		}
		mmc_return =
		    mmc_boot_set_bus_width(card, MMC_BOOT_BUS_WIDTH_4_BIT);
		if (mmc_return != MMC_BOOT_E_SUCCESS) {
			dprintf(CRITICAL,
				"Error No.%d: Failure to set wide bus for Card(RCA:%x)\n",
				mmc_return, card->rca);
			return mmc_return;
		}
	}
	mmc_return = mmc_boot_get_card_status(card, 0, &status);
	if (mmc_return != MMC_BOOT_E_SUCCESS) {
		return mmc_return;
	}
	if (MMC_BOOT_CARD_STATUS(status) != MMC_BOOT_TRAN_STATE)
		return MMC_BOOT_E_FAILURE;
	return MMC_BOOT_E_SUCCESS;
}
static unsigned int mmc_boot_init_and_identify_cards ( struct mmc_boot_host * host , struct mmc_boot_card * card ) { unsigned int mmc_return = MMC_BOOT_E_SUCCESS ; unsigned int status ; if ( host == NULL ) { return MMC_BOOT_E_INVAL ; } card -> status = MMC_BOOT_STATUS_INACTIVE ; card -> rd_block_len = MMC_BOOT_RD_BLOCK_LEN ; card -> wr_block_len = MMC_BOOT_WR_BLOCK_LEN ; mmc_return = mmc_boot_init_card ( host , card ) ; if ( mmc_return != MMC_BOOT_E_SUCCESS ) { return mmc_return ; } mmc_return = mmc_boot_identify_card ( host , card ) ; if ( mmc_return != MMC_BOOT_E_SUCCESS ) { return mmc_return ; } if ( card -> type == MMC_BOOT_TYPE_SDHC || card -> type == MMC_BOOT_TYPE_STD_SD ) { mmc_return = mmc_boot_set_sd_hs ( host , card ) ; if ( mmc_return != MMC_BOOT_E_SUCCESS ) { return mmc_return ; } mmc_return = mmc_boot_set_sd_bus_width ( card , MMC_BOOT_BUS_WIDTH_4_BIT ) ; if ( mmc_return != MMC_BOOT_E_SUCCESS ) { dprintf ( CRITICAL , " \n " ) ; mmc_return = mmc_boot_set_sd_bus_width ( card , MMC_BOOT_BUS_WIDTH_1_BIT ) ; if ( mmc_return != MMC_BOOT_E_SUCCESS ) { dprintf ( CRITICAL , " \n " , mmc_return ) ; return mmc_return ; } } } else { mmc_return = mmc_boot_adjust_interface_speed ( host , card ) ; if ( mmc_return != MMC_BOOT_E_SUCCESS ) { dprintf ( CRITICAL , " \n " , mmc_return ) ; return mmc_return ; } mmc_return = mmc_boot_set_bus_width ( card , MMC_BOOT_BUS_WIDTH_4_BIT ) ; if ( mmc_return != MMC_BOOT_E_SUCCESS ) { dprintf ( CRITICAL , " \n " , mmc_return , card -> rca ) ; return mmc_return ; } } mmc_return = mmc_boot_get_card_status ( card , 0 , & status ) ; if ( mmc_return != MMC_BOOT_E_SUCCESS ) { return mmc_return ; } if ( MMC_BOOT_CARD_STATUS ( status ) != MMC_BOOT_TRAN_STATE ) return MMC_BOOT_E_FAILURE ; return MMC_BOOT_E_SUCCESS ; }
Performs initialization and identification of all the MMC cards connected
 to the host.
Performs initialization and identification of all the MMC cards connected to the host .
/* Basic check */ /* Initialize MMC card structure */ /* Start initialization process (CMD0 & CMD1) */ /* Identify (CMD2, CMD3 & CMD9) and select the card (CMD7) */ /* Setting sD card to high speed without checking card's capability.
		   Cards that do not support high speed may fail to boot */ /* set interface speed */ /* enable wide bus */ /* Just checking whether we're in TRAN state after changing speed and bus width */