Commit c4217568797456bf2db2131a91c565596e88d588

Authored by Marek Vasut
Committed by Haibo Chen
1 parent 4c95f33890

mmc: Do not poll using CMD13 when changing timing

When using CMD6 to switch eMMC card timing from HS200/HS400 to HS/legacy,
do not poll for the completion status using CMD13, but rather wait 50mS.

Once the card receives the CMD6 and starts executing it, the bus is in
undefined state until both the card finishes executing the command and
until the controller switches the bus to matching timing configuration.
During this time, it is not possible to transport any commands or data
across the bus, which includes the CMD13.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Jaehoon Chung <jh80.chung@samsung.com>
(cherry picked from commit 5dbade95cb7ebc1f3a309b00430ebf2b466d7aba)
Signed-off-by: Haibo Chen <haibo.chen@nxp.com>

Showing 1 changed file with 20 additions and 8 deletions Side-by-side Diff

... ... @@ -748,7 +748,8 @@
748 748 return err;
749 749 }
750 750  
751   -int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
  751 +static int __mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value,
  752 + bool send_status)
752 753 {
753 754 struct mmc_cmd cmd;
754 755 int timeout = 1000;
755 756  
756 757  
... ... @@ -764,19 +765,29 @@
764 765 while (retries > 0) {
765 766 ret = mmc_send_cmd(mmc, &cmd, NULL);
766 767  
767   - /* Waiting for the ready status */
768   - if (!ret) {
769   - ret = mmc_send_status(mmc, timeout);
770   - return ret;
  768 + if (ret) {
  769 + retries--;
  770 + continue;
771 771 }
772 772  
773   - retries--;
  773 + if (!send_status) {
  774 + mdelay(50);
  775 + return 0;
  776 + }
  777 +
  778 + /* Waiting for the ready status */
  779 + return mmc_send_status(mmc, timeout);
774 780 }
775 781  
776 782 return ret;
777 783  
778 784 }
779 785  
  786 +int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
  787 +{
  788 + return __mmc_switch(mmc, set, index, value, true);
  789 +}
  790 +
780 791 static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode,
781 792 bool hsdowngrade)
782 793 {
... ... @@ -812,8 +823,9 @@
812 823 default:
813 824 return -EINVAL;
814 825 }
815   - err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,
816   - speed_bits);
  826 +
  827 + err = __mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,
  828 + speed_bits, !hsdowngrade);
817 829 if (err)
818 830 return err;
819 831