summaryrefslogtreecommitdiff
path: root/drivers/mmc
AgeCommit message (Collapse)Author
2012-03-19mmc: mmci : Do not use polling for non removable cardsFredrik Soderstedt
Do not use polling to detect non removable cards. ST-Ericsson ID: 372618 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I18797e5f85d83213bbf520277576425bed4c68f2 Signed-off-by: Fredrik Soderstedt <fredrik.soderstedt@stericsson.com> Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/51859
2012-03-19mmc: mmci: Limit command frequency when using a levelshifterUlf Hansson
Due to timing issues for command direction signaling when using a levelshifter, we limit the frequency to 25 MHz while sending commands. The frequency is just limited during the command send/response, then it is restored to it's original value. ST-Ericsson ID: 355531 ST-Ericsson Linux next: - ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I15d06e3c331a4db717a904937ce6ce60972d185e Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/51785
2012-03-19mmc: mmci: optimize pre_req if no previous requestPer Forlin
Don't prepare DMA in the pre_req hook if there is no previous request. Instead, prepare DMA while start command is being issued. ST-Ericsson Linux next: N/A ST-Ericsson ID: 371812 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I0008b79cbe0e87f830365e689795f344aac3014b Signed-off-by: Per Forlin <per.forlin@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/36181 Reviewed-by: QATOOLS Reviewed-by: QABUILD Reviewed-by: Ulf HANSSON <ulf.hansson@stericsson.com>
2012-03-19ARM: mmci: DMA preparations in parellel with cmdPer Forlin
Do DMA preparations after start_command() instead of before. DMA is being prepared while the controller process the read/write cmd. This flow will decrease the start up latency which improves the throughput, especially for small transfers. ST-Ericsson Linux next: N/A ST-Ericsson ID: 371812 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I98db024658cac5fe6ee09e4250c31e53a643bead Signed-off-by: Per Forlin <per.forlin@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/36180 Reviewed-by: QABUILD Reviewed-by: Ulf HANSSON <ulf.hansson@stericsson.com>
2012-03-19mmc: core: Clean up after mmc_pre_req if card was removedUlf Hansson
Make sure mmc_start_req cancel the prepared job, if the request was prevented to be started due to the card has been removed. This bug was introduced in commit: mmc: allow upper layers to know immediately if card has been removed Change-Id: I5e35e668bd3715c62081e725eca8eb073d19e9a6 Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/51442 Reviewed-by: Per FORLIN <per.forlin@stericsson.com>
2012-03-19mmc: mmci: Add support for start_signal_voltage_switchUlf Hansson
This function switches I/O voltage, which is needed to support UHS-I cards with 1.8V I/O. Change-Id: Id33a9c6e15bd4ba598e533bf9115cb7583369706 Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/50383 Reviewed-by: Per FORLIN <per.forlin@stericsson.com>
2012-03-19mmc: mmci: Fixup post error handling for dmaUlf Hansson
The next pointers for the next dma job needs to be reset when an error occurs. Change-Id: Ieae63ccb97b11c0f6edb7b383c84259082b83760 Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/50454 Reviewed-by: Per FORLIN <per.forlin@stericsson.com> Reviewed-by: QABUILD
2012-03-19mmc: mmci: Do not finalize dma job at data error irqUlf Hansson
mmci_dma_finalize must not be executed when a data error irq has been received. We do mmci_dma_unmap directly instead and moreover make sure the dma handles are reset as soon as the dma job is done/terminated. Change-Id: Ib4ed3f380f4383cb2a28613552569b950c5204a5 Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/49925 Reviewed-by: Per FORLIN <per.forlin@stericsson.com>
2012-03-19mmc: mmci: Cleanup code for DMA handlingUlf Hansson
The cookie is now used to indicate if dma_unmap_sg shall be done in post_request. At DMA errors, the DMA job is immediately not only terminated but also unmapped. To indicate that this has been done the cookie is reset to zero. post_request will thus only do dma_umap_sg for requests which has a cookie not set to zero. Some corresponding duplicated code could then be removed and moreover some minor corrections at DMA errors for terminating the same DMA job twice has also been fixed. ST-Ericsson Linux next: N/A ST-Ericsson ID: 371812 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I2fedfc906ec861ab431f43c333237adb85f2fa99 Signed-off-by: Per Forlin <per.forlin@stericsson.com> Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/47628
2012-03-19mmc: init sysfs attr to fix lockdep warningsRabin Vincent
BUG: key df230ba4 not in .data! ------------[ cut here ]------------ WARNING: at kernel/lockdep.c:2885 sysfs_add_file_mode+0x4c/0xb0() Modules linked in: [<c01a36ac>] (unwind_backtrace+0x0/0xec) from [<c01c90a0>] (warn_slowpath_common+0x4c/0x64) [<c01c90a0>] (warn_slowpath_common+0x4c/0x64) from [<c01c90d0>] (warn_slowpath_null+0x18/0x1c) [<c01c90d0>] (warn_slowpath_null+0x18/0x1c) from [<c02c5ad8>] (sysfs_add_file_mode+0x4c/0xb0) [<c02c5ad8>] (sysfs_add_file_mode+0x4c/0xb0) from [<c04c1df4>] (mmc_add_disk+0xb8/0x154) [<c04c1df4>] (mmc_add_disk+0xb8/0x154) from [<c04c1f78>] (mmc_blk_probe+0xe8/0x138) [<c04c1f78>] (mmc_blk_probe+0xe8/0x138) from [<c04b72d4>] (mmc_bus_probe+0x18/0x1c) [<c04b72d4>] (mmc_bus_probe+0x18/0x1c) from [<c03f2c90>] (really_probe+0x98/0x148) [<c03f2c90>] (really_probe+0x98/0x148) from [<c03f2d88>] (driver_probe_device+0x48/0x60) [<c03f2d88>] (driver_probe_device+0x48/0x60) from [<c03f21e8>] (bus_for_each_drv+0x44/0x74) [<c03f21e8>] (bus_for_each_drv+0x44/0x74) from [<c03f2f08>] (device_attach+0x78/0xa4) [<c03f2f08>] (device_attach+0x78/0xa4) from [<c03f2020>] (bus_probe_device+0x24/0x40) [<c03f2020>] (bus_probe_device+0x24/0x40) from [<c03f0ff0>] (device_add+0x174/0x2b4) [<c03f0ff0>] (device_add+0x174/0x2b4) from [<c04b7500>] (mmc_add_card+0x138/0x188) [<c04b7500>] (mmc_add_card+0x138/0x188) from [<c04b91bc>] (mmc_attach_mmc+0x108/0x178) [<c04b91bc>] (mmc_attach_mmc+0x108/0x178) from [<c04b5c08>] (mmc_rescan_try_freq+0x5c/0x7c) [<c04b5c08>] (mmc_rescan_try_freq+0x5c/0x7c) from [<c04b67ec>] (mmc_rescan+0x1c8/0x20c) [<c04b67ec>] (mmc_rescan+0x1c8/0x20c) from [<c01e250c>] (process_one_work+0x2ac/0x4c8) [<c01e250c>] (process_one_work+0x2ac/0x4c8) from [<c01e29f8>] (worker_thread+0x144/0x234) [<c01e29f8>] (worker_thread+0x144/0x234) from [<c01e8280>] (kthread+0x80/0x88) [<c01e8280>] (kthread+0x80/0x88) from [<c019dc88>] (kernel_thread_exit+0x0/0x8) ---[ end trace 90d62d7618c6b90e ]--- Change-Id: I123e84b08e085d1b562674533417cb43f295095d Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com> ST-Ericsson ID: 413918 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I216974bfa1323d3a390ee8e8acc029c13a9525f5 Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/47172 Tested-by: Rabin VINCENT <rabin.vincent@stericsson.com> Reviewed-by: QABUILD Reviewed-by: Johan RUDHOLM <johan.rudholm@stericsson.com> Reviewed-by: Rabin VINCENT <rabin.vincent@stericsson.com>
2012-03-19mmc: mmci: Use ios_handler to save powerUlf Hansson
To disable a levelshifter when we are in an idle state will decrease current consumption. We make use of the ios_handler at runtime suspend and at regular suspend to accomplish this. Of course depending on the used levelshifter the decrease of current differs. For ST6G3244ME the value is up to ~200 uA. Tested-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Change-Id: Ie782d3af7932730c442dcb6c7f12b2f69dcac75e Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/44399 Reviewed-by: QABUILD Reviewed-by: QATEST
2012-03-19mmc: mmci: Implement PM runtime callbacks to save powerUlf Hansson
In the runtime_suspend callback we make use of mmci_save to disable the VCORE regulator and the MCLK to decrease current consumption. At runtime resume, we use mmci_restore to re-enable the resourses again. From now on this will mean that especially the mmci_restore function must be fast to execute since otherwise request latency will be introduced. For the ARM Primcell PL180, the MMCIPOWER register is used to control an external power supply to the card. Thus we need to prevent the runtime callbacks from doing save and restore, otherwise the power to card will be cut. This is done by adding a new flag to the variant data. Tested-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Change-Id: Ic6af2f59e57df82acb4be730bb855e1d39c9439b Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/44398 Reviewed-by: QABUILD
2012-03-19mmc: mmci: Decrease current consumption in suspendUlf Hansson
To decrease current consumption in suspend state the VCORE regulator, the MCLK and PCLK for the ARM PL18x are now disabled. When resuming the resourses are re-enabled and register values for MMCICLOCK, MMCIPOWER and MMCIMASK0 are restored. Change-Id: I400237bf67fa37861d6fb47c4a2fd493b58c3a60 Tested-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/44397 Reviewed-by: QABUILD
2012-03-19mmc: mmci: Fixup use of runtime PM and use autosuspendUlf Hansson
Added use of runtime PM autosuspend feature, with a fixed timeout of 50 ms. This will prevent adding a latency, although very minor, for _every_ request. Moreover the runtime_get_sync is now also used in set_ios and suspend since the runtime resourses are needed here as well. Tested-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Change-Id: Iabf2e109abb8a5a0459d77d813e04d8a2e9289c5 Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/44396 Reviewed-by: QABUILD
2012-03-19mmc: mmci: Cache MMCICLOCK and MMCIPOWER registerUlf Hansson
Instead of reading a register value everytime we need to apply a new value for it, maintain a cached copy for it. This also means we are able to skip writes that are not needed. Tested-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Change-Id: I57fdb1aff8906334ff42d6d808c526e69a0203a4 Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/44395 Reviewed-by: Fredrik SODERSTEDT <fredrik.soderstedt@stericsson.com> Reviewed-by: QABUILD Reviewed-by: Johan RUDHOLM <johan.rudholm@stericsson.com>
2012-03-19mmc: mmci: Change from using legacy suspendUlf Hansson
This patch switch from using the legacy suspend/resume to the new way of registering PM callbacks. No functional change is done. Tested-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Change-Id: I13a620c58d1c89f9d012503c40a51e7a79b1d663 Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/44394 Reviewed-by: QABUILD
2012-03-19mmc: mmci: Do not release spinlock in request_endUlf Hansson
The patch "mmc: core: move ->request() call from atomic context", is the reason to why this change is possible. This simplifies the error handling code execution path quite a lot and potentially also fixes some error handling hang problems. Tested-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Change-Id: Ibdad8f4d9295b539928556e94c7652d3bdb66ddc Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/44393 Reviewed-by: QABUILD
2012-03-19mmc: Add old-style pwr/perm boot part lockingJohan Rudholm
Add backwards-compatible sysfs nodes for locking the boot partitions power and permanently read-only. This is done by writing "pwr_ro" or "perm_ro" to /sys/block/mmcblkXbootY/ro_lock ST-Ericsson ID: 344197 ST-Ericsson FOSS-OUT ID: Trivial ST-Ericsson Linux next: NA Change-Id: Ibe1874bbb3b1b6ce9f7955537b5e083e97f69d11 Signed-off-by: Johan Rudholm <johan.rudholm@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/44842 Reviewed-by: Ulf HANSSON <ulf.hansson@stericsson.com>
2012-03-19mmc: mmci: Fix PIO read for small SDIO packetsStefan Nilsson XK
Corrects a bug in MMCI host driver which silently causes small reads (< 4 bytes as only used in SDIO) from PL-18X to fail. ST-Ericsson Linux next: - ST-Ericsson ID: 401293 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: Ieb14fc792c43429bf396532ed403b1ecc0efcd74 Signed-off-by: Stefan Nilsson XK <stefan.xk.nilsson@stericsson.com> Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Signed-off-by: Fredrik Soderstedt <fredrik.soderstedt@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/40802 Reviewed-by: QABUILD
2012-03-19mmc: mmci: Use HWFC when possibleStefan Nilsson XK
HW flow control should not be used for write transfers less then 8 bytes. All other transfers should use HW flow control. ST-Ericsson Linux next: NA ST-Ericsson ID: 398871 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I51044d26cfc7df033852becbbc6e796396dfb45f Signed-off-by: Stefan Nilsson XK <stefan.xk.nilsson@stericsson.com> Signed-off-by: Fredrik Soderstedt <fredrik.soderstedt@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/40191 Reviewed-by: QATOOLS Reviewed-by: QABUILD Reviewed-by: Ulf HANSSON <ulf.hansson@stericsson.com>
2012-03-19mmc: Minimize resume-time by deferring resumeUlf Hansson
Typically an sd/mmc card takes around 200 - 1100 ms to initialize when the power to the card has been cut, which is what happens during a suspend/resume sequence. All device's resume time adds up to the total kernel resume time. Some use cases requires the kernel to be resumed fast, to be able to meet deadlines. One use case example is WLAN SOFT_AP, but there are certainly more. This patch schedules a delayed work to do a deferred resume of the mmc host, if the bus holds a card of SD or MMC type. The reason for not supporting SDIO and SDcombo cards at this stage, is because the SDIO API is synchronus, which complicates request locking mechanism when waiting for a deferred resume to be completed. While waiting for a deferred resume to be completed, detect works are prevented from doing a new rescan. If a mmcblk request arrives, the deferred resume will be synced immediately. The deferred resume is scheduled 3000 ms after the resume request arrived. The idea behind this timer value is to let the mmc host being able to accept a new suspend request before it has been deferred resumed and thus not increase the resume to suspend time if not really needed. Change-Id: I7e97e59c8709cf5d8e3c76478771ddf6062a54ec Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/39692
2012-03-19mmc: block: Remove use of mmc_blk_set_blksizeUlf Hansson
According to the specifications for SD and (e)MMC default blocksize (named BLOCKLEN in Spec.) must always be 512 bytes. Since we hardcoded to always use 512 bytes, we do not explicitly have to set it. Future improvements should potentially make it possible to use a greater blocksize than 512 bytes, but until then let's skip this. Change-Id: Id8b844858caef3a28df838d85086593b8b16277d Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/39740 Reviewed-by: QABUILD Reviewed-by: Stefan NILSSON9 <stefan.xk.nilsson@stericsson.com>
2012-03-19mmc: mmci: Support MMC_PM_KEEP_POWERUlf Hansson
Add MMC_PM_KEEP_POWER to pm_caps so SDIO clients are able to use this option to prevent power off in suspend. Change-Id: I36df77e66ca8845ceeffb9d5163d4c1e77821b7d Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/34918
2012-03-19mmc: mmc_test: add 4 byte alignment testsPer Forlin
Add test cases to verify alignment with 4 bytes and 32 bytes for sg element lengths and memory addresses. These tests were added to investigate DMA constraints when transferring buffers that are not aligned with 32 bytes. ST-Ericsson ID: 363565 ST-Ericsson FOSS-OUT ID: Trivial ST-Ericsson Linux next: NA Change-Id: I6363a018647f22e5d69920af2cb30dfe2b2a699e Signed-off-by: Per Forlin <per.forlin@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/34362 Reviewed-by: QATOOLS Reviewed-by: Ulf HANSSON <ulf.hansson@stericsson.com>
2012-03-19MMCI: Increase max_segs from 16 to 128Ulf Hansson
A significant increase (10-20%) in performance throughput for USB mass storage is the reason for incrementing the value. By some reason the USB driver allocates buffers which requires a scattergather list to contain a lot more than 16 elements to get optimal performance. This change sets the maximum elements to 128. Tests with large reads and large writes (100 MiB) show that the throughput increase is significant for write (10% for this test) but not for read. Tests are run on a Linux host with ext4 FS on the gadget mass storage device. The sg-len still exceeds 16 for the read tests but the performance gain is low or nothing. Change-Id: I5f23a470f6d979905f6952b947411cf848f667bb Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Signed-off-by: Per Forlin <per.forlin@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/16071 Reviewed-by: Sebastian RASMUSSEN <sebastian.rasmussen@stericsson.com> Reviewed-by: Stefan NILSSON9 <stefan.xk.nilsson@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/32160
2012-03-19mmc: mmci: Change vdd_handler to a generic ios handlerUlf Hansson
The purpose of the vdd_handler does not make sense. We remove it and use a more generic approach instead. A new "ios" handler is thus added, the purpose of which e.g. can be to control GPIO pins to a levelshifter. Previously the vdd_handler was also used for making additional changes to the MMCIPOWER register bits. This option is now removed. This patch is based upon a patch from Sebastian Rasmussen. Change-Id: I250c7d243946acd9cc9da2d4d18394db1256cd27 Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Signed-off-by: Sebastian Rasmussen <sebastian.rasmussen@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/31883
2012-03-19mmci: add constraints on alignment for SDIOUlf Hansson
Buffers must be 4 bytes aligned due to restrictions that the PL18x FIFO accesses must be done in a 4-byte aligned manner. Enable DMA_REQCTL for SDIO to support write of not 32 bytes aligned sg element lengths. In PIO mode any buffer length can be handled as long as the buffer address is 4 byte aligned. Signed-off-by: Ulf Hansson <(address hidden)> Signed-off-by: Per Forlin <(address hidden)> Signed-off-by: Stefan Nilsson XK <(address hidden)>
2012-03-19mmci: Provide option to configure bus signal directionUlf Hansson
The ST Micro variant supports bus signal direction indication. A new member in the variant struct is added for this. Moreover the actual signal direction configuration is board specific, thus the amba mmci platform data is extended with a new member to be able provide mmci with these specific board configurations. This patch is based upon a patch from Sebastian Rasmussen. Signed-off-by: Ulf Hansson <(address hidden)> Signed-off-by: Sebastian Rasmussen <(address hidden)> Acked-by: Linus Walleij <(address hidden)>
2012-03-19mmci: Put power register deviations in variant dataUlf Hansson
Use variant data to store hardware controller deviations concerning power registers to improve readability of the code. Signed-off-by: Sebastian Rasmussen <(address hidden)> Signed-off-by: Ulf Hansson <(address hidden)> Reviewed-by: Linus Walleij <(address hidden)>
2012-03-19mmci: Fix incorrect handling of HW flow control for SDIOUlf Hansson
For data writes smaller <= 8 bytes (only SDIO case), HW flow control was disabled but never re-enabled again. This meant that a following large read request would randomly give buffer overrun errors. Moreover HW flow control is not needed for transfers that fits in the FIFO of PL18x. Thus it is disabled for write operations <= the FIFO size. Signed-off-by: Ulf Hansson <(address hidden)> Signed-off-by: Stefan Nilsson XK <(address hidden)>
2012-03-19mmci: Prepare for SDIO before setting up DMA jobUlf Hansson
Move the SDIO preparation to be done before the DMA job is setup. This makes it possible to do DMA for SDIO transfers as well as the earlier supported pio mode. Signed-off-by: Ulf Hansson <(address hidden)> Signed-off-by: Stefan Nilsson XK <(address hidden)>
2012-03-19mmci: Support non-power-of-two block sizes for ux500v2 variantUlf Hansson
For the ux500v2 variant of the PL18x block, non power of two block sizes are supported. This will make it possible to decrease data overhead for SDIO transfers. Signed-off-by: Stefan Nilsson XK <(address hidden)> Signed-off-by: Ulf Hansson <(address hidden)>
2012-03-04mmc: core: Fixup suspend/resume issues for UHS-I cardsUlf Hansson
Even if cards supports 1.8V I/O voltage those should anyway be initialized at 3.3V I/O according to (e)MMC, SD and SDIO specs. Some eMMC and embedded SDIO devices are able to be initialized at 1.8V as well, but it is better to be safe. Do note that initialization in this context means that the card has been completely powered off, otherwise the card will remain at the last I/O voltage level that were negotitiated. Due to the above being taken care of the suspend/resume issues for UHS-I SD-cards has been fixed. Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Acked-by: Philip Rakity <prakity@marvell.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Tested-by: Subhash Jadavani <subhashj@codeaurora.org> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-03-04mmc: mmci: reduce max_blk_count to avoid overflowing max_req_sizeWill Deacon
On a system with large pages (64k in my case), the following BUG is triggered in MMC core: [ 2.338023] BUG: failure at drivers/mmc/core/core.c:221/mmc_start_request()! [ 2.338102] Kernel panic - not syncing: BUG! [ 2.338155] Call trace: [ 2.338228] [<ffffffc00008635c>] dump_backtrace+0x0/0x120 [ 2.338317] [<ffffffc0003365ec>] dump_stack+0x14/0x1c [ 2.338403] [<ffffffc000336990>] panic+0xbc/0x1f0 [ 2.338498] [<ffffffc00027a494>] mmc_start_request+0x154/0x184 [ 2.338600] [<ffffffc00027abdc>] mmc_start_req+0x110/0x140 [ 2.338701] [<ffffffc00028604c>] mmc_blk_issue_rw_rq+0x7c/0x39c [ 2.338804] [<ffffffc00028652c>] mmc_blk_issue_rq+0x1c0/0x468 [ 2.338905] [<ffffffc000287564>] mmc_queue_thread+0x68/0x118 [ 2.338995] [<ffffffc0000bc308>] kthread+0x84/0x8c This is because of a 64k request with a max_req_size of 64k-1 bytes. The following patch fixes the problem by limiting the max_blk_count such that max_blk_count * max_blk_size == max_req_size. I couldn't pursuade the compiler to emit a shift instead of a div without encoding the shift explicitly. Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-03-04mmc: sdhci-esdhc-imx: fix for mmc cards on i.MX5Sascha Hauer
On i.MX53 we have to write a special SDHCI_CMD_ABORTCMD to the SDHCI_TRANSFER_MODE register during a MMC_STOP_TRANSMISSION command. This works for SD cards. However, with MMC cards the MMC_SET_BLOCK_COUNT command is used instead, but this needs the same handling. Fix MMC cards by testing for the MMC_SET_BLOCK_COUNT command aswell. Tested on a custom i.MX53 board with a Transcend MMC+ card and eMMC. The kernel started used MMC_SET_BLOCK_COUNT in 3.0, so this is a regression for these boards introduced in 3.0; it should go to 3.0/3.1/3.2-stable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: Shawn Guo <shawn.guo@linaro.org> Cc: <stable@vger.kernel.org> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-03-04mmc: core: fix regression: set default clock gating delay to 0Guennadi Liakhovetski
A recent commit "mmc: core: Use delayed work in clock gating framework" (597dd9d79cfbbb1) introduced a default 200ms delay before clock gating actually takes place. This means that every time an MMC interface becomes idle it first stays on for 200ms before gating its clock. This leads to increased power consumption and is therefore a clear regression. This patch restores the original behaviour by setting the default delay to 0. Users prioritising throughput over power efficiency can still modify the delay via sysfs. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-03-02mmc: atmel-mci: don't use dma features when using DMA with no chan availableLudovic Desroches
Some callbacks are set too early -- i.e. we can have dma capabilities but we can't get a dma channel. So wait to get the dma channel before setting callbacks and change logs consequently. Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> [Should be applied to 3.2-stable.] Cc: <stable@vger.kernel.org> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-02-13mmc: dw_mmc: Fix PIO mode with support of highmemSeungwon Jeon
Current PIO mode makes a kernel crash with CONFIG_HIGHMEM. Highmem pages have a NULL from sg_virt(sg). This patch fixes the following problem. Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = c0004000 [00000000] *pgd=00000000 Internal error: Oops: 817 [#1] PREEMPT SMP Modules linked in: CPU: 0 Not tainted (3.0.15-01423-gdbf465f #589) PC is at dw_mci_pull_data32+0x4c/0x9c LR is at dw_mci_read_data_pio+0x54/0x1f0 pc : [<c0358824>] lr : [<c035988c>] psr: 20000193 sp : c0619d48 ip : c0619d70 fp : c0619d6c r10: 00000000 r9 : 00000002 r8 : 00001000 r7 : 00000200 r6 : 00000000 r5 : e1dd3100 r4 : 00000000 r3 : 65622023 r2 : 0000007f r1 : eeb96000 r0 : e1dd3100 Flags: nzCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment xkernel Control: 10c5387d Table: 61e2004a DAC: 00000015 Process swapper (pid: 0, stack limit = 0xc06182f0) Stack: (0xc0619d48 to 0xc061a000) 9d40: e1dd3100 e1a4f000 00000000 e1dd3100 e1a4f000 00000200 9d60: c0619da4 c0619d70 c035988c c03587e4 c0619d9c e18158f4 e1dd3100 e1dd3100 9d80: 00000020 00000000 00000000 00000020 c06e8a84 00000000 c0619e04 c0619da8 9da0: c0359b24 c0359844 e18158f4 e1dd3164 e1dd3168 e1dd3150 3d02fc79 e1dd3154 9dc0: e1dd3178 00000000 00000020 00000000 e1dd3150 00000000 c10dd7e8 e1a84900 9de0: c061e7cc 00000000 00000000 0000008d c06e8a84 c061e780 c0619e4c c0619e08 9e00: c00c4738 c0359a34 3d02fc79 00000000 c0619e4c c05a1698 c05a1670 c05a165c 9e20: c04de8b0 c061e780 c061e7cc e1a84900 ffffed68 0000008d c0618000 00000000 9e40: c0619e6c c0619e50 c00c48b4 c00c46c8 c061e780 c00423ac c061e7cc ffffed68 9e60: c0619e8c c0619e70 c00c7358 c00c487c 0000008d ffffee38 c0618000 ffffed68 9e80: c0619ea4 c0619e90 c00c4258 c00c72b0 c00423ac ffffee38 c0619ecc c0619ea8 9ea0: c004241c c00c4234 ffffffff f8810000 0000006d 00000002 00000001 7fffffff 9ec0: c0619f44 c0619ed0 c0048bc0 c00423c4 220ae7a9 00000000 386f0d30 0005d3a4 9ee0: c00423ac c10dd0b8 c06f2cd8 c0618000 c0594778 c003a674 7fffffff c0619f44 9f00: 386f0d30 c0619f18 c00a6f94 c005be3c 80000013 ffffffff 386f0d30 0005d3a4 9f20: 386f0d30 0005d2d1 c10dd0a8 c10dd0b8 c06f2cd8 c0618000 c0619f74 c0619f48 9f40: c0345858 c005be00 c00a2440 c0618000 c0618000 c00410d8 c06c1944 c00410fc 9f60: c0594778 c003a674 c0619f9c c0619f78 c004a7e8 c03457b4 c0618000 c06c18f8 9f80: 00000000 c0039c70 c06c18d4 c003a674 c0619fb4 c0619fa0 c04ceafc c004a714 9fa0: c06287b4 c06c18f8 c0619ff4 c0619fb8 c0008b68 c04cea68 c0008578 00000000 9fc0: 00000000 c003a674 00000000 10c5387d c0628658 c003aa78 c062f1c4 4000406a 9fe0: 413fc090 00000000 00000000 c0619ff8 40008044 c0008858 00000000 00000000 Backtrace: [<c03587d8>] (dw_mci_pull_data32+0x0/0x9c) from [<c035988c>] (dw_mci_read_data_pio+0x54/0x1f0) r6:00000200 r5:e1a4f000 r4:e1dd3100 [<c0359838>] (dw_mci_read_data_pio+0x0/0x1f0) from [<c0359b24>] (dw_mci_interrupt+0xfc/0x4a4) [<c0359a28>] (dw_mci_interrupt+0x0/0x4a4) from [<c00c4738>] (handle_irq_event_percpu+0x7c/0x1b4) [<c00c46bc>] (handle_irq_event_percpu+0x0/0x1b4) from [<c00c48b4>] (handle_irq_event+0x44/0x64) [<c00c4870>] (handle_irq_event+0x0/0x64) from [<c00c7358>] (handle_fasteoi_irq+0xb4/0x124) r7:ffffed68 r6:c061e7cc r5:c00423ac r4:c061e780 [<c00c72a4>] (handle_fasteoi_irq+0x0/0x124) from [<c00c4258>] (generic_handle_irq+0x30/0x38) r7:ffffed68 r6:c0618000 r5:ffffee38 r4:0000008d [<c00c4228>] (generic_handle_irq+0x0/0x38) from [<c004241c>] (asm_do_IRQ+0x64/0xe0) r5:ffffee38 r4:c00423ac [<c00423b8>] (asm_do_IRQ+0x0/0xe0) from [<c0048bc0>] (__irq_svc+0x80/0x14c) Exception stack(0xc0619ed0 to 0xc0619f18) Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com> Acked-by: Will Newton <will.newton@imgtec.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-02-13mmc: atmel-mci: save and restore sdioirq when soft reset is performedLudovic Desroches
Sometimes a software reset is needed. Then some registers are saved and restored but the interrupt mask register is missing. It causes issues with sdio devices whose interrupts are masked after reset. Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-02-13mmc: block: Init ro_lock sysfs attr to fix lockdep warningsRabin Vincent
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com> Signed-off-by: Johan Rudholm <johan.rudholm@stericsson.com> Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Namjae Jeon <linkinjeon@gmail.com> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-02-13mmc: sh_mmcif: fix late delayed work initialisationGuennadi Liakhovetski
If the driver is loaded with a card in the slot, mmc_add_host() will schedule an immediate card-detection work, which will start IO and wait for command completion. Usually the kernel first returns to the sh_mmcif probe function, lets it finish and only then schedules the rescan work. But sometimes, expecially under heavy system load, the work will be scheduled immediately before returning to the probe method. In this case it is important for the driver to be fully prepared for IO. For sh_mmcif this means, that also the timeout work has to be initialised before calling mmc_add_host(). It is also better to prepare interrupts beforehand. Besides, since mmc_add_host() does card-detection itself, there is no need to do it again immediately afterwards. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-02-13mmc: tmio_mmc: fix card eject during IO with DMAGuennadi Liakhovetski
When DMA is in use and the card is ejected during IO, DMA transfers have to be terminated, otherwise the dmaengine driver fails to operate properly, when the card is re-inserted. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-02-13mmc: core: Fix comparison issue in mmc_compare_ext_csdsJurgen Heeks
Found this issue during code review. Actually, there are two issues which both compensate together in lucky case. In unlucky case the bus width probing might not work as expected. Signed-off-by: Jurgen Heeks <jurgen.heeks@nokia.com> Reviewed-by: Namjae Jeon <linkinjeon@gmail.com> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-02-13mmc: core: Fix PowerOff Notify suspend/resumeGirish K S
Modified the mmc_poweroff to resume before sending the poweroff notification command. In sleep mode only AWAKE and RESET commands are allowed, so before sending the poweroff notification command resume from sleep mode and then send the notification command. PowerOff Notify is tested on a Synopsis Designware Host Controller (eMMC 4.5). The suspend to RAM and resume works fine. Signed-off-by: Girish K S <girish.shivananjappa@linaro.org> Tested-by: Girish K S <girish.shivananjappa@linaro.org> Reviewed-by: Saugata Das <saugata.das@linaro.org> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-02-13mmc: sdhci-pci: set Medfield SDIO as non-removableAdrian Hunter
Set Medfield SDIO as non-removable to avoid un-necessary card detect activity. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-02-13mmc: core: add the capability for broken voltageJaehoon Chung
There is an understood mismatch between the voltage the host controller is set to and the voltage supplied to the card by a fixed voltage regulator. Teaching the driver to accept the mismatch is overly complicated. Instead just accept the regulator's voltage. This patch adds MMC_CAP2_BROKEN_VOLTAGE. If the voltage didn't satisfy between min_uV and max_uV, try to change the voltage in core.c. When changing the voltage, maybe use regulator_set_voltage(). In regulator_set_voltage(), check the below condition. /* sanity check */ if (!rdev->desc->ops->set_voltage && !rdev->desc->ops->set_voltage_sel) { ret = -EINVAL; goto out; } If some board should use the fixed-regulator, always return -EINVAL. Then, eMMC didn't initialize always. So if use a fixed-regulator, we need to add the MMC_CAP2_BROKEN_VOLTAGE. Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-02-13mmc: core: Fix low speed mmc card detection failureGirish K S
This patch fixes the failure of low speed mmc card detection. Signed-off-by: Girish K S <girish.shivananjappa@linaro.org> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-02-13mmc: esdhc: set the timeout to the max valueJerry Huang
When accessing the card on some FSL platform boards (e.g p2020, p1010, mpc8536), the following error is reported with the timeout value calculated: mmc0: Got data interrupt 0x00000020 even though no data operation was in progress. mmc0: Got data interrupt 0x00000020 even though no data operation was in progress. So we skip the calculation of timeout and use the max value to fix it. Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com> Signed-off-by: Gao Guanhua <B22826@freescale.com> Signed-off-by: Xie Xiaobo <X.Xie@freescale.com> Acked-by: Anton Vorontsov <cbouatmailru@gmail.com> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-02-13mmc: esdhc: add PIO mode supportJerry Huang
For some FSL ESDHC controllers (e.g. P2020E, Rev1.0), the SDHC can not work on DMA mode because of the hardware bug, so we set a broken dma flag and use PIO mode. Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com> Signed-off-by: Gao Guanhua <B22826@freescale.com> Acked-by: Anton Vorontsov <cbouatmailru@gmail.com> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-02-13mmc: core: Ensure clocks are always enabled before host interactionSujit Reddy Thumma
Ensure clocks are always enabled before any interaction with the host controller driver. This makes sure that there is no race between host execution and the core layer turning off clocks in different context with clock gating framework. Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Per Forlin <per.forlin@stericsson.com> Signed-off-by: Chris Ball <cjb@laptop.org>