xref: /openbmc/u-boot/doc/README.atmel_mci (revision 314284b1)
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
141592ef85SReinhard MeyerIt should work with all other ATMEL devices that have MCI,
151592ef85SReinhard Meyerincluding AVR32.
161592ef85SReinhard Meyer
171592ef85SReinhard MeyerThe generic driver does NOT assign port pins to the MCI block
181592ef85SReinhard Meyernor does it start the MCI clock. This has to be handled in a
191592ef85SReinhard Meyerboard/SoC specific manner before the driver is initialized:
201592ef85SReinhard Meyer
211592ef85SReinhard Meyerexample: this is added to at91sam9260_devices.c:
221592ef85SReinhard Meyer
231592ef85SReinhard Meyer#if defined(CONFIG_ATMEL_MCI) || defined(CONFIG_GENERIC_ATMEL_MCI)
241592ef85SReinhard Meyervoid at91_mci_hw_init(void)
251592ef85SReinhard Meyer{
261592ef85SReinhard Meyer	at91_set_a_periph(AT91_PIO_PORTA, 8, PUP);	/* MCCK */
271592ef85SReinhard Meyer#if defined(CONFIG_ATMEL_MCI_PORTB)
281592ef85SReinhard Meyer	at91_set_b_periph(AT91_PIO_PORTA, 1, PUP);	/* MCCDB */
291592ef85SReinhard Meyer	at91_set_b_periph(AT91_PIO_PORTA, 0, PUP);	/* MCDB0 */
301592ef85SReinhard Meyer	at91_set_b_periph(AT91_PIO_PORTA, 5, PUP);	/* MCDB1 */
311592ef85SReinhard Meyer	at91_set_b_periph(AT91_PIO_PORTA, 4, PUP);	/* MCDB2 */
321592ef85SReinhard Meyer	at91_set_b_periph(AT91_PIO_PORTA, 3, PUP);	/* MCDB3 */
331592ef85SReinhard Meyer#else
341592ef85SReinhard Meyer	at91_set_a_periph(AT91_PIO_PORTA, 7, PUP);	/* MCCDA */
351592ef85SReinhard Meyer	at91_set_a_periph(AT91_PIO_PORTA, 6, PUP);	/* MCDA0 */
361592ef85SReinhard Meyer	at91_set_a_periph(AT91_PIO_PORTA, 9, PUP);	/* MCDA1 */
371592ef85SReinhard Meyer	at91_set_a_periph(AT91_PIO_PORTA, 10, PUP);	/* MCDA2 */
381592ef85SReinhard Meyer	at91_set_a_periph(AT91_PIO_PORTA, 11, PUP);	/* MCDA3 */
391592ef85SReinhard Meyer#endif
401592ef85SReinhard Meyer}
411592ef85SReinhard Meyer#endif
421592ef85SReinhard Meyer
431592ef85SReinhard Meyerthe board specific file need added:
441592ef85SReinhard Meyer...
451592ef85SReinhard Meyer#ifdef CONFIG_GENERIC_ATMEL_MCI
461592ef85SReinhard Meyer# include <mmc.h>
471592ef85SReinhard Meyer#endif
481592ef85SReinhard Meyer...
491592ef85SReinhard Meyer#ifdef CONFIG_GENERIC_ATMEL_MCI
501592ef85SReinhard Meyer/* this is a weak define that we are overriding */
511592ef85SReinhard Meyerint board_mmc_init(bd_t *bd)
521592ef85SReinhard Meyer{
531592ef85SReinhard Meyer	/* Enable clock */
541592ef85SReinhard Meyer	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_MCI);
551592ef85SReinhard Meyer	at91_mci_hw_init();
561592ef85SReinhard Meyer
571592ef85SReinhard Meyer	/* This calls the atmel_mci_init in gen_atmel_mci.c */
581592ef85SReinhard Meyer	return atmel_mci_init((void *)AT91_BASE_MCI);
591592ef85SReinhard Meyer}
601592ef85SReinhard Meyer
611592ef85SReinhard Meyer/* this is a weak define that we are overriding */
62*314284b1SThierry Redingint board_mmc_getcd(struct mmc *mmc)
631592ef85SReinhard Meyer{
64*314284b1SThierry Reding	return !at91_get_gpio_value(CONFIG_SYS_MMC_CD_PIN);
651592ef85SReinhard Meyer}
661592ef85SReinhard Meyer
671592ef85SReinhard Meyer#endif
681592ef85SReinhard Meyer
691592ef85SReinhard Meyerand the board definition files needs:
701592ef85SReinhard Meyer
711592ef85SReinhard Meyer/* SD/MMC card */
721592ef85SReinhard Meyer#define CONFIG_MMC			1
731592ef85SReinhard Meyer#define CONFIG_GENERIC_MMC		1
741592ef85SReinhard Meyer#define CONFIG_GENERIC_ATMEL_MCI	1
751592ef85SReinhard Meyer#define CONFIG_ATMEL_MCI_PORTB		1	/* Atmel XE-EK uses port B */
761592ef85SReinhard Meyer#define CONFIG_SYS_MMC_CD_PIN		AT91_PIN_PC9
771592ef85SReinhard Meyer#define CONFIG_CMD_MMC			1
78