History log of /drivers/mmc/host/mmci.c
Revision Date Author Comments
89168b48991537bec2573b3b6a8841df74465b12 02-Oct-2014 Linus Walleij <linus.walleij@linaro.org> mmc: core: restore detect line inversion semantics

commit 98e90de99a0c43bd434da814c882c4332441871e
"mmc: host: switch OF parser to use gpio descriptors"
switched the semantic behaviour of card detect and read
only flags such that the inversion capability flag would
only be set if inversion was explicitly specified in the
device tree, in the hopes that no-one was using double
inversion.

It turns out that the XOR:ing between the explicit
inversion was indeed in use, so we need to restore the
old semantics where both ways of inversion are checked
and the end result XOR:ed.

Reported-by: Javier Martinez Canillas <javier@dowhile0.org>
Tested-by: Javier Martinez Canillas <javier@dowhile0.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
c73541336389f9fd72f592601c40a2e70320cf31 22-Aug-2014 Srinivas Kandagatla <srinivas.kandagatla@linaro.org> mmc: mmci: rename sdio flag in vendor data to st_sdio

This patch renames sdio flag in vendor data to st_sdio, as this flag is
only used to enable ST specific sdio setup. This will also ensure that
the ST specfic setup is not done on other vendor like Qualcomm.

Originally the issue was detected while testing WLAN ath6kl on IFC6410
board with APQ8064 SOC.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
5df014df12b1178e0b76b7273913ce1531ecf20e 22-Aug-2014 Srinivas Kandagatla <srinivas.kandagatla@linaro.org> mmc: mmci: Add sdio enable mask in variant data

This patch adds sdio enable mask in variant data, SOCs like ST have
special bits in datactrl register to enable sdio. Unconditionally setting
this bit in this driver breaks other SOCs like Qualcomm which maps this
bits to something else, so making this enable bit to come from variant
data solves the issue.

Originally the issue is detected while testing WLAN ath6kl on Qualcomm
APQ8064.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
ce437aa4519c46a0f12455c320b6f65dde16c26e 27-Aug-2014 Linus Walleij <linus.walleij@linaro.org> mmc: mmci: augment driver to handle gpio descriptors

Currently the MMCI driver will only handle GPIO descriptors
implicitly through the device tree probe glue in mmc_of_init(),
but devices instatiated other ways such as through board files
and passing descriptors using the GPIO descriptor table will
not be able to exploit descriptors.

Augment the driver to look for a GPIO descriptor if device
tree is not used for the device, and if that doesn't work,
fall back to platform data GPIO assignment using the old
API. The end goal is to get rid of the platform data integer
GPIO assingments from the kernel.

This enable the MMCI-embedding platforms to be converted to
GPIO descritor tables.

Cc: Alexandre Courbot <gnurou@gmail.com>
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
9cb15142d0e336874ecc753e9a4e5696c46a67d9 29-Jul-2014 Srinivas Kandagatla <srinivas.kandagatla@linaro.org> mmc: mmci: Add qcom dml support to the driver.

On Qualcomm APQ8064 SOCs, SD card controller has an additional glue
called DML (Data Mover Local/Lite) to assist dma transfers.
This hardware needs to be setup before any dma transfer is requested.
DML itself is not a DMA engine, its just a gule between the SD card
controller and dma controller.

Most of this code has been ported from qualcomm's 3.4 kernel.

This patch adds the code necessary to intialize the hardware and setup
before doing any dma transfers.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7878289b269d41c8e611aa6d4519feae706e49f3 13-Jun-2014 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Reverse IRQ handling for the arm_variant

Commit "mmc: mmci: Handle CMD irq before DATA irq", caused an issue
when using the ARM model of the PL181 and running QEMU.

The bug was reported for the following QEMU version:
$ qemu-system-arm -version
QEMU emulator version 2.0.0 (Debian 2.0.0+dfsg-2ubuntu1.1), Copyright
(c) 2003-2008 Fabrice Bellard

To resolve the problem, let's restore the old behavior were the DATA
irq is handled prior the CMD irq, but only for the arm_variant, which
the problem was reported for.

Reported-by: John Stultz <john.stultz@linaro.org>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Russell King <linux@arm.linux.org.uk>
Tested-by: Kees Cook <keescook@chromium.org>
Tested-by: John Stultz <john.stultz@linaro.org>
Cc: <stable@vger.kernel.org> # v3.15+
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
ad82bfea44835da9633548e2031a1af4a9965c14 12-Jun-2014 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Move all CMD irq handling to mmci_cmd_irq()

This patch won't change the behavior of how mmci deals with CMD irqs.
By moving code from mmci_irq() to mmci_cmd_irq(), we getter a better
overview of what going on.

Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Russell King <linux@arm.linux.org.uk>
Tested-by: Kees Cook <keescook@chromium.org>
Tested-by: John Stultz <john.stultz@linaro.org>
Cc: <stable@vger.kernel.org> # v3.15+
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1cb9da502835dad73dda772b20c1e792f4e71589 12-Jun-2014 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Remove redundant check of status for DATA irq

We don't need to verify the content of the status register twice, while
we are about to handle a DATA irq. Instead let's leave all verification
to be handled by mmci_data_irq().

Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Russell King <linux@arm.linux.org.uk>
Tested-by: Kees Cook <keescook@chromium.org>
Tested-by: John Stultz <john.stultz@linaro.org>
Cc: <stable@vger.kernel.org> # v3.15+
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
55b604ae4b50023356064f43c24ea896ee8e400a 02-Jun-2014 Srinivas Kandagatla <srinivas.kandagatla@linaro.org> mmc: mmci: Add Qualcomm Id to amba id table

This patch adds a fake Qualcomm ID 0x00051180 to the amba_ids, as Qualcomm
SDCC controller is pl180, but amba id registers read 0x0's.
The plan is to remove SDCC driver totally and use mmci as the main SD
controller driver for Qualcomm SOCs.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
9c34b73deec147a042c4bd871a373f76af70e38c 02-Jun-2014 Srinivas Kandagatla <srinivas.kandagatla@linaro.org> mmc: mmci: Add Qcom specific rx_fifocnt logic.

MCIFIFOCNT register behaviour on Qcom chips is very different than the other
pl180 integrations. MCIFIFOCNT register contains the number of
words that are still waiting to be transferred through the FIFO. It keeps
decrementing once the host CPU reads the MCIFIFO. With the existing logic and
the MCIFIFOCNT behaviour, mmci_pio_read will loop forever, as the FIFOCNT
register will always return transfer size before reading the FIFO.

Also the data sheet states that "This register is only useful for debug
purposes and should not be used for normal operation since it does not reflect
data which may or may not be in the pipeline".

This patch implements a qcom specific get_rx_fifocnt function which is
implemented based on status register flags. Based on qcom_fifo flag in
variant data structure, the corresponding get_rx_fifocnt function is selected.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
3f4e6f7b9175e2914b82134c4a6a02825f4766db 02-Jun-2014 Srinivas Kandagatla <srinivas.kandagatla@linaro.org> mmc: mmci: add explicit clk control

On Controllers like Qcom SD card controller where cclk is mclk and mclk should
be directly controlled by the driver.

This patch adds support to control mclk directly in the driver, and also
adds explicit_mclk_control flag in variant structure giving more flexibility
to the driver.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
[Ulf Hansson] Fixed checkpatch warning
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
dc6500bfe889321f7f4fd01e96062a80643d81c1 02-Jun-2014 Srinivas Kandagatla <srinivas.kandagatla@linaro.org> mmc: mmci: add f_max to variant structure

Some of the controller have maximum supported frequency, This patch adds
support in variant data structure to specify such restrictions. This
gives more flexibility in calculating the f_max before passing it to
mmc-core.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
ae7b0061f61e7c96884f4080b4e28544a0cedd76 02-Jun-2014 Srinivas Kandagatla <srinivas.kandagatla@linaro.org> mmc: mmci: Add support to data commands via variant structure.

On some SOCs like Qcom there are explicit bits in the command register
to specify if its a data transfer command or not. So this patch adds
support to such bits in variant data, giving more flexibility to the
driver.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
e8740644ab5f906e131596d7580701b2ca855210 02-Jun-2014 Srinivas Kandagatla <srinivas.kandagatla@linaro.org> mmc: mmci: add edge support to data and command out in variant data.

This patch adds edge support for data and command out to variant structure
giving more flexibility to the driver to support more SOCs which have
different clock register layout.

Without this patch other new SOCs like Qcom will have to add more code to
special case them

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
[Ulf Hansson] Resolved conflict
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
e1412d85a8e50d2b22970df29a804477582a6637 02-Jun-2014 Srinivas Kandagatla <srinivas.kandagatla@linaro.org> mmc: mmci: add 8bit bus support in variant data

This patch adds 8bit bus enable to variant structure giving more flexibility
to the driver to support more SOCs which have different clock register layout.

Without this patch other new SOCs like Qcom will have to add more code
to special case them.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
[Ulf Hansson] Resolved conflict
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
e17dca2b2df30676adbbc18a1022884dc73187a5 02-Jun-2014 Srinivas Kandagatla <srinivas.kandagatla@linaro.org> mmc: mmci: add ddrmode mask to variant data

