The current 4-minute data transfer timeout is misleading and broken.
Instead of such a long wait, calculate the timeout duration based on
the length of the data transfer. The current formula is the transfer
length in bits, divided by a multiplication of bus frequency in Hz,
bus width, DDR mode and converted the mSec. The value is bounded from
the bottom to 10000 mSec.
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Jaehoon Chung <jh80.chung@samsung.com>
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: I168b6ceba917d3e621559a92a63fac78abca6bff
(cherry picked from commit 4e16f0a67d80b4ce11995b870b5d9c8d11266d0d)
This allows using CONFIG_IS_ENABLED(MMC_WRITE) to compile out code
needed only if write support is required.
The option is added for u-boot and for SPL
Change-Id: Ibb3836ed8713e491238460783a85ee1808770f66
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
(cherry picked from commit d6400c3f8520bb9a203fe397039279c80f093c27)
Reset the clock phase when the frequency is lower than 52MHz.
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: I49c50779ab5e1103d815cd2be1a7c9603cea397a
Different platform has different phy IP, distinguish them by
the compatible data.
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: Iaf78eee8abe7e9cd91c1edcd42fd65a611c3b0be
This function prepares to read data without confirming completed.
We can use it to prefetch data and run other process.
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: I76116c25dfdb7559b80a0216c414189e85409a3e
Since v2.80a, dwmmc controller introduced the card write threshold for
HS200 & HS400 mode. So CardThrCtl can be supported during write operation, not
only read operation.
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: I7f345660107c2978d2f874d36f2dffd2acdfbcb6
The MMC is initialized by pre-loader or bootrom, so it is no need to
initialize it again. Open this config to skip some unused initialized
process.
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: If00fc3ce7df4d15e71ecfd8f8717a59640c3b7a9
Sometimes we need to reconfigure the eMMC gpio state in spl without
pinctrl driver. So add func mmc_gpio_init_direct to initialize the
eMMC gpio in different platform.
Change-Id: I22500f8865a9e29e59be6ff224001bad899cec48
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Since we use the aliases in U-Boot to get the MMC device order, and
sometimes we pass the spl boot device to U-Boot. This may be confused
that which MMC device is passed to U-Boot. So unify it together.
Change-Id: I8db5e90d9543004aff128322398edffad35b551b
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Thomas reported U-Boot failed to build host tools if libfdt-devel
package is installed because tools include libfdt headers from
/usr/include/ instead of using internal ones.
This commit moves the header code:
include/libfdt.h -> include/linux/libfdt.h
include/libfdt_env.h -> include/linux/libfdt_env.h
and replaces include directives:
#include <libfdt.h> -> #include <linux/libfdt.h>
#include <libfdt_env.h> -> #include <linux/libfdt_env.h>
Change-Id: I68fd5734d6460c169fa5ee2893c57cb5d73340b6
Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit b08c8c4870831c9315dcae237772238e80035bd5)
This converts the following to Kconfig:
CONFIG_APBH_DMA
CONFIG_APBH_DMA_BURST
CONFIG_APBH_DMA_BURST8
Signed-off-by: Adam Ford <aford173@gmail.com>
Reviewed-by: Stefan Agner <stefan.agner@toradex.com>
[trini: Add in MMC as well]
Change-Id: I45b919ab747aa414ba23f1e165c11dd8aff44c44
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 99bec1aead5927c54f4364bfe10823a86fe0dad2)
wait_for_bit callers use the 32 bit LE version
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Reviewed-by: Jagan Teki <jagan@openedev.com>
Change-Id: I638846de7db29711fb7c778cc8304b507de057fe
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 48263504c8d501678acaa90c075f3f7cda17c316)
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
The sd card power is enabled when PWREN is set low by rockchip hardware design.
Change-Id: I4fb54235bd5235030146f77be1e07dc4e729ae06
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Add function get_cd to detect storage device directly instead of detect
it by mmc command.
Change-Id: I486dee836c62092baabe40fc6de995904849f91d
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
According to eMMC spec, the resp_type of MMC_CMD_WRITE_MULTIPLE_BLOCK
is MMC_RSP_R1 but not MMC_RSP_R1b.
If use MMC_RSP_R1b, this causes rpmb can not work with sdhci drive.
Change-Id: I02ab825a4a526646079be6a7ae27326d1a3b7acf
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Thomas reported U-Boot failed to build host tools if libfdt-devel
package is installed because tools include libfdt headers from
/usr/include/ instead of using internal ones.
This commit moves the header code:
include/libfdt.h -> include/linux/libfdt.h
include/libfdt_env.h -> include/linux/libfdt_env.h
and replaces include directives:
#include <libfdt.h> -> #include <linux/libfdt.h>
#include <libfdt_env.h> -> #include <linux/libfdt_env.h>
Change-Id: I6c0f7e50e8b571106627f25ddac008a62bd2994e
Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
In the eMMC spec, “Note that while the actual timing change is done,
the behavior of any command sent command sent (like CMD13) cannot be
guaranteed due to the asynchronous operation. Therefore it is not
recommended to use CMD13 to check the busy completion of the timing
change indication.” indicates that SEND_STATUS can not be send after
set-timing, so delete it.
Test eMMC model:
Manufacturer ID: 45
OEM: 100
Name: DG401
Rd Block Len: 512
MMC version 5.1
Capacity: 14.7 GiB
Change-Id: Idd47461b529f28af649f2275041f36ef998ee404
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
The cmd13 can't guarantee the switch command is success even it response
without any error bit assert. So we should wait busy signal to wait the
behaviour of the device is completed.
Change-Id: Ia7e9efc27b5e05a7bcb9b4c98eef1e134efc29e7
Fixes: 55e5defd20 ("mmc: rework mmc_switch for non-send_status scenario")
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
We set the fifo_depth to 0x100 word in Rockchip platform, and
fifo_depth/2 must be multiple of dma_multiple_transaction_size.
So we can set DWMCI_MSIZE to 6 according to max
dma_multiple_transaction_size being 128.
The DWMCI_MSIZE must be set as larger as possible. If not, dma fifo will
be full, and crc error occur when the clock stop during the data phase.
Change-Id: I013b6f9c272edbc723b2f627e88d30d653c42d1b
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
The valid window of mmc sample phase is 0-360. It is separated
to four options for tuning to improve tuning efficiency.
If init_retry counter exceeds four, set init_retry to zero.
If the default_phase is set, we use it. If fail, try strategy of
tuning above.
Change-Id: I4938717937d37ef156c278277d188f1b25d6ebbc
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Add the "mmc-hs200-1_8v & mmc-hs400-1_8v" to the dts
to support hs200&hs400
Change-Id: Ic141b75b328a56609853aae50c8a094c605931e1
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Add default sample clock phase and it can be used when
run mmc_send_tuning.
The function mmc_send_tuning will use default_phase directly
to set the sample clock phase, and this can improve tuning's
efficiency. If use default_phase to run mmc_send_tuning fail,
it will change to tune 0&45...&270 phase.
Change-Id: I747f7820a7d2a67ffb9152794acec31b15e97e2b
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
BUG: If erase is set as MMC_ERASE_ARG, the erase command
perform an erase on erase group(s). If so, when the start
address is close to the next partition address and the
blkcnt is less than erase group size, the mmc_berase()
will recalculate the end address and may exceed the next
partition start address. This will erase the other partition
useful data.
Solve: Set erase mode as trim, the erase command perform an
erase on the sector(s).
The erase command of SD card perform an erase on the sector(s).
We can just send the start and end address to erase SD card
and send CMD38 with argument MMC_ERASE_ARG.
Change-Id: Ic4251b77e9f9feb6a087324c0241625ff013a0a0
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Use debug instead of print for not always print the message, we can use
mmc info to know MMC mode.
Update the info by the way.
Change-Id: Iaf5762246b4dbbbb4baf92aca478304dc1f49746
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
The emmc support several erase mode, we add mmc_can_trim
flag hear to support trim.
Change-Id: Iaee154eb0ef5edb95783aa3753421afd7c058263
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
If data error, we will reset the controller and wait when it is
ready. But the timeout data type is u32, it is never less than
zero. So change judgement data to one.
Change-Id: If049da06ecfe42fd31cca344bf87f69f7850dbe2
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
If emmc driver config MMC_TIMING_MMC_HS, need config
controller SDHCI_HOST_CONTROL2 register SDHCI_CTRL_UHS_SDR50.
It will affect emmc phy work mode.
Change-Id: Ib45f30eb6b70bde6f1beb4612ded17ee2b24b5fe
Signed-off-by: chenfen <chenfen@rock-chips.com>
Priority to use cru division is better timing than use controller
division.
Change-Id: I8b7b9a9c99f09407f209fda8df6460136a3105e9
Signed-off-by: chenfen <chenfen@rock-chips.com>
BUG: If not find ciu-sample, probe will fail. This make
mmc device unusable.
Change-Id: I86310cd2bc84cea5a81b72d103c8947ed4c1b07b
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
we can set mmc-hs200-1_8v to the node of emmc
in the dts to support hs200.
Change-Id: I5fa195505b877449864f294564cfc33bcd4202e5
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
1.judge the clk_get_by_name return value
2.rename the ciu_sample to ciu-sample according
to dts
Change-Id: I60c9f43f8cf0dd02815ee9078f5e957dc9c6d24d
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
This reverts commit 4a872f4aa8.
rk3229 evb and echo can not work with ddr52 enable.
Change-Id: Ia22b30ffe40de6f6e74e50ec5fd52e3715006de0
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
U-Boot widely uses error() as a bit noisier variant of printf().
This macro causes name conflict with the following line in
include/linux/compiler-gcc.h:
# define __compiletime_error(message) __attribute__((error(message)))
This prevents us from using __compiletime_error(), and makes it
difficult to fully sync BUILD_BUG macros with Linux. (Notice
Linux's BUILD_BUG_ON_MSG is implemented by using compiletime_assert().)
Let's convert error() into now treewide-available pr_err().
Done with the help of Coccinelle, excluing tools/ directory.
The semantic patch I used is as follows:
// <smpl>
@@@@
-error
+pr_err
(...)
// </smpl>
Change-Id: I921807c1770d36a91e692c48ab477558bb2ed0b8
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
[trini: Re-run Coccinelle]
Signed-off-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit 9b643e312d528f291966c1f30b0d90bf3b1d43dc)
Update the Rockchip SDHCI wrapper to support a live device tree.
Change-Id: I6b093c4dcb7f9286b156fe8d2cef54d030969840
Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit 327b2b35c527d2ec6c8de4fdebb71322c0f085fb)