From patchwork Tue Feb 16 04:06:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 8320901 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2444AC02AA for ; Tue, 16 Feb 2016 04:04:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3894B202E6 for ; Tue, 16 Feb 2016 04:04:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 450DC202F0 for ; Tue, 16 Feb 2016 04:04:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751750AbcBPEDy (ORCPT ); Mon, 15 Feb 2016 23:03:54 -0500 Received: from mail-pf0-f180.google.com ([209.85.192.180]:34625 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751635AbcBPEDx (ORCPT ); Mon, 15 Feb 2016 23:03:53 -0500 Received: by mail-pf0-f180.google.com with SMTP id x65so97501023pfb.1; Mon, 15 Feb 2016 20:03:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:date:message-id:subject; bh=HC7MQKSYhFiw+rO/e7/7VdSOEvDtQHXg8tWArrsWlXM=; b=IzsWi85lJQVzWJk3S0Qu3qn0nCe9y9WxVBu8SrTc/ePZp+imFJJL3Ded79YPntsMsy XhnTMsxAULEgsx8h/nXkcCn5/Tvvcz67YHgEcEVBV3zusP7Cxea6sVP64oe0euRInwz8 WrJmZfmyLLULTXdbIj9Q6ercF15v4flIerAoaCYs/ufecGBawE56KS6JHI6T7QAbo6V2 mAw1C9JePHgbyoJkT18fa8yXCZgjX0TkreAbMv5xfpZkt9mQkBiLHEfgbTd1rqBTFegX 9HtW5fY+3n0K9exswN3BXSHJuEn6Ezx1btjXMGcVtmYhWJOfF22X7996PkwOPvE+Ft/y nSwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:date:message-id:subject; bh=HC7MQKSYhFiw+rO/e7/7VdSOEvDtQHXg8tWArrsWlXM=; b=HpAmMK1vT4bqwK+aG3I8iqWt9xoVBi76wgNTUFSuDBMGZJZdHbJoMVRLu+2vppFieL 47DMCCSAbhOHMvevcuqI83rJG7BDoaZWp13H6/zuGkWzRi5CBxtTBv4ZAt/1nj/wtTfg isVoN+RYlSeP5Sbp5t1OXJklpbLNPl1c+UxbzCAF978UWt6IEwlPmQ44r42aCnsqj2k5 BsoDAuiAQ69YSt72HvmNn9ilYC9Mv/+N4S/M6ZnNqYTxBxnDSBqKwJngFk6DQ6Z6OgmX u4OLS1xWLxwfWzpxlDwSj95PLBJIGQTQNFIEcO79DWTXVWZ8v/fYflC+c58Lom8paBpC ZG4A== X-Gm-Message-State: AG10YOSe3dAOtGvafr/OB6417ehfalBSDz49aFtwntPeYEBEpm3D6He2e53zL97p0G9LHQ== X-Received: by 10.98.70.211 with SMTP id o80mr27959971pfi.124.1455595433147; Mon, 15 Feb 2016 20:03:53 -0800 (PST) Received: from [127.0.0.1] (s214090.ppp.asahi-net.or.jp. [220.157.214.90]) by smtp.gmail.com with ESMTPSA id l24sm29946178pfb.73.2016.02.15.20.03.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Feb 2016 20:03:52 -0800 (PST) From: Magnus Damm To: linux-mmc@vger.kernel.org Cc: ulf.hansson@linaro.org, swarren@nvidia.com, linux-kernel@vger.kernel.org, eha@doredevelopment.dk, adrian.hunter@intel.com, Magnus Damm Date: Tue, 16 Feb 2016 13:06:41 +0900 Message-Id: <20160216040641.31979.6202.sendpatchset@little-apple> Subject: [PATCH] mmc: mmc_spi: Add Card Detect comments and fix CD GPIO case 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 From: Magnus Damm This patch adds comments to describe the various ways card detection may be implemented and when polling is needed. Also a fix is included to prevent the MMC SPI driver from polling when a CD GPIO that supports interrupts is specified using the gpios DT property (case 1). Without this patch the DT node below results in the following output: spi_gpio: spi-gpio { /* SD2 @ CN12 */ compatible = "spi-gpio"; #address-cells = <1>; #size-cells = <0>; gpio-sck = <&gpio6 16 GPIO_ACTIVE_HIGH>; gpio-mosi = <&gpio6 17 GPIO_ACTIVE_HIGH>; gpio-miso = <&gpio6 18 GPIO_ACTIVE_HIGH>; num-chipselects = <1>; cs-gpios = <&gpio6 21 GPIO_ACTIVE_LOW>; status = "okay"; spi@0 { compatible = "mmc-spi-slot"; reg = <0>; voltage-ranges = <3200 3400>; spi-max-frequency = <25000000>; gpios = <&gpio6 22 GPIO_ACTIVE_LOW>; /* CD */ }; }; # dmesg | grep mmc mmc_spi spi32766.0: SD/MMC host mmc0, no WP, no poweroff, cd polling mmc0: host does not support reading read-only switch, assuming write-enable mmc0: new SDHC card on SPI mmcblk0: mmc0:0000 SU04G 3.69 GiB mmcblk0: p1 With this patch applied the "cd polling" portion above disappears. Signed-off-by: Magnus Damm --- Developed on top of renesas-drivers-2016-02-09-v4.5-rc3 which simply put is v4.5-rc3 + selected linux-next trees. drivers/mmc/host/mmc_spi.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 0001/drivers/mmc/host/mmc_spi.c +++ work/drivers/mmc/host/mmc_spi.c 2016-02-16 12:47:47.900513000 +0900 @@ -1437,11 +1437,25 @@ static int mmc_spi_probe(struct spi_devi if (status != 0) goto fail_add_host; + /* Card detection in case of DT is supported in several ways: + * 1) GPIO with interrupt support using "gpios" DT property. + * 2) GPIO without interrupt support using "gpios" DT property. + * 3) Interrupt only using "interrupt-parent/interrupts" DT properties. + * 4) Both "gpios" and "interrupt-parent/interrupts" DT properties. + * 5) Nothing specified. + * For case 2 and 5 above polling is required. + */ if (host->pdata && host->pdata->flags & MMC_SPI_USE_CD_GPIO) { status = mmc_gpio_request_cd(mmc, host->pdata->cd_gpio, host->pdata->cd_debounce); if (status != 0) goto fail_add_host; + + /* The platform has a CD GPIO signal that may support + * interrupts, so let mmc_gpiod_request_cd_irq() decide + * if polling is needed or not. + */ + mmc->caps &= ~MMC_CAP_NEEDS_POLL; mmc_gpiod_request_cd_irq(mmc); }