From patchwork Tue Apr 28 09:40:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 6287411 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 022B79F859 for ; Tue, 28 Apr 2015 09:51:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2DFB7201ED for ; Tue, 28 Apr 2015 09:51:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 33A7720306 for ; Tue, 28 Apr 2015 09:51:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932454AbbD1JvX (ORCPT ); Tue, 28 Apr 2015 05:51:23 -0400 Received: from smtp-out-223.synserver.de ([212.40.185.223]:1098 "EHLO smtp-out-223.synserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932510AbbD1JvX (ORCPT ); Tue, 28 Apr 2015 05:51:23 -0400 Received: (qmail 30740 invoked by uid 0); 28 Apr 2015 09:40:21 -0000 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 30640 Received: from p4fde67af.dip0.t-ipconnect.de (HELO lars-adi-laptop.analog.com) [79.222.103.175] by 217.119.54.87 with SMTP; 28 Apr 2015 09:40:21 -0000 From: Lars-Peter Clausen To: Ulf Hansson Cc: Mike Looijmans , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, Lars-Peter Clausen Subject: [PATCH 1/2] mmc: sdhci: Add quirk to disable write-protect detection Date: Tue, 28 Apr 2015 11:40:19 +0200 Message-Id: <1430214020-16816-1-git-send-email-lars@metafoo.de> X-Mailer: git-send-email 1.8.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It is not uncommon to see systems where there is no physical write-protect signal (e.g. when using eMMC or microSD cards). Some SDHCI controllers may have bogus data in the SDHCI_WRITE_PROTECT of the SDHCI_PRESENT_STATE register on such systems. Add a new quirk which disables reading of the write-protect status when set. Signed-off-by: Lars-Peter Clausen --- drivers/mmc/host/sdhci.c | 3 +++ drivers/mmc/host/sdhci.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index c80287a..7448757 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1719,6 +1719,9 @@ static int sdhci_get_ro(struct mmc_host *mmc) struct sdhci_host *host = mmc_priv(mmc); int ret; + if (host->quirks2 & SDHCI_QUIRK2_DISABLE_WRITE_PROTECT) + return 0; + sdhci_runtime_pm_get(host); ret = sdhci_do_get_ro(host); sdhci_runtime_pm_put(host); diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index e639b7f..62615e1 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -409,6 +409,8 @@ struct sdhci_host { #define SDHCI_QUIRK2_SUPPORT_SINGLE (1<<13) /* Controller broken with using ACMD23 */ #define SDHCI_QUIRK2_ACMD23_BROKEN (1<<14) +/* Write protect signal is not wired, data in SDHCI_PRESENT_STATE is bogus */ +#define SDHCI_QUIRK2_DISABLE_WRITE_PROTECT (1<<15) int irq; /* Device IRQ */ void __iomem *ioaddr; /* Mapped address */