platform/kernel/linux-rpi.git
7 years agommc: queue: Factor out mmc_queue_reqs_free_bufs()
Adrian Hunter [Tue, 29 Nov 2016 10:09:14 +0000 (12:09 +0200)]
mmc: queue: Factor out mmc_queue_reqs_free_bufs()

In preparation for supporting a queue of requests, factor out
mmc_queue_reqs_free_bufs().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Harjani Ritesh <riteshh@codeaurora.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: queue: Factor out mmc_queue_alloc_sgs()
Adrian Hunter [Tue, 29 Nov 2016 10:09:13 +0000 (12:09 +0200)]
mmc: queue: Factor out mmc_queue_alloc_sgs()

In preparation for supporting a queue of requests, factor out
mmc_queue_alloc_sgs().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Harjani Ritesh <riteshh@codeaurora.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: queue: Factor out mmc_queue_alloc_bounce_sgs()
Adrian Hunter [Tue, 29 Nov 2016 10:09:12 +0000 (12:09 +0200)]
mmc: queue: Factor out mmc_queue_alloc_bounce_sgs()

In preparation for supporting a queue of requests, factor out
mmc_queue_alloc_bounce_sgs().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Harjani Ritesh <riteshh@codeaurora.org>
[Ulf: Fixed compiler warning]
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: queue: Factor out mmc_queue_alloc_bounce_bufs()
Adrian Hunter [Tue, 29 Nov 2016 10:09:11 +0000 (12:09 +0200)]
mmc: queue: Factor out mmc_queue_alloc_bounce_bufs()

In preparation for supporting a queue of requests, factor out
mmc_queue_alloc_bounce_bufs().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Harjani Ritesh <riteshh@codeaurora.org>
[Ulf: Fixed compiler warning]
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: queue: Fix queue thread wake-up
Adrian Hunter [Tue, 29 Nov 2016 10:09:10 +0000 (12:09 +0200)]
mmc: queue: Fix queue thread wake-up

The only time the driver sleeps expecting to be woken upon the arrival of
a new request, is when the dispatch queue is empty. The only time that it
is known whether the dispatch queue is empty is after NULL is returned
from blk_fetch_request() while under the queue lock.

Recognizing those facts, simplify the synchronization between the queue
thread and the request function. A couple of flags tell the request
function what to do, and the queue lock and barriers associated with
wake-ups ensure synchronization.

The result is simpler and allows the removal of the context_info lock.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Harjani Ritesh <riteshh@codeaurora.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: block: Fix 4K native sector check
Adrian Hunter [Tue, 29 Nov 2016 10:09:09 +0000 (12:09 +0200)]
mmc: block: Fix 4K native sector check

The 4K native sector check does not allow for the 'do' loop nor the
variables used after the 'cmd_abort' label.

'brq' and 'req' get reassigned in the 'do' loop, so the check must not
assume what their values are. After the 'cmd_abort' label, 'mq_rq' and
'req' are used, but 'rqc' must be NULL otherwise it can be started again.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: block: Restore line inadvertently removed with packed commands
Adrian Hunter [Tue, 29 Nov 2016 10:09:08 +0000 (12:09 +0200)]
mmc: block: Restore line inadvertently removed with packed commands

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
7 years agosoc: fsl: fix section mismatch build warnings
Sudeep Holla [Thu, 17 Nov 2016 15:11:59 +0000 (15:11 +0000)]
soc: fsl: fix section mismatch build warnings

We get the following warning with the driver is compiled in:

WARNING: modpost: Found 1 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'

With CONFIG_DEBUG_SECTION_MISMATCH enabled, the details are reported:

WARNING: vmlinux.o(.text+0x55d014): Section mismatch in reference from the
function fsl_guts_probe() to the function
.init.text:of_flat_dt_get_machine_name()
The function fsl_guts_probe() references
the function __init of_flat_dt_get_machine_name().
This is often because fsl_guts_probe lacks a __init
annotation or the annotation of of_flat_dt_get_machine_name is wrong.

This patch fixes the issue by using the normal DT/OF API rather than
the of_flat_* one.

Cc: Scott Wood <oss@buserror.net>
Cc: Yangbo Lu <yangbo.lu@nxp.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0
yangbo lu [Wed, 9 Nov 2016 03:14:12 +0000 (11:14 +0800)]
mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0

The eSDHC of T4240-R1.0-R2.0 has incorrect vender version and spec version.
Acturally the right version numbers should be VVN=0x13 and SVN = 0x1.
This patch adds the GUTS driver support for eSDHC driver to match SoC.
And fix host version to avoid that incorrect version numbers break down
the ADMA data transfer.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Scott Wood <oss@buserror.net>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agoMAINTAINERS: add entry for Freescale SoC drivers
yangbo lu [Wed, 9 Nov 2016 03:14:09 +0000 (11:14 +0800)]
MAINTAINERS: add entry for Freescale SoC drivers

Add maintainer entry for Freescale SoC drivers including
the QE library and the GUTS driver now. Also add maintainer
for QE library.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Acked-by: Scott Wood <oss@buserror.net>
Acked-by: Qiang Zhao <qiang.zhao@nxp.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agosoc: fsl: add GUTS driver for QorIQ platforms
yangbo lu [Wed, 9 Nov 2016 03:14:08 +0000 (11:14 +0800)]
soc: fsl: add GUTS driver for QorIQ platforms

The global utilities block controls power management, I/O device
enabling, power-onreset(POR) configuration monitoring, alternate
function selection for multiplexed signals,and clock control.

This patch adds a driver to manage and access global utilities block.
Initially only reading SVR and registering soc device are supported.
Other guts accesses, such as reading RCW, should eventually be moved
into this driver as well.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agodt: bindings: move guts devicetree doc out of powerpc directory
yangbo lu [Wed, 9 Nov 2016 03:14:07 +0000 (11:14 +0800)]
dt: bindings: move guts devicetree doc out of powerpc directory

Move guts devicetree doc to Documentation/devicetree/bindings/soc/fsl/
since it's used by not only PowerPC but also ARM. And add a specification
for 'little-endian' property.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Scott Wood <oss@buserror.net>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agoARM64: dts: ls2080a: add device configuration node
yangbo lu [Wed, 9 Nov 2016 03:14:06 +0000 (11:14 +0800)]
ARM64: dts: ls2080a: add device configuration node

