OSDN Git Service

uclinux-h8/linux.git
6 years agommc: tmio: hide unused tmio_mmc_clk_disable/tmio_mmc_clk_enable functions
Arnd Bergmann [Fri, 19 Jan 2018 14:54:44 +0000 (15:54 +0100)]
mmc: tmio: hide unused tmio_mmc_clk_disable/tmio_mmc_clk_enable functions

When CONFIG_PM is disabled, we get a warning about the clock handling
being unused:

drivers/mmc/host/tmio_mmc_core.c:937:13: error: 'tmio_mmc_clk_disable' defined but not used [-Werror=unused-function]
 static void tmio_mmc_clk_disable(struct tmio_mmc_host *host)
             ^~~~~~~~~~~~~~~~~~~~
drivers/mmc/host/tmio_mmc_core.c:929:12: error: 'tmio_mmc_clk_enable' defined but not used [-Werror=unused-function]
 static int tmio_mmc_clk_enable(struct tmio_mmc_host *host)
            ^~~~~~~~~~~~~~~~~~~

As the clock handling is now done elsewhere, this is only used when
power management is enabled. We could make the functions as __maybe_unused,
but since there is already an #ifdef section, it seems easier to move
the helpers closer to their callers.

Fixes: b21fc294387e ("mmc: tmio: move clk_enable/disable out of tmio_mmc_host_probe()")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: mmci: Add STM32 variant
Patrice Chotard [Thu, 18 Jan 2018 14:34:21 +0000 (15:34 +0100)]
mmc: mmci: Add STM32 variant

STM32F4 and STM32F7 MCUs has a SDIO controller that looks like
an ARM PL810.
This patch adds the STM32 variant so that mmci driver supports it.

Signed-off-by: Andrea Merello <andrea.merello@gmail.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: mmci: Add support for setting pad type via pinctrl
Patrice Chotard [Thu, 18 Jan 2018 14:34:20 +0000 (15:34 +0100)]
mmc: mmci: Add support for setting pad type via pinctrl

If variant hasn't the control bit to switch pads in opendrain mode,
we can achieve the same result by asking to the pinmux driver to
configure pins for us.

This patch make the mmci driver able to do this whenever needed.

Signed-off-by: Andrea Merello <andrea.merello@gmail.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: mmci: Don't pretend all variants to have OPENDRAIN bit
Patrice Chotard [Thu, 18 Jan 2018 14:34:19 +0000 (15:34 +0100)]
mmc: mmci: Don't pretend all variants to have OPENDRAIN bit

This patch prepares for supporting STM32 variant which doesn't
have opendrain bit in MMCIPOWER register.
ST others variant (u300, nomadik and ux500) uses MCI_OD bit whereas
others variants uses MCI_ROD bit.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: mmci: Don't pretend all variants to have MCI_STARBITERR flag
Patrice Chotard [Thu, 18 Jan 2018 14:34:18 +0000 (15:34 +0100)]
mmc: mmci: Don't pretend all variants to have MCI_STARBITERR flag

This patch prepares for supporting the STM32 variant that
has no such bit in the status register.

Signed-off-by: Andrea Merello <andrea.merello@gmail.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: mmci: Don't pretend all variants to have MMCIMASK1 register
Patrice Chotard [Thu, 18 Jan 2018 14:34:17 +0000 (15:34 +0100)]
mmc: mmci: Don't pretend all variants to have MMCIMASK1 register

Two mask registers are used in order to select which events have to
actually generate an interrupt on each IRQ line.

It seems that in the single-IRQ case it's assumed that the IRQs lines
are simply OR-ed, while the two mask registers are still present. The
driver still programs the two mask registers separately.

However the STM32 variant has only one IRQ, and also has only one mask
register.

This patch prepares for STM32 variant support by making the driver using
only one mask register.

This patch also optimize the MMCIMASK1 mask usage by caching it into
host->mask1_reg which avoid to read it into mmci_irq().

Tested only on STM32 variant. RFT for variants other than STM32

Signed-off-by: Andrea Merello <andrea.merello@gmail.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: tmio: refactor .get_ro hook
Masahiro Yamada [Wed, 17 Jan 2018 16:28:06 +0000 (01:28 +0900)]
mmc: tmio: refactor .get_ro hook

This IP provides the write protect signal level in the status
register, but it is also possible to use GPIO for WP.  They are
exclusive, so it is not efficient to call mmc_gpio_get_ro() every
time from tmio_mmc_get_ro() if we know gpio_ro is not used.

Check the capability of gpio_ro just once in the probe function,
then set mmc_gpio_get_ro to .get_ro if it is the case.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: slot-gpio: add a helper to check capability of GPIO WP detection
Masahiro Yamada [Wed, 17 Jan 2018 16:28:05 +0000 (01:28 +0900)]
mmc: slot-gpio: add a helper to check capability of GPIO WP detection

Like mmc_can_gpio_cd(), mmc_can_gpio_ro() will also be useful for host
drivers to know whether GPIO write-protect detection is supported.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: tmio: remove dma_ops from tmio_mmc_host_probe() argument
Masahiro Yamada [Wed, 17 Jan 2018 16:28:04 +0000 (01:28 +0900)]
mmc: tmio: remove dma_ops from tmio_mmc_host_probe() argument

Drivers need to set up various struct members for tmio_mmc_host before
calling tmio_mmc_host_probe().  Do likewise for host->dma_ops instead
of passing it as a function argument.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: tmio: move {tmio_}mmc_of_parse() to tmio_mmc_host_alloc()
Masahiro Yamada [Wed, 17 Jan 2018 16:28:03 +0000 (01:28 +0900)]
mmc: tmio: move {tmio_}mmc_of_parse() to tmio_mmc_host_alloc()

mmc_of_parse() parses various DT properties and sets capability flags
accordingly.  However, drivers have no chance to run platform init
code depending on such flags because mmc_of_parse() is called from
tmio_mmc_host_probe().

Move mmc_of_parse() to tmio_mmc_host_alloc() so that drivers can
handle capabilities before mmc_add_host().  Move tmio_mmc_of_parse()
likewise.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: tmio: move clk_enable/disable out of tmio_mmc_host_probe()
Masahiro Yamada [Wed, 17 Jan 2018 16:28:02 +0000 (01:28 +0900)]
mmc: tmio: move clk_enable/disable out of tmio_mmc_host_probe()

The clock is enabled in the tmio_mmc_host_probe().  It also prevents
drivers from performing platform-specific settings before mmc_add_host()
because the register access generally requires a clock.

