OSDN Git Service

uclinux-h8/linux.git
7 years agommc: meson-gx: add support for descriptor chain mode
Heiner Kallweit [Fri, 7 Apr 2017 19:22:44 +0000 (21:22 +0200)]
mmc: meson-gx: add support for descriptor chain mode

So far a bounce buffer is used to serialize the scatterlist(s).
This overhead can be avoided by switching to descriptor chain mode.
As result the performance is drastically improved. On a Odroid-C2 with
a 128 GB eMMC module raw reads reach 140 MB/s.

Prerequisite for descriptor chain mode is that all scatterlist buffers
are 8 byte aligned for 64-bit DMA. That's not always the case, at least
the brcmfmac SDIO WiFi driver is known to cause problems.

Therefore, for each request, check upfront whether all scatterlist
buffers are 8 byte aligned and fall back to bounce buffer mode if
that's not the case.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: meson-gx: add basic tuning for rx clock phase
Heiner Kallweit [Tue, 4 Apr 2017 19:11:17 +0000 (21:11 +0200)]
mmc: meson-gx: add basic tuning for rx clock phase

This patch adds basic tuning which changes the rx clock phase only
until a working setting is found.

On a Odroid C2 with 128GB eMMC card and 200 MHz MMC clock only
180° rx clock phase make the system boot w/o CRC errors.

With other MMC devices / clock speeds this might be different,
therefore don't change the driver config in general.

When retuning skip the currently active parameter set. This avoids
the current problematic config to be chosen again if it causes CRC
errors just occasionally.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: meson-gx: introduce struct meson_tuning_params
Heiner Kallweit [Tue, 4 Apr 2017 19:03:22 +0000 (21:03 +0200)]
mmc: meson-gx: introduce struct meson_tuning_params

Introduce struct meson_tuning_params for storing the clock phase
configurations. There's no functional change because tx and rx
clock phase were implicitely set to CLK_PHASE_0 before.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: core: add proper be32 annotation
Winkler, Tomas [Sun, 2 Apr 2017 20:56:03 +0000 (23:56 +0300)]
mmc: core: add proper be32 annotation

Annotate big endian values correctly and make sparse happy.
In mmc_app_send_scr remove scr function parameter as it was
updating card->raw_scr anyway.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-cadence: add parsing sdhci properties
Piotr Sroka [Tue, 11 Apr 2017 11:13:38 +0000 (12:13 +0100)]
mmc: sdhci-cadence: add parsing sdhci properties

Add calling sdhci_get_of_property function to parse sdhci properties.

Signed-off-by: Piotr Sroka <piotrs@cadence.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: host: omap_hsmmc: checking for NULL instead of IS_ERR()
Dan Carpenter [Mon, 10 Apr 2017 13:54:17 +0000 (16:54 +0300)]
mmc: host: omap_hsmmc: checking for NULL instead of IS_ERR()

devm_pinctrl_get() returns error pointers, it never returns NULL.

Fixes: 455e5cd6f736 ("mmc: omap_hsmmc: Pin remux workaround to support SDIO interrupt on AM335x")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agoMAINTAINERS: add entry for Marvell Xenon MMC Host Controller drivers
Hu Ziji [Thu, 30 Mar 2017 15:23:02 +0000 (17:23 +0200)]
MAINTAINERS: add entry for Marvell Xenon MMC Host Controller drivers

Add maintainer entry for Marvell Xenon eMMC/SD/SDIO
Host Controller drivers.

Signed-off-by: Hu Ziji <huziji@marvell.com>
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-xenon: Add SoC PHY PAD voltage control
Hu Ziji [Thu, 30 Mar 2017 15:23:01 +0000 (17:23 +0200)]
mmc: sdhci-xenon: Add SoC PHY PAD voltage control

Some SoCs have PHY PAD outside Xenon IP.
PHY PAD voltage should match signalling voltage in use.

Add generic SoC PHY PAD voltage control interface.
Implement Aramda-3700 SoC PHY PAD voltage control.

Signed-off-by: Hu Ziji <huziji@marvell.com>
Tested-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-xenon: Add support to PHYs of Marvell Xenon SDHC
Hu Ziji [Thu, 30 Mar 2017 15:23:00 +0000 (17:23 +0200)]
mmc: sdhci-xenon: Add support to PHYs of Marvell Xenon SDHC

Marvell Xenon eMMC/SD/SDIO Host Controller contains PHY.
Multiple types of PHYs are supported.

Add support to multiple types of PHYs init and configuration.
Add register definitions of PHYs.

Xenon PHY cannot fit in kernel common PHY framework.
Xenon SDHC PHY register is a part of Xenon SDHC register set.
Besides, MMC initialization has to call several PHY functions to
complete timing setting.
Those PHY setting functions have to access SDHC registers and know
current MMC setting, such as bus width, clock frequency and
speed mode.
As a result, implement Xenon PHY in MMC host directory.

Signed-off-by: Hu Ziji <huziji@marvell.com>
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-xenon: Add Marvell Xenon SDHC core functionality
Hu Ziji [Thu, 30 Mar 2017 15:22:59 +0000 (17:22 +0200)]
mmc: sdhci-xenon: Add Marvell Xenon SDHC core functionality

