Skip to content
Snippets Groups Projects
mmc.c 21.1 KiB
Newer Older
  • Learn to ignore specific revisions
  • Andy Fleming's avatar
    Andy Fleming committed
    
    
    	mmc_set_bus_width(mmc, 1);
    	mmc_set_clock(mmc, 1);
    
    
    Andy Fleming's avatar
    Andy Fleming committed
    	/* Reset the Card */
    	err = mmc_go_idle(mmc);
    
    	if (err)
    		return err;
    
    	/* Test for SD version 2 */
    	err = mmc_send_if_cond(mmc);
    
    	/* Now try to get the SD card's operating condition */
    	err = sd_send_op_cond(mmc);
    
    	/* If the command timed out, we check for an MMC card */
    	if (err == TIMEOUT) {
    		err = mmc_send_op_cond(mmc);
    
    		if (err) {
    			printf("Card did not respond to voltage select!\n");
    			return UNUSABLE_ERR;
    		}
    	}
    
    	return mmc_startup(mmc);
    }
    
    /*
     * CPU and board-specific MMC initializations.  Aliased function
     * signals caller to move on
     */
    static int __def_mmc_init(bd_t *bis)
    {
    	return -1;
    }
    
    
    int cpu_mmc_init(bd_t *bis) __attribute__((weak, alias("__def_mmc_init")));
    int board_mmc_init(bd_t *bis) __attribute__((weak, alias("__def_mmc_init")));
    
    Andy Fleming's avatar
    Andy Fleming committed
    
    void print_mmc_devices(char separator)
    {
    	struct mmc *m;
    	struct list_head *entry;
    
    	list_for_each(entry, &mmc_devices) {
    		m = list_entry(entry, struct mmc, link);
    
    		printf("%s: %d", m->name, m->block_dev.dev);
    
    		if (entry->next != &mmc_devices)
    			printf("%c ", separator);
    	}
    
    	printf("\n");
    }
    
    int mmc_initialize(bd_t *bis)
    {
    	INIT_LIST_HEAD (&mmc_devices);
    	cur_dev_num = 0;
    
    	if (board_mmc_init(bis) < 0)
    		cpu_mmc_init(bis);
    
    	print_mmc_devices(',');
    
    	return 0;
    }