This patch adds ddrmode mask to variant structure giving more flexibility
to the driver to support more SOCs which have different datactrl register
layout.

Without this patch datactrl register is updated with incorrect ddrmode mask,
resulting in failures on Qualcomm SD Card Controller.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
[Ulf Hansson] Resolved conflict
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
ff783233cc13eca99a3b59c0609c1ffc6164b7a2 02-Jun-2014 Srinivas Kandagatla <srinivas.kandagatla@linaro.org> mmc: mmci: Add Qcom datactrl register variant

Instance of this IP on Qualcomm's SOCs has bit different layout for datactrl
register. Bit position datactrl[16:4] hold the true block size instead of power
of 2.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6adb2a804a943a348eadfb09266571cd4557387c 02-Jun-2014 Srinivas Kandagatla <srinivas.kandagatla@linaro.org> mmc: mmci: Add enough delay between writes to CMD register.

On Qcom SD Card controller POWER, CLKCTRL, DATACTRL and COMMAND registers
should be updated in MCLK domain, and writes to these registers must be
separated by three MCLK cycles. This resitriction is not applicable for
other registers. Any subsequent writes to these register will be ignored
until 3 MCLK have passed.

One usec delay between two CMD register writes is not sufficient in the
card identification phase where the CCLK is very low. This patch replaces
a static 1 usec delay to use mmci_reg_delay function which can provide
correct delay depending on the cclk frequency.

Without this patch the card is not detected.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
c4a357691693776f5f941f29bdce704b29b156ba 02-Jun-2014 Srinivas Kandagatla <srinivas.kandagatla@linaro.org> mmc: mmci: use NSEC_PER_SEC macro

This patch replaces a constant used in calculating timeout with a proper
macro. This is make code more readable.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
8c3a05b489ef097f86bf87c64192456553f57781 20-May-2014 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Enforce DMA configuration through DT

Remove the option to provide DMA configuration as platform data,
enforce it through DT.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Roland Stigge <stigge@antcom.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
5080a08d0f8a4b2ba3a15e5ddc5ece84a444cad8 21-Mar-2014 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Enforce max frequency configuration through DT

Remove the option to provide a maximum frequency as platform data,
enforce it through DT.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
3faf80dfa342e98b5780e0b78b7a670c7b61a9be 21-Mar-2014 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Enforce mmc capabilities through DT

Remove the option to provide the flags for mmc capabilities as platform
data, enforce it through DT.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
4593df29b94b31de931dc20d7da2e6c468c8d473 21-Mar-2014 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Enforce DT for signal direction and feedback clock

Remove the option to provide signal direction configuration and
feeback clock as platform data, enforce it through DT.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
9dd8a8b81c7c947e9be29ca047f10ac9910a41bb 19-Mar-2014 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Enable MMC_CAP_CMD23

This is pure software configuration, which mmci has been supporting for
a while. Let's enable it as default so we can take benefit from it.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
78f87df2b4f8760954d7d80603d0cfcbd4759683 17-Mar-2014 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Use the common mmc DT parser

Let mmci DT parser only handle the specific bindings related to mmci
and extend the DT support by converting to the common mmc DT parser.

While both DT and platform data exist, DT takes precedence. If there
are supplied DT data, the card detect and write protect GPIOS are
enforced to be provided through it.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1a7e99c1fe080cc75ab34e1cbf788ed09b2f58b5 31-Mar-2014 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Add DT bindings for feedback clock pin

The ST Micro variant supports the option of using a feedback clock signal in
favor of the clockout pin when latching incoming signals on the data bus.

Since this is matter of how pins are being routed we need to provide a new DT
binding to be able to configure this through DT.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
ae94cafe293343c2680c638c7af8499d708e4d71 18-Mar-2014 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Add DT bindings for signal direction

Some variants have support for indicating the bus signal directions,
which currently are configured through platform data.

Add corresponding DT bindings to enable us to move away from using the
platform data.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
ef289982f2cf9f36c64b3e64d584b74b6ea2e70b 17-Mar-2014 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Convert to devm functions

Converting to devm functions to simplify error handling in ->probe() and
to cleanup ->remove().

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
d2762090153053bca984ce5f8978953f63390401 17-Mar-2014 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Convert to the mmc gpio API

To avoid duplication of code while handling card detect and write
protect GPIO pins/irqs, let's convert to use the mmc gpio API.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
f3737fa388388bc864bc63b1c70e3679fe839a52 23-Jan-2014 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Put the device into low power state at system suspend

For CONFIG_PM_SLEEP, the device were always left in full power state
after system suspend.

We solely relied on a power domain to put it into low power state,
which is an unreasonable requirement to put on SOCs to implement.
Especially for those SOCs not supporting power domains at all.

Use pm_runtime_force_suspend|resume() as the system suspend callbacks,
to resolve the issue.

Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
571dce4f105cf2b8e57ec4330da71bd0cb6d38bb 23-Jan-2014 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Let runtime PM callbacks be available for CONFIG_PM

Convert to the SET_PM_RUNTIME_PM macro while defining the runtime PM
callbacks. This means the callbacks becomes available for both
CONFIG_PM_SLEEP and CONFIG_PM_RUNTIME, which is needed to handle the
combinations of these scenarios.

Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
42dcc89a914722635814ae405cfdacfeccad82d1 23-Jan-2014 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Mask IRQs for all variants during runtime suspend

In runtime suspended state, we are not expecting IRQs and thus we can
safely mask them, not only for pwrreg_nopower variants but for all.

Obviously we then also need to make sure we restore the IRQ mask while
becoming runtime resumed.

Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6dad6c9594577969f6d74ca1b344e00314bb3b64 14-Mar-2014 Seungwon Jeon <tgih.jun@samsung.com> mmc: mmci: clarify DDR timing mode between SD-UHS and eMMC

Added MMC_DDR52 as eMMC's DDR mode distinguished from SD-UHS.

CC: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <chris@printf.net>
8d94b54d99ea968a9d188ca0e68793ebed601220 13-Jan-2014 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Enable support for busy detection for ux500 variant

The ux500 variants have HW busy detection support, which is indicated
by the busy_detect flag. For these variants let's enable the
MMC_CAP_WAIT_WHILE_BUSY flag and add the support for it.

The mmc core will provide the RSP_BUSY command flag for those requests
we should care about busy detection. Regarding the max_busy_timeout,
the HW don't support busy detection timeouts so at this initial step
let's make it simple and set it to zero to indicate we are able to
support any timeout.

Cc: Russell King <linux@arm.linux.org.uk>
Cc: Johan Rudholm <jrudholm@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <chris@printf.net>
e7f3d22289e4307b3071cc18b1d8ecc6598c0be4 10-Jan-2014 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Handle CMD irq before DATA irq

In case of a read operation both MCI_CMDRESPEND and MCI_DATAEND can be
set in the status register when entering the interrupt handler. This is
due to that the card start sending data before the host has
acknowledged the command response.

To resolve the issue for this scenario, we must start by handling the
CMD irq instead of the DATA irq. The reason is beacuse the completion
of the DATA irq will not respect the current command and then causing
it to be garbled.

Cc: Russell King <linux@arm.linux.org.uk>
Cc: Johan Rudholm <jrudholm@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <chris@printf.net>
23c34527a45885cd8f9dd58294de3cbaa32b10be 26-Nov-2013 Michal Simek <michal.simek@xilinx.com> ARM: 7906/1: mmc: mmci: Remove unnecessary amba_set_drvdata()

Driver core clears the driver data to NULL after device_release
or on probe failure, so just remove it from here.

Driver core change:
"device-core: Ensure drvdata = NULL when no driver is bound"
(sha1: 0998d0631001288a5974afc0b2a5f568bcdecb4d)

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
578aebc7d6eca1de7a641b7ab0e70db73a42bcfa 26-Sep-2013 Ulf Hansson <ulf.hansson@linaro.org> mmc: mmci: Move away from using deprecated APIs

Suspend and resume of cards are being handled from the protocol layer
and consequently the mmc_suspend|resume_host APIs are deprecated.

This means we can simplify the suspend|resume callbacks by removing the
use of the deprecated APIs.

Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
1ff44433c661c30afde6e6d2c47a29039a293da4 04-Sep-2013 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7834/1: mmc: mmci: Save and restore register context

If a corresponding power domain exists for the device and it manages
to cut the domain regulator while the device is runtime suspended,
the IP loses it's registers context. We restore the context in the
.runtime_resume callback from the existing register caches to adapt
to this situation.

We also want to make sure the registers are in a known state while
restoring context in the case when the power domain did not drop the
power, since there are restrictions for the order of writing to these
registers. To handle this, we clear the registers in the
.runtime_suspend callback.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Rickard Andersson <rickard.andersson@stericsson.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
f829c04204de83aa0d13307d2a2dc07c0d9a94e3 04-Sep-2013 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7833/1: mmc: mmci: Adapt to register write restrictions

After a write to the MMCICLOCK register data cannot be written to this
register for three feedback clock cycles. Writes to the MMCIPOWER
register must be separated by three MCLK cycles. Previously no issues
has been observered, but using higher ARM clock frequencies on STE-
platforms has triggered this problem.

