History log of /drivers/mmc/host/atmel-mci.c
Revision Date Author Comments
faf8180b20882b52145b96d6d4ed082d41908f90 21-Mar-2012 Ludovic Desroches <ludovic.desroches@atmel.com> mmc: atmel-mci: add support for odd clock dividers

Add an odd clock divider capability available from v5xx. It also involves
changing the clock divider calculation, and changing the switch-case
statement to use top-down fallthrough.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
33ab4bbbdf6c60a8c196b5a28215a93aa2a4ed2e 21-Mar-2012 Ludovic Desroches <ludovic.desroches@atmel.com> mmc: atmel-mci: r/w proof capability only available since v2xx

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
66292ad92c6d3f2f1c137a1c826b331ca8595dfd 28-Mar-2012 Ludovic Desroches <ludovic.desroches@atmel.com> mmc: atmel-mci: correct data timeout computation

The HSMCI operates at a rate of up to Master Clock divided by two.
Moreover previous calculation can cause overflows and so wrong
timeouts.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
b81cfc413047181a8f2599cacf927dc09a81a123 09-Feb-2012 Ludovic Desroches <ludovic.desroches@atmel.com> mmc: atmel-mci: fix typo

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
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>
ef8781989a1bcd05aa47e853917c37df44917194 09-Feb-2012 Ludovic Desroches <ludovic.desroches@atmel.com> mmc: atmel-mci: don't use dma features when using DMA with no chan available

Some callbacks are set too early -- i.e. we can have dma capabilities but
we can't get a dma channel. So wait to get the dma channel before setting
callbacks and change logs consequently.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
[Should be applied to 3.2-stable.]
Cc: <stable@vger.kernel.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
e2b35f3dbfc080f15b72834d08f04f0269dbe9be 01-Feb-2012 Viresh Kumar <viresh.kumar@st.com> dmaengine/dw_dmac: Fix dw_dmac user drivers to adapt to slave_config changes

There are few existing user drivers of dw_dmac. They will break as soon as we
remove unused fields from struct dw_dma_slave. This patch focuses to fix these
user drivers to use dma_slave_config() routine.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
18ee684b8ab666329e0a0a72d8b70f16fb0e2243 09-Feb-2012 Ludovic Desroches <ludovic.desroches@atmel.com> mmc: atmel-mci: save and restore sdioirq when soft reset is performed

Sometimes a software reset is needed. Then some registers are saved and
restored but the interrupt mask register is missing. It causes issues
with sdio devices whose interrupts are masked after reset.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
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>
7e8ba228d9f43a4e4b3ed0e6aa3399e8f30d7bc1 11-Aug-2011 Ludovic Desroches <ludovic.desroches@atmel.com> mmc: atmel-mci: fix a potential issue about pending PDC interrupts

