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>
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>
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>
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>
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_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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
This fixes u32 vs. pm_message_t in drivers/mmc, drivers/mtd and
drivers/scsi.
Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!