Commit Graph

1072 Commits

Author SHA1 Message Date
Jason Zhu 6221c090c7 dm: mmc: add more conditions to judge whether print the info
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: I94f60c9102c8708d7fa84e729762bfe2956d4fd5
2021-02-01 10:21:45 +08:00
Jason Zhu 327b5d5723 dm: mmc: print the cmd index when sending cmd error occur
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: I08aab678c5e539000fadccf4a8ad9e97e3693894
2021-01-21 18:12:47 +08:00
Jason Zhu 34d21c9ad8 UPSTREAM: mmc: dw_mmc: Calculate timeout from transfer length
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)
2021-01-19 16:57:34 +08:00
Jean-Jacques Hiblot 9127fbf440 UPSTREAM: mmc: add a Kconfig option to enable the support for MMC write operations
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)
2021-01-04 17:12:30 +08:00
Jason Zhu d62fa58224 mmc: sdhci: rockchip: reset the clock phase
Reset the clock phase when the frequency is lower than 52MHz.

Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: I49c50779ab5e1103d815cd2be1a7c9603cea397a
2020-12-07 09:20:43 +08:00
Jason Zhu 60238d95dc mmc: sdhci: rockchip: change tapnum to 16
According to the test hadware testing.

Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: I2750a7de9f79807256800868ae53d3fe4a23b2f1
2020-11-14 11:55:39 +08:00
Yifeng Zhao 8d74d6b7d3 drivers: mmc: rockchip: rk3568: config rx clock no inverter for hs200
Signed-off-by: Yifeng Zhao <yifeng.zhao@rock-chips.com>
Change-Id: I426a5c3ee0899fbd54711e13550310f77f8abd3e
2020-11-11 19:48:46 +08:00
Yifeng Zhao 28b3b131e9 drivers: mmc: rockchip: fix phy dll config for hs200
Signed-off-by: Yifeng Zhao <yifeng.zhao@rock-chips.com>
Change-Id: Ie72f2414eca2856102e0a477668ec2729396cd25
2020-11-09 16:10:02 +08:00
Jason Zhu b7b235505b mmc: sdhci: support new phy IP
The new phy IP is designed by rockchip.

Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: I5a84bcc6fff7aaf0bc848cdb70b78a57f471e51e
2020-10-28 15:03:46 +08:00
Jason Zhu 05f3b0ab30 mmc: sdhci: clean up the phy code
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
2020-10-28 15:03:46 +08:00
Jason Zhu 7863dac107 dm: mmc: remove mmc_bread_prepare in mmc_blk_ops
Merge it to mmc_bread() with using op_flag.

Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: I3f63ebf66c43184a134c49a39a62feb2d5ae9821
2020-08-11 09:11:21 +08:00
Jason Zhu 47f7fd3a52 blk/mmc: add function blk_dread_prepare
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
2020-06-16 11:34:02 +08:00
Jason Zhu 33e40bac6a mmc: dw_mmc: set DWMCI_CARDTHRCTL
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
2020-06-02 09:49:38 +08:00
Jason Zhu 2056aa9f86 drivers: mmc: pass the mmc ext_csd to kernel
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: I95dbd0da5d8750e5b19f00a54596ca484f72ecb2
2020-05-06 22:12:30 +08:00
Jason Zhu 479fbf72ee drivers: mmc: use pre-configure set by pre-loader or bootrom
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
2020-04-03 11:34:11 +08:00
Jason Zhu 1a0c3c4ddd mmc: dw_mmc: implement the function board_mmc_dm_reinit
Change-Id: I18409bd6857d3bc8f4268a78593b23b3e19e744f
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2020-02-24 18:20:52 +08:00
Jason Zhu e531136ec7 mmc: avoid reading ext_csd several times
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: Iaf952a4721ea74a1fa55da9f1a3eece5cdcd2c0c
2020-02-24 16:35:30 +08:00
Jason Zhu 1f250d0a05 mmc: support hs200 in spl
Change-Id: I9c25265a2a1e2b10a4e6815c918b6bba750c5df8
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2020-02-24 16:35:26 +08:00
Jason Zhu ace0ade619 mmc: add func mmc_gpio_init_direct in spl
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>
2020-02-24 14:03:43 +08:00
Jason Zhu 444036a7cd dm: mmc: support get MMC order through aliases in spl process
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>
2019-07-29 15:35:17 +08:00
Masahiro Yamada f1ba13f8e2 UPSTREAM: libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h>
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)
2019-07-05 19:33:35 +08:00
Adam Ford 6a35a5ca77 UPSTREAM: Convert CONFIG_APBH_DMA et al to Kconfig
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)
2019-07-05 19:33:35 +08:00
Jon Lin b491b49882 UPSTREAM: wait_bit: use wait_for_bit_le32 and remove wait_for_bit
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>
2019-07-05 19:21:04 +08:00
Jason Zhu 204f7c3926 mmc: dw_mmc: fix sd card power enable errror
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>
2019-04-02 17:44:46 +08:00
Jason Zhu 5743ef647f mmc: dw_mmc: support get_cd in struct dm_mmc_ops
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>
2019-03-28 15:51:05 +08:00
Jason Zhu a0bf35b582 mmc: rpmb: correct MMC_RSP_R1b to MMC_RSP_R1
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>
2019-03-05 11:20:06 +08:00
Masahiro Yamada 0e00a84cde UPSTREAM: libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h>
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>
2018-12-24 17:20:37 +08:00
Ziyuan Xu fafc46378e rockchip: sdhci: print helpful message out explicitly
Change-Id: If51e25ed7e1b321edd06eaa153894ec638a7963a
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-01 11:54:03 +08:00
Jason Zhu ae1f243a7b mmc: delete SEND_STATUS after set-timing in hs200 mode
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>
2018-11-19 15:16:56 +08:00
Ziyuan Xu 9e8ce8162d mmc: distinguish switch command via send_status
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>
2018-11-19 15:16:56 +08:00
Ziyuan Xu 10f01e730f rockchip: sdhci: improve calpad busy trimming
Change-Id: I8326d72d36a6aa58615d8c502881e4d446451a99
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-11-09 17:01:42 +08:00
Jason Zhu 5ef8980810 mmc: dw_mmc: set DWMCI_MSIZE to 6
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>
2018-10-19 15:27:57 +08:00
Jason Zhu c30b51158f mmc: re-init when read error occur
Change-Id: I1cb7e913159c4588e0f5dee2180aa1945504eaf5
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-10-19 15:27:57 +08:00
Jason Zhu 4a6b865662 mmc: dw_mmc: change the strategy of tuning
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>
2018-10-19 15:27:57 +08:00
Jason Zhu e860ec3258 mmc: add init_retry
Use the init_retry when mmc error occur.

