aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/host/sdhci.c
Commit message (Collapse)AuthorAgeFilesLines
* sdhci: Add quirk for forcing maximum block size to 2048 bytesAnton Vorontsov2009-03-241-7/+13
| | | | | | | | | | | | | FSL eSDHC controllers can support maximum block size up to 4096 bytes, the MBL (Maximum Block Length) field in the capabilities register extended by one bit, and is set to 0x3. But the SDHCI core doesn't support blocks of 4096 bytes, and thus forces blksz to the lowest value -- 512 bytes. With this patch we can pin up the blksz to the maximum supported block size, i.e. 2048 bytes. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: Add quirk for controllers that need IRQ re-init after resetAnton Vorontsov2009-03-241-0/+7
| | | | | | | | FSL eSDHC controllers losing signal/interrupt enable states after reset, so we should re-enable them. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: Add quirk for controllers that need small delays for PIOAnton Vorontsov2009-03-241-0/+3
| | | | | | | | | | | Small udelay is needed to make eSDHC work in PIO mode. Without the delay reading causes endless interrupt storm, and writing corrupts data. The first guess would be that we must wait for some bit in some register, but I didn't find any reliable bits that change before and after the delay. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: Add set_clock callback and a quirk for nonstandard clocksAnton Vorontsov2009-03-241-0/+6
| | | | | | | | | | | | | | | FSL eSDHC hosts have incompatible register map to manage the SDCLK. This patch adds set_clock callback so that drivers could overwrite set_clock behaviour. Similar patch[1] was posted by Ben Dooks, though in Ben's version the callback is named change_clock, plus the patch has some unrelated bits that makes the patch difficult to reuse. [1] http://lkml.org/lkml/2008/12/2/160 Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: Add get_{max,timeout}_clock callbacksBen Dooks2009-03-241-7/+15
| | | | | | | | | | | | | | | Some controllers do not provide clock information in their capabilities (in the Samsung case, it is because there are multiple clock sources available to the controller). Add hooks to allow the system to supply clock information. p.s. In the original Ben's patch there was a bug that makes sdhci_add_host() return -ENODEV even if callbacks were specified. This is fixed now. Signed-off-by: Ben Dooks <ben-linux@fluff.org> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: Add support for hosts reporting inverted write-protect stateAnton Vorontsov2009-03-241-0/+2
| | | | | | | | | | | This patch adds SDHCI_QUIRK_INVERTED_WRITE_PROTECT quirk. When specified, the sdhci driver will invert WP state. p.s. Actually, the quirk is more board-specific than controller-specific. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: Add support for card-detection pollingAnton Vorontsov2009-03-241-2/+15
| | | | | | | | | | | | | | | This patch adds SDHCI_QUIRK_BROKEN_CARD_DETECTION quirk. When specified, sdhci driver will set MMC_CAP_NEEDS_POLL MMC host capability, and won't enable card insert/remove interrupts. This is needed for hosts with unreliable card detection, such as FSL eSDHC. The original eSDHC driver was tring to "debounce" card-detection IRQs by reading present state and disabling particular interrupts. But with this debouncing scheme I noticed that sometimes we miss card insertion/removal events. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: Enable only relevant (DMA/PIO) interrupts during transfersAnton Vorontsov2009-03-241-3/+14
| | | | | | | | | | | | Some hosts (that is, FSL eSDHC) throw PIO interrupts during DMA transfers, this causes tons of unneeded interrupts, and thus highly degraded speed. This patch modifies the driver so that now we only enable relevant (DMA or PIO) interrupts during transfers. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: Split card-detection IRQs management from sdhci_init()Anton Vorontsov2009-03-241-17/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Card detection interrupts should be handled separately as they should not be enabled before mmc_add_host() returns and should be disabled before calling mmc_remove_host(). The same is for suspend and resume routines. sdhci_init() no longer enables card-detection irqs. Instead, two new functions implemented: sdhci_enable_card_detection() and sdhci_disable_card_detection(). New sdhci_reinit() call implemented to behave the same way as the old sdhci_init(). Also, this patch implements and uses few new helpers to manage IRQs in a more conveinient way, that is: - sdhci_clear_set_irqs() - sdhci_unmask_irqs() - sdhci_mask_irqs() - SDHCI_INT_ALL_MASK constant sdhci_enable_sdio_irq() converted to these new helpers, plus the helpers will be used by the subsequent patches. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: Add support for bus-specific IO memory accessorsAnton Vorontsov2009-03-241-81/+78
| | | | | | | | | | | | | | | | Currently the SDHCI driver works with PCI accessors (write{l,b,w} and read{l,b,w}). With this patch drivers may change memory accessors, so that we can support hosts with "weird" IO memory access requirments. For example, in "FSL eSDHC" SDHCI hardware all registers are 32 bit width, with big-endian addressing. That is, readb(0x2f) should turn into readb(0x2c), and readw(0x2c) should be translated to le16_to_cpu(readw(0x2e)). Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: Add quirk for controllers with no end-of-busy IRQBen Dooks2009-03-021-1/+4
| | | | | | | | | | | | | The Samsung SDHCI (and FSL eSDHC) controller block seems to fail to generate an INT_DATA_END after the transfer has completed and the bus busy state finished. Changes in e809517f6fa5803a5a1cd56026f0e2190fc13d5c to use the new busy method are the cause of the behaviour change. Signed-off-by: Ben Dooks <ben-linux@fluff.org> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: fix led namingHelmut Schaa2009-02-181-1/+3
| | | | | | | | | | | | | | Fix the led device naming for the sdhci driver. The led class documentation defines the led name to have the form "devicename:colour:function" while not applicable sections should be left blank. To comply with the documentation the led device name is changed from "mmc*" to "mmc*::". Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* Revert "sdhci: force high speed capability on some controllers"Pierre Ossman2009-02-181-2/+1
| | | | | | | | | | This reverts commit a4b76193774b463b922cab2f92450efb20d29ef0. It turned out that the controller had problem running at the higher speed, so go back to trusting the hardware capability bits. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: handle built-in sdhci with modular leds classPierre Ossman2008-12-311-6/+11
| | | | | | | | As reported by Randy Dunlap, having sdhci built-in and LEDs class as a module resulted in undefined symbols. Change the code to handle that case properly (by not having LEDs class support in sdhci). Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: activate led support also when moduleÉric Piel2008-12-311-6/+6
| | | | | | | | | CONFIG_LEDS_CLASS is defined only if led-class is built-in, otherwise when it is a module the option is called CONFIG_LEDS_CLASS_MODULE. Led support should also be activated in this case. Signed-off-by: Eric Piel <eric.piel@tremplin-utc.net> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: struct device - replace bus_id with dev_name(), dev_set_name()Kay Sievers2008-11-081-1/+1
| | | | | | Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-Off-By: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: 'scratch' may be used uninitializedSteven Noonan2008-10-121-1/+1
| | | | | | | | | | | The variable 'scratch' is always initialized before it's used. The conditional which is responsible for initialization of 'scratch' will always evaluate 'true' when the first loop iteration occurs, and thus, it's properly initialized. GCC doesn't see this, of course, so using the uninitialized_var() macro seems to work for silencing this case. Signed-off-by: Steven Noonan <steven@uplinklabs.net> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: force high speed capability on some controllersPierre Ossman2008-10-121-1/+2
| | | | | | | Some high speed capable controllers forget to set the high speed capability bit. Make sure we enable the functionality anyway. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: reduce card detection delayPierre Ossman2008-10-121-1/+1
| | | | | | | | | The card detection delay was added early when the behaviour of the card interrupt was still very much unknown (i.e. before there was a public specification). As it is now known that it is a debounced signal, reduce the delay to something more sensible. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: let the controller wait for busy state to endPierre Ossman2008-10-121-6/+33
| | | | | | | The sdhci controllers can interrupt us when the busy state from the card has ended, saving CPU cycles and power. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: check correct return valuePierre Ossman2008-08-011-1/+1
| | | | | | Fix a copy-and-paste error. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: disable DMA for req, not completelyPierre Ossman2008-08-011-2/+2
| | | | | | | | The wrong flag was manipulated when an invalid sg list was given, turning off DMA on the next (and all subsequent) request instead of the current one. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: handle bug in JMB38x for sizes < 4 bytesPierre Ossman2008-08-011-0/+9
| | | | Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* dma-mapping: add the device argument to dma_mapping_error()FUJITA Tomonori2008-07-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add per-device dma_mapping_ops support for CONFIG_X86_64 as POWER architecture does: This enables us to cleanly fix the Calgary IOMMU issue that some devices are not behind the IOMMU (http://lkml.org/lkml/2008/5/8/423). I think that per-device dma_mapping_ops support would be also helpful for KVM people to support PCI passthrough but Andi thinks that this makes it difficult to support the PCI passthrough (see the above thread). So I CC'ed this to KVM camp. Comments are appreciated. A pointer to dma_mapping_ops to struct dev_archdata is added. If the pointer is non NULL, DMA operations in asm/dma-mapping.h use it. If it's NULL, the system-wide dma_ops pointer is used as before. If it's useful for KVM people, I plan to implement a mechanism to register a hook called when a new pci (or dma capable) device is created (it works with hot plugging). It enables IOMMUs to set up an appropriate dma_mapping_ops per device. The major obstacle is that dma_mapping_error doesn't take a pointer to the device unlike other DMA operations. So x86 can't have dma_mapping_ops per device. Note all the POWER IOMMUs use the same dma_mapping_error function so this is not a problem for POWER but x86 IOMMUs use different dma_mapping_error functions. The first patch adds the device argument to dma_mapping_error. The patch is trivial but large since it touches lots of drivers and dma-mapping.h in all the architecture. This patch: dma_mapping_error() doesn't take a pointer to the device unlike other DMA operations. So we can't have dma_mapping_ops per device. Note that POWER already has dma_mapping_ops per device but all the POWER IOMMUs use the same dma_mapping_error function. x86 IOMMUs use device argument. [akpm@linux-foundation.org: fix sge] [akpm@linux-foundation.org: fix svc_rdma] [akpm@linux-foundation.org: build fix] [akpm@linux-foundation.org: fix bnx2x] [akpm@linux-foundation.org: fix s2io] [akpm@linux-foundation.org: fix pasemi_mac] [akpm@linux-foundation.org: fix sdhci] [akpm@linux-foundation.org: build fix] [akpm@linux-foundation.org: fix sparc] [akpm@linux-foundation.org: fix ibmvscsi] Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Cc: Muli Ben-Yehuda <muli@il.ibm.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@elte.hu> Cc: Avi Kivity <avi@qumranet.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* sdhci: highmem capable PIO routinesPierre Ossman2008-07-231-91/+72
| | | | | | Improve the PIO handling so that it can service highmem pages. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: fix bad warning from commit c8b3e02Pierre Ossman2008-07-231-1/+1
| | | | | | | Commit c8b3e02 renamed a variable, but missed one reference to it inside a WARN_ON, causing it to incorrectly trigger. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: add warnings for bad buffers in ADMA pathPierre Ossman2008-07-231-0/+2
| | | | | | | | The ADMA code path assumes that the 3 byte alignment fix doesn't cross a page boundary. I'm not convinced this is worth supporting, but at least print a warning in the off chance we'll actually see such a request. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: OLPC: update vdd/powerup quirk commentAndres Salomon2008-07-151-1/+1
| | | | | | | | This comment update got lost in the great floo^Wmerge. As Pierre pointed out, no one knows what 'CaFe' is. Signed-off-by: Andres Salomon <dilinger@debian.org> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: fix spares errors of sdhci.cTomas Winkler2008-07-151-4/+4
| | | | | | | | | | | 1. sdhci_prepare_data: fix shadowing of count variable u8 count int count -> sg_cnt; 2. sdhci_add_host: assignment of integer to pointer dma_mask = 0 -> dma_mask = NULL; Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: graceful handling of bad addressesPierre Ossman2008-07-151-20/+57
| | | | | | | Be a bit more robust and fall back to PIO if someone is feeding us bogus addresses. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: scatter-gather (ADMA) supportPierre Ossman2008-07-151-36/+347
| | | | | | | | | | | Add support for the scatter-gather DMA mode present on newer controllers. As the mode requires 32-bit alignment, non-aligned chunks are handled by using a bounce buffer. Also add some new quirks to handle controllers that have bugs in the ADMA engine. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: handle hot-removePierre Ossman2008-07-151-8/+40
| | | | | | | Gracefully handle when the device is suddenly removed. Do a test read and avoid any further access if that read returns -1. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: make workaround for timeout bug more generalPierre Ossman2008-07-151-20/+30
| | | | | | | | Give the quirk for broken timeout handling a better chance of handling more controllers by simply classifying the system as broken and setting a fixed value. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: move pci stuff to separate modulePierre Ossman2008-07-151-408/+91
| | | | | | | | | | | The SDHCI interface is not PCI specific, yet the Linux driver was intimitely connected to the PCI bus. This patch properly separates the PCI specific portion from the bus independent code. This patch is based on work by Ben Dooks but he did not have time to complete it. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: don't check block count for progressPierre Ossman2008-07-151-14/+9
| | | | | | | | The specification is insufficiently strict when it comes to how the hardware should update the block count register, making it useless for checking transfer progress. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: don't use DMA on newer ENE controllersPierre Ossman2008-07-041-2/+4
| | | | | | | | | | | | Even the newer ENE controllers have bugs in their DMA engine that make it too dangerous to use. Disable it until someone has figured out under which conditions it corrupts data. This has caused problems at least once, and can be found as bug report 10925 in the kernel bugzilla. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* olpc: sdhci: add quirk for the Marvell CaFe's interrupt timeoutAndres Salomon2008-07-041-1/+11
| | | | | | | | | | | | | | | | | | | | | | The CaFe chip has a hardware bug that ends up with us getting a timeout value that's too small, causing the following sorts of problems: [ 60.525138] mmcblk0: error -110 transferring data [ 60.531477] end_request: I/O error, dev mmcblk0, sector 1484353 [ 60.533371] Buffer I/O error on device mmcblk0p2, logical block 181632 [ 60.533371] lost page write due to I/O error on mmcblk0p2 Presumably this is an off-by-one error in the hardware. Incrementing the timeout count value that we stuff into the TIMEOUT_CONTROL register gets us a value that works. This bug was originally discovered by Pierre Ossman, I believe. [thanks to Robert Millan for proving that this was still a problem] Signed-off-by: Andres Salomon <dilinger@debian.org> Cc: Pierre Ossman <drzeus-list@drzeus.cx> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* olpc: sdhci: add quirk for the Marvell CaFe's vdd/powerup issueAndres Salomon2008-07-041-0/+18
| | | | | | | | | | | | | | | | This has been sitting around unloved for way too long.. The Marvell CaFe chip's SD implementation chokes during card insertion if one attempts to set the voltage and power up in the same SDHCI_POWER_CONTROL register write. This adds a quirk that does that particular dance in two steps. It also adds an entry to pci_ids.h for the CaFe chip's SD device. Signed-off-by: Andres Salomon <dilinger@debian.org> Cc: Pierre Ossman <drzeus-list@drzeus.cx> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* sdhci: improve no card, no reset quirkPierre Ossman2008-04-181-2/+10
| | | | | | | | | | | The quirk was meant to just inhibit some resets, but ended up blocking all of them. Fortunately, this was just what was needed. Change the comment to reflect reality. Also, this issue has just been observed on Samsung laptops, so reduce the number of chips the quirk affects. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: allow led to be controlled freelyPierre Ossman2008-04-181-0/+44
| | | | | | | Hook up the controller LED to the LED subsystem, allowing more flexible control than simply indicating an ongoing request. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: remove custom controller namePierre Ossman2008-04-181-28/+16
| | | | | | | Remove the use of the sdhci specific device name and use the mmc controller name instead. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: add num index for multi controllers caseFeng Tang2008-02-081-1/+12
| | | | | | | | Some devices have several controllers; need add the index info to device slot name host->slot_desc[] Signed-off-by: Feng Tang <feng.tang@intel.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: support JMicron JMB38x chipsPierre Ossman2007-12-121-1/+18
| | | | | | | | The JMicron JMB38x chip doesn't support transfers that aren't 32-bit aligned (both size and start address). It also doesn't like switching between PIO and DMA mode, so it needs to be reset after each request. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: use PIO when DMA can't satisfy the requestPierre Ossman2007-12-121-3/+29
| | | | | | | | | | | Some controllers have been designed on the assumption that all transfers will be 32-bit aligned, both in start address and in size. This is not a guarantee the SDHCI specification provides and not one we can provide. Revert back to PIO for individual requests in order to work around the hardware bug. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: don't warn about sdhci 2.0 controllersPierre Ossman2007-12-121-1/+1
| | | | | | | We support 2.0 controllers, even though we don't use anything in the new feature set. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* sdhci: describe quirksPierre Ossman2007-12-121-0/+10
| | | | | | Add a comment for each quirk to describe what it does and why. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* Add missing "\n" to log messageRolf Eike Beer2007-11-101-1/+1
| | | | | Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
* mmc: sg falloutJens Axboe2007-10-241-2/+0
| | | | | | | Do a full scan of the directory to try and be a bit more proactive, instead of waiting for things to break. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
* [PATCH] Fix breakage after SG cleanupsRalf Baechle2007-10-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | Commits 58b053e4ce9d2fc3023645c1b96e537c72aa8d9a ("Update arch/ to use sg helpers") 45711f1af6eff1a6d010703b4862e0d2b9afd056 ("[SG] Update drivers to use sg helpers") fa05f1286be25a8ce915c5dd492aea61126b3f33 ("Update net/ to use sg helpers") converted many files to use the scatter gather helpers without ensuring that the necessary headerfile <linux/scatterlist> is included. This happened to work for ia64, powerpc, sparc64 and x86 because they happened to drag in that file via their <asm/dma-mapping.h>. On most of the others this probably broke. Instead of increasing the header file spider web I choose to include <linux/scatterlist.h> directly into the affectes files. Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Jens Axboe <jens.axboe@oracle.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* [SG] Update drivers to use sg helpersJens Axboe2007-10-221-1/+1
| | | | Signed-off-by: Jens Axboe <jens.axboe@oracle.com>