This patch fixes a potential issue about PDC interrupts. For example we
have a ENDRX pending interrupt and a RXBUFF pending interrupt. We have
received the RXBUFF interrupt but the transfer is not finished (so we
didn't have time to give a new buffer to the PDC controller). Then we
will compute ENDRX interrupt and we will give a new buffer to the PDC
controller, just after we will compute the RXBUFF interrupt and give
one or two new buffers to the PDC controller but we are not sure that
the first buffer given has been filled. So in this situation we may
have "lost" one sg buffer. It's the same for transmission.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
341fa4c3affe1171005597847a86e4c26dea8bb1 11-Aug-2011 Ludovic Desroches <ludovic.desroches@atmel.com> mmc: atmel-mci: correct sg buffer size evaluation

Assuming that a sg buffer size is a page size is false so use sg_dma_len.
A 4096 bytes can be required with two 2048-bytes sg buffer.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
1ebbe3d31fd96865b4d4874f3c74fef0e386fb79 11-Aug-2011 Ludovic Desroches <ludovic.desroches@atmel.com> mmc: atmel-mci: use ATMEL_PDC_SCND_BUF_OFF instead of a literal value

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
11d1488b01b803254842b756ff7662085b37970e 11-Aug-2011 Ludovic Desroches <ludovic.desroches@atmel.com> mmc: atmel-mci: change atmci_start_command to atmci_send_command

Rename atmci_start_command() to atmci_send_command() which is more
appropriate; atmci_start_command suggests we're sending a start command.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
796211b7953bd1036670359f31cd97f309322107 11-Aug-2011 Ludovic Desroches <ludovic.desroches@atmel.com> mmc: atmel-mci: add pdc support and runtime capabilities detection

Add pdc support for atmel-mci. It makes at91-mci driver useless because it
was only used for the old atmel MCI core which has pdc but no dma support.
To allow removing at91-mci, the capabilities of the MCI core are detected
at runtime -- then the driver will use pio, pdc or dma transfers.
Warning: at91rm9200 is not supported, to support it we need to use swab32
on data but I have no board to test it.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
03fc9a7f0c48a05ca548cd277835d7da97ed6936 11-Aug-2011 Ludovic Desroches <ludovic.desroches@atmel.com> mmc: atmel-mci: change atmci_readl and atmci_writel macros

Change atmci_readl and atmci_writel macros: remove string concatenation.
We can use these macros with registers which are not prefixed by ATMCI_.
This is the case if we want to write PDC registers which are common to
several devices so they are not prefixed with ATMCI_.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
2c96a293bbd6b34698c6710ea8607049956247c4 11-Aug-2011 Ludovic Desroches <ludovic.desroches@atmel.com> mmc: atmel-mci: change namespace

Homogenize namespace to atmci.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
5c2f2b9bd0db84eabaf0d2cf7a9392a1581c2545 06-Jul-2011 Nicolas Ferre <nicolas.ferre@atmel.com> mmc: atmel-mci: add suspend/resume support

Take care of slots while going to suspend state.

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
e05503ef1186ad33dfe56794407891eb1dd93ef6 18-May-2011 Jean Delvare <khali@linux-fr.org> Haavard Skinnemoen has left Atmel

Haavard's e-mail address at Atmel is no longer valid.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Havard Skinnemoen <hskinnemoen@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
25985edcedea6396277003854657b5f3cb31a628 31-Mar-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Fix common misspellings

Fixes generated by 'codespell' and manually reviewed.

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
5328906aa2e54a7a5e99e1ba8ee52b387e8be44b 10-Feb-2011 Linus Walleij <linus.walleij@linaro.org> mmc: atmel-mci: use dmaengine helper functions

Use the new dmaengine helpers to make the code more readable.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
88ce4db313bca1e4e6ef3b448471f85d3e14a854 10-Feb-2011 Linus Walleij <linus.walleij@linaro.org> mmc: atmel-mci: conform to DMA-API

Fixes the following:
- It is perfectly legal for the dma_map_sg() to return fewer
entries than were passed in.
- Supply the returned numer of (possibly coalesced) entries to
the device_pre_slave_sg() function.
- Use the proper original sg_len when unmapping the sglist
in the error path.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
266ac3f297adb72fb6c34949a38337c6fad4c7a6 10-Feb-2011 Linus Walleij <linus.walleij@linaro.org> mmc: atmel-mci: map DMA sglist on the DMA engine

As established for the MMCI, it is proper to map the DMA buffers
on the DMA engine which is the one actually performing the DMA.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
2f1d791882d21a4002a719fb016a1ac21c8bd6b7 10-Dec-2010 Nicolas Ferre <nicolas.ferre@atmel.com> mmc: atmel-mci: fix multiblock SDIO transfers

Based on report made by Yauhen in:
"MMC: Fix multiblock SDIO transfers in AT91 MCI" patch,
I report those changes to the brother driver: atmel-mci.

So, this patch sets SDIO transfer types: SDIO block and SDIO byte
transfers instead of using ordinary MMC block transfers.
It is checking opcode for SDIO CMD53 and setting transfer
type in MCI_CMDR register properly.

Reported-by: Yauhen Kharuzhy <yauhen.kharuzhy@promwad.com>
Cc: <stable@kernel.org>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
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>
e8e3f6ca12d95181ce4718bcb4865c1913eac983 14-Dec-2009 H Hartley Sweeten <hsweeten@visionengravers.com> mmc: atmel-mci.c: use resource_size()

[cjb: rebased patch against Linus]
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
88ff82ed4ff048c5548db9313b3de327c91234f8 26-May-2010 Anders Grahn <anders.grahn@hd-wireless.se> mmc: atmel-mci: Add support for SDIO interrupts

Atmel-mci support for SDIO interrupts. This adds the enable_sdio_irq()
function and the configuration of sdio irq mask per slot. With this irq
mask information, we keep the idea of multiple slot per sd/mmc host (not
only A and B). MMC_CAP_SDIO_IRQ is added according to slot configuration.

A new little function is added to run mmc_signal_sdio_irq() during
interrupt handling routine.

Signed-off-by: Anders Grahn <anders.grahn@hd-wireless.se>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
99ddffd8ef84c0389e31cb4b90d9e5415ea19cb0 26-May-2010 Nicolas Ferre <nicolas.ferre@atmel.com> mmc: atmel-mci: enable SD high speed support

Enable high speed support for atmel-mci driver. This support is dependent
of the revision of the IP and, of course, the capacity of the SD card
used.

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Reviewed-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Cc: Maciej Sosnowski <maciej.sosnowski@intel.com>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
058276303dbc4ed089c1f7dad0871810b1f5ddf1 18-May-2010 Linus Walleij <linus.walleij@stericsson.com> DMAENGINE: extend the control command to include an arg

This adds an argument to the DMAengine control function, so that
we can later provide control commands that need some external data
passed in through an argument akin to the ioctl() operation
prototype.

[dan.j.williams@intel.com: fix up some missed conversions]
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
d586ebbb8814e039545d38f69029533f3f17748d 11-May-2010 Nicolas Ferre <nicolas.ferre@atmel.com> mmc: atmel-mci: fix in debugfs: response value printing

In debugfs, printing of command response reports resp[2] twice: fix it to
resp[3].

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Haavard Skinnemoen <hskinnemoen@atmel.com>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
abc2c9fdf636c4335a8d72ac3c5ae152bca44b68 11-May-2010 Nicolas Ferre <nicolas.ferre@atmel.com> mmc: atmel-mci: remove data error interrupt after xfer

Disable data error interrupts while we are actually recording that there
is not such errors. This will prevent, in some cases, the warning message
printed at new request queuing (in atmci_start_request()).

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>
Cc: <linux-mmc@vger.kernel.org>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
009a891b22395fc86e5f34057d79fffee4509ab5 11-May-2010 Nicolas Ferre <nicolas.ferre@atmel.com> mmc: atmel-mci: prevent kernel oops while removing card

The removing of an SD card in certain circumstances can lead to a kernel
oops if we do not make sure that the "data" field of the host structure is
valid. This patch adds a test in atmci_dma_cleanup() function and also
calls atmci_stop_dma() before throwing away the reference to data.

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>
Cc: <linux-mmc@vger.kernel.org>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
ebb1fea9b3adf25d7e2f643c614163af4f93a17f 11-May-2010 Nicolas Ferre <nicolas.ferre@atmel.com> mmc: atmel-mci: fix two parameters swapped

Two parameters were swapped in the calls to atmci_init_slot().

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Reported-by: Anders Grahn <anders.grahn@hd-wireless.se>
Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>
Cc: <linux-mmc@vger.kernel.org>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
5a0e3ad6af8660be21ca98a971cd00f331318c05 24-Mar-2010 Tejun Heo <tj@kernel.org> include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h

percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.

2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).

* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
c3635c78e500a52c9fcd55de381a72928d9e054d 27-Mar-2010 Linus Walleij <linus.walleij@stericsson.com> DMAENGINE: generic slave control v2

Convert the device_terminate_all() operation on the
DMA engine to a generic device_control() operation
which can now optionally support also pausing and
resuming DMA on a certain channel. Implemented for the
COH 901 318 DMAC as an example.

[dan.j.williams@intel.com: update for timberdale]
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Maciej Sosnowski <maciej.sosnowski@intel.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Li Yang <leoli@freescale.com>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Cc: Magnus Damm <damm@opensource.se>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>
Cc: Joe Perches <joe@perches.com>
Cc: Roland Dreier <rdreier@cisco.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
74791a2dc8dc2af3feeaf3242d642ff58d33bd30 15-Dec-2009 Nicolas Ferre <nicolas.ferre@atmel.com> mmc: atmel-mci: new MCI2 module support in atmel-mci driver

This new revision of the IP adds some improvements to the MCI already
present in several Atmel SOC.

Some new registers are added and a particular way of handling DMA
interaction lead to a new sequence in function call which is backward
compatible: On MCI2, we must set the DMAEN bit to enable the DMA
handshaking interface. This must happen before the data transfer command
is sent.

A new function is able to differentiate MCI2 code and is based on
knowledge of processor id (cpu_is_xxx()).

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2635d1ba711560d521f6218c585a3e0401f566e1 15-Dec-2009 Nicolas Ferre <nicolas.ferre@atmel.com> atmel-mci: change use of dma slave interface

