From patchwork Tue Oct 16 12:02:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marcel Eckert X-Patchwork-Id: 984785 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=none (p=none dis=none) header.from=hsu-hh.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42ZHwk2D7Bz9s8F for ; Wed, 17 Oct 2018 01:38:14 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id DD3B8C21E07; Tue, 16 Oct 2018 14:38:08 +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=none 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 14EFEC21CB1; Tue, 16 Oct 2018 14:38:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 80F27C21CB1; Tue, 16 Oct 2018 12:02:03 +0000 (UTC) Received: from premail.unibw-hamburg.de (mail-sender-5.unibw-hamburg.de [139.11.10.105]) by lists.denx.de (Postfix) with ESMTPS id 3BD2EC21C38 for ; Tue, 16 Oct 2018 12:02:03 +0000 (UTC) Received: from rzav4.unibw-hamburg.de ([139.11.12.54]:47652) by premail.unibw-hamburg.de with esmtp (HSU Mailserver) (envelope-from ) id 1gCO31-0007ZL-35 for u-boot@lists.denx.de; Tue, 16 Oct 2018 14:02:03 +0200 X-IronPort-AV: E=Sophos;i="5.54,388,1534802400"; d="scan'208";a="30792917" Received: from mailcluster-1.unibw-hamburg.de (HELO premail.unibw-hamburg.de) ([139.11.5.101]) by rzav4.unibw-hamburg.de with ESMTP; 16 Oct 2018 14:02:04 +0200 Received: from tipc05.unibw-hamburg.de ([139.11.158.155]:36194 helo=[192.168.1.155]) by premail.unibw-hamburg.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (HSU Mailserver) (envelope-from ) id 1gCO30-0007Yw-Uu for u-boot@lists.denx.de; Tue, 16 Oct 2018 14:02:02 +0200 To: u-boot@lists.denx.de From: Marcel Eckert Message-ID: Date: Tue, 16 Oct 2018 14:02:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 Content-Language: de-LU X-HSU-Virusscan: Routed to first Viruswall X-Brisant: Sender eckert@hsu-hh.de X-HSU-Virusscan: First Viruswall passed X-Authenticated-Sender: 34119/139.11.158.155 X-HSU-Virusscan: Routed to second Viruswall (Cisco Ironport ESAV) X-Brisant: Sender eckert@hsu-hh.de X-Mailman-Approved-At: Tue, 16 Oct 2018 14:38:04 +0000 Subject: [U-Boot] mmc: get mmc_spi working again 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" Trying to migrate to the latest U-Boot version (my old version was u-boot-2016.09.y), mmc_spi command fails with "unable to select a mode". I hunted this down to a rewrite in mmc.c regarding MMC/SD mode handling (d0c221fe7336fc7d9ada57d96f4a8911a3aac041). Current mmc.c tries to perform SD commands (like sd_set_card_speed or sd_select_bus_width) that produce a "illegal command" response from different of my SD-Cards when used in SPI-Mode. Attached patch just skips these illegal command sequences, when mmc_host uses SPI-mode. The patch is a straightforward solution, maybe SPI-mode needs to be added in "enum bus_mode" (see mmc.h) and handled properly in mmc.c. Signed-off-by: Marcel Eckert ---  drivers/mmc/mmc.c | 9 +++++++++  1 file changed, 9 insertions(+) @@ -1332,6 +1335,9 @@ static int sd_select_bus_width(struct mmc *mmc, int w)         int err;         struct mmc_cmd cmd; +       if (mmc_host_is_spi(mmc)) +               return 0; +         if ((w != 4) && (w != 1))                 return -EINVAL; @@ -1375,6 +1381,9 @@ static int sd_read_ssr(struct mmc *mmc)         int timeout = 3;         unsigned int au, eo, et, es; +       if (mmc_host_is_spi(mmc)) +               return 0; +         cmd.cmdidx = MMC_CMD_APP_CMD;         cmd.resp_type = MMC_RSP_R1;         cmd.cmdarg = mmc->rca << 16; diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 585951cd78..d78b58ac77 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1286,6 +1286,9 @@ static int sd_set_card_speed(struct mmc *mmc, enum bus_mode mode)  {         int err; +       if (mmc_host_is_spi(mmc)) +               return 0; +         ALLOC_CACHE_ALIGN_BUFFER(uint, switch_status, 16);         int speed;