Add Xenon eMMC/SD/SDIO host controller core functionality.
Add Xenon specific initialization process.
Add Xenon specific mmc_host_ops APIs.
Add Xenon specific register definitions.

Add CONFIG_MMC_SDHCI_XENON support in drivers/mmc/host/Kconfig.

Marvell Xenon SDHC conforms to SD Physical Layer Specification
Version 3.01 and is designed according to the guidelines provided
in the SD Host Controller Standard Specification Version 3.00.

Signed-off-by: Hu Ziji <huziji@marvell.com>
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agodt: bindings: Add bindings for Marvell Xenon SD Host Controller
Hu Ziji [Thu, 30 Mar 2017 15:22:58 +0000 (17:22 +0200)]
dt: bindings: Add bindings for Marvell Xenon SD Host Controller

Marvell Xenon SDHC can support eMMC/SD/SDIO.
Add Xenon-specific properties.
Also add properties for Xenon PHY setting.

Signed-off-by: Hu Ziji <huziji@marvell.com>
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci: Export sdhci_enable_sdio_irq() from sdhci.c
Hu Ziji [Thu, 30 Mar 2017 15:22:57 +0000 (17:22 +0200)]
mmc: sdhci: Export sdhci_enable_sdio_irq() from sdhci.c

Export sdhci_enable_sdio_irq() from sdhci.c.
Thus vendor SDHC driver can implement its specific SDIO irq
control.

Signed-off-by: Hu Ziji <huziji@marvell.com>
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci: Export sdhci_start_signal_voltage_switch() in sdhci.c
Hu Ziji [Thu, 30 Mar 2017 15:22:56 +0000 (17:22 +0200)]
mmc: sdhci: Export sdhci_start_signal_voltage_switch() in sdhci.c

Export sdhci_start_signal_voltage_switch() from sdhci.c.
Thus vendor sdhci driver can implement its own signal voltage
switch routine.

Signed-off-by: Hu Ziji <huziji@marvell.com>
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci: Export sdhci_set_ios() from sdhci.c
Hu Ziji [Thu, 30 Mar 2017 15:22:55 +0000 (17:22 +0200)]
mmc: sdhci: Export sdhci_set_ios() from sdhci.c

Export sdhci_set_ios() in sdhci.c.
Thus vendor sdhci driver can implement its own set_ios() routine.

Signed-off-by: Hu Ziji <huziji@marvell.com>
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agoclk: apn806: Turn the eMMC clock as optional for dts backwards compatible
Gregory CLEMENT [Thu, 30 Mar 2017 15:22:54 +0000 (17:22 +0200)]
clk: apn806: Turn the eMMC clock as optional for dts backwards compatible

First version of the binding didn't have the eMMC clock. This patch
allows to not registering the eMMC clock if it is not present in the
device tree. Then the device tree can be backwards compatible.

Suggested-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agoclk: apn806: Add eMMC clock to system controller driver
Konstantin Porotchkin [Thu, 30 Mar 2017 15:22:53 +0000 (17:22 +0200)]
clk: apn806: Add eMMC clock to system controller driver

Add fixed clock of 400MHz to system controller driver.  This clock is
used as SD/eMMC clock source.

Signed-off-by: Konstantin Porotchkin <kostap@marvell.com>
Reviewed-by: Omri Itach <omrii@marvell.com>
Reviewed-by: Hanna Hawa <hannah@marvell.com>
[fixed up conflicts, added error handling --rmk]
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Acked-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agoMAINTAINERS: Add entry for Cavium MMC driver
Jan Glauber [Thu, 30 Mar 2017 15:31:28 +0000 (17:31 +0200)]
MAINTAINERS: Add entry for Cavium MMC driver

Signed-off-by: Jan Glauber <jglauber@cavium.com>
Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: Steven J. Hill <steven.hill@cavium.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: cavium: Support DDR mode for eMMC devices
Jan Glauber [Thu, 30 Mar 2017 15:31:27 +0000 (17:31 +0200)]
mmc: cavium: Support DDR mode for eMMC devices

Add support for switching to DDR mode for eMMC devices.

Signed-off-by: Jan Glauber <jglauber@cavium.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: cavium: Add scatter-gather DMA support
Jan Glauber [Thu, 30 Mar 2017 15:31:26 +0000 (17:31 +0200)]
mmc: cavium: Add scatter-gather DMA support

Add Support for the scatter-gather DMA available in the
ThunderX MMC units. Up to 16 DMA requests can be processed
together.

Signed-off-by: Jan Glauber <jglauber@cavium.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: cavium: Add MMC PCI driver for ThunderX SOCs
Jan Glauber [Thu, 30 Mar 2017 15:31:25 +0000 (17:31 +0200)]
mmc: cavium: Add MMC PCI driver for ThunderX SOCs

Add a platform driver for ThunderX ARM SOCs.

Signed-off-by: Jan Glauber <jglauber@cavium.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: cavium: Add core MMC driver for Cavium SOCs
Jan Glauber [Thu, 30 Mar 2017 15:31:24 +0000 (17:31 +0200)]
mmc: cavium: Add core MMC driver for Cavium SOCs

This core driver will be used by a MIPS platform driver
or by an ARM64 PCI driver. The core driver implements the
mmc_host_ops and slot probe & remove functions.
Callbacks are provided to allow platform specific interrupt
enable and bus locking.

