From patchwork Fri Aug 18 05:19:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijay Viswanath X-Patchwork-Id: 9907643 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 0103960385 for ; Fri, 18 Aug 2017 05:23:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6D1428C45 for ; Fri, 18 Aug 2017 05:23:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB90128C47; Fri, 18 Aug 2017 05:23:29 +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=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW 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 8442528C45 for ; Fri, 18 Aug 2017 05:23:29 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=dd0G84o2eL9XZCpc63jZ9qKD3FIsGQ99EARBvod+YNA=; b=r7fbc7q2SJ41aRJjsffGOjCzzo hRD9LrAx/ehs2V6NM9gR6VH2M05cJKuxSrN5rqQrVFO+PssFfp15fKplLuWK8oIPi2vbNBzAcoTMa d30bw1N1XeWzG6g8a2dvrAexqfcebx0llDQX53xmZLl855oeqCw5ObsuVklQ+gstdoyCJArRyhaqq kDrSqQkWC+2ymTx5emusiG3K7WOX0QUDtq7R4kg9p1NxBPgL+F+1aIVszjsnEIysg3/GkH5d0adad 5hwG3PNRMDGP5bOzm1Ux8bGzpN+DVn1Zgh3FBQp/lGY7mtyMV4/ed0RR0Ej8JeSgFKMJ3//KarJD9 S9xFY8iQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1diZki-0006iw-Oz; Fri, 18 Aug 2017 05:23:24 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1diZim-0005Ty-7d for linux-arm-kernel@lists.infradead.org; Fri, 18 Aug 2017 05:21:26 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 92C186044E; Fri, 18 Aug 2017 05:21:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1503033664; bh=nvlxRyElMg4eMxC1Far7XhqNzmBXIRLQBJH/KZ82PT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oFiuW68JbfRGkaxNKRY+aoF7EmRZ8+Ms50yE4rfUXECRUSo3Rw89EaFuAurDVOXL3 HaGoq8gE/VLyOY+SAPuBViAMow9tlxdAnX2vV5CeJQG0yhh/W7Vohz7w2eU2vRW4Q8 /A7CEhhOp5Xeg+0E2W7vt1ep9J/TDYsW5HJCHShg= Received: from hydcbspbld03.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vviswana@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id E7D3C60618; Fri, 18 Aug 2017 05:20:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1503033663; bh=nvlxRyElMg4eMxC1Far7XhqNzmBXIRLQBJH/KZ82PT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cHdwFvgilXVy9W8/braSKDyeFRPnBhXayz1vwe/LoYNE9ieJxjeiJQAlagtWYAgZS Y9RyE3XaXmbNPTJIy/lkTYrZ6g3OZzfY0PNmPs7g8D6iuccEYkJOz7ilQRl06hbWuh t+28FIsDI5krZqaL6FoLukBVTYXl0fUEasYJaiIU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E7D3C60618 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vviswana@codeaurora.org From: Vijay Viswanath To: adrian.hunter@intel.com, ulf.hansson@linaro.org, will.deacon@arm.com Subject: [PATCH 4/5] mmc: sdhci-msm: Add ops to do sdhc register write Date: Fri, 18 Aug 2017 10:49:41 +0530 Message-Id: <1503033582-48703-5-git-send-email-vviswana@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503033582-48703-1-git-send-email-vviswana@codeaurora.org> References: <1503033582-48703-1-git-send-email-vviswana@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170817_222124_470478_82E0D334 X-CRM114-Status: GOOD ( 13.96 ) 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: riteshh@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Vijay Viswanath , stummala@codeaurora.org, subhashj@codeaurora.org, linux-arm-kernel@lists.infradead.org, asutoshd@codeaurora.org MIME-Version: 1.0 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 Register writes which change voltage of IO lines or turn the IO bus on/off require controller to be ready before progressing further. When the controller is ready, it will generate a power irq which needs to be handled. The thread which initiated the register write should wait for power irq to complete. This will be done through the new sdhc msm write APIs which will check whether the particular write can trigger a power irq and wait for it with a timeout if it is expected. The SDHC core power control IRQ gets triggered when - * There is a state change in power control bit (bit 0) of SDHCI_POWER_CONTROL register. * There is a state change in 1.8V enable bit (bit 3) of SDHCI_HOST_CONTROL2 register. * Bit 1 of SDHCI_SOFTWARE_RESET is set. Signed-off-by: Vijay Viswanath --- drivers/mmc/host/sdhci-msm.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index 6d3b1fd..6571880 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -1250,6 +1250,41 @@ static void sdhci_msm_set_clock(struct sdhci_host *host, unsigned int clock) __sdhci_msm_set_clock(host, clock); } +#ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS +static void __sdhci_msm_check_write(struct sdhci_host *host, u16 val, int reg) +{ + u32 req_type = 0; + + switch (reg) { + case SDHCI_HOST_CONTROL2: + req_type = (val & SDHCI_CTRL_VDD_180) ? REQ_IO_LOW : + REQ_IO_HIGH; + break; + case SDHCI_SOFTWARE_RESET: + if (host->pwr && (val & SDHCI_RESET_ALL)) + req_type = REQ_BUS_OFF; + break; + case SDHCI_POWER_CONTROL: + req_type = !val ? REQ_BUS_OFF : REQ_BUS_ON; + break; + } + + if (req_type) + sdhci_msm_check_power_status(host, req_type); +} + +static void sdhci_msm_writew(struct sdhci_host *host, u16 val, int reg) +{ + writew_relaxed(val, host->ioaddr + reg); + __sdhci_msm_check_write(host, val, reg); +} + +static void sdhci_msm_writeb(struct sdhci_host *host, u8 val, int reg) +{ + writeb_relaxed(val, host->ioaddr + reg); + __sdhci_msm_check_write(host, val, reg); +} +#endif static const struct of_device_id sdhci_msm_dt_match[] = { { .compatible = "qcom,sdhci-msm-v4" }, {}, @@ -1264,6 +1299,10 @@ static void sdhci_msm_set_clock(struct sdhci_host *host, unsigned int clock) .get_max_clock = sdhci_msm_get_max_clock, .set_bus_width = sdhci_set_bus_width, .set_uhs_signaling = sdhci_msm_set_uhs_signaling, +#ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS + .write_w = sdhci_msm_writew, + .write_b = sdhci_msm_writeb, +#endif }; static const struct sdhci_pltfm_data sdhci_msm_pdata = {