Commit graph

414 commits

Author SHA1 Message Date
lintao
3aa5e0ae7a Revert "mmc: add rto for infinit sending timeout loop"
This reverts commit 426495888a.
2014-11-27 20:04:34 +08:00
lintao
426495888a mmc: add rto for infinit sending timeout loop
dw_mci write cmd index to CMD register to trigger sending cmd by BIU.
However, if device fall into panic holding cmd/data line to low level cause BIU
cannnot send out cmd forever. So no cmd_done_int will come. AND, cmd response timeout
only valid after cmd been sent. Nothing to break this loop, we need a s/w recovery from
STATE_SENDING_CMD to STATE_IDLE, and the pending one reported as -ETIMEOUT, let caller
decide howto again.

Reported-by: roger.hu <hwg@rock-chips.com>
Signed-off-by: lintao <lintao@rock-chips.com>
Reviewed-and-tested-by: roger.hu <hwg@rock-chips.com>
2014-11-27 15:25:47 +08:00
lintao
92469f0f90 mmc: capture dpm notify and avoid conflict scan flow
Signed-off-by: lintao <lintao@rock-chips.com>
2014-11-17 11:36:45 +08:00
lintao
218243389f mmc: Hynix 4.41 iNAND no trim quirk patch from mediatek 2014-10-22 14:59:32 +08:00
lintao
47f217c4ea mmc: Support sdmmc/uart_dbg auto switch
Add pinctrl-names "udbg" in sdmmc blob, and drivers auto
switch io useage by card-detect tasklet routine. Only audi series need
it indeed now and ever.

