From patchwork Thu Mar 9 15:18:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 9613545 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 1E036604D9 for ; Thu, 9 Mar 2017 15:31:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F22AF284C9 for ; Thu, 9 Mar 2017 15:31:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E52AB28675; Thu, 9 Mar 2017 15:31:26 +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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham 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 713F3284C9 for ; Thu, 9 Mar 2017 15:31:26 +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: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:In-Reply-To: References:List-Owner; bh=ujCJCrWnYLMbcHrvcNRbul41dkzRgALcz4xVrSTrghg=; b=HOb 2NrmUlhLrAuoLEcKdw/MAZllZhfMsxtQWGDi7Dt5fE+4N8+q1tw6FZxIK71y6UE/+6aEhwNjBvLZ/ WvGMphxj6/OHb4h7SZgb2r8oSRcyuPFh3bjPRh5k1IfQMt1tNokS003uSAq0ezoHgz907cBXiV2KO 8+DzufM1kD04Q4M8Cf1jUsE59FUIuxY/F2STuiI7oZCMmNvqm9BO4EgNrMenFcMZoYa5YQO+QbqoS Q6qp1TAEo+LK1EqeRl6SNeYVlxnIJnS2czKr/xfGa/7q52xfmQc4VUkpRQ6mvgL84jsmqHu9IO2js g7YHMrIB6w377BKrRk8dKGiWLVWz4vg==; 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 1cm02F-00045y-Qr; Thu, 09 Mar 2017 15:31:23 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cm01W-0003Wq-16 for linux-arm-kernel@bombadil.infradead.org; Thu, 09 Mar 2017 15:30:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=7WSvoSliuqAbdlkOxd1DjTuegl/vwil92lbHUnZG9mc=; b=CJ0mIZATUMSU2AOvXrECVJwVV k+dtH24+9cVF8wxgtg7PSVUBt/oE2alvYKClRRhR7yJHQT1CcPV9EeIXe8US03VXyrRoDBTmqC/sv tstbPwKgcDq+0tdVlVsY78+yzo7LLUMJI6aPuuT0imlbYuU+Riw7Yaa3Z9uxAdRbW76/YBFl3xNtF yispKKm+eUFr2+FTVQtd693FpgG+zbHpAjm5X591zrGsVcEeLhY6eQojZOBBBxraXkeLrtAnnJz6o 4Yb8GPzGKe+OaUA8fVqZFt0nW5zwThS7kTadjnKPFLt7GaJZx+gCaFphIRz27saoKw6wItlRkb6MH hQSTDb+Tg==; Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1clzq9-0006OY-P4 for linux-arm-kernel@lists.infradead.org; Thu, 09 Mar 2017 15:18:55 +0000 Received: by mail-wm0-x241.google.com with SMTP id u132so11438873wmg.1 for ; Thu, 09 Mar 2017 07:18:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=7WSvoSliuqAbdlkOxd1DjTuegl/vwil92lbHUnZG9mc=; b=Guju8RFJzu+TEAicI1jzMZjaHIn635yUCPAXdEiFsEXnbY6sQsQZ/OrYwDrO2JYAHK q5pimnqHCb7RVPqtnNDzgySRDEFGf2ecys70ez4T9qrUzHWf8zrx3xYedIEQW1s0miAP TStBF22rvvZn/zVel89M+MumRrFuF0NW0l4ztIx4MMidQdhvz1NebK2Imhc0ADBXEBJH 5WVxlkXWmjK4Mm63Afc502SOxYZxZQZwq6x8UxlRgH0huI09efIKwgV6wVB5X9mR5WU4 1UTUxQqJ5/lJM3iAag4PS+AUSSgBRmrzvS+0kGUpJPK4dMOuZbXdVnQaDyVMXbCAd5k0 2tdg== 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; bh=7WSvoSliuqAbdlkOxd1DjTuegl/vwil92lbHUnZG9mc=; b=MxXxtTZXDboYIylv/5DhfprsTk5TSDZAAkJA+lioySK+RDBlAq6Zw8G1GEbdD6trOT dAg7DFL/bI0f/pqLzw/lXi+Z2hoSXVNP0GbITMUyzY2N8PKZkcRwra4nR77pmUMHZkNn hIH8oPUlLccm62TDrmpopKPs5TjXgToC3jfVAB1SkCn/FVViA6Vxb8+I19A7uKOhimAJ Mv2/mLHZ20CHYoRV7d4tDYDHKCsVbEsty5Ifrx1LUK2xwbOFgVPHaA/+BSZH+DS498jx 0J1DGU5sJLC6Blr6cGqlahrYM0/wPJKEa5rowoegsLiuPiuVpLzTJVCQchKfqZi61B8w hmJA== X-Gm-Message-State: AMke39mBBHifNoQamuyCS/Fv8W67z+HIFmqpg4+W5qHMDdgL92B5jHJmcCM5RLPpZXjAmw== X-Received: by 10.28.182.10 with SMTP id g10mr29315167wmf.123.1489072712146; Thu, 09 Mar 2017 07:18:32 -0800 (PST) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id n59sm8634092wrb.54.2017.03.09.07.18.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 07:18:31 -0800 (PST) From: Romain Izard To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mmc@vger.kernel.org, Ludovic Desroches , Adrian Hunter , Ulf Hansson Subject: [PATCH] mmc: sdhci-of-at91: Support external regulators Date: Thu, 9 Mar 2017 16:18:20 +0100 Message-Id: <20170309151820.7510-1-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.9.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170309_151853_844408_2DA3B09D X-CRM114-Status: GOOD ( 15.61 ) 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: Romain Izard 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 The SDHCI controller in the SAMA5D2 chip requires a valid voltage set in the power control register, otherwise commands will fail with a timeout error. When using the regulator framework to specify the regulator used by the mmc device, the voltage is not configured, and it is not possible to use the connected device. Implement a custom 'set_power' function for this specific hardware, that configures the voltage in the register in all cases. Signed-off-by: Romain Izard Acked-by: Ludovic Desroches --- drivers/mmc/host/sdhci-of-at91.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c index 2f9ad213377a..291a74955a4c 100644 --- a/drivers/mmc/host/sdhci-of-at91.c +++ b/drivers/mmc/host/sdhci-of-at91.c @@ -85,11 +85,30 @@ static void sdhci_at91_set_clock(struct sdhci_host *host, unsigned int clock) sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); } +/* + * In this specific implementation of the SDHCI contoller, the power register + * needs to have a valid voltage set even when the power supply is managed by + * an external regulator. + */ +static void sdhci_at91_set_power(struct sdhci_host *host, unsigned char mode, + unsigned short vdd) +{ + if (!IS_ERR(host->mmc->supply.vmmc)) { + struct mmc_host *mmc = host->mmc; + + spin_unlock_irq(&host->lock); + mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd); + spin_lock_irq(&host->lock); + } + sdhci_set_power_noreg(host, mode, vdd); +} + static const struct sdhci_ops sdhci_at91_sama5d2_ops = { .set_clock = sdhci_at91_set_clock, .set_bus_width = sdhci_set_bus_width, .reset = sdhci_reset, .set_uhs_signaling = sdhci_set_uhs_signaling, + .set_power = sdhci_at91_set_power, }; static const struct sdhci_pltfm_data soc_data_sama5d2 = {