Allow the use of another DMA controller driver in atmel-mci sd/mmc driver.
This adds a generic dma_slave pointer to the mci platform structure where
we can store DMA controller information. In atmel-mci we use information
provided by this structure to initialize the driver (with new helper
functions that are architecture dependant).

This also adds at32/avr32 chip modifications to cope with this new access
method.

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
04d699c3643fbf75dd72c03a4eacec87149c4aca 23-Sep-2009 Rob Emanuele <rob@emanuele.us> atmel-mci: unified Atmel MCI drivers (AVR32 & AT91)

Unification of the atmel-mci driver to support the AT91 processors MCI
interface. The atmel-mci driver currently supports the AVR32 and this
patch adds AT91 support.

Add read/write proof selection switch dependent on chip availability of
this feature.

To use this new driver on a at91 the platform driver for your board needs
to be updated.

[nicolas.ferre@atmel.com indent, Kconfig comment and one printk modification]
Signed-off-by: Rob Emanuele <rob@emanuele.us>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>
Cc: Andrew Victor <linux@maxim.org.za>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
657a77fa7284d8ae28dfa48f1dc5d919bf5b2843 09-Sep-2009 Atsushi Nemoto <anemo@mba.ocn.ne.jp> dmaengine: Move all map_sg/unmap_sg for slave channel to its client

Dan Williams wrote:
... DMA-slave clients request specific channels and know the hardware
details at a low level, so it should not be too high an expectation to
push dma mapping responsibility to the client.

Also this patch includes DMA_COMPL_{SRC,DEST}_UNMAP_SINGLE support for
dw_dmac driver.

Acked-by: Maciej Sosnowski <maciej.sosnowski@intel.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1c1452be2e9ae282a7316c3b23987811bd7acda6 31-Mar-2009 Jonas Larsson <jonas.larsson@martinsson.se> atmel-mci: Add support for inverted detect pin

Same patch as before, modified to use bool. Also adds description of
the new field in struct atmel_mci that I missed in the first patch.

This patch adds Atmel MCI support for inverted detect pins.

Signed-off-by: Jonas Larsson <jonas.larsson@martinsson.se>
Acked-by: Pierre Ossman <pierre@ossman.eu>
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
48f8151ea68ad78391ef6ff12a83e6fbdb6094f6 25-Mar-2009 Kay Sievers <kay.sievers@vrfy.org> mmc: struct device - replace bus_id with dev_name(), dev_set_name()

Cc: drzeus-mmc@drzeus.cx
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
32ab83a56fdf42f543b86c349143c2a86ead9707 24-Mar-2009 Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com> atmel-mci: fix sdc_reg typo

This fixes a bug when setting the sdc_reg for 4-bit bus width
transactions.

Signed-off-by: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
89c8aa203e71f05afdc978700cbc767d310e3d70 02-Feb-2009 Kay Sievers <kay.sievers@vrfy.org> mmc: struct device - replace bus_id with dev_name(), dev_set_name()

Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
287d859222e0adbc67666a6154aaf42d7d5bbb54 18-Feb-2009 Dan Williams <dan.j.williams@intel.com> atmel-mci: fix initialization of dma slave data

The conversion of atmel-mci to dma_request_channel missed the
initialization of the channel dma_slave information. The filter_fn passed
to dma_request_channel is responsible for initializing the channel's
private data. This implementation has the additional benefit of enabling
a generic client-channel data passing mechanism.

Reviewed-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
7dd602510128d7a64b11ff3b7d4f30ac8e3946ce 06-Jan-2009 Dan Williams <dan.j.williams@intel.com> dmaengine: kill enum dma_state_client

DMA_NAK is now useless. We can just use a bool instead.

Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
aa1e6f1a385eb2b04171ec841f3b760091e4a8ee 06-Jan-2009 Dan Williams <dan.j.williams@intel.com> dmaengine: kill struct dma_client and supporting infrastructure

All users have been converted to either the general-purpose allocator,
dma_find_channel, or dma_request_channel.

Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
74465b4ff9ac1da503025c0a0042e023bfa6505c 06-Jan-2009 Dan Williams <dan.j.williams@intel.com> atmel-mci: convert to dma_request_channel and down-level dma_slave