The MMCICLOCK register is written to in .set_ios and for some data
transmissions for SDIO. We do not need a delay at the data transmission
path, because sending and receiving data will require more than three
clock cycles. Then we use a simple logic to only delay in .set_ios and
thus we don't affect throughput performance.

Signed-off-by: Johan Rudholm <jrudholm@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Rickard Andersson <rickard.andersson@stericsson.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
e36bd9c6c99f47902d6fd6804730aa587ae275a0 04-Sep-2013 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7832/1: mmc: mmci: Use optional sleep pinctrl state

By optionally putting the pins into sleep state in the .runtime_suspend
callback we can accomplish two things. One is to minimize current leakage
from pins and thus save power, second we can prevent the IP from driving
pins output in an uncontrolled manner, which may happen if the power domain
drops the domain regulator.

When returning from idle, entering .runtime_resume callback, the pins
are restored to default state.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Rickard Andersson <rickard.andersson@stericsson.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
edaf6d3d264ae9323a53a49b2a1cf42cc5df1be2 04-Sep-2013 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7831/1: mmc: mmci: Adapt to new pinctrl handling

There is no need for every driver to fetch a pinctrl handle and to
select the default state. Instead this is handled by the device driver
core, thus we can remove this piece of code from mmci.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
0125962000777cd1e2ce53deefb99779d5ee5199 15-May-2013 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7726/1: mmc: mmci: Add card_busy function to improve UHS card support

To verify a signal voltage switch at initialization of UHS cards the
.card_busy callback is used. For some of the ST-variants, card busy
detection on the DAT0 pin is supported.

We extend the variant struct with a busy_detect flag to indicate
support for it. A corresponding busy detect function, which polls the
busy status bit, is then set to the .card_busy callback.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
9cc639a20fdc0b935e55d4992f93963f95233ca4 15-May-2013 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7725/1: mmc: mmci: Cache MMCIDATACTRL register

Add a cache variable in the host struct that reflects the current data in
the MMCIDATACTRL register. This patch will not introduce any functional
change but instead provide an easy option to keep specific bits in the
register between each data transfer.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
0f3ed7f75cf1a16df9309f3a9ffaf62a3fc1f0bb 15-May-2013 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7724/1: mmc: mmci: Support signal voltage switch for UHS cards

Add .start_signal_voltage_switch callback to be able to support UHS cards.
The voltage switch requires the optional vqmmc regulator to exist since
the actual voltage switch will be performed directly on it.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
7c0136ef773c206e242b9718740377a45747bd70 14-May-2013 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7721/1: mmc: mmci: Fixup regulator handling for vqmmc

We can not rely on regulator_is_enabled to decide whether to
enable|disable the regulator. It would mean that the reference
counter for it is not balanced properly.

Instead keep track of our internal state by using a new flag in
the host struct, so we can take correct decisions.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1fd83f0ecf87e33ab560e8229842cf10f91552ee 03-May-2013 Lee Jones <lee.jones@linaro.org> ARM: 7713/1: mmc: mmci: Allow MMCI to request channels with information acquired from DT

Currently, if DMA information isn't passed from platform data, then DMA
will not be used. This patch allows DMA information obtained though Device
Tree to be used as well.

Cc: Chris Ball <cjb@laptop.org>
Cc: linux-mmc@vger.kernel.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
024629c62ffc25f267d57bf588cc10c96ccc0ce5 13-May-2013 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7719/1: mmc: mmci: Support for CMD23

Support added for transmission of CMD23 during multi block read or
write. In order to activate this feature, MMC_CAP_CMD23 flag needs
to be enabled in the capabilities field. Note that CMD23 support is
mandatory to support features like reliable write, data tag, context
ID, packed command.

This patch is based upon a patch from Saugata Das.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
c58a85090c8fbf7274af5ed0fe30828320c40ad6 13-May-2013 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7718/1: mmc: mmci: Set actual clock for debug purpose

Update cclk to the acutal used value and copy it to the actual_clock
variable in the mmc host for debug purpose.

Signed-off-by: Fredrik Soderstedt <fredrik.soderstedt@stericsson.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
665ba56fdab1670ef686ec35569aa1de0ec4ef4d 13-May-2013 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7717/1: mmc: mmci: Use devm_clk_get API

Converting to devm_clk_get simplifies error handling in probe
and we can remove other corresponding calls to clk_put.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
db90f91f6f4a870583d5c11cda187f20e4d835ae 03-May-2013 Lee Jones <lee.jones@linaro.org> ARM: 7714/1: mmc: mmci: Ensure return value of regulator_enable() is checked

This patch suppresses the warning below:

drivers/mmc/host/mmci.c: In function ‘mmci_set_ios’:
drivers/mmc/host/mmci.c:1165:20: warning: ignoring return value of
‘regulator_enable’, declared with attribute warn_unused_result
[-Wunused-result]

Cc: Chris Ball <cjb@laptop.org>
Acked-by: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
237fb5e675a312a84a602ad0fbdf0b4957c71073 31-Jan-2013 Lee Jones <lee.jones@linaro.org> mmc: mmci: Move ios_handler functionality into the driver

There are currently two instances of the ios_handler being used.
Both of which mearly toy with some regulator settings. Now there
is a GPIO regulator API, we can use that instead, and lessen the
per platform burden. By doing this, we also become more Device
Tree compatible.

Acked-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
653a761e4ba70bf12174dedcd5fbbf54f431abb3 21-Jan-2013 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7630/1: mmc: mmci: Fixup and cleanup code for DMA handling

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 corrections at DMA errors for terminating the same
DMA job twice has also been fixed.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Per Forlin <per.forlin@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
3a37298ada749897ec2c5c1cdcd5932218eb2928 24-Jan-2013 Pawel Moll <pawel.moll@arm.com> ARM: 7631/1: mmc: mmci: Add new VE MMCI variant

The Versatile Express IOFPGA as shipped on VECD 5.0 (bitfiles v108/208
and v116/216) contains a modified version of the PL180 MMCI, with
PeriphID Configuration value changed to 0x2.

This version adds an optional "hardware flow control" feature. When
enabled MMC card clock will be automatically disabled when FIFO is
about to over/underflow and re-enabled once the host retrieved some
data. This makes the controller immune to over/underrun errors caused
by big interrupt handling latencies.

This patch adds relevant device variant in the driver.

Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
f4670daef5e81aa312f5a18f571dbd8169ce079e 09-Jan-2013 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7623/1: mmc: mmci: Fixup clock gating when freq is 0 for ST-variants

In the ST Micro variant, the MMCICLOCK register must not be used to
gate the clock. Instead use MMCIPOWER register and by clearing the
PWR_ON bit to do this.

Signed-off-by: Johan Rudholm <johan.rudholm@stericsson.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
8259293aee1d44d7ebf0c644ef48db835653ebc3 09-Jan-2013 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7622/1: mmc: mmci: Gate the clock in runtime suspend to save power

The amba bus is already performing same actions but for the apb_pclk.
So here we just make sure the clock to card is gated as well to save
more power. At runtime resume we will thus restore the clock again.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Kevin Liu <kliu5@marvell.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
599c1d5c750ddf528c7c6d3cdc466708f0502e66 07-Jan-2013 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7620/1: mmc: mmci: Convert to use mmc_regulator_get_supply

By using the mmc_regulator_get_supply API we are able to do some
cleanups of the regulator code. Additionally let the regulator
API handle the error printing.

Cc: Chris Ball <cjb@laptop.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
70be208f0bd75eb81264f681e36485d0617d612f 07-Jan-2013 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7618/1: mmc: mmci: Support MMC_PM_KEEP_POWER

Add MMC_PM_KEEP_POWER to pm_caps so SDIO clients are able
to use this option to prevent power off in suspend.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
6dbb6ee090e810be337945a7a64d647549b70328 07-Jan-2013 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7617/1: mmc: mmci: Support for DDR mode

Add support for DDR mode which may be used for the ux500v2 variant.
Corresponding capabilities to enable the DDR support must be set in
the platform struct to enable the functionality.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
4b85da08c4d19f5de48d904d4f879dcfa04ec14c 10-Dec-2012 Davide Ciminaghi <ciminaghi@gnudd.com> ARM: 7596/1: mmci: replace readsl/writesl with ioread32_rep/iowrite32_rep

Not all the architectures have readsl/writesl,
use the more portable ioread32_rep/iowrite32_rep functions instead.

Signed-off-by: Davide Ciminaghi <ciminaghi@gnudd.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
6e0ee714fdab0568c3487455951dea2673e9557f 19-Nov-2012 Bill Pemberton <wfp5p@virginia.edu> mmc: remove use of __devexit

CONFIG_HOTPLUG is going away as an option so __devexit is no
longer needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Manuel Lauss <manuel.lauss@gmail.com>
Cc: Chris Ball <cjb@laptop.org>
Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: Jarkko Lavinen <jarkko.lavinen@nokia.com>
Cc: Venkatraman S <svenkatr@ti.com>
Cc: Viresh Kumar <viresh.linux@gmail.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: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
c3be1efd41a97f93be390240387d356a07b664c7 19-Nov-2012 Bill Pemberton <wfp5p@virginia.edu> mmc: remove use of __devinit

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>
0433c14356702e296f474f77ebd42f0a9d9a5487 19-Nov-2012 Bill Pemberton <wfp5p@virginia.edu> mmc: remove use of __devexit_p

CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer
needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Chris Ball <cjb@laptop.org>
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: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
a9a83785def8bf9142b37c86ffcb0fdc93fb851e 29-Oct-2012 Linus Walleij <linus.walleij@linaro.org> ARM: 7562/2: MMCI: fetch pinctrl handle and set default state

This fetches the pinctrl resource for the MMCI driver, and if
a "default" state is found, it is activated.

Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
70ac09358cc52f3ddbf73555dc150d486a7133bb 12-Oct-2012 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7552/1: mmc: mmci: Switching off HWFC for SDIO depends on MCLK

For writes, HWFC shall be switched off when transfer size <= 8
bytes and when MCLK rate is above 50 MHz. For 50MHz and below
it shall be switched off when transfer size < 8 bytes.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Johan Rudholm <johan.rudholm@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
06c1a121805d7870abbf037d3ccd9a609a5219f2 12-Oct-2012 Ulf Hansson <ulf.hansson@linaro.org> ARM: 7551/1: mmc: mmci: Fix incorrect handling of HW flow control for SDIO

For data writes <= 8 bytes, HW flow control was disabled but
never re-enabled when the transfer was completed. This meant
that a following read request would give buffer overrun errors.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Johan Rudholm <johan.rudholm@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
ac940938df138acd241dc5ae9a933416da036a35 26-Aug-2012 Julia Lawall <Julia.Lawall@lip6.fr> mmc: mmci: use clk_prepare_enable and clk_disable_unprepare

clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare. They make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.

A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e;
@@

- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);

@@
expression e;
@@

- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Chris Ball <cjb@laptop.org>
2805b9ab7c836cfbe01e86129983e36205078cb2 17-Jun-2012 Roland Stigge <stigge@antcom.de> ARM: 7427/1: mmc: mmci: Defer probe() in case of yet uninitialized GPIOs

If the GPIOs used by the MMCI driver are not registered yet when the driver is
probe()d, they can't be used. This happens if the mmci driver is probed before
the respective GPIO controller (e.g. on the LPC32xx EA3250 board, the PCA9532
GPIO controller would be initialized via DT after mmci). Therefore, we defer
mmci in this case.

Signed-off-by: Roland Stigge <stigge@antcom.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
f43380981716c9b48bf2809e4cd1cb0c6b71429d 17-Jun-2012 Roland Stigge <stigge@antcom.de> ARM: 7426/1: mmc: mmci: Remove wrong error handling of gpio 0

Zero is a valid GPIO and shouldn't be handled as an error return code from
of_get_named_gpio(). It was a leftover from old code before getting
pdata->gpio_*() was modified.

Signed-off-by: Roland Stigge <stigge@antcom.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
b9b52918abe88d9135dd570fb394b9c432eb1cfd 12-Jun-2012 Lee Jones <lee.jones@linaro.org> ARM: 7422/1: mmc: mmci: Allocate platform memory during Device Tree boot

When booting with Device Tree enabled, platform specific information
is gathered by parsing the DT binary. Platform data is subsequently
populated with the result. The memory required for this is not
automatically allocated during Device Tree boot, so we'll do it here
instead.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
c0a120a4bc68f5dc5f5238e76013cc18bac0ffed 08-May-2012 Lee Jones <lee.jones@linaro.org> mmc: mmci: Fix compiler error when CONFIG_OF is not set

error: implicit declaration of function 'mmci_dt_populate_generic_pdata'

This is due to the '#if CONFIG_OF' guards placed around
mmci_dt_populate_generic_pdata(), but not around the call to it. We
repair this by inserting a stub which elegantly returns when CONFIG_OF
is not set.

Reported-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
9a597016058520665452390df919428e4edd7770 12-Apr-2012 Lee Jones <lee.jones@linaro.org> mmc: mmci: Use correct GPIO binding for IRQ requests

Now there are irqdomains in place for Snowball, we can request GPIO
IRQs directly by their binding. This replaces the previous method
of hard-coding the hwirq using u32 values in the DT.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
000bc9d5ed296550e7009f56cbdb4b35459beb69 16-Apr-2012 Lee Jones <lee.jones@linaro.org> mmc: mmci: Enable Device Tree support for ux500 variants

Provide a means to collect attributes specific to ST-Ericsson's ux500
variant series. This patch registers itself as the AMBA driver to be
called during the probe process. Once all attributes and ux500 specifics
are are collected the normal mmci core probe is called.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Chris Ball <cjb@laptop.org>
dfb85185bda373a70409c70c2632b02fb0f8f449 03-May-2012 Russell King <rmk+kernel@arm.linux.org.uk> AMBA: get rid of last two uses of NO_IRQ

This gets rid of the last two users of NO_IRQ in AMBA primecell
drivers.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
34fd421349ffc6a4280b71276bf7c6d48f92156f 10-Apr-2012 Linus Walleij <linus.walleij@linaro.org> ARM: 7378/1: mmci: add support for the Nomadik MMCI variant

The Nomadik variant is somewhere inbetween the U300 and the Ux500
variant, its actually expose the same primecell ID as the U300
but had different characteristics so it needs a small revision
bump and hard-coding from the board/device tree. After this it
works just fine.

Acked-by: Ulf Hansson <ulf.hansson@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
16052827d98fbc13c31ebad560af4bd53e2b4dd5 08-Mar-2012 Alexandre Bounine <alexandre.bounine@idt.com> dmaengine/dma_slave: introduce inline wrappers

