Ejemplo n.º 1
0
static zx_status_t sdio_switch_bus_width(sdmmc_device_t *dev, uint32_t bw) {
    zx_status_t st = ZX_OK;
    if (bw != SDIO_BW_1BIT && bw != SDIO_BW_4BIT) {
        return ZX_ERR_NOT_SUPPORTED;
    }
    if (bw == SDIO_BW_4BIT) {
        if ((st = sdio_enable_4bit_bus(dev)) != ZX_OK) {
            return st;
        }
    }
    return ZX_OK;
}
Ejemplo n.º 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;
}