Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2224952ybc; Wed, 13 Nov 2019 10:55:42 -0800 (PST) X-Google-Smtp-Source: APXvYqyyUliRQamBEgYlBVmDkZ1ct5G1+FrTC3tD4B91N4PeL2v8DbuMj9Kv528994Rfy2altO4l X-Received: by 2002:a17:906:f255:: with SMTP id gy21mr4401881ejb.204.1573671341964; Wed, 13 Nov 2019 10:55:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573671341; cv=none; d=google.com; s=arc-20160816; b=Mke0cHNz/ou6NrIrlicUnAm9il1J/Ckhk0++mXjJtdlMszPGTEA+g/wIilKe5sBMCm ve2FUGdr2oxLgx2ts0cPCVXHMBZh/1VNkrNy2EIkVQF5ZomJ93tWzgNLsHoLpvd8O/ky LtS/irzpbgS9khgOW3nc+4XpLLAadM9gPW/Djw6TrAYbOU1MD6qwczTPk+2VbEardrM2 aojI/EilLNuiX+hZmYrZlIWnI+lrXcyNnSzHYh9QxeZ/Y37H03MjrCPRFalaa55nQ07I 2ySpfk165FbIxnHWVQgu7GmaOahYXrf3kfIpej/OqVF2eqGtGjqA1OzTyKNvhBrQGPNQ 9vWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=yCCB16qs4f7IJAFjt7171zGq3D9bSQgdFGkgtaKnB8A=; b=XHcms6ZzdqkWMzCnEafLPWFN9l9kvMBnKBhEQYGjgo+4cNDJx8kPe1hsMG6UKxWX9T jWeMQ6Mir61nIsqZUKZZhdT4kvBWiUsjXARmz+ItL53Sy5G5NKwe8YSr6TJKdJoKRG/W EjTLC/SrFFNYtIrEQwCj0lJ5KkChCxyje+kLNXbDN3t23nd8AN/4Qf8f7hzN7kaOGbAH IaeDU2rLv834LO0nTtQTYHlJzzoHkhJzwDy3A+evpMCozm4mRrg4L5MP2E4xqP7CHfQm SjzH0mFg2gDXnJ9u8Oi5u2vIIMRvm+be4TCvt6qNTHCE3NbhNLT1gQJVm3gMi28/H276 Mwfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yadro.com header.s=mta-01 header.b=Lsyan+DY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yadro.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w26si1758511eju.48.2019.11.13.10.55.15; Wed, 13 Nov 2019 10:55:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@yadro.com header.s=mta-01 header.b=Lsyan+DY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yadro.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728181AbfKMPxI (ORCPT + 99 others); Wed, 13 Nov 2019 10:53:08 -0500 Received: from mta-02.yadro.com ([89.207.88.252]:59932 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726074AbfKMPxE (ORCPT ); Wed, 13 Nov 2019 10:53:04 -0500 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 20344412D2; Wed, 13 Nov 2019 15:53:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received; s=mta-01; t= 1573660380; x=1575474781; bh=u6VsNH8spieqcZMUkwhitlLPwcJWZA6GXjz wh0sgyTs=; b=Lsyan+DYpW6IleLOjFmf3XpEK9zYBKXdYEnzmDUPEQS42b9Tiby hkzVq2+4LuGLOW1Wh3/0ge3qIJZj2e20aqG4D2iugnJ7fbfcAmdlUzKXzukxNb3x kFmSghKapTW9B5iuXXBpLI9qeSpr6Ktkp/JHTh3TJzOBpr/uEcCauUOk= X-Virus-Scanned: amavisd-new at yadro.com Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5Lco3oJBrAxV; Wed, 13 Nov 2019 18:53:00 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (t-exch-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 4CECE42F12; Wed, 13 Nov 2019 18:52:59 +0300 (MSK) Received: from localhost.dev.yadro.com (172.17.15.69) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Wed, 13 Nov 2019 18:52:53 +0300 From: Ivan Mikhaylov CC: Ivan Mikhaylov , Joel Stanley , Andrew Jeffery , Rob Herring , Mark Rutland , Adrian Hunter , Ulf Hansson , , , , , , Subject: [PATCH 2/2] mmc: sdhci-of-aspeed: add inversion signal presence Date: Wed, 13 Nov 2019 18:52:37 +0300 Message-ID: <20191113155237.30646-3-i.mikhaylov@yadro.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191113155237.30646-1-i.mikhaylov@yadro.com> References: <20191113155237.30646-1-i.mikhaylov@yadro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.17.15.69] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-EXCH-02.corp.yadro.com (172.17.10.102) To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Change the default .get_cd callback. Add inverted signal card detection check. Signed-off-by: Ivan Mikhaylov diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c index 8962f6664381..8eded8a6ed8d 100644 --- a/drivers/mmc/host/sdhci-of-aspeed.c +++ b/drivers/mmc/host/sdhci-of-aspeed.c @@ -31,6 +31,7 @@ struct aspeed_sdc { struct aspeed_sdhci { struct aspeed_sdc *parent; u32 width_mask; + u8 cd_inverted; }; static void aspeed_sdc_configure_8bit_mode(struct aspeed_sdc *sdc, @@ -143,6 +144,21 @@ static inline int aspeed_sdhci_calculate_slot(struct aspeed_sdhci *dev, return (delta / 0x100) - 1; } +static int aspeed_get_cd(struct mmc_host *mmc) +{ + struct aspeed_sdhci *aspeed_sdhci; + struct sdhci_pltfm_host *pltfm_priv; + struct sdhci_host *host = mmc_priv(mmc); + + int presence = !!(sdhci_readl(host, SDHCI_PRESENT_STATE) + & SDHCI_CARD_PRESENT); + + pltfm_priv = sdhci_priv(host); + aspeed_sdhci = sdhci_pltfm_priv(pltfm_priv); + + return presence ^ aspeed_sdhci->cd_inverted; +} + static int aspeed_sdhci_probe(struct platform_device *pdev) { struct sdhci_pltfm_host *pltfm_host; @@ -183,6 +199,13 @@ static int aspeed_sdhci_probe(struct platform_device *pdev) goto err_pltfm_free; } + dev->cd_inverted = 0; + host->mmc_host_ops.get_cd = aspeed_get_cd; + if (of_property_read_bool(pdev->dev.of_node, "cd-inverted")) { + dev->cd_inverted = 1; + dev_info(&pdev->dev, "aspeed: sdhci: presence signal inversion enabled\n"); + } + ret = mmc_of_parse(host->mmc); if (ret) goto err_sdhci_add; -- 2.20.1