dma_request_channel provides an exclusive channel, so we no longer need to
pass slave data through dmaengine.

Cc: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
6f49a57aa5a0c6d4e4e27c85f7af6c83325a12d1 06-Jan-2009 Dan Williams <dan.j.williams@intel.com> dmaengine: up-level reference counting to the module level

Simply, if a client wants any dmaengine channel then prevent all dmaengine
modules from being removed. Once the clients are done re-enable module
removal.

Why?, beyond reducing complication:
1/ Tracking reference counts per-transaction in an efficient manner, as
is currently done, requires a complicated scheme to avoid cache-line
bouncing effects.
2/ Per-transaction ref-counting gives the false impression that a
dma-driver can be gracefully removed ahead of its user (net, md, or
dma-slave)
3/ None of the in-tree dma-drivers talk to hot pluggable hardware, but
if such an engine were built one day we still would not need to notify
clients of remove events. The driver can simply return NULL to a
->prep() request, something that is much easier for a client to handle.

Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Maciej Sosnowski <maciej.sosnowski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
c42aa775cc8a8ca558db0cc75979fb8e16667447 20-Nov-2008 Nicolas Ferre <nicolas.ferre@atmel.com> atmel-mci: move atmel-mci.h file to include/linux

Needed to use the atmel-mci driver in an architecture
independant maner.

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
e683b423007b9befec30c672c695d0e6abf87493 06-Oct-2008 Haavard Skinnemoen <haavard.skinnemoen@atmel.com> atmel-mci: Initialize BLKR before sending data transfer command

The atmel-mci driver sometimes fails data transfers like this:

mmcblk0: error -5 transferring data
end_request: I/O error, dev mmcblk0, sector 2749769
end_request: I/O error, dev mmcblk0, sector 2749777

It turns out that this might be caused by the BLKR register (which
contains the block size and the number of blocks being transfered) being
initialized too late. This patch moves the initialization of BLKR so
that it contains the correct value before the block transfer command is
sent.

This error is difficult to reproduce, but if you insert a long delay
(mdelay(10) or thereabouts) between the calls to atmci_start_command()
and atmci_submit_data(), all transfers seem to fail without this patch,
while I haven't seen any failures with this patch.

Reported-by: Hein_Tibosch <hein_tibosch@yahoo.es>
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
5e7184ae0dd49456387e8b1cdebc6b2c92fc6d51 05-Oct-2008 Haavard Skinnemoen <haavard.skinnemoen@atmel.com> atmel-mci: Add missing flush_dcache_page() in PIO transfer code

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
ca55f46e13dd07b029b0a3d64637f983a6627b23 05-Oct-2008 Haavard Skinnemoen <haavard.skinnemoen@atmel.com> atmel-mci: Don't overwrite error bits when NOTBUSY is set

After a data error, we wait for the NOTBUSY bit to be set so that we can
be sure the data transfer is completely finished. However, when NOTBUSY
is set, the interrupt handler copies the contents of SR into
data_status, overwriting any error bits we may have detected earlier.

To avoid this, initialize data_status to 0 before starting a request, and
don't overwrite it unless it still contains 0.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
65e8b083fc8ec303499baa1924ae032d46d29990 30-Jul-2008 Haavard Skinnemoen <haavard.skinnemoen@atmel.com> atmel-mci: Add experimental DMA support

This adds support for DMA transfers through the generic DMA engine
framework with the DMA slave extensions.

The driver has been tested using mmc-block and ext3fs on several SD,
SDHC and MMC+ cards. Reads and writes work fine, with read transfer
rates up to 7.5 MiB/s on fast cards with debugging disabled.

Unfortunately, the driver has been known to lock up from time to time
with DMA enabled, so DMA support is currently optional and marked
EXPERIMENTAL. However, I didn't see any problems while testing 13
different cards (MMC, SD and SDHC of different brands and sizes), so I
suspect the "Initialize BLKR before sending data transfer command" fix
that was posted earlier fixed this as well.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
965ebf33ea5afb6386f5b57cc71e6572253746b3 17-Sep-2008 Haavard Skinnemoen <haavard.skinnemoen@atmel.com> atmel-mci: support multiple mmc slots

The Atmel MCI controller can drive multiple cards through separate sets
of pins, but only one at a time. This patch adds support for
multiplexing access to the controller so that multiple card slots can be
used as if they were hooked up to separate mmc controllers.