The host controller supports:
- up to 4 slots that can contain sd-cards or eMMC chips
- 1, 4 and 8 bit bus width
- SDR and DDR
- transfers up to 52 Mhz (might be less when multiple slots are used)
- DMA read/write
- multi-block read/write (but not stream mode)

Voltage is limited to 3.3v and shared for all slots (vmmc and vmmcq).

A global lock for all MMC devices is required because the host
controller is shared.

Signed-off-by: Jan Glauber <jglauber@cavium.com>
Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: Steven J. Hill <steven.hill@cavium.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agodt-bindings: mmc: Add Cavium SOCs MMC bindings
Jan Glauber [Thu, 30 Mar 2017 15:31:23 +0000 (17:31 +0200)]
dt-bindings: mmc: Add Cavium SOCs MMC bindings

Add description of Cavium Octeon and ThunderX SOC device tree bindings.

CC: Ulf Hansson <ulf.hansson@linaro.org>
CC: Rob Herring <robh+dt@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: devicetree@vger.kernel.org
Signed-off-by: Jan Glauber <jglauber@cavium.com>
Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: Steven J. Hill <steven.hill@cavium.com>
Acked-by: Rob Herring <robh+dt@kernel.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: core: refactor mmc_request_done()
Linus Walleij [Tue, 28 Mar 2017 08:40:31 +0000 (10:40 +0200)]
mmc: core: refactor mmc_request_done()

We have this construction:

if (a && b && !c)
   finalize;
else
   block;
   finalize;

Which is equivalent by boolean logic to:

if (!a || !b || c)
   block;
finalize;

Which is simpler code.

Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: core: refactor asynchronous request finalization
Linus Walleij [Tue, 28 Mar 2017 08:40:30 +0000 (10:40 +0200)]
mmc: core: refactor asynchronous request finalization

mmc_wait_for_data_req_done() is called in exactly one place,
and having it spread out is making things hard to oversee.
Factor this function into mmc_finalize_areq().

Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: core: move some code in mmc_start_areq()
Linus Walleij [Tue, 28 Mar 2017 08:40:29 +0000 (10:40 +0200)]
mmc: core: move some code in mmc_start_areq()

"previous" is a better name for the variable storing the previous
asynchronous request, better than the opaque name "data" atleast.
We see that we assign the return status to the returned variable
on all code paths, so we might as well just do that immediately
after calling mmc_finalize_areq().

Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: core: Factor out mrq preparation from mmc_start_request()
Adrian Hunter [Mon, 13 Mar 2017 12:36:43 +0000 (14:36 +0200)]
mmc: core: Factor out mrq preparation from mmc_start_request()

In preparation to reuse the code for CQE support.

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: core: Factor out debug prints from mmc_start_request()
Adrian Hunter [Mon, 13 Mar 2017 12:36:42 +0000 (14:36 +0200)]
mmc: core: Factor out debug prints from mmc_start_request()

In preparation to reuse the code for CQE support.

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: Factor out data preparation
Adrian Hunter [Mon, 13 Mar 2017 12:36:41 +0000 (14:36 +0200)]
mmc: block: Factor out data preparation

Factor out data preparation into a separate function mmc_blk_data_prep()
which can be re-used for command queuing.

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: Change mmc_apply_rel_rw() to get block address from the request
Adrian Hunter [Mon, 13 Mar 2017 12:36:40 +0000 (14:36 +0200)]
mmc: block: Change mmc_apply_rel_rw() to get block address from the request

mmc_apply_rel_rw() will be used by Software Command Queuing also. In that
case the command argument is not the block address so change
mmc_apply_rel_rw() to get block address from the request.

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: Disable Command Queue while RPMB is used
Adrian Hunter [Mon, 13 Mar 2017 12:36:39 +0000 (14:36 +0200)]
mmc: block: Disable Command Queue while RPMB is used

RPMB does not allow Command Queue commands. Disable and re-enable the
Command Queue when switching.

Note that the driver only switches partitions when the queue is empty.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Harjani Ritesh <riteshh@codeaurora.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: mmc_test: Disable Command Queue while mmc_test is used
Adrian Hunter [Mon, 13 Mar 2017 12:36:38 +0000 (14:36 +0200)]
mmc: mmc_test: Disable Command Queue while mmc_test is used

Normal read and write commands may not be used while the command queue is
enabled. Disable the Command Queue when mmc_test is probed and re-enable it
when it is removed.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Harjani Ritesh <riteshh@codeaurora.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: mmc: Add functions to enable / disable the Command Queue
Adrian Hunter [Mon, 13 Mar 2017 12:36:37 +0000 (14:36 +0200)]
mmc: mmc: Add functions to enable / disable the Command Queue

Add helper functions to enable or disable the Command Queue.

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: queue: Share mmc request array between partitions
Adrian Hunter [Mon, 13 Mar 2017 12:36:36 +0000 (14:36 +0200)]
mmc: queue: Share mmc request array between partitions

eMMC can have multiple internal partitions that are represented as separate
disks / queues. However switching between partitions is only done when the
queue is empty. Consequently the array of mmc requests that are queued can
be shared between partitions saving memory.

Keep a pointer to the mmc request queue on the card, and use that instead
of allocating a new one for each partition.

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: Introduce queue semantics
Adrian Hunter [Mon, 13 Mar 2017 12:36:35 +0000 (14:36 +0200)]
mmc: block: Introduce queue semantics

