From patchwork Wed Jan 15 15:32:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 23239 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D9B82206A0 for ; Wed, 15 Jan 2014 15:32:28 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id lx4sf6613182iec.11 for ; Wed, 15 Jan 2014 07:32:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:cc:subject:references:in-reply-to:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=DNkwxLukQelZTYXKU4jG9Zgestrm0gqx76ibh21Wlpc=; b=LnGtVKXRFdWa6hib+b9UDajytn6sfu8idntUk/KVKvBDvDVAXQAPGF2WOHJD1vS8fh 9Ix58/Lvn+N62emFP+OnQTzdiMw3Pn6+izabW6PGk62AvBML4WL9O7QeceycJIevA8TU dtyo/LNrvM6LYMkGcFoJnw3zVx4ydSx006PmvZ1P5TPEoMLS0QfJ2Tl0Zs6ZFnY98NL8 050PyJK9pcchZejYZ/5QTnNYfkKtDYV6VKK1CjFU5kTqHtAO6vTTihCDuQWBvUMTcXhV ucdPdi08wARrD7GE9f7OOPFAtBJHeTZFxVnu5vy3MYXzmEcLj/bt8Yk2cAwFGReI7jQ4 IzFQ== X-Gm-Message-State: ALoCoQnfiVdAtiFu5QKQNPNkoVKb8DEWneb6KWecM53/zw310JhfXJN94GaCv/z5/TMrtVhs/AXg X-Received: by 10.42.46.3 with SMTP id i3mr834368icf.31.1389799948214; Wed, 15 Jan 2014 07:32:28 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.75.8 with SMTP id y8ls176038qev.86.gmail; Wed, 15 Jan 2014 07:32:28 -0800 (PST) X-Received: by 10.58.118.36 with SMTP id kj4mr2381338veb.2.1389799948090; Wed, 15 Jan 2014 07:32:28 -0800 (PST) Received: from mail-vb0-f41.google.com (mail-vb0-f41.google.com [209.85.212.41]) by mx.google.com with ESMTPS id mj10si1826269vcb.87.2014.01.15.07.32.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Jan 2014 07:32:28 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.41; Received: by mail-vb0-f41.google.com with SMTP id g10so458809vbg.14 for ; Wed, 15 Jan 2014 07:32:28 -0800 (PST) X-Received: by 10.220.178.73 with SMTP id bl9mr1799371vcb.42.1389799948004; Wed, 15 Jan 2014 07:32:28 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp282225ved; Wed, 15 Jan 2014 07:32:27 -0800 (PST) X-Received: by 10.66.217.133 with SMTP id oy5mr3663615pac.46.1389799947056; Wed, 15 Jan 2014 07:32:27 -0800 (PST) Received: from mail-pd0-f176.google.com (mail-pd0-f176.google.com [209.85.192.176]) by mx.google.com with ESMTPS id g5si4027537pav.172.2014.01.15.07.32.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Jan 2014 07:32:27 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.176 is neither permitted nor denied by best guess record for domain of zhangfei.gao@linaro.org) client-ip=209.85.192.176; Received: by mail-pd0-f176.google.com with SMTP id r10so1249262pdi.35 for ; Wed, 15 Jan 2014 07:32:26 -0800 (PST) X-Received: by 10.66.66.202 with SMTP id h10mr3614678pat.70.1389799946524; Wed, 15 Jan 2014 07:32:26 -0800 (PST) Received: from [192.168.3.108] ([124.73.90.72]) by mx.google.com with ESMTPSA id pe3sm8802800pbc.23.2014.01.15.07.32.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Jan 2014 07:32:25 -0800 (PST) Message-ID: <52D6A9FF.3000603@linaro.org> Date: Wed, 15 Jan 2014 23:32:15 +0800 From: zhangfei User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: Seungwon Jeon , 'Kevin Hilman' , 'Sachin Kamat' , 'Chris Ball' , 'Arnd Bergmann' , 'Mike Turquette' , 'Jaehoon Chung' CC: linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, patches@linaro.org Subject: Re: [PATCH] mmc: dw_mmc: fix dw_mci_get_cd References: <1389770159-21125-1-git-send-email-zhangfei.gao@linaro.org> <1389780469-32633-1-git-send-email-zhangfei.gao@linaro.org> <001701cf11e9$25b5fe50$7121faf0$%jun@samsung.com> <52D67A9B.4090607@linaro.org> <001c01cf11ed$039b6270$0ad22750$%jun@samsung.com> <52D6938A.9050806@linaro.org> <002c01cf11ff$6790a8a0$36b1f9e0$%jun@samsung.com> In-Reply-To: <002c01cf11ff$6790a8a0$36b1f9e0$%jun@samsung.com> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: zhangfei.gao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On 01/15/2014 10:38 PM, Seungwon Jeon wrote: >> Hmm, looks you are right. >> Though not see clearly mmc_gpio_get_cd declaratoin, other drivers >> directly set get_cd as mmc_gpio_get_cd. >> .get_cd = mmc_gpio_get_cd >> >> However, in our board cd =0 when card is deteced while cd=1 when card is >> removed. >> In order to mmc_gpio_get_cd return 1, MMC_CAP2_CD_ACTIVE_HIGH has to be >> set, as well as new property "caps2-mmc-cd-active-low". > > Ok, you could do more. > mmc_gpio_get_cd() is expected to return non-zero if card is detection. > I think your board seems not to use pull-up on GPIO line for card detection. > So, MMC_CAP2_CD_ACTIVE_HIGH would be needed. Unfortunately, the specific cd pin can not be configured. Suspect on our board the cd =1 when card is inserted, can not measure as no clear resister and need check with hardware guy tomorrow. "cd-inverted" may be required as mentioned by Arnd. Will update the patch as following if no problem. diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 9ded62c8225e..8326e54b96a8 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1042,7 +1042,7 @@ static int dw_mci_get_cd(struct mmc_host *mmc) else if (brd->get_cd) present = !brd->get_cd(slot->id); else if (!IS_ERR_VALUE(gpio_cd)) - present = !gpio_cd; + present = gpio_cd ^ brd->cd_inverted; else present = (mci_readl(slot->host, CDETECT) & (1 << slot->id)) == 0 ? 1 : 0; @@ -2414,6 +2414,9 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) if (of_find_property(np, "caps2-mmc-hs200-1_2v", NULL)) pdata->caps2 |= MMC_CAP2_HS200_1_2V_SDR; + if (of_get_property(np, "cd-inverted", NULL)) + pdata->cd_inverted = 1; + return pdata; } diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h index 6ce7d2cd3c7a..4535282589ab 100644 --- a/include/linux/mmc/dw_mmc.h +++ b/include/linux/mmc/dw_mmc.h @@ -238,6 +238,7 @@ struct dw_mci_board { u32 caps; /* Capabilities */ u32 caps2; /* More capabilities */ u32 pm_caps; /* PM capabilities */ + u8 cd_inverted;