Add the dts node for device configuration unit that provides
general purpose configuration and status for the device.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Acked-by: Scott Wood <oss@buserror.net>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agoMerge tag 'soc-device-match-tag1' into next
Ulf Hansson [Tue, 29 Nov 2016 08:09:09 +0000 (09:09 +0100)]
Merge tag 'soc-device-match-tag1' into next

Merge the immutable soc-device-match-tag1 provided by Geert Uytterhoeven
to pull in the new soc_device_match() interface for matching against
soc_bus attributes.

7 years agommc: sh_mmcif: Document r8a73a4, r8a7778 and sh73a0 DT bindings
Simon Horman [Fri, 25 Nov 2016 07:56:14 +0000 (08:56 +0100)]
mmc: sh_mmcif: Document r8a73a4, r8a7778 and sh73a0 DT bindings

Simply document new compatibility strings as the driver is already
activated using a fallback compatibility string.

These compat strings are in keeping with those for all other
Renesas ARM based SoCs with sh_mmcif enabled in mainline.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sh_mobile_sdhi: remove support for sh7372
Simon Horman [Thu, 24 Nov 2016 10:48:54 +0000 (11:48 +0100)]
mmc: sh_mobile_sdhi: remove support for sh7372

Remove documentation of support for the SH7372 (SH-Mobile AP4) from the MMC
driver. The driver itself appears to have no SH7372 specific code.

Commit edf4100906044225 ("ARM: shmobile: sh7372 dtsi: Remove Legacy file")
removes this SoC from the kernel in v4.1.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: block: delete packed command support
Linus Walleij [Fri, 25 Nov 2016 09:35:00 +0000 (10:35 +0100)]
mmc: block: delete packed command support

I've had it with this code now.

The packed command support is a complex hurdle in the MMC/SD block
layer, around 500+ lines of code which was introduced in 2013 in