The atmel-mci driver registers each slot as a separate mmc_host. Both
access the same common controller state, but they also have some state
on their own for card detection/write protect handling, and separate
shadows of the MR and SDCR registers.

When one of the slots receives a request from the mmc core, the common
controller state is checked. If it's idle, the request is submitted
immediately. If not, the request is added to a queue. When a request is
done, the queue is checked and if there is a queued request, it is
submitted before the completion callback is called.

This patch also includes a few cleanups and fixes, including a locking
overhaul. I had to change the locking extensively in any case, so I
might as well try to get it right. The driver no longer takes any
irq-safe locks, which may or may not improve the overall system
performance.

This patch also adds a bit of documentation of the internal data
structures.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
6b918657b7431e4c5c953b8222ae2f4fc1b2576a 07-Aug-2008 Haavard Skinnemoen <haavard.skinnemoen@atmel.com> atmel-mci: Platform code for supporting multiple mmc slots

Add the necessary platform infrastructure to support multiple mmc/sdcard
slots all at once through a single controller. Currently, the driver
will use the first valid slot it finds and stick with that, but later
patches will add support for switching between several slots on the fly.

Extend the platform data structure with per-slot information: MMC/SDcard
bus width and card detect/write protect pins. This will affect the pin
muxing as well as the capabilities announced to the mmc core.

Note that board code is now required to supply a mci_platform_data
struct to at32_add_device_mci().

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
945533b538c6c6185afc77ba4a81eeba8f6ef8dd 03-Oct-2008 Haavard Skinnemoen <haavard.skinnemoen@atmel.com> atmel-mci: Don't stop the clock between transfers

Some cards might get upset if we turn off the clock for extended periods
of time. So keep the clock running until the mmc core tells us to turn
it off.

Also, don't reset the controller between each transfer. That was an
attempt to work around earlier bugs, and it never really worked very
well.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
c06ad2580dca4eb14ca07541d4f00a3b7cbcf12f 31-Jul-2008 Haavard Skinnemoen <haavard.skinnemoen@atmel.com> atmel-mci: Implement tasklet as a state machine

With the current system of completed/pending events, things may get
handled in different order depending on which event triggers first. For
example, if the data transfer is complete before the command, the stop
command must be sent after the command is complete, not the data. This
creates a bit of complexity around the stop command.

By having the tasklet go through a sequence of clearly defined states,
things always happen in a certain order even if the events come at
different times, so the stop command can simply be sent when we exit the
"sending data" state because we will never enter that state before the
command has been sent successfully.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
a252e3e35ef8144fb772da70bb93c99a1486097a 03-Oct-2008 Haavard Skinnemoen <haavard.skinnemoen@atmel.com> atmel-mci: Initialize BLKR before sending data transfer command

The atmel-mci driver sometimes fails data transfers like this:

mmcblk0: error -5 transferring data
end_request: I/O error, dev mmcblk0, sector 2749769
end_request: I/O error, dev mmcblk0, sector 2749777

It turns out that this might be caused by the BLKR register (which
contains the block size and the number of blocks being transfered) being
initialized too late. This patch moves the initialization of BLKR so
that it contains the correct value before the block transfer command is
sent.

This error is difficult to reproduce, but if you insert a long delay
(mdelay(10) or thereabouts) between the calls to atmci_start_command()
and atmci_submit_data(), all transfers seem to fail without this patch,
while I haven't seen any failures with this patch.

Reported-by: Hein_Tibosch <hein_tibosch@yahoo.es>
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
da45b66ec89bbf3a1c172688c35d4d3a6e8e757f 19-Sep-2008 Haavard Skinnemoen <haavard.skinnemoen@atmel.com> atmel-mci: Set MMC_CAP_NEEDS_POLL if no detect_pin

This allows the mmc core to detect card insertion/removal for slots that
don't have any CD pin wired up.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
75d33cc751214f8388d58fca3ef6d1df786b5861 19-Sep-2008 Haavard Skinnemoen <haavard.skinnemoen@atmel.com> atmel-mci: Fix bogus debugfs file size

We used to store a binary register snapshot in the "regs" file, so we
set the file size to be the size of this snapshot. This is no longer
valid since we switched to using seq_file.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
b17339a12c279d73869c74a37642035cd2f896f8 19-Sep-2008 Haavard Skinnemoen <haavard.skinnemoen@atmel.com> atmel-mci: Fix memory leak in atmci_regs_show

