Ejemplo n.º 1
0
int board_mmc_init(bd_t *bis)
{
	int ret;

	if (get_boot_mode() == BOOT_MODE_SD) {
		ret = init_mmc();
		ret |= init_dwmmc();
	} else {
		ret = init_dwmmc();
		ret |= init_mmc();
	}

	if (ret)
		debug("mmc init failed\n");

	return ret;
}
Ejemplo n.º 2
0
void mmcsd_detect(void *param)
{
    struct rt_mmcsd_host *host;
    rt_uint32_t  ocr;
    rt_int32_t  err;

    while (1) 
    {
        if (rt_mb_recv(&mmcsd_detect_mb, (rt_uint32_t*)&host, RT_WAITING_FOREVER) == RT_EOK)
        {
            if (host->card == RT_NULL)
            {
                mmcsd_host_lock(host);
                mmcsd_power_up(host);
                mmcsd_go_idle(host);

                mmcsd_send_if_cond(host, host->valid_ocr);

                err = sdio_io_send_op_cond(host, 0, &ocr);
                if (!err)
                {
                    if (init_sdio(host, ocr))
                        mmcsd_power_off(host);
                    mmcsd_host_unlock(host);
                    continue;
                }

                /*
                 * detect SD card
                 */
                err = mmcsd_send_app_op_cond(host, 0, &ocr);
                if (!err) 
                {
                    if (init_sd(host, ocr))
                        mmcsd_power_off(host);
                    mmcsd_host_unlock(host);
                    continue;
                }
                
                /*
                 * detect mmc card
                 */
                err = mmc_send_op_cond(host, 0, &ocr);
                if (!err) 
                {
                    if (init_mmc(host, ocr))
                        mmcsd_power_off(host);
                    mmcsd_host_unlock(host);
                    continue;
                }
                mmcsd_host_unlock(host);
            }
            else
            {
            	/* card removed */
            	mmcsd_host_lock(host);
            	if (host->card->sdio_function_num != 0)
            	{
            		rt_kprintf("unsupport sdio card plug out!\n");
            	}
            	else
            	{
            		rt_mmcsd_blk_remove(host->card);
            		rt_free(host->card);

            		host->card = RT_NULL;
            	}
            	mmcsd_host_unlock(host);
            }
        }
    }
}