Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4514760imd; Tue, 30 Oct 2018 03:18:22 -0700 (PDT) X-Google-Smtp-Source: AJdET5eXe7QlCE+Y4cSG/Jlgrz/2IzX+NlY3+uPmaJjAXojTr/AVXdvFQRUJFu3Ai8GPQd7irbEI X-Received: by 2002:a17:902:7c87:: with SMTP id y7-v6mr4326815pll.232.1540894702605; Tue, 30 Oct 2018 03:18:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540894702; cv=none; d=google.com; s=arc-20160816; b=BLfxGpx3CGDtUtcNnF2hXcxosFNOBcbNYGyHyBTxkyjLfg2a4ZP7B3UM+/FQ5wHMCR SXJfWD1Ut9noW4g9kM3uVUMt3iCztUnt7b/HKDtV1cyjvZHziwFZ7hE7L/6IYOLl2VKu DbASXWpY+k1nMPmWDTxRbMPHQnI6HaEIOEntLrNEXsXsTHaA1IQZCD/4fULT1a41Xkce hwsAsh9JNxs9nJ3oWNS5l3ztmr59a2FgDOImc3hd+zsUzVkZqJqnCfy/5hHRf2vEScac iJyYRfTgnb42+itZif4gFhPMqPo9iwJpqoxtLns5qhKiBENlt0zROzv1TfwddN8kGcCg zJwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=hA34/8jSFon8uNoCZ+yjWxYJ+xwjH0ZT2hCNGrsl9BM=; b=BrE2+9Xttyu/DLdeyQ1+nr5pr4FQsmlTriXhgqYM/VTbS5TmTqEozqgHVQLIJI4NDe 48e7GB7axF+EY1FKAZkbhdTVQU1osPwBW6xA9JimKuywkwn4wromu4ohURY2l7RDWp/Z VdFOhKR2TdqemKY8bXpm+8sr/8gUwuaZl9Ttkyr6i6CbD/Aupf+5q+GDKQSvPoNe83tP HOwBul7nurPlzxf6mKuPimQDOxP3K5f1ixzPQfFbBDxWrFLk6lE56qWkiVLrBA2/4ggr spZTzusOMi+nxDJhPJxB2y3VsRkKiNHN+5JkQaxYwETOpd0pTcCxy/S1A1xqcm9k/R6r +stw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g9-v6si22170379plo.328.2018.10.30.03.18.06; Tue, 30 Oct 2018 03:18:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727265AbeJ3TK2 (ORCPT + 99 others); Tue, 30 Oct 2018 15:10:28 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:44637 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726523AbeJ3TK2 (ORCPT ); Tue, 30 Oct 2018 15:10:28 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w9UAEYL6014434; Tue, 30 Oct 2018 11:16:59 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2nen67gbpa-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 30 Oct 2018 11:16:59 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 19B6434; Tue, 30 Oct 2018 10:16:58 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id DD2372991; Tue, 30 Oct 2018 10:16:57 +0000 (GMT) Received: from SAFEX1HUBCAS23.st.com (10.75.90.47) by SAFEX1HUBCAS21.st.com (10.75.90.44) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 30 Oct 2018 11:16:57 +0100 Received: from lmecxl0923.lme.st.com (10.48.0.237) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 30 Oct 2018 11:16:57 +0100 From: Ludovic Barre To: Ulf Hansson , Rob Herring CC: , Maxime Coquelin , Alexandre Torgue , , , , , , Ludovic Barre Subject: [PATCH] mmc: mmci: add variant property to send stop cmd if a command fail Date: Tue, 30 Oct 2018 11:16:29 +0100 Message-ID: <1540894589-4004-1-git-send-email-ludovic.Barre@st.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.48.0.237] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-30_07:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ludovic Barre The mmc framework follows the requirement of SD_Specification: the STOP_TRANSMISSION is sent on multiple write/read commands and the stop command (alone), not needed on other ADTC commands. But, if an error happens on command or data step, some variants require a stop command "STOP_TRANSMISION" to clear the DPSM "Data Path State Machine". If it's not done the next data command freezes hardware block. Needed to support the STM32 sdmmc variant. Signed-off-by: Ludovic Barre --- drivers/mmc/host/mmci.c | 33 +++++++++++++++++++++++++++++++++ drivers/mmc/host/mmci.h | 4 ++++ 2 files changed, 37 insertions(+) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 19650ed..ecedca3 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -57,6 +58,8 @@ void sdmmc_variant_init(struct mmci_host *host); #else static inline void sdmmc_variant_init(struct mmci_host *host) {} #endif +static void +mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c); static unsigned int fmax = 515633; @@ -274,6 +277,7 @@ static struct variant_data variant_stm32_sdmmc = { .cmdreg_lrsp_crc = MCI_CPSM_STM32_LRSP_CRC, .cmdreg_srsp_crc = MCI_CPSM_STM32_SRSP_CRC, .cmdreg_srsp = MCI_CPSM_STM32_SRSP, + .cmdreg_stop = MCI_CPSM_STM32_CMDSTOP, .data_cmd_enable = MCI_CPSM_STM32_CMDTRANS, .irq_pio_mask = MCI_IRQ_PIO_STM32_MASK, .datactrl_first = true, @@ -574,6 +578,24 @@ void mmci_dma_error(struct mmci_host *host) static void mmci_request_end(struct mmci_host *host, struct mmc_request *mrq) { + /* + * If an error happens on command or data step, some variants + * require a stop command to reinit the DPSM. + * If it's not done the next data command freeze hardware block. + */ + if (host->variant->cmdreg_stop) { + u32 dpsm; + + dpsm = readl_relaxed(host->base + MMCISTATUS); + dpsm &= MCI_STM32_DPSMACTIVE; + + if (dpsm && ((mrq->cmd && mrq->cmd->error) || + (mrq->data && mrq->data->error))) { + mmci_start_command(host, &host->stop_abort, 0); + return; + } + } + writel(0, host->base + MMCICOMMAND); BUG_ON(host->data); @@ -1106,6 +1128,10 @@ mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c) mmci_reg_delay(host); } + if (host->variant->cmdreg_stop && + cmd->opcode == MMC_STOP_TRANSMISSION) + c |= host->variant->cmdreg_stop; + c |= cmd->opcode | host->variant->cmdreg_cpsm_enable; if (cmd->flags & MMC_RSP_PRESENT) { if (cmd->flags & MMC_RSP_136) @@ -1957,6 +1983,13 @@ static int mmci_probe(struct amba_device *dev, mmc->max_busy_timeout = 0; } + /* prepare the stop command, used to abort and reinitialized the DPSM */ + if (variant->cmdreg_stop) { + host->stop_abort.opcode = MMC_STOP_TRANSMISSION; + host->stop_abort.arg = 0; + host->stop_abort.flags = MMC_RSP_R1B | MMC_CMD_AC; + } + mmc->ops = &mmci_ops; /* We support these PM capabilities. */ diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h index ec13d90..afb6ec4 100644 --- a/drivers/mmc/host/mmci.h +++ b/drivers/mmc/host/mmci.h @@ -166,6 +166,7 @@ #define MCI_ST_CEATAEND (1 << 23) #define MCI_ST_CARDBUSY (1 << 24) /* Extended status bits for the STM32 variants */ +#define MCI_STM32_DPSMACTIVE BIT(12) #define MCI_STM32_BUSYD0 BIT(20) #define MMCICLEAR 0x038 @@ -269,6 +270,7 @@ struct mmci_host; * @cmdreg_lrsp_crc: enable value for long response with crc * @cmdreg_srsp_crc: enable value for short response with crc * @cmdreg_srsp: enable value for short response without crc + * @cmdreg_stop: enable value for stop and abort transmission * @datalength_bits: number of bits in the MMCIDATALENGTH register * @fifosize: number of bytes that can be written when MMCI_TXFIFOEMPTY * is asserted (likewise for RX) @@ -322,6 +324,7 @@ struct variant_data { unsigned int cmdreg_lrsp_crc; unsigned int cmdreg_srsp_crc; unsigned int cmdreg_srsp; + unsigned int cmdreg_stop; unsigned int datalength_bits; unsigned int fifosize; unsigned int fifohalfsize; @@ -384,6 +387,7 @@ struct mmci_host { void __iomem *base; struct mmc_request *mrq; struct mmc_command *cmd; + struct mmc_command stop_abort; struct mmc_data *data; struct mmc_host *mmc; struct clk *clk; -- 2.7.4