Change from viewing the requests in progress as 'current' and 'previous',
to viewing them as a queue. The current request is allocated to the first
free slot. The presence of incomplete requests is determined from the
count (mq->qcnt) of entries in the queue. Non-read-write requests (i.e.
discards and flushes) are not added to the queue at all and require no
special handling. Also no special handling is needed for the
MMC_BLK_NEW_REQUEST case.

As well as allowing an arbitrarily sized queue, the queue thread function
is significantly simpler.

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: Use local var for mqrq_cur
Adrian Hunter [Mon, 13 Mar 2017 12:36:34 +0000 (14:36 +0200)]
mmc: block: Use local var for mqrq_cur

A subsequent patch will remove 'mq->mqrq_cur'. Prepare for that by
assigning it to a local variable.

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: host: s3cmci: allow probing from device tree
Sergio Prado [Fri, 31 Mar 2017 23:50:56 +0000 (20:50 -0300)]
mmc: host: s3cmci: allow probing from device tree

Allows configuring Samsung S3C24XX MMC/SD/SDIO controller using a device
tree.

Signed-off-by: Sergio Prado <sergio.prado@e-labworks.com>
[Arnd: fix broken conditional expression]
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agodt-bindings: mmc: add DT binding for S3C24XX MMC/SD/SDIO controller
Sergio Prado [Fri, 31 Mar 2017 23:50:55 +0000 (20:50 -0300)]
dt-bindings: mmc: add DT binding for S3C24XX MMC/SD/SDIO controller

Adds the device tree bindings description for Samsung S3C24XX
MMC/SD/SDIO controller, used as a connectivity interface with external
MMC, SD and SDIO storage mediums.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sergio Prado <sergio.prado@e-labworks.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-pci: Set MMC_CAP_AGGRESSIVE_PM for BYT-related Intel controllers
Azhar Shaikh [Wed, 29 Mar 2017 18:16:33 +0000 (11:16 -0700)]
mmc: sdhci-pci: Set MMC_CAP_AGGRESSIVE_PM for BYT-related Intel controllers

Set MMC_CAP_AGGRESSIVE_PM for BYT-related Intel SD card
controllers.

Signed-off-by: Azhar Shaikh <azhar.shaikh@intel.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-acpi: Set MMC_CAP_AGGRESSIVE_PM for BYT-related Intel controllers
Azhar Shaikh [Wed, 29 Mar 2017 18:16:32 +0000 (11:16 -0700)]
mmc: sdhci-acpi: Set MMC_CAP_AGGRESSIVE_PM for BYT-related Intel controllers

Set MMC_CAP_AGGRESSIVE_PM for BYT-related Intel SD card
controllers.

Signed-off-by: Azhar Shaikh <azhar.shaikh@intel.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: meson-gx: factor out setting response configuration bits
Heiner Kallweit [Mon, 27 Mar 2017 20:02:32 +0000 (22:02 +0200)]
mmc: meson-gx: factor out setting response configuration bits

Factor out setting the response configuration bits thus further reducing
complexity of function meson_mmc_start_cmd.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: meson-gx: factor out setting block size
Heiner Kallweit [Mon, 27 Mar 2017 19:57:11 +0000 (21:57 +0200)]
mmc: meson-gx: factor out setting block size

Factor out setting the block size. This also contributes to reducing
complexity of function meson_mmc_start_cmd.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-cadence: refactor probe function
Piotr Sroka [Tue, 21 Mar 2017 14:33:26 +0000 (14:33 +0000)]
mmc: sdhci-cadence: refactor probe function

Use added dev variable for devm_clk_get.

Signed-off-by: Piotr Sroka <piotrs@cadence.com>
Reviewed-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-cadence: Update PHY delay configuration
Piotr Sroka [Tue, 21 Mar 2017 14:33:11 +0000 (14:33 +0000)]
mmc: sdhci-cadence: Update PHY delay configuration

DTS properties are used instead of fixed data
because PHY settings can be different for different chips/boards.

Signed-off-by: Piotr Sroka <piotrs@cadence.com>
Reviewed-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 agodt-bindings: mmc: add description of PHY delays for sdhci-cadence
Piotr Sroka [Tue, 21 Mar 2017 14:33:01 +0000 (14:33 +0000)]
dt-bindings: mmc: add description of PHY delays for sdhci-cadence

DTS properties are used instead of fixed data
because PHY settings can be different for different chips/boards.
Add description of new DLL PHY delays.

Signed-off-by: Piotr Sroka <piotrs@cadence.com>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-cadence: Fix writing PHY delay
Piotr Sroka [Tue, 21 Mar 2017 14:32:16 +0000 (14:32 +0000)]
mmc: sdhci-cadence: Fix writing PHY delay

Add polling for ACK to be sure that data are written to PHY register.

Signed-off-by: Piotr Sroka <piotrs@cadence.com>
Reviewed-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: bcm2835: Fix possible NULL ptr dereference in bcm2835_request
Stefan Wahren [Sat, 25 Mar 2017 13:17:00 +0000 (13:17 +0000)]
mmc: bcm2835: Fix possible NULL ptr dereference in bcm2835_request