Change-Id: I5db56d59d4c1f2ed2744d800f475da228cfcaf69
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-10-19 15:27:57 +08:00
Jason Zhu a59bd218a5 rockchip: sdhci: support hs200&hs400
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>
2018-10-16 15:48:16 +08:00
Jason Zhu 09494d3a1b mmc: add default_phase
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>
2018-10-16 15:25:43 +08:00
Jason Zhu 812df22a14 dm: mmc: add trim erase mode
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>
2018-09-12 17:26:13 +08:00
Kever Yang 1e72694f2c rockchip: dw_mmc: do not print msg when not find sample clock
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>
2018-09-10 11:16:25 +08:00
Jason Zhu a6a1f5f858 mmc: add mmc_can_trim flag
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>
2018-08-13 10:12:52 +08:00
Jason Zhu f7c0370c61 mmc: dw_mmc: fix timeout error
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>
2018-08-06 11:24:09 +08:00
chenfen 850fcf3e04 mmc: sdhci: config controller MMC_TIMING_MMC_HS
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>
2018-08-01 17:18:59 +08:00
chenfen cc0bf5ed98 rockchip: emmc: rk3399: priority to use cru division.
Priority to use cru division is better timing than use controller

division.

Change-Id: I8b7b9a9c99f09407f209fda8df6460136a3105e9
Signed-off-by: chenfen <chenfen@rock-chips.com>
2018-07-31 17:22:33 +08:00
Jason Zhu 60f62d2692 mmc: dw_mmc: print a caution when find ciu-sample fail
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>
2018-07-24 16:15:37 +08:00
Jason Zhu 16cc62c811 mmc: dw_mmc: support mmc hs200
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>
2018-07-23 10:09:03 +08:00
Jason Zhu 08c9dc10f4 mmc: dw_mmc: rockchip: fix get ciu-sample bug
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>
2018-07-18 15:00:33 +08:00
Kever Yang 2f97233324 rockchip: sdhci: phy init convert to use live dt
Change-Id: Iac6f2b6151d977b9ec121828790a1ba75e8c418f
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2018-05-25 11:51:57 +08:00
Kever Yang c85f17a61d Revert "rockchip: rk322x: speed up the emmc and the cpu."
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>
2018-01-17 15:49:28 +08:00
Masahiro Yamada 90aa625c9a treewide: replace with error() with pr_err()
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)
2018-01-17 15:27:28 +08:00
Philipp Tomsich 4ae650e51d UPSTREAM: rockchip: sdhci: Convert to livetree
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)
2018-01-16 18:16:48 +08:00