Add inline wrappers for device_prep_slave_sg() and device_prep_dma_cyclic()
interfaces to hide new parameter from current users of affected interfaces.
Convert current users to use new wrappers instead of direct calls.
Suggested by Russell King [https://lkml.org/lkml/2012/2/3/269].

Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
9e5ed094c89e55fbf11d2e81d60be98eb12346c0 15-Mar-2012 viresh kumar <viresh.kumar@st.com> ARM: 7362/1: AMBA: Add module_amba_driver() helper macro for amba_driver

For simple modules that contain a single amba_driver without any
additional setup code then ends up being a block of duplicated
boilerplate. This patch adds a new macro, module_amba_driver(),
which replaces the module_init()/module_exit() registrations with
template functions.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
8f7f6b7e46117edb83d12a508fffa0f013457677 24-Feb-2012 Will Deacon <will.deacon@arm.com> mmc: mmci: reduce max_blk_count to avoid overflowing max_req_size

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>
258aea76f552cc755da92e7e823abbb85e021514 01-Feb-2012 Viresh Kumar <viresh.kumar@st.com> dmaengine: Pass dma_slave_config .device_fc = NULL for all existing users

.device_fc is added in struct dma_slave_config recently. All user drivers, which
want DMA to be the flow controller must pass this field as false. As earlier
driver don't look to use this feature, mark it false for now.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
7437cfa532842ce75189826742bddf1ba137f58e 18-Jan-2012 Ulf Hansson <ulf.hansson@stericsson.com> ARM: 7280/1: mmc: mmci: Cache MMCICLOCK and MMCIPOWER register

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>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
023f117c547719fbc087ad72276aec5a026370df 18-Dec-2011 Russell King <rmk+kernel@arm.linux.org.uk> ARM: amba: make irq 0 invalid

Fix core bus and MMCI such that irq 0 means that there is no IRQ
attached.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
393e5e24165d0bef60489ecd0baef085e9af2e5a 13-Dec-2011 Ulf Hansson <ulf.hansson@stericsson.com> ARM: 7230/1: mmc: mmci: Fix PIO read for small SDIO packets

Corrects a bug in MMCI host driver which silently causes
small reads (< 4 bytes as only used in SDIO) from PL-18X to fail.

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>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
7258db7efe7d9c5eb80151554faa1fa7411d6e3e 13-Dec-2011 Ulf Hansson <ulf.hansson@stericsson.com> ARM: 7227/1: mmc: mmci: Prepare for SDIO before setting up DMA job

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 <ulf.hansson@stericsson.com>
Signed-off-by: Stefan Nilsson XK <stefan.xk.nilsson@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2cd976c46472e34460349ed43a217e34f90bad55 13-Dec-2011 Ulf Hansson <ulf.hansson@stericsson.com> ARM: 7223/1: mmc: mmci: Fixup use of runtime PM and use autosuspend

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: Russell King <rmk+kernel@arm.linux.org.uk>
48fa700388bec2ba79e9c8cc087f39c800a6fff5 13-Dec-2011 Ulf Hansson <ulf.hansson@stericsson.com> ARM: 7221/1: mmc: mmci: Change from using legacy suspend

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: Russell King <rmk+kernel@arm.linux.org.uk>
bc521818e28042bb6018d91c353d24fb01ccb162 13-Dec-2011 Ulf Hansson <ulf.hansson@stericsson.com> ARM: 7219/1: mmc: mmci: Change vdd_handler to a generic ios_handler

The purpose of the vdd_handler does not make sense. We remove it
and use a generic approach instead. A new ios_handler is 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 power register bits. This option is superfluous and is
therefore removed.

Adaptaptions from the old vdd_handler to the new ios_handler is done for
mach-ux500 board, which was the only one using the vdd_handler.

This patch is based upon a patch from Sebastian Rasmussen.

Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Rasmussen <sebastian.rasmussen@stericsson.com>
Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
4d1a3a0dc551cfa7304ca46e014231500f3b81a6 13-Dec-2011 Ulf Hansson <ulf.hansson@stericsson.com> ARM: 7218/1: mmc: mmci: Provide option to configure bus signal direction

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.

Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Rasmussen <sebastian.rasmussen@stericsson.com>
Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
7d72a1d48af95211677ea83157945a8ef76b0751 13-Dec-2011 Ulf Hansson <ulf.hansson@stericsson.com> ARM: 7217/1: mmc: mmci: Put power register deviations in variant data

Use variant data to store hardware controller deviations concerning
power registers to improve readability of the code.

Signed-off-by: Sebastian Rasmussen <sebastian.rasmussen@stericsson.com>
Tested-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
5074d25dc97ac2d93fca7852563b7e204f03464a 13-Dec-2011 Ulf Hansson <ulf.hansson@stericsson.com> ARM: 7216/1: mmc: mmci: Do not release spinlock in request_end

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: Russell King <rmk+kernel@arm.linux.org.uk>
5a09262744a0b84719b933ac66801de058776755 14-Nov-2011 Per Forlin <per.forlin@stericsson.com> mmc: mmci: add capabilities2 for MMC_CAP2

Signed-off-by: Per Forlin <per.forlin@stericsson.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
3b6e3c73851a9a4b0e6ed9d378206341dd65e8a5 13-Dec-2011 Ulf Hansson <ulf.hansson@stericsson.com> ARM: 7220/1: mmc: mmci: Fixup error handling for dma

When getting a cmd irq during an ongoing data transfer
with dma, the dma job were never terminated. This is now
corrected.

Cc: <stable@vger.kernel.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Per Forlin <per.forlin@stericsson.com>
Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
b63038d6f4ca5d1849ce01d9fc5bb9cb426dec73 13-Dec-2011 Ulf Hansson <ulf.hansson@stericsson.com> ARM: 7214/1: mmc: mmci: Fixup handling of MCI_STARTBITERR

The interrupt was previously enabled and then correctly cleared.
Now we also handle it correctly.

Cc: <stable@vger.kernel.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
9f99835f1121bf81f1323b6267ea2957a179da2b 05-Oct-2011 Dave Martin <dave.martin@linaro.org> mmc: mmci: Enable module alias autogeneration for AMBA drivers

Signed-off-by: Dave Martin <dave.martin@linaro.org>
05f5799cbe5c9e2c03f604b3de5783cf4d726227 14-Oct-2011 Vinod Koul <vinod.koul@linux.intel.com> mmc-host: move to dma_transfer_direction

fixup usage of dma direction by introducing dma_transfer_direction,
this patch moves mmc drivers to use new enum

Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Chris Ball <cjb@laptop.org>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
a3c76eb9d4a1e68a69dd880cf0bcb8a52418b993 11-Oct-2011 Girish K S <girish.shivananjappa@linaro.org> mmc: replace printk with appropriate display macro

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>
8e3336b1e4378f7d205af9b25dcc9e645c8a9609 29-Aug-2011 Per Forlin <per.forlin@linaro.org> mmc: mmci: simplify err check in mmci_post_request

The error condition indicates that mmci_post_request() should cleanup
after the mmci_pre_request(). In this case the resources allocated by
device_prep_slave_sg() are freed by calling dmaengine_terminate_all().
dma_unmap_sg() should always be performed if the host_cookie is set.

Signed-off-by: Per Forlin <per.forlin@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
52ca0f3ab568497adeac217e4167b51d9b4d4884 22-Sep-2011 Russell King <rmk+kernel@arm.linux.org.uk> clk: mmci: convert to clk_prepare()/clk_unprepare()

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1c3be369c5fcd36c5d3841ca5d97d80ad34e76dd 14-Aug-2011 Russell King <rmk+kernel@arm.linux.org.uk> PM: add runtime PM support to MMCI

Add runtime PM support to the MMCI primecell driver, making use of
the core primecell bus runtime PM support.

Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
58c7ccbf9109abcc6b7ed2f76c21ebee244d31a8 01-Jul-2011 Per Forlin <per.forlin@linaro.org> mmc: mmci: implement pre_req() and post_req()

pre_req() runs dma_map_sg() and prepares the dma descriptor for the next
mmc data transfer. post_req() runs dma_unmap_sg. If not calling pre_req()
before mmci_request(), mmci_request() will prepare the cache and dma just
like it did it before. It is optional to use pre_req() and post_req()
for mmci.

Signed-off-by: Per Forlin <per.forlin@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
7f294e4983b67be802277d139522837b3ce5769f 08-Jul-2011 Linus Walleij <linus.walleij@linaro.org> ARM: 6981/2: mmci: adjust calculation of f_min

The ARM version maximum clock divider is 512 whereas for the ST
variants it's 257. Let's use DIV_ROUND_UP() for both cases so we
can see clearly what's going on here.

[Use DIV_ROUND_UP to clarify elder code]

Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com>
Reviewed-by: Sebastian Rasmussen <sebastian.rasmussen@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
757df746fc5db0020ddab45914617a19d149c252 30-Jun-2011 Linus Walleij <linus.walleij@linaro.org> ARM: 6980/1: mmci: use StartBitErr to detect bad connections

Stresstesting insert/remove of SD-cards can trigger
a StartBitErr. This made the driver to hang in forever
waiting for a non ocurring data timeout.

This bit and interrupt is documented in the original
PL180 TRM, just never implemented until now.

Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com>
Reviewed-by: Linus Walleij <linus.walleij@stericsson.com>
Reviewed-by: Jonas Aberg <jonas.aberg@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
17ee083b7897ab27b4949c42de805889ebd2b4c5 05-May-2011 Linus Walleij <linus.walleij@linaro.org> ARM: 6894/1: mmci: trigger card detect IRQs on falling and rising edges

Right now the card detect IRQ for MMCI is requested without any
flags which will give some default machine-specified IRQ
behaviour. However on the U300 rising+falling edges (such as can
be expected from a simple GPIO to generate when inserting/removing
a card) need to be requested explicitly.

Cc: Rabin Vincent <rabin.vincent@stericsson.com>
Cc: Ulf Hansson <ulf.hansson@stericsson.com>
Cc: Sebastian Rasmussen <sebastian.rasmussen@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1784b157c89cd2b5e6a3840abfdab6ed51f31d86 25-Mar-2011 Philippe Langlais <philippe.langlais@stericsson.com> ARM: 6832/1: mmci: support for ST-Ericsson db8500v2

ST-Ericsson modified ARM PrimeCell PL180 block has not got
an updated corresponding amba-id, althought the IP block has
changed in db8500v2. The change was done to the datactrl register.
Using the overrided subversion ID, account for this.

Signed-off-by: Philippe Langlais <philippe.langlais@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
399bc4863e2a3b4b255ca22189820c81ca34f4e0 01-Apr-2011 Linus Walleij <linus.walleij@linaro.org> ARM: 6858/1: mmci: force negative edge on clock bypass for ux500

This fixes a regression on high clock speeds with the MMCI on
ux500. We need to make sure we derive the passthru clock on the
falling edge of the incoming clock if it shall work at high
frequencies, and on the ux500's there is a special bit for this.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
49ac215e071234b2bf2cff7b8bf4f4f3d0e8cd6e 04-Mar-2011 Linus Walleij <linus.walleij@linaro.org> ARM: 6785/1: mmci: separate out ST Micro register defines

The mmci.h header contained a few registers not clearly marked
as ST Micro only, rectify this and remove the HWFC magic in the
process. The idea is to make the mmci.h header file more ordered
so other vendors with PL180 derivates can see where to put in
their custom register defines.

Includes portions of an earlier patch from Sebastian Rasmussen.

Acked-by: Sebastian Rasmussen <sebastian.rasmussen@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
768fbc1876b3239f4c463c00ea1e78725554cf21 11-Mar-2011 Pawel Moll <pawel.moll@arm.com> mmc: mmci: Add ARM variant with extended FIFO

New IO FPGA implementation for Versatile Express boards contain
MMCI (PL180) cell with FIFO extended to 128 words (512 bytes).

Matt Waddel reports that this patch improves MMC performance on
his vexpress system, and also fixes "mmcblk0: error -5 transferring
data" errors.

Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Tested-by: Matt Waddel <matt.waddel@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
aa25afad2ca60d19457849ea75e9c31236f4e174 19-Feb-2011 Russell King <rmk+kernel@arm.linux.org.uk> ARM: amba: make probe() functions take const id tables

Make Primecell driver probe functions take a const pointer to their
ID tables. Drivers should never modify their ID tables in their
probe handler.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
c8ebae37034c0ead62eb4df8ef88e999ddb8d5cf 11-Jan-2011 Russell King <rmk+kernel@arm.linux.org.uk> ARM: mmci: add dmaengine-based DMA support

Based on a patch from Linus Walleij.

Add dmaengine based support for DMA to the MMCI driver, using the
Primecell DMA engine interface. The changes over Linus' driver are:

- rename txsize_threshold to dmasize_threshold, as this reflects the
purpose more.
- use 'mmci_dma_' as the function prefix rather than 'dma_mmci_'.
- clean up requesting of dma channels.
- don't release a single channel twice when it's shared between tx and rx.
- get rid of 'dma_enable' bool - instead check whether the channel is NULL.
- detect incomplete DMA at the end of a transfer. Some DMA controllers
(eg, PL08x) are unable to be configured for scatter DMA and also listen
to all four DMA request signals [BREQ,SREQ,LBREQ,LSREQ] from the MMCI.
They can do one or other but not both. As MMCI uses LBREQ/LSREQ for the
final burst/words, PL08x does not transfer the last few words.
- map and unmap DMA buffers using the DMA engine struct device, not the
MMCI struct device - the DMA engine is doing the DMA transfer, not us.
- avoid double-unmapping of the DMA buffers on MMCI data errors.
- don't check for negative values from the dmaengine tx submission
function - Dan says this must never fail.
- use new dmaengine helper functions rather than using the ugly function
pointers directly.
- allow DMA code to be fully optimized away using dma_inprogress() which
is defined to constant 0 if DMA engine support is disabled.
- request maximum segment size from the DMA engine struct device and
set this appropriately.
- removed checking of buffer alignment - the DMA engine should deal with
its own restrictions on buffer alignment, not the individual DMA engine
users.
- removed setting DMAREQCTL - this confuses some DMA controllers as it
causes LBREQ to be asserted for the last seven transfers, rather than
six SREQ and one LSREQ.
- removed burst setting - the DMA controller should not burst past the
transfer size required to complete the DMA operation.

Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
51d4375dd72f352594f1a4f1d7598bf9a75b8dfe 27-Jan-2011 Russell King <rmk+kernel@arm.linux.org.uk> ARM: mmci: no need for separate host->data_xfered

We don't need to store the number of bytes transferred in our host
structure - we can store this directly in data->bytes_xfered.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
c4d877c1b3df58d89f01d7b211f58b944356eea3 27-Jan-2011 Russell King <rmk+kernel@arm.linux.org.uk> ARM: mmci: avoid unnecessary switch to data available PIO interrupts

We don't need to switch to data available interrupts if there's at
least half a FIFO depth worth of data remaining, as we'll still get
the FIFO half full interrupt. Keep this interrupt masked off until
we have less than half the FIFO depth worth of data remaining.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
7d7aa23cf0700f4025cb61bd1ac517ccf79bd460 27-Jan-2011 Russell King <rmk+kernel@arm.linux.org.uk> ARM: mmci: no need to call flush_dcache_page() with sg_miter API

The sg_miter API provides the required cache maintainence, so we don't
need to do that ourselves. Remove the unnecessary additional cache
maintainence.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
c8afc9d59ce1100d3f7704e86fda5a25361c45bf 04-Feb-2011 Russell King <rmk+kernel@arm.linux.org.uk> ARM: mmci: avoid reporting too many completed bytes on fifo overrun

The data counter counts the number of bytes transferred on the MMC bus.
When a FIFO overrun occurs, we will not have transferred a FIFOs-worth
of data to memory, and so the data counter will be a FIFOs-worth ahead.
If this occurs on a block boundary, we will report one too many sectors
as successful. Fix this.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
613b152c63e35095a929f9bb80441cbe91ff5e80 30-Jan-2011 Russell King <rmk+kernel@arm.linux.org.uk> ARM: mmci: round down the bytes transferred on error

We should not report incomplete blocks on error. Return the number of
bytes successfully transferred, rounded down to the nearest block.

Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
ccff9b51825b7335889b780bdf7de84ca803e291 30-Jan-2011 Russell King <rmk+kernel@arm.linux.org.uk> ARM: mmci: complete the transaction on error

When we encounter an error, make sure we complete the transaction
otherwise we'll leave the request dangling.

Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
f5a106d9e2a5d947e106c3caace373ded1a695ed 27-Jan-2011 Linus Walleij <linus.walleij@stericsson.com> ARM: 6642/1: mmci: calculate remaining bytes at error correctly

The MMCIDATACNT register contain the number of byte left at error
not the number of words, so loose the << 2 thing. Further if CRC
fails on the first block, we may end up with a negative number
of transferred bytes which is not good, and the formula was in
wrong order.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
9047b435a0b43952f5d1f7eb15a9b63a36efc7f2 11-Jan-2011 Russell King - ARM Linux <linux@arm.linux.org.uk> mmc: mmci: don't read command response when invalid

Don't read the command response from the registers when either the
command timed out (because there was no response from the card) or
the checksum on the response was invalid.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Chris Ball <cjb@laptop.org>
8cb2815574278a1bf966f041cbfe5b7c91472dcd 24-Jan-2011 Linus Walleij <linus.walleij@stericsson.com> ARM: 6632/3: mmci: stop using the blockend interrupts

Implement a suggestion from Russell to drop the use of blockend
interrupts altogether and instead rely on the data counter.

Tested with error-free cards on U300, U8500 and RealView PB1176.

Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
8c11a94d86eb5489dc665bc566bf624e329d89fa 28-Dec-2010 Russell King <rmk+kernel@arm.linux.org.uk> ARM: mmci: Clean up MMCI announcement printk

Make the MMCI announcement printk say which primecell part number
has been found. Display the revision as an unsigned decimal, and
display only the first 8 hex digits of the base address unless it's
larger.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
991a86e182203913b71607f0695955d7e23075d7 10-Dec-2010 Linus Walleij <linus.walleij@stericsson.com> ARM: 6530/1: mmci: partially revert clock divisor code

I misread the datasheet as if bypass mode was not available at all
on the ux500's, I was wrong. It is there, the datasheet just
states that you should not have to use it.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
b70a67f938e4a7544ca4dea2856b88f3c47669ff 06-Dec-2010 Linus Walleij <linus.walleij@stericsson.com> ARM: 6526/1: mmci: corrected calculation of clock div for ux500

The Ux500 variant of this block has a different divider.
The value used right now is too big and which means a loss
in performance. This fix corrects it. Also expand the math
comments a bit so it's clear what's happening. Further
the Ux500 variant does not like if we use the BYPASS bit,
instead we are supposed to set the clock divider to zero.

Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
34177802001894e064c857cac2759f68119550cd 19-Oct-2010 Linus Walleij <linus.walleij@stericsson.com> ARM: 6438/2: mmci: add SDIO support for ST Variants

This adds some minor variant data and trickery to enable SDIO
on the ST Micro variants of MMCI/PL180.

Signed-off-by: Marcin Mielczarczyk <marcin.mielczarczyk@tieto.com>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
f20f8f21e0402c785c342547f7e49eafc42cfb52 19-Oct-2010 Linus Walleij <linus.walleij@stericsson.com> ARM: 6399/3: mmci: handle broken MCI_DATABLOCKEND hardware

On the U300 the MCI_DATAEND and MCI_DATABLOCKEND IRQs can arrive
out-of-order. Replace an ugly #ifdef hack with a proper runtime
solution which models what is really happening.

In the U300 DMA mode and on all Ux500 models, the MCI_DATABLOCKEND
flag isn't properly cleared in hardware following and ACK leading
to all kind of weird behaviour when the flag is still up in
subsequent interrupts, so we add two flags indicating the
error and handle this runtime.

Cc: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2686b4b408c25349aee7b35558722d5730d67224 19-Oct-2010 Linus Walleij <linus.walleij@stericsson.com> ARM: 6311/2: mmci: work with only one irq

The DBx500 variants have only one IRQ line hooked up. Allow these (and
any other implementations which choose to use only one irq) to work by
directing the PIO interrupts also to the first IRQ line.

Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
99fc5131018cbdc3cf42ce09fb394a4e8b053c74 29-Sep-2010 Linus Walleij <linus.walleij@stericsson.com> mmc: Move regulator handling closer to core

After discovering a problem in regulator reference counting I took Mark
Brown's advice to move the reference count into the MMC core by making the
regulator status a member of struct mmc_host.

I took this opportunity to also implement NULL versions of
the regulator functions so as to rid the driver code from
some ugly #ifdef CONFIG_REGULATOR clauses.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Adrian Hunter <adrian.hunter@nokia.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Sundar Iyer <sundar.iyer@stericsson.com>
Cc: Daniel Mack <daniel@caiaq.de>
Cc: Pierre Ossman <pierre@ossman.eu>
Cc: Matt Fleming <matt@console-pimps.org>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Cliff Brake <cbrake@bec-systems.com>
Cc: Jarkko Lavinen <jarkko.lavinen@nokia.com>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
a36274e0184193e393fb82957925c3981a6b0477 10-Sep-2010 Martin K. Petersen <martin.petersen@oracle.com> mmc: Remove distinction between hw and phys segments

We have deprecated the distinction between hardware and physical
segments in the block layer. Consolidate the two limits into one in
drivers/mmc/.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
18a06301158b5e4e9fae29e477f468e23f3eda90 12-Sep-2010 Linus Walleij <linus.walleij@stericsson.com> ARM: 6370/1: mmci: use _cansleep GPIO functions

Currently the kernel is screaming about slowpath at me for the
wp/cd callbacks. Switch to the _cansleep variants so as to silence
this.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
4b8caec09562ce7e6e3aaf2954eef8ea73ba67b8 09-Aug-2010 Rabin Vincent <rabin.vincent@stericsson.com> ARM: 6309/1: mmci: allow neither ->status nor gpio_cd to be specified

The card may be always present on the board, and for these cases neither
a status callback nor a card detect GPIO is required, and card detection
polling can be disabled.

Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
148b8b39c156424da22693d26adcb69800faf95e 09-Aug-2010 Rabin Vincent <rabin.vincent@stericsson.com> ARM: 6308/1: mmci: support card detection interrupts

If an IRQ can be requested on the card detected GPIO, use it instead of
polling.

Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
8301bb68c6bb9836889641a47443aeb97b763f6c 09-Aug-2010 Rabin Vincent <rabin.vincent@stericsson.com> ARM: 6310/1: mmci: support different FIFO sizes

The Ux500 variant has a 32-word FIFO (TXFIFOEMPTY is asserted when it
has 2 left) and TXFIFOHALFEMPTY is repurposed as TXFIFOBURSTWRITEABLE,
with a burst being defined as 8-words. Likewise for RX.

Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2971944582ff43b7dedbb460777052243ac9915a 09-Aug-2010 Rabin Vincent <rabin.vincent@stericsson.com> ARM: 6307/1: mmci: allow the card detect GPIO value not to be inverted

On some platforms, the GPIO value from the gpio_cd pin doesn't need to
be inverted to get it active high. Add a cd_invert platform data
parameter and change existing platforms using GPIO for CD (only
Realview) to enable it.

Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
74bc80931c8bc34d24545f992a35349ad548897c 29-Jul-2010 Russell King <rmk+kernel@arm.linux.org.uk> ARM: Fix Versatile/Realview/VExpress MMC card detection sense

The MMC card detection sense has become really confused with negations
at various levels, leading to some platforms not detecting inserted
cards. Fix this by converting everything to positive logic throughout,
thereby getting rid of these negations.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
08458ef6eede6cf7d5a33c3a7c8bcdc3943012c2 21-Jul-2010 Rabin Vincent <rabin.vincent@stericsson.com> ARM: 6246/1: mmci: support larger MMCIDATALENGTH register

The Ux500 variant has a 24-bit MMCIDATALENGTH register, as opposed to
the 16-bit one on the ARM version.

Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
4380c14fd77338bac9d1da4dc5dd9f6eb4966c82 21-Jul-2010 Rabin Vincent <rabin.vincent@stericsson.com> ARM: 6245/1: mmci: enable hardware flow control on Ux500 variants

Although both the U300 and Ux500 use ST variants, the HWFCEN bits are at
different positions, so use the variant_data to store the information.

Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
4956e10903fd3459306dd9438c1e714ba3068a2a 21-Jul-2010 Rabin Vincent <rabin.vincent@stericsson.com> ARM: 6244/1: mmci: add variant data and default MCICLOCK support

Add a variant_data structure to handle the differences between the
various variants of this peripheral. Add a first quirk for a default
MCICLOCK value, required on the Ux500 variant where the enable bit needs
to be always set, since it controls access to some registers.

Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
bb8f563c848faa113059973f68c24a3bb6a9585e 21-Jul-2010 Rabin Vincent <rabin.vincent@stericsson.com> ARM: 6243/1: mmci: pass power_mode to the translate_vdd callback

Platforms may have some external power control which need to be
controlled from board specific code. Rename the translate_vdd()
callback to vdd_handler() and pass it the power mode.

Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
f5e2574e734650bbeb801a31cc99e628f9a027af 21-Jul-2010 Rabin Vincent <rabin.vincent@stericsson.com> ARM: 6239/1: mmci: let core poll for card detection

Use the MMC core's ability to poll for card detection. This also has
the advantage of doing the gpio_get_value from a workqueue instead of
timer, allowing the gpio to be on a sleeping gpiochip.

Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
528320db013b687c5f0150fd77eb4dc02ca328d1 21-Jul-2010 Rabin Vincent <rabin.vincent@stericsson.com> ARM: 6238/1: mmci: fix multi block transfers

Fix the data transfer size to allow multi block transfers to work.

Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
4ce1d6cbf07271ab8f7cc47c3e27edeac08b58a7 21-Jul-2010 Rabin Vincent <rabin.vincent@stericsson.com> ARM: 6237/1: mmci: use sg_miter API to fix multi-page sg handling

The mmci driver's SG list iteration logic assumes that each SG entry
spans only one page, and only maps and flushes one page of the sg. This
is not a valid assumption. Fix it by converting the driver to the
sg_miter API, which correctly handles sgs which span multiple pages.

Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1a13f8fa76c880be41d6b1e6a2b44404bcbfdf9e 26-May-2010 Matt Fleming <matt@console-pimps.org> mmc: remove the "state" argument to mmc_suspend_host()

Even though many mmc host drivers pass a pm_message_t argument to
mmc_suspend_host() that argument isn't used the by MMC core. As host
drivers are converted to dev_pm_ops they'll have to construct
pm_message_t's (as they won't be passed by the PM subsystem any more) just
to appease the mmc suspend interface.

