summaryrefslogtreecommitdiffstats
path: root/drivers/mmc/mmc.c
Commit message (Collapse)AuthorAgeFilesLines
* mmc: Move core functions to subdirPierre Ossman2007-05-011-1638/+0Star
| | | | | | | Create a "core" subdirectory to house the central bus handling functions. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: deprecate mmc bus topologyPierre Ossman2007-05-011-528/+393Star
| | | | | | | | | | | | | | | | | | The classic MMC bus was defined as multi card bus system, which is reflected in the design in the MMC layer. When SD showed up, the bus topology was abandoned and a star topology (one card per host) was mandated. MMC version 4 has followed this, officially deprecating the bus topology. As we do not have any known users of the bus topology we can remove support for it. This will simplify the code and rectify some incorrect assumptions in the newer additions. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: remove card upon suspendPierre Ossman2007-05-011-3/+10
| | | | | | | Suspending MMC/SD cards (versus removing and readding them) is an inherently unsafe operation and has even been broken for some time. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: Flush pending detects on host removalPierre Ossman2007-05-011-1/+14
| | | | | | | | | Make sure we kill of any pending detection runs when the host is removed instead of when it is freed. Also add some debugging to make sure the driver doesn't queue up more detection after it has removed the host. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: Move "present" markingPierre Ossman2007-05-011-2/+0Star
| | | | | | | The "present" state indicates that the card is a registered device, so it is more clear to put it together with the actual registration. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: add type field to cardsPierre Ossman2007-05-011-1/+2
| | | | | | | Split out the type of card into its own field as it hardly qualifies as a state. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: MMC sector based cardsPierre Ossman2007-05-011-3/+22
| | | | | | | Support for MMC 4.2 sector based cards. This tweaks the init a bit and reads a new field out of the EXT_CSD. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: use right timing mode constantPierre Ossman2007-05-011-1/+1
| | | | | | Fix copy-n-paste error. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: enforce correct sg listPierre Ossman2007-05-011-0/+11
| | | | | | | | Now that we've fixed our only offender when it comes to strange sg list, add a check so that future users keep the sg list proper with regard to transfer size. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: require explicit support for high-speedPierre Ossman2007-03-061-35/+48
| | | | | | | | | The new high-speed timings are similar to each other and the old system, but not identical. And although things "just work" most of the time, sometimes it does not. So we need to start marking which hosts are known to fully comply with the new timings. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: Graceful fallback for fancy featuresPierre Ossman2007-02-041-9/+7Star
| | | | | | | | | | | | | | MMC high-speed, wide bus support and SD high-speed are functions that aren't critical for correct operation of the card. As such, they shouldn't mark the card as bad or dead when there is a failure activating these features. This is needed in particular on some really stupid hardware (e.g. Winbond's) where not all data transfer commands are supported. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: Allow host drivers to specify max block countPierre Ossman2007-02-041-1/+5
| | | | | | | | | | | | Many controllers have an upper limit on the number of blocks that can be transferred in one request. Allow the host drivers to specify this and make sure we avoid hitting this limit. Also change the max_sectors field to avoid confusion. This makes it map less directly to the block layer limits, but as they didn't apply directly on MMC cards anyway, this isn't a great loss. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: Allow host drivers to specify a max block sizePierre Ossman2007-02-041-0/+4
| | | | | | | Most controllers have an upper limit on the block size. Allow the host drivers to specify this and make sure we avoid hitting this limit. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: Add support for SDHC cardsPhilip Langdale2007-02-041-28/+112
| | | | | | | | | | | | | | | | | | | | | | | | | Thanks to the generous donation of an SDHC card by John Gilmore, and the surprisingly enlightened decision by the SD Card Association to publish useful specs, I've been able to bash out support for SDHC. The changes are not too profound: i) Add a card flag indicating the card uses block level addressing and check it in the block driver. As we never took advantage of byte-level addressing, this simply involves skipping the block -> byte translation when sending commands. ii) The layout of the CSD is changed - a set of fields are discarded to make space for a larger C_SIZE. We did not reference any of the discarded fields except those related to the C_SIZE. iii) Read and write timeouts are fixed values and not calculated from CSD values. iv) Before invoking SEND_APP_OP_COND, we must invoke the new SEND_IF_COND to inform the card we support SDHC. Signed-off-by: Philipl Langdale <philipl@overt.org> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: replace host->card_busyPierre Ossman2007-02-041-8/+8
| | | | | | | | As card_busy was only used to indicate if the host was exclusively claimed and not really used to identify a particular card, replacing it with just a boolean makes things a lot more easily understandable. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* Merge branch 'master' of ↵David Howells2006-12-051-20/+274
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 Conflicts: drivers/infiniband/core/iwcm.c drivers/net/chelsio/cxgb2.c drivers/net/wireless/bcm43xx/bcm43xx_main.c drivers/net/wireless/prism54/islpci_eth.c drivers/usb/core/hub.h drivers/usb/input/hid-core.c net/core/netpoll.c Fix up merge failures with Linus's head and fix new compilation failures. Signed-Off-By: David Howells <dhowells@redhat.com>
| * mmc: Support for high speed SD cardsPierre Ossman2006-12-011-4/+118
| | | | | | | | | | | | | | | | | | | | | | Modern SD cards support a clock speed of 50 MHz. Make sure we test for this capability and do the song and dance required to activate it. Activating high speed support actually modifies the TRAN_SPEED field of the CSD. But as the spec says that the cards must report 50 MHz, we might as well skip re-reading the CSD. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
| * mmc: Fix mmc_delay() functionPierre Ossman2006-12-011-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Several fixes for mmc_delay(): * Repair if-clause that was supposed to detect sub-hz delays. * Change yield() to cond_resched() as yield() no longer has the semantics we desire. * mmc_delay() is used to guarantee protocol delays, so we cannot return early (i.e. use _interruptable). Based on patch by Amol Lad. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
| * mmc: Add support for mmc v4 wide-bus modesPhilip Langdale2006-12-011-14/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change adds support for the mmc4 4-bit wide-bus mode. The mmc4 spec defines 8-bit and 4-bit transfer modes. As we do not support any 8-bit hardware, this patch only adds support for the 4-bit mode, but it can easily be built upon when the time comes. The 4-bit mode is electrically compatible with SD's 4-bit mode but the procedure for turning it on is different. This patch implements only the essential parts of the procedure as defined by the spec. Two additional steps are recommended but not compulsory. I am documenting them here so that there's a record. 1) A bus-test mechanism is implemented using dedicated mmc commands which allow for testing the functionality of the data bus at the electrical level. This is pretty paranoid and they way the commands work is not compatible with the mmc subsystem (they don't set valid CRC values). 2) MMC v4 cards can indicate they would like to draw more than the default amount of current in wide-bus modes. We currently will never switch the card into a higher draw mode. Supposedly, allowing the card to draw more current will let it perform better, but the specs seem to indicate that the card will function correctly without the mode change. Empirical testing supports this interpretation. Signed-off-by: Philip Langdale <philipl@overt.org> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
| * [PATCH] mmc: Add support for mmc v4 high speed modePhilip Langdale2006-12-011-2/+119
| | | | | | | | | | | | | | | | | | | | | | | | This adds support for the high-speed modes defined by mmc v4 (assuming the host controller is up to it). On a TI sdhci controller, it improves read speed from 1.3MBps to 2.3MBps. The TI controller can only go up to 24MHz, but everything helps. Another person has taken this basic patch and used it on a Nokia 770 to get a bigger boost because that controller can run at 48MHZ. Signed-off-by: Philip Langdale <philipl@overt.org> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* | WorkStruct: make allyesconfigDavid Howells2006-11-221-8/+6Star
|/ | | | | | Fix up for make allyesconfig. Signed-Off-By: David Howells <dhowells@redhat.com>
* MMC: Do not set unsupported bits in OCR responseTimo Teras2006-11-091-1/+1
| | | | | | | | The card might go to inactive state (according to specification), if there are unsupported bits set in the OCR. Signed-off-by: Timo Teras <timo.teras@solidboot.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* MMC: Poll card status after rescanning cardsTimo Teras2006-11-091-1/+16
| | | | | | | | | | | | Some broken cards seem to process CMD1 even in stand-by state. The result is that the card replies with ILLEGAL_COMMAND error for the next command sent after rescanning. Currently the next command is select card, which would return the error. But CMD7 does actually succeed and retries of the command will timeout. The workaround is to poll card status after CMD1 to clear the pending error. Signed-off-by: Timo Teras <timo.teras@solidboot.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* [PATCH] mmc: use own work queuePierre Ossman2006-10-041-3/+3
| | | | | | | | | | | | | | | | The MMC layer uses the standard work queue for doing card detection. As this queue is shared with other crucial subsystems, the effects of a long (and perhaps buggy) detection can cause the system to be unusable. E.g. the keyboard stops working while the detection routine is running. The solution is to add a specific mmc work queue to run the detection code in. This is similar to how other subsystems handle detection (a full kernel thread is the most common theme). Signed-off-by: Pierre Ossman <drzeus@drzeus.cx> Cc: Russell King <rmk@arm.linux.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [MMC] Remove data->blksz_bits memberRussell King2006-09-161-1/+0Star
| | | | | | data->blksz_bits is unused now - remove it. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
* [MMC] Cleanup 385e3227d4d83ab13d7767c4bb3593b0256bf246Russell King2006-09-071-14/+50
| | | | | | | | Rather than having two places which independently calculate the timeout for data transfers, make it a library function instead. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Acked-by: Pierre Ossman <drzeus@drzeus.cx>
* [MMC] Fix SD timeout calculationPierre Ossman2006-09-071-2/+13
| | | | | | | | Secure Digital cards use a different algorithm to calculate the timeout for data transfers. Using the MMC one works often, but not always. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
* [PATCH] lockdep: annotate on-stack completions, mmcIngo Molnar2006-07-041-1/+1
| | | | | | | | | | | | | | | lockdep needs to have the waitqueue lock initialized for on-stack waitqueues implicitly initialized by DECLARE_COMPLETION(). Annotate mmc_wait_for_req()'s on-stack completion accordingly. Has no effect on non-lockdep kernels. Signed-off-by: Ingo Molnar <mingo@elte.hu> Cc: Arjan van de Ven <arjan@linux.intel.com> Cc: Russell King <rmk@arm.linux.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* Remove obsolete #include <linux/config.h>Jörn Engel2006-06-301-1/+0Star
| | | | | Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de> Signed-off-by: Adrian Bunk <bunk@stusta.de>
* [ARM] 3531/1: i.MX/MX1 SD/MMC ensure, that clock are stopped before new ↵Pavel Pisa2006-05-191-0/+1
| | | | | | | | | | | | | | command and cleanups Patch from Pavel Pisa There has been problems that for some paths that clock are not stopped during new command programming and initiation. Result is issuing of incorrect command to the card. Some other problems are cleaned too. Noisy report of known ERRATUM #4 has been suppressed. Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
* [MMC] Move set_ios debugging into mmc.cRussell King2006-05-041-17/+34
| | | | | | | | Rather than having every driver duplicate the set_ios debugging, provide a single version in mmc.c which can be expanded as we add additional functionality. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
* [MMC] Correct mmc_request_done commentsRussell King2006-05-041-5/+4Star
| | | | | | | mmc_request_done should be called at the end of handling a request, not between the data and initial command parts of the request. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
* [MMC] extend data timeout for writesRussell King2006-05-021-0/+2
| | | | | | | | | The CSD contains a "read2write factor" which determines the multiplier to be applied to the read timeout to obtain the write timeout. We were ignoring this parameter, resulting in the possibility for writes being timed out too early. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
* [MMC] Pass -DDEBUG on compiler command line if MMC_DEBUG selectedRussell King2006-03-291-12/+7Star
| | | | | | | | | | Rather than each driver test MMC_DEBUG itself, and define DEBUG, pass it in via the makefile instead. Fix drivers to use pr_debug() where appropriate, and avoid defining a DEBUG() macro. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
* [MMC] Add MMC command type flagsRussell King2006-02-021-14/+14
| | | | | | | Some hosts need to know the command type, so pass it via a set of flags in cmd->flags. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
* [MMC] Support MMC version 4 cardsPierre Ossman2006-01-081-0/+1
| | | | | | | | | Version 4 of the MMC specification increased the version number of the CID structure. None of the fields changed though so the only required change is adding '4' to the approved list. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
* [MMC] Improve MMC card block size selectionRussell King2006-01-031-0/+10
| | | | | | | | | | | Select a block size for IO based on the read and write block size combinations, and whether the card supports partial block reads and/or partial block writes. If we are able to satisfy block reads but not block writes, mark the device read only. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
* [MMC] Explain the internals of mmc_power_up()Russell King2005-12-141-1/+9
| | | | | | | | It seems that people get confused about what is happening in mmc_power_up(). Add a comment to make it clear why we have a two stage process. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
* [MMC] Proper check of SCR error codePierre Ossman2005-12-051-2/+3
| | | | | | | | The routine reading the SCR wasn't paying proper attention to the error codes returned from the driver. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
* [MMC] Fix protocol errorsPierre Ossman2005-11-281-1/+1
| | | | | | | | A review against MMC/SD specifications found some errors in the current implementation. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
* [ARM] 3120/1: Fix MMC/SD card driver resume deadlockUli Luckas2005-11-071-1/+1
| | | | | | | | | Patch from Uli Luckas This is a simplification of patch 3116/1 as sugested by Russell King. Signed-off-by: Uli Luckas <u.luckas@road-gmbh.de> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
* [MMC] Allow detection/removal to be delayedRichard Purdie2005-09-081-4/+8
| | | | | | | | | Change mmc_detect_change() to take a delay argument such that the detection of card insertions and removals can be delayed according to the requirements of the host driver or platform. Signed-off-by: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
* [PATCH] sd: SD copyright noticePierre Ossman2005-09-081-0/+2
| | | | | | | | | | Credit where credit is due. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx> Cc: Russell King <rmk@arm.linux.org.uk> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [PATCH] sd: SD 4-bit busPierre Ossman2005-09-081-0/+36
| | | | | | | | | | Infrastructure for 4-bit bus transfers with SD cards. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx> Cc: Russell King <rmk@arm.linux.org.uk> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [PATCH] sd: SCR registerPierre Ossman2005-09-081-10/+133
| | | | | | | | | | Read the SD specific SCR register from the card. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx> Cc: Russell King <rmk@arm.linux.org.uk> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [PATCH] sd: read-only switchPierre Ossman2005-09-081-16/+23
| | | | | | | | | | | Support for the read-only switch on SD cards which must be enforced by the host. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx> Cc: Russell King <rmk@arm.linux.org.uk> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [PATCH] sd: initialize SD cardsPierre Ossman2005-09-081-73/+253
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support for the Secure Digital protocol in the MMC layer. A summary of the legal issues surrounding SD cards, as understood by yours truly: Members of the Secure Digital Association, hereafter SDA, are required to sign a NDA[1] before given access to any specifications. It has been speculated that including an SD implementation would forbid these members to redistribute Linux. This is the basic problem with SD support so it is unclear if it even is a problem since it has no effect on those of us that aren't members. The SDA doesn't seem to enforce these rules though since the patches included here are based on documentation made public by some of the members. The most complete specs[2] are actually released by Sandisk, one of the founding companies of the SDA. Because of this the NDA is considered a non-issue by most involved in the discussions concerning these patches. It might be that the SDA is only interested in protecting the so called "secure" bits of SD, which so far hasn't been found in any public spec. (The card is split into two sections, one "normal" and one "secure" which has an access scheme similar to TPM:s). (As a side note, Microsoft is working to make things easier for us since they want to be able to include the source code for a SD driver in one of their development kits. HP is making sure that the new NDA will allow a Linux implementation. So far only the SDIO specs have been opened up[3]. More will hopefully follow.) [1] http://www.sdcard.org/membership/images/ippolicy.pdf [2] http://www.sandisk.com/pdf/oem/ProdManualSDCardv1.9.pdf [3] http://www.sdcard.org/sdio/Simplified%20SDIO%20Card%20Specification.pdf This patch contains the central parts of the SD support. If no MMC cards are found on a bus then the MMC layer proceeds looking for SD cards. Helper functions are extended to handle the special needs of SD cards. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx> Cc: Russell King <rmk@arm.linux.org.uk> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [MMC] ios for mmc chip selectPierre Ossman2005-09-031-0/+12
| | | | | | | | | Adds a new ios for setting the chip select pin on MMC cards. Needed on SD controllers which use this pin for other things and therefore cannot have it pulled high at all times. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
* [MMC] Add MMC class devicesRussell King2005-08-191-13/+10Star
| | | | | | | | | Create a mmc_host class to allow enumeration of MMC host controllers even though they have no card(s) inserted. Patch based on work by Pierre Ossman. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
* [MMC] Add mmc_hostname() macroRussell King2005-08-191-3/+3
| | | | | | mmc_hostname() returns a pointer to the hostname for the mmc_host. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>