[U-Boot] [PATCH 1/2] mmc: Avoid redundant switching to 1-bit bus width for MMC cards

Pantelis Antoniou pantelis.antoniou at gmail.com
Mon Jan 19 15:42:49 CET 2015


Hi Andrew,

> On Dec 25, 2014, at 18:22 , Andrew Gabbasov <andrew_gabbasov at mentor.com> wrote:
> 
> If all the commands switching an MMC card to 4- or 8-bit bus width fail,
> and the bus width for the controller and the driver is still set
> to default 1 bit, there is no need to send one more command to switch
> the card to 1-bit bus width. Also, if the card or host controller do not
> support wider bus widths, there is no need to send a switch command at all.
> 
> However, if one of switch commands succeeds, but the subsequent ext_csd
> fields comparison fails, the card should be switched to some other bus width
> (next in the list for the loop), or to default 1-bit bus width as a last
> resort. That's why it would be incorrect to just remove the 1-bit bus width
> case from the list, it should still be processed in some cases.
> 
> Signed-off-by: Andrew Gabbasov <andrew_gabbasov at mentor.com>
> Tested-by: Alexey Brodkin <abrodkin at synopsys.com>
> ---
> drivers/mmc/mmc.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 1eb9c27..c0cf318 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -1139,6 +1139,18 @@ static int mmc_startup(struct mmc *mmc)
> 			unsigned int caps = ext_to_hostcaps[extw];
> 
> 			/*
> +			 * If the bus width is still not changed,
> +			 * don't try to set the default again.
> +			 * Otherwise, recover from switch attempts
> +			 * by switching to 1-bit bus width.
> +			 */
> +			if ((extw == EXT_CSD_BUS_WIDTH_1) &&
> +			    (mmc->bus_width == 1)) {
> +				err = 0;
> +				break;
> +			}
> +
> +			/*
> 			 * Check to make sure the card and controller support
> 			 * these capabilities
> 			 */
> -- 
> 2.1.0
> 

Patch looks fine; taken the liberty to remove the superfluous parentheses at the
if statement.

Regards

— Pantelis



More information about the U-Boot mailing list