Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp852771ybz; Wed, 22 Apr 2020 09:06:25 -0700 (PDT) X-Google-Smtp-Source: APiQypI6gUZ0kJOWzNj8excy44cgkv37MeAAHFIsoVPnNuaUkV9FEBTlrOBZJ1gQNgGrmpZBr5Wx X-Received: by 2002:aa7:d514:: with SMTP id y20mr24305329edq.28.1587571585148; Wed, 22 Apr 2020 09:06:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587571585; cv=none; d=google.com; s=arc-20160816; b=TTHNXdWcGfRGHjp8JglrIGF1eOlEXo2OTEp6s5+Q2QIPSbmIWjINKjk+e8MRI+flXe gNYWbjZ6Iwe0PWcRUl5qzF9OActFlGth/nReiLLqkuoSRON9JeWbm0y2S/XbHtXkbS8o +JLuzfX05BAQP/7W+kho5ymb4auWv24DHGZ05eKakdMhKluKpD4otP93SKWjas0RsLHQ aNvcSSvitHZ9MnmlLtyKAvbznxjFF/XIHbQeyebkKQkcgcv3qlYbO/7qwYNkaZ4qKP6g H2Fgt4dGEiYmbXx3qpGX7u26ATKx8F+N8KEpIepYiRi4LdEZrtsZEu0fWrMdsL6jYlKO 9Hyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=R6uBiNfit5YCO191/wwIsaUUqzxSLO/g5l1s37v3Z3w=; b=EReGMQKhYm0377pPjeAjVyr0vuNYa+IYPcjY7Qj9hp12CZUaYp5X3MmqpJx6fp1yv8 2TCp5v6gWVuZRv0GNFYgjvZF1ZAm6o8bhdoDCuuKqZ5BSdQo24s0QE337pO2aitdv87Z GinzhE70HHbmvGZy17ZtPHnmDd8uJyPqFMS2C6U4Q0vRxcIvMs2pGrUs589i/1TFQVSH t58c5RHQBzxvA+brWXxzufPdO7tPUizUIEZEzLeNPS8eCMWgHdi4eJepKSM9nhbyd1Lq NYxS652Do8DzrPcgDTiq9kjgGoFI2F+ld1E8pdYe3dV/RyvkiC9l8RvSargjQELayQlV ZEBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q91bHmJw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si3610234ejv.401.2020.04.22.09.06.00; Wed, 22 Apr 2020 09:06:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q91bHmJw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726421AbgDVQE1 (ORCPT + 99 others); Wed, 22 Apr 2020 12:04:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726358AbgDVQE0 (ORCPT ); Wed, 22 Apr 2020 12:04:26 -0400 Received: from mail-ua1-x941.google.com (mail-ua1-x941.google.com [IPv6:2607:f8b0:4864:20::941]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D581C03C1AB for ; Wed, 22 Apr 2020 09:04:26 -0700 (PDT) Received: by mail-ua1-x941.google.com with SMTP id y10so2184929uao.8 for ; Wed, 22 Apr 2020 09:04:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=R6uBiNfit5YCO191/wwIsaUUqzxSLO/g5l1s37v3Z3w=; b=Q91bHmJwQtHKONLOIZVoVWCWA8wv4FJ6D+5JbGFlH88Y+/P8I6LlZJbyat1zNpYnaf r9JaIC2uFsoEs8V9fc21pNnrEnBTY0z4mPbLva9ly4DlnJCI1pxsfQi5Qf874n/YBWXp P6OzTz4nF2sutRlKNThQUqe+3ohrfIMiGWGbk/+l+YxGCV+2ATZ8bK8jV/D6rCN/17ja 05VW2Ria5KGkfQS3EngD394SpfJwwdv2/Ps+LXsLN29JPBGNyGewMdFTTABE14T4A4yC 4FASMLFN6kKn19Mg17U9anWakRdEGFgCyYqTvdEdi8pWvqQQpmzFhTBHb+r8UUDTIxGJ nqMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=R6uBiNfit5YCO191/wwIsaUUqzxSLO/g5l1s37v3Z3w=; b=eRwNH1L2+IhEwzb1Rc42EU7sgsjeIwSnl5P/wkCWSS4nflznnGTkEWa5RAVFFAHI6F J9SsN1CvvJcrX+FSpdhRAVfKgGBhWO4Cw6pD3pCTfifvxfLNPPlmXsmRCJp5x0aakb3q pAL+SZTufuCHMwXzqP+8nLTz1YrFCBYaS+XkSQ7XysSo4R+R042vC+B1qfc42tMmisN0 TV9YIKBuLJIkq/LS1wxPOebtd9YJf6ds/YhbF7ctU6GwU7q50aZ3GyzLk2uRt0FmVLGn vep5cZa/+Ef/xwPuqrCBwBW5adbGthazf5znfc2/d3YREQqeZmfgWGXQjfFzFGUTEM23 T6bw== X-Gm-Message-State: AGi0Puanp0V3Dgz8l6W7eL9JXc93LrV10LcghmrqPrchS9quZlcpzKts sMMnU7gBhbLtx1qUsUciWEBvAAhBOd9+vbOw1h2B3Q== X-Received: by 2002:a67:ead1:: with SMTP id s17mr20427811vso.200.1587571464862; Wed, 22 Apr 2020 09:04:24 -0700 (PDT) MIME-Version: 1.0 References: <20200420161831.5043-1-ludovic.barre@st.com> <1d9cefd1-aaed-1eb5-92f2-b1f45b4da2ac@st.com> In-Reply-To: <1d9cefd1-aaed-1eb5-92f2-b1f45b4da2ac@st.com> From: Ulf Hansson Date: Wed, 22 Apr 2020 18:03:48 +0200 Message-ID: Subject: Re: [PATCH] mmc: mmci_sdmmc: fix power on issue due to pwr_reg initialization To: Ludovic BARRE Cc: Rob Herring , Srini Kandagatla , Maxime Coquelin , Alexandre Torgue , Linux ARM , Linux Kernel Mailing List , DTML , "linux-mmc@vger.kernel.org" , linux-stm32@st-md-mailman.stormreply.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 22 Apr 2020 at 15:40, Ludovic BARRE wrote: > > hi Ulf > > Le 4/21/20 =C3=A0 11:38 AM, Ulf Hansson a =C3=A9crit : > > On Tue, 21 Apr 2020 at 11:25, Ulf Hansson wrot= e: > >> > >> On Mon, 20 Apr 2020 at 18:18, Ludovic Barre wro= te: > >>> > >>> This patch fix a power-on issue, and avoid to retry the power sequenc= e. > >>> > >>> In power off sequence: sdmmc must set pwr_reg in "power-cycle" state > >>> (value 0x2), to prevent the card from being supplied through the sign= al > >>> lines (all the lines are driven low). > >>> > >>> In power on sequence: when the power is stable, sdmmc must set pwr_re= g > >>> in "power-off" state (value 0x0) to drive all signal to high before t= o > >>> set "power-on". > >> > >> Just a question to gain further understanding. > >> > >> Let's assume that the controller is a power-on state, because it's > >> been initialized by the boot loader. When the mmc core then starts the > >> power-on sequence (not doing a power-off first), would $subject patch > >> then cause the > >> MMCIPOWER to remain as is, or is it going to be overwritten? > > On sdmmc controller, the PWRCTRL[1:0] field of MMCIPOWER register allow > to manage sd lines and has a specific bahavior. > > PWRCTRL value: > - 0x0: After reset, Reset: the SDMMC is disabled and the clock to the > Card is stopped, SDMMC_D[7:0], and SDMMC_CMD are HiZ and > SDMMC_CK is driven low. > When written 00, power-off: the SDMMC is disabled and the clock > to the card is stopped, SDMMC_D[7:0], SDMMC_CMD and SDMMC_CK > are driven high. > > - 0x2: Power-cycle, the SDMMC is disabled and the clock to the card is > stopped, SDMMC_D[7:0], SDMMC_CMD and SDMMC_CK are driven low. > > - 0x3: Power-on: the card is clocked, The first 74 SDMMC_CK cycles the > SDMMC is still disabled. After the 74 cycles the SDMMC is > enabled and the SDMMC_D[7:0], SDMMC_CMD and SDMMC_CK are > controlled according the SDMMC operation. > **Any further write will be ignored, PWRCTRL value > will keep 0x3**. when the SDMMC is ON (0x3) only a reset could > change pwrctrl value and the state of sdmmc lines. > > So if the lines are already "ON", the power-on sequence (decribed in > commit message) not overwrite the pwctrl field and not disturb the sdmmc > lines. Thanks for the detailed information, much appreciated! > > >> > >> I am a little worried that we may start to rely on boot loader > >> conditions, which isn't really what we want either... > >> > > We not depend of boot loader conditions. > > This patch simply allows to drive high the sd lines before to set > "power-on" value (no effect if already power ON). Yep, thanks! > > >>> > >>> To avoid writing the same value to the power register several times, = this > >>> register is cached by the pwr_reg variable. At probe pwr_reg is initi= alized > >>> to 0 by kzalloc of mmc_alloc_host. > >>> > >>> Like pwr_reg value is 0 at probing, the power on sequence fail becaus= e > >>> the "power-off" state is not writes (value 0x0) and the lines > >>> remain drive to low. > >>> > >>> This patch initializes "pwr_reg" variable with power register value. > >>> This it done in sdmmc variant init to not disturb default mmci behavi= or. > >>> > >>> Signed-off-by: Ludovic Barre > >> > >> Besides the comment, the code and the approach seems reasonable to me. > > > > Another related question. I just realized why you probably haven't set > > .pwrreg_nopower for the variant_stm32_sdmmc and variant_stm32_sdmmcv2. > > > > I guess it's because you need a slightly different way to restore the > > context of MMCIPOWER register at ->runtime_resume(), rather than just > > re-writing it with the saved register values. Is this something that > > you are looking into as well? > > Yes exactly, the sequence is slightly different. I can't write 0 on > mmci_runtime_suspend, and can't just re-writing the saved register. So, it seems like you need to use the ->set_ios() callback, to re-configure the controller correctly. Just tell if you need more help to make that work, otherwise I am here to review your patches. In regards to $subject patch, I have applied it for next, thanks! Kind regards Uffe