summaryrefslogtreecommitdiff
path: root/drivers/mmc/host/tmio_mmc_pio.c
AgeCommit message (Collapse)Author
2013-02-24mmc: tmio: add support for the VccQ regulatorGuennadi Liakhovetski
Some SD/MMC interfaces use 2 power regulators: one to power the card itself (Vcc) and another one to pull signal lines up (VccQ). In case of eMMC and UHS SD cards the regulators also have to be configured to supply different voltages. The preferred order of turning supply power on and off is to turn Vcc first on and last off. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2013-02-24mmc: tmio-mmc: parse device-tree bindingsGuennadi Liakhovetski
Add parsing of common and driver-specific DT bindings to the tmio-mmc MMC host driver and the sh_mobile_sdhi interface layer. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2013-02-24mmc: sdhi, tmio: only check flags in tmio-mmc driver properGuennadi Liakhovetski
tmio-mmc platform flags can be set by various means, including caller drivers and device-tree bindings, therefore it is better to only check them in the tmio-mmc driver proper, not in caller drivers themselves. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2013-02-11mmc: remove unncessary mmc_gpio_free_cd() call from slot-gpio usersShawn Guo
Since slot-gpio uses devm_* managed functions in mmc_gpio_request_cd() now, we can remove those mmc_gpio_free_cd() call from host drivers' .probe() error path and .remove(). Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-11-28mmc: remove use of __devinitBill Pemberton
CONFIG_HOTPLUG is going away as an option so __devinit is no longer needed. Signed-off-by: Bill Pemberton <wfp5p@virginia.edu> Cc: Chris Ball <cjb@laptop.org> Cc: Manuel Lauss <manuel.lauss@gmail.com> Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl> Cc: Jarkko Lavinen <jarkko.lavinen@nokia.com> Cc: Venkatraman S <svenkatr@ti.com> Cc: Ian Molton <ian@mnementh.co.uk> Cc: Bruce Chang <brucechang@via.com.tw> Cc: Harald Welte <HaraldWelte@viatech.com> Cc: Pierre Ossman <pierre@ossman.eu> Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-07-21mmc: tmio: use generic GPIO CD and WP handlersGuennadi Liakhovetski
The tmio-mmc driver is already using the generic GPIO CD handler in IRQ mode. This patch adds support for CD polling mode and also checks for availability of a WP GPIO. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-07-21mmc: tmio: support caps2 flagsGuennadi Liakhovetski
Allow tmio mmc glue drivers to pass mmc_host::caps2 flags down to the mmc layer. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-07-21mmc: tmio: remove a duplicated comment lineGuennadi Liakhovetski
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-07-21mmc: tmio: add regulator supportGuennadi Liakhovetski
Currently the TMIO MMC driver derives the OCR mask from the platform data and uses a platform callback to turn card power on and off. This patch adds regulator support to the driver. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Cc: Liam Girdwood <lrg@ti.com> Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-07-21mmc: tmio: add callbacks to enable-update and disable the interface clockGuennadi Liakhovetski
Every time the clock is enabled after possibly being disabled, we have to re-read its frequency and update our configuration. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-07-21mmc: tmio: don't needlessly enable interrupts during probingGuennadi Liakhovetski
We don't have to force-enable MMC interrupts in our .probe() method, mmc_add_host() will trigger card detection, that will enable all the necessary interrupts. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-07-21mmc: tmio: Don't access hardware registers after stopping clocksLaurent Pinchart
The tmio_mmc_set_ios() function configures the MMC power, clock and bus width. When the mmc core requests the driver to power off the card, we inform runtime PM, that the controller can be suspended. This can lead to the MSTP clock being turned off. Writing to any 16-bit hardware registers with the MSTP clock off leads to timeouts and errors being printed to the kernel log. This can occur both when stopping the MMC clock and when configuring the bus width. To fix this, stop the MMC clock before calling put_runtime_pm(), and skip bus width configuration when power is off. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Tested-by: Simon Horman <horms@verge.net.au> Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-07-10mmc: extend and rename cd-gpio helpers to handle more slot GPIO functionsGuennadi Liakhovetski
GPIOs can be used in MMC/SD-card slots not only for hotplug detection, but also to implement the write-protection pin. Rename cd-gpio helpers to slot-gpio to make addition of further slot GPIO functions possible. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-07-10mmc: tmio: use MMC opcode defines instead of numbersGuennadi Liakhovetski
mmc.h defines macros for most frequently used MMC opcodes. Use them instead of hard-coded numbers. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-03-27mmc: tmio: cosmetic: prettify the tmio_mmc_set_ios() functionGuennadi Liakhovetski
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-03-27mmc: tmio_mmc: remove unused sdio_irq_enabled flagGuennadi Liakhovetski
The sdio_irq_enabled member of struct tmio_mmc_host is a left-over from the previously removed SDIO IRQ workaround. It is no longer needed and can now be removed too. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-03-27mmc: tmio_mmc: power status flag doesn't have to be exposed in platform dataGuennadi Liakhovetski
The controller power status flag does not have to be accessed from the hot-plug detection code any more, it can now be removed from the platform data and put in the controller private struct. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-03-27mmc: tmio_mmc: support the generic MMC GPIO card hotplug helperGuennadi Liakhovetski
If the platform specifies the TMIO_MMC_HAS_COLD_CD flag, use the generic MMC GPIO card hotplug helper. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-03-27mmc: tmio: calculate the native hotplug condition only onceGuennadi Liakhovetski
The condition, whether we have to use the native TMIO card hotplug detection interrupt, is rather complex, it is better to only calculate it once and store in the private data. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-03-27mmc: tmio_mmc: do not enable card hotplug interrupts, if unusedGuennadi Liakhovetski
If TMIO MMC is used in polling mode, or the card is non-removable, or card-detection is performed, using an external interrupt, there is no need to enable controller native card hotplug interrupts. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2012-03-16Merge branch 'pm-qos'Rafael J. Wysocki
* pm-qos: sh_mmcif / PM: Use PM QoS latency constraint tmio_mmc / PM: Use PM QoS latency constraint PM / QoS: Make it possible to expose PM QoS latency constraints
2012-03-13tmio_mmc / PM: Use PM QoS latency constraintRafael J. Wysocki
Make tmio_mmc call dev_pm_qos_expose_latency_limit() to expose the PM QoS latency limit to user space and specify the initial value of it as 100 microseconds. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
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-01-11mmc: tmio_mmc: Hotplug code regroupingBastian Hecht
This patch regroups the code slightly, adds documentation and allows the rtpm counter of MMC_CAP_NEEDS_POLL devices to reach 0 again. Signed-off-by: Bastian Hecht <hechtb@gmail.com> [g.liakhovetski@gmx.de: restore pm_runtime_get_noresume()] Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-12-10mmc: tmio: fix clock gating on platforms with a .set_pwr() methodGuennadi Liakhovetski
Do not power down the card in .set_ios(), unless MMC_POWER_OFF is requested. This fixes the SDHI functionality on ecovec. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-10-26mmc: replace printk with appropriate display macroGirish K S
All the files using printk function for displaying kernel messages in the mmc driver have been replaced with corresponding macro. Signed-off-by: Girish K S <girish.shivananjappa@linaro.org> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-10-26mmc: tmio: Provide separate interrupt handlersSimon Horman
Provide separate interrupt handlers which may be used by platforms where SDHI has three interrupt sources. This patch also removes the commented-out handling of CRC and other errors. Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Acked-by: Magnus Damm <magnus.damm@gmail.com> Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-10-26mmc: tmio: Cache interrupt masksSimon Horman
This avoids the need to look up the masks each time an interrupt is handled. As suggested by Guennadi. Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Acked-by: Magnus Damm <magnus.damm@gmail.com> Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-07-21mmc: tmio: fix a deadlockGuennadi Liakhovetski
Currently the tmio-mmc driver contains a recursive runtime PM method invocation, which leads to a deadlock on a mutex. Avoid it by taking care not to request DMA too early. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-07-21mmc: tmio: maximize power savingGuennadi Liakhovetski
This patch uses runtime PM to allow the system to power down the MMC controller, when the MMC closk is switched off. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-07-21mmc: tmio: fix recursive spinlock, don't schedule with interrupts disabledGuennadi Liakhovetski
Calling mmc_request_done() under a spinlock with interrupts disabled leads to a recursive spin-lock on request retry path and to scheduling in atomic context. This patch fixes both these problems by moving mmc_request_done() to the scheduler workqueue. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-07-20mmc: tmio: Fix race condition resulting in spurious interruptsPaul Parsons
There is a race condition in the tmio_mmc_irq() interrupt handler, caused by the presence of a while loop, which results in warnings of spurious interrupts. This was found on an HP iPAQ hx4700 whose HTC ASIC3 reportedly incorporates the Toshiba TC6380AF controller. Towards the end of a multiple read (CMD18) operation the handler clears the final RXRDY status bit in the first loop iteration, sees the DATAEND status bit at the bottom of the loop, and so clears the DATAEND status bit in the second loop iteration. However the DATAEND interrupt is still queued in the system somewhere and can't be delivered until the handler has returned. This second interrupt is then reported as spurious in the next call to the handler. Likewise for single read (CMD17) operations. And something similar occurs for multiple write (CMD25) and single write (CMD24) operations, where CMDRESPEND and TXRQ status bits are cleared in a single call. In these cases the interrupt handler clears two separate interrupts when it should only clear the one interrupt for which it was invoked. The fix is to remove the while loop. Signed-off-by: Paul Parsons <lost.distance@yahoo.com> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-07-20mmc: tmio: Share register access functionsSimon Horman
Move register access functions into a shared header. Use sd_ctrl_write16 in tmio_mmc_dma.c:tmio_mmc_enable_dma(). Other than avoiding (trivial) open-coding, the motivation for this is to allow platform-hooks in access functions to be applied across all applicable accesses. Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Cc: Magnus Damm <magnus.damm@gmail.com> Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-06-25mmc: tmio: fix regression in TMIO_MMC_WRPROTECT_DISABLE handlingGuennadi Liakhovetski
Commit b6147490e6aac82 ("mmc: tmio: split core functionality, DMA and MFD glue") broke handling of the TMIO_MMC_WRPROTECT_DISABLE flag by the tmio-mmc driver. This patch restores the original behaviour. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Cc: <stable@kernel.org> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-05-24mmc: tmio: runtime suspend the controller, where possibleGuennadi Liakhovetski
The TMIO MMC controller cannot be powered off to save power, when no card is plugged in, because then it will not be able to detect a new card-insertion event. On some implementations, however, it is possible to switch to using another source to detect card insertion. This patch adds support for such implementations. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-05-24mmc: tmio/sdhi: break out interrupt request/freeMagnus Damm
Move request_irq()/free_irq() from the shared code in tmio_mmc.c into the SDHI/tmio specific portion in sh_mobile_sdhi.c and tmio_mmc_pio.c. This is ground work to allow us to adjust the SDHI code with IRQ flags and number of interupt sources. Signed-off-by: Magnus Damm <damm@opensource.se> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-05-24mmc: protect the tmio_mmc driver against a theoretical raceGuennadi Liakhovetski
The MMC subsystem does not guarantee, that host driver .request() and .set_ios() callbacks are serialised. Such concurrent calls, however, do not have to be meaningfully supported, drivers just have to make sure to avoid any severe problems. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-05-24mmc: Add runtime and system-wide PM to the TMIO MMC driverGuennadi Liakhovetski
Add runtime and system-wide power management to the TMIO MMC driver in PIO and DMA modes, allowing it to properly save and restore its state during system suspend. Runtime PM is very crude ATM, because the controller has to be powered on all the time to detect card hotplug events. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-04-27mmc: tmio: fix .set_ios(MMC_POWER_UP) handlingGuennadi Liakhovetski
The aggressive clock gating for TMIO MMC patch has broken switching interface power on, using MFD or platform callbacks. Restore the ios->power_mode == MMC_POWER_UP && ios->clock == 0 case handling. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-03-31Fix common misspellingsLucas De Marchi
Fixes generated by 'codespell' and manually reviewed. Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
2011-03-26mmc: tmio_mmc: Move some defines into a shared headerSimon Horman
Also add TMIO_BBS. This allows these defines to also be used by zboot. Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Acked-by: Paul Mundt <lethal@linux-sh.org> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-03-25mmc: tmio: support aggressive clock gatingGuennadi Liakhovetski
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Acked-by: Paul Mundt <lethal@linux-sh.org> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-03-25mmc: tmio: fix power-mode interpretationGuennadi Liakhovetski
The power-mode sequence on MMC is MMC_POWER_OFF -> MMC_POWER_UP -> MMC_POWER_ON and not MMC_POWER_ON -> MMC_POWER_UP, as the driver currently is implying. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Acked-by: Paul Mundt <lethal@linux-sh.org> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-03-25mmc: tmio: remove work-around for unmasked SDIO interruptsGuennadi Liakhovetski
SDIO IRQs got unmasked on sh-mobile while writing to the CTL_CLK_AND_WAIT_CTL register, because that register at address 0x138 is not implemented on those SoCs and writes to it overwrite the register at address 0x38: CTL_SDIO_IRQ_MASK. Previous patches eliminated access to register above 0xff on sh-mobile, so that this work-around isn't needed anymore. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Acked-by: Paul Mundt <lethal@linux-sh.org> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-03-25mmc: tmio: only access registers above 0xff, if availableGuennadi Liakhovetski
Not all tmio implementations have registers above oxff. Accessing them on thise platforms is dangerous. In some cases it leads to address wrapping to addresses below 0x100, which corrupts random unrelated registers. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Acked-by: Paul Mundt <lethal@linux-sh.org> Signed-off-by: Chris Ball <cjb@laptop.org>
2011-03-25mmc: tmio: split core functionality, DMA and MFD glueGuennadi Liakhovetski
TMIO MMC chips contain an SD / SDIO IP core from Panasonic, similar to the one, used in MN5774 and other MN57xx controllers. These IP cores are included in many multifunction devices, in sh-mobile chips from Renesas, in the latter case they can also use DMA. Some sh-mobile implementations also have some other specialities, that MFD-based solutions don't have. This makes supporting all these features in a monolithic driver inconveniet and error-prone. This patch splits the driver into 3 parts: the core, the MFD glue and the DMA support. In case of a modular build, two modules will be built: mmc_tmio_core and mmc_tmio. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Acked-by: Paul Mundt <lethal@linux-sh.org> Signed-off-by: Chris Ball <cjb@laptop.org>