From patchwork Fri Jun 21 06:12:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 11008467 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 9F47C1395 for ; Fri, 21 Jun 2019 06:13:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FE33289C2 for ; Fri, 21 Jun 2019 06:13:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83B00289D0; Fri, 21 Jun 2019 06:13:11 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7314289C2 for ; Fri, 21 Jun 2019 06:13:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726264AbfFUGMy (ORCPT ); Fri, 21 Jun 2019 02:12:54 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:45937 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725911AbfFUGMx (ORCPT ); Fri, 21 Jun 2019 02:12:53 -0400 Received: by mail-pl1-f196.google.com with SMTP id bi6so2453368plb.12 for ; Thu, 20 Jun 2019 23:12:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=7nHW+SBzX1vnb4mk1MDf9lGhalkNUllPIWRi8UNhM/c=; b=osCAdvXZJmd8s32WoaH84e0LvoQF3n8quJaSrFXXcZI2cepOsKaYqkZhdXl6Hipp1t MNT21Hkn6pag47WU/b70key5vgzuhiyEbIyDFj7NUoKIwA4nVoTsgAr1LbAvE1e9580o ojwN0FXPZn+ZwbFGBZaWJBlmoykMq8Y3IfDCrdn4Lje8NGTdaAn4Zu0K3ZaBj3ngMSzd 5heMfR7ve4WTUcKdL3TLMPPguf7EzfTIJCi6nJQkpc5I3ja4gL7elfXltWm2OukUep48 KQ6bedBrVvRAxuX0n+NXZV/uHEmz1LzGOWHDLYMm/iBXQpWgyeU+VJJSgISWBjEFC1++ gMwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=7nHW+SBzX1vnb4mk1MDf9lGhalkNUllPIWRi8UNhM/c=; b=Z+GpQzvwq/zrru8i5pMmSTFGX5yjc4xOrQ+fYdhipIKGeoxLpUQUSLJIRCtniItkX3 SRrgH4puCcft4I92UDhA5kPkzQNOzgJqcKf1XYTRk1GrlrPxFl1H3v1QytkB9kdM8Piv VzFTFQJkJDWySUJ2RxzzEKyvbHmLMEfO/Tck2299n3xNqWn/PqTWsOcfvkg1+c+P1mZb 6Jf6jGQf9wlrl/Y/bFQxIYbXGZH1yTZys1RL1ZLHm36Khk1MtqI0iGmnZpUKAOV+sp7+ sOSm4L8G+NxXz9xZHKUoLHhRK2Nb5AbbLweutGdrp+yU07Jdmdb0YVSB3FynbX1QBlkw lLbA== X-Gm-Message-State: APjAAAU34PDyvU+sDZHG40lN6+B4WaQ5pZYlEAB0/Mw04n6zytnoWYqK N+GTeWNBnyGaH8w7UTPBoGXXlQ== X-Google-Smtp-Source: APXvYqzV1QMcGWKHcO3GJFszFvYHtJaXinkBiAsjKQeNI5kSsCCcFHT5+Hm1oVT9CT+LJc1z8sKSjg== X-Received: by 2002:a17:902:7583:: with SMTP id j3mr11377956pll.196.1561097573451; Thu, 20 Jun 2019 23:12:53 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id x7sm1266134pfm.82.2019.06.20.23.12.50 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Jun 2019 23:12:53 -0700 (PDT) From: Baolin Wang To: adrian.hunter@intel.com, ulf.hansson@linaro.org, zhang.lyra@gmail.com, orsonzhai@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com Cc: baolin.wang@linaro.org, vincent.guittot@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 1/3] mmc: sdhci-sprd: Add start_signal_voltage_switch ops Date: Fri, 21 Jun 2019 14:12:31 +0800 Message-Id: <89fb15e88f33a3c1ce7b5eefa9414a20c984c579.1561094029.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For Spreadtrum SD host controller, we can not use standard SD registers to change and detect the I/O voltage signals, since our voltage regulator for I/O is fixed in hardware, and no signals were connected to the SD controller. Thus add Spreadtrum specific voltage switch ops to change voltage instead of using standard SD host registers. Signed-off-by: Baolin Wang Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci-sprd.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c index 024c3c5..8b23c88 100644 --- a/drivers/mmc/host/sdhci-sprd.c +++ b/drivers/mmc/host/sdhci-sprd.c @@ -403,6 +403,22 @@ static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq) sdhci_request(mmc, mrq); } +static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios) +{ + int ret; + + if (!IS_ERR(mmc->supply.vqmmc)) { + ret = mmc_regulator_set_vqmmc(mmc, ios); + if (ret) { + pr_err("%s: Switching signalling voltage failed\n", + mmc_hostname(mmc)); + return ret; + } + } + + return 0; +} + static void sdhci_sprd_hs400_enhanced_strobe(struct mmc_host *mmc, struct mmc_ios *ios) { @@ -470,6 +486,14 @@ static int sdhci_sprd_probe(struct platform_device *pdev) host->mmc_host_ops.request = sdhci_sprd_request; host->mmc_host_ops.hs400_enhanced_strobe = sdhci_sprd_hs400_enhanced_strobe; + /* + * We can not use the standard ops to change and detect the voltage + * signal for Spreadtrum SD host controller, since our voltage regulator + * for I/O is fixed in hardware, that means we do not need control + * the standard SD host controller to change the I/O voltage. + */ + host->mmc_host_ops.start_signal_voltage_switch = + sdhci_sprd_voltage_switch; host->mmc->caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_ERASE | MMC_CAP_CMD23; From patchwork Fri Jun 21 06:12:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 11008465 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 C590F186E for ; Fri, 21 Jun 2019 06:13:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6BE5289AF for ; Fri, 21 Jun 2019 06:13:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AAD60289BE; Fri, 21 Jun 2019 06:13:07 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C7A8289AF for ; Fri, 21 Jun 2019 06:13:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726333AbfFUGNG (ORCPT ); Fri, 21 Jun 2019 02:13:06 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:43293 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726297AbfFUGM5 (ORCPT ); Fri, 21 Jun 2019 02:12:57 -0400 Received: by mail-pf1-f193.google.com with SMTP id i189so3010898pfg.10 for ; Thu, 20 Jun 2019 23:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=sTCdN8+J6KLa7sEKH0EdC3HRf3eZR2ST2OSFrpSj98Q=; b=hRj5ECnn+gxAxOedpghqwfXjTbai4FfzLUa9qcX00huzqhbDDBkKgalm3JGfPzF4sm 18yXQSv2ukoeVpjOkv7Db2DZDB28Ddz1Jkn3Q6od/ez8JwBgtOtfOj9X7ShDnaOcEZdA KM1UOo97Eo5hwjvpmIQCLUrL2E1wytzb1SD4kV+ffY2IRcgG4TT9FyI62cGLmutOceIj ipEH0GNu8YZ1aIGoR2Ku1j9iYaZQ84JO+TrBmMZYGD6Dx85JTEmWEO4lX7M6hvVTfA5N dvfPJJ8svG6P159BVUNq3Xzv6MU6BxsEK4BoUVBA9CNKMzhFQvWUVgCUhAsWngA5gedR Lbgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=sTCdN8+J6KLa7sEKH0EdC3HRf3eZR2ST2OSFrpSj98Q=; b=CbSPtjG1+D8gdFrVW4a6AoOSK2GB+MuuDR3tjIl2KUbh4LCTeKkZzECMBjh/DdsTrf sCjZtNvm9QeiYiQuD8I0EUwvjeuujn2Ag2NDZykOePt1jrKW2Dr2v9ZvFF1btO5632W+ 6iJD+WjF8VJCOjyKA4hoVl/lcRw9sn0q2245R8MJ5lzzonU+cYUNy80xY7MLT36x/pGY HRNHXpZoVjb35xxACsdJlXsvmvyc8hW9N268NvIBlVMAgSqS/ba6W9lRnO2P0X3EUTd5 oCoxGDhQsD24q7QBGESrR6BEm08AgkFUN4Li9tIEywrHG1ZBc5OWojIH04/ytVmy4YZd Emyg== X-Gm-Message-State: APjAAAU4DRDK1Zf+yOl10exNqKtFQSwoh+8HoScDNPxNrz9gtYCnlalp Ulf0vyMSI5Z9El1dXub/RxN/Yw== X-Google-Smtp-Source: APXvYqxmGH0nMNJrwTfUuJHvrMIseiYEj2N0NeglRuKFRKi0jUIO0oJYd4+5NHEBufpTMCTrFHeIQQ== X-Received: by 2002:a17:90a:d814:: with SMTP id a20mr4358452pjv.48.1561097576891; Thu, 20 Jun 2019 23:12:56 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id x7sm1266134pfm.82.2019.06.20.23.12.53 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Jun 2019 23:12:56 -0700 (PDT) From: Baolin Wang To: adrian.hunter@intel.com, ulf.hansson@linaro.org, zhang.lyra@gmail.com, orsonzhai@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com Cc: baolin.wang@linaro.org, vincent.guittot@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 2/3] dt-bindings: mmc: sprd: Add pinctrl support Date: Fri, 21 Jun 2019 14:12:32 +0800 Message-Id: <73f6c1291e4c15da6be53a6dd4602622e142fefb.1561094029.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When changing SD card voltage signal for Spreadtrum SD host controller, it also need to switch related pin's state. Thus add pinctrl properties' description in documentation. Signed-off-by: Baolin Wang --- .../devicetree/bindings/mmc/sdhci-sprd.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/mmc/sdhci-sprd.txt b/Documentation/devicetree/bindings/mmc/sdhci-sprd.txt index e675397..eb7eb1b 100644 --- a/Documentation/devicetree/bindings/mmc/sdhci-sprd.txt +++ b/Documentation/devicetree/bindings/mmc/sdhci-sprd.txt @@ -19,6 +19,9 @@ Required properties: Optional properties: - assigned-clocks: the same with "sdio" clock - assigned-clock-parents: the default parent of "sdio" clock +- pinctrl-names: should be "default", "state_uhs" +- pinctrl-0: should contain default/high speed pin control +- pinctrl-1: should contain uhs mode pin control PHY DLL delays are used to delay the data valid window, and align the window to sampling clock. PHY DLL delays can be configured by following properties, @@ -50,6 +53,10 @@ sdio0: sdio@20600000 { assigned-clocks = <&ap_clk CLK_EMMC_2X>; assigned-clock-parents = <&rpll CLK_RPLL_390M>; + pinctrl-names = "default", "state_uhs"; + pinctrl-0 = <&sd0_pins_default>; + pinctrl-1 = <&sd0_pins_uhs>; + sprd,phy-delay-sd-uhs-sdr104 = <0x3f 0x7f 0x2e 0x2e>; bus-width = <8>; non-removable; From patchwork Fri Jun 21 06:12:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 11008463 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 B81101395 for ; Fri, 21 Jun 2019 06:13:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4D09289B5 for ; Fri, 21 Jun 2019 06:13:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98AC1289C2; Fri, 21 Jun 2019 06:13:07 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74BD4289CF for ; Fri, 21 Jun 2019 06:13:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726334AbfFUGNB (ORCPT ); Fri, 21 Jun 2019 02:13:01 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:42390 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726331AbfFUGNA (ORCPT ); Fri, 21 Jun 2019 02:13:00 -0400 Received: by mail-pl1-f193.google.com with SMTP id ay6so2450514plb.9 for ; Thu, 20 Jun 2019 23:13:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=ImM7LoJ0g/LV9Msk8fC9rkqyN6ipnuYryn1oHdAjw90=; b=IsSBjGrF+DN7QHmXac43Ny79aaDEhysk2zRkeDW43Wox0gAQlxq2jhbf6FPNlZ0Ivg W5dXPLPd/Gl+e6zZvdKMuSxCqWPSObH8X+6Ftomh0xUVUeY9bJW8JlShqfj7hcs/Efjb WCJhUx6hG8j/IV54/quUx/94bk1d6jXYUvkajSza2zunVxXSy+NIClWkeztrxvb4bGIA M0VGYyvy930CJIehNbG1vyrmufkJ6KudfaIw/VvW8p0aT4auVM1Gfc1eLZmKefZGqdyb fWgl0VC4cT8ipH3uf17ndRAQsBWPklzGRQaHexZTkF7/F/oKNyfwQgR8BLi5BzlZwF2r ADDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=ImM7LoJ0g/LV9Msk8fC9rkqyN6ipnuYryn1oHdAjw90=; b=Krd0D2PZ53+fYSAPFDLMve6ghXYpq/4tsCJNNjirW2UWPa4eAL5OhN6h18tr6c6T0P UfB0u4fBjdU0Uuj9qdUlO9QImdc+ZxLTW8eutl78PoWP1czuerWT3r0q5m0SbxK3z4L0 sEtN92ztDxgVgiJtR3GpalDtmtoIfIQ0jxO9/VtLW7Gz536eAedVFazWHVkA3KqGVGs6 IIm4lMTjSb2YMxreLMeXwhhewFWGNdeHQvi8oywtKJXWd/gG3cpBLF+JmhN+l5raRiFv YZ7unMl3A5LRYYP6509zrno7t9um5Spo2+BqXk3jJeaTJL7iXg5Lv6n4VEEqs3nN3fDR j0ug== X-Gm-Message-State: APjAAAVs7ydTTb1DQvDKLwJditFOcc0oRzliOZoXB+mJTY/0lBeGuC8y m2R1ABH/0d/DisFhgA8zq4XouaqZvzSdAA== X-Google-Smtp-Source: APXvYqz898MP1cNZToQJ6foRRP/YHqudKpgx1HQy2pqhLZm61bx9cEa7MCexGOqYuMmbmiHTN0ANag== X-Received: by 2002:a17:902:b603:: with SMTP id b3mr69912736pls.72.1561097579911; Thu, 20 Jun 2019 23:12:59 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id x7sm1266134pfm.82.2019.06.20.23.12.57 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Jun 2019 23:12:59 -0700 (PDT) From: Baolin Wang To: adrian.hunter@intel.com, ulf.hansson@linaro.org, zhang.lyra@gmail.com, orsonzhai@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com Cc: baolin.wang@linaro.org, vincent.guittot@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 3/3] mmc: sdhci-sprd: Add pin control support for voltage switch Date: Fri, 21 Jun 2019 14:12:33 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For Spreadtrum SD card voltage switching, besides regulator setting, it also need switch related pin's state to output corresponding voltage. This patch adds pin control operation to support voltage switch. Signed-off-by: Baolin Wang Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci-sprd.c | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c index 8b23c88..6ee340a 100644 --- a/drivers/mmc/host/sdhci-sprd.c +++ b/drivers/mmc/host/sdhci-sprd.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -72,6 +73,9 @@ struct sdhci_sprd_host { struct clk *clk_sdio; struct clk *clk_enable; struct clk *clk_2x_enable; + struct pinctrl *pinctrl; + struct pinctrl_state *pins_uhs; + struct pinctrl_state *pins_default; u32 base_rate; int flags; /* backup of host attribute */ u32 phy_delay[MMC_TIMING_MMC_HS400 + 2]; @@ -405,6 +409,8 @@ static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq) static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios) { + struct sdhci_host *host = mmc_priv(mmc); + struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host); int ret; if (!IS_ERR(mmc->supply.vqmmc)) { @@ -416,6 +422,37 @@ static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios) } } + if (IS_ERR(sprd_host->pinctrl)) + return 0; + + switch (ios->signal_voltage) { + case MMC_SIGNAL_VOLTAGE_180: + ret = pinctrl_select_state(sprd_host->pinctrl, + sprd_host->pins_uhs); + if (ret) { + pr_err("%s: failed to select uhs pin state\n", + mmc_hostname(mmc)); + return ret; + } + break; + + default: + /* fall-through */ + case MMC_SIGNAL_VOLTAGE_330: + ret = pinctrl_select_state(sprd_host->pinctrl, + sprd_host->pins_default); + if (ret) { + pr_err("%s: failed to select default pin state\n", + mmc_hostname(mmc)); + return ret; + } + break; + } + + /* Wait for 300 ~ 500 us for pin state stable */ + usleep_range(300, 500); + sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA); + return 0; } @@ -504,6 +541,23 @@ static int sdhci_sprd_probe(struct platform_device *pdev) sprd_host = TO_SPRD_HOST(host); sdhci_sprd_phy_param_parse(sprd_host, pdev->dev.of_node); + sprd_host->pinctrl = devm_pinctrl_get(&pdev->dev); + if (!IS_ERR(sprd_host->pinctrl)) { + sprd_host->pins_uhs = + pinctrl_lookup_state(sprd_host->pinctrl, "state_uhs"); + if (IS_ERR(sprd_host->pins_uhs)) { + ret = PTR_ERR(sprd_host->pins_uhs); + goto pltfm_free; + } + + sprd_host->pins_default = + pinctrl_lookup_state(sprd_host->pinctrl, "default"); + if (IS_ERR(sprd_host->pins_default)) { + ret = PTR_ERR(sprd_host->pins_default); + goto pltfm_free; + } + } + clk = devm_clk_get(&pdev->dev, "sdio"); if (IS_ERR(clk)) { ret = PTR_ERR(clk);