From patchwork Wed Jan 15 13:56:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 23236 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gg0-f197.google.com (mail-gg0-f197.google.com [209.85.161.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 66944206A0 for ; Wed, 15 Jan 2014 13:56:48 +0000 (UTC) Received: by mail-gg0-f197.google.com with SMTP id q3sf2430999gge.0 for ; Wed, 15 Jan 2014 05:56:47 -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=0d5e39RHK/OHmPQ8Lo2EHBDT57dxLnCmu6CeDKurDbU=; b=WgnQ50bbYaW0iBUo9ecrAu03qzN7AjwRaN9MF99P8nB3RbIFd/yOmueforucNXaj4K hC9L5ZDBPOXn9XF2nslBwmxnEkgTcdjaavdfIKn7cHzNej/Du43ZwkPiwBNa59NmZqlk 8s98AQIY0j1UwgclAb2Vg49XjEvC5T4e16Qkv4XsjqboYFVWefWJl8YW1RVKUk13squF lXHiT6vFqBokJxke+IxtGOan8TNzdUKxdxukBrZ7G5YugtdVqJT4YkGwI4gE+dQ7qOHD 5eFhqElMMS36GOsC8Mpw8z10+ONlgZNf4UXiE9Qxg5Zwv8uxHZKoHUP/I/B4/1BwX/re ZOuw== X-Gm-Message-State: ALoCoQl0NqWkjk8yrkkKdQmjP2kU2/qRVKHeNj1+J13NGJ76QjGlT0W7LH/FdjKDnYmoMmCGOOuM X-Received: by 10.236.125.79 with SMTP id y55mr630875yhh.53.1389794207576; Wed, 15 Jan 2014 05:56:47 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.35.18 with SMTP id d18ls580177qej.14.gmail; Wed, 15 Jan 2014 05:56:47 -0800 (PST) X-Received: by 10.221.37.1 with SMTP id tc1mr1796194vcb.32.1389794207511; Wed, 15 Jan 2014 05:56:47 -0800 (PST) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id f7si1711858vcz.57.2014.01.15.05.56.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Jan 2014 05:56:47 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id c14so411430vea.5 for ; Wed, 15 Jan 2014 05:56:47 -0800 (PST) X-Received: by 10.220.116.136 with SMTP id m8mr373065vcq.77.1389794207440; Wed, 15 Jan 2014 05:56:47 -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 ey3csp275440ved; Wed, 15 Jan 2014 05:56:46 -0800 (PST) X-Received: by 10.68.228.138 with SMTP id si10mr2921521pbc.13.1389794206492; Wed, 15 Jan 2014 05:56:46 -0800 (PST) Received: from mail-pd0-f171.google.com (mail-pd0-f171.google.com [209.85.192.171]) by mx.google.com with ESMTPS id s4si3756867pbg.333.2014.01.15.05.56.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Jan 2014 05:56:46 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.171 is neither permitted nor denied by best guess record for domain of zhangfei.gao@linaro.org) client-ip=209.85.192.171; Received: by mail-pd0-f171.google.com with SMTP id g10so402671pdj.16 for ; Wed, 15 Jan 2014 05:56:46 -0800 (PST) X-Received: by 10.69.31.97 with SMTP id kl1mr2808407pbd.127.1389794206115; Wed, 15 Jan 2014 05:56:46 -0800 (PST) Received: from [192.168.3.108] ([124.73.90.72]) by mx.google.com with ESMTPSA id os1sm10611803pac.20.2014.01.15.05.56.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Jan 2014 05:56:45 -0800 (PST) Message-ID: <52D6938A.9050806@linaro.org> Date: Wed, 15 Jan 2014 21:56:26 +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> In-Reply-To: <001c01cf11ed$039b6270$0ad22750$%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.128.174 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 08:26 PM, Seungwon Jeon wrote: >>>> @@ -1033,7 +1033,8 @@ static int dw_mci_get_cd(struct mmc_host *mmc) >>>> int present; >>>> struct dw_mci_slot *slot = mmc_priv(mmc); >>>> struct dw_mci_board *brd = slot->host->pdata; >>>> - int gpio_cd = !mmc_gpio_get_cd(mmc); >>>> + struct dw_mci *host = slot->host; >>>> + int gpio_cd = mmc_gpio_get_cd(mmc); >>>> >>>> /* Use platform get_cd function, else try onboard card detect */ >>>> if (brd->quirks & DW_MCI_QUIRK_BROKEN_CARD_DETECTION) >>>> @@ -1041,11 +1042,12 @@ 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; >>> !!gpio_cd or gpio_cd is correct, isn't it? >>> >> >> No, mmc_gpio_get_cd(mmc) has to revert. > I'm missing something? > If card is detected, mmc_gpio_get_cd() returns non-zero, right? > I guess gpio_cd should be kept. > 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". int mmc_gpio_get_cd(struct mmc_host *host) { return !gpio_get_value_cansleep(ctx->cd_gpio) ^ !!(host->caps2 & MMC_CAP2_CD_ACTIVE_HIGH); } Thanks --- a/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt +++ b/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt @@ -73,6 +73,8 @@ Optional properties: +* caps2-mmc-cd-active-low: cd pin is low when card active + diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c + if (of_find_property(np, "caps2-mmc-cd-active-low", NULL)) + pdata->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; + But it looks strange "cd-active-low" describing "CD_ACTIVE_HIGH" flag. When card active, cd = 0, and ACTIVE_HIGH is required to make mmc_gpio_get_cd return 1.