This fixes a NULL pointer dereference in case of a MMC request with a
set block count command and no data.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: use new core function mmc_get_dma_dir
Heiner Kallweit [Sun, 26 Mar 2017 18:45:56 +0000 (20:45 +0200)]
mmc: use new core function mmc_get_dma_dir

Use new core function mmc_get_dma_dir().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: core: add mmc_get_dma_dir
Heiner Kallweit [Sun, 26 Mar 2017 18:41:32 +0000 (20:41 +0200)]
mmc: core: add mmc_get_dma_dir

Add function for determining DMA direction to core.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: meson-gx: add CMD23 mode
Heiner Kallweit [Sat, 25 Mar 2017 10:28:13 +0000 (11:28 +0100)]
mmc: meson-gx: add CMD23 mode

CMD23 mode (use "set block count" command before transferring multiple
data blocks) typically is more performant as host / card know upfront
how many data blocks to expect. Therefore add support for this mode to
the driver.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: meson-gx: switch to dynamic timeout values
Heiner Kallweit [Sat, 25 Mar 2017 10:26:18 +0000 (11:26 +0100)]
mmc: meson-gx: switch to dynamic timeout values

Currently we use a fixed timeout of 4s for all data transfers. Switch
to dynamic timeout values by making use of data->timeout_ns.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: meson-gx: use per port interrupt names
Heiner Kallweit [Sat, 25 Mar 2017 10:24:41 +0000 (11:24 +0100)]
mmc: meson-gx: use per port interrupt names

So far the driver name is used as interrupt description, therefore in
/proc/interrupts it's not possible to tell which interrupt belongs to
which port. Change this by switching to NULL what causes the default
(device name) to be used. In our case that's the DT node name.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: meson-gx: use bitfield macros
Heiner Kallweit [Sat, 25 Mar 2017 10:23:24 +0000 (11:23 +0100)]
mmc: meson-gx: use bitfield macros

Use GENMASK consistently for all bit masks and switch to using the
bitfield macros FIELD_GET and FIELD_PREP. This hides parts of the
complexity of dealing with bit fields.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci: clarify the get_timeout_clock callback
Shawn Lin [Fri, 24 Mar 2017 07:50:12 +0000 (15:50 +0800)]
mmc: sdhci: clarify the get_timeout_clock callback

Currently the get_timeout_clock callback doesn't clearly
have a statement that it needs the variant drivers to return
the timeout clock rate in kHz if the SDHCI_TIMEOUT_CLK_UNIT
isn't present, otherwise the variant drivers should return it
in MHz. It's also very likely that further variant drivers which
are going to use this callback will be confused by this situation.
Given the fact that moderm sdhci variant hosts are very prone to get
the timeout clock from common clock framework (actually the only three
users did that), it's more natural to return the value in Hz and we
make an explicit comment there. Then we put the unit conversion inside
the sdhci core. Thus will improve the code and prevent further misuses.

Reported-by: Anssi Hannula <anssi.hannula@bitwise.fi>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Acked-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: sunxi: change controller error info to debug level
Icenowy Zheng [Thu, 16 Mar 2017 13:29:03 +0000 (21:29 +0800)]
mmc: sunxi: change controller error info to debug level

The controller's errors are usually normal (for example, for MMC or SDIO
cards, some errors are expected to happen; and for boards without a
dedicated card detect pin the error info will even flood console and
hide other normal messages) and hard to understand.

Change their print level to debug, thus it won't be shown to generic
users.

Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: meson-gx: simplify setting timeout configuration parameters
Heiner Kallweit [Wed, 22 Mar 2017 21:34:01 +0000 (22:34 +0100)]
mmc: meson-gx: simplify setting timeout configuration parameters

We don't need variable cmd_cfg_timeout, so remove it and simplify the
code a little.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
7 years agommc: meson-gx: improve setting data->bytes_xfered
Heiner Kallweit [Wed, 22 Mar 2017 21:33:53 +0000 (22:33 +0100)]
mmc: meson-gx: improve setting data->bytes_xfered

Centralize setting data->bytes_xfered in one place and make sure
that the number of transfererd bytes is set only if we receive
the end-of-chain interrupt and there was no error.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
7 years agommc: meson-gx: improve response reading
Heiner Kallweit [Wed, 22 Mar 2017 21:33:50 +0000 (22:33 +0100)]
mmc: meson-gx: improve response reading

Response reading can be slightly improved by doing it in just one place.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
7 years agommc: meson-gx: improve variable usage in meson_mmc_start_cmd
Heiner Kallweit [Wed, 22 Mar 2017 21:33:47 +0000 (22:33 +0100)]
mmc: meson-gx: improve variable usage in meson_mmc_start_cmd

Simplify the code by using two variables instead of a struct sd_emmc_desc.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
7 years agommc: meson-gx: replace cmd->data in meson_mmc_start_cmd
Heiner Kallweit [Wed, 22 Mar 2017 21:33:44 +0000 (22:33 +0100)]
mmc: meson-gx: replace cmd->data in meson_mmc_start_cmd

Replace cmd->data with a local variable to simplify code a little.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
7 years agommc: meson-gx: remove unneeded configuration bit resets
Heiner Kallweit [Wed, 22 Mar 2017 21:18:37 +0000 (22:18 +0100)]
mmc: meson-gx: remove unneeded configuration bit resets