commit ce39f9d17c14 ("mmc: support packed write command for eMMC4.5
devices")
commit abd9ac144947 ("mmc: add packed command feature of eMMC4.5")

...and since then it has been rotting. The original author of the
code has disappeared from the community and the mail address is
bouncing.

For the code to be exercised the host must flag that it supports
packed commands, so in mmc_blk_prep_packed_list() which is called for
every single request, the following construction appears:

u8 max_packed_rw = 0;

if ((rq_data_dir(cur) == WRITE) &&
    mmc_host_packed_wr(card->host))
        max_packed_rw = card->ext_csd.max_packed_writes;

if (max_packed_rw == 0)
    goto no_packed;

This has the following logical deductions:

- Only WRITE commands can really be packed, so the solution is
  only half-done: we support packed WRITE but not packed READ.
  The packed command support has not been finalized by supporting
  reads in three years!

- mmc_host_packed_wr() is just a static inline that checks
  host->caps2 & MMC_CAP2_PACKED_WR. The problem with this is
  that NO upstream host sets this capability flag! No driver
  in the kernel is using it, and we can't test it. Packed
  command may be supported in out-of-tree code, but I doubt
  it. I doubt that the code is even working anymore due to
  other refactorings in the MMC block layer, who would
  notice if patches affecting it broke packed commands?
  No one.

- There is no Device Tree binding or code to mark a host as
  supporting packed read or write commands, just this flag
  in caps2, so for sure there are not any DT systems using
  it either.

It has other problems as well: mmc_blk_prep_packed_list() is
speculatively picking requests out of the request queue with
blk_fetch_request() making the MMC/SD stack harder to convert
to the multiqueue block layer. By this we get rid of an
obstacle.

The way I see it this is just cruft littering the MMC/SD
stack.

Cc: Namjae Jeon <namjae.jeon@samsung.com>
Cc: Maya Erez <qca_merez@qca.qualcomm.com>
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: delete is_first_req parameter from pre-request callback
Linus Walleij [Wed, 23 Nov 2016 10:02:24 +0000 (11:02 +0100)]
mmc: delete is_first_req parameter from pre-request callback

The void (*pre_req) callback in the struct mmc_host_ops vtable
is passing an argument "is_first_req" indicating whether this is
the first request or not.

None of the in-kernel users use this parameter: instead, since
they all just do variants of dma_map* they use the DMA cookie
to indicate whether a pre* callback has already been done for
a request when they decide how to handle it.

Delete the parameter from the callback and all users, as it is
just pointless cruft.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: core: Update CMD13 polling policy when switch to HS DDR mode
Ulf Hansson [Wed, 9 Nov 2016 20:00:26 +0000 (21:00 +0100)]
mmc: core: Update CMD13 polling policy when switch to HS DDR mode

According to the JEDEC specification, during bus timing change operations
for mmc, sending a CMD13 could trigger CRC errors.

As switching to HS DDR mode indeed causes a bus timing change, polling with
CMD13 to detect card busy, may thus potentially trigger CRC errors.
Currently these errors are treated as the switch to HS DDR mode failed.

To improve this behaviour, let's instead tell __mmc_switch() to retry when
it encounters CRC errors during polling.

Moreover, when switching to HS DDR mode, let's make sure the CMD13 polling
is done by having the mmc host and the mmc card, being configured to
operate at the same selected bus speed timing. Fix this by providing
MMC_TIMING_MMC_DDR52 as the timing parameter to __mmc_switch().

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
7 years agommc: core: Allow CMD13 polling when switching to HS mode for mmc
Ulf Hansson [Wed, 9 Nov 2016 18:40:29 +0000 (19:40 +0100)]
mmc: core: Allow CMD13 polling when switching to HS mode for mmc

In cases when the mmc host doesn't support HW busy detection, polling for a
card being busy by using CMD13 is beneficial. That is because, instead of
waiting a fixed amount of time, 500ms or the generic CMD6 time from
EXT_CSD, we find out a lot sooner when the card stops signaling busy. This
leads to a significant decreased total initialization time for the mmc
card.

However, to allow polling with CMD13 during a bus timing change operation,
such as switching to HS mode, we first need to update the mmc host's bus
timing before starting to poll. Deal with that, simply by providing
MMC_TIMING_MMC_HS as the timing parameter to __mmc_switch() from
mmc_select_hs().

By telling __mmc_switch() to allow polling with CMD13, also makes it
validate the CMD6 status, thus we can remove the corresponding checks.

When switching to HS400ES, the mmc_select_hs() function is called in one of
the intermediate steps. To still prevent CMD13 polling for HS400ES, let's
call the __mmc_switch() function in this path as it enables us to keep
using the existing method.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
7 years agommc: core: Enable __mmc_switch() to change bus speed timing for the host
Ulf Hansson [Wed, 9 Nov 2016 16:33:36 +0000 (17:33 +0100)]
mmc: core: Enable __mmc_switch() to change bus speed timing for the host

In cases when a speed mode change is requested for mmc cards, a CMD6 is
sent by calling __mmc_switch() during the card initialization. The CMD6
leads to the card entering a busy period. When that is completed, the host
must parse the CMD6 status to find out whether the change of the speed mode
succeeded.

To enable the mmc core to poll the card by using CMD13 to find out when the
busy period is completed, it's reasonable to make sure polling is done by
having the mmc host and the mmc card, being configured to operate at the
same selected bus speed timing.

Therefore, let's extend __mmc_switch() to take yet another parameter, which
allow its callers to update the bus speed timing of the mmc host. In this
way, __mmc_switch() also becomes capable of reading and validating the CMD6
status by sending a CMD13, in cases when that's desired.

If __mmc_switch() encounters a failure, we make sure to restores the old
bus speed timing for the mmc host, before propagating the error code.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
7 years agommc: core: Check SWITCH_ERROR bit from each CMD13 response when polling
Ulf Hansson [Mon, 21 Nov 2016 14:49:48 +0000 (15:49 +0100)]
mmc: core: Check SWITCH_ERROR bit from each CMD13 response when polling

According to the JEDEC specification, the SWITCH_ERROR bit in the device
status from a R1 response, is an error bit which may be cleared as soon as
the response that reports the error is sent.

When polling with CMD13 to find out when the card stops signaling busy
after a CMD6 has been sent, we currently parse only the last CMD13 response
for the SWITCH_ERROR bit. Consequentially we could loose important
information about the card.

In worst case if the card stops signaling busy within the allowed timeout,
we could end up believing that the CMD6 command completed successfully,
when in fact it didn't.

To improve the behaviour, let's parse each CMD13 response to see if the
SWITCH_ERROR bit is set in the device status. In such case, we abort the
polling loop and report the error.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
7 years agommc: core: Rename ignore_crc to retry_crc_err to reflect its purpose
Ulf Hansson [Tue, 8 Nov 2016 14:39:13 +0000 (15:39 +0100)]
mmc: core: Rename ignore_crc to retry_crc_err to reflect its purpose

The ignore_crc parameter/variable name is used at a couple of places in the
mmc core. Let's rename it to retry_crc_err to reflect its new purpose.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
7 years agommc: core: Remove redundant __mmc_send_status()
Ulf Hansson [Tue, 8 Nov 2016 14:27:27 +0000 (15:27 +0100)]
mmc: core: Remove redundant __mmc_send_status()

There are only one users left which calls __mmc_send_status(). Moreover,
the ignore_crc parameter isn't being used, so let's just remove these
redundant parts.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
7 years agommc: core: Retry instead of ignore at CRC errors when polling for busy
Ulf Hansson [Tue, 8 Nov 2016 12:53:36 +0000 (13:53 +0100)]
mmc: core: Retry instead of ignore at CRC errors when polling for busy

After a CMD6 command has been sent, the __mmc_switch() function might be
advised to poll the card for busy by using CMD13 and also by ignoring CRC
errors.

In the case of ignoring CRC errors, the mmc core tells the mmc host to also
ignore these errors via masking the MMC_RSP_CRC response flag. This seems
wrong, as it leads to that the mmc host could propagate an unreliable
response, instead of a proper error code.

What we really want, is not to ignore CRC errors but instead retry the
polling attempt. So, let's change this by treating a CRC error as the card
is still being busy and thus continue to run the polling loop.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
7 years agommc: sdhci-pci: Allow deferred probe for sd card detect gpio
David E. Box [Tue, 22 Nov 2016 09:03:38 +0000 (11:03 +0200)]
mmc: sdhci-pci: Allow deferred probe for sd card detect gpio

With commit f35bbf61ab77 ("gpio / ACPI: Return -EPROBE_DEFER if the
gpiochip was not found"), a gpio descriptor request can now be deferred if
the providing gpio host controller driver hasn't been loaded yet. Allow use
in mmc slot probe in order to prevent card detect gpio setup from failing
in this case.

Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-pci: Add support for Intel GLK
Adrian Hunter [Tue, 22 Nov 2016 09:03:37 +0000 (11:03 +0200)]
mmc: sdhci-pci: Add support for Intel GLK

Add support for eMMC/SD/SDIO Intel GLK host controllers.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agosdhci: sdhci-msm: update dll configuration
Ritesh Harjani [Mon, 21 Nov 2016 06:37:26 +0000 (12:07 +0530)]
sdhci: sdhci-msm: update dll configuration

The newer msm sdhci's cores use a different DLL hardware for HS400.
Update the configuration and calibration of the newer DLL block.

The HS400 DLL block used previously is CDC LP 533 and requires
programming multiple registers and waiting for configuration to
complete and then enable it. It has about 18 register writes and
two register reads.

The newer HS400 DLL block is SDC4 DLL and requires two register
writes for configuration and one register read to confirm that it
is initialized. There is an additional register write to enable
the power save mode for SDC4 DLL block.

Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-msm: Add calibration tuning for CDCLP533 circuit
Ritesh Harjani [Mon, 21 Nov 2016 06:37:25 +0000 (12:07 +0530)]
mmc: sdhci-msm: Add calibration tuning for CDCLP533 circuit

In HS400 mode a new RCLK is introduced on the interface for read data
transfers. The eMMC5.0 device transmits the read data to the host with
respect to rising and falling edges of RCLK. In order to ensure correct
operation of read data transfers in HS400 mode, the incoming RX data
needs to be sampled by delayed version of RCLK.

The CDCLP533 delay circuit shifts the RCLK by T/4. It needs to be
initialized, configured and enabled once during HS400 mode switch and
when operational voltage/clock is changed.

Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-msm: Save the calculated tuning phase
Ritesh Harjani [Mon, 21 Nov 2016 06:37:24 +0000 (12:07 +0530)]
mmc: sdhci-msm: Save the calculated tuning phase

Save the tuning phase once the tuning is performed.
This phase value will be used while calibrating DLL
for HS400 mode.

Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-msm: Add HS400 platform support
Venkat Gopalakrishnan [Mon, 21 Nov 2016 06:37:23 +0000 (12:07 +0530)]
mmc: sdhci-msm: Add HS400 platform support

The following msm platform specific changes are added to support HS400.
- Allow tuning for HS400 mode.
- Configure HS400 timing mode using the VENDOR_SPECIFIC_FUNC register.

Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-msm: Add clock changes for DDR mode.
Ritesh Harjani [Mon, 21 Nov 2016 06:37:21 +0000 (12:07 +0530)]
mmc: sdhci-msm: Add clock changes for DDR mode.

SDHC MSM controller need 2x clock for MCLK at GCC.
Hence make required changes to have 2x clock for
DDR timing modes.

Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-msm: Implement set_clock callback for sdhci-msm
Ritesh Harjani [Mon, 21 Nov 2016 06:37:20 +0000 (12:07 +0530)]
mmc: sdhci-msm: Implement set_clock callback for sdhci-msm

sdhci-msm controller may have different clk-rates for each
bus speed mode. Thus implement set_clock callback for
sdhci-msm driver.

Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci: Factor out sdhci_enable_clk
Ritesh Harjani [Mon, 21 Nov 2016 06:37:19 +0000 (12:07 +0530)]
mmc: sdhci: Factor out sdhci_enable_clk

Factor out sdhci_enable_clk from sdhci_set_clock
and make it EXPORT_SYMBOL so that it can be called.

Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-msm: Enable few quirks
Ritesh Harjani [Mon, 21 Nov 2016 06:37:18 +0000 (12:07 +0530)]
mmc: sdhci-msm: Enable few quirks

sdhc-msm controller needs this SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN
& SDHCI_QUIRK2_PRESET_VALUE_BROKEN to be set. Hence setting it.

Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-msm: Add get_min_clock() and get_max_clock() callback
Ritesh Harjani [Mon, 21 Nov 2016 06:37:17 +0000 (12:07 +0530)]
mmc: sdhci-msm: Add get_min_clock() and get_max_clock() callback

This add get_min_clock() and get_max_clock() callback
for sdhci-msm. sdhci-msm min/max clocks may be different
hence implement these callbacks.

Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-msm: Update DLL reset sequence
Venkat Gopalakrishnan [Mon, 21 Nov 2016 06:37:16 +0000 (12:07 +0530)]
mmc: sdhci-msm: Update DLL reset sequence

SDCC core with minor version >= 0x42 introduced new 14lpp
DLL. This has additional requirements in the reset sequence
for DLL tuning. Make necessary changes as needed.

Without this patch we see below errors on such SDHC controllers
sdhci_msm 7464900.sdhci: mmc0: DLL failed to LOCK
mmc0: tuning execution failed: -110

Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agodt-bindings: sdhci-msm: Add xo value
Ritesh Harjani [Mon, 21 Nov 2016 06:37:15 +0000 (12:07 +0530)]
dt-bindings: sdhci-msm: Add xo value

Add "xo" value which is tcxo clock to sdhci-msm
DT binding properties.

Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-msm: Change poor style writel/readl of registers
Ritesh Harjani [Mon, 21 Nov 2016 06:37:13 +0000 (12:07 +0530)]
mmc: sdhci-msm: Change poor style writel/readl of registers

This patch changes the poor style of writel/readl registers
into more readable format. This avoid mixed style format
of readl/writel in sdhci-msm driver.
This patch also removes the one line comments which were present for
above writel/readl, since they were of no help.

Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agoDocumentation: synopsys-dw-mshc: remove the unused properties
Jaehoon Chung [Thu, 17 Nov 2016 07:40:41 +0000 (16:40 +0900)]
Documentation: synopsys-dw-mshc: remove the unused properties

"support-highspeed" was the obsoleted property.
And "broken-cd" is not synopsys specific property.
It can be referred to mmc.txt binding Documentation.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Acked-by: Rob Herring <robh@kernel.org>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: dw_mmc: The "clock-freq-min-max" property was deprecated
Jaehoon Chung [Thu, 17 Nov 2016 07:40:40 +0000 (16:40 +0900)]
mmc: dw_mmc: The "clock-freq-min-max" property was deprecated

The "clock-freq-min-max" property was deprecated.
There is "max-frequency" property in drivers/mmc/core/host.c
"max-frequency" can be replaced with "clock-freq-min-max".
Minimum clock value might be set to 100K by default.
Then MMC core should try to find the correct value from 400K to 100K.
So it just needs to set Maximum clock value.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: dw_mmc: remove the unnecessary mmc_data structure
Jaehoon Chung [Thu, 17 Nov 2016 07:40:39 +0000 (16:40 +0900)]
mmc: dw_mmc: remove the unnecessary mmc_data structure

Remove the unnecessary mmc_data structure.
Instead, cmd->data can be used.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: dw_mmc: use the cookie's enum values for post/pre_req()
Jaehoon Chung [Thu, 17 Nov 2016 07:40:38 +0000 (16:40 +0900)]
mmc: dw_mmc: use the cookie's enum values for post/pre_req()

This patch removed the meaningless value. Instead, use the cookie's enum
values for executing correctly.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: dw_mmc: call the dw_mci_prep_stop_abort() by default
Jaehoon Chung [Thu, 17 Nov 2016 07:40:37 +0000 (16:40 +0900)]
mmc: dw_mmc: call the dw_mci_prep_stop_abort() by default

stop_cmdr should be set to values relevant to stop command.
It migth be assigned to values whatever there is mrq->stop or not.
Then it doesn't need to use dw_mci_prepare_command().
It's enough to use the prep_stop_abort for preparing stop command.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: dw_mmc: use the hold register when send stop command
Jaehoon Chung [Thu, 17 Nov 2016 07:40:36 +0000 (16:40 +0900)]
mmc: dw_mmc: use the hold register when send stop command

If DW_MMC_CARD_NO_USE_HOLD isn't set, it's usesd by default.
Enve if SDMMC_CMD_USB_HOLD_REG is set in prepare_command(), but it
doesn't set in pre_stop_abort().

To maintain the consistency, add the checking condition for this.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: dw_mmc: change the DW_MCI_FREQ_MIN from 400K to 100K
Jaehoon Chung [Thu, 17 Nov 2016 07:40:35 +0000 (16:40 +0900)]
mmc: dw_mmc: change the DW_MCI_FREQ_MIN from 400K to 100K

If there is no property "clock-freq-min-max", mmc->f_min should be set
to 400K by default. But Some SoC can be used 100K.
When 100K is used, MMC core will try to check from 400K to 100K.

Reported-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: dw_mmc: fix the debug message for checking card's present
Jaehoon Chung [Thu, 17 Nov 2016 07:40:34 +0000 (16:40 +0900)]
mmc: dw_mmc: fix the debug message for checking card's present

If display the debug message, this message should be spamming.
If flags is maintained the previous value, didn't display the debug
message.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: dw_mmc: display the real register value on debugfs
Jaehoon Chung [Thu, 17 Nov 2016 07:40:33 +0000 (16:40 +0900)]
mmc: dw_mmc: display the real register value on debugfs

Developer wants to see the real register value, not register offset.
This patch fixed to display the real value of register.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: dw_mmc: fix spelling mistake in dev_dbg message
Colin Ian King [Wed, 16 Nov 2016 18:55:01 +0000 (18:55 +0000)]
mmc: dw_mmc: fix spelling mistake in dev_dbg message

Trivial fix to spelling mistake "desciptor" to "descriptor" in
dev_dbg message.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: block: move packed command struct init
Linus Walleij [Fri, 18 Nov 2016 12:36:16 +0000 (13:36 +0100)]
mmc: block: move packed command struct init

By moving the mmc_packed_init() and mmc_packed_clean() into the
only file in the kernel where they are used, we save two exported
functions and can staticize those to the block.c file.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: block: rename data to blkdata
Linus Walleij [Fri, 18 Nov 2016 12:36:15 +0000 (13:36 +0100)]
mmc: block: rename data to blkdata

The struct mmc_blk_request contains an opaque void *data that
is actually only used to store a pointer to a per-request
struct mmc_blk_data. This is confusing, so rename the member
to blkdata and forward-declare the block.c local struct.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: block: use mmc_req_is_special()
Linus Walleij [Fri, 18 Nov 2016 12:36:14 +0000 (13:36 +0100)]
mmc: block: use mmc_req_is_special()

Instead of open coding the check for the same thing that
the helper checks: use the helper.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: davinci: request gpios using gpio descriptors
ahaslam@baylibre.com [Tue, 15 Nov 2016 16:28:22 +0000 (17:28 +0100)]
mmc: davinci: request gpios using gpio descriptors

Request card detect and write protect gpios using the provided API
by mmc core.

If a gpio is provided for card detect, we don't need to poll.
So only use polling when a gpio is not provided.

Once all pdata users register the gpios using gpio descriptors,
we could remove the platform callbacks.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: David Lechner <david@lechnology.com>
7 years agommc: davinci: use mmc_of_parse to parse common mmc configuration
ahaslam@baylibre.com [Tue, 15 Nov 2016 16:28:21 +0000 (17:28 +0100)]
mmc: davinci: use mmc_of_parse to parse common mmc configuration

Card detect and write protect are currently not working on a DT
boot, and the driver relies on polling to get the state
of the card. The current code depends on platform data callbacks
to register and get the state of the gpios.

mmc core provides a generic way to parse device tree configuration,
which will take care of registering the gpios for us, lets use it
so that we don't need to poll, and parse the same properties.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: David Lechner <david@lechnology.com>
7 years agommc: tmio: remove SDIO from TODO list
Wolfram Sang [Sun, 13 Nov 2016 14:29:12 +0000 (15:29 +0100)]
mmc: tmio: remove SDIO from TODO list

We surely have SDIO support by now :)

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: tmio: fix wrong bitmask for SDIO irqs
Wolfram Sang [Sun, 13 Nov 2016 14:29:11 +0000 (15:29 +0100)]
mmc: tmio: fix wrong bitmask for SDIO irqs

Commit 7729c7a232a953 ("mmc: tmio: Provide separate interrupt handlers")
refactored the sdio irq handler and wrongly used the mask for SD irqs,
not for SDIO irqs. This doesn't really matter in practice because both
values keep the only interrupt we are interested in. But still, this is
wrong and wants to be fixed.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: wbsd: implement check for dma mapping error
Alexey Khoroshilov [Fri, 11 Nov 2016 21:42:44 +0000 (00:42 +0300)]
mmc: wbsd: implement check for dma mapping error

wbsd_request_dma() does not check for dma mapping errors.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: mmc_test: Uninitialized return value
Dan Carpenter [Mon, 14 Nov 2016 11:31:34 +0000 (14:31 +0300)]
mmc: mmc_test: Uninitialized return value

We never set "ret" to RESULT_OK.

Fixes: 9f9c4180f88d ("mmc: mmc_test: add test for non-blocking transfers")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci: remove unneeded (void *) casts in sdhci_(pltfm_)priv()
Masahiro Yamada [Thu, 10 Nov 2016 13:22:17 +0000 (22:22 +0900)]
mmc: sdhci: remove unneeded (void *) casts in sdhci_(pltfm_)priv()

The type of host->private is (unsigned long *).  No cast is needed
to return an opaque pointer.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-iproc: support standard byte register accesses
Scott Branden [Tue, 1 Nov 2016 16:37:57 +0000 (09:37 -0700)]
mmc: sdhci-iproc: support standard byte register accesses

Add bytewise register accesses support for newer versions of IPROC
SDHCI controllers.
Previous sdhci-iproc versions of SDIO controllers
(such as Raspberry Pi and Cygnus) only allowed for 32-bit register
accesses.

Signed-off-by: Srinath Mannam <srinath.mannam@broadcom.com>
Signed-off-by: Scott Branden <scott.branden@broadcom.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-iproc: Add brcm, sdhci-iproc compat string in bindings document
Scott Branden [Tue, 1 Nov 2016 16:37:56 +0000 (09:37 -0700)]
mmc: sdhci-iproc: Add brcm, sdhci-iproc compat string in bindings document

Adds brcm,sdhci-iproc compat string to DT bindings document for
the iProc SDHCI driver.

Signed-off-by: Anup Patel <anup.patel@broadcom.com>
Signed-off-by: Scott Branden <scott.branden@broadcom.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sh_mobile_sdhi: Add tuning support
Simon Horman [Thu, 3 Nov 2016 14:16:04 +0000 (15:16 +0100)]
mmc: sh_mobile_sdhi: Add tuning support

Add tuning support for use with SDR104 mode
This includes adding support for the sampling clock controller (SCC).

Based on work by Ai Kyuse.

Cc: Ai Kyuse <ai.kyuse.uw@renesas.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: tmio: Add tuning support
Ai Kyuse [Thu, 3 Nov 2016 14:16:03 +0000 (15:16 +0100)]
mmc: tmio: Add tuning support

Add tuning support for use with SDR104 mode

Signed-off-by: Ai Kyuse <ai.kyuse.uw@renesas.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: tmio: Add hw reset support
Ai Kyuse [Thu, 3 Nov 2016 14:16:02 +0000 (15:16 +0100)]
mmc: tmio: Add hw reset support

Add hw reset support.

Signed-off-by: Ai Kyuse <ai.kyuse.uw@renesas.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: tmio: document mandatory and optional callbacks
Simon Horman [Thu, 3 Nov 2016 14:16:01 +0000 (15:16 +0100)]
mmc: tmio: document mandatory and optional callbacks

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: tmio: enhance illegal sequence handling
Ai Kyuse [Thu, 3 Nov 2016 14:16:00 +0000 (15:16 +0100)]
mmc: tmio: enhance illegal sequence handling

An illegal sequence command error may occur if there is a stopbit or
cmd_index error as well as a CRC error. The correct course of action
is to re-enable IRQs

An illegal sequence data error may occur if there is a CRC or stopbit
error,  or underrun. In this case set data->error correctly.

This is in preparation for enabling tuning support which relies on
differentiating between illegal sequence and other errors.

Signed-off-by: Ai Kyuse <ai.kyuse.uw@renesas.com>
[simon: broken out of a larger patch]
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: core: Add helper to see if a host can be retuned
Simon Horman [Thu, 3 Nov 2016 14:15:59 +0000 (15:15 +0100)]
mmc: core: Add helper to see if a host can be retuned

This is in preparation for restoring saved tuning parameters
when resuming the TMIO driver.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sh_mobile_sdhi: Add r7s72100 support
Chris Brandt [Mon, 12 Sep 2016 14:15:07 +0000 (10:15 -0400)]
mmc: sh_mobile_sdhi: Add r7s72100 support

Add support for r7s72100 SoC.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: tmio-mmc: add support for 32bit data port
Chris Brandt [Mon, 12 Sep 2016 14:15:06 +0000 (10:15 -0400)]
mmc: tmio-mmc: add support for 32bit data port

For the r7s72100 SOC, the DATA_PORT register was changed to 32-bits wide.
Therefore a new flag has been created that will allow 32-bit reads/writes
to the DATA_PORT register instead of 16-bit (because 16-bits accesses are
not supported).

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sh_mobile_sdhi: add ocr_mask option
Chris Brandt [Mon, 12 Sep 2016 14:15:05 +0000 (10:15 -0400)]
mmc: sh_mobile_sdhi: add ocr_mask option

In moving platforms from board files to DT, there still needs to be a way
to set the ocr_mask setting for the tmio driver during probe. Without this
setting, the probe will fail because the supported voltages are not known.

This patch will also traditional platform registration platforms to
migrate to DT.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: core: use enum mmc_blk_status properly
Linus Walleij [Fri, 4 Nov 2016 10:05:19 +0000 (11:05 +0100)]
mmc: core: use enum mmc_blk_status properly

There were several instances of code using the
enum mmc_blk_status by arbitrarily converting it to an int and
throwing it around to different functions. This makes the code
hard to understand to may give rise to strange errors.

Especially the function prototype mmc_start_req() had to be
modified to take a pointer to an enum mmc_blk_status and the
function pointer .err_check() inside struct mmc_async_req
needed to return an enum mmc_blk_status.

In every case: instead of assigning the block layer error code
to an int, use the enum, also change the signature of all
functions actually passing this enum to use the enum.

To make it possible to use the enum everywhere applicable, move
it to <linux/mmc/core.h> so that all code actually using it can
also see it.

An interesting case was encountered in the MMC test code which
did not return a enum mmc_blk_status at all in the .err_check
function supposed to check whether asynchronous requests worked
or not: instead it returned a normal -ERROR or even the test
frameworks internal error codes.

The test code would also pass on enum mmc_blk_status codes as
error codes inside the test code instead of converting them
to the local RESULT_* codes.

I have tried to fix all instances properly and run some tests
on the result.

Cc: Chunyan Zhang <zhang.chunyan@linaro.org>
Cc: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: block: convert ecc_err to a bool
Linus Walleij [Fri, 4 Nov 2016 10:05:18 +0000 (11:05 +0100)]
mmc: block: convert ecc_err to a bool

The ecc_err flag is only assigned 0 or 1 and treated as a bool,
so convert it to a bool.

Cc: Chunyan Zhang <zhang.chunyan@linaro.org>
Cc: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: block: make gen_err a bool variable
Linus Walleij [Fri, 4 Nov 2016 10:05:17 +0000 (11:05 +0100)]
mmc: block: make gen_err a bool variable

This gen_err flag is only assigned 0 or 1 and treated as a bool,
so convert it to a bool.

Cc: Chunyan Zhang <zhang.chunyan@linaro.org>
Cc: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci: Use sdhci-caps-mask and sdhci-caps to change the caps read during __sdhci...
Zach Brown [Wed, 2 Nov 2016 15:26:16 +0000 (10:26 -0500)]
mmc: sdhci: Use sdhci-caps-mask and sdhci-caps to change the caps read during __sdhci_read_caps

The sdhci capabilities register can be incorrect. The sdhci-caps-mask
and sdhci-caps dt properties specify which bits of the register are
incorrect and what their values should be. This patch makes the sdhci
driver use those properties to correct the caps during
__sdhci_read_caps.

During __sdhci_read_caps
Use the sdhci-caps-mask property to turn off the incorrect bits of the
sdhci register after reading them.
Use the sdhci-caps to turn on bits after using sdhci-caps-mask to turn
off the incorrect ones.

Signed-off-by: Zach Brown <zach.brown@ni.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci: dt: Add device tree properties sdhci-caps and sdhci-caps-mask
Zach Brown [Wed, 2 Nov 2016 15:26:15 +0000 (10:26 -0500)]
mmc: sdhci: dt: Add device tree properties sdhci-caps and sdhci-caps-mask

On some systems the sdhci capabilty register is incorrect for one
reason or another.

The sdhci-caps-mask property specifies which bits in the register
are incorrect and should be turned off before using sdhci-caps to turn
on bits.

The sdhci-caps property specifies which bits should be turned on.

Signed-off-by: Zach Brown <zach.brown@ni.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: mmci: refactor ST Micro busy detection
Linus Walleij [Tue, 25 Oct 2016 09:06:06 +0000 (11:06 +0200)]
mmc: mmci: refactor ST Micro busy detection

The ST Micro-specific busy detection was made after the assumption
that only this variant supports busy detection. So when doing busy
detection, the host immediately tries to use some ST-specific
register bits.

Since the qualcomm variant also supports some busy detection
schemes, encapsulate the variant flags better in the variant struct
and prepare to add more variants by just providing some bitmasks
to the logic.

Put the entire busy detection logic within an if()-clause in the
mmci_cmd_irq() function so the code is only executed when busy
detection is enabled, and so that it is kept in (almost) one
place, and add comments describing what is going on so the
code can be understood.

Tested on the Ux500 by introducing some prints in the busy
detection path and noticing how the IRQ is enabled, used and
disabled successfully.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: mmci: clean up header defines
Linus Walleij [Tue, 25 Oct 2016 09:06:05 +0000 (11:06 +0200)]
mmc: mmci: clean up header defines

There was some confusion in the CPSM (Command Path State Machine)
and DPSM (Data Path State Machine) regarding the naming of the
registers, clarify the meaning of this acronym so the naming is
understandable, and consistently use BIT() to define these fields.

Consequently name the register bit defines MCI_[C|D]PSM_* and
adjust the driver as well.

Include new definitions for a few bits found in a patch from
Srinivas Kandagatla.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: s3cmci: Use DMA slave map rather than exported DMA filter
Sylwester Nawrocki [Wed, 26 Oct 2016 16:30:53 +0000 (18:30 +0200)]
mmc: s3cmci: Use DMA slave map rather than exported DMA filter

Support for DMA slave map has been added to the s3c24xx-dma
controller in commit 34681d84a0f7cc22ded1413dc79eef8a2f23d9c3
"dmaengine: s3c24xx: Add dma_slave_map for s3c2440 devices"
This patch converts the s3cmci driver to also use it, so we can
eventually get rid of the exported filter function once all
related DMA clients are updated.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: core: Don't power off the card when starting the host
Ulf Hansson [Thu, 13 Oct 2016 11:37:40 +0000 (13:37 +0200)]
mmc: core: Don't power off the card when starting the host

The MMC_CAP2_NO_PRESCAN_POWERUP was invented to avoid running the power up
sequence, mmc_power_up(), during ->probe() of the mmc host driver, but
instead defer this to the mmc detect work. This is especially useful for
those hosts that suffers from a long initialization time, as this time
would otherwise add up to the total boot time.

However, due to the introduction of runtime PM of mmc host devices in the
mmc core, this behaviour changed a bit. More precisely, it caused the mmc
core to runtime resume the host device during ->probe() of the host driver.
In cases like the rtsx_usb_sdmmc, runtime resuming the device may be costly
and thus affecting the total boot time.

To improve this behaviour when using MMC_CAP2_NO_PRESCAN_POWERUP, let's
postpone also calling mmc_power_off() when starting the host. This change
allows the mmc core to avoid runtime resuming the device, as it don't need
to claim the host for that execution path.

Cc: Ritesh Raj Sarraf <rrs@researchut.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agoDocumentation: DT: MMC: meson-gx: new bindings doc
Kevin Hilman [Wed, 19 Oct 2016 18:18:25 +0000 (11:18 -0700)]
Documentation: DT: MMC: meson-gx: new bindings doc

Signed-off-by: Kevin Hilman <khilman@baylibre.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agoMMC: meson: initial support for GX platforms
Kevin Hilman [Wed, 19 Oct 2016 18:18:24 +0000 (11:18 -0700)]
MMC: meson: initial support for GX platforms

Initial support for the SD/eMMC controller in the Amlogic S905/GX*
family of SoCs.

Signed-off-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: dw_mmc: remove system PM callback
Shawn Lin [Wed, 12 Oct 2016 02:56:55 +0000 (10:56 +0800)]
mmc: dw_mmc: remove system PM callback

Now there are no variant drivers using dw_mci_suspend
and dw_mci_resume, so let's remove it.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: dw_mmc-pltfm: deploy runtime PM facilities
Shawn Lin [Wed, 12 Oct 2016 02:56:46 +0000 (10:56 +0800)]
mmc: dw_mmc-pltfm: deploy runtime PM facilities

Let's migrate it to use runtime PM and remove the system
PM callback from this driver. With this patch, it could
handle system PM properly and could also use runtime PM
if we enable it.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: dw_mmc-pci: deploy runtime PM facilities
Shawn Lin [Wed, 12 Oct 2016 02:56:34 +0000 (10:56 +0800)]
mmc: dw_mmc-pci: deploy runtime PM facilities

Let's migrate it to use runtime PM and remove the system
PM callback from this driver. With this patch, it could
handle system PM properly and could also use runtime PM
if we enable it.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: dw_mmc-exynos: deploy runtime PM facilities
Shawn Lin [Wed, 12 Oct 2016 02:55:55 +0000 (10:55 +0800)]
mmc: dw_mmc-exynos: deploy runtime PM facilities

Let's migrate it to use runtime PM and remove the system
PM callback from this driver. With this patch, it could
handle system PM properly and could also use runtime PM
if we enable it.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: dw_mmc-k3: deploy runtime PM facilities
Shawn Lin [Wed, 12 Oct 2016 02:54:40 +0000 (10:54 +0800)]
mmc: dw_mmc-k3: deploy runtime PM facilities

Let's migrate it to use runtime PM and remove the system
PM callback from this driver. With this patch, it could
handle system PM properly and could also use runtime PM
if we enable it.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: dw_mmc: disable biu clk if possible
Shawn Lin [Wed, 12 Oct 2016 02:50:38 +0000 (10:50 +0800)]
mmc: dw_mmc: disable biu clk if possible

We could disable biu clk if gpio card detect available,
or it is a non-removable device.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: core: expose the capability of gpio card detect
Shawn Lin [Wed, 12 Oct 2016 02:50:37 +0000 (10:50 +0800)]
mmc: core: expose the capability of gpio card detect

Add new helper API mmc_can_gpio_cd for slot-gpio to make
host drivers know whether it supports gpio card detect.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: dw_mmc-rockchip: add runtime PM support
Shawn Lin [Wed, 12 Oct 2016 02:50:36 +0000 (10:50 +0800)]
mmc: dw_mmc-rockchip: add runtime PM support

This patch adds runtime PM support for dw_mmc-rockchip.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: dw_mmc: add runtime PM callback
Shawn Lin [Wed, 12 Oct 2016 02:50:35 +0000 (10:50 +0800)]
mmc: dw_mmc: add runtime PM callback

This patch add dw_mci_runtime_suspend/resume interfaces
and expose it to dw_mci variant driver to support runtime
PM.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: core: Don't use ->card_busy() and CMD13 in combination when polling
Ulf Hansson [Wed, 19 Oct 2016 14:15:31 +0000 (16:15 +0200)]
mmc: core: Don't use ->card_busy() and CMD13 in combination when polling

When polling for busy after sending a MMC_SWITCH command, both the optional
->card_busy() callback and CMD13 are being used in conjunction.

This doesn't make sense. Instead it's more reasonable to rely solely on the
->card_busy() callback when it exists. Let's change that and instead use
the CMD13 as a fall-back. In this way we avoid sending CMD13, unless it's
really needed.

Within this context, let's also take the opportunity to make some
additional clean-ups and clarifications to the related code.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Tested-by: Jaehoon Chung <jh80.chung@samsung.com>
7 years agommc: core: Factor out code related to polling in __mmc_switch()
Ulf Hansson [Wed, 19 Oct 2016 11:20:49 +0000 (13:20 +0200)]
mmc: core: Factor out code related to polling in __mmc_switch()

In yet another step of cleaning up __mmc_switch(), let's factor out the
code that deals with card busy polling.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Tested-by: Jaehoon Chung <jh80.chung@samsung.com>
7 years agommc: core: Clarify code which deals with polling in __mmc_switch()
Ulf Hansson [Wed, 19 Oct 2016 09:35:12 +0000 (11:35 +0200)]
mmc: core: Clarify code which deals with polling in __mmc_switch()

The __mmc_switch() deserves a clean-up. In this step, let's move some code
outside of the do-while loop, which deal deals with the card busy polling.

This change simplifies the code in that sense that it becomes easier to follow
what is being executed during card busy polling, but it also gives a better
understanding for when polling isn't done.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Tested-by: Jaehoon Chung <jh80.chung@samsung.com>
7 years agommc: core: Make mmc_switch_status() available for mmc core
Ulf Hansson [Wed, 19 Oct 2016 09:04:42 +0000 (11:04 +0200)]
mmc: core: Make mmc_switch_status() available for mmc core

Following changes needs mmc_switch_status() to be available both from mmc.c
and mmc_ops.c. Allow that by moving its implementation to mmc_ops.c and
make it available via mmc_ops.h.

Moving mmc_switch_status() to mmc_ops.c, also enables us to turn
mmc_switch_status_error() into static function. So let's take the
opportunity to change this as well.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Tested-by: Jaehoon Chung <jh80.chung@samsung.com>
7 years agommc: sdhci-msm: Add pm_runtime and system PM support
Pramod Gurav [Fri, 21 Oct 2016 06:42:04 +0000 (12:12 +0530)]
mmc: sdhci-msm: Add pm_runtime and system PM support

Provides runtime PM callbacks to enable and disable clock resources
when idle. Also support system PM callbacks to be called during system
suspend and resume.

Reviewed-by: Ritesh Harjani <riteshh@codeaurora.org>
Reviewed-by: Georgi Djakov <georgi.djakov@linaro.org>
Tested-by: Ritesh Harjani <riteshh@codeaurora.org>
Signed-off-by: Pramod Gurav <pramod.gurav@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sunxi: Prevent against null dereference for vmmc
Maxime Ripard [Wed, 19 Oct 2016 13:33:04 +0000 (15:33 +0200)]
mmc: sunxi: Prevent against null dereference for vmmc

VMMC is an optional regulator, which means that mmc_regulator_get_supply
will only return an error in case of a deferred probe, but not when the
regulator is not set in the DT.

However, the sunxi driver assumes that VMMC is always there, and doesn't
check the value of the regulator pointer before using it, which obviously
leads to a (close to) null pointer dereference.

Add proper checks to prevent that.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: block: Change MMC_IOC_MAX_BYTES
Jeonghan Kim [Wed, 19 Oct 2016 10:48:02 +0000 (19:48 +0900)]
mmc: block: Change MMC_IOC_MAX_BYTES

It is used for limitation of buffer size during IOCTL such as FFU.
However, eMMC FW size is bigger than (512L*256).
(For instance, currently, Samsung eMMC FW size is over 300KB.)
So, it needs to increase to execute FFU.

Signed-off-by: Jeonghan Kim <jh4u.kim@samsung.com>
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-of-at91: Fix module autoload
Javier Martinez Canillas [Mon, 17 Oct 2016 16:13:45 +0000 (13:13 -0300)]
mmc: sdhci-of-at91: Fix module autoload

If the driver is built as a module, autoload won't work because the module
alias information is not filled. So user-space can't match the registered
device with the corresponding module.

Export the module alias information using the MODULE_DEVICE_TABLE() macro.

Before this patch:

$ modinfo drivers/mmc/host/sdhci-of-at91.ko | grep alias
$

After this patch:

$ modinfo drivers/mmc/host/sdhci-of-at91.ko | grep alias
alias:          of:N*T*Catmel,sama5d2-sdhciC*
alias:          of:N*T*Catmel,sama5d2-sdhci

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: mediatek: Fix module autoload
Javier Martinez Canillas [Mon, 17 Oct 2016 16:13:44 +0000 (13:13 -0300)]
mmc: mediatek: Fix module autoload

If the driver is built as a module, autoload won't work because the module
alias information is not filled. So user-space can't match the registered
device with the corresponding module.

Export the module alias information using the MODULE_DEVICE_TABLE() macro.

Before this patch:

$ modinfo drivers/mmc/host/mtk-sd.ko | grep alias
$

After this patch:

$ modinfo drivers/mmc/host/mtk-sd.ko | grep alias
alias:          of:N*T*Cmediatek,mt8135-mmcC*
alias:          of:N*T*Cmediatek,mt8135-mmc

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: rtsx_usb_sdmmc: Enable runtime PM autosuspend
Ulf Hansson [Thu, 13 Oct 2016 11:37:39 +0000 (13:37 +0200)]
mmc: rtsx_usb_sdmmc: Enable runtime PM autosuspend

Enable runtime PM autosuspend for the rtsx_usb_sdmmc driver to avoid the
device being runtime suspended and runtime resumed between each request.
Let's use a default timeout of 50ms, to be consistent with other mmc hosts.

Cc: Ritesh Raj Sarraf <rrs@researchut.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>