From patchwork Wed Jun 28 13:35:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 9814321 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 81426603F2 for ; Wed, 28 Jun 2017 13:35:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 738A228511 for ; Wed, 28 Jun 2017 13:35:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6723E28549; Wed, 28 Jun 2017 13:35:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC0E428511 for ; Wed, 28 Jun 2017 13:35:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751874AbdF1Nf3 (ORCPT ); Wed, 28 Jun 2017 09:35:29 -0400 Received: from mail-it0-f43.google.com ([209.85.214.43]:37791 "EHLO mail-it0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752007AbdF1NfP (ORCPT ); Wed, 28 Jun 2017 09:35:15 -0400 Received: by mail-it0-f43.google.com with SMTP id m84so33399768ita.0 for ; Wed, 28 Jun 2017 06:35:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Pv8ub8wsRKJkA262Lw6zCgorPhSPw4DwkAyy6hGqghs=; b=grZ63XZvoJ+eUWSk+r4/6f5Oq0jr0t8uYBynhF1rohKkU/ZfaTRInfp6cFt9XogUxB q2dxUZn5/qqeDZ+cr6QAU0Q9QO4oS8TAYl3FNiGM9T2tm3KqnPCuPJwe1n9yWREloSNM yrkViIMNzJ3IMcjIh5mV+U9sMcHTv+ndEAYxM= 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; bh=Pv8ub8wsRKJkA262Lw6zCgorPhSPw4DwkAyy6hGqghs=; b=LdMR4j36Njcndg5KXBydayflO9QH63dyCtsU8LQOFOp7xlqVVlfQfyIBTimUPgNb62 FZPkLTQ0M8pSAGhwBL8HkNgN6yiBHw1Bh0Up6E5ka1hoWCtkyWDBeMEI2EWjQI7cAMog h/0OPxd7oRvJvGRb86HjhbFrvfd6IJjZtLvPP5f4DMccj7mIpLMSMweXHguhbpnyBnE/ xodIpv3rJ4NB6c8AqNpp+QN6aYUnMiH6FHkJfWr2JuxNM9Kn71MrSf/N7ry/g3+loEbl kjPczcNbEgh8eZDw0n7/1QdUjfI++wZxUklxoG2lFYRHQUvgrDUp8X1R7RojtbjyrShC 60og== X-Gm-Message-State: AKS2vOwTWzhIczjPrv6l0RT9UoNrUezri4A3w5edqQ0++bfiG9sBk+XM fmN/6IsAagmtlMWX X-Received: by 10.36.163.198 with SMTP id p189mr7560833ite.64.1498656914892; Wed, 28 Jun 2017 06:35:14 -0700 (PDT) Received: from localhost.localdomain (static.8.26.4.46.clients.your-server.de. [46.4.26.8]) by smtp.gmail.com with ESMTPSA id h76sm2859553ith.24.2017.06.28.06.35.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Jun 2017 06:35:14 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: Adrian Hunter , Ulf Hansson Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Srinivas Kandagatla Subject: [RFC PATCH 1/2] mmc: sdhci: add quirk SDHCI_QUIRK2_BROKEN_SDMA_BOUNDARY_BUFFER Date: Wed, 28 Jun 2017 15:35:03 +0200 Message-Id: <20170628133504.17422-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170628133504.17422-1-srinivas.kandagatla@linaro.org> References: <20170628133504.17422-1-srinivas.kandagatla@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Srinivas Kandagatla This patch adds quirk to sdhci controllers which are broken when HOST SDMA Buffer Boundary is programmed in Block Size Register (0x04) when using ADMA. Qualcomm sdhci controller is one of such type, writing to this bits is un-supported. Signed-off-by: Srinivas Kandagatla --- drivers/mmc/host/sdhci.c | 24 ++++++++++++++++++------ drivers/mmc/host/sdhci.h | 2 ++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index ecd0d4350e8a..d68ff1955761 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -765,6 +765,20 @@ static void sdhci_set_timeout(struct sdhci_host *host, struct mmc_command *cmd) } } +static void sdhci_set_blk_size_reg(struct sdhci_host *host, + unsigned int sdma_boundary, + unsigned int blksz) +{ + if ((host->quirks2 & SDHCI_QUIRK2_BROKEN_SDMA_BOUNDARY_BUFFER) && + (host->flags & SDHCI_USE_ADMA)) { + sdhci_writew(host, SDHCI_MAKE_BLKSZ(0, blksz), + SDHCI_BLOCK_SIZE); + } else { + sdhci_writew(host, SDHCI_MAKE_BLKSZ(sdma_boundary, blksz), + SDHCI_BLOCK_SIZE); + } +} + static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd) { u8 ctrl; @@ -897,8 +911,7 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd) sdhci_set_transfer_irqs(host); /* Set the DMA boundary value and block size */ - sdhci_writew(host, SDHCI_MAKE_BLKSZ(SDHCI_DEFAULT_BOUNDARY_ARG, - data->blksz), SDHCI_BLOCK_SIZE); + sdhci_set_blk_size_reg(host, SDHCI_DEFAULT_BOUNDARY_ARG, data->blksz); sdhci_writew(host, data->blocks, SDHCI_BLOCK_COUNT); } @@ -2052,9 +2065,9 @@ static void sdhci_send_tuning(struct sdhci_host *host, u32 opcode) */ if (cmd.opcode == MMC_SEND_TUNING_BLOCK_HS200 && mmc->ios.bus_width == MMC_BUS_WIDTH_8) - sdhci_writew(host, SDHCI_MAKE_BLKSZ(7, 128), SDHCI_BLOCK_SIZE); + sdhci_set_blk_size_reg(host, SDHCI_DEFAULT_BOUNDARY_ARG, 128); else - sdhci_writew(host, SDHCI_MAKE_BLKSZ(7, 64), SDHCI_BLOCK_SIZE); + sdhci_set_blk_size_reg(host, SDHCI_DEFAULT_BOUNDARY_ARG, 64); /* * The tuning block is sent by the card to the host controller. @@ -2998,8 +3011,7 @@ void sdhci_cqe_enable(struct mmc_host *mmc) ctrl |= SDHCI_CTRL_ADMA32; sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL); - sdhci_writew(host, SDHCI_MAKE_BLKSZ(SDHCI_DEFAULT_BOUNDARY_ARG, 512), - SDHCI_BLOCK_SIZE); + sdhci_set_blk_size_reg(host, SDHCI_DEFAULT_BOUNDARY_ARG, 512); /* Set maximum timeout */ sdhci_writeb(host, 0xE, SDHCI_TIMEOUT_CONTROL); diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 0469fa191493..9a1343509bb5 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -435,6 +435,8 @@ struct sdhci_host { #define SDHCI_QUIRK2_ACMD23_BROKEN (1<<14) /* Broken Clock divider zero in controller */ #define SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN (1<<15) +/* Controller doesn't support sdma boundray buffer setup when using ADMA */ +#define SDHCI_QUIRK2_BROKEN_SDMA_BOUNDARY_BUFFER (1<<16) int irq; /* Device IRQ */ void __iomem *ioaddr; /* Mapped address */