The variables holding the configuration bits are zero-initialized.
So we can remove all bit resets.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
7 years agommc: mediatek: Use data tune for CMD line tune
yong mao [Wed, 15 Mar 2017 07:26:40 +0000 (15:26 +0800)]
mmc: mediatek: Use data tune for CMD line tune

If we don't select a set of better parameters for our emmc host,
It may easily occur CMD response CRC error. And also it may cause
cannot boot up issue.

Fot getting a set of better parameters, our emmc host supports
data tune mechanism.Therefore, our emmc driver also should change
to use data tune for CMD line.

Because our emmc host use the different clock source to sample the
CMD signal between HS200 and HS400 mode, the parameters are also
different between these two modes.
Separate cmd internal delay for HS200/HS400 mode.

This change can fix "System can not boot up" issue.

Signed-off-by: Yong Mao <yong.mao@mediatek.com>
Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: dt-bindings: update Mediatek MMC bindings
yong mao [Wed, 15 Mar 2017 07:26:38 +0000 (15:26 +0800)]
mmc: dt-bindings: update Mediatek MMC bindings

Add description for mediatek,hs200-cmd-int-delay
Add description for mediatek,hs400-cmd-int-delay
Add description for mediatek,hs400-cmd-resp-sel-rising

Signed-off-by: Yong Mao <yong.mao@mediatek.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdio: improve mmc_io_rw_extended
Heiner Kallweit [Wed, 22 Mar 2017 20:59:29 +0000 (21:59 +0100)]
mmc: sdio: improve mmc_io_rw_extended

Improve mmc_io_rw_extended a little:
- using DIV_ROUND_UP achieves the same but is better readable
- simplify code by using sg_set_buf
- simplify one statement by using -= operator

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sh_mmcif: Document r7s72100 DT bindings
Chris Brandt [Wed, 22 Mar 2017 14:42:09 +0000 (10:42 -0400)]
mmc: sh_mmcif: Document r7s72100 DT bindings

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: tmio: always get number of taps
Masaharu Hayakawa [Fri, 17 Mar 2017 09:04:50 +0000 (10:04 +0100)]
mmc: tmio: always get number of taps

Current code gets number of taps only once and keeps the value. This is
not correct, we need to obtain it every time before executing tuning,
so remove the outer if-block.

Signed-off-by: Masaharu Hayakawa <masaharu.hayakawa.ry@renesas.com>
[wsa: extracted from a larger patch and reworded commit message]
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: always unmap DMA before waiting for interrupt
Wolfram Sang [Thu, 16 Mar 2017 10:56:02 +0000 (11:56 +0100)]
mmc: tmio: always unmap DMA before waiting for interrupt

In the (maybe academical) case, we don't get a DATAEND interrupt after
DMA completed, we will wait endlessly for the completion to complete.
This is not bad per se, since we have a more generic completion tracking
a timeout. In that rare case, however, the DMA buffer will not get
unmapped and we have a leak. Reorder the code, so unmapping will always
take place.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-pci: Move a function to avoid later forward declaration
Adrian Hunter [Mon, 20 Mar 2017 17:50:53 +0000 (19:50 +0200)]
mmc: sdhci-pci: Move a function to avoid later forward declaration

Move a function to avoid having to forward declare it in a subsequent
patch.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci-pci: Add runtime suspend/resume callbacks
Adrian Hunter [Mon, 20 Mar 2017 17:50:52 +0000 (19:50 +0200)]
mmc: sdhci-pci: Add runtime suspend/resume callbacks

Add runtime suspend/resume callbacks to match suspend/resume callbacks.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci-pci: Let suspend/resume callbacks replace default callbacks
Adrian Hunter [Mon, 20 Mar 2017 17:50:51 +0000 (19:50 +0200)]
mmc: sdhci-pci: Let suspend/resume callbacks replace default callbacks

The suspend / resume callbacks lack the flexibility to allow a device to
specify a different function entirely. Change them around so that device
functions are called directly and they in turn can call the default
implementations if needed.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci-pci: Conditionally compile pm sleep functions
Adrian Hunter [Mon, 20 Mar 2017 17:50:50 +0000 (19:50 +0200)]
mmc: sdhci-pci: Conditionally compile pm sleep functions

It is confusing to have some parts of suspend / resume under conditional
compilation and some parts not. Use conditional compilation everywhere.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci-pci: Do not use suspend/resume callbacks with runtime pm
Adrian Hunter [Mon, 20 Mar 2017 17:50:49 +0000 (19:50 +0200)]
mmc: sdhci-pci: Do not use suspend/resume callbacks with runtime pm

Do not use suspend/resume callbacks with runtime pm. It doesn't make sense
and isn't being used, so remove.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci-pci: Let devices define how to add the host
Adrian Hunter [Mon, 20 Mar 2017 17:50:48 +0000 (19:50 +0200)]
mmc: sdhci-pci: Let devices define how to add the host

SDHCI provides more flexibility than simply calling sdhci_add_host(). Make
that available by allowing devices to specify their own ->add_host()
function.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci: Add CQE support
Adrian Hunter [Mon, 20 Mar 2017 17:50:47 +0000 (19:50 +0200)]
mmc: sdhci: Add CQE support

