From patchwork Tue Jun 4 08:14:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olof Johansson X-Patchwork-Id: 11033417 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A62F014DB for ; Fri, 5 Jul 2019 22:25:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9465228A8C for ; Fri, 5 Jul 2019 22:25:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87B6828AAB; Fri, 5 Jul 2019 22:25:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,MIME_HEADER_CTYPE_ONLY,RCVD_IN_DNSWL_LOW, T_TVD_MIME_NO_HEADERS autolearn=ham version=3.3.1 Received: from web01.groups.io (web01.groups.io [66.175.222.12]) (using TLSv1.2 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2A72B28A8C for ; Fri, 5 Jul 2019 22:25:55 +0000 (UTC) X-Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by groups.io with SMTP; Fri, 05 Jul 2019 15:25:54 -0700 X-Received: by mail-lj1-f193.google.com with SMTP id t28so10521377lje.9 for ; Fri, 05 Jul 2019 15:25:54 -0700 (PDT) X-Gm-Message-State: APjAAAWMMyj2OoBmeqCqH34GV58fSs5BGelHS6xrGlkuMnmMB6UOtcAC +RPX/VZNb7NJmBrcAHM9VxXLTIWlhlMrTg== X-Google-Smtp-Source: APXvYqwDOdQPUZYNPmULv07xpb1peAWtTGHWCFiWWlH+pT4hFQ/un+ZsYUmwS1MU9/Bc8a7mqreCbw== X-Received: by 2002:a2e:5b0f:: with SMTP id p15mr3292185ljb.82.1562365552394; Fri, 05 Jul 2019 15:25:52 -0700 (PDT) X-Received: from localhost (h85-30-9-151.cust.a3fiber.se. [85.30.9.151]) by smtp.gmail.com with ESMTPSA id e26sm2022656ljl.33.2019.07.05.15.25.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jul 2019 15:25:52 -0700 (PDT) Resent-From: Olof Johansson Resent-Date: Fri, 5 Jul 2019 13:51:26 -0700 Resent-Message-ID: <20190705205126.fnw4l3m7wibts2vw@localhost> Resent-To: patchwork-soc@linux.kernel.org X-Received: by 2002:a05:6602:220a:0:0:0:0 with SMTP id n10csp5434862ion; Tue, 4 Jun 2019 01:15:02 -0700 (PDT) X-Received: by 2002:a62:82c2:: with SMTP id w185mr14625370pfd.202.1559636102805; Tue, 04 Jun 2019 01:15:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559636102; cv=none; d=google.com; s=arc-20160816; b=YeA08aKoqpEDmch8fyCQSMFsgwlwDdl2pNveF7bkGXvr4UN3TKTXmh3TV16W0Ngqd/ Oop8HLmk3Of2KmAczgGCmT8e0/plu1L+J3dKe9jJAe59ddqSFg4mCAEH0QUzmoNX1ThB pcDTds1o20j2rF1uBf5OZGsEOn9xbaVOrdKOrsJ2hT/JYjdm80iNQY7vU2bFgo/0iiV2 X1/CMQyV324Ln9mrgChcz4lQdewjegob0MEGCCobMBvDJJgJO2sTpt2uz6cPZbQX2Ydb naox1ng/AMNbGGT/vb8zdRlhVfn96GTnZM83hE3JX49sI4nofp3EheROnteLSNkjDTbV bjHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=FdrxifC9VKJDfmhJlZCtT+SJXQU8nyEdMzYOjCE23wE=; b=iIeRI8gow3UXeDzaRVIuZCWizwhrrHt9YbZQn6YABnh3iRdfJXYl2x+U6syMbX0Xe7 Nos8Yrwb5iivGmNF22nbjjRXYqyQsOf9qHLG5HaYMbsnRTpMp6s+jPcQcBv1rpeHADNy YzaXll0BMdQUMy07BZdxcSDpOUPujwJdfB9qa9T0dunQdyIiOPwD5MZT8UMISjcEyYbQ X+wwSTyV1M9NA6U+Bsy1a/ljy3l1Wn3ACJ5FuYfBf1A16d33TCCXiTBCY6esbDRe99zF OeeC3WJnHvN4wXL54feLpkuqSd6VIfUzaJzHg3VmkHW6ktpuL6YS4fXUrbQU59vVlVKY QTVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O+2GCVHo; spf=pass (google.com: domain of baolin.wang@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=baolin.wang@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id x2sor6207409plo.58.2019.06.04.01.15.02 for (Google Transport Security); Tue, 04 Jun 2019 01:15:02 -0700 (PDT) Received-SPF: pass (google.com: domain of baolin.wang@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:7e0e:: with SMTP id b14mr9660980plm.257.1559636102504; Tue, 04 Jun 2019 01:15:02 -0700 (PDT) X-Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id j4sm14818804pgc.56.2019.06.04.01.14.58 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Jun 2019 01:15:02 -0700 (PDT) From: "Olof Johansson" To: adrian.hunter@intel.com, ulf.hansson@linaro.org, zhang.lyra@gmail.com, orsonzhai@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com, arnd@arndb.de, olof@lixom.net Cc: baolin.wang@linaro.org, vincent.guittot@linaro.org, arm@kernel.org, linux-arm-kernel@lists.infradead.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v2 3/9] mmc: sdhci-sprd: Add optional gate clock support Date: Tue, 4 Jun 2019 16:14:23 +0800 Message-Id: <3bd7f5b0d4c78b75f8c4067a34f79396b4fd0a5c.1559635435.git.baolin.wang@linaro.org> In-Reply-To: References: In-Reply-To: References: X-TUID: lmv3KY25T5G5 Precedence: Bulk List-Unsubscribe: Sender: patchwork-soc@linux.kernel.org List-Id: Mailing-List: list patchwork-soc@linux.kernel.org; contact patchwork-soc+owner@linux.kernel.org Delivered-To: mailing list patchwork-soc@linux.kernel.org Reply-To: patchwork-soc+owner@linux.kernel.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.kernel.org; q=dns/txt; s=20140610; t=1562365555; bh=RdrvU1jxOgzG4sLHU+EZqm1TGGwcKveDRYamTshIlgo=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=poNI5mTieOJzIMMjZ8ohf/gBDHvsF7750LBEz/tEHw0g81Tlw+bnWhDlKSxdtN+Yk6v gx1KP41dGwLVLziJG3NqTcB3rYfS0aBFwaT/Ra8QGTiU4PMlPcefrUq82YjzNV+PQSBwg FkvtNHYoQqtTzhZH89T6WeYEROnNpZH8dLU= X-Virus-Scanned: ClamAV using ClamSMTP For the Spreadtrum SC9860 platform, we should enable another gate clock '2x_enable' to make the SD host controller work well. Signed-off-by: Baolin Wang Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci-sprd.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c index e741491..31ba7d6 100644 --- a/drivers/mmc/host/sdhci-sprd.c +++ b/drivers/mmc/host/sdhci-sprd.c @@ -60,6 +60,7 @@ struct sdhci_sprd_host { u32 version; struct clk *clk_sdio; struct clk *clk_enable; + struct clk *clk_2x_enable; u32 base_rate; int flags; /* backup of host attribute */ }; @@ -364,6 +365,10 @@ static int sdhci_sprd_probe(struct platform_device *pdev) } sprd_host->clk_enable = clk; + clk = devm_clk_get(&pdev->dev, "2x_enable"); + if (!IS_ERR(clk)) + sprd_host->clk_2x_enable = clk; + ret = clk_prepare_enable(sprd_host->clk_sdio); if (ret) goto pltfm_free; @@ -372,6 +377,10 @@ static int sdhci_sprd_probe(struct platform_device *pdev) if (ret) goto clk_disable; + ret = clk_prepare_enable(sprd_host->clk_2x_enable); + if (ret) + goto clk_disable2; + sdhci_sprd_init_config(host); host->version = sdhci_readw(host, SDHCI_HOST_VERSION); sprd_host->version = ((host->version & SDHCI_VENDOR_VER_MASK) >> @@ -408,6 +417,9 @@ static int sdhci_sprd_probe(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); + clk_disable_unprepare(sprd_host->clk_2x_enable); + +clk_disable2: clk_disable_unprepare(sprd_host->clk_enable); clk_disable: @@ -427,6 +439,7 @@ static int sdhci_sprd_remove(struct platform_device *pdev) mmc_remove_host(mmc); clk_disable_unprepare(sprd_host->clk_sdio); clk_disable_unprepare(sprd_host->clk_enable); + clk_disable_unprepare(sprd_host->clk_2x_enable); mmc_free_host(mmc); @@ -449,6 +462,7 @@ static int sdhci_sprd_runtime_suspend(struct device *dev) clk_disable_unprepare(sprd_host->clk_sdio); clk_disable_unprepare(sprd_host->clk_enable); + clk_disable_unprepare(sprd_host->clk_2x_enable); return 0; } @@ -459,19 +473,28 @@ static int sdhci_sprd_runtime_resume(struct device *dev) struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host); int ret; - ret = clk_prepare_enable(sprd_host->clk_enable); + ret = clk_prepare_enable(sprd_host->clk_2x_enable); if (ret) return ret; + ret = clk_prepare_enable(sprd_host->clk_enable); + if (ret) + goto clk_2x_disable; + ret = clk_prepare_enable(sprd_host->clk_sdio); - if (ret) { - clk_disable_unprepare(sprd_host->clk_enable); - return ret; - } + if (ret) + goto clk_disable; sdhci_runtime_resume_host(host); - return 0; + +clk_disable: + clk_disable_unprepare(sprd_host->clk_enable); + +clk_2x_disable: + clk_disable_unprepare(sprd_host->clk_2x_enable); + + return ret; } #endif