From patchwork Wed Feb 6 13:10:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1037492 X-Patchwork-Delegate: van.freenix@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="mK38Glqb"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43vhdz4nk4z9s3x for ; Thu, 7 Feb 2019 00:11:03 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 1C94BC21FA3; Wed, 6 Feb 2019 13:11:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A04F9C21F90; Wed, 6 Feb 2019 13:10:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 17861C21F91; Wed, 6 Feb 2019 13:10:56 +0000 (UTC) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by lists.denx.de (Postfix) with ESMTPS id AD5EDC21F90 for ; Wed, 6 Feb 2019 13:10:56 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id t200so2669472wmt.0 for ; Wed, 06 Feb 2019 05:10:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Riv4rbBO9BxkiIXoop0qqj+FPtRLegtJlBcZJ2GtC14=; b=mK38Glqb4T9jJtADPLKEuURO2aSd5y2wf9FxRua03YI3D5tPw0YOhOQ0/WMsq8GrgX XqM9jkLFkCSMtDqvXmEL95wpRsAtm8LDwip6SQrp+MffGR1Dn5aKwI7gW9/f9n/eqlTM 0iAY5ah8e+j/Mxb0MT0dkCAn0XMkpqpfWPzCBJK8skzpQe24SOEltxst8KOlN0NBTiBC CYL9NhQhLZqeRUgyHuiaSSBRkyixiH503quCMcxE1fAltapQ1bJkQsPrFJBKJkInAj2T /hE1Fysr6TGNmOxfiukwD8utp8Yzt7v3X04jqPlOvsLS/hKJZY6GCnPY+rpMG3oHNMK1 Sy1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Riv4rbBO9BxkiIXoop0qqj+FPtRLegtJlBcZJ2GtC14=; b=RugoDQivpkISZC7H9NDgWbVwlA0kkRZ79CuNputV9jU1j9TjfoFS1KLby9sf0i+uhS KH2jYIObBAyi4baL8PGmX0cwhACtrrr39+guJ0yTCxlhv+XXVLwgrsPSiZyvT+L8G8cT iSXzHAFTdk/x/+LaSuaONiFkB7jcNEb5Gjkh5W49Kav6V5BU2dmR4UHC80bgqYzLkFLF 02bHASVgEOF2aHsZaMO8RVHZfRqTjITPnGf+RdM55zMu2/FgbrBV0+bS25GtFbN9WrYt dw0grwn4wvbafTy2yWrRoisb8IAQNXncDKZsCKyF9r5/w5wh5o6PKUw7p98tQrQRvNdb va+w== X-Gm-Message-State: AHQUAub7tsCjtmnmOHFXCCBNu571Q82aY+n0s2OxUkSTjiiAMaAt1J9V V4YMP/R1C3tSVUTMK33qjQmPDoB7 X-Google-Smtp-Source: AHgI3IYLnur8Xv3RA5CW4I+97p5DTYEDah6teau2UgPf5UzGq9p/3NiC1nI4lhRY2iiUm8FyB1iwTg== X-Received: by 2002:a1c:2314:: with SMTP id j20mr3119928wmj.142.1549458655958; Wed, 06 Feb 2019 05:10:55 -0800 (PST) Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz. [86.49.110.70]) by smtp.gmail.com with ESMTPSA id f22sm10787097wmj.26.2019.02.06.05.10.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Feb 2019 05:10:54 -0800 (PST) From: Marek Vasut X-Google-Original-From: Marek Vasut To: u-boot@lists.denx.de Date: Wed, 6 Feb 2019 14:10:51 +0100 Message-Id: <20190206131052.24334-1-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Cc: Marek Vasut Subject: [U-Boot] [PATCH 1/2] mmc: Export {sd,mmc}_select_mode_and_width() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Make {sd,mmc}_select_mode_and_width() functions available to drivers, so that they can call these functions to reconfigure SD/MMC mode if necessary. Signed-off-by: Marek Vasut --- drivers/mmc/mmc.c | 8 ++------ drivers/mmc/mmc_private.h | 4 ++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 84d157ff40..c7730c9233 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -23,10 +23,6 @@ static int mmc_set_signal_voltage(struct mmc *mmc, uint signal_voltage); static int mmc_power_cycle(struct mmc *mmc); -#if !CONFIG_IS_ENABLED(MMC_TINY) -static int mmc_select_mode_and_width(struct mmc *mmc, uint card_caps); -#endif - #if !CONFIG_IS_ENABLED(DM_MMC) #if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) @@ -1643,7 +1639,7 @@ static const struct mode_width_tuning sd_modes_by_pref[] = { mwt++) \ if (caps & MMC_CAP(mwt->mode)) -static int sd_select_mode_and_width(struct mmc *mmc, uint card_caps) +int sd_select_mode_and_width(struct mmc *mmc, uint card_caps) { int err; uint widths[] = {MMC_MODE_4BIT, MMC_MODE_1BIT}; @@ -1912,7 +1908,7 @@ static int mmc_select_hs400(struct mmc *mmc) ecbv++) \ if ((ddr == ecbv->is_ddr) && (caps & ecbv->cap)) -static int mmc_select_mode_and_width(struct mmc *mmc, uint card_caps) +int mmc_select_mode_and_width(struct mmc *mmc, uint card_caps) { int err; const struct mode_width_tuning *mwt; diff --git a/drivers/mmc/mmc_private.h b/drivers/mmc/mmc_private.h index f49b6eb573..7198baf4fd 100644 --- a/drivers/mmc/mmc_private.h +++ b/drivers/mmc/mmc_private.h @@ -18,6 +18,10 @@ extern int mmc_set_blocklen(struct mmc *mmc, int len); #ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT void mmc_adapter_card_type_ident(void); #endif +#if !CONFIG_IS_ENABLED(MMC_TINY) +int sd_select_mode_and_width(struct mmc *mmc, uint card_caps); +int mmc_select_mode_and_width(struct mmc *mmc, uint card_caps); +#endif #if CONFIG_IS_ENABLED(BLK) ulong mmc_bread(struct udevice *dev, lbaint_t start, lbaint_t blkcnt, From patchwork Wed Feb 6 13:10:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1037493 X-Patchwork-Delegate: van.freenix@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LPa0Ggck"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43vhfH6sNxz9s3x for ; Thu, 7 Feb 2019 00:11:19 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id A1B51C21F9D; Wed, 6 Feb 2019 13:11:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 3566FC21F90; Wed, 6 Feb 2019 13:11:10 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 04AD8C21F9F; Wed, 6 Feb 2019 13:11:05 +0000 (UTC) Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by lists.denx.de (Postfix) with ESMTPS id 29218C21F9B for ; Wed, 6 Feb 2019 13:11:00 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id m1so2420385wml.2 for ; Wed, 06 Feb 2019 05:11:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p/O0jvXvmKOPsP0f9g/wpxv2L2nNKrqLXU1HuH4Fa6k=; b=LPa0Ggckigvdess66uwroGfLgjLhI8ycf1wBjJRZa2GsIwiJkcFPyH35JZsJAyaeq9 Tt7y9r8+PF0LKCxNXnuY2KuxCPdWTowNv02QdaB4vFC016cg9dd+bEeIu33+k+F4z4W/ HKl55ccOVAZbO+1bOfMzN9ZY3aOmqgRMpmRq9rJwaKbC7mOJb4XXqxAgt2t2s30AFBx3 0z5+89+F5w2fbRtGM+OdclpQ0JlIIGq6MMWPh8LMO4VzznAEFZ37jKCGHm04XnNoBk1e 7h3/1sNz1OmWOg7oGz9OntaIdC98MGy4IOzrCoAAJYgMqi3U7IdoAo8/yfbMbuOrkVVB ePAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p/O0jvXvmKOPsP0f9g/wpxv2L2nNKrqLXU1HuH4Fa6k=; b=qkj1Eluwklp3cwVi2Hvlc8fOsgjJTtmSkC01eMSrRFYN7+MMLrspOQ81IatsRSx59j xazcPM8cUYUozA8zUZdn3rvVXEbfyE3wxPyi7CFlDzhgEZ6JtHgeViMIirD/6ajJrCH3 NpCnoFnV40bEUdnhHM0DLtL1XnnDn46wKAeTom9lCQhW157Qu+wLIBqzQFZR0iFtjC58 9mLm6A1xxJicMss72usUwebAQIW8Nh+AOkONMVav+gfxZ7BN881QZGDVX98Vqwqdb6Nf YVEuU+MxJS6btun4iL6BcxVBbumbFJ968pc4DCNe+IOOHcPXDQ8cX7bKHgdlkJh94WGs 1kQw== X-Gm-Message-State: AHQUAuZf5ReAVqpcc79JnDYVjoHuPoxYiKW0oIEQ3swhJ5vyW8Ldqhb2 LVjJG2YiT93G2hGc/ZgEqleyhVt5 X-Google-Smtp-Source: AHgI3IbeKTtxDh/coQqsTSlqEKz51sJxGfNltPkEgO4j6O+g+kUJphvmUVtumKn9MoNM2E4YeA9hig== X-Received: by 2002:a1c:7408:: with SMTP id p8mr2221475wmc.119.1549458659231; Wed, 06 Feb 2019 05:10:59 -0800 (PST) Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz. [86.49.110.70]) by smtp.gmail.com with ESMTPSA id f22sm10787097wmj.26.2019.02.06.05.10.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Feb 2019 05:10:58 -0800 (PST) From: Marek Vasut X-Google-Original-From: Marek Vasut To: u-boot@lists.denx.de Date: Wed, 6 Feb 2019 14:10:52 +0100 Message-Id: <20190206131052.24334-2-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190206131052.24334-1-marek.vasut+renesas@gmail.com> References: <20190206131052.24334-1-marek.vasut+renesas@gmail.com> MIME-Version: 1.0 Cc: Marek Vasut Subject: [U-Boot] [PATCH 2/2] mmc: tmio: renesas: Downgrade SD/MMC from UHS/HS200/HS400 modes before boot X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Older kernel versions cannot handle situation where either the eMMC is left in HS200/HS400 mode or SD in UHS modes by the bootloader and can misbehave. Downgrade the eMMC to HS/HS52 mode and/or SD to non-UHS mode before boot to allow such older kernels to work with modern U-Boot. Signed-off-by: Marek Vasut Cc: Masahiro Yamada --- drivers/mmc/renesas-sdhi.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c index a556acd5cb..d78f91f937 100644 --- a/drivers/mmc/renesas-sdhi.c +++ b/drivers/mmc/renesas-sdhi.c @@ -15,6 +15,7 @@ #include #include +#include "mmc_private.h" #include "tmio-common.h" #if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) || \ @@ -530,13 +531,38 @@ static int renesas_sdhi_probe(struct udevice *dev) return ret; } +int renesas_sdhi_remove(struct udevice *dev) +{ + struct mmc *mmc = mmc_get_mmc_dev(dev); + u32 caps_filtered; + + if (!mmc->has_init) + return 0; + + if (IS_SD(mmc)) { + caps_filtered = mmc->card_caps & + ~(MMC_CAP(UHS_SDR12) | MMC_CAP(UHS_SDR25) | + MMC_CAP(UHS_SDR50) | MMC_CAP(UHS_DDR50) | + MMC_CAP(UHS_SDR104)); + + return sd_select_mode_and_width(mmc, caps_filtered); + } else { + caps_filtered = mmc->card_caps & + ~(MMC_CAP(MMC_HS_200) | MMC_CAP(MMC_HS_400)); + + return mmc_select_mode_and_width(mmc, caps_filtered); + } +} + U_BOOT_DRIVER(renesas_sdhi) = { .name = "renesas-sdhi", .id = UCLASS_MMC, .of_match = renesas_sdhi_match, .bind = tmio_sd_bind, .probe = renesas_sdhi_probe, + .remove = renesas_sdhi_remove, .priv_auto_alloc_size = sizeof(struct tmio_sd_priv), .platdata_auto_alloc_size = sizeof(struct tmio_sd_plat), .ops = &renesas_sdhi_ops, + .flags = DM_FLAG_OS_PREPARE, };