Add an interrupt hook and helper functions for enabling, disabling and
delivering interrupts to a CQE.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci: Factor out sdhci_set_default_irqs
Adrian Hunter [Mon, 20 Mar 2017 17:50:46 +0000 (19:50 +0200)]
mmc: sdhci: Factor out sdhci_set_default_irqs

Factor out sdhci_set_default_irqs().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci: Add sdhci_cleanup_host
Adrian Hunter [Mon, 20 Mar 2017 17:50:45 +0000 (19:50 +0200)]
mmc: sdhci: Add sdhci_cleanup_host

Add sdhci_cleanup_host() to cleanup __sdhci_add_host().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci: Get rid of 'extern' in header file
Adrian Hunter [Mon, 20 Mar 2017 17:50:44 +0000 (19:50 +0200)]
mmc: sdhci: Get rid of 'extern' in header file

Get rid of unnecessary 'extern' in header file.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci: Export sdhci_dumpregs
Adrian Hunter [Mon, 20 Mar 2017 17:50:43 +0000 (19:50 +0200)]
mmc: sdhci: Export sdhci_dumpregs

Export sdhci_dumpregs so that it can be called by drivers.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci: Improve register dump print format
Adrian Hunter [Mon, 20 Mar 2017 17:50:42 +0000 (19:50 +0200)]
mmc: sdhci: Improve register dump print format

Ensure all prints start with the mmc host name, and the text all lines up.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci: Use sdhci_readl() not readl() in sdhci_dumpregs()
Adrian Hunter [Mon, 20 Mar 2017 17:50:41 +0000 (19:50 +0200)]
mmc: sdhci: Use sdhci_readl() not readl() in sdhci_dumpregs()

Use sdhci io wrappers consistently.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci: Add response register to register dump
Adrian Hunter [Mon, 20 Mar 2017 17:50:40 +0000 (19:50 +0200)]
mmc: sdhci: Add response register to register dump

Add response register to register dump.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci: Improve debug print format
Adrian Hunter [Mon, 20 Mar 2017 17:50:39 +0000 (19:50 +0200)]
mmc: sdhci: Improve debug print format

Ensure all debug prints start with the mmc host name.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci: Reduce spin lock usage in sdhci_execute_tuning
Adrian Hunter [Mon, 20 Mar 2017 17:50:38 +0000 (19:50 +0200)]
mmc: sdhci: Reduce spin lock usage in sdhci_execute_tuning

Tuning execution is already synchronized with respect to other host
operations by upper layers "claiming" the host, which also takes care of
runtime pm. There can be no requests in progress. Retain the spin lock
usage only for ensuring that sending tuning commands is synchronized with
respect to the interrupt handler.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci: Do not use spin lock in set_ios paths
Adrian Hunter [Mon, 20 Mar 2017 17:50:37 +0000 (19:50 +0200)]
mmc: sdhci: Do not use spin lock in set_ios paths

The spin lock is not necessary in set_ios. Anything that is racing with
changes to the I/O state is already broken. The mmc core already provides
synchronization via "claiming" the host. So remove spin_lock and friends
from sdhci_set_ios and related callbacks.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci: Remove ->select_drive_strength() callback
Adrian Hunter [Mon, 20 Mar 2017 17:50:36 +0000 (19:50 +0200)]
mmc: sdhci: Remove ->select_drive_strength() callback

Drivers can use the host operation directly, so remove this now unused
callback.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci-pci: Use ACPI DSM to get driver strength for some Intel devices
Adrian Hunter [Mon, 20 Mar 2017 17:50:35 +0000 (19:50 +0200)]
mmc: sdhci-pci: Use ACPI DSM to get driver strength for some Intel devices

Make use  of an Intel ACPI _DSM that provides eMMC driver strength.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci-pci: Don't re-tune with runtime pm for some Intel devices
Adrian Hunter [Mon, 20 Mar 2017 17:50:34 +0000 (19:50 +0200)]
mmc: sdhci-pci: Don't re-tune with runtime pm for some Intel devices

Make use  of an Intel ACPI _DSM that indicates if re-tuning is needed after
D3.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci-pci: Let devices define their own private data
Adrian Hunter [Mon, 20 Mar 2017 17:50:33 +0000 (19:50 +0200)]
mmc: sdhci-pci: Let devices define their own private data

Let devices define their own private data to facilitate device-specific
operations. The size of the private structure is specified in the
sdhci_pci_fixes structure, then sdhci_pci_probe_slot() will allocate extra
space for it, and sdhci_pci_priv() can be used to get a reference to it.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm
Adrian Hunter [Mon, 20 Mar 2017 17:50:32 +0000 (19:50 +0200)]
mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm

Devices might save and restore tuning values so that re-tuning might not be
needed after a pm transition.  Let drivers decide by pushing the
mmc_retune_needed() logic down to them.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: sdhci: Optimize delay loops
Adrian Hunter [Mon, 20 Mar 2017 17:50:31 +0000 (19:50 +0200)]
mmc: sdhci: Optimize delay loops

The delay loops for reset and clock enable always take at least 1 ms
because they use mdelay(1). However they can take a lot less time e.g. less
than 50us. Use ktime and reduce the delay to 10 microseconds per loop.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
7 years agommc: bcm2835: Add new driver for the sdhost controller.
Eric Anholt [Wed, 8 Mar 2017 09:19:03 +0000 (10:19 +0100)]
mmc: bcm2835: Add new driver for the sdhost controller.