We might as well just delete the unused paramter.

Signed-off-by: Matt Fleming <matt@console-pimps.org>
Acked-by: Anton Vorontsov <cbouatmailru@gmail.com>
Acked-by: Michal Miroslaw <mirq-linux@rere.qmqm.pl>ZZ
Acked-by: Sascha Sommer <saschasommer@freenet.de>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
808d97ccbe8e8251b1435e86c762965fd7e8a75e 08-Apr-2010 Linus Walleij <linus.walleij@stericsson.com> ARM: 6033/1: ARM: MMCI: pass max frequency from platform

This introduce the field f_max into the mmci_platform_data,
making it possible to pass in a desired block clocking frequency
from a board configuration. This is often more desirable than
using a module parameter. We keep the module parameter as a
fallback as well as the default frequency specified for this
parameter if a parameter is not provided.

This also adds some kerneldoc style documentation to the
platform data struct in mmci.h.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
771dc157e06d69fcece0b2c8a29b9010345d8e9a 08-Apr-2010 Linus Walleij <linus.walleij@stericsson.com> ARM: 6032/1: ARM: MMCI: support 8bit mode on the ST Micro version

This adds support for an 8bit wide bus to the card (data lines
MCIDAT0 through 7 exist) on the ST Micro version and alters the
U300 platform to support this. Also add some ST_ prefix to the
ST-specific registers.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
64de028948f449af17cf387f45a45f36ffd3c960 19-Feb-2010 Linus Walleij <linus.walleij@stericsson.com> ARM: 5940/2: ARM: MMCI: remove custom DBG macro and printk

