Example #1
0
static int mmc_sdio_init_card(struct mmc_host *host)
{
	int i = 0, ret = 0;
	__u32  rocr;

	ret = mmc_io_rw_direct(host, 1, 0, 6, 8, NULL);
	for (i = 0; i < 10; i++) {
		ret = mmc_send_io_op_cond(host, 0, &rocr);
		if (!(host->resp[0] & (7 << 28)))
			return -1;

		ret = mmc_send_io_op_cond(host, rocr, &rocr);

		if (host->resp[0] & 0x80000000)
			break;
	}

	ret = mmc_set_relative_addr(host);

	DPRINT("rca = %d\n", host->card.rca);

	ret = mmc_select_card(host);

	ret = sdio_read_cccr(host);

	ret = sdio_read_cis(host);

	return ret;
}
Example #2
0
/*
 * Handle the detection and initialisation of a card.
 *
 * In the case of a resume, "oldcard" will contain the card
 * we're trying to reinitialise.
 */
static int32 mmc_sdio_init_card(void *card)
{
    SDM_CARD_INFO*   pCard;
    int              err = SDC_SUCCESS;

    pCard = (SDM_CARD_INFO*)card;

	/*
	 * Sanity check the voltages that the card claims to support.
	 */
	if (pCard->ocr & 0xFF) 
		pCard->ocr &= ~0xFF;

	/*
	 * Inform the card of the voltage
	 */
	err = mmc_send_io_op_cond(card, pCard->ocr&USER_SUPPORT_VOLTAGE, NULL);
	if (err)
	    goto remove;
	    
	/*
	 * For native busses:  set card RCA and quit open drain mode.
	 */
	err = mmc_send_relative_addr(card, NULL);
	if (err)
		goto remove;

	/*
	 * Select card, as all following commands rely on that.
	 */
	err = mmc_select_card(card, NULL);
	if (err)
		goto remove;

	/*
	* Read the common registers.
	*/
	err = sdio_read_cccr(card);
	if (err)
	    goto remove;

	/*
	 * Read the common CIS tuples.
	 */
	err = sdio_read_common_cis(card);
	if (err)
		goto remove;

	/*
	 * If needed, disconnect card detection pull-up resistor.
	 */
	err = sdio_disable_cd(card);
	if (err)
		goto remove;

	/*
	 * Switch to high-speed (if supported).
	 * err == 0/1 [not]support high speed.
	 */
	err = sdio_enable_hs(card);
	if (err > 0)
		mmc_card_set_highspeed(pCard); // success to enable high speed. 
	else if (err)
		goto remove;
	
	/*
	 * Change to the card's maximum speed.
	 */
    err = SDIOC_UpdateFreq(pCard->SDCPort, SD_FPP_FREQ);//SD_FPP_FREQ SDHC_FPP_FREQ
    if (SDC_SUCCESS != err)
        goto remove;
	
    pCard->TranSpeed = SD_FPP_FREQ;
    pCard->WorkMode |= SDM_HIGH_SPEED_MODE;

	/*
	* Switch to wider bus (if supported).
	*/
	err = sdio_enable_4bit_bus(card);
	if (err > 0)
		; //success to switch 4 bits wide.
	else if (err)
		goto remove;
	
	return 0;

remove:
	return err;
}