The debugfs hook atmci_regs_show allocates a temporary buffer for
storing a register snapshot, but it doesn't free it before returning.
Plug this leak.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
87e60f2b80202575a23fa1bf56c6eb3b419c480a 19-Sep-2008 Haavard Skinnemoen <haavard.skinnemoen@atmel.com> atmel-mci: debugfs: enable clock before dumping regs

Make sure that the peripheral clock is enabled before reading the MMIO
registers for the debugfs "regs" dump.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
3663b736a5083b3bce74520b637f630f01f66a7f 05-Aug-2008 Haavard Skinnemoen <haavard.skinnemoen@atmel.com> avr32: Use <mach/foo.h> instead of <asm/arch/foo.h>

Update all avr32-specific files to use the new platform-specific header
locations. Drivers shared with ARM are left alone for now.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
3c26e17032e42cfbe606882288223ad6146e4c38 27-Jul-2008 David Brownell <dbrownell@users.sourceforge.net> avr32: some mmc/sd cleanups

Minor cleanups for the MMC/SD support on avr32:

- Make at32_add_device_mci() properly initialize "missing"
platform data ... so boards like STK1002 won't try GPIO 0.

- Switch over to gpio_is_valid() instead of testing for only
one designated value.

- Provide STK1002 platform data for the unlikely case that
switches are set so first Ethernet controller isn't in use.
(That's the only way to get card detect and writeprotect
switch sensing on the STK1000.)

And get rid of one "unused variable" warning.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
deec9ae31e6079551ce9260d29a4cf83e5b19a83 24-Jul-2008 Haavard Skinnemoen <haavard.skinnemoen@atmel.com> atmel-mci: debugfs support

Create additional files under the host's debugfs directory containing
additional host-specific debug information.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
fbfca4b8781757c1950b2225ba67d83072e0bc07 18-Jul-2008 Ben Nizette <bn@niasdigital.com> avr32: clean up mci platform code

This patch does a few small cleanups around the atmel mci platform code
and in the atmel-mci driver. The platform changes simply removes an
unused variable, uses the fact that by the end we always have some form
of platform data and notes that GPIO_PIN_NONE != 0. This last point
could cause the incorrect attempt to twice reserve pin PA0.

While we've got the hood up, add linux/err.h to the atmel-mci.c include
list. It needs it and generally pulls it by voodoo but I did once
stumble across a config which don't build.

This is against Linus' latest git.

Signed-off-by: Ben Nizette <bn@niasdigital.com>
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
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>
7d2be0749a59096a334c94dc48f43294193cb8ed 30-Jun-2008 Haavard Skinnemoen <haavard.skinnemoen@atmel.com> atmel-mci: Driver for Atmel on-chip MMC controllers

This is a driver for the MMC controller on the AP7000 chips from
Atmel. It should in theory work on AT91 systems too with some
tweaking, but since the DMA interface is quite different, it's not
entirely clear if it's worth merging this with the at91_mci driver.

This driver has been around for a while in BSPs and kernel sources
provided by Atmel, but this particular version uses the generic DMA
Engine framework (with the slave extensions) instead of an
avr32-only DMA controller framework.

This driver can also use PIO transfers when no DMA channels are
available, and for transfers where using DMA may be difficult or
impractical for some reason (e.g. the DMA setup overhead is usually
not worth it for very short transfers, and badly aligned buffers or
lengths are difficult to handle.)

Currently, the driver only support PIO transfers. DMA support has been
split out to a separate patch to hopefully make it easier to review.

The driver has been tested using mmc-block and ext3fs on several SD,
SDHC and MMC+ cards. Reads and writes work fine, with read transfer
rates up to 3.5 MiB/s on fast cards with debugging disabled.

The driver has also been tested using the mmc_test module on the same
cards. All tests except 7, 9, 15 and 17 succeed. The first two are
unsupported by all the cards I have, so I don't know if the driver
handles this correctly. The last two fail because the hardware flags a
Data CRC Error instead of a Data Timeout error. I'm not sure how to deal
with that.

Documentation for this controller can be found in many data sheets from
Atmel, including the AT32AP7000 data sheet which can be found here:

http://www.atmel.com/dyn/products/datasheets.asp?family_id=682

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>