The 2835 has two SD controllers: The Arasan sdhci controller (supported
by the iproc driver) and a custom sdhost controller.  This patch adds a
driver for the latter.

The sdhci controller supports both sdcard and sdio.  The sdhost
controller supports the sdcard only, but has better performance.  Also
note that the rpi3 has sdio wifi, so driving the sdcard with the sdhost
controller allows to use the sdhci controller for wifi support.

The configuration is done by devicetree via pin muxing.  Both SD
controller are available on the same pins (2 pin groups = pin 22 to 27 +
pin 48 to 53).  So it's possible to use both SD controllers at the same
time with different pin groups.

The code was originally written by Phil Elwell in the downstream
Rasbperry Pi tree.   In preparation for the upstream merge it was
cleaned up and the code base was moderized by Eric Anholt, Stefan
Wahren and Gerd Hoffmann.

Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agodt-bindings: Add binding for brcm,bcm2835-sdhost.
Eric Anholt [Wed, 8 Mar 2017 09:19:01 +0000 (10:19 +0100)]
dt-bindings: Add binding for brcm,bcm2835-sdhost.

This is the other SD controller on the platform, which can be swapped
to the role of SD card host using pin muxing.

Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: core: simplify return code
tcharding [Wed, 15 Mar 2017 08:48:04 +0000 (19:48 +1100)]
mmc: core: simplify return code

File contains multiple functions doing variations on the same thing,
sdio_readb(), sdio_writeb()f, sdio_readw(), sdio_writew()
etc. Although the functions have very similar logic the code is laid
out in a variety of ways. This makes it overly complicated to
read. There is a already a nice clean chunk of code, if we use this
format for all instances then we will have cleaned up the code,
reduced the line count and lessened the cognitive load required while
reading. Less lines equals less bugs.

Pick the most simple and clear code flow and change all functions to
be the same.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: core: guard dereference of optional parameter
tcharding [Wed, 15 Mar 2017 08:48:03 +0000 (19:48 +1100)]
mmc: core: guard dereference of optional parameter

Various functions take as parameter an optional pointer. Pointer
should be guarded with non-NULL check before dereferencing.

Add non-NULL check before dereference of pointer.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: meson-gx: fix error path when driver initialization fails before enabling clocks
Michał Zegan [Tue, 14 Mar 2017 20:05:20 +0000 (21:05 +0100)]
mmc: meson-gx: fix error path when driver initialization fails before enabling clocks

This patch fixes the case where meson_mmc_probe function fails before
core_clk is enabled.
Originally, that would result in a try to disable the core clock, and if
it was not already enabled, it would result in a kernel warning.
This issue is similar to the one with div_clk.
Fix it by introducing another error path used only between successfully
enabling the core clock, and successfully enabling the div clock.
That would ensure that core clock is disabled only if it was enabled before.

Signed-off-by: Michał Zegan <webczat@webczatnet.pl>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agodt-bindings: mmc: tegra: Document Tegra186 compatible string
Thierry Reding [Tue, 14 Mar 2017 19:01:52 +0000 (20:01 +0100)]
dt-bindings: mmc: tegra: Document Tegra186 compatible string

The SDHCI controller found on Tegra186 in very similar to the controller
found on earlier generations of Tegra.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agodt-bindings: mmc: tegra: Reformat compatible string list
Thierry Reding [Tue, 14 Mar 2017 19:01:51 +0000 (20:01 +0100)]
dt-bindings: mmc: tegra: Reformat compatible string list

The list of compatible strings is somewhat difficult to read and extend.
Reformat it into a list to make it more easily extensible.

While at it, also remove the "plus one of the above" clause because it
isn't actually valid.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-st: remove unnecessary platform_set_drvdata() call
Jisheng Zhang [Fri, 10 Mar 2017 03:17:33 +0000 (11:17 +0800)]
mmc: sdhci-st: remove unnecessary platform_set_drvdata() call

sdhci_pltfm_init() has already set the platform drvdata for us, remove
the unnecessary platform_set_drvdata() call.

Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
Acked-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-pxav2: remove unnecessary platform_set_drvdata() call
Jisheng Zhang [Fri, 10 Mar 2017 03:17:32 +0000 (11:17 +0800)]
mmc: sdhci-pxav2: remove unnecessary platform_set_drvdata() call

sdhci_pltfm_init() has already set the platform drvdata for us, remove
the unnecessary platform_set_drvdata() call.

Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-pxav3: remove unnecessary platform_set_drvdata() call
Jisheng Zhang [Fri, 10 Mar 2017 03:17:31 +0000 (11:17 +0800)]
mmc: sdhci-pxav3: remove unnecessary platform_set_drvdata() call

sdhci_pltfm_init() has already set the platform drvdata for us, remove
the unnecessary platform_set_drvdata() call.

Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
7 years agommc: sdhci-cadence: add HS400 enhanced strobe support
Piotr Sroka [Mon, 6 Mar 2017 08:28:41 +0000 (08:28 +0000)]
mmc: sdhci-cadence: add HS400 enhanced strobe support

Add support for HS400ES mode to Cadence SDHCI driver.

Signed-off-by: Piotr Sroka <piotrs@cadence.com>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>