mmc: fixes for eMMC v4.5 sanitize operation

eMMC v4.5 sanitize operation erases all copies of unmapped
data.  However trim or erase operations must be used first
to unmap the required sectors.  That was not being done.

Fixes apply to linux 3.2 on.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: <stable@vger.kernel.org>
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
 mmc: sdhci: refine non-removable card checking for card detection

Commit c79396c ("mmc: sdhci: prevent card detection activity
for non-removable cards") disables card detection where the cards
are marked as non-removable.

This makes sense, but the implementation detail of calling
mmc_card_is_removable() causes some problems, because
mmc_card_is_removable() is overloaded with CONFIG_MMC_UNSAFE_RESUME
semantics.

In the OLPC XO case, we need CONFIG_MMC_UNSAFE_RESUME because our root
filesystem is stored on SD, but we also have external SD card slots
where we want automatic card detection.

Refine the check to only apply to hosts marked as MMC_CAP_NONREMOVABLE,
which is defined to mean that the card is *really* nonremovable. This
could be revisited in future if we find a way to improve
CONFIG_MMC_UNSAFE_RESUME semantics.

Signed-off-by: Daniel Drake <dsd@laptop.org>
Acked-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
[stable@: please apply to 3.3-stable]
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Chris Ball <cjb@laptop.org>

+ Friends!
mmc: cd-gpio: Include header to pickup exported symbol prototypes

Include the linux/mmc/cd-gpio.h header to pickup the prototypes
for the two exported symbols.

This quiets the sparse warnings:

warning: symbol 'mmc_cd_gpio_request' was not declared. Should it be static?
warning: symbol 'mmc_cd_gpio_free' was not declared. Should it be static?

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Acked-by: Venkatraman S <svenkatr@ti.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
Revert "mmc: Set suspend/resume bus operations if CONFIG_PM_RUNTIME is used"

This reverts commit 2f4735e514e3e3ed9e55a8cd3c2c90690ee44b90.
mmc: cd-gpio: protect against NULL context in mmc_cd_gpio_free()

commit 0e9f480bb553d39ee06ccd45639ba7a5446a7b81 upstream.

Do not oops, even if mmc_cd_gpio_free() is mistakenly called on a driver
cleanup path, even though a previous call to mmc_cd_gpio_request() failed.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
[stable@: please apply to 3.3-stable]
Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
mmc: core: fix the decision of mmc card-type

Current implementation decides the card type exclusively. Even though
eMMC device can support both HS200 and DDR mode, card type will be
set only for HS200. If the host doesn't support HS200 but has DDR
capability, then DDR mode can't be selected.

Change-Id: Ia643dab39806a3e5e83b132d1c78bc7b2f58852f
Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
mmc: core: fix the signaling 1.8V for HS200

Currently only 1.2V is treated for HS200 mode. If the host has only
1.8V I/O capability not 1.2V, mmc_set_signal_voltage can't be called
for 1.8V HS200. EXT_CSD_CARD_TYPE_SDR_1_8V needs to be considered.

Change-Id: I403f4f8f9a28a3e7ac4037349a8f47704f509b02
Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
mmc: sdio: Fix sdio_reset_comm for sync

mmc_sdio_init_card function is doing necessary initialization

Change-Id: I7d2e432b2af8a76267378acba07e3e4e8fd1e6bc
Signed-off-by: Hosung Kim <hosung0.kim@samsung.com>
mmc: bus: add bus speed mode of UHS-I SDIO card

This patch adds bus speed mode of UHS-I SDIO card.
When UHS-I SDIO card is detected, only SDR12 mode is printed
in SDIO.

Change-Id: I99e299f65f7b9a67891c9e47718fd4139397f985
Signed-off-by: Hosung Kim <hosung0.kim@samsung.com>
mmc: sdio: add to set S18R to 1 for supporting UHS-I

This patch add to supports UHS-I sets S18R to 1 in the argument
of CMD5 to request a change of signal voltage 1.8V.
And Some devices use only dedicated 1.8V signaling level for
design reasons. MMC_CAP2_BROKEN_VOLTAGE flag is used when there
is no needs to change to any signal level.

Change-Id: Iaac45bc4296c442724de0f21edc01a7a46e24eb2
Signed-off-by: Hosung Kim <hosung0.kim@samsung.com>