Enable/disable the clock in drivers' probe/remove.  Also, I passed
tmio_mmc_data to tmio_mmc_host_alloc() because renesas_sdhi_clk_enable()
needs it to get the private data from tmio_mmc_host.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: tmio: ioremap memory resource in tmio_mmc_host_alloc()
Masahiro Yamada [Wed, 17 Jan 2018 16:28:01 +0000 (01:28 +0900)]
mmc: tmio: ioremap memory resource in tmio_mmc_host_alloc()

The register region is ioremap'ed in the tmio_mmc_host_probe(), i.e.
drivers cannot get access to the hardware before mmc_add_host().

Actually, renesas_sdhi_core.c reads out the CTL_VERSION register to
complete the platform-specific settings.  However, at this point,
the MMC host is already running.

Move the register ioremap to tmio_mmc_host_alloc() so that drivers
can perform platform-specific settings between tmio_mmc_host_alloc()
and tmio_mmc_host_probe().

I changed tmio_mmc_host_alloc() to return an error pointer to
propagate the return code from devm_ioremap_resource().

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sh_mmcif: remove redundant initialization of 'opc'
Colin Ian King [Wed, 17 Jan 2018 13:41:57 +0000 (13:41 +0000)]
mmc: sh_mmcif: remove redundant initialization of 'opc'

Variable opc is initialized with a value that is never read, opc
is later re-assigned a newer value, hence the initialization can
be removed.

Cleans up clang warning:
drivers/mmc/host/sh_mmcif.c:919:6: warning: Value stored to 'opc'
during its initialization is never read

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sdhci: Rework sdhci_enable_irq_wakeups()
Adrian Hunter [Tue, 9 Jan 2018 07:52:22 +0000 (09:52 +0200)]
mmc: sdhci: Rework sdhci_enable_irq_wakeups()

In preparation for adding more conditions for whether IRQ wakeup is
enabled, rework sdhci_enable_irq_wakeups() so that needed bits are added
instead of adding them all and then removing the unneeded bits.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sdhci: Handle failure of enable_irq_wake()
Adrian Hunter [Tue, 9 Jan 2018 07:52:21 +0000 (09:52 +0200)]
mmc: sdhci: Handle failure of enable_irq_wake()

Now that sdhci_enable_irq_wakeups() is a local function, change it to
return whether the IRQ wakeup was successfully enabled. This is in
preparation for adding more conditions for whether IRQ wakeup is enabled.

Note it is assumed, for SDHCI devices, that suspend is more important than
wakeup, so we continue to suspend regardless.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sdhci: Stop exporting sdhci_enable_irq_wakeups()
Adrian Hunter [Tue, 9 Jan 2018 07:52:20 +0000 (09:52 +0200)]
mmc: sdhci: Stop exporting sdhci_enable_irq_wakeups()

Now that it is not being used by any drivers, stop exporting it.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sdhci-pci: Use device wakeup capability to determine MMC_PM_WAKE_SDIO_IRQ capability
Adrian Hunter [Tue, 9 Jan 2018 07:52:19 +0000 (09:52 +0200)]
mmc: sdhci-pci: Use device wakeup capability to determine MMC_PM_WAKE_SDIO_IRQ capability

PCI and ACPI determine if a device is wakeup capable, so use that to
determine the MMC_PM_WAKE_SDIO_IRQ capability correctly.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sdhci-pci: Stop calling sdhci_enable_irq_wakeups()
Adrian Hunter [Tue, 9 Jan 2018 07:52:18 +0000 (09:52 +0200)]
mmc: sdhci-pci: Stop calling sdhci_enable_irq_wakeups()

sdhci_enable_irq_wakeups() is already called by sdhci_suspend_host() so
sdhci-pci should not need to call it. However sdhci_suspend_host() only
calls it if wakeups are enabled, and sdhci-pci does not enable them until
after calling sdhci_suspend_host(). So move the calls to
sdhci_pci_init_wakeup() before calling sdhci_suspend_host(), and
stop calling sdhci_enable_irq_wakeups(). That results in some
simplification because sdhci_pci_suspend_host() and
__sdhci_pci_suspend_host() no longer need to be separate functions.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sdhci-of-arasan: Add CQHCI support for arasan,sdhci-5.1
Shawn Lin [Tue, 16 Jan 2018 03:43:51 +0000 (11:43 +0800)]
mmc: sdhci-of-arasan: Add CQHCI support for arasan,sdhci-5.1

Add CQHCI initialization and implement CQHCI operations for Arasan
SDHCI variant host, namely arasan,sdhci-5.1, which is used by Rockchip
RK3399 platform.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agoMerge branch 'fixes' into next
Ulf Hansson [Mon, 15 Jan 2018 12:53:10 +0000 (13:53 +0100)]
Merge branch 'fixes' into next

6 years agommc: sdhci-esdhc-imx: Fix i.MX53 eSDHCv3 clock
Benoît Thébaudeau [Sun, 14 Jan 2018 18:43:05 +0000 (19:43 +0100)]
mmc: sdhci-esdhc-imx: Fix i.MX53 eSDHCv3 clock

