summaryrefslogtreecommitdiff
path: root/drivers/mmc/mmc.c
Commit message (Collapse)AuthorAgeLines
* mmc: Fix mmc_send_status()Marek Vasut2011-09-04-1/+2
| | | | | | | | The mmc_send_status() function sets cmd.arg = 0. That's incorrect, so fix it. Signed-off-by: Marek Vasut <marek.vasut@gmail.com> Acked-by: Andy Fleming <afleming@freescale.com> Tested-by: Lei Wen <adrian.wenl@gmail.com>
* disk/part.c: Make features optionalMatthew McClintock2011-07-26-0/+2
| | | | | | | | | If we don't want to build support for any partition types we can now add #undef CONFIG_PARTITIONS in a board config file to keep this from being compiled in. Otherwise boards assume this is compiled in by default Signed-off-by: Matthew McClintock <msm@freescale.com>
* mmc: Access mode validation for eMMC cards > 2 GiBŁukasz Majewski2011-07-15-1/+5
| | | | | | | | | | | | | | | | This patch provides handling of the two way handshake when SEND_OP_COND (CMD1) is send to mmc card. It is necessary to inform eMMC card if the host can work with high capacity cards (Jedec JESD84-A441, point 7.4.3). The extra flag MMC_MODE_HC (high capacity) is added to indicate if the host is capable of handling the high capacity eMMC cards. Since this change is added to the generic mmc framework, then it requires other boards to indicate if their mmc controllers can handle high capacity cards. As it is now - the old behaviour of the framework is preserved. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> Signed-off-by: Andy Fleming <afleming@freescale.com>
* mmc: fix the condition for MMC version 4Yoshihiro Shimoda2011-07-15-4/+11
| | | | | | | | | | Fix the problem that if we use the chip of MMC version 4 and the capacity is smaller than 2GB or equal, the mmc->capacity is invalid. According to the JEDEC Standard, the value of ext_csd's capacity is valid if the value is more than 2GB. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Acked-by: Andy Fleming <afleming@freescale.com>
* MMC: add erase function to both mmc and sdLei Wen2011-07-15-0/+102
| | | | | | | | | | | Erase is a very basic function since the begin of sd specification is announced. Although we could write a bulk of full 0xff memory to the range to take place of erase, it is more convenient and safe to implement the erase function itself. Signed-off-by: Lei Wen <leiwen@marvell.com> Signed-off-by: Andy Fleming <afleming@freescale.com> Acked-by: Mike Frysinger <vapier@gentoo.org>
* Minor coding style cleanup.Wolfgang Denk2011-05-19-4/+4
| | | | Signed-off-by: Wolfgang Denk <wd@denx.de>
* mmc: enable partition switch function for emmcLei Wen2011-05-18-1/+29
| | | | | | | | | | | | | | | | | | | For emmc, it may have up to 7 partitions: two boot partitions, one user partition, one RPMB partition and four general purpose partitions. (Refer to JESD84-A44.pdf/page 154) As bootloader may need to read out or reflashing images on those different partitions, it is better to enable the partition switch with console command support. Also for partition would be restore to user partition(part 0) when CMD0 is used, so change mmc_init routine to perform normal initialization only once for each slot, unless use the rescan command to force init again. Signed-off-by: Lei Wen <leiwen@marvell.com> Acked-by: Andy Fleming <afleming@freescale.com>
* cmd_mmc: eliminate device num in the mmc commandLei Wen2011-05-18-0/+5
| | | | | | | mmc command applied device, like ide and usb... Signed-off-by: Lei Wen <leiwen@marvell.com> Acked-by: Andy Fleming <afleming@freescale.com>
* MMC: make b_max unconditionalJohn Rigby2011-04-29-4/+4
| | | | | | | | | | | | | | Make existing field b_max field in struct mmc unconditional and use it instead of CONFIG_SYS_MMC_MAX_BLK_COUNT in mmc_bread and mmc_bwrite. Initialize b_max to CONFIG_SYS_MMC_MAX_BLK_COUNT in mmc_register if it has not been initialized by the hw driver. Initialize b_max to 0 in all callers to mmc_register. Signed-off-by: John Rigby <john.rigby@linaro.org> Signed-off-by: Andy Fleming <afleming@freescale.com>
* MMC may wrongly regconize 2GB eMMC as high capacityRaffaele Recalcati2011-04-13-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | Hi Terry, > So I guess: > mmc_init calls mmc_send_op_cond  that set  high_capacity, > than it calls mmc_startup, that, with MMC_CMD_SEND_CSD  command, set > the capacity, using values in CSD register. > So I guess that mmc_change_freq should not recalculate high_capacity. > > It seems better, isn't it? > > Regards, > Raffaele > Finally I think that it is enough to apply the following patch in order to fix the issue. Regards, Raffaele Signed-off-by: Andy Fleming <afleming@freescale.com>
* mmc: trace addedRaffaele Recalcati2011-04-13-0/+57
| | | | | | | | | | Defining CONFIG_MMC_TRACE in the include board file it is possible to activate a tracing support. This code helps in case of eMMC hw failure or to investigate possible eMMC initialization issues. Signed-off-by: Raffaele Recalcati <raffaele.recalcati@bticino.it> Signed-off-by: Andy Fleming <afleming@freescale.com>
* mmc: SEND_OP_COND considers card capabilities (voltage)Raffaele Recalcati2011-04-13-3/+18
| | | | | | | | | | | The first SEND_OP_COND (CMD1) command added is used to ask card capabilities. After it an AND operation is done between card capabilities and host capabilities (at the moment only for the voltage field). Finally the correct value is sent to the MMC, waiting that the card exits from busy state. Signed-off-by: Raffaele Recalcati <raffaele.recalcati@bticino.it> Signed-off-by: Andy Fleming <afleming@freescale.com>
* mmc: checking status after commands with R1b responseRaffaele Recalcati2011-04-13-3/+59
| | | | | | | | | | It is recommended to check card status after these kind of commands. This is done using CMD13 (SEND_STATUS) JEDEC command until the card is ready. In case of error the card status field is displayed. Signed-off-by: Raffaele Recalcati <raffaele.recalcati@bticino.it> Signed-off-by: Andy Fleming <afleming@freescale.com>
* mmc: remove duplicated header fileMinkyu Kang2011-04-13-1/+0
| | | | | Signed-off-by: Minkyu Kang <mk7.kang@samsung.com> Signed-off-by: Andy Fleming <afleming@freescale.com>
* mmc: add generic mmc spi driverThomas Chou2011-04-13-20/+73
| | | | | | | | | | | | | This patch supports mmc/sd card with spi interface. It is based on the generic mmc framework. It works with SDHC and supports multi blocks read/write. The crc checksum on data packet is enabled with the def, There is a subcomamnd "mmc_spi" to setup spi bus and cs at run time. Signed-off-by: Thomas Chou <thomas@wytron.com.tw> Signed-off-by: Andy Fleming <afleming@freescale.com>
* mmc: constify & localize dataMike Frysinger2011-04-13-2/+2
| | | | | | | These local vars need not be writable nor exported. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Andy Fleming <afleming@freescale.com>
* MMC: Max blocks value adjustableMatt Waddel2011-04-13-10/+9
| | | | | | | | | | The maximum blocks value was hardcoded to 65535 due to a 16 bit register length. The value can change for different platforms. This patch makes the default the current value of 65535, but it is configurable for other platforms. Signed-off-by: Matt Waddel <matt.waddel@linaro.org> Signed-off-by: Andy Fleming <afleming@freescale.com>
* SD1.00 wide-bus fixAlagu Sankar2011-04-13-3/+3
| | | | | | Fixed a bug wherein SD version 1.0 cards were not configured for 4-bit mode Signed-off-by: Alagu Sankar <alagusankar@embwise.com>
* mmc: Add multi-block read support to the generic mmc driverAlagu Sankar2010-11-04-71/+39
| | | | | | | | | | | | | | This patch adds multi-block read support for the generic MMC driver. Large reads are broken into chunks of 65535 blocks to ensure that the code works with controllers having a 16 bit block counter. This patch results in a significant performance improvement. Time to read a 45 MB file went from 36 seconds to 9 seconds on Overo Signed-off-by: Steve Sakoman <steve.sakoman@linaro.org> Tested-by: Steve Sakoman <steve.sakoman@linaro.org> Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
* mmc: Clean up generic mmc driver multi-block write functionsSteve Sakoman2010-11-04-24/+14
| | | | | | | | | | | The current mmc write implementation is type ulong, but returns int values. Some of the printf's are terminated with /n/r, one has none. This patch fixes these issues and also removes some unnecessary local variables. Signed-off-by: Steve Sakoman <steve.sakoman@linaro.org> Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
* mmc: seperate block number into small parts for multi-write cmdLei Wen2010-10-27-15/+39
| | | | | | | | | | Constraint the mmc framework to only send no more than 65535 blocks in one go during the multi-write command. This constraint comes due to the limitation of 16bit width block counter register at some hardware. Signed-off-by: Lei Wen <leiwen@marvell.com> Cc: Reinhard Meyer <u-boot@emk-elektronik.de>
* MMC: Fix for capacity calculation on eMMCSukumar Ghorai2010-10-17-0/+11
| | | | | | | | | | The current mmc driver returns erroneous capacity information for eMMC. The capacity of eMMC devices is available only in the ext-CSD register. This patch add code to read the ext-CDSD register and correctly calculate eMMC capacity. Signed-off-by: Sukumar Ghorai <s-ghorai@ti.com> Acked-by: Steve Sakoman <steve@sakoman.com>
* mmc: fix compiler warningsWolfgang Denk2010-09-19-2/+2
| | | | | | | | | | | | | | | | Commit d2bf29e3 caused a number of compiler warnings: mmc.c: In function 'mmc_bwrite': mmc.c:97: warning: format '%x' expects type 'unsigned int', but argument 2 has type 'long unsigned int' mmc.c:97: warning: format '%x' expects type 'unsigned int', but argument 3 has type 'lbaint_t' mmc.c: In function 'mmc_bread': mmc.c:229: warning: format '%x' expects type 'unsigned int', but argument 2 has type 'long unsigned int' mmc.c:229: warning: format '%x' expects type 'unsigned int', but argument 3 has type 'lbaint_t' Fix these. Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Lei Wen <leiwen@marvell.com>
* mmc: add boundary check for mmc operationLei Wen2010-09-18-0/+10
| | | | Signed-off-by: Lei Wen <leiwen@marvell.com>
* Fix memory leak in mmc_read()Wolfgang Denk2010-03-11-1/+1
| | | | | | | | | There is be a path through mmc_read in drivers/mmc/mmc.c where malloc'd memory is not freed before exiting mmc_read: it occurs if mmc_set_blocklen() returns a non-zero value. Reported-by: Quentin Armitage <Quentin@Armitage.org.uk> Signed-off-by: Wolfgang Denk <wd@denx.de>
* MMC: add weak function to detect MMC/SD cardStefano Babic2010-03-07-0/+7
| | | | | | | | | | | Most controllers can check if there is a card in the slot. However, they require pins that could be not available because required by other functions and the detection of a card must be performed in another way. This patch adds a weak function that a board can implement to add its internal custom way to check the presence of a MMC/SD card. Signed-off-by: Stefano Babic <sbabic@denx.de>
* mmc: check correctness of the voltage mask in ocrStefano Babic2010-03-07-1/+9
| | | | | | | | | | Most cards do not answer if some reserved bits in the ocr are set. However, some controllers can set bit 7 (reserved for low voltages), but how to manage low voltages SD card is not yet specified. Signed-off-by: Stefano Babic <sbabic@denx.de>
* mmc: set bus width to 1 and clock to minimum early during initializationIlya Yanok2009-07-19-0/+3
| | | | | | | We need to switch back to 1-bit before initialization or SD 2.0 cards will fail to send SCR if we've switched to 4-bit already. Signed-off-by: Ilya Yanok <yanok@emcraft.com>
* mmc: Fix decoding of SCR & function switch data on little-endian machinesYauhen Kharuzhy2009-06-02-5/+5
| | | | | | | | SCR & switch data are read from card as big-endian words and should be converted to CPU byte order. Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com> Signed-off-by: Andy Fleming <afleming@freescale.com>
* mmc: Remove return from mmc_init for non SD 2.0 compatible cards.Yauhen Kharuzhy2009-06-02-4/+0
| | | | | | | | | Cards which are not compatible with SD 2.0 standard, may return response for CMD8 command, but it will be invalid in terms of SD 2.0. We should accept this case as admissible, just like Linux does. Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com> Signed-off-by: Andy Fleming <afleming@freescale.com>
* mmc: drop unnecessary castsRabin Vincent2009-06-02-10/+10
| | | | | | Now that response is a uint, we can drop all the casts. Signed-off-by: Rabin Vincent <rabin@rab.in>
* mmc: fix response decoding on little endianRabin Vincent2009-06-02-10/+10
| | | | | | | | | | | | | | | | The mmc code defines the response as an array of chars. However, it access the response bytes both as (i) an array of four uints (with casts) and (ii) as individual chars. The former case is used more often, including by the driver when it assigns the response. The char-wise accesses are broken on little endian systems because they assume that the bytes in the uints are in big endian byte order. This patch fixes this by changing the response to be an array of four uints and replacing the char-wise accesses with equivalent uint-wise accesses. Signed-off-by: Rabin Vincent <rabin@rab.in>
* mmc: use lldiv to fix arm eabi buildRabin Vincent2009-06-02-3/+4
| | | | | | | The generic MMC core uses direct long long divisions, which do not build with ARM EABI toolchains. Use lldiv() instead, which works everywhere. Signed-off-by: Rabin Vincent <rabin@rab.in>
* mmc: check find_mmc_device return valueRabin Vincent2009-06-02-1/+1
| | | | | | | find_mmc_device returns NULL if an invalid device number is specified. Check for this to avoid dereferencing NULL pointers. Signed-off-by: Rabin Vincent <rabin@rab.in>
* Replace __attribute references with __attribute__Peter Tyser2009-04-28-2/+2
| | | | | | | | __attribute__ follows gcc's documented syntax and is generally more common than __attribute. This change is only asthetic and should not affect functionality. Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
* Add MMC FrameworkAndy Fleming2009-02-16-0/+930
Here's a new framework (based roughly off the linux one) for managing MMC controllers. It handles all of the standard SD/MMC transactions, leaving the host drivers to implement only what is necessary to deal with their specific hardware. This also hooks the infrastructure into the PowerPC board code (similar to how the ethernet infrastructure now hooks in) Some of this code was contributed by Dave Liu <daveliu@freescale.com> Signed-off-by: Andy Fleming <afleming@freescale.com>