Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp766354ybz; Wed, 22 Apr 2020 07:38:22 -0700 (PDT) X-Google-Smtp-Source: APiQypI18wEqqyBQHtWqnywLQApJ0c3Cmeq1sPQ4oZbLlUqUO+zDb8Lybh3yZXa9JuDWtCO9IqrP X-Received: by 2002:a17:906:b7da:: with SMTP id fy26mr27177608ejb.327.1587566302013; Wed, 22 Apr 2020 07:38:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587566302; cv=none; d=google.com; s=arc-20160816; b=l9jHfTVC77b5ydVHu62ljXF5IVubC3ZlYuz7kcvi0sGwqhVxWJn+mPj0xzvAQdyYvN /96wBfEu3Qk5iIMywyOvQG/GKznzOifLnK6Db4s6Q6xe3Te/x4UkmfAu5WCMkqFYhoqh Q6ixJEMhtCMFEmqqCOvS45sK+hTbToYWIoeQcfTffzh3WzIddkefClpYVmDo8/mV3goC l8iRhw2GHzMnO9Mvvqx4sUaofaMsQttWG8YeWxJttERgkRyXQXnGkSaYHpFcan2ykdag K3wDAkRn17gMSHFy+Zb6K52PuJgps6zURrLbZWXq545DCAYTR/A36mx1FJgI/GIacPe0 4gRg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=ZeG5MEBElFGxvDwVRDIezNZHBbeSXf35WjhoaaZsj6A=; b=j9SBFFZBY7+vcvtDYw3vZhUKOe5na7iQtytYOfPH1qiJ1J3lWiVsRNCHjQl3kv5X9s vJ5Lwhr7Pljo/dbhLJK8OdLXRBU6YUqUSx9KJjDUBT5zGR5yAG4+hE7d8SYadX/joiG4 2MhZIL0k55Skcak/MJetBBCpOA7XjKxuH2vLj+bt07LsFG4LXr3508+QbS+Qoz6JMqVf ZuXloQCUrizVNjYbA3GOHezMyBCFAcb/3em3ALvgbpxRqYZizMkrbQSSwLDuj2Y2u+G5 kw4jy1bPayGjbgRg6I6YD2oq/OHHmwgyJGwI7b4Y9uAIY47ORutswbPMBZqc9TsH88V4 Ommg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=jO+y+5a3; 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=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bd12si3370099edb.506.2020.04.22.07.37.57; Wed, 22 Apr 2020 07:38:21 -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=@st.com header.s=STMicroelectronics header.b=jO+y+5a3; 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=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726829AbgDVNkm (ORCPT + 99 others); Wed, 22 Apr 2020 09:40:42 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:36246 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726158AbgDVNkl (ORCPT ); Wed, 22 Apr 2020 09:40:41 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03MDcOSJ007859; Wed, 22 Apr 2020 15:40:09 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=STMicroelectronics; bh=ZeG5MEBElFGxvDwVRDIezNZHBbeSXf35WjhoaaZsj6A=; b=jO+y+5a32gAoEFM1QqBzK5iYTjSmrs7P8SuFYvtFR+W3OnGhd/4Gp2BDA+qrlTFbFTsJ BMn/lRxiRcbFnqblJhnf66LRE9O5sRx/AVwyDw4vAR9QnnI8f45cuFdhMWDmbuTrSvve r/QZ4eDjlMGNpiKxrPC7aMnHM/XUFDgUpURhbDLJNeg8kMRXvtNWCChZlPVwjRhCPwLr KsSAgre6hLBCL0tCNVVJTIRtjNULSb8E/g+FBEyovrkI4Gbgb3I/NKjZJhC+/UFoC6pi x+VoUY4+cq/cYppqFIlXllWqSMXhqt1SgXCeVltwpvaV7u0MUR8TDZYQ3JqT1dXmpTRW og== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30fregpq4d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Apr 2020 15:40:09 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 951D310002A; Wed, 22 Apr 2020 15:40:07 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag6node1.st.com [10.75.127.16]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 8015C2B1889; Wed, 22 Apr 2020 15:40:07 +0200 (CEST) Received: from lmecxl0923.lme.st.com (10.75.127.44) by SFHDAG6NODE1.st.com (10.75.127.16) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 22 Apr 2020 15:40:06 +0200 Subject: Re: [PATCH] mmc: mmci_sdmmc: fix power on issue due to pwr_reg initialization To: Ulf Hansson CC: Rob Herring , Srini Kandagatla , Maxime Coquelin , Alexandre Torgue , Linux ARM , Linux Kernel Mailing List , DTML , "linux-mmc@vger.kernel.org" , References: <20200420161831.5043-1-ludovic.barre@st.com> From: Ludovic BARRE Message-ID: <1d9cefd1-aaed-1eb5-92f2-b1f45b4da2ac@st.com> Date: Wed, 22 Apr 2020 15:40:05 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG3NODE1.st.com (10.75.127.7) To SFHDAG6NODE1.st.com (10.75.127.16) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-22_06:2020-04-22,2020-04-22 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hi Ulf Le 4/21/20 à 11:38 AM, Ulf Hansson a écrit : > On Tue, 21 Apr 2020 at 11:25, Ulf Hansson wrote: >> >> On Mon, 20 Apr 2020 at 18:18, Ludovic Barre wrote: >>> >>> This patch fix a power-on issue, and avoid to retry the power sequence. >>> >>> In power off sequence: sdmmc must set pwr_reg in "power-cycle" state >>> (value 0x2), to prevent the card from being supplied through the signal >>> lines (all the lines are driven low). >>> >>> In power on sequence: when the power is stable, sdmmc must set pwr_reg >>> in "power-off" state (value 0x0) to drive all signal to high before to >>> 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. >> >> 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). >>> >>> 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 initialized >>> to 0 by kzalloc of mmc_alloc_host. >>> >>> Like pwr_reg value is 0 at probing, the power on sequence fail because >>> 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 behavior. >>> >>> 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. Regards Ludo > > [...] > > Kind regards > Uffe >