Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1600377pxy; Thu, 6 May 2021 11:09:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZPtvPOtBBOQmkHLiFUUzjOmqhJYqrBef7hSSNPQED07XVQw+T4MzsxxiEa3EY2bB7fP4A X-Received: by 2002:a17:907:10d8:: with SMTP id rv24mr5830036ejb.542.1620324544235; Thu, 06 May 2021 11:09:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620324544; cv=none; d=google.com; s=arc-20160816; b=M9wJeaCYwDr01Q5aDEOwWZZ/Xzd6Kdn9y1brenNnivrIWuPARuehSDtVJeCth7BGxV 1I1e19g1V/SrQ0XHB214NreBAQ8I3UnBZLgKp2hVVNIcXu7co55+0W5/DGWerDDw3MAt /t30rSfaE21WRB5C6MZUMEuLpNvFzlayx4MZjpc8ruiuMiSnpxo8a/3z7fE7qNsWO+jm Ha7r8JI0uzER1bXvzDN5BCqnVN9afAjVAeoMFB2L7dRUJGVkNggkQHbKaRIaLwXD5Opo uMOl8jmMQPhqkecpMnv3UoQgQ+4GffS416tcVzIFhT7or6cZiU/dEkeMih3AFPQDuJ5U MOJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=BaHkzyBA8pT0zFA8Yw1gv3x/qmKQ7lSdWR8P5y6FUeU=; b=Do4YFY+Ro3Xwb/NyogMYgPtdg/05ElvsW3c/oxzVbigscPMhn3yvAYNpOrRFwMq7a1 s7/WkUNXCt46ZlahsEimEsDV1TSSjgIshvw0EBeByqw1rkaBiU7e4UPDhAK1eJ5E0SnG 6bkTRAAS8zC2h3iQhsUS6CNa/sGrHDNSDw2x08aATlh0B5fHY1319UmXnknlSf5MwEOC WdPW5gTxqOcZFcTgfYmC/aVlOGeY3Hb4GN7D23alYf0RPzNr1HbAi4fQ6kOcFkehz+VH d7Ej2nIy7xhnbUYvjEzga1zP7i8yYKNjeSo3BL9DOTiPOFKwHSfNPYA9BtlGQf3O8S92 a8EA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i22si2730546ejy.656.2021.05.06.11.08.36; Thu, 06 May 2021 11:09:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234006AbhEFKJT (ORCPT + 99 others); Thu, 6 May 2021 06:09:19 -0400 Received: from twspam01.aspeedtech.com ([211.20.114.71]:38052 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233964AbhEFKJS (ORCPT ); Thu, 6 May 2021 06:09:18 -0400 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 1469pTG0024645; Thu, 6 May 2021 17:51:29 +0800 (GMT-8) (envelope-from steven_lee@aspeedtech.com) Received: from localhost.localdomain (192.168.100.253) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 6 May 2021 18:03:17 +0800 From: Steven Lee To: Andrew Jeffery , Ulf Hansson , Rob Herring , Joel Stanley , "Adrian Hunter" , Philipp Zabel , Ryan Chen , "moderated list:ASPEED SD/MMC DRIVER" , "moderated list:ASPEED SD/MMC DRIVER" , "open list:ASPEED SD/MMC DRIVER" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "moderated list:ARM/ASPEED MACHINE SUPPORT" , open list CC: , , , Subject: [PATCH v3 5/5] mmc: sdhci-of-aspeed: Assert/Deassert reset signal before probing eMMC Date: Thu, 6 May 2021 18:03:12 +0800 Message-ID: <20210506100312.1638-6-steven_lee@aspeedtech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210506100312.1638-1-steven_lee@aspeedtech.com> References: <20210506100312.1638-1-steven_lee@aspeedtech.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.100.253] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 1469pTG0024645 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For cleaning up the AST2600 eMMC controller, the reset signal should be asserted and deasserted before it is probed. Signed-off-by: Steven Lee --- drivers/mmc/host/sdhci-of-aspeed.c | 49 ++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c index 4979f98ffb52..8ef06f32abff 100644 --- a/drivers/mmc/host/sdhci-of-aspeed.c +++ b/drivers/mmc/host/sdhci-of-aspeed.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "sdhci-pltfm.h" @@ -36,9 +37,16 @@ /* SDIO{14,24} */ #define ASPEED_SDC_CAP2_SDR104 (1 * 32 + 1) +#define PROBE_AFTER_ASSET_DEASSERT 0x1 + +struct aspeed_sdc_info { + u32 flag; +}; + struct aspeed_sdc { struct clk *clk; struct resource *res; + struct reset_control *rst; spinlock_t lock; void __iomem *regs; @@ -78,6 +86,10 @@ struct aspeed_sdhci { }; +struct aspeed_sdc_info ast2600_sdc_info = { + .flag = PROBE_AFTER_ASSET_DEASSERT +}; + /* * The function sets the mirror register for updating * capbilities of the current slot. @@ -533,11 +545,22 @@ static struct platform_driver aspeed_sdhci_driver = { .remove = aspeed_sdhci_remove, }; +static const struct of_device_id aspeed_sdc_of_match[] = { + { .compatible = "aspeed,ast2400-sd-controller", }, + { .compatible = "aspeed,ast2500-sd-controller", }, + { .compatible = "aspeed,ast2600-sd-controller", .data = &ast2600_sdc_info}, + { } +}; + +MODULE_DEVICE_TABLE(of, aspeed_sdc_of_match); + static int aspeed_sdc_probe(struct platform_device *pdev) { struct device_node *parent, *child; struct aspeed_sdc *sdc; + const struct of_device_id *match = NULL; + const struct aspeed_sdc_info *info = NULL; int ret; sdc = devm_kzalloc(&pdev->dev, sizeof(*sdc), GFP_KERNEL); @@ -546,6 +569,23 @@ static int aspeed_sdc_probe(struct platform_device *pdev) spin_lock_init(&sdc->lock); + match = of_match_device(aspeed_sdc_of_match, &pdev->dev); + if (!match) + return -ENODEV; + + if (match->data) + info = match->data; + + if (info) { + if (info->flag & PROBE_AFTER_ASSET_DEASSERT) { + sdc->rst = devm_reset_control_get(&pdev->dev, NULL); + if (!IS_ERR(sdc->rst)) { + reset_control_assert(sdc->rst); + reset_control_deassert(sdc->rst); + } + } + } + sdc->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(sdc->clk)) return PTR_ERR(sdc->clk); @@ -593,15 +633,6 @@ static int aspeed_sdc_remove(struct platform_device *pdev) return 0; } -static const struct of_device_id aspeed_sdc_of_match[] = { - { .compatible = "aspeed,ast2400-sd-controller", }, - { .compatible = "aspeed,ast2500-sd-controller", }, - { .compatible = "aspeed,ast2600-sd-controller", }, - { } -}; - -MODULE_DEVICE_TABLE(of, aspeed_sdc_of_match); - static struct platform_driver aspeed_sdc_driver = { .driver = { .name = "sd-controller-aspeed", -- 2.17.1