platform/msm_shared/mmc.c
static unsigned int
mmc_boot_set_bus_width(struct mmc_boot_card *card, unsigned int width)
{
	unsigned int mmc_ret = MMC_BOOT_E_SUCCESS;
	unsigned int mmc_reg = 0;
	unsigned int mmc_width = 0;
	unsigned int status;
	unsigned int wait_count = 100;

	if (width != MMC_BOOT_BUS_WIDTH_1_BIT) {
		mmc_width = width - 1;
	}

	mmc_ret = mmc_boot_switch_cmd(card, MMC_BOOT_ACCESS_WRITE,
				      MMC_BOOT_EXT_CMMC_BUS_WIDTH, mmc_width);

	if (mmc_ret != MMC_BOOT_E_SUCCESS) {
		return mmc_ret;
	}

	/* Wait for the card to complete the switch command processing */
	do {
		mmc_ret = mmc_boot_get_card_status(card, 0, &status);
		if (mmc_ret != MMC_BOOT_E_SUCCESS) {
			return mmc_ret;
		}

		wait_count--;
		if (wait_count == 0) {
			return MMC_BOOT_E_FAILURE;
		}
	}
	while (MMC_BOOT_CARD_STATUS(status) == MMC_BOOT_PROG_STATE);

	/* set MCI_CLK accordingly */
	mmc_reg = readl(MMC_BOOT_MCI_CLK);
	mmc_reg &= ~MMC_BOOT_MCI_CLK_WIDEBUS_MODE;
	if (width == MMC_BOOT_BUS_WIDTH_1_BIT) {
		mmc_reg |= MMC_BOOT_MCI_CLK_WIDEBUS_1_BIT;
	} else if (width == MMC_BOOT_BUS_WIDTH_4_BIT) {
		mmc_reg |= MMC_BOOT_MCI_CLK_WIDEBUS_4_BIT;
	} else if (width == MMC_BOOT_BUS_WIDTH_8_BIT) {
		mmc_reg |= MMC_BOOT_MCI_CLK_WIDEBUS_8_BIT;
	}
	writel(mmc_reg, MMC_BOOT_MCI_CLK);

	mdelay(10);		// Giving some time to card to stabilize.

	return MMC_BOOT_E_SUCCESS;
}
/*
 * A command to set the data bus width for card. Set width to either
 */
A command to set the data bus width for card. Set width to either
A command to set the data bus width for card . Set width to either
static unsigned int
mmc_boot_set_bus_width(struct mmc_boot_card *card, unsigned int width)
{
	unsigned int mmc_ret = MMC_BOOT_E_SUCCESS;
	unsigned int mmc_reg = 0;
	unsigned int mmc_width = 0;
	unsigned int status;
	unsigned int wait_count = 100;
	if (width != MMC_BOOT_BUS_WIDTH_1_BIT) {
		mmc_width = width - 1;
	}
	mmc_ret = mmc_boot_switch_cmd(card, MMC_BOOT_ACCESS_WRITE,
				      MMC_BOOT_EXT_CMMC_BUS_WIDTH, mmc_width);
	if (mmc_ret != MMC_BOOT_E_SUCCESS) {
		return mmc_ret;
	}
	do {
		mmc_ret = mmc_boot_get_card_status(card, 0, &status);
		if (mmc_ret != MMC_BOOT_E_SUCCESS) {
			return mmc_ret;
		}
		wait_count--;
		if (wait_count == 0) {
			return MMC_BOOT_E_FAILURE;
		}
	}
	while (MMC_BOOT_CARD_STATUS(status) == MMC_BOOT_PROG_STATE);
	mmc_reg = readl(MMC_BOOT_MCI_CLK);
	mmc_reg &= ~MMC_BOOT_MCI_CLK_WIDEBUS_MODE;
	if (width == MMC_BOOT_BUS_WIDTH_1_BIT) {
		mmc_reg |= MMC_BOOT_MCI_CLK_WIDEBUS_1_BIT;
	} else if (width == MMC_BOOT_BUS_WIDTH_4_BIT) {
		mmc_reg |= MMC_BOOT_MCI_CLK_WIDEBUS_4_BIT;
	} else if (width == MMC_BOOT_BUS_WIDTH_8_BIT) {
		mmc_reg |= MMC_BOOT_MCI_CLK_WIDEBUS_8_BIT;
	}
	writel(mmc_reg, MMC_BOOT_MCI_CLK);
	mdelay(10);		
	return MMC_BOOT_E_SUCCESS;
}
static unsigned int mmc_boot_set_bus_width ( struct mmc_boot_card * card , unsigned int width ) { unsigned int mmc_ret = MMC_BOOT_E_SUCCESS ; unsigned int mmc_reg = 0 ; unsigned int mmc_width = 0 ; unsigned int status ; unsigned int wait_count = 100 ; if ( width != MMC_BOOT_BUS_WIDTH_1_BIT ) { mmc_width = width - 1 ; } mmc_ret = mmc_boot_switch_cmd ( card , MMC_BOOT_ACCESS_WRITE , MMC_BOOT_EXT_CMMC_BUS_WIDTH , mmc_width ) ; if ( mmc_ret != MMC_BOOT_E_SUCCESS ) { return mmc_ret ; } do { mmc_ret = mmc_boot_get_card_status ( card , 0 , & status ) ; if ( mmc_ret != MMC_BOOT_E_SUCCESS ) { return mmc_ret ; } wait_count -- ; if ( wait_count == 0 ) { return MMC_BOOT_E_FAILURE ; } } while ( MMC_BOOT_CARD_STATUS ( status ) == MMC_BOOT_PROG_STATE ) ; mmc_reg = readl ( MMC_BOOT_MCI_CLK ) ; mmc_reg &= ~ MMC_BOOT_MCI_CLK_WIDEBUS_MODE ; if ( width == MMC_BOOT_BUS_WIDTH_1_BIT ) { mmc_reg |= MMC_BOOT_MCI_CLK_WIDEBUS_1_BIT ; } else if ( width == MMC_BOOT_BUS_WIDTH_4_BIT ) { mmc_reg |= MMC_BOOT_MCI_CLK_WIDEBUS_4_BIT ; } else if ( width == MMC_BOOT_BUS_WIDTH_8_BIT ) { mmc_reg |= MMC_BOOT_MCI_CLK_WIDEBUS_8_BIT ; } writel ( mmc_reg , MMC_BOOT_MCI_CLK ) ; mdelay ( 10 ) ; return MMC_BOOT_E_SUCCESS ; }
A command to set the data bus width for card.
A command to set the data bus width for card .
/* Wait for the card to complete the switch command processing */ /* set MCI_CLK accordingly */ // Giving some time to card to stabilize.