This removes the custom DBG macro in favor of the in-kernel
dev_dbg() macro. Probably a leftover from a time when dev_dbg()
didn't yet exist. Also remove a printk() in favor of dev_err().

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
f28e8a4d027e4e21c3d0a52706527bb87397bea0 25-Jan-2010 Linus Walleij <linus.walleij@stericsson.com> ARM: 5896/1: MMCI: work around a hardware bug in U300

In the U300 some hardware bug makes the status flag not come up
signalling a successful write (or anything else, like an error, for
that matter) on write requests. This little quirk makes the writes
work on U300.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
b43149c168ce4069ce8828b1ceb8f7eb42bc4b82 10-Nov-2009 Linus Walleij <linus.walleij@stericsson.com> ARM: 5785/1: Use ST vendor enum instead of numeral

This fixes a leftover instance of using the 0x80 numeral instead
of the new AMBA_VENDOR_ST enum in the MMCI/PL180 driver.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
ee17962e249024ebba72acbfe7cf54f8ea5b72f8 28-Sep-2009 Linus Walleij <linus.walleij@stericsson.com> ARM: 5731/2: Fix U300 generic GPIO, remove ifdefs from MMCI v3

The #ifdefs in the MMCI driver were erroneous and just masking
a bug in the U300 generic GPIO implementation. This removes the
ifdefs and fixes the U300 generic GPIO instead.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
34e84f39a27d059a3e6ec6e8b94aafa702e6f220 22-Sep-2009 Linus Walleij <linus.walleij@stericsson.com> ARM: 5721/1: MMCI enable the use of a regulator

This enables the use of a regulator to power the MMCI/PL180
PrimeCell. The OCR mask is calculated and voltage is set using
the new MMC core functions for discovering voltage ranges
in regulators. The platform translate_vdd function which basically
controls the 4 lines out of the PL180 is disabled if you use a
regulator instead.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
6ef297f86b62f187c59475784208f75c2ed8ccd8 22-Sep-2009 Linus Walleij <linus.walleij@stericsson.com> ARM: 5720/1: Move MMCI header to amba include dir

This moves the mmci platform data definition struct away from
arch/arm/include/asm/mach/mmc.h into the more proper place among
the other primecells in include/linux/amba/mmci.h and at the same
time renames it to "mmci.h", and also the struct in this file
confusingly named mmc_platform_data has been renamed
mmci_platform_data for clarity.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
9e6c82cd3e1a739ef48bf8c1decc8e7a7d8de3ac 14-Sep-2009 Linus Walleij <linus.walleij@stericsson.com> ARM: 5698/1: MMCI pass capabilities in platform data