Commit 5143c953a786 ("mmc: sdhci-esdhc-imx: Allow all supported
prescaler values") made it possible to set SYSCTL.SDCLKFS to 0 in SDR
mode, thus bypassing the SD clock frequency prescaler, in order to be
able to get higher SD clock frequencies in some contexts. However, that
commit missed the fact that this value is illegal on the eSDHCv3
instance of the i.MX53. This seems to be the only exception on i.MX,
this value being legal even for the eSDHCv2 instances of the i.MX53.

Fix this issue by changing the minimum prescaler value if the i.MX53
eSDHCv3 is detected. According to the i.MX53 reference manual, if
DLLCTRL[10] can be set, then the controller is eSDHCv3, else it is
eSDHCv2.

This commit fixes the following issue, which was preventing the i.MX53
Loco (IMX53QSB) board from booting Linux 4.15.0-rc5:
[    1.882668] mmcblk1: error -84 transferring data, sector 2048, nr 8, cmd response 0x900, card status 0xc00
[    2.002255] mmcblk1: error -84 transferring data, sector 2050, nr 6, cmd response 0x900, card status 0xc00
[   12.645056] mmc1: Timeout waiting for hardware interrupt.
[   12.650473] mmc1: sdhci: ============ SDHCI REGISTER DUMP ===========
[   12.656921] mmc1: sdhci: Sys addr:  0x00000000 | Version:  0x00001201
[   12.663366] mmc1: sdhci: Blk size:  0x00000004 | Blk cnt:  0x00000000
[   12.669813] mmc1: sdhci: Argument:  0x00000000 | Trn mode: 0x00000013
[   12.676258] mmc1: sdhci: Present:   0x01f8028f | Host ctl: 0x00000013
[   12.682703] mmc1: sdhci: Power:     0x00000002 | Blk gap:  0x00000000
[   12.689148] mmc1: sdhci: Wake-up:   0x00000000 | Clock:    0x0000003f
[   12.695594] mmc1: sdhci: Timeout:   0x0000008e | Int stat: 0x00000000
[   12.702039] mmc1: sdhci: Int enab:  0x107f004b | Sig enab: 0x107f004b
[   12.708485] mmc1: sdhci: AC12 err:  0x00000000 | Slot int: 0x00001201
[   12.714930] mmc1: sdhci: Caps:      0x07eb0000 | Caps_1:   0x08100810
[   12.721375] mmc1: sdhci: Cmd:       0x0000163a | Max curr: 0x00000000
[   12.727821] mmc1: sdhci: Resp[0]:   0x00000920 | Resp[1]:  0x00000000
[   12.734265] mmc1: sdhci: Resp[2]:   0x00000000 | Resp[3]:  0x00000000
[   12.740709] mmc1: sdhci: Host ctl2: 0x00000000
[   12.745157] mmc1: sdhci: ADMA Err:  0x00000001 | ADMA Ptr: 0xc8049200
[   12.751601] mmc1: sdhci: ============================================
[   12.758110] print_req_error: I/O error, dev mmcblk1, sector 2050
[   12.764135] Buffer I/O error on dev mmcblk1p1, logical block 0, lost sync page write
[   12.775163] EXT4-fs (mmcblk1p1): mounted filesystem without journal. Opts: (null)
[   12.782746] VFS: Mounted root (ext4 filesystem) on device 179:9.
[   12.789151] mmcblk1: response CRC error sending SET_BLOCK_COUNT command, card status 0x900

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
Reported-by: Wladimir J. van der Laan <laanwj@gmail.com>
Tested-by: Wladimir J. van der Laan <laanwj@gmail.com>
Fixes: 5143c953a786 ("mmc: sdhci-esdhc-imx: Allow all supported prescaler values")
Cc: <stable@vger.kernel.org> # v4.13+
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: tmio: use mmc_can_gpio_cd() instead of checking TMIO_MMC_USE_GPIO_CD
Masahiro Yamada [Fri, 24 Nov 2017 16:24:44 +0000 (01:24 +0900)]
mmc: tmio: use mmc_can_gpio_cd() instead of checking TMIO_MMC_USE_GPIO_CD

To use a GPIO line for card detection, TMIO_MMC_USE_GPIO_CD is set
by a legacy board (arch/sh/boards/mach-ecovec24).

For DT platforms, the "cd-gpios" property is a legitimate way for that
in case the IP-builtin card detection can not be used for some reason.
mmc_of_parse() calls mmc_gpiod_request_cd() to set up ctx->cd_gpio if
the "cd-gpios" property is specified.

To cater to both cases, mmc_can_gpio_cd() is a correct way to check
which card detection logic is used.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agosdhci: Advertise 2.0v supply on SDIO host controller
Andy Shevchenko [Thu, 11 Jan 2018 13:51:58 +0000 (15:51 +0200)]
sdhci: Advertise 2.0v supply on SDIO host controller

On Intel Edison the Broadcom Wi-Fi card, which is connected to SDIO,
requires 2.0v, while the host, according to Intel Merrifield TRM,
supports 1.8v supply only.

The card announces itself as

  mmc2: new ultra high speed DDR50 SDIO card at address 0001

Introduce a custom OCR mask for SDIO host controller on Intel Merrifield
and add a special case to sdhci_set_power_noreg() to override 2.0v supply
by enforcing 1.8v power choice.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: tmio, renesas_sdhi: Remove unneeded NULL check
Dan Carpenter [Tue, 9 Jan 2018 09:39:10 +0000 (12:39 +0300)]
mmc: tmio, renesas_sdhi: Remove unneeded NULL check

The inconsistent NULL checking in this function causes static checker
warnings.

    drivers/mmc/host/renesas_sdhi_sys_dmac.c:360 renesas_sdhi_sys_dmac_issue_tasklet_fn()
    error: we previously assumed 'host' could be null (see line 351)

On reviewing this code, "host" can't ever be NULL so we can just remove
the check.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sdhci_f_sdh30: add ACPI support
Ard Biesheuvel [Mon, 8 Jan 2018 15:44:19 +0000 (15:44 +0000)]
mmc: sdhci_f_sdh30: add ACPI support

The Fujitsu SDH30 SDHCI controller may be described as a SCX0002 ACPI
device on ACPI platforms incorporating the Socionext SynQuacer SoC.

Given that mmc_of_parse() has already been made ACPI/DT agnostic,
making the SDH30 driver ACPI capable is actually rather simple:
all we need to do is make the call to sdhci_get_of_property() [which
does not set any properties we care about] and the clock handling
dependent on whether we are dealing with a DT device, and exposing
the ACPI id via the platform_driver struct and the module metadata.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sdhci-esdhc-imx: Enable/Disable mmc clock during runtime suspend
Michael Trimarchi [Thu, 4 Jan 2018 15:30:59 +0000 (16:30 +0100)]
mmc: sdhci-esdhc-imx: Enable/Disable mmc clock during runtime suspend

mmc clock can be stopped during runtime suspend and restart during runtime
resume if the sdio irq is not enabled. Stop sdio clock reduce EMI of
the device when the bus is not in use.

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sdhci-esdhc-imx: Changes the order of how clocks are being re-enabled
Michael Trimarchi [Thu, 4 Jan 2018 15:30:58 +0000 (16:30 +0100)]
mmc: sdhci-esdhc-imx: Changes the order of how clocks are being re-enabled

runtime_resume() should re-enable the clocks in reverse order comparing with
runtime_suspend()

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sdhci-esdhc-imx: Manage sdhci_runtime_suspend_host error code
Michael Trimarchi [Thu, 4 Jan 2018 15:30:57 +0000 (16:30 +0100)]
mmc: sdhci-esdhc-imx: Manage sdhci_runtime_suspend_host error code

We need to return in case of error even if the actual implementation
of sdhci_runtime_suspend_host always return 0. We don't want to
power down the clock and the assuption is that the sdhci_runtime_suspend_host
always let the system consistent in case of failure

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc:host:sdhci-pci:Addition of Arasan PCI Controller with integrated phy.
Atul Garg [Thu, 4 Jan 2018 04:17:36 +0000 (20:17 -0800)]
mmc:host:sdhci-pci:Addition of Arasan PCI Controller with integrated phy.

The Arasan Controller is based on a FPGA platform and has integrated phy
with specific registers used during initialization and
management of different modes. The phy and the controller are integrated
and registers are very specific to Arasan.

Arasan being an IP provider, licenses these IPs to various companies for
integration of IP in custom SOCs. The custom SOCs define own register
map depending on how bits are tied inside the SOC for phy registers,
depending on SOC memory plan and hence will require own platform drivers.

If more details on phy registers are required, an interface document is
hosted at https://arasan.com/NF/eMMC5.1 PHY Programming in Linux.pdf.

Signed-off-by: Atul Garg <agarg@arasan.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agoMerge branch 'fixes' into next
Ulf Hansson [Thu, 4 Jan 2018 11:44:21 +0000 (12:44 +0100)]
Merge branch 'fixes' into next

6 years agommc: s3mci: mark debug_regs[] as static
Arnd Bergmann [Wed, 3 Jan 2018 22:49:18 +0000 (23:49 +0100)]
mmc: s3mci: mark debug_regs[] as static

The global array clashes with a newly added symbol of the same name:

drivers/staging/ccree/cc_debugfs.o:(.data+0x0): multiple definition of `debug_regs'
drivers/mmc/host/s3cmci.o:(.data+0x70): first defined here

We should fix both, this one addresses the s3cmci driver by removing
the symbol from the global namespace. While at it, this separates
the declaration from the type definition and makes the variable const.

Fixes: 9bdd203b4dc8 ("s3cmci: add debugfs support for examining driver and hardware state")
Fixes: b3ec9a6736f2 ("staging: ccree: staging: ccree: replace sysfs by debugfs interface")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: tmio: use io* accessors consistently
Wolfram Sang [Tue, 19 Dec 2017 13:34:03 +0000 (14:34 +0100)]
mmc: tmio: use io* accessors consistently

Because we started using io*_rep accessors previously because they are
more widely defined across architectures, let's be consistent and use
this family for all accessor wrappers.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sdhci-xenon: wait 5ms after set 1.8V signal enable
Zhoujie Wu [Mon, 18 Dec 2017 22:38:47 +0000 (14:38 -0800)]
mmc: sdhci-xenon: wait 5ms after set 1.8V signal enable

According to SD spec 3.00 3.6.1 signal voltage switch
procedure step 6~8,
(6) Set 1.8V Signal Enable in the Host Control 2 register.
(7) Wait 5ms. 1.8V voltage regulator shall be stable within this period.
(8) If 1.8V Signal Enable is cleared by Host Controller, go to step (12).
Host should wait 5ms after set 1.8V signal enable bit in
Host Control 2 register and check if 1.8V is stable or not.

But current code checks this bit right after set it.
On some platforms with xenon controller found the bit is
cleared right away and host reports "1.8V regulator output
did not became stable" and 5ms delay can help.

Implement voltage_switch callback for xenon controller to add 5ms
delay to make sure the 1.8V signal enable bit is set by controller.

Signed-off-by: Zhoujie Wu <zjwu@marvell.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: tmio: change bus_shift to unsigned int
Masahiro Yamada [Fri, 24 Nov 2017 16:24:50 +0000 (01:24 +0900)]
mmc: tmio: change bus_shift to unsigned int

Sane values for bus_shift are:
   0 - for 16 bit bus
   1 - for 32 bit bus
   2 - for 64 bit bus

"unsigned long" is too much.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: tmio,renesas_sdhi: move ssc_tappos to renesas_sdhi.h
Masahiro Yamada [Fri, 24 Nov 2017 16:24:49 +0000 (01:24 +0900)]
mmc: tmio,renesas_sdhi: move ssc_tappos to renesas_sdhi.h

struct tmio_mmc_host has "scc_tappos", but in fact, it is Renesas
private data.  Move it to renesas_sdhi.h

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: tmio, renesas_sdhi: move Renesas-specific DMA data to renesas_sdhi.h
Masahiro Yamada [Fri, 24 Nov 2017 16:24:48 +0000 (01:24 +0900)]
mmc: tmio, renesas_sdhi: move Renesas-specific DMA data to renesas_sdhi.h

struct tmio_mmc_host has "dma_dataend" and "dma_complete", but in fact,
they are Renesas private data.  Move them to renesas_sdhi.h

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: tmio, renesas_sdhi: move struct tmio_mmc_dma to renesas_sdhi.h
Masahiro Yamada [Fri, 24 Nov 2017 16:24:47 +0000 (01:24 +0900)]
mmc: tmio, renesas_sdhi: move struct tmio_mmc_dma to renesas_sdhi.h

struct tmio_mmc_dma looks like TMIO core data, but in fact, Renesas
private data.  Move it to renesas_sdhi.h (probably, it is better to
rename it to renesas_sdhi_dma, or squash it into struct renesas_sdhi).

I also moved struct renesas_sdhi and host_to_priv() to that header
because they are necessary to convert the tmio_mmc_host pointer into
the renesas_sdhi pointer.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: renesas_sdhi: remove always false condition
Masahiro Yamada [Fri, 24 Nov 2017 16:24:46 +0000 (01:24 +0900)]
mmc: renesas_sdhi: remove always false condition

renesas_sdhi_probe() always sets host->dma as follows:

        host->dma               = dma_priv;

!host->dma is always false.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: block: fix logical error to avoid memory leak
Liu, Changcheng [Sat, 16 Dec 2017 15:15:45 +0000 (23:15 +0800)]
mmc: block: fix logical error to avoid memory leak

If the MMC_DRV_OP_GET_EXT_CSD request completes successfully, then
ext_csd must be freed, but in one case it was not. Fix that.

Signed-off-by: Liu Changcheng <changcheng.liu@intel.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agoMerge branch 'fixes' into next
Ulf Hansson [Mon, 18 Dec 2017 12:57:04 +0000 (13:57 +0100)]
Merge branch 'fixes' into next

6 years agommc: avoid removing non-removable hosts during suspend
Daniel Drake [Tue, 12 Dec 2017 10:49:02 +0000 (10:49 +0000)]
mmc: avoid removing non-removable hosts during suspend

The Weibu F3C MiniPC has an onboard AP6255 module, presenting
two SDIO functions on a single MMC host (Bluetooth/btsdio and
WiFi/brcmfmac), and the mmc layer correctly detects this as
non-removable.

After suspend/resume, the wifi and bluetooth interfaces disappear
and do not get probed again.

The conditions here are:

 1. During suspend, we reach mmc_pm_notify()

 2. mmc_pm_notify() calls mmc_sdio_pre_suspend() to see if we can
    suspend the SDIO host. However, mmc_sdio_pre_suspend() returns
    -ENOSYS because btsdio_driver does not have a suspend method.

 3. mmc_pm_notify() proceeds to remove the card

 4. Upon resume, mmc_rescan() does nothing with this host, because of
    the rescan_entered check which aims to only scan a non-removable
    device a single time (i.e. during boot).

Fix the loss of functionality by detecting that we are unable to
suspend a non-removable host, so avoid the forced removal in that
case. The comment above this function already indicates that this
code was only intended for removable devices.

Signed-off-by: Daniel Drake <drake@endlessm.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: android-goldfish: remove duplicate includes
Pravin Shedge [Wed, 6 Dec 2017 16:57:03 +0000 (22:27 +0530)]
mmc: android-goldfish: remove duplicate includes

These duplicate includes have been found with scripts/checkincludes.pl but
they have been removed manually to avoid removing false positives.

Signed-off-by: Pravin Shedge <pravin.shedge4linux@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: tmio: move mmc_gpio_request_cd() before mmc_add_host()
Masahiro Yamada [Fri, 24 Nov 2017 16:24:43 +0000 (01:24 +0900)]
mmc: tmio: move mmc_gpio_request_cd() before mmc_add_host()

Drivers do not need to call mmc_gpiod_request_cd_irq() explicitly
because mmc_start_host() calls it.  To make it work, cd_gpio must
be set before mmc_add_host().

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: tmio, renesas_sdhi: set mmc_host_ops hooks directly
Masahiro Yamada [Fri, 24 Nov 2017 16:24:42 +0000 (01:24 +0900)]
mmc: tmio, renesas_sdhi: set mmc_host_ops hooks directly

Drivers can set any mmc_host_ops hooks between tmio_mmc_host_alloc()
and tmio_mmc_host_probe().  Remove duplicated hooks in tmio_mmc_host.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-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>
6 years agommc: tmio: move mmc_host_ops to struct tmio_mmc_host from static data
Masahiro Yamada [Fri, 24 Nov 2017 16:24:41 +0000 (01:24 +0900)]
mmc: tmio: move mmc_host_ops to struct tmio_mmc_host from static data

Currently, tmio_mmc_ops is static data and tmio_mmc_host_probe()
updates some hooks in the static data.  This is a problem when
two or more instances call tmio_mmc_host_probe() and each of them
requests to use its own card_busy/start_signal_voltage_switch.

We can borrow a solution from sdhci_alloc_host().  Copy the whole
ops structure to host->mmc_host_ops, then override the hooks in
malloc'ed data.  Constify tmio_mmc_ops since it is now a template
ops used by default.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-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>
6 years agommc: tmio: use devm_ioremap_resource() instead of devm_ioremap()
Masahiro Yamada [Fri, 24 Nov 2017 16:24:40 +0000 (01:24 +0900)]
mmc: tmio: use devm_ioremap_resource() instead of devm_ioremap()

The TMIO core misses to call request_mem_region().
devm_ioremap_resource() takes care of it and makes the code cleaner.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-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>
6 years agommc: tmio: set tmio_mmc_host to driver data
Masahiro Yamada [Fri, 24 Nov 2017 16:24:39 +0000 (01:24 +0900)]
mmc: tmio: set tmio_mmc_host to driver data

The remove, suspend, resume hooks need to get tmio_mmc_host.  It is
tedious to call mmc_priv() to convert mmc_host to tmio_mmc_host.
We can directly set tmio_mmc_host to driver data.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: renesas_sdhi: remove eprobe jump label
Masahiro Yamada [Fri, 24 Nov 2017 16:24:38 +0000 (01:24 +0900)]
mmc: renesas_sdhi: remove eprobe jump label

"goto eprobe" does nothing.  Return directly.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: renesas_sdhi: remove wrong depends on to enable compile test
Masahiro Yamada [Fri, 24 Nov 2017 16:24:37 +0000 (01:24 +0900)]
mmc: renesas_sdhi: remove wrong depends on to enable compile test

ARCH_RENESAS is a stronger condition than (ARM || ARM64).
If ARCH_RENESAS is enabled, (ARM || ARM64) is met as well.

What is worse, the first depends on line prevents COMPILE_TEST from
enabling this driver.  It should be removed.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: tmio: use ioread* for repeated access to a register
Wolfram Sang [Mon, 18 Dec 2017 00:00:21 +0000 (01:00 +0100)]
mmc: tmio: use ioread* for repeated access to a register

Not all archs define reads* and writes*. Switch to ioread*_rep and
friends which is defined everywhere, so we can enable COMPILE_TEST after
that.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: renesas_sdhi: Add MODULE_LICENSE
Masaharu Hayakawa [Wed, 13 Dec 2017 02:33:00 +0000 (11:33 +0900)]
mmc: renesas_sdhi: Add MODULE_LICENSE

The following error occurs when loading renesas_sdhi_core.c module,
so add MODULE_LICENSE("GPL v2").

 renesas_sdhi_core: module license 'unspecified' taints kernel.

Signed-off-by: Masaharu Hayakawa <masaharu.hayakawa.ry@renesas.com>
Fixes: 9d08428afb72 ("mmc: renesas-sdhi: make renesas_sdhi_sys_dmac main module file")
Cc: <stable@vger.kernel.org> # v4.13+
[Shimoda: Added Fixes tag and Cc to the stable ML]
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: renesas_sdhi: consolidate DMAC CONFIG options
Masahiro Yamada [Fri, 24 Nov 2017 16:24:36 +0000 (01:24 +0900)]
mmc: renesas_sdhi: consolidate DMAC CONFIG options

The description in the Makefile is odd.  Fix the CONFIG selection
in a cleaner way.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sunxi-mmc: Handle return value of platform_get_irq
Arvind Yadav [Sun, 19 Nov 2017 04:52:47 +0000 (10:22 +0530)]
mmc: sunxi-mmc: Handle return value of platform_get_irq

platform_get_irq() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sdhci-spear: Handle return value of platform_get_irq
Arvind Yadav [Sun, 19 Nov 2017 04:52:46 +0000 (10:22 +0530)]
mmc: sdhci-spear: Handle return value of platform_get_irq

platform_get_irq() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sdhci-acpi: Handle return value of platform_get_irq
Arvind Yadav [Sun, 19 Nov 2017 04:52:45 +0000 (10:22 +0530)]
mmc: sdhci-acpi: Handle return value of platform_get_irq

platform_get_irq() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: s3cmci: Fix platform_get_irq's error checking
Arvind Yadav [Sun, 19 Nov 2017 04:52:44 +0000 (10:22 +0530)]
mmc: s3cmci: Fix platform_get_irq's error checking

The platform_get_irq() function returns negative if an error occurs.
zero or positive number on success. platform_get_irq() error checking
for zero is not correct.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: meson-gx-mmc: Fix platform_get_irq's error checking
Arvind Yadav [Sun, 19 Nov 2017 04:52:43 +0000 (10:22 +0530)]
mmc: meson-gx-mmc: Fix platform_get_irq's error checking

The platform_get_irq() function returns negative if an error occurs.
zero or positive number on success. platform_get_irq() error checking
for zero is not correct.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Acked-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: dt-bindings: add mmc support to MT7623 SoC
Sean Wang [Thu, 7 Dec 2017 06:43:22 +0000 (14:43 +0800)]
mmc: dt-bindings: add mmc support to MT7623 SoC

Add the devicetree binding for MT7623 SoC using MT2701 as the fallback.

Cc: devicetree@vger.kernel.org
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agoMerge branch 'fixes' into next
Ulf Hansson [Mon, 11 Dec 2017 12:56:08 +0000 (13:56 +0100)]
Merge branch 'fixes' into next

6 years agommc: core: apply NO_CMD23 quirk to some specific cards
Christoph Fritz [Sat, 9 Dec 2017 22:47:55 +0000 (23:47 +0100)]
mmc: core: apply NO_CMD23 quirk to some specific cards

To get an usdhc Apacer and some ATP SD cards work reliable, CMD23 needs
to be disabled.  This has been tested on i.MX6 (sdhci-esdhc) and rk3288
(dw_mmc-rockchip).

Without this patch on i.MX6 (sdhci-esdhc):

 $ dd if=/dev/urandom of=/mnt/test bs=1M count=10 conv=fsync

    | <mmc0: starting CMD23 arg 00000400 flags 00000015>
    | mmc0: starting CMD25 arg 00a71f00 flags 000000b5
    | mmc0:     blksz 512 blocks 1024 flags 00000100 tsac 3000 ms nsac 0
    | mmc0:     CMD12 arg 00000000 flags 0000049d
    | sdhci [sdhci_irq()]: *** mmc0 got interrupt: 0x00000001
    | mmc0: Timeout waiting for hardware interrupt.

Without this patch on rk3288 (dw_mmc-rockchip):

    | mmc1: Card stuck in programming state! mmcblk1 card_busy_detect
    | dwmmc_rockchip ff0c0000.dwmmc: Busy; trying anyway
    | mmc_host mmc1: Bus speed (slot 0) = 400000Hz (slot req 400000Hz,
    | actual 400000HZ div = 0)
    | mmc1: card never left busy state
    | mmc1: tried to reset card, got error -110
    | blk_update_request: I/O error, dev mmcblk1, sector 139778
    | Buffer I/O error on dev mmcblk1p1, logical block 131586, lost async
    | page write

Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
Cc: <stable@vger.kernel.org> # v4.14+
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agoMerge branch 'fixes' into next
Ulf Hansson [Mon, 11 Dec 2017 12:19:35 +0000 (13:19 +0100)]
Merge branch 'fixes' into next

6 years agommc: sdhci-acpi: Avoid broken UHS transfer modes on Intel CHT
Adrian Hunter [Fri, 8 Dec 2017 13:08:18 +0000 (15:08 +0200)]
mmc: sdhci-acpi: Avoid broken UHS transfer modes on Intel CHT

Intel DSM function 8 has been used to identify transfer modes that are not
working on some CHT boards. Add support for that.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Carlo Caione <carlo@endlessm.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sdhci-acpi: Add setup_host() callback
Adrian Hunter [Fri, 8 Dec 2017 13:04:58 +0000 (15:04 +0200)]
mmc: sdhci-acpi: Add setup_host() callback

Add a ->setup_host() callback so that device-specific changes can be made
to the mmc host controller before it is added.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: block: blk-mq: Potential NULL deref on mmc_blk_alloc_req() failure
Dan Carpenter [Fri, 8 Dec 2017 11:55:16 +0000 (14:55 +0300)]
mmc: block: blk-mq: Potential NULL deref on mmc_blk_alloc_req() failure

mmc_blk_alloc_req() is supposed to return error pointers but there is
one path where we forget to set the error code and accidentally return
NULL.  The callers are not expecting that and will have a NULL pointer
dereference.

Fixes: 41e3efd07d5a ("mmc: block: Simplify cleaning up the queue")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: cqhci: Ensure macro parameters are wrapped in parentheses
Adrian Hunter [Fri, 8 Dec 2017 07:31:06 +0000 (09:31 +0200)]
mmc: cqhci: Ensure macro parameters are wrapped in parentheses

Absence of parentheses is not affecting current code, but ensure macro
parameters are wrapped in parentheses.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: a4080225f51d ("mmc: cqhci: support for command queue enabled host")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: core: Remove code no longer needed after the switch to blk-mq
Adrian Hunter [Wed, 29 Nov 2017 13:41:19 +0000 (15:41 +0200)]
mmc: core: Remove code no longer needed after the switch to blk-mq

Remove code no longer needed after the switch to blk-mq.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: block: Remove code no longer needed after the switch to blk-mq
Adrian Hunter [Wed, 29 Nov 2017 13:41:18 +0000 (15:41 +0200)]
mmc: block: Remove code no longer needed after the switch to blk-mq

Remove code no longer needed after the switch to blk-mq.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: core: Remove option not to use blk-mq
Adrian Hunter [Wed, 29 Nov 2017 13:41:17 +0000 (15:41 +0200)]
mmc: core: Remove option not to use blk-mq

Remove config option MMC_MQ_DEFAULT and parameter mmc_use_blk_mq, so that
blk-mq must be used always.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sdhci-of-esdhc: fix the mmc error after sleep on ls1046ardb
yinbo.zhu [Fri, 1 Dec 2017 07:09:34 +0000 (15:09 +0800)]
mmc: sdhci-of-esdhc: fix the mmc error after sleep on ls1046ardb

When system wakes up from sleep on ls1046ardb, the SD operation fails
with mmc error messages since ESDHC_TB_EN bit couldn't be cleaned by
eSDHC_SYSCTL[RSTA]. It's proper to clean this bit in esdhc_reset()
rather than in probe.

Signed-off-by: yinbo.zhu <yinbo.zhu@nxp.com>
Acked-by: Yangbo Lu <yangbo.lu@nxp.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: mmc_test: Ensure command queue is disabled for testing
Adrian Hunter [Fri, 1 Dec 2017 12:55:31 +0000 (14:55 +0200)]
mmc: mmc_test: Ensure command queue is disabled for testing

mmc_test disables the command queue because none of the tests use the
command queue. However the Reset Test will re-enable it, so disable it in
that case too.

Fixes: 9d4579a85c84 ("mmc: mmc_test: Disable Command Queue while mmc_test is used")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: core: Ensure cmd_completion is initialized
Adrian Hunter [Fri, 1 Dec 2017 12:55:30 +0000 (14:55 +0200)]
mmc: core: Ensure cmd_completion is initialized

mmc_test now uses mmc_start_request() to test sending commands during
"ongoing" asynchronous transfers, i.e. tests:
Commands during non-blocking read - use Set Block Count (CMD23)
Commands during non-blocking write - use Set Block Count (CMD23)

mmc_start_request() was not initializing cmd_completion, but cmd_completion
is used by "ongoing" transfers, so move initialization of cmd_completion
into making mmc_start_request().

Fixes: cb39f61e9b1e ("mmc: core: Export a few functions needed for blkmq support")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sdhci-acpi: Add support for ACPI HID of AMD Controller with HS400
Shah Nehal-Bakulchandra [Fri, 1 Dec 2017 10:08:52 +0000 (15:38 +0530)]
mmc: sdhci-acpi: Add support for ACPI HID of AMD Controller with HS400

This patch supports HS400 for AMD upcoming emmc 5.0 controller.The
HS400 and HS200 mode requires hardware work around also. This patch
adds the quirks for the same.

Signed-off-by: Nehal-bakulchandra Shah <Nehal-bakulchandra.Shah@amd.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc_test: use ktime_get_ts64 for timestamps
Arnd Bergmann [Mon, 27 Nov 2017 11:53:22 +0000 (12:53 +0100)]
mmc_test: use ktime_get_ts64 for timestamps

Calling getnstimeofday() can suffer from time jumps and from the
y2038 overflow, so it is not appropriate here. Using ktime_get_ts64()
solves both problems. Using ktime_get() with ktime_t timestamps would
also work, but it seems that we mainly want to print the times as
seconds+nanoseconds, so it would require an extra division in the output.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: sdhci-of-arasan: Add sdhci_arasan_set_power
Milan Stevanovic [Tue, 28 Nov 2017 00:02:57 +0000 (01:02 +0100)]
mmc: sdhci-of-arasan: Add sdhci_arasan_set_power

The power register needs to have a valid voltage set
even when the power supply is managed by  an external regulator.

Signed-off-by: Milan Stevanovic <milan.o.stevanovic@gmail.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: renesas_sdhi: enable R-Car D3 (r8a77995) support
Ulrich Hecht [Wed, 29 Nov 2017 16:06:45 +0000 (17:06 +0100)]
mmc: renesas_sdhi: enable R-Car D3 (r8a77995) support

Whitelists for internal DMAC implementation.

Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
6 years agommc: block: make function mmc_cqe_issue_type static
Colin Ian King [Thu, 30 Nov 2017 11:37:38 +0000 (11:37 +0000)]
mmc: block: make function mmc_cqe_issue_type static

The function mmc_cqe_issue_type is local to the source and does
not need to be in global scope, so make it static.

Cleans up sparse warning:
drivers/mmc/core/queue.c:62:21: warning: symbol 'mmc_cqe_issue_type'
was not declared. Should it be static?

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: block: blk-mq: fix boolreturn.cocci warnings
Wu Fengguang [Wed, 29 Nov 2017 21:54:24 +0000 (05:54 +0800)]
mmc: block: blk-mq: fix boolreturn.cocci warnings

drivers/mmc/core/block.c:2106:9-10: WARNING: return of 0/1 in function 'mmc_blk_status_error' with return type bool

 Return statements in functions returning bool should use
 true/false instead of 1/0.
Generated by: scripts/coccinelle/misc/boolreturn.cocci

Fixes:7eb43d537166 ("mmc: block: blk-mq: Stop using legacy recovery")
CC: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: mmc_test: Do not use mmc_start_areq() anymore
Adrian Hunter [Wed, 29 Nov 2017 13:41:16 +0000 (15:41 +0200)]
mmc: mmc_test: Do not use mmc_start_areq() anymore

The block driver's blk-mq paths do not use mmc_start_areq(). In order to
remove mmc_start_areq() entirely, start by removing it from mmc_test.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: block: blk-mq: Stop using legacy recovery
Adrian Hunter [Wed, 29 Nov 2017 13:41:15 +0000 (15:41 +0200)]
mmc: block: blk-mq: Stop using legacy recovery

There are only a few things the recovery needs to do. Primarily, it just
needs to:
Determine the number of bytes transferred
Get the card back to transfer state
Determine whether to retry

There are also a couple of additional features:
Reset the card before the last retry
Read one sector at a time

The legacy code spent much effort analyzing command errors, but commands
fail fast, so it is simpler just to give all command errors the same number
of retries.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: block: Reduce polling timeout from 10 minutes to 10 seconds
Adrian Hunter [Wed, 29 Nov 2017 13:41:14 +0000 (15:41 +0200)]
mmc: block: Reduce polling timeout from 10 minutes to 10 seconds

Set a 10 second timeout for polling write request busy state. Note, mmc
core is setting a 3 second timeout for SD cards, and SDHCI has long had a
10 second software timer to timeout the whole request, so 10 seconds should
be ample.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: block: Add timeout_clks when calculating timeout
Adrian Hunter [Wed, 29 Nov 2017 13:41:13 +0000 (15:41 +0200)]
mmc: block: Add timeout_clks when calculating timeout

According to the specification, total access time is derived from both TAAC
and NSAC, which means the timeout should add both timeout_ns and
timeout_clks. Host drivers do that, so make the block driver do that too.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: block: Check for transfer state in card_busy_detect()
Adrian Hunter [Wed, 29 Nov 2017 13:41:12 +0000 (15:41 +0200)]
mmc: block: Check for transfer state in card_busy_detect()

The card is required to return to transfer state. Since that is the state
required to start another transfer, check for that state instead of
programming state.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: block: Check the timeout correctly in card_busy_detect()
Adrian Hunter [Wed, 29 Nov 2017 13:41:11 +0000 (15:41 +0200)]
mmc: block: Check the timeout correctly in card_busy_detect()

Pedantically, ensure the status is checked for the last time after the full
timeout has passed.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: block: blk-mq: Check error bits and save the exception bit when polling card...
Adrian Hunter [Wed, 29 Nov 2017 13:41:10 +0000 (15:41 +0200)]
mmc: block: blk-mq: Check error bits and save the exception bit when polling card busy

Check error bits and save the exception bit when polling card busy.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: block: Make card_busy_detect() accumulate all response error bits
Adrian Hunter [Wed, 29 Nov 2017 13:41:09 +0000 (15:41 +0200)]
mmc: block: Make card_busy_detect() accumulate all response error bits

Make card_busy_detect() accumulate all response error bits. Later patches
will make use of this.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: block: blk-mq: Separate card polling from recovery
Adrian Hunter [Wed, 29 Nov 2017 13:41:08 +0000 (15:41 +0200)]
mmc: block: blk-mq: Separate card polling from recovery

Recovery is simpler to understand if it is only used for errors. Create a
separate function for card polling.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: block: blk-mq: Add support for direct completion
Adrian Hunter [Wed, 29 Nov 2017 13:41:07 +0000 (15:41 +0200)]
mmc: block: blk-mq: Add support for direct completion

For blk-mq, add support for completing requests directly in the ->done
callback. That means that error handling and urgent background operations
must be handled by recovery_work in that case.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: sdhci-pci: Add CQHCI support for Intel GLK
Adrian Hunter [Wed, 29 Nov 2017 13:41:06 +0000 (15:41 +0200)]
mmc: sdhci-pci: Add CQHCI support for Intel GLK

Add CQHCI initialization and implement CQHCI operations for Intel GLK.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: cqhci: support for command queue enabled host
Venkat Gopalakrishnan [Wed, 29 Nov 2017 13:41:05 +0000 (15:41 +0200)]
mmc: cqhci: support for command queue enabled host

This patch adds CMDQ support for command-queue compatible
hosts.

Command queue is added in eMMC-5.1 specification. This
enables the controller to process upto 32 requests at
a time.

Adrian Hunter contributed renaming to cqhci, recovery, suspend
and resume, cqhci_off, cqhci_wait_for_idle, and external timeout
handling.

Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: block: Add CQE support
Adrian Hunter [Wed, 29 Nov 2017 13:41:04 +0000 (15:41 +0200)]
mmc: block: Add CQE support

Add CQE support to the block driver, including:
    - optionally using DCMD for flush requests
    - "manually" issuing discard requests
    - issuing read / write requests to the CQE
    - supporting block-layer timeouts
    - handling recovery
    - supporting re-tuning

CQE offers 25% - 50% better random multi-threaded I/O.  There is a slight
(e.g. 2%) drop in sequential read speed but no observable change to sequential
write.

CQE automatically sends the commands to complete requests.  However it only
supports reads / writes and so-called "direct commands" (DCMD).  Furthermore
DCMD is limited to one command at a time, but discards require 3 commands.
That makes issuing discards through CQE very awkward, but some CQE's don't
support DCMD anyway.  So for discards, the existing non-CQE approach is
taken, where the mmc core code issues the 3 commands one at a time i.e.
mmc_erase(). Where DCMD is used, is for issuing flushes.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: block: Add blk-mq support
Adrian Hunter [Wed, 29 Nov 2017 13:41:03 +0000 (15:41 +0200)]
mmc: block: Add blk-mq support

Define and use a blk-mq queue. Discards and flushes are processed
synchronously, but reads and writes asynchronously. In order to support
slow DMA unmapping, DMA unmapping is not done until after the next request
is started. That means the request is not completed until then. If there is
no next request then the completion is done by queued work.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: core: Add parameter use_blk_mq
Adrian Hunter [Wed, 29 Nov 2017 13:41:02 +0000 (15:41 +0200)]
mmc: core: Add parameter use_blk_mq

Until mmc has blk-mq support fully implemented and tested, add a parameter
use_blk_mq, set to true if config option MMC_MQ_DEFAULT is selected, which
it is by default.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: block: Add error-handling comments
Adrian Hunter [Wed, 29 Nov 2017 13:41:01 +0000 (15:41 +0200)]
mmc: block: Add error-handling comments

Add error-handling comments to explain what would also be done for blk-mq
if it used the legacy error-handling.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: core: Make mmc_pre_req() and mmc_post_req() available
Adrian Hunter [Wed, 29 Nov 2017 13:41:00 +0000 (15:41 +0200)]
mmc: core: Make mmc_pre_req() and mmc_post_req() available

Make mmc_pre_req() and mmc_post_req() available to the card drivers. Later
patches will make use of this.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: block: Simplify cleaning up the queue
Adrian Hunter [Wed, 29 Nov 2017 13:40:59 +0000 (15:40 +0200)]
mmc: block: Simplify cleaning up the queue

Use blk_cleanup_queue() to shutdown the queue when the driver is removed,
and instead get an extra reference to the queue to prevent the queue being
freed before the final mmc_blk_put().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: block: No need to export mmc_cleanup_queue()
Adrian Hunter [Wed, 29 Nov 2017 13:40:58 +0000 (15:40 +0200)]
mmc: block: No need to export mmc_cleanup_queue()

mmc_cleanup_queue() is not used by a different module. Do not export it.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
6 years agommc: sunxi: fix mojibake in module metadata
Adam Borowski [Tue, 28 Nov 2017 03:44:55 +0000 (04:44 +0100)]
mmc: sunxi: fix mojibake in module metadata

It had an U+FFFD: not a corrupted character but a literal well-formed
replacement marker.

Signed-off-by: Adam Borowski <kilobyte@angband.pl>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agodt-bindings: mmc: renesas_sdhi: Add r8a77995 support
Ulrich Hecht [Wed, 15 Nov 2017 15:25:49 +0000 (16:25 +0100)]
dt-bindings: mmc: renesas_sdhi: Add r8a77995 support

Adds bindings for the R-Car D3 SoC's SDHI IP.

Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: tmio: use usleep_range consistently
Wolfram Sang [Tue, 14 Nov 2017 22:51:04 +0000 (23:51 +0100)]
mmc: tmio: use usleep_range consistently

There are a few udelay() left which are in a range that they should be
usleep_range() these days.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
6 years agommc: core: use usleep_range rather than HZ magic in mmc_delay()
Wolfram Sang [Tue, 14 Nov 2017 22:55:20 +0000 (23:55 +0100)]
mmc: core: use usleep_range rather than HZ magic in mmc_delay()

Documentation/timers/timers-howto.txt recommends to use usleep_range for
delays 1-20ms. Let's adhere to it. No need for messing with HZ and still
do busy looping these days.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>