Signed-off-by: lintao <lintao@rock-chips.com>
Acked-by: lw <lw@rock-chips.com>
Cc: phc <phc@rock-chips.com>
2014-10-10 09:56:24 +08:00
lintao
1c912e0e91 mmc: add atomic operation for register 2014-09-22 10:17:20 +08:00
lintao
d9a820a163 mmc: schedule out rescan flow for confilicting with ehci reset
Signed-off-by: lintao <lintao@rock-chips.com>
2014-09-20 16:59:44 +08:00
lintao
1040978412 mmc: fix wrong physical partition definition
eMMC card can support up to 7 partitions, including 2 boot,
1 RPMB and 4 GPs. But MMC_NUM_PHY_PARTITION is defined to
6 so we should fix it to 7.
2014-09-09 10:23:35 +08:00
lintao
3936e240c2 mmc: Support tSD or SD booting OS.
In case of tSD board or SD booting project, BSP engineers could
only add "supports-tSD" into emmc_of_node claim. Refer to arch/arm/boot/dts/rk3288-tb.dts
2014-09-04 16:11:05 +08:00
lintao
45d41680fe mmc: change mmc_rescan_host usage for Rockchip turnkey customer :((
Before this patch we identify oob-wifi or sdio-irq-wifi by DTS.
However wifi engineers argue that our customer is lazy to modify it event
we had moentioned in release wifi configure document before and claim it
again and agin.

Cc: hwg <hwg@rock-chips.com>
Cc: gwl <gwl@rock-chips.com>
Signed-off-by: Shawn Lin <lintao@rock-chips.com>
2014-08-15 17:00:06 +08:00
lintao
0e21a6d15e mmc: rk_sdmmc:
(1) auto select edma/idma by Soc chip id
	(2) enable rk3036-sdk sd & sdio
2014-07-15 17:27:01 +08:00
lintao
bfc40850c4 mmc: support drv_e and sr modify 2014-07-09 18:09:20 +08:00
lintao
00b34deba4 mmc: host: rk_sdmmc: prepare for next Soc(s)
fix edma slave config phy regs
2014-07-07 16:43:00 +08:00
lintao
78f99b8039 mmc: core: rk_sdmmc: prepare for next Soc(s)
Merge branch from develop-3.10-next into develop-3.10
2014-06-26 21:27:48 +08:00
lintao
fbfdff1f46 mmc: host: rk_sdmmc: add data-over-int timeout for data_busy
If devices fall in bad state make data_busy be hold too long,
dto interrupt will not be present, which leading  mmc-core wait for it forever.

 [<c06d42e4>] (__schedule+0x48c/0x554) from [<c06d275c>] (schedule_timeout+0x1c/0x260)
 [<c06d275c>] (schedule_timeout+0x1c/0x260) from [<c06d3c10>] (wait_for_common+0xd0/0x164)
 [<c06d3c10>] (wait_for_common+0xd0/0x164) from [<c044a4bc>] (mmc_wait_for_req_done+0x1c/0xe0)
 [<c044a4bc>] (mmc_wait_for_req_done+0x1c/0xe0) from [<c0453730>] (mmc_io_rw_extended+0x218/0x294)
 [<c0453730>] (mmc_io_rw_extended+0x218/0x294) from [<c0454590>] (sdio_io_rw_ext_helper+0xc8/0x194)
 [<c0454590>] (sdio_io_rw_ext_helper+0xc8/0x194) from [<c04546b0>] (sdio_memcpy_toio+0x1c/0x20)
 [<c04546b0>] (sdio_memcpy_toio+0x1c/0x20) from [<c032e96c>] (sdioh_request_packet+0x664/0x7e8)
 [<c032e96c>] (sdioh_request_packet+0x664/0x7e8) from [<c032fc78>] (sdioh_request_buffer+0x1a8/0x210)
2014-06-25 21:42:19 +08:00
lin tao
c580ac7deb mmc: host: rk_sdmmc:
Support physical level three transfer.
2014-06-16 10:56:00 +08:00
lin tao
086c795117 mmc: fix compile warning 2014-06-16 08:00:18 +08:00
lintao
bc9c115f09 Revert "mmc: host: rk_sdmmc:"
This reverts commit 4821809db2.
2014-06-11 14:40:09 +08:00
lintao
4821809db2 mmc: host: rk_sdmmc:
[IMPORTANT COMMIT | NEED_EXPERIMENTAL | CAN_REVERT]

     <1> Support SDIO 3.0, workaround for non-standard behaviour(AP6335) Temporarily.
     <2> Support SD3.0, and SDXC card  should use  exfat filesystem.
     <3> Non-emmc devices that turning fail would not bug kernel.
         Hotplug and poweroff-able (wifi,SD,MMC) devices support re-insert and try it again.
     <4> note:
         (a) card & io aware devices, f_max = 2 * clock, e.g USH_SDR104 means
             support max 208MHz clock in standard.
         (b) setup_bus doesn't need update clk in svi flow
         (c) card_busy: bascially should check CMD,DATA[0:3], however we use
             toggle tags to match svi flow now.
         (d) shorter wait busy and remove  dump_stack in vsi flow.
             Card should be busy until clk re-enable and svi complete.

      All behaviour follow the protocol, enjoy it!
2014-06-11 14:14:55 +08:00
xbw
36ae021903 SDMMC:
1、set the emmc-clock to 150Mhz which compatible with new PLL.
2. Optimization timing Training.
3. SD3.0/SDIO3.0 implementation process.
2014-05-05 10:10:32 +08:00
xbw
d20f74a360 SDMMC:
1. emmc to support High Speed DDR MMC.
2. emmc to support HS200 mode ,and add the tuning timing for HS200 mode.
3. Improve mmc bus frequency to 400Mhz, and Imporve cclk_in to 200Mhz.
4. modify the p977.dts for the above performance.
2014-04-01 13:54:20 +08:00
lintao
f5b42ad17d mmc: host: rockchip: setup max hold time for cmd_rto 2014-03-27 10:32:45 +08:00
xbw
d1eda47b81 SDMMC: Dynamically set the clock of sdmmc 2014-03-26 16:47:01 +08:00
lintao
49264b25b9 mmc: host: rk3288-pinctrl: fix sdmmc & sdio0 controller pad iomux setting
rk_sdmmc: setting default pinctrl in controller probe but eMMC.
2014-03-26 13:19:17 +08:00
xbw
a9c8bad76f SDMMC:
1.add the flag for emmc-disk.
2.the process of insert-remove card is ok.
3.modify the sdio-detect for sdio wifi.
2014-03-24 06:12:08 +08:00
xbw
59861ed4ca SDMMC: Add the judgment on soc differences between rk3188 and rk32XX 2014-03-15 17:37:14 +08:00
xbw
3bf6d8c0cc SDMMC: eMMC OK. It is good to run correctly from emmc 2014-03-12 14:44:46 +08:00
xbw
7dcb2b4f0a 1.to support eMMC.
2.Resolve conflicts pin used to wifi-sdio-det.
3.Resolve the clock conflict between sd and sdio.
2014-03-11 10:01:46 +08:00
xbw
c8dc36ca79 SDMMC: 1.to identify eMMC. 2.add the trace log in rk_sdmmc driver. 2014-03-10 12:05:59 +08:00
Ulf Hansson
10d03026fe mmc: block: Enable runtime pm for mmc blkdevice
Once the mmc blkdevice is being probed, runtime pm will be enabled.
By using runtime autosuspend, the power save operations can be done
when request inactivity occurs for a certain time. Right now the
selected timeout value is set to 3 s. Obviously this value will likely
need to be configurable somehow since it needs to be trimmed depending
on the power save algorithm.

For SD-combo cards, we are still leaving the enablement of runtime PM
to the SDIO init sequence since it depends on the capabilities of the
SDIO func driver.

Moreover, when the blk device is being suspended, we make sure the device
will be runtime resumed. The reason for doing this is that we want the
host suspend sequence to be unaware of any runtime power save operations
done for the card in this phase. Thus it can just handle the suspend as
the card is fully powered from a runtime perspective.

Finally, this patch prepares to make it possible to move BKOPS handling
into the runtime callbacks for the mmc bus_ops. Thus IDLE BKOPS can be
accomplished.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>

Conflicts:
	drivers/mmc/card/block.c
2014-03-07 19:49:54 +08:00
Bing Zhao
9545e8d7fe mmc: sdio: add a quirk for broken SDIO_CCCR_INTx polling
Polling SDIO_CCCR_INTx could create a fake interrupt with Marvell
SD8797 card. Add a quirk to handle this case. The fixup here is
to issue a dummy CMD52 read to function 0 register 0xff, and this
dummy read must be right after SDIO_CCCR_INTx is read.

Patch has been verified on a dw_mmc controller (Samsung Chromebook)
with MMC_CAP_SDIO_IRQ disabled.

Signed-off-by: Bing Zhao <bzhao@marvell.com>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Reviewed-by: Doug Anderson <dianders@chromium.org>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <chris@printf.net>
2014-03-07 19:39:01 +08:00
Ulf Hansson
0233fd23a5 mmc: core: Add MMC_CAP_RUNTIME_RESUME to resume at runtime_resume
In some environments it is to prefer to postpone the resume of the card
device until runtime_resume is being carried out, since it will mean a
signficant decrease of the total system resume time.

The reason of the decreased resume time is simply because of the actual
re-initalization of the card, which typically takes hundreds of
milliseconds, is performed outside the resume sequence and wont thus
affect it.

For removable card, the detect work tries to re-detect the card to make
sure it is still present, as a part of that sequence the card will also
be runtime_resumed and thus also fully resumed.

For a non-removable card, typically a mmc blk request will trigger a
runtime_resume and thus fully resume the card. This also means the
first request will likely suffer from an inital latency since the
re-initialization of the card needs to be performed.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
2014-03-07 19:35:27 +08:00
Ulf Hansson
4b1ff18255 mmc: Don't force card to active state when entering suspend/shutdown
By adding a card state that records if it is suspended or resumed, we
can accept asyncronus suspend/resume requests for the mmc and sd
bus_ops.

MMC_CAP_AGGRESSIVE_PM, will at request inactivity through the runtime
bus_ops callbacks, execute a suspend of the the card. In the state were
this has been done, we can receive a suspend request for the mmc bus,
which for sd and mmc forced the card to active state by a
pm_runtime_get_sync. In other words, the card was resumed and then
immediately suspended again, completely unnecessary.

Since the suspend/resume bus_ops callbacks for sd and mmc are now
capable of handling asynchronous requests, we no longer need to force
the card to active state before executing suspend. Evidently preventing
the above sequence for MMC_CAP_AGGRESSIVE_PM.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
2014-03-07 19:34:01 +08:00
Ulf Hansson
3027099fb5 mmc: core: Remove deprecated mmc_suspend|resume_host APIs
The are no more users of the deprecated mmc_suspend|resume_host API,
so let's remove it.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
2014-03-07 19:28:24 +08:00
Ulf Hansson
51dfeaef6a mmc: core: Move cached value of the negotiated ocr mask to card struct
The negotiated ocr mask is directly related to the card. Once a card
gets removed, the mask shall be dropped. By moving the cache of the ocr
mask from the host struct to the card struct we have accomplished this.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>

Conflicts:
	drivers/mmc/core/sd.c
2014-03-07 17:35:23 +08:00
Ulf Hansson
5161f23189 mmc: core: Do not poll for busy with status cmd for all switch cmds
Some switch operations like poweroff notify, shall according to the
spec not be followed by any other new commands. For these cases and
when the host does'nt support MMC_CAP_WAIT_WHILE_BUSY, we must not
send status commands to poll for busy detection. Instead wait for
the stated timeout from the EXT_CSD before completing the request.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
2014-03-07 16:16:06 +08:00
Jackey Shen
8feaef3479 mmc: core: clean up duplicate macros
Clean up the duplicate macros:
mmc_sd_card_uhs -> mmc_card_uhs
mmc_sd_card_set_uhs -> mmc_card_set_uhs

Signed-off-by: Jackey Shen <jackey.shen@amd.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
2014-03-07 15:44:29 +08:00
Grant Grundler
e439607d23 mmc: core: remove dead function mmc_try_claim_host
cscope says there are no callers for mmc_try_claim_host in the kernel.
No reason to keep it.

Signed-off-by: Grant Grundler <grundler@chromium.org>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
2014-03-07 15:44:06 +08:00
Haijun Zhang
1c9aaaee2c mmc: core: parse voltage from device-tree
Add function to support getting voltage from device-tree.
If voltage-range is specified in device-tree node, this function
will parse it and return the available voltage mask.

Signed-off-by: Haijun Zhang <haijun.zhang@freescale.com>
Acked-by: Anton Vorontsov <anton@enomsg.org>
Signed-off-by: Chris Ball <cjb@laptop.org>

Conflicts:
	drivers/mmc/core/core.c
2014-03-07 15:43:40 +08:00
Laurent Pinchart
a0f135e61b mmc: slot-gpio: Add debouncing capability to mmc_gpio_request_cd()
Add a debounce parameter to the mmc_gpio_request_cd() function that
enables GPIO debouncing when set to a non-zero value. This can be used
by MMC host drivers to enable debouncing on the card detect signal.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Chris Ball <cjb@laptop.org>

Conflicts:
	drivers/mmc/host/jz4740_mmc.c
	drivers/mmc/host/mvsdio.c
2014-03-07 14:12:09 +08:00
Ulf Hansson
7f584c49c8 mmc: core: Invent MMC_CAP2_FULL_PWR_CYCLE
MMC_CAP2_FULL_PWR_CYCLE shall be set by host drivers which are able to
do a complete power cycle of the card. In the eMMC case that includes
both vcc and vccq.

This CAP is providing the protocol layer with important information,
needed to take optimized decisions during card initialization and in
the suspend/resume sequence.

MMC_CAP2_POWEROFF_NOTIFY is replaced by MMC_CAP2_FULL_PWR_CYCLE, since
it makes sense to use a wider scope for it.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
2014-03-07 13:38:30 +08:00
Ulf Hansson
cbac2e5201 mmc: core: Handle card shutdown from mmc_bus
Considering shutdown of the card, the responsibility to initate this
sequence shall be driven from the mmc_bus.

This patch enables the mmc_bus to handle this sequence properly. A new
.shutdown callback is added in the mmc_driver struct which is used to
shutdown the blk device.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
2014-03-07 13:07:45 +08:00
Simon Baatz
3a392c1df3 mmc: return mmc_of_parse() errors to caller
In addition to just logging errors encountered during DT parsing or
allocating GPIO slots for CD/WP, mmc_of_parse() now returns with an error.

In particular, this is needed if the GPIO allocation may return
EPROBE_DEFER.

Signed-off-by: Simon Baatz <gmbnomis@gmail.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
2014-03-07 12:53:48 +08:00
Fredrik Soderstedt
65cdca4472 mmc: core: Fix select power class after resume
Use the saved values in card->ext_csd when selecting power class.
By doing this the power class will be selected even if mmc_init_card
is called with oldcard != NULL, which is the case after a suspend/resume.

Today ext_csd is NULL if mmc_init_card is called with oldcard != NULL
and power class will not be selected.

According to the eMMC specification the POWER_CLASS value is reset after
power failure, H/W reset assertion and any CMD0 reset.

Signed-off-by: Fredrik Soderstedt <fredrik.soderstedt@stericsson.com>
Reviewed-by: Johan Rudholm <jrudholm@gmail.com>
Acked By: Girish K S <girish.shivananjappa@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
2014-03-07 12:48:57 +08:00
Ulf Hansson
d7b8a89726 mmc: core: Restructure and simplify code for mmc sleep|awake
The mmc_card_sleep|awake APIs are not being used since the support is
already properly encapsulated within the suspend sequence. Sleep|awake
command is also specific for eMMC.

We remove the sleep|awake bus_ops, the mmc_card_sleep|awake APIs and
move the code into the mmc specific core instead. This also includes
the mmc ops function, mmc_sleepawake. All releated functions have then
become static and we have got far less code to maintain.

Additionally this patch also simplifies the code from mmc_sleepawake,
since it is only used to put the card to sleep and not awake.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
2014-03-07 12:48:03 +08:00
Ulf Hansson
0a82e11529 mmc: core: Support aggressive power management for (e)MMC/SD
Aggressive power management is suitable when saving power is
essential. At request inactivity timeout, aka pm runtime
autosuspend timeout, the card will be suspended.

Once a new request arrives, the card will be re-initalized and
thus the first request will suffer from a latency. This latency
is card-specific, experiments has shown in general that SD-cards
has quite poor initialization time, around 300ms-1100ms. eMMC is
not surprisingly far better but still a couple of hundreds of ms
has been observed.

Except for the request latency, it is important to know that
suspending the card will also prevent the card from executing
internal house-keeping operations in idle mode. This could mean
degradation in performance.

To use this feature make sure the request inactivity timeout is
chosen carefully. This has not been done as a part of this patch.

Enable this feature by using host cap MMC_CAP_AGGRESSIVE_PM and
by setting CONFIG_MMC_UNSAFE_RESUME.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
2014-03-07 12:46:23 +08:00
Ulf Hansson
22c6d9771f mmc: block: Enable runtime pm for mmc blkdevice
Once the mmc blkdevice is being probed, runtime pm will be enabled.
By using runtime autosuspend, the power save operations can be done
when request inactivity occurs for a certain time. Right now the
selected timeout value is set to 3 s. Obviously this value will likely
need to be configurable somehow since it needs to be trimmed depending
on the power save algorithm.

For SD-combo cards, we are still leaving the enablement of runtime PM
to the SDIO init sequence since it depends on the capabilities of the
SDIO func driver.

Moreover, when the blk device is being suspended, we make sure the device
will be runtime resumed. The reason for doing this is that we want the
host suspend sequence to be unaware of any runtime power save operations
done for the card in this phase. Thus it can just handle the suspend as
the card is fully powered from a runtime perspective.

Finally, this patch prepares to make it possible to move BKOPS handling
into the runtime callbacks for the mmc bus_ops. Thus IDLE BKOPS can be
accomplished.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
2014-03-07 12:45:16 +08:00
Maya Erez
cac3fcee6f mmc: card: Adding support for sanitize in eMMC 4.5
The sanitize support is added as a user-app ioctl call, and
was removed from the block-device request, since its purpose is
to be invoked not via File-System but by a user.

This feature deletes the unmap memory region of the eMMC card,
by writing to a specific register in the EXT_CSD.

unmap region is the memory region that was previously deleted
(by erase, trim or discard operation).

In order to avoid timeout when sanitizing large-scale cards,
the timeout for sanitize operation is 240 seconds.

Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Chris Ball <cjb@laptop.org>

Conflicts:
	drivers/mmc/card/block.c
2014-03-07 12:40:27 +08:00
Ulf Hansson
59d3e81209 mmc: core: Re-use code for MMC_CAP2_DETECT_ON_ERR in polling mode
Previously the MMC_CAP2_DETECT_ON_ERR was invented for detecting
slow card removal. In was never a realy good solution and a proper
fix has been merged using gpio debouncing instead. We remove this
cap in this patch.

Although when using polling card detect mode, the code invented for
MMC_CAP2_DETECT_ON_ERR is re-used to complete card removal in an
earlier phase. There are no need waiting for the polling timeout to
elapse in this case.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Kevin Liu <kliu5@marvell.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
2014-03-07 12:28:15 +08:00
xbw
fbdd2f071b SDMMC-emmc:add the capability to support hs200 mode 2014-03-04 17:47:47 +08:00