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: 9613519 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 51415602B4 for ; Thu, 9 Mar 2017 15:18:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E38E28113 for ; Thu, 9 Mar 2017 15:18:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 306F62852A; Thu, 9 Mar 2017 15:18:36 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 D5E6128113 for ; Thu, 9 Mar 2017 15:18:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932226AbdCIPSf (ORCPT ); Thu, 9 Mar 2017 10:18:35 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:33114 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754933AbdCIPSe (ORCPT ); Thu, 9 Mar 2017 10:18:34 -0500 Received: by mail-wm0-f67.google.com with SMTP id n11so11459894wma.0; Thu, 09 Mar 2017 07:18:32 -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=PDk/NobziVQdUwCCWC1S/BodrM3dfBtxzv3ZvgXxd4Gfhq6qknMderC9ZVAOUHRk1F yKRAC7+chtCnhG+KM3OFkSUMoxefaLS8ZDkye7NG92Pbg8oNPm5iq8oJOyg0I5opxYb6 PMUzdANM7QfQ3DZjOW+2LqYsJlJYbxJi+5D7LXx2JnCO0qvudyGbNpnyc7TQM8vRXlfA NQBal0N8avCmDBY4D7YENAg+IRHdc8dFGlGvLTfXnCbK5PJ/yYPcECvX0Z/xkIkkwBMh QizNYkjODb24g/ijBrjBMauBe14ARrlQz+wK0LeuApO+gz/Vkziy5YgXw7fzfrUHwuMG Cfgw== X-Gm-Message-State: AMke39kLdjjHpdepPEZTlWGXnnAmmla7/7byqCrAmLM9OwNJY4xbYJUjHZWaAS5xMvt9Zw== 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 Cc: Romain Izard 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 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 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 = {