From patchwork Fri Jan 12 12:15:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrice CHOTARD X-Patchwork-Id: 10160639 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 152CB60327 for ; Fri, 12 Jan 2018 12:25:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE67427968 for ; Fri, 12 Jan 2018 12:25:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E150F289D3; Fri, 12 Jan 2018 12:25: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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3817E27968 for ; Fri, 12 Jan 2018 12:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1zdrqFIYMBnJbh8cpZZATxTKEfU0iHRayvjN4PvYnQQ=; b=tpDcx35HZjxtsy 4HGtgZHc+ejRX+4S6LmXRSt4zD3EFyhxOyiDY3bdLLscke50/ogru3judLs1tp9OV/Fia+STdz3GR bmuddbw+p4OChsfpqXsQRpgtx8WwQ4Tcy5PGksCVyBJpraQcTQ/TkMr2vEQSC8B9Eq7KHWJr/2aEG uMOOucguh+T7MuxzOPgRgGQSxIuZZmMcZZKBIEOb+/OmAcJkEgDduk8PNUSIeO/A2sL2CvcoXwrqj uqxNKSP9pvKTo95aTfrx8vzR0kD2KRnCTLIf8oj7ferD+zeXegJRiG/6dncuO3L5EB9CTxG3m/z0y x0dYaP3CO4xvvDP1Vjew==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eZyOO-0000fm-26; Fri, 12 Jan 2018 12:25:04 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZyNZ-0007Z3-R8 for linux-arm-kernel@bombadil.infradead.org; Fri, 12 Jan 2018 12:24:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=zUmNqDjkUSSwHlzgK2/RvcVGBsi7RBMNdD40Rd7hy5Q=; b=IFudBF/4cz2AU2EL1XStr0SRA pJDmTJ4WOEpuMxP6kaxdZqNf0VQD5r6MlXjhtbqqlOfB3XFCBctRpgX9ZIq0csyqaRzpbMX5uDwiu WplIwyxTuMsV6Gw3KOVeacPcqEOz12uHgRtY7AhejCxXCD4y39+DuciNxk/VLHmwXga+iqlxQ219P DdHeTEAT4Zr9uGLDNHT3BrmslGmHvPvQI4l6u9heulSwYprwegUAVFLReibcIwu5l6T9FZYPxPTP6 kOQJnGJNNx79tRRkR7r/twVHRT5403J23SmtWa0jO4wNoO94xmIBYRqJtazcumTxKJeY6m5vzGMHm cBOjjXLdQ==; Received: from mx07-00178001.pphosted.com ([62.209.51.94]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZyGl-0003gl-HD for linux-arm-kernel@lists.infradead.org; Fri, 12 Jan 2018 12:17:18 +0000 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w0CCEHFV011416; Fri, 12 Jan 2018 13:16:20 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2febc4vy2b-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 12 Jan 2018 13:16:20 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id DC7DB31; Fri, 12 Jan 2018 12:16:19 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag6node3.st.com [10.75.127.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B0A7E24C1; Fri, 12 Jan 2018 12:16:19 +0000 (GMT) Received: from localhost (10.75.127.50) by SFHDAG6NODE3.st.com (10.75.127.18) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 12 Jan 2018 13:16:19 +0100 From: To: Russell King , Ulf Hansson , Michael Turquette , Stephen Boyd , Linus Walleij , Rob Herring , Mark Rutland , Alexandre Torgue Subject: [PATCH 03/14] mmc: mmci: Add support for setting pad type via pinctrl Date: Fri, 12 Jan 2018 13:15:57 +0100 Message-ID: <1515759368-16946-4-git-send-email-patrice.chotard@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1515759368-16946-1-git-send-email-patrice.chotard@st.com> References: <1515759368-16946-1-git-send-email-patrice.chotard@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG6NODE3.st.com (10.75.127.18) To SFHDAG6NODE3.st.com (10.75.127.18) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-12_06:, , signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180112_121711_839543_9E527B65 X-CRM114-Status: GOOD ( 25.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Andrea Merello , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Patrice Chotard , linux-gpio@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Patrice Chotard The STM32 variant hasn't the control bit to switch pads in opendrain mode. In this case we can achieve the same result by asking to the pinmux driver to configure pins for us. This patch make the mmci driver able to do this whenever needed. Signed-off-by: Andrea Merello Signed-off-by: Patrice Chotard Reviewed-by: Linus Walleij --- drivers/mmc/host/mmci.c | 54 ++++++++++++++++++++++++++++++++++++++++--------- drivers/mmc/host/mmci.h | 5 +++++ 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 7e56f85..38e8c20 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -85,6 +85,8 @@ * @mmcimask1: true if variant have a MMCIMASK1 register. * @start_err: true is the variant has STARTBITERR bit inside MMCISTATUS * register. + * @opendrain: true if variant have dedicated bit for opendrain pins + * configuration. */ struct variant_data { unsigned int clkreg; @@ -116,6 +118,7 @@ struct variant_data { bool reversed_irq_handling; bool mmcimask1; bool start_err; + bool opendrain; }; static struct variant_data variant_arm = { @@ -127,6 +130,7 @@ struct variant_data { .reversed_irq_handling = true, .mmcimask1 = true, .start_err = true, + .opendrain = true, }; static struct variant_data variant_arm_extended_fifo = { @@ -137,6 +141,7 @@ struct variant_data { .f_max = 100000000, .mmcimask1 = true, .start_err = true, + .opendrain = true, }; static struct variant_data variant_arm_extended_fifo_hwfc = { @@ -148,6 +153,7 @@ struct variant_data { .f_max = 100000000, .mmcimask1 = true, .start_err = true, + .opendrain = true, }; static struct variant_data variant_u300 = { @@ -165,6 +171,7 @@ struct variant_data { .pwrreg_nopower = true, .mmcimask1 = true, .start_err = true, + .opendrain = true, }; static struct variant_data variant_nomadik = { @@ -183,6 +190,7 @@ struct variant_data { .pwrreg_nopower = true, .mmcimask1 = true, .start_err = true, + .opendrain = true, }; static struct variant_data variant_ux500 = { @@ -207,6 +215,7 @@ struct variant_data { .pwrreg_nopower = true, .mmcimask1 = true, .start_err = true, + .opendrain = true, }; static struct variant_data variant_ux500v2 = { @@ -233,6 +242,7 @@ struct variant_data { .pwrreg_nopower = true, .mmcimask1 = true, .start_err = true, + .opendrain = true, }; static struct variant_data variant_qcom = { @@ -253,6 +263,7 @@ struct variant_data { .qcom_dml = true, .mmcimask1 = true, .start_err = true, + .opendrain = true, }; /* Busy detection for the ST Micro variant */ @@ -1394,9 +1405,11 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) { struct mmci_host *host = mmc_priv(mmc); struct variant_data *variant = host->variant; + struct pinctrl_state *pins; u32 pwr = 0; unsigned long flags; int ret; + bool is_opendrain; if (host->plat->ios_handler && host->plat->ios_handler(mmc_dev(mmc), ios)) @@ -1455,16 +1468,31 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) ~MCI_ST_DATA2DIREN); } - if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) { - if (host->hw_designer != AMBA_VENDOR_ST) - pwr |= MCI_ROD; - else { - /* - * The ST Micro variant use the ROD bit for something - * else and only has OD (Open Drain). - */ - pwr |= MCI_OD; + if (host->variant->opendrain) { + if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) { + if (host->hw_designer != AMBA_VENDOR_ST) { + pwr |= MCI_ROD; + } else { + /* + * The ST Micro variant use the ROD bit for + * something else and only has OD (Open Drain). + */ + pwr |= MCI_OD; + } } + } else { + /* + * If the variant cannot configure the pads by its own, then we + * expect the pinctrl to be able to do that for us + */ + is_opendrain = (ios->bus_mode == MMC_BUSMODE_OPENDRAIN); + pins = pinctrl_lookup_state(host->pinctrl, is_opendrain ? + MMCI_PINCTRL_STATE_OPENDRAIN : + MMCI_PINCTRL_STATE_PUSHPULL); + if (IS_ERR(pins)) + dev_warn(mmc_dev(mmc), "Cannot select pin drive type via pinctrl\n"); + else + pinctrl_select_state(host->pinctrl, pins); } /* @@ -1609,6 +1637,14 @@ static int mmci_probe(struct amba_device *dev, host = mmc_priv(mmc); host->mmc = mmc; + if (!variant->opendrain) { + host->pinctrl = devm_pinctrl_get(&dev->dev); + if (IS_ERR(host->pinctrl)) { + dev_err(&dev->dev, "failed to get pinctrl"); + goto host_free; + } + } + host->hw_designer = amba_manf(dev); host->hw_revision = amba_rev(dev); dev_dbg(mmc_dev(mmc), "designer ID = 0x%02x\n", host->hw_designer); diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h index 83160a9..de3d0b3 100644 --- a/drivers/mmc/host/mmci.h +++ b/drivers/mmc/host/mmci.h @@ -192,6 +192,10 @@ #define NR_SG 128 +/* pinctrl configs */ +#define MMCI_PINCTRL_STATE_PUSHPULL "default" +#define MMCI_PINCTRL_STATE_OPENDRAIN "opendrain" + struct clk; struct variant_data; struct dma_chan; @@ -227,6 +231,7 @@ struct mmci_host { bool vqmmc_enabled; struct mmci_platform_data *plat; struct variant_data *variant; + struct pinctrl *pinctrl; u8 hw_designer; u8 hw_revision:4;