Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support
Dear Schleifer, Alexander, > Hello Reinhard, > > thanks for your reply. > I checked the register settings and sorted out, that the SDCBUS was > initialized in 4-bit mode by the bootstrap. > > So I added the explicit initialization when port A is used: > > #if defined(CONFIG_ATMEL_MCI_PORTB) > mmci_writel(SDCR, (MMCI_BF(SCDSEL, 1) > | MMCI_BF(SCDBUS, 0))); > #else > mmci_writel(SDCR, (MMCI_BF(SCDSEL, 0) > | MMCI_BF(SCDBUS, 0))); > #endif Arghh, thats why getting the "geometry" worked, but not a block read. And you were right, the new driver would have handled that correctly :) Since currently the new driver is among the "newest" in my series of changes here, I'll have to try to rebase to get it to the "oldest" position. Reinhard ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support
Hello Reinhard, thanks for your reply. I checked the register settings and sorted out, that the SDCBUS was initialized in 4-bit mode by the bootstrap. So I added the explicit initialization when port A is used: #if defined(CONFIG_ATMEL_MCI_PORTB) mmci_writel(SDCR, (MMCI_BF(SCDSEL, 1) | MMCI_BF(SCDBUS, 0))); #else mmci_writel(SDCR, (MMCI_BF(SCDSEL, 0) | MMCI_BF(SCDBUS, 0))); #endif Best regards, Alex -Original Message- From: Reinhard Meyer [mailto:u-b...@emk-elektronik.de] Sent: Montag, 16. August 2010 12:16 To: Schleifer, Alexander Cc: u-boot@lists.denx.de Subject: Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support Dear Schleifer, Alexander, > But I found out, that the AT91Bootstrap initialization impacts the U-Boot code. If I use the AT91Bootstrap (without mci initialization) from NAND flash, the mmc init command successfully reads the card. It fails if I use the AT91Bootstrap with mci initialization. That's unlikely (it has the same init sequences)... Do you have at91_mci_hw_init(void) in your at91sam_devices.c and do you call that function from your board init? Can you list me what that bootstrap does initialize differently if mci is enabled? Best Regards, Reinhard ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support
Dear Reinhard Meyer, In message <4c691822.8050...@emk-elektronik.de> you wrote: > > > Please fix your mailer. Your quoting is seriously broken! > No, its not. I manually added breaks to that line because it was not > wrapped at all - and I did not bother to add extra ">"s. I wrote "Your quoting is seriously broken", and indeed it is ;-) I was just polite enough to blame it on your mailer... Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de The only time the world beats a path to your door is when you are in the bathroom. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support
Wolfgang Denk wrote: > Dear Reinhard Meyer, > > In message <4c690fec.6040...@emk-elektronik.de> you wrote: >> Dear Schleifer, Alexander, >>> But I found out, that the AT91Bootstrap initialization impacts >> the U-Boot code. If I use the AT91Bootstrap (without mci initialization) >> >> from NAND flash, the mmc init command successfully reads the card. >> >> It fails if I use the AT91Bootstrap with mci initialization. >> >> That's unlikely (it has the same init sequences)... >> >> Do you have at91_mci_hw_init(void) in your at91sam_devices.c >> and do you call that function from your board init? > > Please fix your mailer. Your quoting is seriously broken! No, its not. I manually added breaks to that line because it was not wrapped at all - and I did not bother to add extra ">"s. Reinhard ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support
Dear Reinhard Meyer, In message <4c690fec.6040...@emk-elektronik.de> you wrote: > Dear Schleifer, Alexander, > > But I found out, that the AT91Bootstrap initialization impacts > > the U-Boot code. If I use the AT91Bootstrap (without mci initialization) > > from NAND flash, the mmc init command successfully reads the card. > > It fails if I use the AT91Bootstrap with mci initialization. > > That's unlikely (it has the same init sequences)... > > Do you have at91_mci_hw_init(void) in your at91sam_devices.c > and do you call that function from your board init? Please fix your mailer. Your quoting is seriously broken! Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de The optimum committee has no members. - Norman Augustine ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support
Dear Schleifer, Alexander, > But I found out, that the AT91Bootstrap initialization impacts the U-Boot code. If I use the AT91Bootstrap (without mci initialization) from NAND flash, the mmc init command successfully reads the card. It fails if I use the AT91Bootstrap with mci initialization. That's unlikely (it has the same init sequences)... Do you have at91_mci_hw_init(void) in your at91sam_devices.c and do you call that function from your board init? Can you list me what that bootstrap does initialize differently if mci is enabled? Best Regards, Reinhard ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support
Hi Eric, Thanks for your reply. I sorted out, that the AT91Bootstrap impacts the U-Boot. See http://lists.denx.de/pipermail/u-boot/2010-August/075646.html. I am using a hardware which is based on the EK board from Atmel and I will try out the new driver patch from Reinhard to see if it helps me out. Best regards, Alex -Original Message- From: Xu, Hong [mailto:hong...@atmel.com] Sent: Monday, August 16, 2010 4:04 AM To: Schleifer, Alexander Cc: u-boot@lists.denx.de; u-b...@emk-elektronik.de Subject: RE: [U-Boot] [PATCH v2a] AT91: add SD/MMC support Hi Alex, Thanks to Reinhard, his previous work does well on SAM9260 SAM9G20 SAM9XE SAM9RL (I tested all of them). Since he said he'll provide a more fancy one, I'm just on hold :-) For your issue, could you try (If you're using the original EK board from Atmel) Remove R42 - or - In at91_mci_hw_init() @ arch/arm/cpu/arm926ejs/at91/at91sam9260_devices.c , Add a line at91_set_pio_input(AT91_PIO_PORTA, 2, 0); This will let the CLK line of dataflash appear high resistance state. (By default, the CLK line of dataflash and SD slot are connected together by a 0R resistor) BR, Eric > -Original Message- > From: u-boot-boun...@lists.denx.de > [mailto:u-boot-boun...@lists.denx.de] On Behalf Of asc0 > Sent: 2010?8?13? 18:19 > To: u-boot@lists.denx.de > Subject: Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support > > > Hello! I have successfully applied your patch on a > AT91SAM9G20 cpu and it reads the correct CID & CSD info. > At the end of initialization the bread function fails with the > following > error: > > mmc: bread failed, status = 0040c0e5, card status = 0900 > > Does someone else received this error or have a hint on this error > message? > > Thanks, > Alex > -- > View this message in context: > http://old.nabble.com/-U-Boot---PATCH--AT91SAM9260-9XE%3A-add- > support-for-MultiMedia-Card-Interface-%28MCI%29-tp29068839p294 > 27373.html > Sent from the Uboot - Users mailing list archive at Nabble.com. > > ___ > U-Boot mailing list > U-Boot@lists.denx.de > http://lists.denx.de/mailman/listinfo/u-boot > ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support
The clock messages are .. mmc: bus_hz is 99072000, setting clock 15 Hz, block size 512 mmc: requested clock 15 is too low; changed to 193500 But I found out, that the AT91Bootstrap initialization impacts the U-Boot code. If I use the AT91Bootstrap (without mci initialization) from NAND flash, the mmc init command successfully reads the card. It fails if I use the AT91Bootstrap with mci initialization. The new driver may help me out of this - so I would be happy to test your patch ;) Best Regards, Alex -Original Message- From: Reinhard Meyer [mailto:u-b...@emk-elektronik.de] Sent: Friday, August 13, 2010 8:32 PM To: Schleifer, Alexander Cc: u-boot@lists.denx.de Subject: Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support Dear Schleifer, Alexander, > Thanks for your reply... > > The CID part is: > mmc: response: 1a50514d 53202020 1018301a ec007b8b > Manufacturer ID: 1A > OEM/Application ID:5051 > Product name: MS > Product Revision: 1.0 > Product Serial Number: 405805804 > Manufacturing Date:07/11 > > The CSD part is: > mmc: response: 005e0032 5f5983cf edb6ff87 9640003f raw CSD data: > 005e0032 5f5983cf edb6ff87 9640003f Read block length: 512 > (Supports partial reads) > Card capacity: 244 Mbytes > Warning: Using maximum data timeout > mmc: Using 983040 cycles data timeout (DTOR=0x7f) I miss the clock messages here. Whats the MCK and which divider is calculated? > mmc: bread failed, status = 0040c0e5, card status = 0900 0040c0e5= DTOE=1(data time out error) TXBUFE=1 RXBUFF=1(rx buffer full) and other bits That seems to me like some timing problem, or a hardware problem, where reading data with slow clock (used to get CID/CSD) works, but reading at several MHz (depending on card) does not work. Besides the clock calculation in this driver rounds the divider down, so on a typical system a 25MHz card will receive a 48 MHz clock instead of a 24 MHz. I figured this out while testing the new driver... If you really want to bother with this now old driver use this excerpt from the new driver: debug("mci: bus_hz is %u, setting clock %u Hz, block size %u\n", bus_hz, hz, blklen); if (hz > 0) { /* find lowest clkdiv yielding a rate <= than requested */ for (clkdiv=0; clkdiv<255; clkdiv++) { if ((bus_hz / (clkdiv+1) / 2) <= hz) break; } } printf("mci: setting clock %u Hz, block size %u\n", (bus_hz / (clkdiv+1)) / 2, blklen); If you have two days patience, wait for the new driver, I will be most happy to have a tester ;) Best Regards, Reinhard ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support
Hi Alex, Thanks to Reinhard, his previous work does well on SAM9260 SAM9G20 SAM9XE SAM9RL (I tested all of them). Since he said he'll provide a more fancy one, I'm just on hold :-) For your issue, could you try (If you're using the original EK board from Atmel) Remove R42 - or - In at91_mci_hw_init() @ arch/arm/cpu/arm926ejs/at91/at91sam9260_devices.c , Add a line at91_set_pio_input(AT91_PIO_PORTA, 2, 0); This will let the CLK line of dataflash appear high resistance state. (By default, the CLK line of dataflash and SD slot are connected together by a 0R resistor) BR, Eric > -Original Message- > From: u-boot-boun...@lists.denx.de > [mailto:u-boot-boun...@lists.denx.de] On Behalf Of asc0 > Sent: 2010?8?13? 18:19 > To: u-boot@lists.denx.de > Subject: Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support > > > Hello! I have successfully applied your patch on a > AT91SAM9G20 cpu and it reads the correct CID & CSD info. > At the end of initialization the bread function fails with > the following > error: > > mmc: bread failed, status = 0040c0e5, card status = 0900 > > Does someone else received this error or have a hint on this > error message? > > Thanks, > Alex > -- > View this message in context: > http://old.nabble.com/-U-Boot---PATCH--AT91SAM9260-9XE%3A-add- > support-for-MultiMedia-Card-Interface-%28MCI%29-tp29068839p294 > 27373.html > Sent from the Uboot - Users mailing list archive at Nabble.com. > > ___ > U-Boot mailing list > U-Boot@lists.denx.de > http://lists.denx.de/mailman/listinfo/u-boot > ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support
Dear Schleifer, Alexander, > If you have two days patience, wait for the new driver, I will be > most happy to have a tester ;) TOP9000> mmci mci: setting clock 194000 Hz, block size 512 mci: setting clock 24832000 Hz, block size 512 mci: setting clock 194000 Hz, block size 512 mci: setting clock 194000 Hz, block size 512 mci: setting clock 24832000 Hz, block size 512 Device: mci Manufacturer ID: 3 OEM: 5344 Name: SD32G Tran Speed: 2500 Rd Block Len: 512 SD version 2.0 High Capacity: Yes < SDHC Capacity: 31914983424 32 GB !!! Bus Width: 4-bit TOP9000> mmc read mci 2100 3b7 100 MMC read: dev # 0, block # 62324736, count 256 ... mci: setting clock 194000 Hz, block size 512 mci: setting clock 24832000 Hz, block size 512 mci: setting clock 194000 Hz, block size 512 mci: setting clock 194000 Hz, block size 512 mci: setting clock 24832000 Hz, block size 512 256 blocks read: OK TOP9000> mmc read mci 0 3b7 100 MMC read: dev # 0, block # 62324736, count 256 ... mci: setting clock 194000 Hz, block size 512 mci: setting clock 24832000 Hz, block size 512 mci: setting clock 194000 Hz, block size 512 mci: setting clock 194000 Hz, block size 512 mci: setting clock 24832000 Hz, block size 512 256 blocks read: OK fatls, however fails, probably cannot handle 32 Gigs :) (fatls works with a SDHC card with 4 Gigs) Once my other question pertaining to *.h files is answered, I can supply the driver as a patch. Reinhard ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support
Dear Schleifer, Alexander, > Thanks for your reply... > > The CID part is: > mmc: response: 1a50514d 53202020 1018301a ec007b8b > Manufacturer ID: 1A > OEM/Application ID:5051 > Product name: MS > Product Revision: 1.0 > Product Serial Number: 405805804 > Manufacturing Date:07/11 > > The CSD part is: > mmc: response: 005e0032 5f5983cf edb6ff87 9640003f > raw CSD data: 005e0032 5f5983cf edb6ff87 9640003f > Read block length: 512 > (Supports partial reads) > Card capacity: 244 Mbytes > Warning: Using maximum data timeout > mmc: Using 983040 cycles data timeout (DTOR=0x7f) I miss the clock messages here. Whats the MCK and which divider is calculated? > mmc: bread failed, status = 0040c0e5, card status = 0900 0040c0e5= DTOE=1(data time out error) TXBUFE=1 RXBUFF=1(rx buffer full) and other bits That seems to me like some timing problem, or a hardware problem, where reading data with slow clock (used to get CID/CSD) works, but reading at several MHz (depending on card) does not work. Besides the clock calculation in this driver rounds the divider down, so on a typical system a 25MHz card will receive a 48 MHz clock instead of a 24 MHz. I figured this out while testing the new driver... If you really want to bother with this now old driver use this excerpt from the new driver: debug("mci: bus_hz is %u, setting clock %u Hz, block size %u\n", bus_hz, hz, blklen); if (hz > 0) { /* find lowest clkdiv yielding a rate <= than requested */ for (clkdiv=0; clkdiv<255; clkdiv++) { if ((bus_hz / (clkdiv+1) / 2) <= hz) break; } } printf("mci: setting clock %u Hz, block size %u\n", (bus_hz / (clkdiv+1)) / 2, blklen); If you have two days patience, wait for the new driver, I will be most happy to have a tester ;) Best Regards, Reinhard ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support
Thanks for your reply... The CID part is: mmc: response: 1a50514d 53202020 1018301a ec007b8b Manufacturer ID: 1A OEM/Application ID:5051 Product name: MS Product Revision: 1.0 Product Serial Number: 405805804 Manufacturing Date:07/11 The CSD part is: mmc: response: 005e0032 5f5983cf edb6ff87 9640003f raw CSD data: 005e0032 5f5983cf edb6ff87 9640003f Read block length: 512 (Supports partial reads) Card capacity: 244 Mbytes Warning: Using maximum data timeout mmc: Using 983040 cycles data timeout (DTOR=0x7f) ... MCI_DTOR = 007f ... mmc: bread failed, status = 0040c0e5, card status = 0900 ... The maximum data timeout is set hard-coded for testing purposes because the bread status has the DTOE bit set. I have also tried a 2GB SD card (no SDHC) with the same error and status code. Best regards, Alexander -Original Message- From: Reinhard Meyer [mailto:u-b...@emk-elektronik.de] Sent: Friday, August 13, 2010 1:17 PM To: Schleifer, Alexander Cc: u-boot@lists.denx.de Subject: Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support asc0 wrote: > Hello! I have successfully applied your patch on a AT91SAM9G20 cpu and > it reads the correct CID & CSD info. > At the end of initialization the bread function fails with the > following > error: > > mmc: bread failed, status = 0040c0e5, card status = 0900 > > Does someone else received this error or have a hint on this error message? a) it works fine on ATNGW100 and AT91SAM9XE-EK. Have you tried other cards? The driver will not work with SDHC cards or cards that do not allow partial reads. Maybe supply us here with the CID and CSD output from the driver. b) that driver has become obsolete now... A few days ago I managed to get the mmc framework based driver originally by Rob Emanuele running. That one can deal with large cards (still have to test that, a 32GB card is in the mail to me). During the weekend I might post a first patch of that to the list. Best Regards, Reinhard ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support
asc0 wrote: > Hello! I have successfully applied your patch on a AT91SAM9G20 cpu and it > reads the correct CID & CSD info. > At the end of initialization the bread function fails with the following > error: > > mmc: bread failed, status = 0040c0e5, card status = 0900 > > Does someone else received this error or have a hint on this error message? a) it works fine on ATNGW100 and AT91SAM9XE-EK. Have you tried other cards? The driver will not work with SDHC cards or cards that do not allow partial reads. Maybe supply us here with the CID and CSD output from the driver. b) that driver has become obsolete now... A few days ago I managed to get the mmc framework based driver originally by Rob Emanuele running. That one can deal with large cards (still have to test that, a 32GB card is in the mail to me). During the weekend I might post a first patch of that to the list. Best Regards, Reinhard ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support
Hello! I have successfully applied your patch on a AT91SAM9G20 cpu and it reads the correct CID & CSD info. At the end of initialization the bread function fails with the following error: mmc: bread failed, status = 0040c0e5, card status = 0900 Does someone else received this error or have a hint on this error message? Thanks, Alex -- View this message in context: http://old.nabble.com/-U-Boot---PATCH--AT91SAM9260-9XE%3A-add-support-for-MultiMedia-Card-Interface-%28MCI%29-tp29068839p29427373.html Sent from the Uboot - Users mailing list archive at Nabble.com. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support
Disregard this patch, please. I found a better solution based on Rob Emanuele's work, it will be presented as a patch soon. Reinhard ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support
Xu, Hong wrote: > Hi Reinhard, > > In Linux, I used `fdisk' to cerate 2 primiary partitions on SD card, each is > about 1G bytes. > I used `mkfs.ext2 /dev/sdc1' and 'mkfs.ext2 /dev/sd2' to format the 2 > partitions and then copy some files on them. > > I used SanDisk 2GB SD Card. > > > But in U-Boot, > > 8< > U-Boot> mmc init > mmc: requested clock 15 is too low; changed to 194000 > Manufacturer ID: 03 > OEM/Application ID:5344 > Product name: SD02G > Product Revision: 8.0 > Product Serial Number: 27337763 > Manufacturing Date:09/12 > SD Card detected (RCA 43690) > raw CSD data: 00260032 5f5a83ae fefbcfff 928040df > Read block length: 1024 > (Supports partial reads) > Card capacity: 1884 Mbytes > mmc: Using 131072 cycles data timeout (DTOR=0x62) > mmc: blocksize reduced to 512, number of blocks: 3862528 > mmc1 is available > U-Boot> ext2ls mmc 0 > bad MBR sector signature 0x > ** Bad partition - mmc 0:1 ** > U-Boot> ext2ls mmc 1 > bad MBR sector signature 0x > ** Bad partition - mmc 1:1 ** The number before the ":" is irrelevant (with this driver), after the ":" is the partition number. So anything:1 would be like /dev/sda1. I can't test right now (not in the office) but it seems that a proper mbr is required. You killed that when zeroing the card. Not sure right now how you get that back under LinuX (win: fdisk /mbr) And please replies to the list as well. Reinhard ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2a] AT91: add SD/MMC support
Xu, Hong wrote: > Hi Reinhard, > To format the SD card, I did following > 8< > # dd if=/dev/zero of=/dev/sdc bs=512 count=10 > # mke2fs /dev/sdc > # mount /dev/sdc /mnt/ext2disk > # '' copy some files to /mnt/ext2disk > 8< > > I guess you tested fatls or fatload or fatinfo or ext2ls, could you give me a > hint why I failed with 'ext2ls'? /dev/sdc is the whole card, not a partition on it. I tested with a proper partitioned card (/dev/sdc1 under LinuX). Reinhard ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2a] AT91: add SD/MMC support
This patch adds support for the Atmel MultiMedia Card Interface (MCI) in AT91SAM9260 and AT91SAM9XE SoCs and preserves the original support for the AVR32AP700x SoCs. It patches the original atmel_mci.c driver to remove byte order and toolchain dependencies and makes it a common MCI driver for Atmels AVR32AP7000 and AT91SAM9260 based SoCs. The driver itself is not specific to those SoCs and should work with other Atmel devices having an identical MultiMedia Card Interface (MCI), provided the functions get_mci_clk_rate() and _mci_hw_init() are defined. Tested on AT91SAM9XE-EK (AT91SAM9XE512) Tested on ATNGW100 (AVR32AP7000) Signed-off-by: Reinhard Meyer --- Sorry, my mouse slipped and sent v2 prematurely :) arch/arm/cpu/arm926ejs/at91/at91sam9260_devices.c | 20 +++ arch/arm/include/asm/arch-at91/at91_common.h |1 + arch/arm/include/asm/arch-at91/clk.h |5 + arch/arm/include/asm/arch-at91/hardware.h |1 + doc/README.atmel_mci | 68 +++ drivers/mmc/atmel_mci.c | 134 ++--- drivers/mmc/atmel_mci.h |6 +- include/mmc.h | 93 +-- 8 files changed, 217 insertions(+), 111 deletions(-) create mode 100644 doc/README.atmel_mci diff --git a/arch/arm/cpu/arm926ejs/at91/at91sam9260_devices.c b/arch/arm/cpu/arm926ejs/at91/at91sam9260_devices.c index 77d49ab..9cef832 100644 --- a/arch/arm/cpu/arm926ejs/at91/at91sam9260_devices.c +++ b/arch/arm/cpu/arm926ejs/at91/at91sam9260_devices.c @@ -194,3 +194,23 @@ void at91_macb_hw_init(void) #endif } #endif + +#ifdef CONFIG_ATMEL_MCI +void at91_mci_hw_init(void) +{ + at91_set_a_periph(AT91_PIO_PORTA, 8, 0);/* MCCK */ +#if defined(CONFIG_ATMEL_MCI_PORTB) + at91_set_b_periph(AT91_PIO_PORTA, 1, 0);/* MCCDB */ + at91_set_b_periph(AT91_PIO_PORTA, 0, 0);/* MCDB0 */ + at91_set_b_periph(AT91_PIO_PORTA, 5, 0);/* MCDB1 */ + at91_set_b_periph(AT91_PIO_PORTA, 4, 0);/* MCDB2 */ + at91_set_b_periph(AT91_PIO_PORTA, 3, 0);/* MCDB3 */ +#else + at91_set_a_periph(AT91_PIO_PORTA, 7, 0);/* MCCDA */ + at91_set_a_periph(AT91_PIO_PORTA, 6, 0);/* MCDA0 */ + at91_set_a_periph(AT91_PIO_PORTA, 9, 0);/* MCDA1 */ + at91_set_a_periph(AT91_PIO_PORTA, 10, 0); /* MCDA2 */ + at91_set_a_periph(AT91_PIO_PORTA, 11, 0); /* MCDA3 */ +#endif +} +#endif diff --git a/arch/arm/include/asm/arch-at91/at91_common.h b/arch/arm/include/asm/arch-at91/at91_common.h index 01840ee..90337eb 100644 --- a/arch/arm/include/asm/arch-at91/at91_common.h +++ b/arch/arm/include/asm/arch-at91/at91_common.h @@ -35,5 +35,6 @@ void at91_serial3_hw_init(void); void at91_spi0_hw_init(unsigned long cs_mask); void at91_spi1_hw_init(unsigned long cs_mask); void at91_uhp_hw_init(void); +void at91_mci_hw_init(void); #endif /* AT91_COMMON_H */ diff --git a/arch/arm/include/asm/arch-at91/clk.h b/arch/arm/include/asm/arch-at91/clk.h index f642dd9..457e6c9 100644 --- a/arch/arm/include/asm/arch-at91/clk.h +++ b/arch/arm/include/asm/arch-at91/clk.h @@ -59,5 +59,10 @@ static inline unsigned long get_twi_clk_rate(unsigned int dev_id) return get_mck_clk_rate(); } +static inline unsigned long get_mci_clk_rate(void) +{ + return get_mck_clk_rate(); +} + int at91_clock_init(unsigned long main_clock); #endif /* __ASM_ARM_ARCH_CLK_H__ */ diff --git a/arch/arm/include/asm/arch-at91/hardware.h b/arch/arm/include/asm/arch-at91/hardware.h index 4ddb315..224b285 100644 --- a/arch/arm/include/asm/arch-at91/hardware.h +++ b/arch/arm/include/asm/arch-at91/hardware.h @@ -23,6 +23,7 @@ #define AT91_BASE_SPI AT91SAM9260_BASE_SPI0 #define AT91_ID_UHPAT91SAM9260_ID_UHP #define AT91_PMC_UHP AT91SAM926x_PMC_UHP +#define MMCI_BASE AT91SAM9260_BASE_MCI #elif defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9G10) #include #define AT91_BASE_SPI AT91SAM9261_BASE_SPI0 diff --git a/doc/README.atmel_mci b/doc/README.atmel_mci new file mode 100644 index 000..15b3cc0 --- /dev/null +++ b/doc/README.atmel_mci @@ -0,0 +1,68 @@ +How to use SD/MMC cards with Atmel SoCs having MCI hardware +--- +2010-07-04 Reinhard Meyer + +The drivers/mmc/atmel_mci.c file which originally worked only +with the AVR32 architecture SoCs like AVR32AP700x has been +updated to also work with the AT91SAM9260 compatible architectures: + +- AT91SAM9XE512 (tested, will definitely work with XE128 and XE256) +- AT91SAM9260 (not tested, but MCI is to AT91SAM9XE) +- AT91SAM9G20 (not tested, should work) + +It should work with all other AT91SAM9 devices that have MCI +provided that a correct version of the following function is added +to their specific XXX_devices file: + +(this example is from at91sam9260_devices.c) + +#ifdef CONFIG_ATMEL_MCI +void at91_mci_h