xref: /openbmc/u-boot/doc/README.atmel_mci (revision daab59ac)
11592ef85SReinhard MeyerHow to use SD/MMC cards with Atmel SoCs having MCI hardware
21592ef85SReinhard Meyer-----------------------------------------------------------
31592ef85SReinhard Meyer2010-08-16 Reinhard Meyer <reinhard.meyer@emk-elektronik.de>
41592ef85SReinhard Meyer
51592ef85SReinhard MeyerThis is a new approach to use Atmel MCI hardware with the
61592ef85SReinhard Meyergeneral MMC framework. Therefore it benefits from that
71592ef85SReinhard Meyerframework's abilities to handle SDHC Cards and the ability
81592ef85SReinhard Meyerto write blocks.
91592ef85SReinhard Meyer
101592ef85SReinhard Meyer- AT91SAM9XE512 (tested, will definitely work with XE128 and XE256)
111592ef85SReinhard Meyer- AT91SAM9260 (not tested, but MCI is to AT91SAM9XE)
121592ef85SReinhard Meyer- AT91SAM9G20 (not tested, should work)
131592ef85SReinhard Meyer
14*daab59acSAndy ShevchenkoIt should work with all other ATMEL devices that have MCI.
151592ef85SReinhard Meyer
161592ef85SReinhard MeyerThe generic driver does NOT assign port pins to the MCI block
171592ef85SReinhard Meyernor does it start the MCI clock. This has to be handled in a
181592ef85SReinhard Meyerboard/SoC specific manner before the driver is initialized:
191592ef85SReinhard Meyer
201592ef85SReinhard Meyerexample: this is added to at91sam9260_devices.c:
211592ef85SReinhard Meyer
22c9abb426SSven Schnelle#if defined(CONFIG_GENERIC_ATMEL_MCI)
231592ef85SReinhard Meyervoid at91_mci_hw_init(void)
241592ef85SReinhard Meyer{
251592ef85SReinhard Meyer	at91_set_a_periph(AT91_PIO_PORTA, 8, PUP);	/* MCCK */
261592ef85SReinhard Meyer#if defined(CONFIG_ATMEL_MCI_PORTB)
271592ef85SReinhard Meyer	at91_set_b_periph(AT91_PIO_PORTA, 1, PUP);	/* MCCDB */
281592ef85SReinhard Meyer	at91_set_b_periph(AT91_PIO_PORTA, 0, PUP);	/* MCDB0 */
291592ef85SReinhard Meyer	at91_set_b_periph(AT91_PIO_PORTA, 5, PUP);	/* MCDB1 */
301592ef85SReinhard Meyer	at91_set_b_periph(AT91_PIO_PORTA, 4, PUP);	/* MCDB2 */
311592ef85SReinhard Meyer	at91_set_b_periph(AT91_PIO_PORTA, 3, PUP);	/* MCDB3 */
321592ef85SReinhard Meyer#else
331592ef85SReinhard Meyer	at91_set_a_periph(AT91_PIO_PORTA, 7, PUP);	/* MCCDA */
341592ef85SReinhard Meyer	at91_set_a_periph(AT91_PIO_PORTA, 6, PUP);	/* MCDA0 */
351592ef85SReinhard Meyer	at91_set_a_periph(AT91_PIO_PORTA, 9, PUP);	/* MCDA1 */
361592ef85SReinhard Meyer	at91_set_a_periph(AT91_PIO_PORTA, 10, PUP);	/* MCDA2 */
371592ef85SReinhard Meyer	at91_set_a_periph(AT91_PIO_PORTA, 11, PUP);	/* MCDA3 */
381592ef85SReinhard Meyer#endif
391592ef85SReinhard Meyer}
401592ef85SReinhard Meyer#endif
411592ef85SReinhard Meyer
421592ef85SReinhard Meyerthe board specific file need added:
431592ef85SReinhard Meyer...
441592ef85SReinhard Meyer#ifdef CONFIG_GENERIC_ATMEL_MCI
451592ef85SReinhard Meyer# include <mmc.h>
461592ef85SReinhard Meyer#endif
471592ef85SReinhard Meyer...
481592ef85SReinhard Meyer#ifdef CONFIG_GENERIC_ATMEL_MCI
491592ef85SReinhard Meyer/* this is a weak define that we are overriding */
501592ef85SReinhard Meyerint board_mmc_init(bd_t *bd)
511592ef85SReinhard Meyer{
521592ef85SReinhard Meyer	/* Enable clock */
531592ef85SReinhard Meyer	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_MCI);
541592ef85SReinhard Meyer	at91_mci_hw_init();
551592ef85SReinhard Meyer
561592ef85SReinhard Meyer	/* This calls the atmel_mci_init in gen_atmel_mci.c */
571592ef85SReinhard Meyer	return atmel_mci_init((void *)AT91_BASE_MCI);
581592ef85SReinhard Meyer}
591592ef85SReinhard Meyer
601592ef85SReinhard Meyer/* this is a weak define that we are overriding */
61314284b1SThierry Redingint board_mmc_getcd(struct mmc *mmc)
621592ef85SReinhard Meyer{
63314284b1SThierry Reding	return !at91_get_gpio_value(CONFIG_SYS_MMC_CD_PIN);
641592ef85SReinhard Meyer}
651592ef85SReinhard Meyer
661592ef85SReinhard Meyer#endif
671592ef85SReinhard Meyer
681592ef85SReinhard Meyerand the board definition files needs:
691592ef85SReinhard Meyer
701592ef85SReinhard Meyer/* SD/MMC card */
711592ef85SReinhard Meyer#define CONFIG_GENERIC_ATMEL_MCI	1
721592ef85SReinhard Meyer#define CONFIG_ATMEL_MCI_PORTB		1	/* Atmel XE-EK uses port B */
731592ef85SReinhard Meyer#define CONFIG_SYS_MMC_CD_PIN		AT91_PIN_PC9
741592ef85SReinhard Meyer#define CONFIG_CMD_MMC			1
75