This makes it possible to pass down the host controller
capabilities for the MMCI driver using the platform data. It
also provides the capabilties for the U300 implementation as an
example, and makes sure the 4bit wide mode is set if this is
requested by the ios() now that we can actually set that
capability for a platform.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
a6a6464a0ecd20c5f1594a4fe5b24af6181b7366 14-Sep-2009 Linus Walleij <linus.walleij@stericsson.com> ARM: 5697/1: MMCI Break out clock divider setup

This breaks out the clock divider set-up code from the
mmci_set_ios() code and surrounds the two register
writes with a host lock so we don't get collisions if
(in future code) two code paths want to change the
clock divider at the same time as can be the case if
we get something like pre/post- clock frequency change
notifications soonish.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
f17a1f06d2fa93f4825be572622eb02c4894db4e 04-Aug-2009 Linus Walleij <linus.walleij@stericsson.com> ARM: 5636/1: Move vendor enum to AMBA include

This moves the primecell vendor enum definition inside vic.c
out to linux/amba/bus.h where it belongs and replace any
occurances of specific vendor ID:s with the respective enums
instead.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
7064d2092df5cbff289457424969292bc4062df4 26-Aug-2009 Linus Walleij <linus.walleij@stericsson.com> ARM: 5685/1: Make MMCI driver compile without gpiolib

The recent addition of optional gpiolib support to check if a
card was inserted or write protected was really not optional.
It needs this ifdef to become optional so that U300 compiles,
for example.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
89001446925d6da8785c3265a71316e34c6d15de 09-Jul-2009 Russell King <rmk@dyn-67.arm.linux.org.uk> MMC: MMCI: use gpiolib for card detect/write protect

Use gpiolib where available (and when valid GPIOs are provided) for
write protect/card detect status reporting. We fall back to the old
'status' method where gpiolib support is not available.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
012b7d339ce8c42d41e35b35c4acc3dd29501d52 09-Jul-2009 Russell King <rmk@dyn-67.arm.linux.org.uk> MMC: MMCI: use AMBA bus accessors

Rather than open coding the accessors for decoding peripheral IDs,
use the macros already provided.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
dc890c2dcd63a90de68ee5f0253eefbb89d725f0 08-Jun-2009 Linus Walleij <linus.walleij@stericsson.com> [ARM] 5544/1: Trust PrimeCell resource sizes

I found the PrimeCell/AMBA Bus drivers distrusting the resource
passed in as part of the struct amba_device abstraction. This
patch removes all hard coded resource sizes found in the PrimeCell
drivers and move the responsibility of this definition back to
the platform/board device definition, which already exist and
appear to be correct for all in-tree users of these drivers.
We do this using the resource_size() inline function which was
also replicated in the only driver using the resource size, so
that has been changed too. The KMI_SIZE was left in kmi.h in case
someone likes it. Test-compiled against Versatile and Integrator
defconfigs, seems to work but I don't posess these boards and
cannot test them.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
03fbdb15c14e9746c63168e3ff2c64b9c8336d33 20-May-2009 Alessandro Rubini <rubini@gnudd.com> [ARM] 5519/1: amba probe: pass "struct amba_id *" instead of void *

The second argument of the probe method points to the amba_id
structure, so it's better passed with the correct type. None of the
current in-tree drivers uses the pointer, so they have only been
checked for a clean compile.

Change suggested by Russell King.

Signed-off-by: Alessandro Rubini <rubini@unipv.it>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
4ea580f1db62c5419e6690878fd61a740f3aae8e 17-Apr-2009 Rabin Vincent <rabin@rab.in> mmci: fix crash with debug enabled

If MMC debugging is enabled, the mmci driver oopses because the DBG
macro uses host->mmc before it is set. Set it earlier.

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Pierre Ossman <pierre@ossman.eu>
6dc4a47a0cf423879b505af0e29997fca4088630 07-Mar-2009 Linus Walleij <triad@df.lth.se> [ARM] 5420/1: MMCI devinit and devexit macros

This adds __devinit and __devexit macros to the module probe and
remove functions in MMCI. Now includes the __devexit_p() thing too.

Signed-off-by: Linus Walleij <linus.walleij@ericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
cc30d60e4ca0b68e7e3f906eddd1e5b995d349f8 04-Jan-2009 Linus Walleij <linus.walleij@ericsson.com> mmci: Add support for ST Micro derivate

This patch adds support for the ST Microelectronics version of
the PL180 PrimeCell. They use designer ID 0x80 and have a few
alterations/bugfixes related to open drain and HW flow control.
They also add some SDIO registers, I am unsure if these are
in ST HW only or if this is things also added in later ARM
revisions, but they are included in the mmci.h file for
completeness.

Signed-off-by: Linus Walleij <linus.walleij@ericsson.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
ee569c43e340202fb0ba427c57b77568a32b9a3a 30-Nov-2008 Russell King <rmk@dyn-67.arm.linux.org.uk> [ARM] amba drivers: don't pass a consumer clock name for devices with unique clocks

Where devices only have one consumer, passing a consumer clock ID
has no real benefit, and it only encourages wrong implementations of
the clk API. Remove it.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
9e9430213f85ebdaf40026ec790295420efd0f91 24-Oct-2008 Linus Walleij <triad@df.lth.se> [ARM] 5322/1: Fix fastpath issue in mmci.c

Fix fastpath issues

Since mmci_request() can be called from a non-interrupt
context, and does, during kernel init, causing a host
of debug messages during boot if you enable spinlock debugging,
we need to use the spinlock calls that save IRQ flags and
restore them.

Signed-off-by: Linus Walleij <triad@df.lth.se>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
23af60398af2f5033e2f53665538a09f498dbc03 06-Jul-2008 Pierre Ossman <drzeus@drzeus.cx> mmc: remove multiwrite capability

Relax requirements on host controllers and only require that they do not
report a transfer count than is larger than the actual one (i.e. a lower
value is okay). This is how many other parts of the kernel behaves so
upper layers should already be prepared to handle that scenario. This
gives us a performance boost on MMC cards.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
c8df9a53e8d16877fc0b268b002af2a47a14643a 29-Apr-2008 Linus Walleij <triad@df.lth.se> [ARM] 5024/1: Fix some minor clk issues in the MMCI PL18x driver

This fixes some two minor clk issues.

The first is a comparison where a byte will probably wrap around to 0 instead of being saturated to 255, shouldn't be triggered very often but need fixing.

The second is an attempt by the driver to adjust MCLK down to the maximum frequency according to the spec, so we don't accidentally overclock the PL18x block. None of the mach-{versatile|integrator|lh7a40x} that use it in-tree seem to have a problem with this (all are well below 100MHz, typically 33MHz), but some day there will be a problem.

This is not applied on top of the earlier mmci patch for race condition but rather a clean 2.6.25, but I guess it applies without major protests anyway.

Signed-off-by: Linus Walleij <triad@df.lth.se>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
26eed9a5c61edd93d88e147188d4feae6770174e 27-Apr-2008 Linus Walleij <triad@df.lth.se> [ARM] 5022/1: Race in ARM MMCI PL18x driver, V2

Updated version of 4446/1. This also drops the suggested comparison
of host_remain for == 0, since that doesn't make sense (still works
for us, too). We have verified that this patch solve race problems
on atleast 2 archs at high frequencies.

(Verbatim copy of old patch text below.)

The patch below fixes a race condition in the ARM MMCI PL18x driver.

If new data arrives in the FIFO while existing data is being read then
we get a second iteration of the loop in mmci_pio_read.

However host->size is not updated until after mmci_pio_read returns,
so we get count = number of new bytes PLUS number of bytes already
copied in the first iteration. This results in a FIFO underrun as
we try and read mode data than is available.

The fix is to compensating for data read on previous iterations
when calculating the amount of data in the FIFO.

Signed-off-by: Linus Walleij <triad@df.lth.se>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
bd6dee6f30a0f6943df190b387b5f8fe98a848f3 24-Oct-2007 Jens Axboe <jens.axboe@oracle.com> mmc: sg fallout

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>
019a5f56ec195aceadada18aaaad0f67294bdaef 11-Oct-2007 Nicolas Pitre <nico@cam.org> mmc: don't use weight32()

Using weight32() to determine if a value is a power of 2 is a rather
heavi weight solution. The classic idiom is (x & (x - 1)) == 0, but
the kernel already provide a is_power_of_2 function for it.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
255d01af9a990fd5166f04ed0cc0b30b7b67e81e 24-Jul-2007 Pierre Ossman <drzeus@drzeus.cx> mmc: remove BYTEBLOCK capability

Remove the BYTEBLOCK capability and let the broken hosts fail the
requests with -EINVAL instead.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
17b0429dde9ab60f9cee8e07ab28c7dc6cfe6efd 22-Jul-2007 Pierre Ossman <drzeus@drzeus.cx> mmc: remove custom error codes

Convert the MMC layer to use standard error codes and not its own,
incompatible values.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
70f10482c668301c483acded13bf68780ad352b9 11-Jul-2007 Pierre Ossman <drzeus@drzeus.cx> mmc: update header file paths

Make sure all headers in the files reflect their true position
in the tree.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
1c6a0718f0bfdab0d9b7da5f7b74f38a0058c03a 11-Feb-2007 Pierre Ossman <drzeus@drzeus.cx> mmc: Move host and card drivers to subdirs

Clean up the drivers/mmc directory by moving card and host drivers
into subdirectories.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>